@galacean/engine-loader 1.1.0-beta.9 → 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 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._offset = 0;
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._offset);
129
- this._offset += 1;
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._offset, this._littleEndian);
134
- this._offset += 2;
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._offset, this._littleEndian);
139
- this._offset += 4;
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._offset, this._littleEndian);
144
- this._offset += 4;
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._offset + this._dataView.byteOffset, len);
149
- this._offset += 4 * len;
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._offset, this._littleEndian);
154
- this._offset += 4;
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._offset + this._dataView.byteOffset, len);
159
- this._offset += 4 * len;
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._offset + this._dataView.byteOffset, len);
164
- this._offset += 4 * len;
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._offset + this._dataView.byteOffset, len);
169
- this._offset += len;
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._offset, this._littleEndian);
174
- var right = this._dataView.getUint32(this._offset + 4, this._littleEndian);
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._offset += 8;
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._offset + this._dataView.byteOffset, strByteLength);
182
- this._offset += strByteLength;
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._offset);
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._offset, this._littleEndian);
194
+ var len = this._dataView.getUint32(this._position, this._littleEndian);
195
195
  imagesLen[i] = len;
196
- this._offset += 4;
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._offset, len1);
202
- this._offset += len1;
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._offset += bytes;
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._offset;
213
+ var byteOffset = this._position;
214
214
  var byteLength = 0;
215
- while(this._dataView.getUint8(this._offset) !== term && byteLength < maxByteLength){
215
+ while(this._dataView.getUint8(this._position) !== term && byteLength < maxByteLength){
216
216
  byteLength++;
217
- this._offset++;
217
+ this._position++;
218
218
  }
219
- if (byteLength < maxByteLength) this._offset++;
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._offset;
226
+ return this._position;
227
227
  }
228
228
  },
