@galacean/engine-loader 1.1.0-beta.9 → 1.2.0-alpha.1
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.
- package/dist/main.js +863 -487
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +862 -487
- package/dist/module.js +852 -477
- package/dist/module.js.map +1 -1
- package/package.json +4 -5
- package/types/GLTFLoader.d.ts +8 -1
- package/types/Texture2DLoader.d.ts +9 -1
- package/types/gltf/GLTFResource.d.ts +50 -16
- package/types/gltf/GLTFSchema.d.ts +1 -1
- package/types/gltf/GLTFUtils.d.ts +1 -1
- package/types/gltf/extensions/EXT_meshopt_compression.d.ts +13 -0
- package/types/gltf/extensions/GLTFExtensionParser.d.ts +1 -1
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +18 -10
- package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
- package/types/gltf/extensions/MeshoptDecoder.d.ts +8 -0
- package/types/gltf/extensions/index.d.ts +2 -1
- package/types/gltf/index.d.ts +2 -1
- package/types/gltf/parser/GLTFBufferViewParser.d.ts +5 -0
- package/types/gltf/parser/GLTFParser.d.ts +1 -1
- package/types/gltf/parser/GLTFParserContext.d.ts +24 -8
- package/types/gltf/parser/GLTFSceneParser.d.ts +0 -1
- package/types/gltf/parser/index.d.ts +2 -1
- package/types/index.d.ts +2 -1
- package/types/ktx2/KTX2Loader.d.ts +20 -8
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +1 -1
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +2 -0
- package/types/resource-deserialize/resources/schema/MaterialSchema.d.ts +1 -1
- package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +3 -1
- package/types/resource-deserialize/utils/BufferReader.d.ts +1 -1
package/dist/main.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var engineCore = require('@galacean/engine-core');
|
|
6
6
|
var engineMath = require('@galacean/engine-math');
|
|
7
7
|
var engineRhiWebgl = require('@galacean/engine-rhi-webgl');
|
|
8
|
-
var engineDraco = require('@galacean/engine-draco');
|
|
9
8
|
|
|
10
9
|
function _extends() {
|
|
11
10
|
_extends = Object.assign || function assign(target) {
|
|
@@ -120,116 +119,116 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
120
119
|
this.data = data;
|
|
121
120
|
this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength != null ? byteLength : data.byteLength - byteOffset);
|
|
122
121
|
this._littleEndian = littleEndian;
|
|
123
|
-
this.
|
|
122
|
+
this._position = 0;
|
|
124
123
|
this._baseOffset = byteOffset;
|
|
125
124
|
}
|
|
126
125
|
var _proto = BufferReader.prototype;
|
|
127
126
|
_proto.nextUint8 = function nextUint8() {
|
|
128
|
-
var value = this._dataView.getUint8(this.
|
|
129
|
-
this.
|
|
127
|
+
var value = this._dataView.getUint8(this._position);
|
|
128
|
+
this._position += 1;
|
|
130
129
|
return value;
|
|
131
130
|
};
|
|
132
131
|
_proto.nextUint16 = function nextUint16() {
|
|
133
|
-
var value = this._dataView.getUint16(this.
|
|
134
|
-
this.
|
|
132
|
+
var value = this._dataView.getUint16(this._position, this._littleEndian);
|
|
133
|
+
this._position += 2;
|
|
135
134
|
return value;
|
|
136
135
|
};
|
|
137
136
|
_proto.nextUint32 = function nextUint32() {
|
|
138
|
-
var value = this._dataView.getUint32(this.
|
|
139
|
-
this.
|
|
137
|
+
var value = this._dataView.getUint32(this._position, this._littleEndian);
|
|
138
|
+
this._position += 4;
|
|
140
139
|
return value;
|
|
141
140
|
};
|
|
142
141
|
_proto.nextInt32 = function nextInt32() {
|
|
143
|
-
var value = this._dataView.getInt32(this.
|
|
144
|
-
this.
|
|
142
|
+
var value = this._dataView.getInt32(this._position, this._littleEndian);
|
|
143
|
+
this._position += 4;
|
|
145
144
|
return value;
|
|
146
145
|
};
|
|
147
146
|
_proto.nextInt32Array = function nextInt32Array(len) {
|
|
148
|
-
var value = new Int32Array(this.data.buffer, this.
|
|
149
|
-
this.
|
|
147
|
+
var value = new Int32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
148
|
+
this._position += 4 * len;
|
|
150
149
|
return value;
|
|
151
150
|
};
|
|
152
151
|
_proto.nextFloat32 = function nextFloat32() {
|
|
153
|
-
var value = this._dataView.getFloat32(this.
|
|
154
|
-
this.
|
|
152
|
+
var value = this._dataView.getFloat32(this._position, this._littleEndian);
|
|
153
|
+
this._position += 4;
|
|
155
154
|
return value;
|
|
156
155
|
};
|
|
157
156
|
_proto.nextFloat32Array = function nextFloat32Array(len) {
|
|
158
|
-
var value = new Float32Array(this.data.buffer, this.
|
|
159
|
-
this.
|
|
157
|
+
var value = new Float32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
158
|
+
this._position += 4 * len;
|
|
160
159
|
return value;
|
|
161
160
|
};
|
|
162
161
|
_proto.nextUint32Array = function nextUint32Array(len) {
|
|
163
|
-
var value = new Uint32Array(this.data.buffer, this.
|
|
164
|
-
this.
|
|
162
|
+
var value = new Uint32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
163
|
+
this._position += 4 * len;
|
|
165
164
|
return value;
|
|
166
165
|
};
|
|
167
166
|
_proto.nextUint8Array = function nextUint8Array(len) {
|
|
168
|
-
var value = new Uint8Array(this.data.buffer, this.
|
|
169
|
-
this.
|
|
167
|
+
var value = new Uint8Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
168
|
+
this._position += len;
|
|
170
169
|
return value;
|
|
171
170
|
};
|
|
172
171
|
_proto.nextUint64 = function nextUint64() {
|
|
173
|
-
var left = this._dataView.getUint32(this.
|
|
174
|
-
var right = this._dataView.getUint32(this.
|
|
172
|
+
var left = this._dataView.getUint32(this._position, this._littleEndian);
|
|
173
|
+
var right = this._dataView.getUint32(this._position + 4, this._littleEndian);
|
|
175
174
|
var value = left + Math.pow(2, 32) * right;
|
|
176
|
-
this.
|
|
175
|
+
this._position += 8;
|
|
177
176
|
return value;
|
|
178
177
|
};
|
|
179
178
|
_proto.nextStr = function nextStr() {
|
|
180
179
|
var strByteLength = this.nextUint16();
|
|
181
|
-
var uint8Array = new Uint8Array(this.data.buffer, this.
|
|
182
|
-
this.
|
|
180
|
+
var uint8Array = new Uint8Array(this.data.buffer, this._position + this._dataView.byteOffset, strByteLength);
|
|
181
|
+
this._position += strByteLength;
|
|
183
182
|
return engineCore.Utils.decodeText(uint8Array);
|
|
184
183
|
};
|
|
185
184
|
/**
|
|
186
185
|
* image data 放在最后
|
|
187
186
|
*/ _proto.nextImageData = function nextImageData(count) {
|
|
188
|
-
return new Uint8Array(this.data.buffer, this.data.byteOffset + this.
|
|
187
|
+
return new Uint8Array(this.data.buffer, this.data.byteOffset + this._position);
|
|
189
188
|
};
|
|
190
189
|
_proto.nextImagesData = function nextImagesData(count) {
|
|
191
190
|
var imagesLen = new Array(count);
|
|
192
191
|
// Start offset of Uint32Array should be a multiple of 4. ref: https://stackoverflow.com/questions/15417310/why-typed-array-constructors-require-offset-to-be-multiple-of-underlying-type-si
|
|
193
192
|
for(var i = 0; i < count; i++){
|
|
194
|
-
var len = this._dataView.getUint32(this.
|
|
193
|
+
var len = this._dataView.getUint32(this._position, this._littleEndian);
|
|
195
194
|
imagesLen[i] = len;
|
|
196
|
-
this.
|
|
195
|
+
this._position += 4;
|
|
197
196
|
}
|
|
198
197
|
var imagesData = [];
|
|
199
198
|
for(var i1 = 0; i1 < count; i1++){
|
|
200
199
|
var len1 = imagesLen[i1];
|
|
201
|
-
var buffer = new Uint8Array(this.data.buffer, this._dataView.byteOffset + this.
|
|
202
|
-
this.
|
|
200
|
+
var buffer = new Uint8Array(this.data.buffer, this._dataView.byteOffset + this._position, len1);
|
|
201
|
+
this._position += len1;
|
|
203
202
|
imagesData.push(buffer);
|
|
204
203
|
}
|
|
205
204
|
return imagesData;
|
|
206
205
|
};
|
|
207
206
|
_proto.skip = function skip(bytes) {
|
|
208
|
-
this.
|
|
207
|
+
this._position += bytes;
|
|
209
208
|
return this;
|
|
210
209
|
};
|
|
211
210
|
_proto.scan = function scan(maxByteLength, term) {
|
|
212
211
|
if (term === void 0) term = 0x00;
|
|
213
|
-
var byteOffset = this.
|
|
212
|
+
var byteOffset = this._position;
|
|
214
213
|
var byteLength = 0;
|
|
215
|
-
while(this._dataView.getUint8(this.
|
|
214
|
+
while(this._dataView.getUint8(this._position) !== term && byteLength < maxByteLength){
|
|
216
215
|
byteLength++;
|
|
217
|
-
this.
|
|
216
|
+
this._position++;
|
|
218
217
|
}
|
|
219
|
-
if (byteLength < maxByteLength) this.
|
|
218
|
+
if (byteLength < maxByteLength) this._position++;
|
|
220
219
|
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
|
221
220
|
};
|
|
222
221
|
_create_class(BufferReader, [
|
|
223
222
|
{
|
|
224
223
|
key: "position",
|
|
225
224
|
get: function get() {
|
|
226
|
-
return this.
|
|
225
|
+
return this._position;
|
|
227
226
|
}
|
|
228
227
|
},
|
|
229
228
|
{
|
|
230
229
|
key: "offset",
|
|
231
230
|
get: function get() {
|
|
232
|
-
return this.
|
|
231
|
+
return this._position + this._baseOffset;
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
234
|
]);
|
|
@@ -293,75 +292,74 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
|
|
|
293
292
|
var encodedMeshData = JSON.parse(jsonDataString);
|
|
294
293
|
// @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
|
|
295
294
|
encodedMeshData.bounds && modelMesh.bounds.copyFrom(encodedMeshData.bounds);
|
|
296
|
-
var offset = Math.ceil(bufferReader.offset / 4) * 4;
|
|
295
|
+
var offset = Math.ceil(bufferReader.offset / 4) * 4 + bufferReader.data.byteOffset;
|
|
297
296
|
var buffer = bufferReader.data.buffer;
|
|
298
|
-
var
|
|
299
|
-
var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset + byteOffset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
|
|
297
|
+
var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
|
|
300
298
|
var vertexCount = float32Array.length / 3;
|
|
301
299
|
var positions = float32ArrayToVector3(float32Array, vertexCount);
|
|
302
300
|
modelMesh.setPositions(positions);
|
|
303
301
|
if (encodedMeshData.normals) {
|
|
304
|
-
var float32Array1 = new Float32Array(buffer, encodedMeshData.normals.start + offset
|
|
302
|
+
var float32Array1 = new Float32Array(buffer, encodedMeshData.normals.start + offset, (encodedMeshData.normals.end - encodedMeshData.normals.start) / 4);
|
|
305
303
|
var normals = float32ArrayToVector3(float32Array1, vertexCount);
|
|
306
304
|
modelMesh.setNormals(normals);
|
|
307
305
|
}
|
|
308
306
|
if (encodedMeshData.uvs) {
|
|
309
|
-
var float32Array2 = new Float32Array(buffer, encodedMeshData.uvs.start + offset
|
|
307
|
+
var float32Array2 = new Float32Array(buffer, encodedMeshData.uvs.start + offset, (encodedMeshData.uvs.end - encodedMeshData.uvs.start) / 4);
|
|
310
308
|
modelMesh.setUVs(float32ArrayToVector2(float32Array2, vertexCount));
|
|
311
309
|
}
|
|
312
310
|
if (encodedMeshData.uv1) {
|
|
313
|
-
var float32Array3 = new Float32Array(buffer, encodedMeshData.uv1.start + offset
|
|
311
|
+
var float32Array3 = new Float32Array(buffer, encodedMeshData.uv1.start + offset, (encodedMeshData.uv1.end - encodedMeshData.uv1.start) / 4);
|
|
314
312
|
modelMesh.setUVs(float32ArrayToVector2(float32Array3, vertexCount), 1);
|
|
315
313
|
}
|
|
316
314
|
if (encodedMeshData.uv2) {
|
|
317
|
-
var float32Array4 = new Float32Array(buffer, encodedMeshData.uv2.start + offset
|
|
315
|
+
var float32Array4 = new Float32Array(buffer, encodedMeshData.uv2.start + offset, (encodedMeshData.uv2.end - encodedMeshData.uv2.start) / 4);
|
|
318
316
|
modelMesh.setUVs(float32ArrayToVector2(float32Array4, vertexCount), 2);
|
|
319
317
|
}
|
|
320
318
|
if (encodedMeshData.uv3) {
|
|
321
|
-
var float32Array5 = new Float32Array(buffer, encodedMeshData.uv3.start + offset
|
|
319
|
+
var float32Array5 = new Float32Array(buffer, encodedMeshData.uv3.start + offset, (encodedMeshData.uv3.end - encodedMeshData.uv3.start) / 4);
|
|
322
320
|
modelMesh.setUVs(float32ArrayToVector2(float32Array5, vertexCount), 3);
|
|
323
321
|
}
|
|
324
322
|
if (encodedMeshData.uv4) {
|
|
325
|
-
var float32Array6 = new Float32Array(buffer, encodedMeshData.uv4.start + offset
|
|
323
|
+
var float32Array6 = new Float32Array(buffer, encodedMeshData.uv4.start + offset, (encodedMeshData.uv4.end - encodedMeshData.uv4.start) / 4);
|
|
326
324
|
modelMesh.setUVs(float32ArrayToVector2(float32Array6, vertexCount), 4);
|
|
327
325
|
}
|
|
328
326
|
if (encodedMeshData.uv5) {
|
|
329
|
-
var float32Array7 = new Float32Array(buffer, encodedMeshData.uv5.start + offset
|
|
327
|
+
var float32Array7 = new Float32Array(buffer, encodedMeshData.uv5.start + offset, (encodedMeshData.uv5.end - encodedMeshData.uv5.start) / 4);
|
|
330
328
|
modelMesh.setUVs(float32ArrayToVector2(float32Array7, vertexCount), 5);
|
|
331
329
|
}
|
|
332
330
|
if (encodedMeshData.uv6) {
|
|
333
|
-
var float32Array8 = new Float32Array(buffer, encodedMeshData.uv6.start + offset
|
|
331
|
+
var float32Array8 = new Float32Array(buffer, encodedMeshData.uv6.start + offset, (encodedMeshData.uv6.end - encodedMeshData.uv6.start) / 4);
|
|
334
332
|
modelMesh.setUVs(float32ArrayToVector2(float32Array8, vertexCount), 6);
|
|
335
333
|
}
|
|
336
334
|
if (encodedMeshData.uv7) {
|
|
337
|
-
var float32Array9 = new Float32Array(buffer, encodedMeshData.uv7.start + offset
|
|
335
|
+
var float32Array9 = new Float32Array(buffer, encodedMeshData.uv7.start + offset, (encodedMeshData.uv7.end - encodedMeshData.uv7.start) / 4);
|
|
338
336
|
modelMesh.setUVs(float32ArrayToVector2(float32Array9, vertexCount), 7);
|
|
339
337
|
}
|
|
340
338
|
if (encodedMeshData.colors) {
|
|
341
|
-
var float32Array10 = new Float32Array(buffer, encodedMeshData.colors.start + offset
|
|
339
|
+
var float32Array10 = new Float32Array(buffer, encodedMeshData.colors.start + offset, (encodedMeshData.colors.end - encodedMeshData.colors.start) / 4);
|
|
342
340
|
modelMesh.setColors(float32ArrayToVColor(float32Array10, vertexCount));
|
|
343
341
|
}
|
|
344
342
|
if (encodedMeshData.boneWeights) {
|
|
345
|
-
var float32Array11 = new Float32Array(buffer, encodedMeshData.boneWeights.start + offset
|
|
343
|
+
var float32Array11 = new Float32Array(buffer, encodedMeshData.boneWeights.start + offset, (encodedMeshData.boneWeights.end - encodedMeshData.boneWeights.start) / 4);
|
|
346
344
|
modelMesh.setBoneWeights(float32ArrayToVector4(float32Array11, vertexCount));
|
|
347
345
|
}
|
|
348
346
|
if (encodedMeshData.boneIndices) {
|
|
349
|
-
var float32Array12 = new Float32Array(buffer, encodedMeshData.boneIndices.start + offset
|
|
347
|
+
var float32Array12 = new Float32Array(buffer, encodedMeshData.boneIndices.start + offset, (encodedMeshData.boneIndices.end - encodedMeshData.boneIndices.start) / 4);
|
|
350
348
|
modelMesh.setBoneIndices(float32ArrayToVector4(float32Array12, vertexCount));
|
|
351
349
|
}
|
|
352
350
|
if (encodedMeshData.blendShapes) {
|
|
353
351
|
encodedMeshData.blendShapes.forEach(function(blendShapeData) {
|
|
354
352
|
var blendShape = new engineCore.BlendShape(blendShapeData.name);
|
|
355
353
|
blendShapeData.frames.forEach(function(frameData) {
|
|
356
|
-
var positionArray = new Float32Array(buffer, frameData.deltaPosition.start + offset
|
|
354
|
+
var positionArray = new Float32Array(buffer, frameData.deltaPosition.start + offset, (frameData.deltaPosition.end - frameData.deltaPosition.start) / 4);
|
|
357
355
|
var count = positionArray.length / 3;
|
|
358
356
|
var deltaPosition = float32ArrayToVector3(positionArray, count);
|
|
359
357
|
if (frameData.deltaNormals) {
|
|
360
|
-
var normalsArray = new Float32Array(buffer, frameData.deltaNormals.start + offset
|
|
358
|
+
var normalsArray = new Float32Array(buffer, frameData.deltaNormals.start + offset, (frameData.deltaNormals.end - frameData.deltaNormals.start) / 4);
|
|
361
359
|
float32ArrayToVector3(normalsArray, count);
|
|
362
360
|
}
|
|
363
361
|
if (frameData.deltaTangents) {
|
|
364
|
-
var tangentsArray = new Float32Array(buffer, frameData.deltaTangents.start + offset
|
|
362
|
+
var tangentsArray = new Float32Array(buffer, frameData.deltaTangents.start + offset, (frameData.deltaTangents.end - frameData.deltaTangents.start) / 4);
|
|
365
363
|
float32ArrayToVector4(tangentsArray, count);
|
|
366
364
|
}
|
|
367
365
|
blendShape.addFrame(frameData.weight, deltaPosition);
|
|
@@ -372,9 +370,9 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
|
|
|
372
370
|
if (encodedMeshData.indices) {
|
|
373
371
|
var indices = null;
|
|
374
372
|
if (encodedMeshData.indices.type === 0) {
|
|
375
|
-
indices = new Uint16Array(buffer, encodedMeshData.indices.start + offset
|
|
373
|
+
indices = new Uint16Array(buffer, encodedMeshData.indices.start + offset, (encodedMeshData.indices.end - encodedMeshData.indices.start) / 2);
|
|
376
374
|
} else {
|
|
377
|
-
indices = new Uint32Array(buffer, encodedMeshData.indices.start + offset
|
|
375
|
+
indices = new Uint32Array(buffer, encodedMeshData.indices.start + offset, (encodedMeshData.indices.end - encodedMeshData.indices.start) / 4);
|
|
378
376
|
}
|
|
379
377
|
modelMesh.setIndices(indices);
|
|
380
378
|
}
|
|
@@ -539,15 +537,23 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
539
537
|
if (position) entity.transform.position.copyFrom(position);
|
|
540
538
|
if (rotation) entity.transform.rotation.copyFrom(rotation);
|
|
541
539
|
if (scale) entity.transform.scale.copyFrom(scale);
|
|
540
|
+
var _entityConfig_layer;
|
|
541
|
+
entity.layer = (_entityConfig_layer = entityConfig.layer) != null ? _entityConfig_layer : entity.layer;
|
|
542
542
|
return entity;
|
|
543
543
|
});
|
|
544
544
|
};
|
|
545
545
|
_proto.parseClassObject = function parseClassObject(item) {
|
|
546
|
+
var _this = this;
|
|
546
547
|
var Class = engineCore.Loader.getClass(item.class);
|
|
547
548
|
var _item_constructParams;
|
|
548
549
|
var params = (_item_constructParams = item.constructParams) != null ? _item_constructParams : [];
|
|
549
|
-
|
|
550
|
-
|
|
550
|
+
return Promise.all(params.map(function(param) {
|
|
551
|
+
return _this.parseBasicType(param);
|
|
552
|
+
})).then(function(resultParams) {
|
|
553
|
+
return _construct(Class, [].concat(resultParams));
|
|
554
|
+
}).then(function(instance) {
|
|
555
|
+
return _this.parsePropsAndMethods(instance, item);
|
|
556
|
+
});
|
|
551
557
|
};
|
|
552
558
|
_proto.parsePropsAndMethods = function parsePropsAndMethods(instance, item) {
|
|
553
559
|
var promises = [];
|
|
@@ -555,16 +561,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
555
561
|
for(var methodName in item.methods){
|
|
556
562
|
var methodParams = item.methods[methodName];
|
|
557
563
|
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
558
|
-
|
|
559
|
-
var promise = this.parseMethod(instance, methodName, params);
|
|
560
|
-
promises.push(promise);
|
|
564
|
+
promises.push(this.parseMethod(instance, methodName, methodParams[i]));
|
|
561
565
|
}
|
|
562
566
|
}
|
|
563
567
|
}
|
|
564
568
|
if (item.props) {
|
|
565
569
|
var _this = this, _loop = function(key) {
|
|
566
570
|
var value = item.props[key];
|
|
567
|
-
var promise = _this.parseBasicType(value).then(function(v) {
|
|
571
|
+
var promise = _this.parseBasicType(value, instance[key]).then(function(v) {
|
|
568
572
|
return instance[key] = v;
|
|
569
573
|
});
|
|
570
574
|
promises.push(promise);
|
|
@@ -586,7 +590,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
586
590
|
return (_instance = instance)[methodName].apply(_instance, [].concat(result));
|
|
587
591
|
});
|
|
588
592
|
};
|
|
589
|
-
_proto.parseBasicType = function parseBasicType(value) {
|
|
593
|
+
_proto.parseBasicType = function parseBasicType(value, originValue) {
|
|
590
594
|
var _this = this;
|
|
591
595
|
if (Array.isArray(value)) {
|
|
592
596
|
return Promise.all(value.map(function(item) {
|
|
@@ -603,13 +607,33 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
603
607
|
} else if (ReflectionParser._isEntityRef(value)) {
|
|
604
608
|
// entity reference
|
|
605
609
|
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
606
|
-
} else {
|
|
607
|
-
|
|
608
|
-
|
|
610
|
+
} else if (originValue) {
|
|
611
|
+
var _this1 = this, _loop = function(key) {
|
|
612
|
+
if (key === "methods") {
|
|
613
|
+
var methods = value[key];
|
|
614
|
+
for(var methodName in methods){
|
|
615
|
+
var methodParams = methods[methodName];
|
|
616
|
+
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
617
|
+
var params = methodParams[i];
|
|
618
|
+
var promise = _this1.parseMethod(originValue, methodName, params);
|
|
619
|
+
promises.push(promise);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
promises.push(_this1.parseBasicType(value[key], originValue[key]).then(function(v) {
|
|
624
|
+
return originValue[key] = v;
|
|
625
|
+
}));
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
var promises = [];
|
|
629
|
+
for(var key in value)_loop(key);
|
|
630
|
+
return Promise.all(promises).then(function() {
|
|
631
|
+
return originValue;
|
|
632
|
+
});
|
|
609
633
|
}
|
|
610
|
-
} else {
|
|
611
|
-
return Promise.resolve(value);
|
|
612
634
|
}
|
|
635
|
+
// primitive type
|
|
636
|
+
return Promise.resolve(value);
|
|
613
637
|
};
|
|
614
638
|
_proto._getEntityByConfig = function _getEntityByConfig(entityConfig) {
|
|
615
639
|
// @ts-ignore
|
|
@@ -714,6 +738,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
714
738
|
var componentStr = bufferReader.nextStr();
|
|
715
739
|
var componentType = ComponentMap[componentStr];
|
|
716
740
|
var property = bufferReader.nextStr();
|
|
741
|
+
var getProperty = bufferReader.nextStr();
|
|
717
742
|
var curve = void 0;
|
|
718
743
|
var interpolation = bufferReader.nextUint8();
|
|
719
744
|
var keysLen = bufferReader.nextUint16();
|
|
@@ -838,13 +863,42 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
838
863
|
for(var j7 = 0; j7 < keysLen; ++j7){
|
|
839
864
|
var keyframe8 = new engineCore.Keyframe();
|
|
840
865
|
keyframe8.time = bufferReader.nextFloat32();
|
|
841
|
-
|
|
866
|
+
var str = bufferReader.nextStr();
|
|
867
|
+
if (str) {
|
|
868
|
+
keyframe8.value = JSON.parse(str);
|
|
869
|
+
} else {
|
|
870
|
+
keyframe8.value = null;
|
|
871
|
+
}
|
|
842
872
|
curve.addKey(keyframe8);
|
|
843
873
|
}
|
|
844
874
|
break;
|
|
845
875
|
}
|
|
876
|
+
case "AnimationBoolCurve":
|
|
877
|
+
{
|
|
878
|
+
curve = new engineCore.AnimationBoolCurve();
|
|
879
|
+
curve.interpolation = interpolation;
|
|
880
|
+
for(var j8 = 0; j8 < keysLen; ++j8){
|
|
881
|
+
var keyframe9 = new engineCore.Keyframe();
|
|
882
|
+
keyframe9.time = bufferReader.nextFloat32();
|
|
883
|
+
keyframe9.value = bufferReader.nextUint8() === 1;
|
|
884
|
+
curve.addKey(keyframe9);
|
|
885
|
+
}
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
case "AnimationStringCurve":
|
|
889
|
+
{
|
|
890
|
+
curve = new engineCore.AnimationStringCurve();
|
|
891
|
+
curve.interpolation = interpolation;
|
|
892
|
+
for(var j9 = 0; j9 < keysLen; ++j9){
|
|
893
|
+
var keyframe10 = new engineCore.Keyframe();
|
|
894
|
+
keyframe10.time = bufferReader.nextFloat32();
|
|
895
|
+
keyframe10.value = bufferReader.nextStr();
|
|
896
|
+
curve.addKey(keyframe10);
|
|
897
|
+
}
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
846
900
|
}
|
|
847
|
-
clip.addCurveBinding(relativePath, componentType, property, curve);
|
|
901
|
+
clip.addCurveBinding(relativePath, componentType, property, getProperty, curve);
|
|
848
902
|
}
|
|
849
903
|
resolve(clip);
|
|
850
904
|
});
|
|
@@ -1098,26 +1152,34 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
1098
1152
|
var curveBindingPromises = clip.curveBindings.map(function(curveBinding) {
|
|
1099
1153
|
var curve = curveBinding.curve;
|
|
1100
1154
|
var promises = curve.keys.map(function(key) {
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
resourceManager// @ts-ignore
|
|
1105
|
-
.getResourceByRef(value).then(function(asset) {
|
|
1106
|
-
key.value = asset;
|
|
1107
|
-
resolve(key);
|
|
1108
|
-
}).catch(reject);
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1155
|
+
return _this._parseKeyframeValue(key, resourceManager).then(function(actualValue) {
|
|
1156
|
+
key.value = actualValue;
|
|
1157
|
+
});
|
|
1111
1158
|
});
|
|
1112
1159
|
return Promise.all(promises);
|
|
1113
1160
|
});
|
|
1114
1161
|
return Promise.all(curveBindingPromises).then(function() {
|
|
1115
1162
|
resolve(clip);
|
|
1116
1163
|
});
|
|
1117
|
-
});
|
|
1164
|
+
}).catch(reject);
|
|
1118
1165
|
}).catch(reject);
|
|
1119
1166
|
});
|
|
1120
1167
|
};
|
|
1168
|
+
_proto._parseKeyframeValue = function _parseKeyframeValue(keyframe, resourceManager) {
|
|
1169
|
+
var _value;
|
|
1170
|
+
var value = keyframe.value;
|
|
1171
|
+
if (typeof value === "object" && ((_value = value) == null ? void 0 : _value.refId)) {
|
|
1172
|
+
return new Promise(function(resolve) {
|
|
1173
|
+
resourceManager// @ts-ignore
|
|
1174
|
+
.getResourceByRef(value).then(function(asset) {
|
|
1175
|
+
keyframe.value = asset;
|
|
1176
|
+
resolve(keyframe);
|
|
1177
|
+
});
|
|
1178
|
+
});
|
|
1179
|
+
} else {
|
|
1180
|
+
return Promise.resolve(keyframe.value);
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1121
1183
|
return AnimationClipLoader;
|
|
1122
1184
|
}(engineCore.Loader);
|
|
1123
1185
|
AnimationClipLoader = __decorate([
|
|
@@ -1393,6 +1455,60 @@ FontLoader = __decorate([
|
|
|
1393
1455
|
_this.url = url;
|
|
1394
1456
|
return _this;
|
|
1395
1457
|
}
|
|
1458
|
+
var _proto = GLTFResource.prototype;
|
|
1459
|
+
/**
|
|
1460
|
+
* Instantiate scene root entity.
|
|
1461
|
+
* @param sceneIndex - Scene index
|
|
1462
|
+
* @returns Root entity
|
|
1463
|
+
*/ _proto.instantiateSceneRoot = function instantiateSceneRoot(sceneIndex) {
|
|
1464
|
+
var sceneRoot = sceneIndex === undefined ? this._defaultSceneRoot : this._sceneRoots[sceneIndex];
|
|
1465
|
+
return sceneRoot.clone();
|
|
1466
|
+
};
|
|
1467
|
+
_proto._onDestroy = function _onDestroy() {
|
|
1468
|
+
ReferResource1.prototype._onDestroy.call(this);
|
|
1469
|
+
var _this = this, textures = _this.textures, materials = _this.materials, meshes = _this.meshes;
|
|
1470
|
+
textures && this._disassociationSuperResource(textures);
|
|
1471
|
+
materials && this._disassociationSuperResource(materials);
|
|
1472
|
+
if (meshes) {
|
|
1473
|
+
for(var i = 0, n = meshes.length; i < n; i++){
|
|
1474
|
+
this._disassociationSuperResource(meshes[i]);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
_proto._disassociationSuperResource = function _disassociationSuperResource(resources) {
|
|
1479
|
+
for(var i = 0, n = resources.length; i < n; i++){
|
|
1480
|
+
// @ts-ignore
|
|
1481
|
+
resources[i]._disassociationSuperResource(this);
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
_create_class(GLTFResource, [
|
|
1485
|
+
{
|
|
1486
|
+
key: "extensionsData",
|
|
1487
|
+
get: /**
|
|
1488
|
+
* Extensions data.
|
|
1489
|
+
*/ function get() {
|
|
1490
|
+
return this._extensionsData;
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
key: "sceneRoots",
|
|
1495
|
+
get: /**
|
|
1496
|
+
* @deprecated Please use `instantiateSceneRoot` instead.
|
|
1497
|
+
* RootEntities after SceneParser.
|
|
1498
|
+
*/ function get() {
|
|
1499
|
+
return this._sceneRoots;
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
{
|
|
1503
|
+
key: "defaultSceneRoot",
|
|
1504
|
+
get: /**
|
|
1505
|
+
* @deprecated Please use `instantiateSceneRoot` instead.
|
|
1506
|
+
* RootEntity after SceneParser.
|
|
1507
|
+
*/ function get() {
|
|
1508
|
+
return this._defaultSceneRoot;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
]);
|
|
1396
1512
|
return GLTFResource;
|
|
1397
1513
|
}(engineCore.ReferResource);
|
|
1398
1514
|
|
|
@@ -1419,7 +1535,7 @@ FontLoader = __decorate([
|
|
|
1419
1535
|
* Float
|
|
1420
1536
|
*/ "FLOAT"] = 5126] = "FLOAT";
|
|
1421
1537
|
})(AccessorComponentType || (AccessorComponentType = {}));
|
|
1422
|
-
|
|
1538
|
+
exports.AccessorType = void 0;
|
|
1423
1539
|
(function(AccessorType) {
|
|
1424
1540
|
AccessorType[/**
|
|
1425
1541
|
* Scalar
|
|
@@ -1442,7 +1558,7 @@ var AccessorType;
|
|
|
1442
1558
|
AccessorType[/**
|
|
1443
1559
|
* Matrix4x4
|
|
1444
1560
|
*/ "MAT4"] = "MAT4";
|
|
1445
|
-
})(AccessorType || (AccessorType = {}));
|
|
1561
|
+
})(exports.AccessorType || (exports.AccessorType = {}));
|
|
1446
1562
|
var AnimationChannelTargetPath;
|
|
1447
1563
|
(function(AnimationChannelTargetPath) {
|
|
1448
1564
|
AnimationChannelTargetPath[/**
|
|
@@ -1546,12 +1662,29 @@ var TextureWrapMode;
|
|
|
1546
1662
|
/**
|
|
1547
1663
|
* @internal
|
|
1548
1664
|
*/ var GLTFParserContext = /*#__PURE__*/ function() {
|
|
1549
|
-
function GLTFParserContext(glTFResource, resourceManager,
|
|
1665
|
+
function GLTFParserContext(glTFResource, resourceManager, params) {
|
|
1666
|
+
var _this = this;
|
|
1550
1667
|
this.glTFResource = glTFResource;
|
|
1551
1668
|
this.resourceManager = resourceManager;
|
|
1552
|
-
this.
|
|
1669
|
+
this.params = params;
|
|
1553
1670
|
this.accessorBufferCache = {};
|
|
1554
1671
|
this._resourceCache = new Map();
|
|
1672
|
+
this._progress = {
|
|
1673
|
+
taskDetail: {},
|
|
1674
|
+
taskComplete: {
|
|
1675
|
+
loaded: 0,
|
|
1676
|
+
total: 0
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
this./**
|
|
1680
|
+
* @internal
|
|
1681
|
+
*/ _onTaskDetail = function(url, loaded, total) {
|
|
1682
|
+
var _this__progress_taskDetail, _url;
|
|
1683
|
+
var detail = (_this__progress_taskDetail = _this._progress.taskDetail)[_url = url] || (_this__progress_taskDetail[_url] = {});
|
|
1684
|
+
detail.loaded = loaded;
|
|
1685
|
+
detail.total = total;
|
|
1686
|
+
_this._setTaskDetailProgress(url, loaded, total);
|
|
1687
|
+
};
|
|
1555
1688
|
this.contentRestorer = new GLTFContentRestorer(glTFResource);
|
|
1556
1689
|
}
|
|
1557
1690
|
var _proto = GLTFParserContext.prototype;
|
|
@@ -1574,7 +1707,7 @@ var TextureWrapMode;
|
|
|
1574
1707
|
var glTFItems = this.glTF[glTFSchemaMap[type]];
|
|
1575
1708
|
if (glTFItems && (index === undefined || glTFItems[index])) {
|
|
1576
1709
|
if (index === undefined) {
|
|
1577
|
-
resource = type ===
|
|
1710
|
+
resource = type === 8 ? glTFItems.map(function(_, index) {
|
|
1578
1711
|
return _this.get(type, index);
|
|
1579
1712
|
}) : Promise.all(glTFItems.map(function(_, index) {
|
|
1580
1713
|
return _this.get(type, index);
|
|
@@ -1592,27 +1725,65 @@ var TextureWrapMode;
|
|
|
1592
1725
|
};
|
|
1593
1726
|
_proto.parse = function parse() {
|
|
1594
1727
|
var _this = this;
|
|
1595
|
-
|
|
1728
|
+
var promise = this.get(0).then(function(json) {
|
|
1596
1729
|
_this.glTF = json;
|
|
1597
1730
|
return Promise.all([
|
|
1598
1731
|
_this.get(1),
|
|
1599
|
-
_this.get(4),
|
|
1600
1732
|
_this.get(5),
|
|
1601
1733
|
_this.get(6),
|
|
1602
|
-
_this.get(
|
|
1734
|
+
_this.get(7),
|
|
1603
1735
|
_this.get(9),
|
|
1736
|
+
_this.get(10),
|
|
1604
1737
|
_this.get(2)
|
|
1605
1738
|
]).then(function() {
|
|
1739
|
+
var glTFResource = _this.glTFResource;
|
|
1740
|
+
if (glTFResource.skins || glTFResource.animations) {
|
|
1741
|
+
_this._createAnimator(_this, glTFResource.animations);
|
|
1742
|
+
}
|
|
1606
1743
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
1607
|
-
return
|
|
1744
|
+
return glTFResource;
|
|
1608
1745
|
});
|
|
1609
1746
|
});
|
|
1747
|
+
this._addTaskCompletePromise(promise);
|
|
1748
|
+
return promise;
|
|
1749
|
+
};
|
|
1750
|
+
/**
|
|
1751
|
+
* @internal
|
|
1752
|
+
*/ _proto._addTaskCompletePromise = function _addTaskCompletePromise(taskPromise) {
|
|
1753
|
+
var _this = this;
|
|
1754
|
+
var task = this._progress.taskComplete;
|
|
1755
|
+
task.total += 1;
|
|
1756
|
+
taskPromise.then(function() {
|
|
1757
|
+
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
1758
|
+
});
|
|
1759
|
+
};
|
|
1760
|
+
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
1761
|
+
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
1762
|
+
var animator = defaultSceneRoot.addComponent(engineCore.Animator);
|
|
1763
|
+
var animatorController = new engineCore.AnimatorController();
|
|
1764
|
+
var layer = new engineCore.AnimatorControllerLayer("layer");
|
|
1765
|
+
var animatorStateMachine = new engineCore.AnimatorStateMachine();
|
|
1766
|
+
animatorController.addLayer(layer);
|
|
1767
|
+
animator.animatorController = animatorController;
|
|
1768
|
+
layer.stateMachine = animatorStateMachine;
|
|
1769
|
+
if (animations) {
|
|
1770
|
+
for(var i = 0; i < animations.length; i++){
|
|
1771
|
+
var animationClip = animations[i];
|
|
1772
|
+
var name = animationClip.name;
|
|
1773
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
1774
|
+
if (uniqueName !== name) {
|
|
1775
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
1776
|
+
}
|
|
1777
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
1778
|
+
animatorState.clip = animationClip;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1610
1781
|
};
|
|
1611
1782
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
1612
1783
|
var _this = this;
|
|
1613
1784
|
var glTFResourceKey = glTFResourceMap[type];
|
|
1614
1785
|
if (!glTFResourceKey) return;
|
|
1615
|
-
if (type ===
|
|
1786
|
+
if (type === 8) {
|
|
1616
1787
|
var _this_glTFResource, _glTFResourceKey;
|
|
1617
1788
|
((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
|
|
1618
1789
|
} else {
|
|
@@ -1620,7 +1791,7 @@ var TextureWrapMode;
|
|
|
1620
1791
|
resource.then(function(item) {
|
|
1621
1792
|
var _this_glTFResource, _glTFResourceKey;
|
|
1622
1793
|
((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
|
|
1623
|
-
if (type ===
|
|
1794
|
+
if (type === 7) {
|
|
1624
1795
|
for(var i = 0, length = item.length; i < length; i++){
|
|
1625
1796
|
var mesh = item[i];
|
|
1626
1797
|
// @ts-ignore
|
|
@@ -1660,17 +1831,18 @@ exports.GLTFParserType = void 0;
|
|
|
1660
1831
|
GLTFParserType[GLTFParserType["Validator"] = 1] = "Validator";
|
|
1661
1832
|
GLTFParserType[GLTFParserType["Scene"] = 2] = "Scene";
|
|
1662
1833
|
GLTFParserType[GLTFParserType["Buffer"] = 3] = "Buffer";
|
|
1663
|
-
GLTFParserType[GLTFParserType["
|
|
1664
|
-
GLTFParserType[GLTFParserType["
|
|
1665
|
-
GLTFParserType[GLTFParserType["
|
|
1666
|
-
GLTFParserType[GLTFParserType["
|
|
1667
|
-
GLTFParserType[GLTFParserType["
|
|
1668
|
-
GLTFParserType[GLTFParserType["
|
|
1834
|
+
GLTFParserType[GLTFParserType["BufferView"] = 4] = "BufferView";
|
|
1835
|
+
GLTFParserType[GLTFParserType["Texture"] = 5] = "Texture";
|
|
1836
|
+
GLTFParserType[GLTFParserType["Material"] = 6] = "Material";
|
|
1837
|
+
GLTFParserType[GLTFParserType["Mesh"] = 7] = "Mesh";
|
|
1838
|
+
GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
|
|
1839
|
+
GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
|
|
1840
|
+
GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
|
|
1669
1841
|
})(exports.GLTFParserType || (exports.GLTFParserType = {}));
|
|
1670
1842
|
var _obj;
|
|
1671
|
-
var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[
|
|
1843
|
+
var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[5] = "textures", _obj[6] = "materials", _obj[7] = "meshes", _obj[8] = "nodes", _obj[9] = "skins", _obj[10] = "animations", _obj[4] = "bufferViews", _obj);
|
|
1672
1844
|
var _obj1;
|
|
1673
|
-
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "
|
|
1845
|
+
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[5] = "textures", _obj1[6] = "materials", _obj1[7] = "meshes", _obj1[8] = "entities", _obj1[9] = "skins", _obj1[10] = "animations", _obj1);
|
|
1674
1846
|
function registerGLTFParser(pipeline) {
|
|
1675
1847
|
return function(Parser) {
|
|
1676
1848
|
var parser = new Parser();
|
|
@@ -1724,19 +1896,19 @@ function registerGLTFParser(pipeline) {
|
|
|
1724
1896
|
* Get the number of bytes occupied by accessor type.
|
|
1725
1897
|
*/ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
|
|
1726
1898
|
switch(accessorType){
|
|
1727
|
-
case AccessorType.SCALAR:
|
|
1899
|
+
case exports.AccessorType.SCALAR:
|
|
1728
1900
|
return 1;
|
|
1729
|
-
case AccessorType.VEC2:
|
|
1901
|
+
case exports.AccessorType.VEC2:
|
|
1730
1902
|
return 2;
|
|
1731
|
-
case AccessorType.VEC3:
|
|
1903
|
+
case exports.AccessorType.VEC3:
|
|
1732
1904
|
return 3;
|
|
1733
|
-
case AccessorType.VEC4:
|
|
1905
|
+
case exports.AccessorType.VEC4:
|
|
1734
1906
|
return 4;
|
|
1735
|
-
case AccessorType.MAT2:
|
|
1907
|
+
case exports.AccessorType.MAT2:
|
|
1736
1908
|
return 4;
|
|
1737
|
-
case AccessorType.MAT3:
|
|
1909
|
+
case exports.AccessorType.MAT3:
|
|
1738
1910
|
return 9;
|
|
1739
|
-
case AccessorType.MAT4:
|
|
1911
|
+
case exports.AccessorType.MAT4:
|
|
1740
1912
|
return 16;
|
|
1741
1913
|
}
|
|
1742
1914
|
};
|
|
@@ -1776,11 +1948,10 @@ function registerGLTFParser(pipeline) {
|
|
|
1776
1948
|
GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
|
|
1777
1949
|
var componentType = accessor.componentType;
|
|
1778
1950
|
var bufferView = bufferViews[accessor.bufferView];
|
|
1779
|
-
return context.get(exports.GLTFParserType.
|
|
1951
|
+
return context.get(exports.GLTFParserType.BufferView, accessor.bufferView).then(function(bufferViewData) {
|
|
1780
1952
|
var bufferIndex = bufferView.buffer;
|
|
1781
|
-
var
|
|
1782
|
-
var
|
|
1783
|
-
var bufferByteOffset = (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0;
|
|
1953
|
+
var _bufferViewData_byteOffset;
|
|
1954
|
+
var bufferByteOffset = (_bufferViewData_byteOffset = bufferViewData.byteOffset) != null ? _bufferViewData_byteOffset : 0;
|
|
1784
1955
|
var _accessor_byteOffset;
|
|
1785
1956
|
var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
|
|
1786
1957
|
var TypedArray = GLTFUtils.getComponentType(componentType);
|
|
@@ -1799,19 +1970,21 @@ function registerGLTFParser(pipeline) {
|
|
|
1799
1970
|
if (!bufferInfo) {
|
|
1800
1971
|
var offset = bufferByteOffset + bufferSlice * bufferStride;
|
|
1801
1972
|
var count = accessorCount * (bufferStride / dataElementBytes);
|
|
1802
|
-
var data = new TypedArray(buffer, offset, count);
|
|
1973
|
+
var data = new TypedArray(bufferViewData.buffer, offset, count);
|
|
1803
1974
|
accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
|
|
1804
1975
|
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
|
|
1805
1976
|
}
|
|
1806
1977
|
} else {
|
|
1807
1978
|
var offset1 = bufferByteOffset + byteOffset;
|
|
1808
1979
|
var count1 = accessorCount * dataElementSize;
|
|
1809
|
-
var data1 = new TypedArray(buffer, offset1, count1);
|
|
1980
|
+
var data1 = new TypedArray(bufferViewData.buffer, offset1, count1);
|
|
1810
1981
|
bufferInfo = new BufferInfo(data1, false, elementStride);
|
|
1811
1982
|
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
|
|
1812
1983
|
}
|
|
1813
1984
|
if (accessor.sparse) {
|
|
1814
|
-
GLTFUtils.processingSparseData(
|
|
1985
|
+
return GLTFUtils.processingSparseData(context, accessor, bufferInfo).then(function() {
|
|
1986
|
+
return bufferInfo;
|
|
1987
|
+
});
|
|
1815
1988
|
}
|
|
1816
1989
|
return bufferInfo;
|
|
1817
1990
|
});
|
|
@@ -1887,40 +2060,43 @@ function registerGLTFParser(pipeline) {
|
|
|
1887
2060
|
};
|
|
1888
2061
|
/**
|
|
1889
2062
|
* Get accessor data.
|
|
1890
|
-
*/ GLTFUtils.processingSparseData = function processingSparseData(
|
|
2063
|
+
*/ GLTFUtils.processingSparseData = function processingSparseData(context, accessor, bufferInfo) {
|
|
1891
2064
|
var restoreInfo = bufferInfo.restoreInfo;
|
|
2065
|
+
var bufferViews = context.glTF.bufferViews;
|
|
1892
2066
|
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
1893
2067
|
var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
|
|
1894
2068
|
var data = bufferInfo.data.slice();
|
|
1895
2069
|
var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
|
|
1896
2070
|
var indicesBufferView = bufferViews[indices.bufferView];
|
|
1897
2071
|
var valuesBufferView = bufferViews[values.bufferView];
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
var
|
|
1919
|
-
|
|
1920
|
-
|
|
2072
|
+
return Promise.all([
|
|
2073
|
+
context.get(exports.GLTFParserType.BufferView, indices.bufferView),
|
|
2074
|
+
context.get(exports.GLTFParserType.BufferView, values.bufferView)
|
|
2075
|
+
]).then(function(param) {
|
|
2076
|
+
var indicesUint8Array = param[0], valuesUin8Array = param[1];
|
|
2077
|
+
var _indices_byteOffset, _indicesUint8Array_byteOffset;
|
|
2078
|
+
var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesUint8Array_byteOffset = indicesUint8Array.byteOffset) != null ? _indicesUint8Array_byteOffset : 0);
|
|
2079
|
+
var indicesByteLength = indicesUint8Array.byteLength;
|
|
2080
|
+
var _values_byteOffset, _valuesUin8Array_byteOffset;
|
|
2081
|
+
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesUin8Array_byteOffset = valuesUin8Array.byteOffset) != null ? _valuesUin8Array_byteOffset : 0);
|
|
2082
|
+
var valuesByteLength = valuesUin8Array.byteLength;
|
|
2083
|
+
restoreInfo.typeSize = accessorTypeSize;
|
|
2084
|
+
restoreInfo.sparseCount = count;
|
|
2085
|
+
var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
|
|
2086
|
+
var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
|
|
2087
|
+
var indicesArray = new IndexTypeArray(indicesUint8Array.buffer, indicesByteOffset, indexLength);
|
|
2088
|
+
restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferView.buffer, IndexTypeArray, indicesByteOffset, indexLength);
|
|
2089
|
+
var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
|
|
2090
|
+
var valuesArray = new TypedArray(valuesUin8Array.buffer, valuesByteOffset, valueLength);
|
|
2091
|
+
restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferView.buffer, TypedArray, valuesByteOffset, valueLength);
|
|
2092
|
+
for(var i = 0; i < count; i++){
|
|
2093
|
+
var replaceIndex = indicesArray[i];
|
|
2094
|
+
for(var j = 0; j < accessorTypeSize; j++){
|
|
2095
|
+
data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
|
|
2096
|
+
}
|
|
1921
2097
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
2098
|
+
bufferInfo.data = data;
|
|
2099
|
+
});
|
|
1924
2100
|
};
|
|
1925
2101
|
GLTFUtils.getIndexFormat = function getIndexFormat(type) {
|
|
1926
2102
|
switch(type){
|
|
@@ -2247,7 +2423,7 @@ var SupercompressionScheme;
|
|
|
2247
2423
|
alphaSliceByteLength: sgdReader.nextUint32()
|
|
2248
2424
|
};
|
|
2249
2425
|
}
|
|
2250
|
-
var endpointsByteOffset = sgdByteOffset + sgdReader.
|
|
2426
|
+
var endpointsByteOffset = sgdByteOffset + sgdReader.position;
|
|
2251
2427
|
var selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
|
|
2252
2428
|
var tablesByteOffset = selectorsByteOffset + selectorsByteLength;
|
|
2253
2429
|
var extendedByteOffset = tablesByteOffset + tablesByteLength;
|
|
@@ -2439,6 +2615,25 @@ var AbstractTranscoder = /*#__PURE__*/ function() {
|
|
|
2439
2615
|
}();
|
|
2440
2616
|
|
|
2441
2617
|
/** @internal */ function TranscodeWorkerCode$1() {
|
|
2618
|
+
var initPromise;
|
|
2619
|
+
var init = function init(wasmBinary) {
|
|
2620
|
+
if (!initPromise) {
|
|
2621
|
+
initPromise = new Promise(function(resolve, reject) {
|
|
2622
|
+
var BasisModule = {
|
|
2623
|
+
wasmBinary: wasmBinary,
|
|
2624
|
+
onRuntimeInitialized: function() {
|
|
2625
|
+
return resolve(BasisModule);
|
|
2626
|
+
},
|
|
2627
|
+
onAbort: reject
|
|
2628
|
+
};
|
|
2629
|
+
self["BASIS"](BasisModule);
|
|
2630
|
+
}).then(function(BasisModule) {
|
|
2631
|
+
BasisModule.initializeBasis();
|
|
2632
|
+
return BasisModule.KTX2File;
|
|
2633
|
+
});
|
|
2634
|
+
}
|
|
2635
|
+
return initPromise;
|
|
2636
|
+
};
|
|
2442
2637
|
self.onmessage = function onmessage(event) {
|
|
2443
2638
|
var message = event.data;
|
|
2444
2639
|
switch(message.type){
|
|
@@ -2565,6 +2760,7 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2565
2760
|
var faceCount = ktx2File.getFaces();
|
|
2566
2761
|
var format = getTranscodeFormatFromTarget(targetFormat, hasAlpha);
|
|
2567
2762
|
var faces = new Array(faceCount);
|
|
2763
|
+
var isBC = format === 2 || format === 3 || format === 7;
|
|
2568
2764
|
for(var face = 0; face < faceCount; face++){
|
|
2569
2765
|
var mipmaps = new Array(levelCount);
|
|
2570
2766
|
for(var mip = 0; mip < levelCount; mip++){
|
|
@@ -2572,8 +2768,15 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2572
2768
|
var mipWidth = void 0, mipHeight = void 0;
|
|
2573
2769
|
for(var layer = 0; layer < layerCount; layer++){
|
|
2574
2770
|
var levelInfo = ktx2File.getImageLevelInfo(mip, layer, face);
|
|
2575
|
-
|
|
2576
|
-
|
|
2771
|
+
// see: https://github.com/KhronosGroup/KTX-Software/issues/254
|
|
2772
|
+
if (isBC && mip === 0 && (width !== levelInfo.width || height !== levelInfo.height)) {
|
|
2773
|
+
width = mipWidth = levelInfo.width;
|
|
2774
|
+
height = mipHeight = levelInfo.height;
|
|
2775
|
+
console.warn("KTX2 transcode to BC will resize to width: " + width + ", height: " + height + ". You'd better use an image whose size if multiple of 4.");
|
|
2776
|
+
} else {
|
|
2777
|
+
mipWidth = levelInfo.origWidth;
|
|
2778
|
+
mipHeight = levelInfo.origHeight;
|
|
2779
|
+
}
|
|
2577
2780
|
var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
|
|
2578
2781
|
var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
|
|
2579
2782
|
if (!status) {
|
|
@@ -2639,7 +2842,7 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2639
2842
|
} else {
|
|
2640
2843
|
var funcCode = TranscodeWorkerCode$1.toString();
|
|
2641
2844
|
var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
|
|
2642
|
-
var workerCode = "\n " + jsCode + "\n
|
|
2845
|
+
var workerCode = "\n " + jsCode + "\n " + transcode.toString() + "\n " + transcodeString + "\n ";
|
|
2643
2846
|
var workerURL = URL.createObjectURL(new Blob([
|
|
2644
2847
|
workerCode
|
|
2645
2848
|
], {
|
|
@@ -2885,10 +3088,14 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2885
3088
|
return Loader1.apply(this, arguments);
|
|
2886
3089
|
}
|
|
2887
3090
|
var _proto = KTX2Loader1.prototype;
|
|
2888
|
-
_proto.initialize = function initialize(
|
|
3091
|
+
_proto.initialize = function initialize(_, configuration) {
|
|
2889
3092
|
if (configuration.ktx2Loader) {
|
|
2890
3093
|
var options = configuration.ktx2Loader;
|
|
2891
|
-
if (
|
|
3094
|
+
if (options.priorityFormats) {
|
|
3095
|
+
exports.KTX2Loader._priorityFormats["etc1s"] = options.priorityFormats;
|
|
3096
|
+
exports.KTX2Loader._priorityFormats["uastc"] = options.priorityFormats;
|
|
3097
|
+
}
|
|
3098
|
+
if (options.transcoder === /** Khronos transcoder. */ 1) {
|
|
2892
3099
|
return exports.KTX2Loader._getKhronosTranscoder(options.workerCount).init();
|
|
2893
3100
|
} else {
|
|
2894
3101
|
return exports.KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
|
|
@@ -2898,39 +3105,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2898
3105
|
/**
|
|
2899
3106
|
* @internal
|
|
2900
3107
|
*/ _proto.load = function load(item, resourceManager) {
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
return exports.KTX2Loader.
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
if (priorityFormats === void 0) priorityFormats = [
|
|
2912
|
-
exports.KTX2TargetFormat.ASTC,
|
|
2913
|
-
exports.KTX2TargetFormat.ETC,
|
|
2914
|
-
exports.KTX2TargetFormat.BC7,
|
|
2915
|
-
exports.KTX2TargetFormat.BC1_BC3,
|
|
2916
|
-
exports.KTX2TargetFormat.PVRTC,
|
|
2917
|
-
exports.KTX2TargetFormat.R8G8B8A8
|
|
2918
|
-
];
|
|
2919
|
-
var supportedList = new Array();
|
|
2920
|
-
if (Array.isArray(priorityFormats[0])) {
|
|
2921
|
-
for(var i = 0; i < priorityFormats.length; i++){
|
|
2922
|
-
supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats[i]));
|
|
2923
|
-
}
|
|
2924
|
-
} else {
|
|
2925
|
-
supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats));
|
|
2926
|
-
}
|
|
2927
|
-
return supportedList.every(function(format) {
|
|
2928
|
-
return KhronosTranscoder.transcoderMap[format];
|
|
3108
|
+
var _this = this;
|
|
3109
|
+
return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
3110
|
+
_this.request(item.url, {
|
|
3111
|
+
type: "arraybuffer"
|
|
3112
|
+
}).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
|
|
3113
|
+
return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
|
|
3114
|
+
var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
|
|
3115
|
+
return exports.KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
|
|
3116
|
+
});
|
|
3117
|
+
}).then(resolve).catch(reject);
|
|
2929
3118
|
});
|
|
2930
3119
|
};
|
|
2931
3120
|
/**
|
|
2932
|
-
*
|
|
2933
|
-
|
|
3121
|
+
* Release ktx2 transcoder worker.
|
|
3122
|
+
* @remarks If use loader after releasing, we should release again.
|
|
3123
|
+
*/ KTX2Loader1.release = function release() {
|
|
2934
3124
|
if (this._binomialLLCTranscoder) this._binomialLLCTranscoder.destroy();
|
|
2935
3125
|
if (this._khronosTranscoder) this._khronosTranscoder.destroy();
|
|
2936
3126
|
this._binomialLLCTranscoder = null;
|
|
@@ -2940,7 +3130,8 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2940
3130
|
/** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
|
|
2941
3131
|
var _params;
|
|
2942
3132
|
var ktx2Container = new KTX2Container(buffer);
|
|
2943
|
-
var
|
|
3133
|
+
var _params_priorityFormats;
|
|
3134
|
+
var formatPriorities = (_params_priorityFormats = (_params = params) == null ? void 0 : _params.priorityFormats) != null ? _params_priorityFormats : exports.KTX2Loader._priorityFormats[ktx2Container.isUASTC ? "uastc" : "etc1s"];
|
|
2944
3135
|
var targetFormat = exports.KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
|
|
2945
3136
|
var transcodeResultPromise;
|
|
2946
3137
|
if (exports.KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
|
|
@@ -3007,18 +3198,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3007
3198
|
return targetFormat;
|
|
3008
3199
|
};
|
|
3009
3200
|
KTX2Loader1._detectSupportedFormat = function _detectSupportedFormat(renderer, priorityFormats) {
|
|
3010
|
-
if (priorityFormats === void 0) priorityFormats = [
|
|
3011
|
-
exports.KTX2TargetFormat.ASTC,
|
|
3012
|
-
exports.KTX2TargetFormat.ETC,
|
|
3013
|
-
exports.KTX2TargetFormat.BC7,
|
|
3014
|
-
exports.KTX2TargetFormat.BC1_BC3,
|
|
3015
|
-
exports.KTX2TargetFormat.PVRTC
|
|
3016
|
-
];
|
|
3017
3201
|
for(var i = 0; i < priorityFormats.length; i++){
|
|
3018
|
-
var
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3202
|
+
var format = priorityFormats[i];
|
|
3203
|
+
var capabilities = this._supportedMap[format];
|
|
3204
|
+
if (capabilities) {
|
|
3205
|
+
for(var j = 0; j < capabilities.length; j++){
|
|
3206
|
+
if (renderer.canIUse(capabilities[j])) {
|
|
3207
|
+
return format;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
} else {
|
|
3211
|
+
switch(priorityFormats[i]){
|
|
3212
|
+
case exports.KTX2TargetFormat.R8G8B8A8:
|
|
3213
|
+
return format;
|
|
3214
|
+
case exports.KTX2TargetFormat.R8:
|
|
3215
|
+
case exports.KTX2TargetFormat.R8G8:
|
|
3216
|
+
if (renderer.isWebGL2) return format;
|
|
3022
3217
|
}
|
|
3023
3218
|
}
|
|
3024
3219
|
}
|
|
@@ -3055,6 +3250,23 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3055
3250
|
return KTX2Loader1;
|
|
3056
3251
|
}(engineCore.Loader), function() {
|
|
3057
3252
|
_KTX2Loader._isBinomialInit = false;
|
|
3253
|
+
}(), function() {
|
|
3254
|
+
_KTX2Loader._priorityFormats = {
|
|
3255
|
+
etc1s: [
|
|
3256
|
+
exports.KTX2TargetFormat.ETC,
|
|
3257
|
+
exports.KTX2TargetFormat.BC7,
|
|
3258
|
+
exports.KTX2TargetFormat.ASTC,
|
|
3259
|
+
exports.KTX2TargetFormat.BC1_BC3,
|
|
3260
|
+
exports.KTX2TargetFormat.PVRTC
|
|
3261
|
+
],
|
|
3262
|
+
uastc: [
|
|
3263
|
+
exports.KTX2TargetFormat.ASTC,
|
|
3264
|
+
exports.KTX2TargetFormat.BC7,
|
|
3265
|
+
exports.KTX2TargetFormat.ETC,
|
|
3266
|
+
exports.KTX2TargetFormat.BC1_BC3,
|
|
3267
|
+
exports.KTX2TargetFormat.PVRTC
|
|
3268
|
+
]
|
|
3269
|
+
};
|
|
3058
3270
|
}(), function() {
|
|
3059
3271
|
var _obj;
|
|
3060
3272
|
_KTX2Loader._supportedMap = (_obj = {}, _obj[exports.KTX2TargetFormat.ASTC] = [
|
|
@@ -3075,6 +3287,11 @@ exports.KTX2Loader = __decorate([
|
|
|
3075
3287
|
"ktx2"
|
|
3076
3288
|
])
|
|
3077
3289
|
], exports.KTX2Loader);
|
|
3290
|
+
exports.KTX2Transcoder = void 0;
|
|
3291
|
+
(function(KTX2Transcoder) {
|
|
3292
|
+
KTX2Transcoder[KTX2Transcoder[/** BinomialLLC transcoder. */ "BinomialLLC"] = 0] = "BinomialLLC";
|
|
3293
|
+
KTX2Transcoder[KTX2Transcoder["Khronos"] = 1] = "Khronos";
|
|
3294
|
+
})(exports.KTX2Transcoder || (exports.KTX2Transcoder = {}));
|
|
3078
3295
|
|
|
3079
3296
|
/**
|
|
3080
3297
|
* @internal
|
|
@@ -3425,7 +3642,7 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3425
3642
|
};
|
|
3426
3643
|
var isGLB = this._isGLB(url);
|
|
3427
3644
|
contentRestorer.isGLB = isGLB;
|
|
3428
|
-
var promise = isGLB ? engineCore.request(url, requestConfig).then(function(glb) {
|
|
3645
|
+
var promise = isGLB ? engineCore.request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(glb) {
|
|
3429
3646
|
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
3430
3647
|
return GLTFUtils.parseGLB(context, glb);
|
|
3431
3648
|
}).then(function(param) {
|
|
@@ -3434,7 +3651,7 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3434
3651
|
return glTF;
|
|
3435
3652
|
}) : engineCore.request(url, {
|
|
3436
3653
|
type: "json"
|
|
3437
|
-
});
|
|
3654
|
+
}).onProgress(undefined, context._onTaskDetail);
|
|
3438
3655
|
return promise;
|
|
3439
3656
|
};
|
|
3440
3657
|
_proto._isGLB = function _isGLB(url) {
|
|
@@ -3466,9 +3683,9 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3466
3683
|
* @internal
|
|
3467
3684
|
*/ GLTFAnimationParser1._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
|
|
3468
3685
|
var _loop = function(j, m) {
|
|
3469
|
-
var
|
|
3470
|
-
var inputAccessor = accessors[
|
|
3471
|
-
var outputAccessor = accessors[
|
|
3686
|
+
var glTFSampler = samplers[j];
|
|
3687
|
+
var inputAccessor = accessors[glTFSampler.input];
|
|
3688
|
+
var outputAccessor = accessors[glTFSampler.output];
|
|
3472
3689
|
var promise = Promise.all([
|
|
3473
3690
|
GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
|
|
3474
3691
|
GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
|
|
@@ -3484,8 +3701,8 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3484
3701
|
output = scaled;
|
|
3485
3702
|
}
|
|
3486
3703
|
var outputStride = output.length / input.length;
|
|
3487
|
-
var
|
|
3488
|
-
var interpolation = (
|
|
3704
|
+
var _glTFSampler_interpolation;
|
|
3705
|
+
var interpolation = (_glTFSampler_interpolation = glTFSampler.interpolation) != null ? _glTFSampler_interpolation : AnimationSamplerInterpolation.Linear;
|
|
3489
3706
|
var samplerInterpolation;
|
|
3490
3707
|
switch(interpolation){
|
|
3491
3708
|
case AnimationSamplerInterpolation.CubicSpine:
|
|
@@ -3518,10 +3735,11 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3518
3735
|
var promises = new Array();
|
|
3519
3736
|
// parse samplers
|
|
3520
3737
|
for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
|
|
3738
|
+
promises.push(context.get(exports.GLTFParserType.Scene));
|
|
3521
3739
|
return Promise.all(promises).then(function() {
|
|
3522
3740
|
for(var j = 0, m = channels.length; j < m; j++){
|
|
3523
|
-
var
|
|
3524
|
-
var target =
|
|
3741
|
+
var glTFChannel = channels[j];
|
|
3742
|
+
var target = glTFChannel.target;
|
|
3525
3743
|
var channelTargetEntity = entities[target.node];
|
|
3526
3744
|
var relativePath = "";
|
|
3527
3745
|
var entity = channelTargetEntity;
|
|
@@ -3529,6 +3747,10 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3529
3747
|
relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
|
|
3530
3748
|
entity = entity.parent;
|
|
3531
3749
|
}
|
|
3750
|
+
// If the target node is in the default scene, relativePath will be empty
|
|
3751
|
+
if (context.glTFResource.sceneRoots.indexOf(entity) === -1) {
|
|
3752
|
+
continue;
|
|
3753
|
+
}
|
|
3532
3754
|
var ComponentType = void 0;
|
|
3533
3755
|
var propertyName = void 0;
|
|
3534
3756
|
switch(target.path){
|
|
@@ -3549,14 +3771,21 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3549
3771
|
propertyName = "blendShapeWeights";
|
|
3550
3772
|
break;
|
|
3551
3773
|
}
|
|
3552
|
-
var curve = _this._addCurve(target.path,
|
|
3553
|
-
|
|
3774
|
+
var curve = _this._addCurve(target.path, glTFChannel, sampleDataCollection);
|
|
3775
|
+
if (target.path === AnimationChannelTargetPath.WEIGHTS) {
|
|
3776
|
+
var mesh = glTF.nodes[target.node].mesh;
|
|
3777
|
+
for(var i = 0, n = glTF.meshes[mesh].primitives.length; i < n; i++){
|
|
3778
|
+
animationClip.addCurveBinding(relativePath, ComponentType, i, propertyName, curve);
|
|
3779
|
+
}
|
|
3780
|
+
} else {
|
|
3781
|
+
animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
|
|
3782
|
+
}
|
|
3554
3783
|
}
|
|
3555
3784
|
return animationClip;
|
|
3556
3785
|
});
|
|
3557
3786
|
};
|
|
3558
|
-
GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath,
|
|
3559
|
-
var sampleData = sampleDataCollection[
|
|
3787
|
+
GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, glTFChannel, sampleDataCollection) {
|
|
3788
|
+
var sampleData = sampleDataCollection[glTFChannel.sampler];
|
|
3560
3789
|
var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
|
|
3561
3790
|
switch(animationChannelTargetPath){
|
|
3562
3791
|
case AnimationChannelTargetPath.TRANSLATION:
|
|
@@ -3648,7 +3877,9 @@ exports.GLTFBufferParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3648
3877
|
};
|
|
3649
3878
|
var absoluteUrl = engineCore.Utils.resolveAbsoluteUrl(url, bufferInfo.uri);
|
|
3650
3879
|
restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
|
|
3651
|
-
|
|
3880
|
+
var promise = engineCore.request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
|
|
3881
|
+
context._addTaskCompletePromise(promise);
|
|
3882
|
+
return promise;
|
|
3652
3883
|
};
|
|
3653
3884
|
return GLTFBufferParser;
|
|
3654
3885
|
}(GLTFParser);
|
|
@@ -3663,10 +3894,13 @@ exports.GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3663
3894
|
}
|
|
3664
3895
|
var _proto = GLTFEntityParser.prototype;
|
|
3665
3896
|
_proto.parse = function parse(context, index) {
|
|
3897
|
+
var glTFResource = context.glTFResource;
|
|
3666
3898
|
var entityInfo = context.glTF.nodes[index];
|
|
3667
|
-
var engine =
|
|
3899
|
+
var engine = glTFResource.engine;
|
|
3668
3900
|
var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
|
|
3669
3901
|
var entity = new engineCore.Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
|
|
3902
|
+
// @ts-ignore
|
|
3903
|
+
entity._markAsTemplate(glTFResource);
|
|
3670
3904
|
var transform = entity.transform;
|
|
3671
3905
|
if (matrix) {
|
|
3672
3906
|
var localMatrix = transform.localMatrix;
|
|
@@ -3708,7 +3942,8 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3708
3942
|
var _proto = GLTFMaterialParser1.prototype;
|
|
3709
3943
|
_proto.parse = function parse(context, index) {
|
|
3710
3944
|
var materialInfo = context.glTF.materials[index];
|
|
3711
|
-
var
|
|
3945
|
+
var glTFResource = context.glTFResource;
|
|
3946
|
+
var engine = glTFResource.engine;
|
|
3712
3947
|
var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
|
|
3713
3948
|
if (!material) {
|
|
3714
3949
|
material = new engineCore.PBRMaterial(engine);
|
|
@@ -3716,8 +3951,10 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3716
3951
|
exports.GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
|
|
3717
3952
|
}
|
|
3718
3953
|
return Promise.resolve(material).then(function(material) {
|
|
3719
|
-
material || (material = exports.GLTFMaterialParser._getDefaultMaterial(
|
|
3954
|
+
material || (material = exports.GLTFMaterialParser._getDefaultMaterial(engine));
|
|
3720
3955
|
GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
|
|
3956
|
+
// @ts-ignore
|
|
3957
|
+
material._associationSuperResource(glTFResource);
|
|
3721
3958
|
return material;
|
|
3722
3959
|
});
|
|
3723
3960
|
};
|
|
@@ -3838,14 +4075,20 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
|
|
|
3838
4075
|
var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, meshInfo);
|
|
3839
4076
|
if (mesh) {
|
|
3840
4077
|
if (_instanceof(mesh, engineCore.ModelMesh)) {
|
|
4078
|
+
// @ts-ignore
|
|
4079
|
+
mesh._associationSuperResource(glTFResource);
|
|
3841
4080
|
resolve(mesh);
|
|
3842
4081
|
} else {
|
|
3843
4082
|
mesh.then(function(mesh) {
|
|
3844
|
-
|
|
4083
|
+
// @ts-ignore
|
|
4084
|
+
mesh._associationSuperResource(glTFResource);
|
|
4085
|
+
resolve(mesh);
|
|
3845
4086
|
});
|
|
3846
4087
|
}
|
|
3847
4088
|
} else {
|
|
3848
4089
|
var mesh1 = new engineCore.ModelMesh(engine, meshInfo.name || i + "");
|
|
4090
|
+
// @ts-ignore
|
|
4091
|
+
mesh1._associationSuperResource(glTFResource);
|
|
3849
4092
|
var meshRestoreInfo = new ModelMeshRestoreInfo();
|
|
3850
4093
|
meshRestoreInfo.mesh = mesh1;
|
|
3851
4094
|
context.contentRestorer.meshes.push(meshRestoreInfo);
|
|
@@ -3865,12 +4108,13 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
|
|
|
3865
4108
|
return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
3866
4109
|
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
3867
4110
|
});
|
|
3868
|
-
}, context.keepMeshData).then(resolve);
|
|
4111
|
+
}, context.params.keepMeshData).then(resolve);
|
|
3869
4112
|
}
|
|
3870
4113
|
});
|
|
3871
4114
|
};
|
|
3872
4115
|
var meshInfo = context.glTF.meshes[index];
|
|
3873
|
-
var glTF = context.glTF,
|
|
4116
|
+
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
4117
|
+
var engine = glTFResource.engine;
|
|
3874
4118
|
var primitivePromises = new Array();
|
|
3875
4119
|
for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
|
|
3876
4120
|
return Promise.all(primitivePromises);
|
|
@@ -4043,9 +4287,9 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4043
4287
|
}
|
|
4044
4288
|
var _proto = GLTFSceneParser.prototype;
|
|
4045
4289
|
_proto.parse = function parse(context, index) {
|
|
4046
|
-
var _this = this;
|
|
4047
4290
|
var _context_glTF = context.glTF, scenes = _context_glTF.scenes, _context_glTF_scene = _context_glTF.scene, scene = _context_glTF_scene === void 0 ? 0 : _context_glTF_scene, glTFResource = context.glTFResource;
|
|
4048
4291
|
var sceneInfo = scenes[index];
|
|
4292
|
+
var sceneExtensions = sceneInfo.extensions;
|
|
4049
4293
|
var engine = glTFResource.engine;
|
|
4050
4294
|
var isDefaultScene = scene === index;
|
|
4051
4295
|
var sceneNodes = sceneInfo.nodes;
|
|
@@ -4059,30 +4303,15 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4059
4303
|
sceneRoot.addChild(childEntity);
|
|
4060
4304
|
}
|
|
4061
4305
|
}
|
|
4062
|
-
// @ts-ignore
|
|
4063
|
-
sceneRoot._hookResource = glTFResource;
|
|
4064
|
-
// @ts-ignore
|
|
4065
|
-
glTFResource._addReferCount(1);
|
|
4066
4306
|
if (isDefaultScene) {
|
|
4067
|
-
glTFResource.
|
|
4307
|
+
glTFResource._defaultSceneRoot = sceneRoot;
|
|
4068
4308
|
}
|
|
4069
4309
|
var promises = new Array();
|
|
4070
4310
|
for(var i1 = 0; i1 < sceneNodes.length; i1++){
|
|
4071
4311
|
promises.push(this._parseEntityComponent(context, sceneNodes[i1]));
|
|
4072
4312
|
}
|
|
4073
4313
|
return Promise.all(promises).then(function() {
|
|
4074
|
-
|
|
4075
|
-
return Promise.all([
|
|
4076
|
-
context.get(exports.GLTFParserType.Skin),
|
|
4077
|
-
context.get(exports.GLTFParserType.Animation)
|
|
4078
|
-
]).then(function(param) {
|
|
4079
|
-
var skins = param[0], animations = param[1];
|
|
4080
|
-
if (skins || animations) {
|
|
4081
|
-
_this._createAnimator(context, animations);
|
|
4082
|
-
}
|
|
4083
|
-
return sceneRoot;
|
|
4084
|
-
});
|
|
4085
|
-
}
|
|
4314
|
+
GLTFParser.executeExtensionsAdditiveAndParse(sceneExtensions, context, sceneRoot, sceneInfo);
|
|
4086
4315
|
return sceneRoot;
|
|
4087
4316
|
});
|
|
4088
4317
|
};
|
|
@@ -4194,28 +4423,6 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4194
4423
|
for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
|
|
4195
4424
|
return Promise.all(promises);
|
|
4196
4425
|
};
|
|
4197
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
4198
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
4199
|
-
var animator = defaultSceneRoot.addComponent(engineCore.Animator);
|
|
4200
|
-
var animatorController = new engineCore.AnimatorController();
|
|
4201
|
-
var layer = new engineCore.AnimatorControllerLayer("layer");
|
|
4202
|
-
var animatorStateMachine = new engineCore.AnimatorStateMachine();
|
|
4203
|
-
animatorController.addLayer(layer);
|
|
4204
|
-
animator.animatorController = animatorController;
|
|
4205
|
-
layer.stateMachine = animatorStateMachine;
|
|
4206
|
-
if (animations) {
|
|
4207
|
-
for(var i = 0; i < animations.length; i++){
|
|
4208
|
-
var animationClip = animations[i];
|
|
4209
|
-
var name = animationClip.name;
|
|
4210
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
4211
|
-
if (uniqueName !== name) {
|
|
4212
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
4213
|
-
}
|
|
4214
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
4215
|
-
animatorState.clip = animationClip;
|
|
4216
|
-
}
|
|
4217
|
-
}
|
|
4218
|
-
};
|
|
4219
4426
|
_proto._computeLocalBounds = function _computeLocalBounds(skinnedMeshRenderer, mesh, bones, rootBone, inverseBindMatrices) {
|
|
4220
4427
|
var rootBoneIndex = bones.indexOf(rootBone);
|
|
4221
4428
|
if (rootBoneIndex !== -1) {
|
|
@@ -4364,11 +4571,12 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
|
|
|
4364
4571
|
params: {
|
|
4365
4572
|
mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
|
|
4366
4573
|
}
|
|
4367
|
-
}).then(function(texture) {
|
|
4574
|
+
}).onProgress(undefined, context._onTaskDetail).then(function(texture) {
|
|
4368
4575
|
texture.name = textureName || imageName || texture.name || "texture_" + index;
|
|
4369
4576
|
useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
|
|
4370
4577
|
return texture;
|
|
4371
4578
|
});
|
|
4579
|
+
context._addTaskCompletePromise(texture);
|
|
4372
4580
|
} else {
|
|
4373
4581
|
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
4374
4582
|
texture = context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
@@ -4390,6 +4598,8 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
|
|
|
4390
4598
|
}
|
|
4391
4599
|
return Promise.resolve(texture).then(function(texture) {
|
|
4392
4600
|
GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
|
|
4601
|
+
// @ts-ignore
|
|
4602
|
+
texture._associationSuperResource(glTFResource);
|
|
4393
4603
|
return texture;
|
|
4394
4604
|
});
|
|
4395
4605
|
};
|
|
@@ -4440,28 +4650,283 @@ exports.GLTFValidator = __decorate([
|
|
|
4440
4650
|
registerGLTFParser(exports.GLTFParserType.Validator)
|
|
4441
4651
|
], exports.GLTFValidator);
|
|
4442
4652
|
|
|
4443
|
-
|
|
4653
|
+
exports.GLTFBufferViewParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
4654
|
+
_inherits(GLTFBufferViewParser, GLTFParser1);
|
|
4655
|
+
function GLTFBufferViewParser() {
|
|
4656
|
+
return GLTFParser1.apply(this, arguments);
|
|
4657
|
+
}
|
|
4658
|
+
var _proto = GLTFBufferViewParser.prototype;
|
|
4659
|
+
_proto.parse = function parse(context, index) {
|
|
4660
|
+
var bufferView = context.glTF.bufferViews[index];
|
|
4661
|
+
var extensions = bufferView.extensions, _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset, byteLength = bufferView.byteLength, bufferIndex = bufferView.buffer;
|
|
4662
|
+
return extensions ? GLTFParser.executeExtensionsCreateAndParse(extensions, context, bufferView) : context.get(exports.GLTFParserType.Buffer, bufferIndex).then(function(buffer) {
|
|
4663
|
+
return new Uint8Array(buffer, byteOffset, byteLength);
|
|
4664
|
+
});
|
|
4665
|
+
};
|
|
4666
|
+
return GLTFBufferViewParser;
|
|
4667
|
+
}(GLTFParser);
|
|
4668
|
+
exports.GLTFBufferViewParser = __decorate([
|
|
4669
|
+
registerGLTFParser(exports.GLTFParserType.BufferView)
|
|
4670
|
+
], exports.GLTFBufferViewParser);
|
|
4671
|
+
|
|
4672
|
+
// Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
|
|
4673
|
+
var MeshoptDecoder = function() {
|
|
4674
|
+
var unpack = function unpack(data) {
|
|
4675
|
+
var result = new Uint8Array(data.length);
|
|
4676
|
+
for(var i = 0; i < data.length; ++i){
|
|
4677
|
+
var ch = data.charCodeAt(i);
|
|
4678
|
+
result[i] = ch > 96 ? ch - 97 : ch > 64 ? ch - 39 : ch + 4;
|
|
4679
|
+
}
|
|
4680
|
+
var write = 0;
|
|
4681
|
+
for(var i1 = 0; i1 < data.length; ++i1){
|
|
4682
|
+
result[write++] = result[i1] < 60 ? wasmpack[result[i1]] : (result[i1] - 60) * 64 + result[++i1];
|
|
4683
|
+
}
|
|
4684
|
+
return result.buffer.slice(0, write);
|
|
4685
|
+
};
|
|
4686
|
+
var decode = function decode(fun, target, count, size, source, filter) {
|
|
4687
|
+
var sbrk = instance.exports.sbrk;
|
|
4688
|
+
var count4 = count + 3 & ~3;
|
|
4689
|
+
var tp = sbrk(count4 * size);
|
|
4690
|
+
var sp = sbrk(source.length);
|
|
4691
|
+
var heap = new Uint8Array(instance.exports.memory.buffer);
|
|
4692
|
+
heap.set(source, sp);
|
|
4693
|
+
var res = fun(tp, count, size, sp, source.length);
|
|
4694
|
+
if (res == 0 && filter) {
|
|
4695
|
+
filter(tp, count4, size);
|
|
4696
|
+
}
|
|
4697
|
+
target.set(heap.subarray(tp, tp + count * size));
|
|
4698
|
+
sbrk(tp - sbrk(0));
|
|
4699
|
+
if (res != 0) {
|
|
4700
|
+
throw new Error("Malformed buffer data: " + res);
|
|
4701
|
+
}
|
|
4702
|
+
};
|
|
4703
|
+
var createWorker = function createWorker(url) {
|
|
4704
|
+
var worker = {
|
|
4705
|
+
object: new Worker(url),
|
|
4706
|
+
pending: 0,
|
|
4707
|
+
requests: {}
|
|
4708
|
+
};
|
|
4709
|
+
worker.object.onmessage = function(event) {
|
|
4710
|
+
var data = event.data;
|
|
4711
|
+
worker.pending -= data.count;
|
|
4712
|
+
worker.requests[data.id][data.action](data.value);
|
|
4713
|
+
delete worker.requests[data.id];
|
|
4714
|
+
};
|
|
4715
|
+
return worker;
|
|
4716
|
+
};
|
|
4717
|
+
var initWorkers = function initWorkers(count) {
|
|
4718
|
+
var source = "var instance; var ready = WebAssembly.instantiate(new Uint8Array([" + new Uint8Array(unpack(wasm)) + "]), {})" + ".then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});" + "self.onmessage = workerProcess;" + decode.toString() + workerProcess.toString();
|
|
4719
|
+
var blob = new Blob([
|
|
4720
|
+
source
|
|
4721
|
+
], {
|
|
4722
|
+
type: "text/javascript"
|
|
4723
|
+
});
|
|
4724
|
+
var url = URL.createObjectURL(blob);
|
|
4725
|
+
for(var i = 0; i < count; ++i){
|
|
4726
|
+
workers[i] = createWorker(url);
|
|
4727
|
+
}
|
|
4728
|
+
URL.revokeObjectURL(url);
|
|
4729
|
+
};
|
|
4730
|
+
var decodeWorker = function decodeWorker(count, size, source, mode, filter) {
|
|
4731
|
+
var worker = workers[0];
|
|
4732
|
+
for(var i = 1; i < workers.length; ++i){
|
|
4733
|
+
if (workers[i].pending < worker.pending) {
|
|
4734
|
+
worker = workers[i];
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4737
|
+
return new Promise(function(resolve, reject) {
|
|
4738
|
+
var data = new Uint8Array(source);
|
|
4739
|
+
var id = requestId++;
|
|
4740
|
+
worker.pending += count;
|
|
4741
|
+
worker.requests[id] = {
|
|
4742
|
+
resolve: resolve,
|
|
4743
|
+
reject: reject
|
|
4744
|
+
};
|
|
4745
|
+
worker.object.postMessage({
|
|
4746
|
+
id: id,
|
|
4747
|
+
count: count,
|
|
4748
|
+
size: size,
|
|
4749
|
+
source: data,
|
|
4750
|
+
mode: mode,
|
|
4751
|
+
filter: filter
|
|
4752
|
+
}, [
|
|
4753
|
+
data.buffer
|
|
4754
|
+
]);
|
|
4755
|
+
});
|
|
4756
|
+
};
|
|
4757
|
+
var workerProcess = function workerProcess(event) {
|
|
4758
|
+
ready.then(function() {
|
|
4759
|
+
var data = event.data;
|
|
4760
|
+
try {
|
|
4761
|
+
var target = new Uint8Array(data.count * data.size);
|
|
4762
|
+
decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);
|
|
4763
|
+
self.postMessage({
|
|
4764
|
+
id: data.id,
|
|
4765
|
+
count: data.count,
|
|
4766
|
+
action: "resolve",
|
|
4767
|
+
value: target
|
|
4768
|
+
}, [
|
|
4769
|
+
target.buffer
|
|
4770
|
+
]);
|
|
4771
|
+
} catch (error) {
|
|
4772
|
+
self.postMessage({
|
|
4773
|
+
id: data.id,
|
|
4774
|
+
count: data.count,
|
|
4775
|
+
action: "reject",
|
|
4776
|
+
value: error
|
|
4777
|
+
});
|
|
4778
|
+
}
|
|
4779
|
+
});
|
|
4780
|
+
};
|
|
4781
|
+
var wasm_base = "b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb";
|
|
4782
|
+
var wasm_simd = "b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb";
|
|
4783
|
+
var wasmpack = new Uint8Array([
|
|
4784
|
+
32,
|
|
4785
|
+
0,
|
|
4786
|
+
65,
|
|
4787
|
+
2,
|
|
4788
|
+
1,
|
|
4789
|
+
106,
|
|
4790
|
+
34,
|
|
4791
|
+
33,
|
|
4792
|
+
3,
|
|
4793
|
+
128,
|
|
4794
|
+
11,
|
|
4795
|
+
4,
|
|
4796
|
+
13,
|
|
4797
|
+
64,
|
|
4798
|
+
6,
|
|
4799
|
+
253,
|
|
4800
|
+
10,
|
|
4801
|
+
7,
|
|
4802
|
+
15,
|
|
4803
|
+
116,
|
|
4804
|
+
127,
|
|
4805
|
+
5,
|
|
4806
|
+
8,
|
|
4807
|
+
12,
|
|
4808
|
+
40,
|
|
4809
|
+
16,
|
|
4810
|
+
19,
|
|
4811
|
+
54,
|
|
4812
|
+
20,
|
|
4813
|
+
9,
|
|
4814
|
+
27,
|
|
4815
|
+
255,
|
|
4816
|
+
113,
|
|
4817
|
+
17,
|
|
4818
|
+
42,
|
|
4819
|
+
67,
|
|
4820
|
+
24,
|
|
4821
|
+
23,
|
|
4822
|
+
146,
|
|
4823
|
+
148,
|
|
4824
|
+
18,
|
|
4825
|
+
14,
|
|
4826
|
+
22,
|
|
4827
|
+
45,
|
|
4828
|
+
70,
|
|
4829
|
+
69,
|
|
4830
|
+
56,
|
|
4831
|
+
114,
|
|
4832
|
+
101,
|
|
4833
|
+
21,
|
|
4834
|
+
25,
|
|
4835
|
+
63,
|
|
4836
|
+
75,
|
|
4837
|
+
136,
|
|
4838
|
+
108,
|
|
4839
|
+
28,
|
|
4840
|
+
118,
|
|
4841
|
+
29,
|
|
4842
|
+
73,
|
|
4843
|
+
115
|
|
4844
|
+
]);
|
|
4845
|
+
// @ts-ignore
|
|
4846
|
+
var wasm = engineCore.SystemInfo._detectSIMDSupported() ? wasm_simd : wasm_base;
|
|
4847
|
+
var instance;
|
|
4848
|
+
var ready = WebAssembly.instantiate(unpack(wasm), {}).then(function(result) {
|
|
4849
|
+
instance = result.instance;
|
|
4850
|
+
instance.exports.__wasm_call_ctors();
|
|
4851
|
+
});
|
|
4852
|
+
var filters = {
|
|
4853
|
+
NONE: "",
|
|
4854
|
+
OCTAHEDRAL: "meshopt_decodeFilterOct",
|
|
4855
|
+
QUATERNION: "meshopt_decodeFilterQuat",
|
|
4856
|
+
EXPONENTIAL: "meshopt_decodeFilterExp"
|
|
4857
|
+
};
|
|
4858
|
+
var decoders = {
|
|
4859
|
+
ATTRIBUTES: "meshopt_decodeVertexBuffer",
|
|
4860
|
+
TRIANGLES: "meshopt_decodeIndexBuffer",
|
|
4861
|
+
INDICES: "meshopt_decodeIndexSequence"
|
|
4862
|
+
};
|
|
4863
|
+
var workers = [];
|
|
4864
|
+
var requestId = 0;
|
|
4865
|
+
return {
|
|
4866
|
+
workerCount: 4,
|
|
4867
|
+
ready: ready,
|
|
4868
|
+
useWorkers: function useWorkers() {
|
|
4869
|
+
initWorkers(this.workerCount);
|
|
4870
|
+
},
|
|
4871
|
+
decodeGltfBuffer: function decodeGltfBuffer(count, stride, source, mode, filter) {
|
|
4872
|
+
if (this.workerCount > 0 && workers.length === 0) this.useWorkers();
|
|
4873
|
+
if (workers.length > 0) return decodeWorker(count, stride, source, decoders[mode], filters[filter]);
|
|
4874
|
+
return ready.then(function() {
|
|
4875
|
+
var target = new Uint8Array(count * stride);
|
|
4876
|
+
decode(instance.exports[decoders[mode]], target, count, stride, source, instance.exports[filters[filter]]);
|
|
4877
|
+
return target;
|
|
4878
|
+
});
|
|
4879
|
+
},
|
|
4880
|
+
release: function release() {
|
|
4881
|
+
for(var i = 0; i < workers.length; i++){
|
|
4882
|
+
workers[i].object.terminate();
|
|
4883
|
+
}
|
|
4884
|
+
}
|
|
4885
|
+
};
|
|
4886
|
+
}();
|
|
4887
|
+
|
|
4888
|
+
exports.GLTFLoader = /*#__PURE__*/ function(Loader1) {
|
|
4444
4889
|
_inherits(GLTFLoader, Loader1);
|
|
4445
4890
|
function GLTFLoader() {
|
|
4446
4891
|
return Loader1.apply(this, arguments);
|
|
4447
4892
|
}
|
|
4448
4893
|
var _proto = GLTFLoader.prototype;
|
|
4894
|
+
_proto.initialize = function initialize(_, configuration) {
|
|
4895
|
+
var _configuration_glTF;
|
|
4896
|
+
var meshOptOptions = (_configuration_glTF = configuration.glTF) == null ? void 0 : _configuration_glTF.meshOpt;
|
|
4897
|
+
if (meshOptOptions) {
|
|
4898
|
+
MeshoptDecoder.workerCount = meshOptOptions.workerCount;
|
|
4899
|
+
MeshoptDecoder.useWorkers();
|
|
4900
|
+
}
|
|
4901
|
+
return Promise.resolve();
|
|
4902
|
+
};
|
|
4449
4903
|
_proto.load = function load(item, resourceManager) {
|
|
4450
|
-
var _params;
|
|
4451
4904
|
var url = item.url;
|
|
4452
4905
|
var params = item.params;
|
|
4453
4906
|
var glTFResource = new GLTFResource(resourceManager.engine, url);
|
|
4454
|
-
var context = new GLTFParserContext(glTFResource, resourceManager,
|
|
4455
|
-
|
|
4907
|
+
var context = new GLTFParserContext(glTFResource, resourceManager, _extends({
|
|
4908
|
+
keepMeshData: false
|
|
4909
|
+
}, params));
|
|
4910
|
+
return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
4911
|
+
context._setTaskCompleteProgress = setTaskCompleteProgress;
|
|
4912
|
+
context._setTaskDetailProgress = setTaskDetailProgress;
|
|
4913
|
+
context.parse().then(resolve).catch(reject);
|
|
4914
|
+
});
|
|
4915
|
+
};
|
|
4916
|
+
/**
|
|
4917
|
+
* Release glTF loader memory(includes meshopt workers).
|
|
4918
|
+
* @remarks If use loader after releasing, we should release again.
|
|
4919
|
+
*/ GLTFLoader.release = function release() {
|
|
4920
|
+
MeshoptDecoder.release();
|
|
4456
4921
|
};
|
|
4457
4922
|
return GLTFLoader;
|
|
4458
4923
|
}(engineCore.Loader);
|
|
4459
|
-
GLTFLoader = __decorate([
|
|
4924
|
+
exports.GLTFLoader = __decorate([
|
|
4460
4925
|
engineCore.resourceLoader(engineCore.AssetType.GLTF, [
|
|
4461
4926
|
"gltf",
|
|
4462
4927
|
"glb"
|
|
4463
4928
|
])
|
|
4464
|
-
], GLTFLoader);
|
|
4929
|
+
], exports.GLTFLoader);
|
|
4465
4930
|
|
|
4466
4931
|
var _HDRLoader;
|
|
4467
4932
|
var PI = Math.PI;
|
|
@@ -5099,6 +5564,12 @@ var MaterialLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5099
5564
|
materialShaderData.setTexture(key, texture);
|
|
5100
5565
|
}));
|
|
5101
5566
|
break;
|
|
5567
|
+
case "Boolean":
|
|
5568
|
+
materialShaderData.setInt(key, value ? 1 : 0);
|
|
5569
|
+
break;
|
|
5570
|
+
case "Integer":
|
|
5571
|
+
materialShaderData.setInt(key, Number(value));
|
|
5572
|
+
break;
|
|
5102
5573
|
}
|
|
5103
5574
|
};
|
|
5104
5575
|
var engine = resourceManager.engine;
|
|
@@ -5219,7 +5690,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5219
5690
|
var _proto = SpriteAtlasLoader.prototype;
|
|
5220
5691
|
_proto.load = function load(item, resourceManager) {
|
|
5221
5692
|
var _this = this;
|
|
5222
|
-
return new engineCore.AssetPromise(function(resolve, reject, _, onCancel) {
|
|
5693
|
+
return new engineCore.AssetPromise(function(resolve, reject, _, __, onCancel) {
|
|
5223
5694
|
var chainPromises = [];
|
|
5224
5695
|
onCancel(function() {
|
|
5225
5696
|
for(var i = 0; i < chainPromises.length; i++){
|
|
@@ -5234,9 +5705,10 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5234
5705
|
var _loop = function(i) {
|
|
5235
5706
|
var atlasItem = atlasItems[i];
|
|
5236
5707
|
if (atlasItem.img) {
|
|
5708
|
+
var _atlasItem_type;
|
|
5237
5709
|
chainPromises.push(resourceManager.load({
|
|
5238
5710
|
url: engineCore.Utils.resolveAbsoluteUrl(item.url, atlasItem.img),
|
|
5239
|
-
type: engineCore.AssetType.Texture2D,
|
|
5711
|
+
type: (_atlasItem_type = atlasItem.type) != null ? _atlasItem_type : engineCore.AssetType.Texture2D,
|
|
5240
5712
|
params: {
|
|
5241
5713
|
format: format,
|
|
5242
5714
|
mipmap: mipmap
|
|
@@ -5276,7 +5748,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5276
5748
|
};
|
|
5277
5749
|
_proto._makeSprite = function _makeSprite(engine, config, texture) {
|
|
5278
5750
|
// Generate a SpriteAtlas object.
|
|
5279
|
-
var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border;
|
|
5751
|
+
var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border, width = config.width, height = config.height;
|
|
5280
5752
|
var sprite = new engineCore.Sprite(engine, texture, region ? this._tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? this._tempVec2.set(pivot.x, pivot.y) : undefined, border ? this._tempVec4.set(border.x, border.y, border.z, border.w) : undefined, config.name);
|
|
5281
5753
|
if (texture) {
|
|
5282
5754
|
var invW = 1 / texture.width;
|
|
@@ -5288,6 +5760,8 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5288
5760
|
}
|
|
5289
5761
|
config.atlasRotated && (sprite.atlasRotated = true);
|
|
5290
5762
|
}
|
|
5763
|
+
isNaN(width) || (sprite.width = width);
|
|
5764
|
+
isNaN(height) || (sprite.height = height);
|
|
5291
5765
|
return sprite;
|
|
5292
5766
|
};
|
|
5293
5767
|
return SpriteAtlasLoader;
|
|
@@ -5306,26 +5780,39 @@ var SpriteLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5306
5780
|
var _proto = SpriteLoader.prototype;
|
|
5307
5781
|
_proto.load = function load(item, resourceManager) {
|
|
5308
5782
|
var _this = this;
|
|
5309
|
-
return
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
if (data.belongToAtlas) {
|
|
5314
|
-
resourceManager// @ts-ignore
|
|
5315
|
-
.getResourceByRef(data.belongToAtlas).then(function(atlas) {
|
|
5316
|
-
resolve(atlas.getSprite(data.fullPath));
|
|
5317
|
-
}).catch(reject);
|
|
5318
|
-
} else if (data.texture) {
|
|
5319
|
-
resourceManager// @ts-ignore
|
|
5320
|
-
.getResourceByRef(data.texture).then(function(texture) {
|
|
5321
|
-
resolve(new engineCore.Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border));
|
|
5322
|
-
}).catch(reject);
|
|
5323
|
-
} else {
|
|
5324
|
-
resolve(new engineCore.Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
|
|
5325
|
-
}
|
|
5326
|
-
}).catch(reject);
|
|
5783
|
+
return this.request(item.url, _extends({}, item, {
|
|
5784
|
+
type: "json"
|
|
5785
|
+
})).then(function(data) {
|
|
5786
|
+
return data.belongToAtlas ? _this._loadFromAtlas(resourceManager, data) : _this._loadFromTexture(resourceManager, data);
|
|
5327
5787
|
});
|
|
5328
5788
|
};
|
|
5789
|
+
_proto._loadFromAtlas = function _loadFromAtlas(resourceManager, data) {
|
|
5790
|
+
var _this = this;
|
|
5791
|
+
return resourceManager// @ts-ignore
|
|
5792
|
+
.getResourceByRef(data.belongToAtlas).then(function(atlas) {
|
|
5793
|
+
return atlas.getSprite(data.fullPath) || _this._loadFromTexture(resourceManager, data);
|
|
5794
|
+
});
|
|
5795
|
+
};
|
|
5796
|
+
_proto._loadFromTexture = function _loadFromTexture(resourceManager, data) {
|
|
5797
|
+
if (data.texture) {
|
|
5798
|
+
return resourceManager// @ts-ignore
|
|
5799
|
+
.getResourceByRef(data.texture).then(function(texture) {
|
|
5800
|
+
var sprite = new engineCore.Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border);
|
|
5801
|
+
var width = data.width, height = data.height;
|
|
5802
|
+
isNaN(width) || (sprite.width = width);
|
|
5803
|
+
isNaN(height) || (sprite.height = height);
|
|
5804
|
+
return sprite;
|
|
5805
|
+
});
|
|
5806
|
+
} else {
|
|
5807
|
+
return new engineCore.AssetPromise(function(resolve) {
|
|
5808
|
+
var sprite = new engineCore.Sprite(resourceManager.engine, null, data.region, data.pivot, data.border);
|
|
5809
|
+
var width = data.width, height = data.height;
|
|
5810
|
+
isNaN(width) || (sprite.width = width);
|
|
5811
|
+
isNaN(height) || (sprite.height = height);
|
|
5812
|
+
resolve(sprite);
|
|
5813
|
+
});
|
|
5814
|
+
}
|
|
5815
|
+
};
|
|
5329
5816
|
return SpriteLoader;
|
|
5330
5817
|
}(engineCore.Loader);
|
|
5331
5818
|
SpriteLoader = __decorate([
|
|
@@ -5366,15 +5853,19 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5366
5853
|
var _proto = Texture2DLoader.prototype;
|
|
5367
5854
|
_proto.load = function load(item, resourceManager) {
|
|
5368
5855
|
var _this = this;
|
|
5369
|
-
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
5856
|
+
return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
5370
5857
|
var url = item.url;
|
|
5371
5858
|
var requestConfig = _extends({}, item, {
|
|
5372
5859
|
type: "image"
|
|
5373
5860
|
});
|
|
5374
|
-
_this.request(url, requestConfig).then(function(image) {
|
|
5375
|
-
var
|
|
5376
|
-
var
|
|
5377
|
-
var texture = new engineCore.Texture2D(resourceManager.engine, image.width, image.height,
|
|
5861
|
+
_this.request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
|
|
5862
|
+
var _item_params;
|
|
5863
|
+
var _ref = (_item_params = item.params) != null ? _item_params : {}, format = _ref.format, mipmap = _ref.mipmap, anisoLevel = _ref.anisoLevel, wrapModeU = _ref.wrapModeU, wrapModeV = _ref.wrapModeV, filterMode = _ref.filterMode;
|
|
5864
|
+
var texture = new engineCore.Texture2D(resourceManager.engine, image.width, image.height, format, mipmap);
|
|
5865
|
+
texture.anisoLevel = anisoLevel != null ? anisoLevel : texture.anisoLevel;
|
|
5866
|
+
texture.filterMode = filterMode != null ? filterMode : texture.filterMode;
|
|
5867
|
+
texture.wrapModeU = wrapModeU != null ? wrapModeU : texture.wrapModeU;
|
|
5868
|
+
texture.wrapModeV = wrapModeV != null ? wrapModeV : texture.wrapModeV;
|
|
5378
5869
|
texture.setImageSource(image);
|
|
5379
5870
|
texture.generateMipmaps();
|
|
5380
5871
|
if (url.indexOf("data:") !== 0) {
|
|
@@ -5522,33 +6013,34 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5522
6013
|
var promises = [];
|
|
5523
6014
|
// parse ambient light
|
|
5524
6015
|
var ambient = data.scene.ambient;
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
// prettier-ignore
|
|
5529
|
-
var customAmbientPromise = resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
5530
|
-
scene.ambientLight = ambientLight;
|
|
5531
|
-
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5532
|
-
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5533
|
-
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5534
|
-
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5535
|
-
});
|
|
5536
|
-
promises.push(customAmbientPromise);
|
|
5537
|
-
} else if (!useCustomAmbient && ambient.ambientLight) {
|
|
5538
|
-
// @ts-ignore
|
|
5539
|
-
// prettier-ignore
|
|
5540
|
-
var ambientLightPromise = resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
5541
|
-
scene.ambientLight = ambientLight;
|
|
5542
|
-
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5543
|
-
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5544
|
-
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5545
|
-
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5546
|
-
});
|
|
5547
|
-
promises.push(ambientLightPromise);
|
|
5548
|
-
} else {
|
|
6016
|
+
if (ambient) {
|
|
6017
|
+
var useCustomAmbient = ambient.specularMode === "Custom";
|
|
6018
|
+
var useSH = ambient.diffuseMode === engineCore.DiffuseMode.SphericalHarmonics;
|
|
5549
6019
|
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5550
6020
|
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
6021
|
+
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5551
6022
|
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
6023
|
+
scene.ambientLight.specularTextureDecodeRGBM = true;
|
|
6024
|
+
if (useCustomAmbient && ambient.customAmbientLight) {
|
|
6025
|
+
promises.push(// @ts-ignore
|
|
6026
|
+
resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
6027
|
+
var _ambientLight;
|
|
6028
|
+
scene.ambientLight.specularTexture = (_ambientLight = ambientLight) == null ? void 0 : _ambientLight.specularTexture;
|
|
6029
|
+
}));
|
|
6030
|
+
}
|
|
6031
|
+
if (ambient.ambientLight && (!useCustomAmbient || useSH)) {
|
|
6032
|
+
promises.push(// @ts-ignore
|
|
6033
|
+
resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
6034
|
+
if (!useCustomAmbient) {
|
|
6035
|
+
var _ambientLight;
|
|
6036
|
+
scene.ambientLight.specularTexture = (_ambientLight = ambientLight) == null ? void 0 : _ambientLight.specularTexture;
|
|
6037
|
+
}
|
|
6038
|
+
if (useSH) {
|
|
6039
|
+
var _ambientLight1;
|
|
6040
|
+
scene.ambientLight.diffuseSphericalHarmonics = (_ambientLight1 = ambientLight) == null ? void 0 : _ambientLight1.diffuseSphericalHarmonics;
|
|
6041
|
+
}
|
|
6042
|
+
}));
|
|
6043
|
+
}
|
|
5552
6044
|
}
|
|
5553
6045
|
var background = data.scene.background;
|
|
5554
6046
|
scene.background.mode = background.mode;
|
|
@@ -5590,6 +6082,9 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5590
6082
|
if (shadow.shadowResolution != undefined) scene.shadowResolution = shadow.shadowResolution;
|
|
5591
6083
|
if (shadow.shadowDistance != undefined) scene.shadowDistance = shadow.shadowDistance;
|
|
5592
6084
|
if (shadow.shadowCascades != undefined) scene.shadowCascades = shadow.shadowCascades;
|
|
6085
|
+
var _shadow_shadowTwoCascadeSplits;
|
|
6086
|
+
scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
|
|
6087
|
+
shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
|
|
5593
6088
|
}
|
|
5594
6089
|
return Promise.all(promises).then(function() {
|
|
5595
6090
|
resolve(scene);
|
|
@@ -5605,13 +6100,13 @@ SceneLoader = __decorate([
|
|
|
5605
6100
|
"scene"
|
|
5606
6101
|
], true)
|
|
5607
6102
|
], SceneLoader);
|
|
5608
|
-
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item
|
|
6103
|
+
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item) {
|
|
5609
6104
|
var props;
|
|
5610
6105
|
return __generator(this, function(_state) {
|
|
5611
6106
|
props = item.props;
|
|
5612
6107
|
if (!props.font) {
|
|
5613
6108
|
// @ts-ignore
|
|
5614
|
-
instance.font = engineCore.Font.createFromOS(engine, props.fontFamily || "Arial");
|
|
6109
|
+
instance.font = engineCore.Font.createFromOS(instance.engine, props.fontFamily || "Arial");
|
|
5615
6110
|
}
|
|
5616
6111
|
return [
|
|
5617
6112
|
2,
|
|
@@ -5620,170 +6115,6 @@ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asy
|
|
|
5620
6115
|
});
|
|
5621
6116
|
}));
|
|
5622
6117
|
|
|
5623
|
-
var _KHR_draco_mesh_compression;
|
|
5624
|
-
var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
5625
|
-
_inherits(KHR_draco_mesh_compression1, GLTFExtensionParser1);
|
|
5626
|
-
function KHR_draco_mesh_compression1() {
|
|
5627
|
-
return GLTFExtensionParser1.apply(this, arguments);
|
|
5628
|
-
}
|
|
5629
|
-
var _proto = KHR_draco_mesh_compression1.prototype;
|
|
5630
|
-
_proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
|
|
5631
|
-
var _this = this;
|
|
5632
|
-
this._initialize();
|
|
5633
|
-
var glTF = context.glTF, engine = context.glTFResource.engine;
|
|
5634
|
-
var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
|
|
5635
|
-
var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
|
|
5636
|
-
var attributeMap = {};
|
|
5637
|
-
var attributeTypeMap = {};
|
|
5638
|
-
for(var attributeName in gltfAttributeMap){
|
|
5639
|
-
attributeMap[attributeName] = gltfAttributeMap[attributeName];
|
|
5640
|
-
}
|
|
5641
|
-
for(var attributeName1 in glTFPrimitive.attributes){
|
|
5642
|
-
if (gltfAttributeMap[attributeName1] !== undefined) {
|
|
5643
|
-
var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
|
|
5644
|
-
attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
|
|
5645
|
-
}
|
|
5646
|
-
}
|
|
5647
|
-
var indexAccessor = accessors[glTFPrimitive.indices];
|
|
5648
|
-
var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
|
|
5649
|
-
var taskConfig = {
|
|
5650
|
-
attributeIDs: attributeMap,
|
|
5651
|
-
attributeTypes: attributeTypeMap,
|
|
5652
|
-
useUniqueIDs: true,
|
|
5653
|
-
indexType: indexType
|
|
5654
|
-
};
|
|
5655
|
-
return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
5656
|
-
var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
5657
|
-
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
|
|
5658
|
-
var mesh = new engineCore.ModelMesh(engine, glTFMesh.name);
|
|
5659
|
-
return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
|
|
5660
|
-
for(var j = 0; j < decodedGeometry.attributes.length; j++){
|
|
5661
|
-
if (decodedGeometry.attributes[j].name === attributeSemantic) {
|
|
5662
|
-
return decodedGeometry.attributes[j].array;
|
|
5663
|
-
}
|
|
5664
|
-
}
|
|
5665
|
-
return null;
|
|
5666
|
-
}, function(attributeSemantic, shapeIndex) {
|
|
5667
|
-
throw "BlendShape animation is not supported when using draco.";
|
|
5668
|
-
}, function() {
|
|
5669
|
-
return decodedGeometry.index.array;
|
|
5670
|
-
}, context.keepMeshData);
|
|
5671
|
-
});
|
|
5672
|
-
});
|
|
5673
|
-
};
|
|
5674
|
-
_proto._initialize = function _initialize() {
|
|
5675
|
-
if (!KHR_draco_mesh_compression._decoder) {
|
|
5676
|
-
KHR_draco_mesh_compression._decoder = new engineDraco.DRACODecoder();
|
|
5677
|
-
}
|
|
5678
|
-
};
|
|
5679
|
-
_proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
5680
|
-
var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
|
|
5681
|
-
var vertexCount;
|
|
5682
|
-
var accessors = gltf.accessors;
|
|
5683
|
-
var accessor = accessors[attributes["POSITION"]];
|
|
5684
|
-
var positionBuffer = getVertexBufferData("POSITION");
|
|
5685
|
-
var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
|
|
5686
|
-
mesh.setPositions(positions);
|
|
5687
|
-
var bounds = mesh.bounds;
|
|
5688
|
-
vertexCount = accessor.count;
|
|
5689
|
-
if (accessor.min && accessor.max) {
|
|
5690
|
-
bounds.min.copyFromArray(accessor.min);
|
|
5691
|
-
bounds.max.copyFromArray(accessor.max);
|
|
5692
|
-
} else {
|
|
5693
|
-
var position = KHR_draco_mesh_compression._tempVector3;
|
|
5694
|
-
var min = bounds.min, max = bounds.max;
|
|
5695
|
-
min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
5696
|
-
max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
5697
|
-
var stride = positionBuffer.length / vertexCount;
|
|
5698
|
-
for(var j = 0; j < vertexCount; j++){
|
|
5699
|
-
var offset = j * stride;
|
|
5700
|
-
position.copyFromArray(positionBuffer, offset);
|
|
5701
|
-
engineMath.Vector3.min(min, position, min);
|
|
5702
|
-
engineMath.Vector3.max(max, position, max);
|
|
5703
|
-
}
|
|
5704
|
-
}
|
|
5705
|
-
for(var attributeSemantic in attributes){
|
|
5706
|
-
if (attributeSemantic === "POSITION") {
|
|
5707
|
-
continue;
|
|
5708
|
-
}
|
|
5709
|
-
var bufferData = getVertexBufferData(attributeSemantic);
|
|
5710
|
-
switch(attributeSemantic){
|
|
5711
|
-
case "NORMAL":
|
|
5712
|
-
var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
|
|
5713
|
-
mesh.setNormals(normals);
|
|
5714
|
-
break;
|
|
5715
|
-
case "TEXCOORD_0":
|
|
5716
|
-
var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
5717
|
-
mesh.setUVs(texturecoords, 0);
|
|
5718
|
-
break;
|
|
5719
|
-
case "TEXCOORD_1":
|
|
5720
|
-
var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
5721
|
-
mesh.setUVs(texturecoords1, 1);
|
|
5722
|
-
break;
|
|
5723
|
-
case "TEXCOORD_2":
|
|
5724
|
-
var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
5725
|
-
mesh.setUVs(texturecoords2, 2);
|
|
5726
|
-
break;
|
|
5727
|
-
case "TEXCOORD_3":
|
|
5728
|
-
var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
5729
|
-
mesh.setUVs(texturecoords3, 3);
|
|
5730
|
-
break;
|
|
5731
|
-
case "TEXCOORD_4":
|
|
5732
|
-
var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
5733
|
-
mesh.setUVs(texturecoords4, 4);
|
|
5734
|
-
break;
|
|
5735
|
-
case "TEXCOORD_5":
|
|
5736
|
-
var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
5737
|
-
mesh.setUVs(texturecoords5, 5);
|
|
5738
|
-
break;
|
|
5739
|
-
case "TEXCOORD_6":
|
|
5740
|
-
var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
5741
|
-
mesh.setUVs(texturecoords6, 6);
|
|
5742
|
-
break;
|
|
5743
|
-
case "TEXCOORD_7":
|
|
5744
|
-
var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
|
|
5745
|
-
mesh.setUVs(texturecoords7, 7);
|
|
5746
|
-
break;
|
|
5747
|
-
case "COLOR_0":
|
|
5748
|
-
var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
|
|
5749
|
-
mesh.setColors(colors);
|
|
5750
|
-
break;
|
|
5751
|
-
case "TANGENT":
|
|
5752
|
-
var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
5753
|
-
mesh.setTangents(tangents);
|
|
5754
|
-
break;
|
|
5755
|
-
case "JOINTS_0":
|
|
5756
|
-
var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
5757
|
-
mesh.setBoneIndices(joints);
|
|
5758
|
-
break;
|
|
5759
|
-
case "WEIGHTS_0":
|
|
5760
|
-
var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
|
|
5761
|
-
mesh.setBoneWeights(weights);
|
|
5762
|
-
break;
|
|
5763
|
-
}
|
|
5764
|
-
}
|
|
5765
|
-
// Indices
|
|
5766
|
-
if (indices !== undefined) {
|
|
5767
|
-
var indexAccessor = gltf.accessors[indices];
|
|
5768
|
-
var indexData = getIndexBufferData();
|
|
5769
|
-
mesh.setIndices(indexData);
|
|
5770
|
-
mesh.addSubMesh(0, indexAccessor.count, mode);
|
|
5771
|
-
} else {
|
|
5772
|
-
mesh.addSubMesh(0, vertexCount, mode);
|
|
5773
|
-
}
|
|
5774
|
-
// BlendShapes
|
|
5775
|
-
targets && exports.GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, accessors, targets, getBlendShapeData);
|
|
5776
|
-
mesh.uploadData(!keepMeshData);
|
|
5777
|
-
return Promise.resolve(mesh);
|
|
5778
|
-
};
|
|
5779
|
-
return KHR_draco_mesh_compression1;
|
|
5780
|
-
}(GLTFExtensionParser), function() {
|
|
5781
|
-
_KHR_draco_mesh_compression._tempVector3 = new engineMath.Vector3();
|
|
5782
|
-
}(), _KHR_draco_mesh_compression);
|
|
5783
|
-
KHR_draco_mesh_compression = __decorate([
|
|
5784
|
-
registerGLTFExtension("KHR_draco_mesh_compression", exports.GLTFExtensionMode.CreateAndParse)
|
|
5785
|
-
], KHR_draco_mesh_compression);
|
|
5786
|
-
|
|
5787
6118
|
var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
5788
6119
|
_inherits(KHR_lights_punctual, GLTFExtensionParser1);
|
|
5789
6120
|
function KHR_lights_punctual() {
|
|
@@ -5958,7 +6289,7 @@ var KHR_materials_variants = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5958
6289
|
var _glTFResource;
|
|
5959
6290
|
var _context_glTF = context.glTF, _context_glTF_extensions = _context_glTF.extensions, _context_glTF_extensions_KHR_materials_variants = _context_glTF_extensions.KHR_materials_variants, variantNames = _context_glTF_extensions_KHR_materials_variants.variants, glTFResource = context.glTFResource;
|
|
5960
6291
|
var mappings = schema.mappings;
|
|
5961
|
-
(_glTFResource = glTFResource).
|
|
6292
|
+
(_glTFResource = glTFResource)._extensionsData || (_glTFResource._extensionsData = {});
|
|
5962
6293
|
var extensionData = [];
|
|
5963
6294
|
glTFResource.extensionsData.variants = extensionData;
|
|
5964
6295
|
for(var i = 0; i < mappings.length; i++)_loop(i);
|
|
@@ -5988,7 +6319,7 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5988
6319
|
var _proto = KHR_texture_basisu.prototype;
|
|
5989
6320
|
_proto.createAndParse = function createAndParse(context, schema, textureInfo) {
|
|
5990
6321
|
return _async_to_generator(function() {
|
|
5991
|
-
var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, bufferView;
|
|
6322
|
+
var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, promise, bufferView;
|
|
5992
6323
|
return __generator(this, function(_state) {
|
|
5993
6324
|
glTF = context.glTF, glTFResource = context.glTFResource;
|
|
5994
6325
|
engine = glTFResource.engine, url = glTFResource.url;
|
|
@@ -5998,20 +6329,22 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5998
6329
|
samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
|
|
5999
6330
|
if (uri) {
|
|
6000
6331
|
index = uri.lastIndexOf(".");
|
|
6332
|
+
promise = engine.resourceManager.load({
|
|
6333
|
+
url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
|
|
6334
|
+
type: engineCore.AssetType.KTX2
|
|
6335
|
+
}).onProgress(undefined, context._onTaskDetail).then(function(texture) {
|
|
6336
|
+
if (!texture.name) {
|
|
6337
|
+
texture.name = textureName || imageName || "texture_" + index;
|
|
6338
|
+
}
|
|
6339
|
+
if (sampler !== undefined) {
|
|
6340
|
+
GLTFUtils.parseSampler(texture, samplerInfo);
|
|
6341
|
+
}
|
|
6342
|
+
return texture;
|
|
6343
|
+
});
|
|
6344
|
+
context._addTaskCompletePromise(promise);
|
|
6001
6345
|
return [
|
|
6002
6346
|
2,
|
|
6003
|
-
|
|
6004
|
-
url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
|
|
6005
|
-
type: engineCore.AssetType.KTX2
|
|
6006
|
-
}).then(function(texture) {
|
|
6007
|
-
if (!texture.name) {
|
|
6008
|
-
texture.name = textureName || imageName || "texture_" + index;
|
|
6009
|
-
}
|
|
6010
|
-
if (sampler !== undefined) {
|
|
6011
|
-
GLTFUtils.parseSampler(texture, samplerInfo);
|
|
6012
|
-
}
|
|
6013
|
-
return texture;
|
|
6014
|
-
})
|
|
6347
|
+
promise
|
|
6015
6348
|
];
|
|
6016
6349
|
} else {
|
|
6017
6350
|
bufferView = glTF.bufferViews[bufferViewIndex];
|
|
@@ -6081,7 +6414,9 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
6081
6414
|
_proto.createAndParse = function createAndParse(context, schema) {
|
|
6082
6415
|
var engine = context.glTFResource.engine;
|
|
6083
6416
|
// @ts-ignore
|
|
6084
|
-
|
|
6417
|
+
var promise = engine.resourceManager.getResourceByRef(schema);
|
|
6418
|
+
context._addTaskCompletePromise(promise);
|
|
6419
|
+
return promise;
|
|
6085
6420
|
};
|
|
6086
6421
|
return GALACEAN_materials_remap;
|
|
6087
6422
|
}(GLTFExtensionParser);
|
|
@@ -6112,6 +6447,47 @@ GALACEAN_animation_event = __decorate([
|
|
|
6112
6447
|
registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
|
|
6113
6448
|
], GALACEAN_animation_event);
|
|
6114
6449
|
|
|
6450
|
+
var EXT_meshopt_compression = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
6451
|
+
_inherits(EXT_meshopt_compression, GLTFExtensionParser1);
|
|
6452
|
+
function EXT_meshopt_compression() {
|
|
6453
|
+
return GLTFExtensionParser1.apply(this, arguments);
|
|
6454
|
+
}
|
|
6455
|
+
var _proto = EXT_meshopt_compression.prototype;
|
|
6456
|
+
_proto.createAndParse = function createAndParse(context, schema) {
|
|
6457
|
+
return context.get(exports.GLTFParserType.Buffer, schema.buffer).then(function(arrayBuffer) {
|
|
6458
|
+
return MeshoptDecoder.decodeGltfBuffer(schema.count, schema.byteStride, new Uint8Array(arrayBuffer, schema.byteOffset, schema.byteLength), schema.mode, schema.filter);
|
|
6459
|
+
});
|
|
6460
|
+
};
|
|
6461
|
+
return EXT_meshopt_compression;
|
|
6462
|
+
}(GLTFExtensionParser);
|
|
6463
|
+
EXT_meshopt_compression = __decorate([
|
|
6464
|
+
registerGLTFExtension("EXT_meshopt_compression", exports.GLTFExtensionMode.CreateAndParse)
|
|
6465
|
+
], EXT_meshopt_compression);
|
|
6466
|
+
|
|
6467
|
+
var KHR_materials_anisotropy = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
6468
|
+
_inherits(KHR_materials_anisotropy, GLTFExtensionParser1);
|
|
6469
|
+
function KHR_materials_anisotropy() {
|
|
6470
|
+
return GLTFExtensionParser1.apply(this, arguments);
|
|
6471
|
+
}
|
|
6472
|
+
var _proto = KHR_materials_anisotropy.prototype;
|
|
6473
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
6474
|
+
var _schema_anisotropyStrength = schema.anisotropyStrength, anisotropyStrength = _schema_anisotropyStrength === void 0 ? 0 : _schema_anisotropyStrength, _schema_anisotropyRotation = schema.anisotropyRotation, anisotropyRotation = _schema_anisotropyRotation === void 0 ? 0 : _schema_anisotropyRotation, anisotropyTexture = schema.anisotropyTexture;
|
|
6475
|
+
material.anisotropy = anisotropyStrength;
|
|
6476
|
+
material.anisotropyRotation = anisotropyRotation;
|
|
6477
|
+
if (anisotropyTexture) {
|
|
6478
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(anisotropyTexture, "Anisotropy texture");
|
|
6479
|
+
context.get(exports.GLTFParserType.Texture, anisotropyTexture.index).then(function(texture) {
|
|
6480
|
+
material.anisotropyTexture = texture;
|
|
6481
|
+
});
|
|
6482
|
+
}
|
|
6483
|
+
};
|
|
6484
|
+
return KHR_materials_anisotropy;
|
|
6485
|
+
}(GLTFExtensionParser);
|
|
6486
|
+
KHR_materials_anisotropy = __decorate([
|
|
6487
|
+
registerGLTFExtension("KHR_materials_anisotropy", exports.GLTFExtensionMode.AdditiveParse)
|
|
6488
|
+
], KHR_materials_anisotropy);
|
|
6489
|
+
|
|
6490
|
+
exports.BufferInfo = BufferInfo;
|
|
6115
6491
|
exports.ComponentMap = ComponentMap;
|
|
6116
6492
|
exports.GLTFExtensionParser = GLTFExtensionParser;
|
|
6117
6493
|
exports.GLTFParser = GLTFParser;
|