@galacean/engine-loader 1.1.0-beta.8 → 1.2.0-alpha.0
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 +499 -245
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +499 -245
- package/dist/module.js +501 -247
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/GLTFLoader.d.ts +1 -0
- package/types/Texture2DLoader.d.ts +9 -1
- package/types/gltf/GLTFResource.d.ts +50 -16
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +9 -1
- package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
- package/types/gltf/extensions/index.d.ts +1 -0
- package/types/gltf/parser/GLTFJSONParser.d.ts +7 -0
- package/types/gltf/parser/GLTFParserContext.d.ts +17 -2
- package/types/gltf/parser/GLTFSceneParser.d.ts +0 -1
- package/types/index.d.ts +1 -1
- package/types/ktx2/KTX2Loader.d.ts +16 -5
- package/types/ktx2/transcoder/AbstractTranscoder.d.ts +1 -1
- package/types/ktx2/transcoder/BinomialLLCTranscoder.d.ts +1 -1
- package/types/ktx2/transcoder/BinomialLLCWorkerCode.d.ts +1 -1
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +1 -1
- 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/types/ktx2/BinomialLLCTranscoder/BinomialLLCTranscoder.d.ts +0 -13
- package/types/ktx2/BinomialLLCTranscoder/TranscodeWorkerCode.d.ts +0 -33
- package/types/ktx2/KhronosTranscoder/KhronosTranscoder.d.ts +0 -17
- package/types/ktx2/KhronosTranscoder/TranscoderWorkerCode.d.ts +0 -34
- package/types/ktx2/TranscodeResult.d.ts +0 -10
- package/types/ktx2/constants.d.ts +0 -7
- package/types/ktx2/zstddec.d.ts +0 -62
package/dist/main.js
CHANGED
|
@@ -120,116 +120,116 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
120
120
|
this.data = data;
|
|
121
121
|
this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength != null ? byteLength : data.byteLength - byteOffset);
|
|
122
122
|
this._littleEndian = littleEndian;
|
|
123
|
-
this.
|
|
123
|
+
this._position = 0;
|
|
124
124
|
this._baseOffset = byteOffset;
|
|
125
125
|
}
|
|
126
126
|
var _proto = BufferReader.prototype;
|
|
127
127
|
_proto.nextUint8 = function nextUint8() {
|
|
128
|
-
var value = this._dataView.getUint8(this.
|
|
129
|
-
this.
|
|
128
|
+
var value = this._dataView.getUint8(this._position);
|
|
129
|
+
this._position += 1;
|
|
130
130
|
return value;
|
|
131
131
|
};
|
|
132
132
|
_proto.nextUint16 = function nextUint16() {
|
|
133
|
-
var value = this._dataView.getUint16(this.
|
|
134
|
-
this.
|
|
133
|
+
var value = this._dataView.getUint16(this._position, this._littleEndian);
|
|
134
|
+
this._position += 2;
|
|
135
135
|
return value;
|
|
136
136
|
};
|
|
137
137
|
_proto.nextUint32 = function nextUint32() {
|
|
138
|
-
var value = this._dataView.getUint32(this.
|
|
139
|
-
this.
|
|
138
|
+
var value = this._dataView.getUint32(this._position, this._littleEndian);
|
|
139
|
+
this._position += 4;
|
|
140
140
|
return value;
|
|
141
141
|
};
|
|
142
142
|
_proto.nextInt32 = function nextInt32() {
|
|
143
|
-
var value = this._dataView.getInt32(this.
|
|
144
|
-
this.
|
|
143
|
+
var value = this._dataView.getInt32(this._position, this._littleEndian);
|
|
144
|
+
this._position += 4;
|
|
145
145
|
return value;
|
|
146
146
|
};
|
|
147
147
|
_proto.nextInt32Array = function nextInt32Array(len) {
|
|
148
|
-
var value = new Int32Array(this.data.buffer, this.
|
|
149
|
-
this.
|
|
148
|
+
var value = new Int32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
149
|
+
this._position += 4 * len;
|
|
150
150
|
return value;
|
|
151
151
|
};
|
|
152
152
|
_proto.nextFloat32 = function nextFloat32() {
|
|
153
|
-
var value = this._dataView.getFloat32(this.
|
|
154
|
-
this.
|
|
153
|
+
var value = this._dataView.getFloat32(this._position, this._littleEndian);
|
|
154
|
+
this._position += 4;
|
|
155
155
|
return value;
|
|
156
156
|
};
|
|
157
157
|
_proto.nextFloat32Array = function nextFloat32Array(len) {
|
|
158
|
-
var value = new Float32Array(this.data.buffer, this.
|
|
159
|
-
this.
|
|
158
|
+
var value = new Float32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
159
|
+
this._position += 4 * len;
|
|
160
160
|
return value;
|
|
161
161
|
};
|
|
162
162
|
_proto.nextUint32Array = function nextUint32Array(len) {
|
|
163
|
-
var value = new Uint32Array(this.data.buffer, this.
|
|
164
|
-
this.
|
|
163
|
+
var value = new Uint32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
164
|
+
this._position += 4 * len;
|
|
165
165
|
return value;
|
|
166
166
|
};
|
|
167
167
|
_proto.nextUint8Array = function nextUint8Array(len) {
|
|
168
|
-
var value = new Uint8Array(this.data.buffer, this.
|
|
169
|
-
this.
|
|
168
|
+
var value = new Uint8Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
169
|
+
this._position += len;
|
|
170
170
|
return value;
|
|
171
171
|
};
|
|
172
172
|
_proto.nextUint64 = function nextUint64() {
|
|
173
|
-
var left = this._dataView.getUint32(this.
|
|
174
|
-
var right = this._dataView.getUint32(this.
|
|
173
|
+
var left = this._dataView.getUint32(this._position, this._littleEndian);
|
|
174
|
+
var right = this._dataView.getUint32(this._position + 4, this._littleEndian);
|
|
175
175
|
var value = left + Math.pow(2, 32) * right;
|
|
176
|
-
this.
|
|
176
|
+
this._position += 8;
|
|
177
177
|
return value;
|
|
178
178
|
};
|
|
179
179
|
_proto.nextStr = function nextStr() {
|
|
180
180
|
var strByteLength = this.nextUint16();
|
|
181
|
-
var uint8Array = new Uint8Array(this.data.buffer, this.
|
|
182
|
-
this.
|
|
181
|
+
var uint8Array = new Uint8Array(this.data.buffer, this._position + this._dataView.byteOffset, strByteLength);
|
|
182
|
+
this._position += strByteLength;
|
|
183
183
|
return engineCore.Utils.decodeText(uint8Array);
|
|
184
184
|
};
|
|
185
185
|
/**
|
|
186
186
|
* image data 放在最后
|
|
187
187
|
*/ _proto.nextImageData = function nextImageData(count) {
|
|
188
|
-
return new Uint8Array(this.data.buffer, this.data.byteOffset + this.
|
|
188
|
+
return new Uint8Array(this.data.buffer, this.data.byteOffset + this._position);
|
|
189
189
|
};
|
|
190
190
|
_proto.nextImagesData = function nextImagesData(count) {
|
|
191
191
|
var imagesLen = new Array(count);
|
|
192
192
|
// 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
193
|
for(var i = 0; i < count; i++){
|
|
194
|
-
var len = this._dataView.getUint32(this.
|
|
194
|
+
var len = this._dataView.getUint32(this._position, this._littleEndian);
|
|
195
195
|
imagesLen[i] = len;
|
|
196
|
-
this.
|
|
196
|
+
this._position += 4;
|
|
197
197
|
}
|
|
198
198
|
var imagesData = [];
|
|
199
199
|
for(var i1 = 0; i1 < count; i1++){
|
|
200
200
|
var len1 = imagesLen[i1];
|
|
201
|
-
var buffer = new Uint8Array(this.data.buffer, this._dataView.byteOffset + this.
|
|
202
|
-
this.
|
|
201
|
+
var buffer = new Uint8Array(this.data.buffer, this._dataView.byteOffset + this._position, len1);
|
|
202
|
+
this._position += len1;
|
|
203
203
|
imagesData.push(buffer);
|
|
204
204
|
}
|
|
205
205
|
return imagesData;
|
|
206
206
|
};
|
|
207
207
|
_proto.skip = function skip(bytes) {
|
|
208
|
-
this.
|
|
208
|
+
this._position += bytes;
|
|
209
209
|
return this;
|
|
210
210
|
};
|
|
211
211
|
_proto.scan = function scan(maxByteLength, term) {
|
|
212
212
|
if (term === void 0) term = 0x00;
|
|
213
|
-
var byteOffset = this.
|
|
213
|
+
var byteOffset = this._position;
|
|
214
214
|
var byteLength = 0;
|
|
215
|
-
while(this._dataView.getUint8(this.
|
|
215
|
+
while(this._dataView.getUint8(this._position) !== term && byteLength < maxByteLength){
|
|
216
216
|
byteLength++;
|
|
217
|
-
this.
|
|
217
|
+
this._position++;
|
|
218
218
|
}
|
|
219
|
-
if (byteLength < maxByteLength) this.
|
|
219
|
+
if (byteLength < maxByteLength) this._position++;
|
|
220
220
|
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
|
221
221
|
};
|
|
222
222
|
_create_class(BufferReader, [
|
|
223
223
|
{
|
|
224
224
|
key: "position",
|
|
225
225
|
get: function get() {
|
|
226
|
-
return this.
|
|
226
|
+
return this._position;
|
|
227
227
|
}
|
|
228
228
|
},
|
|
229
229
|
{
|
|
230
230
|
key: "offset",
|
|
231
231
|
get: function get() {
|
|
232
|
-
return this.
|
|
232
|
+
return this._position + this._baseOffset;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
]);
|
|
@@ -293,75 +293,74 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
|
|
|
293
293
|
var encodedMeshData = JSON.parse(jsonDataString);
|
|
294
294
|
// @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
|
|
295
295
|
encodedMeshData.bounds && modelMesh.bounds.copyFrom(encodedMeshData.bounds);
|
|
296
|
-
var offset = Math.ceil(bufferReader.offset / 4) * 4;
|
|
296
|
+
var offset = Math.ceil(bufferReader.offset / 4) * 4 + bufferReader.data.byteOffset;
|
|
297
297
|
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);
|
|
298
|
+
var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
|
|
300
299
|
var vertexCount = float32Array.length / 3;
|
|
301
300
|
var positions = float32ArrayToVector3(float32Array, vertexCount);
|
|
302
301
|
modelMesh.setPositions(positions);
|
|
303
302
|
if (encodedMeshData.normals) {
|
|
304
|
-
var float32Array1 = new Float32Array(buffer, encodedMeshData.normals.start + offset
|
|
303
|
+
var float32Array1 = new Float32Array(buffer, encodedMeshData.normals.start + offset, (encodedMeshData.normals.end - encodedMeshData.normals.start) / 4);
|
|
305
304
|
var normals = float32ArrayToVector3(float32Array1, vertexCount);
|
|
306
305
|
modelMesh.setNormals(normals);
|
|
307
306
|
}
|
|
308
307
|
if (encodedMeshData.uvs) {
|
|
309
|
-
var float32Array2 = new Float32Array(buffer, encodedMeshData.uvs.start + offset
|
|
308
|
+
var float32Array2 = new Float32Array(buffer, encodedMeshData.uvs.start + offset, (encodedMeshData.uvs.end - encodedMeshData.uvs.start) / 4);
|
|
310
309
|
modelMesh.setUVs(float32ArrayToVector2(float32Array2, vertexCount));
|
|
311
310
|
}
|
|
312
311
|
if (encodedMeshData.uv1) {
|
|
313
|
-
var float32Array3 = new Float32Array(buffer, encodedMeshData.uv1.start + offset
|
|
312
|
+
var float32Array3 = new Float32Array(buffer, encodedMeshData.uv1.start + offset, (encodedMeshData.uv1.end - encodedMeshData.uv1.start) / 4);
|
|
314
313
|
modelMesh.setUVs(float32ArrayToVector2(float32Array3, vertexCount), 1);
|
|
315
314
|
}
|
|
316
315
|
if (encodedMeshData.uv2) {
|
|
317
|
-
var float32Array4 = new Float32Array(buffer, encodedMeshData.uv2.start + offset
|
|
316
|
+
var float32Array4 = new Float32Array(buffer, encodedMeshData.uv2.start + offset, (encodedMeshData.uv2.end - encodedMeshData.uv2.start) / 4);
|
|
318
317
|
modelMesh.setUVs(float32ArrayToVector2(float32Array4, vertexCount), 2);
|
|
319
318
|
}
|
|
320
319
|
if (encodedMeshData.uv3) {
|
|
321
|
-
var float32Array5 = new Float32Array(buffer, encodedMeshData.uv3.start + offset
|
|
320
|
+
var float32Array5 = new Float32Array(buffer, encodedMeshData.uv3.start + offset, (encodedMeshData.uv3.end - encodedMeshData.uv3.start) / 4);
|
|
322
321
|
modelMesh.setUVs(float32ArrayToVector2(float32Array5, vertexCount), 3);
|
|
323
322
|
}
|
|
324
323
|
if (encodedMeshData.uv4) {
|
|
325
|
-
var float32Array6 = new Float32Array(buffer, encodedMeshData.uv4.start + offset
|
|
324
|
+
var float32Array6 = new Float32Array(buffer, encodedMeshData.uv4.start + offset, (encodedMeshData.uv4.end - encodedMeshData.uv4.start) / 4);
|
|
326
325
|
modelMesh.setUVs(float32ArrayToVector2(float32Array6, vertexCount), 4);
|
|
327
326
|
}
|
|
328
327
|
if (encodedMeshData.uv5) {
|
|
329
|
-
var float32Array7 = new Float32Array(buffer, encodedMeshData.uv5.start + offset
|
|
328
|
+
var float32Array7 = new Float32Array(buffer, encodedMeshData.uv5.start + offset, (encodedMeshData.uv5.end - encodedMeshData.uv5.start) / 4);
|
|
330
329
|
modelMesh.setUVs(float32ArrayToVector2(float32Array7, vertexCount), 5);
|
|
331
330
|
}
|
|
332
331
|
if (encodedMeshData.uv6) {
|
|
333
|
-
var float32Array8 = new Float32Array(buffer, encodedMeshData.uv6.start + offset
|
|
332
|
+
var float32Array8 = new Float32Array(buffer, encodedMeshData.uv6.start + offset, (encodedMeshData.uv6.end - encodedMeshData.uv6.start) / 4);
|
|
334
333
|
modelMesh.setUVs(float32ArrayToVector2(float32Array8, vertexCount), 6);
|
|
335
334
|
}
|
|
336
335
|
if (encodedMeshData.uv7) {
|
|
337
|
-
var float32Array9 = new Float32Array(buffer, encodedMeshData.uv7.start + offset
|
|
336
|
+
var float32Array9 = new Float32Array(buffer, encodedMeshData.uv7.start + offset, (encodedMeshData.uv7.end - encodedMeshData.uv7.start) / 4);
|
|
338
337
|
modelMesh.setUVs(float32ArrayToVector2(float32Array9, vertexCount), 7);
|
|
339
338
|
}
|
|
340
339
|
if (encodedMeshData.colors) {
|
|
341
|
-
var float32Array10 = new Float32Array(buffer, encodedMeshData.colors.start + offset
|
|
340
|
+
var float32Array10 = new Float32Array(buffer, encodedMeshData.colors.start + offset, (encodedMeshData.colors.end - encodedMeshData.colors.start) / 4);
|
|
342
341
|
modelMesh.setColors(float32ArrayToVColor(float32Array10, vertexCount));
|
|
343
342
|
}
|
|
344
343
|
if (encodedMeshData.boneWeights) {
|
|
345
|
-
var float32Array11 = new Float32Array(buffer, encodedMeshData.boneWeights.start + offset
|
|
344
|
+
var float32Array11 = new Float32Array(buffer, encodedMeshData.boneWeights.start + offset, (encodedMeshData.boneWeights.end - encodedMeshData.boneWeights.start) / 4);
|
|
346
345
|
modelMesh.setBoneWeights(float32ArrayToVector4(float32Array11, vertexCount));
|
|
347
346
|
}
|
|
348
347
|
if (encodedMeshData.boneIndices) {
|
|
349
|
-
var float32Array12 = new Float32Array(buffer, encodedMeshData.boneIndices.start + offset
|
|
348
|
+
var float32Array12 = new Float32Array(buffer, encodedMeshData.boneIndices.start + offset, (encodedMeshData.boneIndices.end - encodedMeshData.boneIndices.start) / 4);
|
|
350
349
|
modelMesh.setBoneIndices(float32ArrayToVector4(float32Array12, vertexCount));
|
|
351
350
|
}
|
|
352
351
|
if (encodedMeshData.blendShapes) {
|
|
353
352
|
encodedMeshData.blendShapes.forEach(function(blendShapeData) {
|
|
354
353
|
var blendShape = new engineCore.BlendShape(blendShapeData.name);
|
|
355
354
|
blendShapeData.frames.forEach(function(frameData) {
|
|
356
|
-
var positionArray = new Float32Array(buffer, frameData.deltaPosition.start + offset
|
|
355
|
+
var positionArray = new Float32Array(buffer, frameData.deltaPosition.start + offset, (frameData.deltaPosition.end - frameData.deltaPosition.start) / 4);
|
|
357
356
|
var count = positionArray.length / 3;
|
|
358
357
|
var deltaPosition = float32ArrayToVector3(positionArray, count);
|
|
359
358
|
if (frameData.deltaNormals) {
|
|
360
|
-
var normalsArray = new Float32Array(buffer, frameData.deltaNormals.start + offset
|
|
359
|
+
var normalsArray = new Float32Array(buffer, frameData.deltaNormals.start + offset, (frameData.deltaNormals.end - frameData.deltaNormals.start) / 4);
|
|
361
360
|
float32ArrayToVector3(normalsArray, count);
|
|
362
361
|
}
|
|
363
362
|
if (frameData.deltaTangents) {
|
|
364
|
-
var tangentsArray = new Float32Array(buffer, frameData.deltaTangents.start + offset
|
|
363
|
+
var tangentsArray = new Float32Array(buffer, frameData.deltaTangents.start + offset, (frameData.deltaTangents.end - frameData.deltaTangents.start) / 4);
|
|
365
364
|
float32ArrayToVector4(tangentsArray, count);
|
|
366
365
|
}
|
|
367
366
|
blendShape.addFrame(frameData.weight, deltaPosition);
|
|
@@ -372,9 +371,9 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
|
|
|
372
371
|
if (encodedMeshData.indices) {
|
|
373
372
|
var indices = null;
|
|
374
373
|
if (encodedMeshData.indices.type === 0) {
|
|
375
|
-
indices = new Uint16Array(buffer, encodedMeshData.indices.start + offset
|
|
374
|
+
indices = new Uint16Array(buffer, encodedMeshData.indices.start + offset, (encodedMeshData.indices.end - encodedMeshData.indices.start) / 2);
|
|
376
375
|
} else {
|
|
377
|
-
indices = new Uint32Array(buffer, encodedMeshData.indices.start + offset
|
|
376
|
+
indices = new Uint32Array(buffer, encodedMeshData.indices.start + offset, (encodedMeshData.indices.end - encodedMeshData.indices.start) / 4);
|
|
378
377
|
}
|
|
379
378
|
modelMesh.setIndices(indices);
|
|
380
379
|
}
|
|
@@ -543,11 +542,17 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
543
542
|
});
|
|
544
543
|
};
|
|
545
544
|
_proto.parseClassObject = function parseClassObject(item) {
|
|
545
|
+
var _this = this;
|
|
546
546
|
var Class = engineCore.Loader.getClass(item.class);
|
|
547
547
|
var _item_constructParams;
|
|
548
548
|
var params = (_item_constructParams = item.constructParams) != null ? _item_constructParams : [];
|
|
549
|
-
|
|
550
|
-
|
|
549
|
+
return Promise.all(params.map(function(param) {
|
|
550
|
+
return _this.parseBasicType(param);
|
|
551
|
+
})).then(function(resultParams) {
|
|
552
|
+
return _construct(Class, [].concat(resultParams));
|
|
553
|
+
}).then(function(instance) {
|
|
554
|
+
return _this.parsePropsAndMethods(instance, item);
|
|
555
|
+
});
|
|
551
556
|
};
|
|
552
557
|
_proto.parsePropsAndMethods = function parsePropsAndMethods(instance, item) {
|
|
553
558
|
var promises = [];
|
|
@@ -555,16 +560,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
555
560
|
for(var methodName in item.methods){
|
|
556
561
|
var methodParams = item.methods[methodName];
|
|
557
562
|
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
558
|
-
|
|
559
|
-
var promise = this.parseMethod(instance, methodName, params);
|
|
560
|
-
promises.push(promise);
|
|
563
|
+
promises.push(this.parseMethod(instance, methodName, methodParams[i]));
|
|
561
564
|
}
|
|
562
565
|
}
|
|
563
566
|
}
|
|
564
567
|
if (item.props) {
|
|
565
568
|
var _this = this, _loop = function(key) {
|
|
566
569
|
var value = item.props[key];
|
|
567
|
-
var promise = _this.parseBasicType(value).then(function(v) {
|
|
570
|
+
var promise = _this.parseBasicType(value, instance[key]).then(function(v) {
|
|
568
571
|
return instance[key] = v;
|
|
569
572
|
});
|
|
570
573
|
promises.push(promise);
|
|
@@ -586,7 +589,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
586
589
|
return (_instance = instance)[methodName].apply(_instance, [].concat(result));
|
|
587
590
|
});
|
|
588
591
|
};
|
|
589
|
-
_proto.parseBasicType = function parseBasicType(value) {
|
|
592
|
+
_proto.parseBasicType = function parseBasicType(value, originValue) {
|
|
590
593
|
var _this = this;
|
|
591
594
|
if (Array.isArray(value)) {
|
|
592
595
|
return Promise.all(value.map(function(item) {
|
|
@@ -603,13 +606,33 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
603
606
|
} else if (ReflectionParser._isEntityRef(value)) {
|
|
604
607
|
// entity reference
|
|
605
608
|
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
606
|
-
} else {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
+
} else if (originValue) {
|
|
610
|
+
var _this1 = this, _loop = function(key) {
|
|
611
|
+
if (key === "methods") {
|
|
612
|
+
var methods = value[key];
|
|
613
|
+
for(var methodName in methods){
|
|
614
|
+
var methodParams = methods[methodName];
|
|
615
|
+
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
616
|
+
var params = methodParams[i];
|
|
617
|
+
var promise = _this1.parseMethod(originValue, methodName, params);
|
|
618
|
+
promises.push(promise);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
} else {
|
|
622
|
+
promises.push(_this1.parseBasicType(value[key], originValue[key]).then(function(v) {
|
|
623
|
+
return originValue[key] = v;
|
|
624
|
+
}));
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
var promises = [];
|
|
628
|
+
for(var key in value)_loop(key);
|
|
629
|
+
return Promise.all(promises).then(function() {
|
|
630
|
+
return originValue;
|
|
631
|
+
});
|
|
609
632
|
}
|
|
610
|
-
} else {
|
|
611
|
-
return Promise.resolve(value);
|
|
612
633
|
}
|
|
634
|
+
// primitive type
|
|
635
|
+
return Promise.resolve(value);
|
|
613
636
|
};
|
|
614
637
|
_proto._getEntityByConfig = function _getEntityByConfig(entityConfig) {
|
|
615
638
|
// @ts-ignore
|
|
@@ -714,6 +737,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
714
737
|
var componentStr = bufferReader.nextStr();
|
|
715
738
|
var componentType = ComponentMap[componentStr];
|
|
716
739
|
var property = bufferReader.nextStr();
|
|
740
|
+
var getProperty = bufferReader.nextStr();
|
|
717
741
|
var curve = void 0;
|
|
718
742
|
var interpolation = bufferReader.nextUint8();
|
|
719
743
|
var keysLen = bufferReader.nextUint16();
|
|
@@ -838,13 +862,42 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
838
862
|
for(var j7 = 0; j7 < keysLen; ++j7){
|
|
839
863
|
var keyframe8 = new engineCore.Keyframe();
|
|
840
864
|
keyframe8.time = bufferReader.nextFloat32();
|
|
841
|
-
|
|
865
|
+
var str = bufferReader.nextStr();
|
|
866
|
+
if (str) {
|
|
867
|
+
keyframe8.value = JSON.parse(str);
|
|
868
|
+
} else {
|
|
869
|
+
keyframe8.value = null;
|
|
870
|
+
}
|
|
842
871
|
curve.addKey(keyframe8);
|
|
843
872
|
}
|
|
844
873
|
break;
|
|
845
874
|
}
|
|
875
|
+
case "AnimationBoolCurve":
|
|
876
|
+
{
|
|
877
|
+
curve = new engineCore.AnimationBoolCurve();
|
|
878
|
+
curve.interpolation = interpolation;
|
|
879
|
+
for(var j8 = 0; j8 < keysLen; ++j8){
|
|
880
|
+
var keyframe9 = new engineCore.Keyframe();
|
|
881
|
+
keyframe9.time = bufferReader.nextFloat32();
|
|
882
|
+
keyframe9.value = bufferReader.nextUint8() === 1;
|
|
883
|
+
curve.addKey(keyframe9);
|
|
884
|
+
}
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
case "AnimationStringCurve":
|
|
888
|
+
{
|
|
889
|
+
curve = new engineCore.AnimationStringCurve();
|
|
890
|
+
curve.interpolation = interpolation;
|
|
891
|
+
for(var j9 = 0; j9 < keysLen; ++j9){
|
|
892
|
+
var keyframe10 = new engineCore.Keyframe();
|
|
893
|
+
keyframe10.time = bufferReader.nextFloat32();
|
|
894
|
+
keyframe10.value = bufferReader.nextStr();
|
|
895
|
+
curve.addKey(keyframe10);
|
|
896
|
+
}
|
|
897
|
+
break;
|
|
898
|
+
}
|
|
846
899
|
}
|
|
847
|
-
clip.addCurveBinding(relativePath, componentType, property, curve);
|
|
900
|
+
clip.addCurveBinding(relativePath, componentType, property, getProperty, curve);
|
|
848
901
|
}
|
|
849
902
|
resolve(clip);
|
|
850
903
|
});
|
|
@@ -1098,26 +1151,34 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
1098
1151
|
var curveBindingPromises = clip.curveBindings.map(function(curveBinding) {
|
|
1099
1152
|
var curve = curveBinding.curve;
|
|
1100
1153
|
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
|
-
}
|
|
1154
|
+
return _this._parseKeyframeValue(key, resourceManager).then(function(actualValue) {
|
|
1155
|
+
key.value = actualValue;
|
|
1156
|
+
});
|
|
1111
1157
|
});
|
|
1112
1158
|
return Promise.all(promises);
|
|
1113
1159
|
});
|
|
1114
1160
|
return Promise.all(curveBindingPromises).then(function() {
|
|
1115
1161
|
resolve(clip);
|
|
1116
1162
|
});
|
|
1117
|
-
});
|
|
1163
|
+
}).catch(reject);
|
|
1118
1164
|
}).catch(reject);
|
|
1119
1165
|
});
|
|
1120
1166
|
};
|
|
1167
|
+
_proto._parseKeyframeValue = function _parseKeyframeValue(keyframe, resourceManager) {
|
|
1168
|
+
var _value;
|
|
1169
|
+
var value = keyframe.value;
|
|
1170
|
+
if (typeof value === "object" && ((_value = value) == null ? void 0 : _value.refId)) {
|
|
1171
|
+
return new Promise(function(resolve) {
|
|
1172
|
+
resourceManager// @ts-ignore
|
|
1173
|
+
.getResourceByRef(value).then(function(asset) {
|
|
1174
|
+
keyframe.value = asset;
|
|
1175
|
+
resolve(keyframe);
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1178
|
+
} else {
|
|
1179
|
+
return Promise.resolve(keyframe.value);
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1121
1182
|
return AnimationClipLoader;
|
|
1122
1183
|
}(engineCore.Loader);
|
|
1123
1184
|
AnimationClipLoader = __decorate([
|
|
@@ -1393,6 +1454,60 @@ FontLoader = __decorate([
|
|
|
1393
1454
|
_this.url = url;
|
|
1394
1455
|
return _this;
|
|
1395
1456
|
}
|
|
1457
|
+
var _proto = GLTFResource.prototype;
|
|
1458
|
+
/**
|
|
1459
|
+
* Instantiate scene root entity.
|
|
1460
|
+
* @param sceneIndex - Scene index
|
|
1461
|
+
* @returns Root entity
|
|
1462
|
+
*/ _proto.instantiateSceneRoot = function instantiateSceneRoot(sceneIndex) {
|
|
1463
|
+
var sceneRoot = sceneIndex === undefined ? this._defaultSceneRoot : this._sceneRoots[sceneIndex];
|
|
1464
|
+
return sceneRoot.clone();
|
|
1465
|
+
};
|
|
1466
|
+
_proto._onDestroy = function _onDestroy() {
|
|
1467
|
+
ReferResource1.prototype._onDestroy.call(this);
|
|
1468
|
+
var _this = this, textures = _this.textures, materials = _this.materials, meshes = _this.meshes;
|
|
1469
|
+
textures && this._disassociationSuperResource(textures);
|
|
1470
|
+
materials && this._disassociationSuperResource(materials);
|
|
1471
|
+
if (meshes) {
|
|
1472
|
+
for(var i = 0, n = meshes.length; i < n; i++){
|
|
1473
|
+
this._disassociationSuperResource(meshes[i]);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
_proto._disassociationSuperResource = function _disassociationSuperResource(resources) {
|
|
1478
|
+
for(var i = 0, n = resources.length; i < n; i++){
|
|
1479
|
+
// @ts-ignore
|
|
1480
|
+
resources[i]._disassociationSuperResource(this);
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
_create_class(GLTFResource, [
|
|
1484
|
+
{
|
|
1485
|
+
key: "extensionsData",
|
|
1486
|
+
get: /**
|
|
1487
|
+
* Extensions data.
|
|
1488
|
+
*/ function get() {
|
|
1489
|
+
return this._extensionsData;
|
|
1490
|
+
}
|
|
1491
|
+
},
|
|
1492
|
+
{
|
|
1493
|
+
key: "sceneRoots",
|
|
1494
|
+
get: /**
|
|
1495
|
+
* @deprecated Please use `instantiateSceneRoot` instead.
|
|
1496
|
+
* RootEntities after SceneParser.
|
|
1497
|
+
*/ function get() {
|
|
1498
|
+
return this._sceneRoots;
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
{
|
|
1502
|
+
key: "defaultSceneRoot",
|
|
1503
|
+
get: /**
|
|
1504
|
+
* @deprecated Please use `instantiateSceneRoot` instead.
|
|
1505
|
+
* RootEntity after SceneParser.
|
|
1506
|
+
*/ function get() {
|
|
1507
|
+
return this._defaultSceneRoot;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
]);
|
|
1396
1511
|
return GLTFResource;
|
|
1397
1512
|
}(engineCore.ReferResource);
|
|
1398
1513
|
|
|
@@ -1546,12 +1661,29 @@ var TextureWrapMode;
|
|
|
1546
1661
|
/**
|
|
1547
1662
|
* @internal
|
|
1548
1663
|
*/ var GLTFParserContext = /*#__PURE__*/ function() {
|
|
1549
|
-
function GLTFParserContext(glTFResource, resourceManager,
|
|
1664
|
+
function GLTFParserContext(glTFResource, resourceManager, params) {
|
|
1665
|
+
var _this = this;
|
|
1550
1666
|
this.glTFResource = glTFResource;
|
|
1551
1667
|
this.resourceManager = resourceManager;
|
|
1552
|
-
this.
|
|
1668
|
+
this.params = params;
|
|
1553
1669
|
this.accessorBufferCache = {};
|
|
1554
1670
|
this._resourceCache = new Map();
|
|
1671
|
+
this._progress = {
|
|
1672
|
+
taskDetail: {},
|
|
1673
|
+
taskComplete: {
|
|
1674
|
+
loaded: 0,
|
|
1675
|
+
total: 0
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
this./**
|
|
1679
|
+
* @internal
|
|
1680
|
+
*/ _onTaskDetail = function(url, loaded, total) {
|
|
1681
|
+
var _this__progress_taskDetail, _url;
|
|
1682
|
+
var detail = (_this__progress_taskDetail = _this._progress.taskDetail)[_url = url] || (_this__progress_taskDetail[_url] = {});
|
|
1683
|
+
detail.loaded = loaded;
|
|
1684
|
+
detail.total = total;
|
|
1685
|
+
_this._setTaskDetailProgress(url, loaded, total);
|
|
1686
|
+
};
|
|
1555
1687
|
this.contentRestorer = new GLTFContentRestorer(glTFResource);
|
|
1556
1688
|
}
|
|
1557
1689
|
var _proto = GLTFParserContext.prototype;
|
|
@@ -1592,7 +1724,7 @@ var TextureWrapMode;
|
|
|
1592
1724
|
};
|
|
1593
1725
|
_proto.parse = function parse() {
|
|
1594
1726
|
var _this = this;
|
|
1595
|
-
|
|
1727
|
+
var promise = this.get(0).then(function(json) {
|
|
1596
1728
|
_this.glTF = json;
|
|
1597
1729
|
return Promise.all([
|
|
1598
1730
|
_this.get(1),
|
|
@@ -1603,10 +1735,48 @@ var TextureWrapMode;
|
|
|
1603
1735
|
_this.get(9),
|
|
1604
1736
|
_this.get(2)
|
|
1605
1737
|
]).then(function() {
|
|
1738
|
+
var glTFResource = _this.glTFResource;
|
|
1739
|
+
if (glTFResource.skins || glTFResource.animations) {
|
|
1740
|
+
_this._createAnimator(_this, glTFResource.animations);
|
|
1741
|
+
}
|
|
1606
1742
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
1607
|
-
return
|
|
1743
|
+
return glTFResource;
|
|
1608
1744
|
});
|
|
1609
1745
|
});
|
|
1746
|
+
this._addTaskCompletePromise(promise);
|
|
1747
|
+
return promise;
|
|
1748
|
+
};
|
|
1749
|
+
/**
|
|
1750
|
+
* @internal
|
|
1751
|
+
*/ _proto._addTaskCompletePromise = function _addTaskCompletePromise(taskPromise) {
|
|
1752
|
+
var _this = this;
|
|
1753
|
+
var task = this._progress.taskComplete;
|
|
1754
|
+
task.total += 1;
|
|
1755
|
+
taskPromise.then(function() {
|
|
1756
|
+
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
1757
|
+
});
|
|
1758
|
+
};
|
|
1759
|
+
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
1760
|
+
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
1761
|
+
var animator = defaultSceneRoot.addComponent(engineCore.Animator);
|
|
1762
|
+
var animatorController = new engineCore.AnimatorController();
|
|
1763
|
+
var layer = new engineCore.AnimatorControllerLayer("layer");
|
|
1764
|
+
var animatorStateMachine = new engineCore.AnimatorStateMachine();
|
|
1765
|
+
animatorController.addLayer(layer);
|
|
1766
|
+
animator.animatorController = animatorController;
|
|
1767
|
+
layer.stateMachine = animatorStateMachine;
|
|
1768
|
+
if (animations) {
|
|
1769
|
+
for(var i = 0; i < animations.length; i++){
|
|
1770
|
+
var animationClip = animations[i];
|
|
1771
|
+
var name = animationClip.name;
|
|
1772
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
1773
|
+
if (uniqueName !== name) {
|
|
1774
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
1775
|
+
}
|
|
1776
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
1777
|
+
animatorState.clip = animationClip;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1610
1780
|
};
|
|
1611
1781
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
1612
1782
|
var _this = this;
|
|
@@ -1670,7 +1840,7 @@ exports.GLTFParserType = void 0;
|
|
|
1670
1840
|
var _obj;
|
|
1671
1841
|
var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[4] = "textures", _obj[5] = "materials", _obj[6] = "meshes", _obj[7] = "nodes", _obj[8] = "skins", _obj[9] = "animations", _obj);
|
|
1672
1842
|
var _obj1;
|
|
1673
|
-
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "
|
|
1843
|
+
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[4] = "textures", _obj1[5] = "materials", _obj1[6] = "meshes", _obj1[7] = "entities", _obj1[8] = "skins", _obj1[9] = "animations", _obj1);
|
|
1674
1844
|
function registerGLTFParser(pipeline) {
|
|
1675
1845
|
return function(Parser) {
|
|
1676
1846
|
var parser = new Parser();
|
|
@@ -2247,7 +2417,7 @@ var SupercompressionScheme;
|
|
|
2247
2417
|
alphaSliceByteLength: sgdReader.nextUint32()
|
|
2248
2418
|
};
|
|
2249
2419
|
}
|
|
2250
|
-
var endpointsByteOffset = sgdByteOffset + sgdReader.
|
|
2420
|
+
var endpointsByteOffset = sgdByteOffset + sgdReader.position;
|
|
2251
2421
|
var selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
|
|
2252
2422
|
var tablesByteOffset = selectorsByteOffset + selectorsByteLength;
|
|
2253
2423
|
var extendedByteOffset = tablesByteOffset + tablesByteLength;
|
|
@@ -2439,6 +2609,25 @@ var AbstractTranscoder = /*#__PURE__*/ function() {
|
|
|
2439
2609
|
}();
|
|
2440
2610
|
|
|
2441
2611
|
/** @internal */ function TranscodeWorkerCode$1() {
|
|
2612
|
+
var initPromise;
|
|
2613
|
+
var init = function init(wasmBinary) {
|
|
2614
|
+
if (!initPromise) {
|
|
2615
|
+
initPromise = new Promise(function(resolve, reject) {
|
|
2616
|
+
var BasisModule = {
|
|
2617
|
+
wasmBinary: wasmBinary,
|
|
2618
|
+
onRuntimeInitialized: function() {
|
|
2619
|
+
return resolve(BasisModule);
|
|
2620
|
+
},
|
|
2621
|
+
onAbort: reject
|
|
2622
|
+
};
|
|
2623
|
+
self["BASIS"](BasisModule);
|
|
2624
|
+
}).then(function(BasisModule) {
|
|
2625
|
+
BasisModule.initializeBasis();
|
|
2626
|
+
return BasisModule.KTX2File;
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
return initPromise;
|
|
2630
|
+
};
|
|
2442
2631
|
self.onmessage = function onmessage(event) {
|
|
2443
2632
|
var message = event.data;
|
|
2444
2633
|
switch(message.type){
|
|
@@ -2553,6 +2742,10 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2553
2742
|
cleanup();
|
|
2554
2743
|
throw new Error("Invalid or unsupported .ktx2 file");
|
|
2555
2744
|
}
|
|
2745
|
+
if (!ktx2File.startTranscoding()) {
|
|
2746
|
+
cleanup();
|
|
2747
|
+
throw new Error("KTX2 startTranscoding failed");
|
|
2748
|
+
}
|
|
2556
2749
|
var width = ktx2File.getWidth();
|
|
2557
2750
|
var height = ktx2File.getHeight();
|
|
2558
2751
|
var layerCount = ktx2File.getLayers() || 1;
|
|
@@ -2561,6 +2754,7 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2561
2754
|
var faceCount = ktx2File.getFaces();
|
|
2562
2755
|
var format = getTranscodeFormatFromTarget(targetFormat, hasAlpha);
|
|
2563
2756
|
var faces = new Array(faceCount);
|
|
2757
|
+
var isBC = format === 2 || format === 3 || format === 7;
|
|
2564
2758
|
for(var face = 0; face < faceCount; face++){
|
|
2565
2759
|
var mipmaps = new Array(levelCount);
|
|
2566
2760
|
for(var mip = 0; mip < levelCount; mip++){
|
|
@@ -2568,8 +2762,15 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2568
2762
|
var mipWidth = void 0, mipHeight = void 0;
|
|
2569
2763
|
for(var layer = 0; layer < layerCount; layer++){
|
|
2570
2764
|
var levelInfo = ktx2File.getImageLevelInfo(mip, layer, face);
|
|
2571
|
-
|
|
2572
|
-
|
|
2765
|
+
// see: https://github.com/KhronosGroup/KTX-Software/issues/254
|
|
2766
|
+
if (isBC && mip === 0 && (width !== levelInfo.width || height !== levelInfo.height)) {
|
|
2767
|
+
width = mipWidth = levelInfo.width;
|
|
2768
|
+
height = mipHeight = levelInfo.height;
|
|
2769
|
+
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.");
|
|
2770
|
+
} else {
|
|
2771
|
+
mipWidth = levelInfo.origWidth;
|
|
2772
|
+
mipHeight = levelInfo.origHeight;
|
|
2773
|
+
}
|
|
2573
2774
|
var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
|
|
2574
2775
|
var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
|
|
2575
2776
|
if (!status) {
|
|
@@ -2635,7 +2836,7 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2635
2836
|
} else {
|
|
2636
2837
|
var funcCode = TranscodeWorkerCode$1.toString();
|
|
2637
2838
|
var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
|
|
2638
|
-
var workerCode = "\n " + jsCode + "\n
|
|
2839
|
+
var workerCode = "\n " + jsCode + "\n " + transcode.toString() + "\n " + transcodeString + "\n ";
|
|
2639
2840
|
var workerURL = URL.createObjectURL(new Blob([
|
|
2640
2841
|
workerCode
|
|
2641
2842
|
], {
|
|
@@ -2881,10 +3082,14 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2881
3082
|
return Loader1.apply(this, arguments);
|
|
2882
3083
|
}
|
|
2883
3084
|
var _proto = KTX2Loader1.prototype;
|
|
2884
|
-
_proto.initialize = function initialize(
|
|
3085
|
+
_proto.initialize = function initialize(_, configuration) {
|
|
2885
3086
|
if (configuration.ktx2Loader) {
|
|
2886
3087
|
var options = configuration.ktx2Loader;
|
|
2887
|
-
if (
|
|
3088
|
+
if (options.priorityFormats) {
|
|
3089
|
+
exports.KTX2Loader._priorityFormats["etc1s"] = options.priorityFormats;
|
|
3090
|
+
exports.KTX2Loader._priorityFormats["uastc"] = options.priorityFormats;
|
|
3091
|
+
}
|
|
3092
|
+
if (options.transcoder === /** Khronos transcoder. */ 1) {
|
|
2888
3093
|
return exports.KTX2Loader._getKhronosTranscoder(options.workerCount).init();
|
|
2889
3094
|
} else {
|
|
2890
3095
|
return exports.KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
|
|
@@ -2894,34 +3099,16 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2894
3099
|
/**
|
|
2895
3100
|
* @internal
|
|
2896
3101
|
*/ _proto.load = function load(item, resourceManager) {
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
return exports.KTX2Loader.
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
if (priorityFormats === void 0) priorityFormats = [
|
|
2908
|
-
exports.KTX2TargetFormat.ASTC,
|
|
2909
|
-
exports.KTX2TargetFormat.ETC,
|
|
2910
|
-
exports.KTX2TargetFormat.BC7,
|
|
2911
|
-
exports.KTX2TargetFormat.BC1_BC3,
|
|
2912
|
-
exports.KTX2TargetFormat.PVRTC,
|
|
2913
|
-
exports.KTX2TargetFormat.R8G8B8A8
|
|
2914
|
-
];
|
|
2915
|
-
var supportedList = new Array();
|
|
2916
|
-
if (Array.isArray(priorityFormats[0])) {
|
|
2917
|
-
for(var i = 0; i < priorityFormats.length; i++){
|
|
2918
|
-
supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats[i]));
|
|
2919
|
-
}
|
|
2920
|
-
} else {
|
|
2921
|
-
supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats));
|
|
2922
|
-
}
|
|
2923
|
-
return supportedList.every(function(format) {
|
|
2924
|
-
return KhronosTranscoder.transcoderMap[format];
|
|
3102
|
+
var _this = this;
|
|
3103
|
+
return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
3104
|
+
_this.request(item.url, {
|
|
3105
|
+
type: "arraybuffer"
|
|
3106
|
+
}).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
|
|
3107
|
+
return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
|
|
3108
|
+
var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
|
|
3109
|
+
return exports.KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
|
|
3110
|
+
});
|
|
3111
|
+
}).then(resolve).catch(reject);
|
|
2925
3112
|
});
|
|
2926
3113
|
};
|
|
2927
3114
|
/**
|
|
@@ -2936,7 +3123,8 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2936
3123
|
/** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
|
|
2937
3124
|
var _params;
|
|
2938
3125
|
var ktx2Container = new KTX2Container(buffer);
|
|
2939
|
-
var
|
|
3126
|
+
var _params_priorityFormats;
|
|
3127
|
+
var formatPriorities = (_params_priorityFormats = (_params = params) == null ? void 0 : _params.priorityFormats) != null ? _params_priorityFormats : exports.KTX2Loader._priorityFormats[ktx2Container.isUASTC ? "uastc" : "etc1s"];
|
|
2940
3128
|
var targetFormat = exports.KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
|
|
2941
3129
|
var transcodeResultPromise;
|
|
2942
3130
|
if (exports.KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
|
|
@@ -3003,18 +3191,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3003
3191
|
return targetFormat;
|
|
3004
3192
|
};
|
|
3005
3193
|
KTX2Loader1._detectSupportedFormat = function _detectSupportedFormat(renderer, priorityFormats) {
|
|
3006
|
-
if (priorityFormats === void 0) priorityFormats = [
|
|
3007
|
-
exports.KTX2TargetFormat.ASTC,
|
|
3008
|
-
exports.KTX2TargetFormat.ETC,
|
|
3009
|
-
exports.KTX2TargetFormat.BC7,
|
|
3010
|
-
exports.KTX2TargetFormat.BC1_BC3,
|
|
3011
|
-
exports.KTX2TargetFormat.PVRTC
|
|
3012
|
-
];
|
|
3013
3194
|
for(var i = 0; i < priorityFormats.length; i++){
|
|
3014
|
-
var
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3195
|
+
var format = priorityFormats[i];
|
|
3196
|
+
var capabilities = this._supportedMap[format];
|
|
3197
|
+
if (capabilities) {
|
|
3198
|
+
for(var j = 0; j < capabilities.length; j++){
|
|
3199
|
+
if (renderer.canIUse(capabilities[j])) {
|
|
3200
|
+
return format;
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
} else {
|
|
3204
|
+
switch(priorityFormats[i]){
|
|
3205
|
+
case exports.KTX2TargetFormat.R8G8B8A8:
|
|
3206
|
+
return format;
|
|
3207
|
+
case exports.KTX2TargetFormat.R8:
|
|
3208
|
+
case exports.KTX2TargetFormat.R8G8:
|
|
3209
|
+
if (renderer.isWebGL2) return format;
|
|
3018
3210
|
}
|
|
3019
3211
|
}
|
|
3020
3212
|
}
|
|
@@ -3051,6 +3243,23 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3051
3243
|
return KTX2Loader1;
|
|
3052
3244
|
}(engineCore.Loader), function() {
|
|
3053
3245
|
_KTX2Loader._isBinomialInit = false;
|
|
3246
|
+
}(), function() {
|
|
3247
|
+
_KTX2Loader._priorityFormats = {
|
|
3248
|
+
etc1s: [
|
|
3249
|
+
exports.KTX2TargetFormat.ETC,
|
|
3250
|
+
exports.KTX2TargetFormat.BC7,
|
|
3251
|
+
exports.KTX2TargetFormat.ASTC,
|
|
3252
|
+
exports.KTX2TargetFormat.BC1_BC3,
|
|
3253
|
+
exports.KTX2TargetFormat.PVRTC
|
|
3254
|
+
],
|
|
3255
|
+
uastc: [
|
|
3256
|
+
exports.KTX2TargetFormat.ASTC,
|
|
3257
|
+
exports.KTX2TargetFormat.BC7,
|
|
3258
|
+
exports.KTX2TargetFormat.ETC,
|
|
3259
|
+
exports.KTX2TargetFormat.BC1_BC3,
|
|
3260
|
+
exports.KTX2TargetFormat.PVRTC
|
|
3261
|
+
]
|
|
3262
|
+
};
|
|
3054
3263
|
}(), function() {
|
|
3055
3264
|
var _obj;
|
|
3056
3265
|
_KTX2Loader._supportedMap = (_obj = {}, _obj[exports.KTX2TargetFormat.ASTC] = [
|
|
@@ -3071,6 +3280,11 @@ exports.KTX2Loader = __decorate([
|
|
|
3071
3280
|
"ktx2"
|
|
3072
3281
|
])
|
|
3073
3282
|
], exports.KTX2Loader);
|
|
3283
|
+
exports.KTX2Transcoder = void 0;
|
|
3284
|
+
(function(KTX2Transcoder) {
|
|
3285
|
+
KTX2Transcoder[KTX2Transcoder[/** BinomialLLC transcoder. */ "BinomialLLC"] = 0] = "BinomialLLC";
|
|
3286
|
+
KTX2Transcoder[KTX2Transcoder["Khronos"] = 1] = "Khronos";
|
|
3287
|
+
})(exports.KTX2Transcoder || (exports.KTX2Transcoder = {}));
|
|
3074
3288
|
|
|
3075
3289
|
/**
|
|
3076
3290
|
* @internal
|
|
@@ -3421,7 +3635,7 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3421
3635
|
};
|
|
3422
3636
|
var isGLB = this._isGLB(url);
|
|
3423
3637
|
contentRestorer.isGLB = isGLB;
|
|
3424
|
-
var promise = isGLB ? engineCore.request(url, requestConfig).then(function(glb) {
|
|
3638
|
+
var promise = isGLB ? engineCore.request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(glb) {
|
|
3425
3639
|
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
3426
3640
|
return GLTFUtils.parseGLB(context, glb);
|
|
3427
3641
|
}).then(function(param) {
|
|
@@ -3430,7 +3644,7 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3430
3644
|
return glTF;
|
|
3431
3645
|
}) : engineCore.request(url, {
|
|
3432
3646
|
type: "json"
|
|
3433
|
-
});
|
|
3647
|
+
}).onProgress(undefined, context._onTaskDetail);
|
|
3434
3648
|
return promise;
|
|
3435
3649
|
};
|
|
3436
3650
|
_proto._isGLB = function _isGLB(url) {
|
|
@@ -3462,9 +3676,9 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3462
3676
|
* @internal
|
|
3463
3677
|
*/ GLTFAnimationParser1._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
|
|
3464
3678
|
var _loop = function(j, m) {
|
|
3465
|
-
var
|
|
3466
|
-
var inputAccessor = accessors[
|
|
3467
|
-
var outputAccessor = accessors[
|
|
3679
|
+
var glTFSampler = samplers[j];
|
|
3680
|
+
var inputAccessor = accessors[glTFSampler.input];
|
|
3681
|
+
var outputAccessor = accessors[glTFSampler.output];
|
|
3468
3682
|
var promise = Promise.all([
|
|
3469
3683
|
GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
|
|
3470
3684
|
GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
|
|
@@ -3480,8 +3694,8 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3480
3694
|
output = scaled;
|
|
3481
3695
|
}
|
|
3482
3696
|
var outputStride = output.length / input.length;
|
|
3483
|
-
var
|
|
3484
|
-
var interpolation = (
|
|
3697
|
+
var _glTFSampler_interpolation;
|
|
3698
|
+
var interpolation = (_glTFSampler_interpolation = glTFSampler.interpolation) != null ? _glTFSampler_interpolation : AnimationSamplerInterpolation.Linear;
|
|
3485
3699
|
var samplerInterpolation;
|
|
3486
3700
|
switch(interpolation){
|
|
3487
3701
|
case AnimationSamplerInterpolation.CubicSpine:
|
|
@@ -3514,10 +3728,11 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3514
3728
|
var promises = new Array();
|
|
3515
3729
|
// parse samplers
|
|
3516
3730
|
for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
|
|
3731
|
+
promises.push(context.get(exports.GLTFParserType.Scene));
|
|
3517
3732
|
return Promise.all(promises).then(function() {
|
|
3518
3733
|
for(var j = 0, m = channels.length; j < m; j++){
|
|
3519
|
-
var
|
|
3520
|
-
var target =
|
|
3734
|
+
var glTFChannel = channels[j];
|
|
3735
|
+
var target = glTFChannel.target;
|
|
3521
3736
|
var channelTargetEntity = entities[target.node];
|
|
3522
3737
|
var relativePath = "";
|
|
3523
3738
|
var entity = channelTargetEntity;
|
|
@@ -3525,6 +3740,10 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3525
3740
|
relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
|
|
3526
3741
|
entity = entity.parent;
|
|
3527
3742
|
}
|
|
3743
|
+
// If the target node is in the default scene, relativePath will be empty
|
|
3744
|
+
if (context.glTFResource.sceneRoots.indexOf(entity) === -1) {
|
|
3745
|
+
continue;
|
|
3746
|
+
}
|
|
3528
3747
|
var ComponentType = void 0;
|
|
3529
3748
|
var propertyName = void 0;
|
|
3530
3749
|
switch(target.path){
|
|
@@ -3545,14 +3764,21 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3545
3764
|
propertyName = "blendShapeWeights";
|
|
3546
3765
|
break;
|
|
3547
3766
|
}
|
|
3548
|
-
var curve = _this._addCurve(target.path,
|
|
3549
|
-
|
|
3767
|
+
var curve = _this._addCurve(target.path, glTFChannel, sampleDataCollection);
|
|
3768
|
+
if (target.path === AnimationChannelTargetPath.WEIGHTS) {
|
|
3769
|
+
var mesh = glTF.nodes[target.node].mesh;
|
|
3770
|
+
for(var i = 0, n = glTF.meshes[mesh].primitives.length; i < n; i++){
|
|
3771
|
+
animationClip.addCurveBinding(relativePath, ComponentType, i, propertyName, curve);
|
|
3772
|
+
}
|
|
3773
|
+
} else {
|
|
3774
|
+
animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
|
|
3775
|
+
}
|
|
3550
3776
|
}
|
|
3551
3777
|
return animationClip;
|
|
3552
3778
|
});
|
|
3553
3779
|
};
|
|
3554
|
-
GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath,
|
|
3555
|
-
var sampleData = sampleDataCollection[
|
|
3780
|
+
GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, glTFChannel, sampleDataCollection) {
|
|
3781
|
+
var sampleData = sampleDataCollection[glTFChannel.sampler];
|
|
3556
3782
|
var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
|
|
3557
3783
|
switch(animationChannelTargetPath){
|
|
3558
3784
|
case AnimationChannelTargetPath.TRANSLATION:
|
|
@@ -3644,7 +3870,9 @@ exports.GLTFBufferParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3644
3870
|
};
|
|
3645
3871
|
var absoluteUrl = engineCore.Utils.resolveAbsoluteUrl(url, bufferInfo.uri);
|
|
3646
3872
|
restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
|
|
3647
|
-
|
|
3873
|
+
var promise = engineCore.request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
|
|
3874
|
+
context._addTaskCompletePromise(promise);
|
|
3875
|
+
return promise;
|
|
3648
3876
|
};
|
|
3649
3877
|
return GLTFBufferParser;
|
|
3650
3878
|
}(GLTFParser);
|
|
@@ -3659,10 +3887,13 @@ exports.GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3659
3887
|
}
|
|
3660
3888
|
var _proto = GLTFEntityParser.prototype;
|
|
3661
3889
|
_proto.parse = function parse(context, index) {
|
|
3890
|
+
var glTFResource = context.glTFResource;
|
|
3662
3891
|
var entityInfo = context.glTF.nodes[index];
|
|
3663
|
-
var engine =
|
|
3892
|
+
var engine = glTFResource.engine;
|
|
3664
3893
|
var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
|
|
3665
3894
|
var entity = new engineCore.Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
|
|
3895
|
+
// @ts-ignore
|
|
3896
|
+
entity._markAsTemplate(glTFResource);
|
|
3666
3897
|
var transform = entity.transform;
|
|
3667
3898
|
if (matrix) {
|
|
3668
3899
|
var localMatrix = transform.localMatrix;
|
|
@@ -3704,7 +3935,8 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3704
3935
|
var _proto = GLTFMaterialParser1.prototype;
|
|
3705
3936
|
_proto.parse = function parse(context, index) {
|
|
3706
3937
|
var materialInfo = context.glTF.materials[index];
|
|
3707
|
-
var
|
|
3938
|
+
var glTFResource = context.glTFResource;
|
|
3939
|
+
var engine = glTFResource.engine;
|
|
3708
3940
|
var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
|
|
3709
3941
|
if (!material) {
|
|
3710
3942
|
material = new engineCore.PBRMaterial(engine);
|
|
@@ -3712,8 +3944,10 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3712
3944
|
exports.GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
|
|
3713
3945
|
}
|
|
3714
3946
|
return Promise.resolve(material).then(function(material) {
|
|
3715
|
-
material || (material = exports.GLTFMaterialParser._getDefaultMaterial(
|
|
3947
|
+
material || (material = exports.GLTFMaterialParser._getDefaultMaterial(engine));
|
|
3716
3948
|
GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
|
|
3949
|
+
// @ts-ignore
|
|
3950
|
+
material._associationSuperResource(glTFResource);
|
|
3717
3951
|
return material;
|
|
3718
3952
|
});
|
|
3719
3953
|
};
|
|
@@ -3834,14 +4068,20 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
|
|
|
3834
4068
|
var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, meshInfo);
|
|
3835
4069
|
if (mesh) {
|
|
3836
4070
|
if (_instanceof(mesh, engineCore.ModelMesh)) {
|
|
4071
|
+
// @ts-ignore
|
|
4072
|
+
mesh._associationSuperResource(glTFResource);
|
|
3837
4073
|
resolve(mesh);
|
|
3838
4074
|
} else {
|
|
3839
4075
|
mesh.then(function(mesh) {
|
|
3840
|
-
|
|
4076
|
+
// @ts-ignore
|
|
4077
|
+
mesh._associationSuperResource(glTFResource);
|
|
4078
|
+
resolve(mesh);
|
|
3841
4079
|
});
|
|
3842
4080
|
}
|
|
3843
4081
|
} else {
|
|
3844
4082
|
var mesh1 = new engineCore.ModelMesh(engine, meshInfo.name || i + "");
|
|
4083
|
+
// @ts-ignore
|
|
4084
|
+
mesh1._associationSuperResource(glTFResource);
|
|
3845
4085
|
var meshRestoreInfo = new ModelMeshRestoreInfo();
|
|
3846
4086
|
meshRestoreInfo.mesh = mesh1;
|
|
3847
4087
|
context.contentRestorer.meshes.push(meshRestoreInfo);
|
|
@@ -3861,12 +4101,13 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
|
|
|
3861
4101
|
return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
3862
4102
|
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
3863
4103
|
});
|
|
3864
|
-
}, context.keepMeshData).then(resolve);
|
|
4104
|
+
}, context.params.keepMeshData).then(resolve);
|
|
3865
4105
|
}
|
|
3866
4106
|
});
|
|
3867
4107
|
};
|
|
3868
4108
|
var meshInfo = context.glTF.meshes[index];
|
|
3869
|
-
var glTF = context.glTF,
|
|
4109
|
+
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
4110
|
+
var engine = glTFResource.engine;
|
|
3870
4111
|
var primitivePromises = new Array();
|
|
3871
4112
|
for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
|
|
3872
4113
|
return Promise.all(primitivePromises);
|
|
@@ -4039,9 +4280,9 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4039
4280
|
}
|
|
4040
4281
|
var _proto = GLTFSceneParser.prototype;
|
|
4041
4282
|
_proto.parse = function parse(context, index) {
|
|
4042
|
-
var _this = this;
|
|
4043
4283
|
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;
|
|
4044
4284
|
var sceneInfo = scenes[index];
|
|
4285
|
+
var sceneExtensions = sceneInfo.extensions;
|
|
4045
4286
|
var engine = glTFResource.engine;
|
|
4046
4287
|
var isDefaultScene = scene === index;
|
|
4047
4288
|
var sceneNodes = sceneInfo.nodes;
|
|
@@ -4055,30 +4296,15 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4055
4296
|
sceneRoot.addChild(childEntity);
|
|
4056
4297
|
}
|
|
4057
4298
|
}
|
|
4058
|
-
// @ts-ignore
|
|
4059
|
-
sceneRoot._hookResource = glTFResource;
|
|
4060
|
-
// @ts-ignore
|
|
4061
|
-
glTFResource._addReferCount(1);
|
|
4062
4299
|
if (isDefaultScene) {
|
|
4063
|
-
glTFResource.
|
|
4300
|
+
glTFResource._defaultSceneRoot = sceneRoot;
|
|
4064
4301
|
}
|
|
4065
4302
|
var promises = new Array();
|
|
4066
4303
|
for(var i1 = 0; i1 < sceneNodes.length; i1++){
|
|
4067
4304
|
promises.push(this._parseEntityComponent(context, sceneNodes[i1]));
|
|
4068
4305
|
}
|
|
4069
4306
|
return Promise.all(promises).then(function() {
|
|
4070
|
-
|
|
4071
|
-
return Promise.all([
|
|
4072
|
-
context.get(exports.GLTFParserType.Skin),
|
|
4073
|
-
context.get(exports.GLTFParserType.Animation)
|
|
4074
|
-
]).then(function(param) {
|
|
4075
|
-
var skins = param[0], animations = param[1];
|
|
4076
|
-
if (skins || animations) {
|
|
4077
|
-
_this._createAnimator(context, animations);
|
|
4078
|
-
}
|
|
4079
|
-
return sceneRoot;
|
|
4080
|
-
});
|
|
4081
|
-
}
|
|
4307
|
+
GLTFParser.executeExtensionsAdditiveAndParse(sceneExtensions, context, sceneRoot, sceneInfo);
|
|
4082
4308
|
return sceneRoot;
|
|
4083
4309
|
});
|
|
4084
4310
|
};
|
|
@@ -4190,28 +4416,6 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4190
4416
|
for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
|
|
4191
4417
|
return Promise.all(promises);
|
|
4192
4418
|
};
|
|
4193
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
4194
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
4195
|
-
var animator = defaultSceneRoot.addComponent(engineCore.Animator);
|
|
4196
|
-
var animatorController = new engineCore.AnimatorController();
|
|
4197
|
-
var layer = new engineCore.AnimatorControllerLayer("layer");
|
|
4198
|
-
var animatorStateMachine = new engineCore.AnimatorStateMachine();
|
|
4199
|
-
animatorController.addLayer(layer);
|
|
4200
|
-
animator.animatorController = animatorController;
|
|
4201
|
-
layer.stateMachine = animatorStateMachine;
|
|
4202
|
-
if (animations) {
|
|
4203
|
-
for(var i = 0; i < animations.length; i++){
|
|
4204
|
-
var animationClip = animations[i];
|
|
4205
|
-
var name = animationClip.name;
|
|
4206
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
4207
|
-
if (uniqueName !== name) {
|
|
4208
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
4209
|
-
}
|
|
4210
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
4211
|
-
animatorState.clip = animationClip;
|
|
4212
|
-
}
|
|
4213
|
-
}
|
|
4214
|
-
};
|
|
4215
4419
|
_proto._computeLocalBounds = function _computeLocalBounds(skinnedMeshRenderer, mesh, bones, rootBone, inverseBindMatrices) {
|
|
4216
4420
|
var rootBoneIndex = bones.indexOf(rootBone);
|
|
4217
4421
|
if (rootBoneIndex !== -1) {
|
|
@@ -4360,11 +4564,12 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
|
|
|
4360
4564
|
params: {
|
|
4361
4565
|
mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
|
|
4362
4566
|
}
|
|
4363
|
-
}).then(function(texture) {
|
|
4567
|
+
}).onProgress(undefined, context._onTaskDetail).then(function(texture) {
|
|
4364
4568
|
texture.name = textureName || imageName || texture.name || "texture_" + index;
|
|
4365
4569
|
useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
|
|
4366
4570
|
return texture;
|
|
4367
4571
|
});
|
|
4572
|
+
context._addTaskCompletePromise(texture);
|
|
4368
4573
|
} else {
|
|
4369
4574
|
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
4370
4575
|
texture = context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
@@ -4386,6 +4591,8 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
|
|
|
4386
4591
|
}
|
|
4387
4592
|
return Promise.resolve(texture).then(function(texture) {
|
|
4388
4593
|
GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
|
|
4594
|
+
// @ts-ignore
|
|
4595
|
+
texture._associationSuperResource(glTFResource);
|
|
4389
4596
|
return texture;
|
|
4390
4597
|
});
|
|
4391
4598
|
};
|
|
@@ -4443,12 +4650,17 @@ var GLTFLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
4443
4650
|
}
|
|
4444
4651
|
var _proto = GLTFLoader.prototype;
|
|
4445
4652
|
_proto.load = function load(item, resourceManager) {
|
|
4446
|
-
var _params;
|
|
4447
4653
|
var url = item.url;
|
|
4448
4654
|
var params = item.params;
|
|
4449
4655
|
var glTFResource = new GLTFResource(resourceManager.engine, url);
|
|
4450
|
-
var context = new GLTFParserContext(glTFResource, resourceManager,
|
|
4451
|
-
|
|
4656
|
+
var context = new GLTFParserContext(glTFResource, resourceManager, _extends({
|
|
4657
|
+
keepMeshData: false
|
|
4658
|
+
}, params));
|
|
4659
|
+
return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
4660
|
+
context._setTaskCompleteProgress = setTaskCompleteProgress;
|
|
4661
|
+
context._setTaskDetailProgress = setTaskDetailProgress;
|
|
4662
|
+
context.parse().then(resolve).catch(reject);
|
|
4663
|
+
});
|
|
4452
4664
|
};
|
|
4453
4665
|
return GLTFLoader;
|
|
4454
4666
|
}(engineCore.Loader);
|
|
@@ -5095,6 +5307,12 @@ var MaterialLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5095
5307
|
materialShaderData.setTexture(key, texture);
|
|
5096
5308
|
}));
|
|
5097
5309
|
break;
|
|
5310
|
+
case "Boolean":
|
|
5311
|
+
materialShaderData.setInt(key, value ? 1 : 0);
|
|
5312
|
+
break;
|
|
5313
|
+
case "Integer":
|
|
5314
|
+
materialShaderData.setInt(key, Number(value));
|
|
5315
|
+
break;
|
|
5098
5316
|
}
|
|
5099
5317
|
};
|
|
5100
5318
|
var engine = resourceManager.engine;
|
|
@@ -5215,7 +5433,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5215
5433
|
var _proto = SpriteAtlasLoader.prototype;
|
|
5216
5434
|
_proto.load = function load(item, resourceManager) {
|
|
5217
5435
|
var _this = this;
|
|
5218
|
-
return new engineCore.AssetPromise(function(resolve, reject, _, onCancel) {
|
|
5436
|
+
return new engineCore.AssetPromise(function(resolve, reject, _, __, onCancel) {
|
|
5219
5437
|
var chainPromises = [];
|
|
5220
5438
|
onCancel(function() {
|
|
5221
5439
|
for(var i = 0; i < chainPromises.length; i++){
|
|
@@ -5230,9 +5448,10 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5230
5448
|
var _loop = function(i) {
|
|
5231
5449
|
var atlasItem = atlasItems[i];
|
|
5232
5450
|
if (atlasItem.img) {
|
|
5451
|
+
var _atlasItem_type;
|
|
5233
5452
|
chainPromises.push(resourceManager.load({
|
|
5234
5453
|
url: engineCore.Utils.resolveAbsoluteUrl(item.url, atlasItem.img),
|
|
5235
|
-
type: engineCore.AssetType.Texture2D,
|
|
5454
|
+
type: (_atlasItem_type = atlasItem.type) != null ? _atlasItem_type : engineCore.AssetType.Texture2D,
|
|
5236
5455
|
params: {
|
|
5237
5456
|
format: format,
|
|
5238
5457
|
mipmap: mipmap
|
|
@@ -5362,15 +5581,19 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5362
5581
|
var _proto = Texture2DLoader.prototype;
|
|
5363
5582
|
_proto.load = function load(item, resourceManager) {
|
|
5364
5583
|
var _this = this;
|
|
5365
|
-
return new engineCore.AssetPromise(function(resolve, reject) {
|
|
5584
|
+
return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
5366
5585
|
var url = item.url;
|
|
5367
5586
|
var requestConfig = _extends({}, item, {
|
|
5368
5587
|
type: "image"
|
|
5369
5588
|
});
|
|
5370
|
-
_this.request(url, requestConfig).then(function(image) {
|
|
5371
|
-
var
|
|
5372
|
-
var
|
|
5373
|
-
var texture = new engineCore.Texture2D(resourceManager.engine, image.width, image.height,
|
|
5589
|
+
_this.request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
|
|
5590
|
+
var _item_params;
|
|
5591
|
+
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;
|
|
5592
|
+
var texture = new engineCore.Texture2D(resourceManager.engine, image.width, image.height, format, mipmap);
|
|
5593
|
+
texture.anisoLevel = anisoLevel != null ? anisoLevel : texture.anisoLevel;
|
|
5594
|
+
texture.filterMode = filterMode != null ? filterMode : texture.filterMode;
|
|
5595
|
+
texture.wrapModeU = wrapModeU != null ? wrapModeU : texture.wrapModeU;
|
|
5596
|
+
texture.wrapModeV = wrapModeV != null ? wrapModeV : texture.wrapModeV;
|
|
5374
5597
|
texture.setImageSource(image);
|
|
5375
5598
|
texture.generateMipmaps();
|
|
5376
5599
|
if (url.indexOf("data:") !== 0) {
|
|
@@ -5518,33 +5741,34 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5518
5741
|
var promises = [];
|
|
5519
5742
|
// parse ambient light
|
|
5520
5743
|
var ambient = data.scene.ambient;
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
// prettier-ignore
|
|
5525
|
-
var customAmbientPromise = resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
5526
|
-
scene.ambientLight = ambientLight;
|
|
5527
|
-
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5528
|
-
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5529
|
-
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5530
|
-
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5531
|
-
});
|
|
5532
|
-
promises.push(customAmbientPromise);
|
|
5533
|
-
} else if (!useCustomAmbient && ambient.ambientLight) {
|
|
5534
|
-
// @ts-ignore
|
|
5535
|
-
// prettier-ignore
|
|
5536
|
-
var ambientLightPromise = resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
5537
|
-
scene.ambientLight = ambientLight;
|
|
5538
|
-
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5539
|
-
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5540
|
-
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5541
|
-
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5542
|
-
});
|
|
5543
|
-
promises.push(ambientLightPromise);
|
|
5544
|
-
} else {
|
|
5744
|
+
if (ambient) {
|
|
5745
|
+
var useCustomAmbient = ambient.specularMode === "Custom";
|
|
5746
|
+
var useSH = ambient.diffuseMode === engineCore.DiffuseMode.SphericalHarmonics;
|
|
5545
5747
|
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5546
5748
|
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5749
|
+
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5547
5750
|
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5751
|
+
scene.ambientLight.specularTextureDecodeRGBM = true;
|
|
5752
|
+
if (useCustomAmbient && ambient.customAmbientLight) {
|
|
5753
|
+
promises.push(// @ts-ignore
|
|
5754
|
+
resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
5755
|
+
var _ambientLight;
|
|
5756
|
+
scene.ambientLight.specularTexture = (_ambientLight = ambientLight) == null ? void 0 : _ambientLight.specularTexture;
|
|
5757
|
+
}));
|
|
5758
|
+
}
|
|
5759
|
+
if (ambient.ambientLight && (!useCustomAmbient || useSH)) {
|
|
5760
|
+
promises.push(// @ts-ignore
|
|
5761
|
+
resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
5762
|
+
if (!useCustomAmbient) {
|
|
5763
|
+
var _ambientLight;
|
|
5764
|
+
scene.ambientLight.specularTexture = (_ambientLight = ambientLight) == null ? void 0 : _ambientLight.specularTexture;
|
|
5765
|
+
}
|
|
5766
|
+
if (useSH) {
|
|
5767
|
+
var _ambientLight1;
|
|
5768
|
+
scene.ambientLight.diffuseSphericalHarmonics = (_ambientLight1 = ambientLight) == null ? void 0 : _ambientLight1.diffuseSphericalHarmonics;
|
|
5769
|
+
}
|
|
5770
|
+
}));
|
|
5771
|
+
}
|
|
5548
5772
|
}
|
|
5549
5773
|
var background = data.scene.background;
|
|
5550
5774
|
scene.background.mode = background.mode;
|
|
@@ -5586,6 +5810,9 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5586
5810
|
if (shadow.shadowResolution != undefined) scene.shadowResolution = shadow.shadowResolution;
|
|
5587
5811
|
if (shadow.shadowDistance != undefined) scene.shadowDistance = shadow.shadowDistance;
|
|
5588
5812
|
if (shadow.shadowCascades != undefined) scene.shadowCascades = shadow.shadowCascades;
|
|
5813
|
+
var _shadow_shadowTwoCascadeSplits;
|
|
5814
|
+
scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
|
|
5815
|
+
shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
|
|
5589
5816
|
}
|
|
5590
5817
|
return Promise.all(promises).then(function() {
|
|
5591
5818
|
resolve(scene);
|
|
@@ -5601,13 +5828,13 @@ SceneLoader = __decorate([
|
|
|
5601
5828
|
"scene"
|
|
5602
5829
|
], true)
|
|
5603
5830
|
], SceneLoader);
|
|
5604
|
-
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item
|
|
5831
|
+
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item) {
|
|
5605
5832
|
var props;
|
|
5606
5833
|
return __generator(this, function(_state) {
|
|
5607
5834
|
props = item.props;
|
|
5608
5835
|
if (!props.font) {
|
|
5609
5836
|
// @ts-ignore
|
|
5610
|
-
instance.font = engineCore.Font.createFromOS(engine, props.fontFamily || "Arial");
|
|
5837
|
+
instance.font = engineCore.Font.createFromOS(instance.engine, props.fontFamily || "Arial");
|
|
5611
5838
|
}
|
|
5612
5839
|
return [
|
|
5613
5840
|
2,
|
|
@@ -5663,7 +5890,7 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
5663
5890
|
throw "BlendShape animation is not supported when using draco.";
|
|
5664
5891
|
}, function() {
|
|
5665
5892
|
return decodedGeometry.index.array;
|
|
5666
|
-
}, context.keepMeshData);
|
|
5893
|
+
}, context.params.keepMeshData);
|
|
5667
5894
|
});
|
|
5668
5895
|
});
|
|
5669
5896
|
};
|
|
@@ -5954,7 +6181,7 @@ var KHR_materials_variants = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5954
6181
|
var _glTFResource;
|
|
5955
6182
|
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;
|
|
5956
6183
|
var mappings = schema.mappings;
|
|
5957
|
-
(_glTFResource = glTFResource).
|
|
6184
|
+
(_glTFResource = glTFResource)._extensionsData || (_glTFResource._extensionsData = {});
|
|
5958
6185
|
var extensionData = [];
|
|
5959
6186
|
glTFResource.extensionsData.variants = extensionData;
|
|
5960
6187
|
for(var i = 0; i < mappings.length; i++)_loop(i);
|
|
@@ -5984,7 +6211,7 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5984
6211
|
var _proto = KHR_texture_basisu.prototype;
|
|
5985
6212
|
_proto.createAndParse = function createAndParse(context, schema, textureInfo) {
|
|
5986
6213
|
return _async_to_generator(function() {
|
|
5987
|
-
var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, bufferView;
|
|
6214
|
+
var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, promise, bufferView;
|
|
5988
6215
|
return __generator(this, function(_state) {
|
|
5989
6216
|
glTF = context.glTF, glTFResource = context.glTFResource;
|
|
5990
6217
|
engine = glTFResource.engine, url = glTFResource.url;
|
|
@@ -5994,20 +6221,22 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5994
6221
|
samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
|
|
5995
6222
|
if (uri) {
|
|
5996
6223
|
index = uri.lastIndexOf(".");
|
|
6224
|
+
promise = engine.resourceManager.load({
|
|
6225
|
+
url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
|
|
6226
|
+
type: engineCore.AssetType.KTX2
|
|
6227
|
+
}).onProgress(undefined, context._onTaskDetail).then(function(texture) {
|
|
6228
|
+
if (!texture.name) {
|
|
6229
|
+
texture.name = textureName || imageName || "texture_" + index;
|
|
6230
|
+
}
|
|
6231
|
+
if (sampler !== undefined) {
|
|
6232
|
+
GLTFUtils.parseSampler(texture, samplerInfo);
|
|
6233
|
+
}
|
|
6234
|
+
return texture;
|
|
6235
|
+
});
|
|
6236
|
+
context._addTaskCompletePromise(promise);
|
|
5997
6237
|
return [
|
|
5998
6238
|
2,
|
|
5999
|
-
|
|
6000
|
-
url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
|
|
6001
|
-
type: engineCore.AssetType.KTX2
|
|
6002
|
-
}).then(function(texture) {
|
|
6003
|
-
if (!texture.name) {
|
|
6004
|
-
texture.name = textureName || imageName || "texture_" + index;
|
|
6005
|
-
}
|
|
6006
|
-
if (sampler !== undefined) {
|
|
6007
|
-
GLTFUtils.parseSampler(texture, samplerInfo);
|
|
6008
|
-
}
|
|
6009
|
-
return texture;
|
|
6010
|
-
})
|
|
6239
|
+
promise
|
|
6011
6240
|
];
|
|
6012
6241
|
} else {
|
|
6013
6242
|
bufferView = glTF.bufferViews[bufferViewIndex];
|
|
@@ -6077,7 +6306,9 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
6077
6306
|
_proto.createAndParse = function createAndParse(context, schema) {
|
|
6078
6307
|
var engine = context.glTFResource.engine;
|
|
6079
6308
|
// @ts-ignore
|
|
6080
|
-
|
|
6309
|
+
var promise = engine.resourceManager.getResourceByRef(schema);
|
|
6310
|
+
context._addTaskCompletePromise(promise);
|
|
6311
|
+
return promise;
|
|
6081
6312
|
};
|
|
6082
6313
|
return GALACEAN_materials_remap;
|
|
6083
6314
|
}(GLTFExtensionParser);
|
|
@@ -6108,6 +6339,29 @@ GALACEAN_animation_event = __decorate([
|
|
|
6108
6339
|
registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
|
|
6109
6340
|
], GALACEAN_animation_event);
|
|
6110
6341
|
|
|
6342
|
+
var KHR_materials_anisotropy = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
6343
|
+
_inherits(KHR_materials_anisotropy, GLTFExtensionParser1);
|
|
6344
|
+
function KHR_materials_anisotropy() {
|
|
6345
|
+
return GLTFExtensionParser1.apply(this, arguments);
|
|
6346
|
+
}
|
|
6347
|
+
var _proto = KHR_materials_anisotropy.prototype;
|
|
6348
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
6349
|
+
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;
|
|
6350
|
+
material.anisotropy = anisotropyStrength;
|
|
6351
|
+
material.anisotropyRotation = anisotropyRotation;
|
|
6352
|
+
if (anisotropyTexture) {
|
|
6353
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(anisotropyTexture, "Anisotropy texture");
|
|
6354
|
+
context.get(exports.GLTFParserType.Texture, anisotropyTexture.index).then(function(texture) {
|
|
6355
|
+
material.anisotropyTexture = texture;
|
|
6356
|
+
});
|
|
6357
|
+
}
|
|
6358
|
+
};
|
|
6359
|
+
return KHR_materials_anisotropy;
|
|
6360
|
+
}(GLTFExtensionParser);
|
|
6361
|
+
KHR_materials_anisotropy = __decorate([
|
|
6362
|
+
registerGLTFExtension("KHR_materials_anisotropy", exports.GLTFExtensionMode.AdditiveParse)
|
|
6363
|
+
], KHR_materials_anisotropy);
|
|
6364
|
+
|
|
6111
6365
|
exports.ComponentMap = ComponentMap;
|
|
6112
6366
|
exports.GLTFExtensionParser = GLTFExtensionParser;
|
|
6113
6367
|
exports.GLTFParser = GLTFParser;
|