229
229
  {
230
230
  key: "offset",
231
231
  get: function get() {
232
- return this._offset + this._baseOffset;
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 byteOffset = bufferReader.data.byteOffset;
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 + byteOffset, (encodedMeshData.normals.end - encodedMeshData.normals.start) / 4);
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 + byteOffset, (encodedMeshData.uvs.end - encodedMeshData.uvs.start) / 4);
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 + byteOffset, (encodedMeshData.uv1.end - encodedMeshData.uv1.start) / 4);
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 + byteOffset, (encodedMeshData.uv2.end - encodedMeshData.uv2.start) / 4);
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 + byteOffset, (encodedMeshData.uv3.end - encodedMeshData.uv3.start) / 4);
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 + byteOffset, (encodedMeshData.uv4.end - encodedMeshData.uv4.start) / 4);
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 + byteOffset, (encodedMeshData.uv5.end - encodedMeshData.uv5.start) / 4);
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 + byteOffset, (encodedMeshData.uv6.end - encodedMeshData.uv6.start) / 4);
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 + byteOffset, (encodedMeshData.uv7.end - encodedMeshData.uv7.start) / 4);
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 + byteOffset, (encodedMeshData.colors.end - encodedMeshData.colors.start) / 4);
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 + byteOffset, (encodedMeshData.boneWeights.end - encodedMeshData.boneWeights.start) / 4);
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 + byteOffset, (encodedMeshData.boneIndices.end - encodedMeshData.boneIndices.start) / 4);
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 + byteOffset, (frameData.deltaPosition.end - frameData.deltaPosition.start) / 4);
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 + byteOffset, (frameData.deltaNormals.end - frameData.deltaNormals.start) / 4);
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 + byteOffset, (frameData.deltaTangents.end - frameData.deltaTangents.start) / 4);
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 + byteOffset, (encodedMeshData.indices.end - encodedMeshData.indices.start) / 2);
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 + byteOffset, (encodedMeshData.indices.end - encodedMeshData.indices.start) / 4);
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
- var instance = _construct(Class, [].concat(params));
550
- return this.parsePropsAndMethods(instance, item);
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
- var params = methodParams[i];
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
- // basic type
608
- return Promise.resolve(value);
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
- keyframe8.value = JSON.parse(bufferReader.nextStr());
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
- var value = key.value;
1102
- if (typeof value === "object" && value.refId) {
1103
- return new Promise(function(resolve) {
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, keepMeshData) {
1664
+ function GLTFParserContext(glTFResource, resourceManager, params) {
1665
+ var _this = this;
1550
1666
  this.glTFResource = glTFResource;
1551
1667
  this.resourceManager = resourceManager;
1552
- this.keepMeshData = keepMeshData;
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
- return this.get(0).then(function(json) {
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 _this.glTFResource;
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] = "sceneRoots", _obj1[4] = "textures", _obj1[5] = "materials", _obj1[6] = "meshes", _obj1[7] = "entities", _obj1[8] = "skins", _obj1[9] = "animations", _obj1);
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.offset;
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){
@@ -2565,6 +2754,7 @@ function transcode(buffer, targetFormat, KTX2File) {
2565
2754
  var faceCount = ktx2File.getFaces();
2566
2755
  var format = getTranscodeFormatFromTarget(targetFormat, hasAlpha);
2567
2756
  var faces = new Array(faceCount);
2757
+ var isBC = format === 2 || format === 3 || format === 7;
2568
2758
  for(var face = 0; face < faceCount; face++){
2569
2759
  var mipmaps = new Array(levelCount);
2570
2760
  for(var mip = 0; mip < levelCount; mip++){
@@ -2572,8 +2762,15 @@ function transcode(buffer, targetFormat, KTX2File) {
2572
2762
  var mipWidth = void 0, mipHeight = void 0;
2573
2763
  for(var layer = 0; layer < layerCount; layer++){
2574
2764
  var levelInfo = ktx2File.getImageLevelInfo(mip, layer, face);
2575
- mipWidth = levelInfo.origWidth;
2576
- mipHeight = levelInfo.origHeight;
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
+ }
2577
2774
  var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
2578
2775
  var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
2579
2776
  if (!status) {
@@ -2639,7 +2836,7 @@ function transcode(buffer, targetFormat, KTX2File) {
2639
2836
  } else {
2640
2837
  var funcCode = TranscodeWorkerCode$1.toString();
2641
2838
  var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
2642
- var workerCode = "\n " + jsCode + "\n var init = (" + _init.toString() + ")();\n " + transcode.toString() + "\n " + transcodeString + "\n ";
2839
+ var workerCode = "\n " + jsCode + "\n " + transcode.toString() + "\n " + transcodeString + "\n ";
2643
2840
  var workerURL = URL.createObjectURL(new Blob([
2644
2841
  workerCode
2645
2842
  ], {
@@ -2885,10 +3082,14 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2885
3082
  return Loader1.apply(this, arguments);
2886
3083
  }
2887
3084
  var _proto = KTX2Loader1.prototype;
2888
- _proto.initialize = function initialize(engine, configuration) {
3085
+ _proto.initialize = function initialize(_, configuration) {
2889
3086
  if (configuration.ktx2Loader) {
2890
3087
  var options = configuration.ktx2Loader;
2891
- if (this._isKhronosSupported(options.priorityFormats, engine) && options.workerCount !== 0) {
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) {
2892
3093
  return exports.KTX2Loader._getKhronosTranscoder(options.workerCount).init();
2893
3094
  } else {
2894
3095
  return exports.KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
@@ -2898,34 +3099,16 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2898
3099
  /**
2899
3100
  * @internal
2900
3101
  */ _proto.load = function load(item, resourceManager) {
2901
- return this.request(item.url, {
2902
- type: "arraybuffer"
2903
- }).then(function(buffer) {
2904
- return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
2905
- var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
2906
- return exports.KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
2907
- });
2908
- });
2909
- };
2910
- _proto._isKhronosSupported = function _isKhronosSupported(priorityFormats, engine) {
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];
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);
2929
3112
  });
2930
3113
  };
2931
3114
  /**
@@ -2940,7 +3123,8 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2940
3123
  /** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
2941
3124
  var _params;
2942
3125
  var ktx2Container = new KTX2Container(buffer);
2943
- var formatPriorities = (_params = params) == null ? void 0 : _params.priorityFormats;
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"];
2944
3128
  var targetFormat = exports.KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
2945
3129
  var transcodeResultPromise;
2946
3130
  if (exports.KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
@@ -3007,18 +3191,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
3007
3191
  return targetFormat;
3008
3192
  };
3009
3193
  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
3194
  for(var i = 0; i < priorityFormats.length; i++){
3018
- var capabilities = this._supportedMap[priorityFormats[i]];
3019
- for(var j = 0; j < capabilities.length; j++){
3020
- if (renderer.canIUse(capabilities[j])) {
3021
- return priorityFormats[i];
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;
3022
3210
  }
3023
3211
  }
3024
3212
  }
@@ -3055,6 +3243,23 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
3055
3243
  return KTX2Loader1;
3056
3244
  }(engineCore.Loader), function() {
3057
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
+ };
3058
3263
  }(), function() {
3059
3264
  var _obj;
3060
3265
  _KTX2Loader._supportedMap = (_obj = {}, _obj[exports.KTX2TargetFormat.ASTC] = [
@@ -3075,6 +3280,11 @@ exports.KTX2Loader = __decorate([
3075
3280
  "ktx2"
3076
3281
  ])
3077
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 = {}));
3078
3288
 
3079
3289
  /**
3080
3290
  * @internal
@@ -3425,7 +3635,7 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
3425
3635
  };
3426
3636
  var isGLB = this._isGLB(url);
3427
3637
  contentRestorer.isGLB = isGLB;
3428
- 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) {
3429
3639
  restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
3430
3640
  return GLTFUtils.parseGLB(context, glb);
3431
3641
  }).then(function(param) {
@@ -3434,7 +3644,7 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
3434
3644
  return glTF;
3435
3645
  }) : engineCore.request(url, {
3436
3646
  type: "json"
3437
- });
3647
+ }).onProgress(undefined, context._onTaskDetail);
3438
3648
  return promise;
3439
3649
  };
3440
3650
  _proto._isGLB = function _isGLB(url) {
@@ -3466,9 +3676,9 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3466
3676
  * @internal
3467
3677
  */ GLTFAnimationParser1._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
3468
3678
  var _loop = function(j, m) {
3469
- var gltfSampler = samplers[j];
3470
- var inputAccessor = accessors[gltfSampler.input];
3471
- var outputAccessor = accessors[gltfSampler.output];
3679
+ var glTFSampler = samplers[j];
3680
+ var inputAccessor = accessors[glTFSampler.input];
3681
+ var outputAccessor = accessors[glTFSampler.output];
3472
3682
  var promise = Promise.all([
3473
3683
  GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
3474
3684
  GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
@@ -3484,8 +3694,8 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3484
3694
  output = scaled;
3485
3695
  }
3486
3696
  var outputStride = output.length / input.length;
3487
- var _gltfSampler_interpolation;
3488
- var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
3697
+ var _glTFSampler_interpolation;
3698
+ var interpolation = (_glTFSampler_interpolation = glTFSampler.interpolation) != null ? _glTFSampler_interpolation : AnimationSamplerInterpolation.Linear;
3489
3699
  var samplerInterpolation;
3490
3700
  switch(interpolation){
3491
3701
  case AnimationSamplerInterpolation.CubicSpine:
@@ -3518,10 +3728,11 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3518
3728
  var promises = new Array();
3519
3729
  // parse samplers
3520
3730
  for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
3731
+ promises.push(context.get(exports.GLTFParserType.Scene));
3521
3732
  return Promise.all(promises).then(function() {
3522
3733
  for(var j = 0, m = channels.length; j < m; j++){
3523
- var gltfChannel = channels[j];
3524
- var target = gltfChannel.target;
3734
+ var glTFChannel = channels[j];
3735
+ var target = glTFChannel.target;
3525
3736
  var channelTargetEntity = entities[target.node];
3526
3737
  var relativePath = "";
3527
3738
  var entity = channelTargetEntity;
@@ -3529,6 +3740,10 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3529
3740
  relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
3530
3741
  entity = entity.parent;
3531
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
+ }
3532
3747
  var ComponentType = void 0;
3533
3748
  var propertyName = void 0;
3534
3749
  switch(target.path){
@@ -3549,14 +3764,21 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3549
3764
  propertyName = "blendShapeWeights";
3550
3765
  break;
3551
3766
  }
3552
- var curve = _this._addCurve(target.path, gltfChannel, sampleDataCollection);
3553
- animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
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
+ }
3554
3776
  }
3555
3777
  return animationClip;
3556
3778
  });
3557
3779
  };
3558
- GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, gltfChannel, sampleDataCollection) {
3559
- var sampleData = sampleDataCollection[gltfChannel.sampler];
3780
+ GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, glTFChannel, sampleDataCollection) {
3781
+ var sampleData = sampleDataCollection[glTFChannel.sampler];
3560
3782
  var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
3561
3783
  switch(animationChannelTargetPath){
3562
3784
  case AnimationChannelTargetPath.TRANSLATION:
@@ -3648,7 +3870,9 @@ exports.GLTFBufferParser = /*#__PURE__*/ function(GLTFParser1) {
3648
3870
  };
3649
3871
  var absoluteUrl = engineCore.Utils.resolveAbsoluteUrl(url, bufferInfo.uri);
3650
3872
  restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
3651
- return engineCore.request(absoluteUrl, requestConfig);
3873
+ var promise = engineCore.request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
3874
+ context._addTaskCompletePromise(promise);
3875
+ return promise;
3652
3876
  };
3653
3877
  return GLTFBufferParser;
3654
3878
  }(GLTFParser);
@@ -3663,10 +3887,13 @@ exports.GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
3663
3887
  }
3664
3888
  var _proto = GLTFEntityParser.prototype;
3665
3889
  _proto.parse = function parse(context, index) {
3890
+ var glTFResource = context.glTFResource;
3666
3891
  var entityInfo = context.glTF.nodes[index];
3667
- var engine = context.glTFResource.engine;
3892
+ var engine = glTFResource.engine;
3668
3893
  var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
3669
3894
  var entity = new engineCore.Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
3895
+ // @ts-ignore
3896
+ entity._markAsTemplate(glTFResource);
3670
3897
  var transform = entity.transform;
3671
3898
  if (matrix) {
3672
3899
  var localMatrix = transform.localMatrix;
@@ -3708,7 +3935,8 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3708
3935
  var _proto = GLTFMaterialParser1.prototype;
3709
3936
  _proto.parse = function parse(context, index) {
3710
3937
  var materialInfo = context.glTF.materials[index];
3711
- var engine = context.glTFResource.engine;
3938
+ var glTFResource = context.glTFResource;
3939
+ var engine = glTFResource.engine;
3712
3940
  var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
3713
3941
  if (!material) {
3714
3942
  material = new engineCore.PBRMaterial(engine);
@@ -3716,8 +3944,10 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3716
3944
  exports.GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
3717
3945
  }
3718
3946
  return Promise.resolve(material).then(function(material) {
3719
- material || (material = exports.GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine));
3947
+ material || (material = exports.GLTFMaterialParser._getDefaultMaterial(engine));
3720
3948
  GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
3949
+ // @ts-ignore
3950
+ material._associationSuperResource(glTFResource);
3721
3951
  return material;
3722
3952
  });
3723
3953
  };
@@ -3838,14 +4068,20 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
3838
4068
  var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, meshInfo);
3839
4069
  if (mesh) {
3840
4070
  if (_instanceof(mesh, engineCore.ModelMesh)) {
4071
+ // @ts-ignore
4072
+ mesh._associationSuperResource(glTFResource);
3841
4073
  resolve(mesh);
3842
4074
  } else {
3843
4075
  mesh.then(function(mesh) {
3844
- return resolve(mesh);
4076
+ // @ts-ignore
4077
+ mesh._associationSuperResource(glTFResource);
4078
+ resolve(mesh);
3845
4079
  });
3846
4080
  }
3847
4081
  } else {
3848
4082
  var mesh1 = new engineCore.ModelMesh(engine, meshInfo.name || i + "");
4083
+ // @ts-ignore
4084
+ mesh1._associationSuperResource(glTFResource);
3849
4085
  var meshRestoreInfo = new ModelMeshRestoreInfo();
3850
4086
  meshRestoreInfo.mesh = mesh1;
3851
4087
  context.contentRestorer.meshes.push(meshRestoreInfo);
@@ -3865,12 +4101,13 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
3865
4101
  return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
3866
4102
  return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
3867
4103
  });
3868
- }, context.keepMeshData).then(resolve);
4104
+ }, context.params.keepMeshData).then(resolve);
3869
4105
  }
3870
4106
  });
