@galacean/effects-helper 2.0.0-alpha.32 → 2.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertExist } from '@galacean/effects';
|
|
1
2
|
import { getImageFileContent, loadMipmaps } from './utils';
|
|
2
3
|
const TextureSourceTypeImage = 2;
|
|
3
4
|
/**
|
|
@@ -43,6 +44,7 @@ export async function serializeTextures(textureOptions) {
|
|
|
43
44
|
}
|
|
44
45
|
const job = async () => {
|
|
45
46
|
const buffer = await imageBufferSet.get(url);
|
|
47
|
+
assertExist(buffer);
|
|
46
48
|
imageMap.set(texture, buffer);
|
|
47
49
|
return buffer;
|
|
48
50
|
};
|
|
@@ -62,6 +64,7 @@ export async function serializeTextures(textureOptions) {
|
|
|
62
64
|
const texture = textureOptions[i];
|
|
63
65
|
if (texture.target === WebGLRenderingContext.TEXTURE_CUBE_MAP) {
|
|
64
66
|
const info = cubeMap.get(texture);
|
|
67
|
+
assertExist(info);
|
|
65
68
|
bins.push(info.data);
|
|
66
69
|
tex = { ...texture, ...{ mipmaps: info.mipmaps, sourceType: 7 } };
|
|
67
70
|
if ('cube' in tex) {
|
|
@@ -70,6 +73,7 @@ export async function serializeTextures(textureOptions) {
|
|
|
70
73
|
}
|
|
71
74
|
else {
|
|
72
75
|
const buffer = imageMap.get(texture);
|
|
76
|
+
assertExist(buffer);
|
|
73
77
|
tex = { ...texture, ...{ source: images.indexOf(buffer) } };
|
|
74
78
|
if ('mipmaps' in tex) {
|
|
75
79
|
// @ts-expect-error
|
package/dist/serialize/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spec } from '@galacean/effects';
|
|
1
|
+
import { assertExist, spec } from '@galacean/effects';
|
|
2
2
|
export async function loadMipmaps(textureOptions, dataIndex) {
|
|
3
3
|
const { mipmaps } = textureOptions;
|
|
4
4
|
const { cube } = textureOptions;
|
|
@@ -47,8 +47,12 @@ export async function getImageFileContent(image) {
|
|
|
47
47
|
export function concatBuffers(buffers, bufferInfo, length) {
|
|
48
48
|
const ret = new Uint8Array(length);
|
|
49
49
|
buffers.forEach(buffer => {
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const info = bufferInfo.get(buffer);
|
|
51
|
+
assertExist(info);
|
|
52
|
+
const [, offset, byteLength] = info;
|
|
53
|
+
const source = buffer instanceof ArrayBuffer ?
|
|
54
|
+
new Uint8Array(buffer, 0, byteLength) :
|
|
55
|
+
new Uint8Array(buffer.buffer, buffer.byteOffset, byteLength);
|
|
52
56
|
ret.set(source, offset);
|
|
53
57
|
});
|
|
54
58
|
return ret.buffer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/effects-helper",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.34",
|
|
4
4
|
"description": "Galacean Effects runtime helper for the web",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"registry": "https://registry.npmjs.org"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@galacean/effects": "2.0.0-alpha.
|
|
31
|
+
"@galacean/effects": "2.0.0-alpha.34"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"prebuild": "pnpm clean",
|