3871
4107
  };
3872
4108
  var meshInfo = context.glTF.meshes[index];
3873
- var glTF = context.glTF, engine = context.glTFResource.engine;
4109
+ var glTF = context.glTF, glTFResource = context.glTFResource;
4110
+ var engine = glTFResource.engine;
3874
4111
  var primitivePromises = new Array();
3875
4112
  for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
3876
4113
  return Promise.all(primitivePromises);
@@ -4043,9 +4280,9 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
4043
4280
  }
4044
4281
  var _proto = GLTFSceneParser.prototype;
4045
4282
  _proto.parse = function parse(context, index) {
4046
- var _this = this;
4047
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;
4048
4284
  var sceneInfo = scenes[index];
4285
+ var sceneExtensions = sceneInfo.extensions;
4049
4286
  var engine = glTFResource.engine;
4050
4287
  var isDefaultScene = scene === index;
4051
4288
  var sceneNodes = sceneInfo.nodes;
@@ -4059,30 +4296,15 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
4059
4296
  sceneRoot.addChild(childEntity);
4060
4297
  }
4061
4298
  }
4062
- // @ts-ignore
4063
- sceneRoot._hookResource = glTFResource;
4064
- // @ts-ignore
4065
- glTFResource._addReferCount(1);
4066
4299
  if (isDefaultScene) {
4067
- glTFResource.defaultSceneRoot = sceneRoot;
4300
+ glTFResource._defaultSceneRoot = sceneRoot;
4068
4301
  }
4069
4302
  var promises = new Array();
4070
4303
  for(var i1 = 0; i1 < sceneNodes.length; i1++){
4071
4304
  promises.push(this._parseEntityComponent(context, sceneNodes[i1]));
4072
4305
  }
4073
4306
  return Promise.all(promises).then(function() {
4074
- if (isDefaultScene) {
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
- }
4307
+ GLTFParser.executeExtensionsAdditiveAndParse(sceneExtensions, context, sceneRoot, sceneInfo);
4086
4308
  return sceneRoot;
4087
4309
  });
4088
4310
  };
@@ -4194,28 +4416,6 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
4194
4416
  for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
4195
4417
  return Promise.all(promises);
4196
4418
  };
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
4419
  _proto._computeLocalBounds = function _computeLocalBounds(skinnedMeshRenderer, mesh, bones, rootBone, inverseBindMatrices) {
4220
4420
  var rootBoneIndex = bones.indexOf(rootBone);
4221
4421
  if (rootBoneIndex !== -1) {
@@ -4364,11 +4564,12 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
4364
4564
  params: {
4365
4565
  mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
4366
4566
  }
4367
- }).then(function(texture) {
4567
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
4368
4568
  texture.name = textureName || imageName || texture.name || "texture_" + index;
4369
4569
  useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
4370
4570
  return texture;
4371
4571
  });
4572
+ context._addTaskCompletePromise(texture);
4372
4573
  } else {
4373
4574
  var bufferView = glTF.bufferViews[bufferViewIndex];
4374
4575
  texture = context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
@@ -4390,6 +4591,8 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
4390
4591
  }
4391
4592
  return Promise.resolve(texture).then(function(texture) {
4392
4593
  GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
4594
+ // @ts-ignore
4595
+ texture._associationSuperResource(glTFResource);
4393
4596
  return texture;
4394
4597
  });
4395
4598
  };
@@ -4447,12 +4650,17 @@ var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4447
4650
  }
4448
4651
  var _proto = GLTFLoader.prototype;
4449
4652
  _proto.load = function load(item, resourceManager) {
4450
- var _params;
4451
4653
  var url = item.url;
4452
4654
  var params = item.params;
4453
4655
  var glTFResource = new GLTFResource(resourceManager.engine, url);
4454
- var context = new GLTFParserContext(glTFResource, resourceManager, !!((_params = params) == null ? void 0 : _params.keepMeshData));
4455
- return context.parse();
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
+ });
4456
4664
  };
4457
4665
  return GLTFLoader;
4458
4666
  }(engineCore.Loader);
@@ -5099,6 +5307,12 @@ var MaterialLoader = /*#__PURE__*/ function(Loader1) {
5099
5307
  materialShaderData.setTexture(key, texture);
5100
5308
  }));
5101
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;
5102
5316
  }
5103
5317
  };
5104
5318
  var engine = resourceManager.engine;
@@ -5219,7 +5433,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
5219
5433
  var _proto = SpriteAtlasLoader.prototype;
5220
5434
  _proto.load = function load(item, resourceManager) {
5221
5435
  var _this = this;
5222
- return new engineCore.AssetPromise(function(resolve, reject, _, onCancel) {
5436
+ return new engineCore.AssetPromise(function(resolve, reject, _, __, onCancel) {
5223
5437
  var chainPromises = [];
5224
5438
  onCancel(function() {
5225
5439
  for(var i = 0; i < chainPromises.length; i++){
@@ -5234,9 +5448,10 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
5234
5448
  var _loop = function(i) {
5235
5449
  var atlasItem = atlasItems[i];
5236
5450
  if (atlasItem.img) {
5451
+ var _atlasItem_type;
5237
5452
  chainPromises.push(resourceManager.load({
5238
5453
  url: engineCore.Utils.resolveAbsoluteUrl(item.url, atlasItem.img),
5239
- type: engineCore.AssetType.Texture2D,
5454
+ type: (_atlasItem_type = atlasItem.type) != null ? _atlasItem_type : engineCore.AssetType.Texture2D,
5240
5455
  params: {
5241
5456
  format: format,
5242
5457
  mipmap: mipmap
@@ -5366,15 +5581,19 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader1) {
5366
5581
  var _proto = Texture2DLoader.prototype;
5367
5582
  _proto.load = function load(item, resourceManager) {
5368
5583
  var _this = this;
5369
- return new engineCore.AssetPromise(function(resolve, reject) {
5584
+ return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5370
5585
  var url = item.url;
5371
5586
  var requestConfig = _extends({}, item, {
5372
5587
  type: "image"
5373
5588
  });
5374
- _this.request(url, requestConfig).then(function(image) {
5375
- var _params, _params1;
5376
- var params = item.params;
5377
- var texture = new engineCore.Texture2D(resourceManager.engine, image.width, image.height, (_params = params) == null ? void 0 : _params.format, (_params1 = params) == null ? void 0 : _params1.mipmap);
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;
5378
5597
  texture.setImageSource(image);
5379
5598
  texture.generateMipmaps();
5380
5599
  if (url.indexOf("data:") !== 0) {
@@ -5522,33 +5741,34 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5522
5741
  var promises = [];
5523
5742
  // parse ambient light
5524
5743
  var ambient = data.scene.ambient;
5525
- var useCustomAmbient = ambient.specularMode === "Custom";
5526
- if (useCustomAmbient && ambient.customAmbientLight) {
5527
- // @ts-ignore
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 {
5744
+ if (ambient) {
5745
+ var useCustomAmbient = ambient.specularMode === "Custom";
5746
+ var useSH = ambient.diffuseMode === engineCore.DiffuseMode.SphericalHarmonics;
5549
5747
  scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
5550
5748
  scene.ambientLight.specularIntensity = ambient.specularIntensity;
5749
+ scene.ambientLight.diffuseMode = ambient.diffuseMode;
5551
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
+ }
5552
5772
  }
5553
5773
  var background = data.scene.background;
5554
5774
  scene.background.mode = background.mode;
@@ -5590,6 +5810,9 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5590
5810
  if (shadow.shadowResolution != undefined) scene.shadowResolution = shadow.shadowResolution;
5591
5811
  if (shadow.shadowDistance != undefined) scene.shadowDistance = shadow.shadowDistance;
5592
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);
5593
5816
  }
5594
5817
  return Promise.all(promises).then(function() {
5595
5818
  resolve(scene);
@@ -5605,13 +5828,13 @@ SceneLoader = __decorate([
5605
5828
  "scene"
5606
5829
  ], true)
5607
5830
  ], SceneLoader);
5608
- ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item, engine) {
5831
+ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item) {
5609
5832
  var props;
5610
5833
  return __generator(this, function(_state) {
5611
5834
  props = item.props;
5612
5835
  if (!props.font) {
5613
5836
  // @ts-ignore
5614
- instance.font = engineCore.Font.createFromOS(engine, props.fontFamily || "Arial");
5837
+ instance.font = engineCore.Font.createFromOS(instance.engine, props.fontFamily || "Arial");
5615
5838
  }
5616
5839
  return [
5617
5840
  2,
@@ -5667,7 +5890,7 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
5667
5890
  throw "BlendShape animation is not supported when using draco.";
5668
5891
  }, function() {
5669
5892
  return decodedGeometry.index.array;
5670
- }, context.keepMeshData);
5893
+ }, context.params.keepMeshData);
5671
5894
  });
5672
5895
  });
5673
5896
  };
@@ -5958,7 +6181,7 @@ var KHR_materials_variants = /*#__PURE__*/ function(GLTFExtensionParser1) {
5958
6181
  var _glTFResource;
5959
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;
5960
6183
  var mappings = schema.mappings;
5961
- (_glTFResource = glTFResource).extensionsData || (_glTFResource.extensionsData = {});
6184
+ (_glTFResource = glTFResource)._extensionsData || (_glTFResource._extensionsData = {});
5962
6185
  var extensionData = [];
5963
6186
  glTFResource.extensionsData.variants = extensionData;
5964
6187
  for(var i = 0; i < mappings.length; i++)_loop(i);
@@ -5988,7 +6211,7 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
5988
6211
  var _proto = KHR_texture_basisu.prototype;
5989
6212
  _proto.createAndParse = function createAndParse(context, schema, textureInfo) {
5990
6213
  return _async_to_generator(function() {
5991
- 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;
5992
6215
  return __generator(this, function(_state) {
5993
6216
  glTF = context.glTF, glTFResource = context.glTFResource;
5994
6217
  engine = glTFResource.engine, url = glTFResource.url;
@@ -5998,20 +6221,22 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
5998
6221
  samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
5999
6222
  if (uri) {
6000
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);
6001
6237
  return [
6002
6238
  2,
6003
- engine.resourceManager.load({
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
- })
6239
+ promise
6015
6240
  ];
6016
6241
  } else {
6017
6242
  bufferView = glTF.bufferViews[bufferViewIndex];
@@ -6081,7 +6306,9 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser1) {
6081
6306
  _proto.createAndParse = function createAndParse(context, schema) {
6082
6307
  var engine = context.glTFResource.engine;
6083
6308
  // @ts-ignore
6084
- return engine.resourceManager.getResourceByRef(schema);
6309
+ var promise = engine.resourceManager.getResourceByRef(schema);
6310
+ context._addTaskCompletePromise(promise);
6311
+ return promise;
6085
6312
  };
6086
6313
  return GALACEAN_materials_remap;
6087
6314
  }(GLTFExtensionParser);
@@ -6112,6 +6339,29 @@ GALACEAN_animation_event = __decorate([
6112
6339
  registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
6113
6340
  ], GALACEAN_animation_event);
6114
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
+
6115
6365
  exports.ComponentMap = ComponentMap;
6116
6366
  exports.GLTFExtensionParser = GLTFExtensionParser;
6117
6367
  exports.GLTFParser = GLTFParser;