@galacean/engine-loader 0.9.0-beta.80 → 1.0.0-alpha.6

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/module.js CHANGED
@@ -1,7 +1,7 @@
1
- import { resourceLoader, AssetType, AssetPromise, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, AnimatorStateTransition, Loader, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, IndexFormat, VertexElementFormat, DirectLight, PointLight, SpotLight, PBRMaterial, TextureCoordinate, Logger, RenderFace, PBRSpecularMaterial, UnlitMaterial, AnimationClip, InterpolationType, AnimationFloatArrayCurve, Keyframe, AnimationQuaternionCurve, AnimationVector3Curve, SkinnedMeshRenderer, Transform, request, Entity, VertexElement, Buffer, BufferBindFlag, BufferUsage, BlendShape, ModelMesh, Camera, Animator, BlinnPhongMaterial, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, Texture2D, EngineObject, TextureFormat, PBRBaseMaterial, Shader, ParticleRenderer, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationEvent, AnimationColorCurve, AnimationVector4Curve, AnimationVector2Curve, AnimationArrayCurve, AnimationFloatCurve, Scene, SpriteAtlas, Sprite, BackgroundMode, SkyBoxMaterial, PrimitiveMesh } from '@galacean/engine-core';
1
+ import { resourceLoader, AssetType, AssetPromise, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Loader, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, request, ContentRestorer, IndexFormat, VertexElementFormat, AnimationClip, InterpolationType, AnimationFloatArrayCurve, Keyframe, AnimationQuaternionCurve, AnimationVector3Curve, SkinnedMeshRenderer, Transform, Entity, PBRMaterial, Logger, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, BlendShape, ModelMesh, Camera, MeshRenderer, Animator, BlinnPhongMaterial, Skin, TextureWrapMode as TextureWrapMode$1, Texture2D, EngineObject, TextureFormat, PBRBaseMaterial, Shader, UnlitMaterial, DirectLight, ParticleRenderer, PointLight, SpotLight, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationEvent, AnimationColorCurve, AnimationVector4Curve, AnimationVector2Curve, AnimationArrayCurve, AnimationFloatCurve, Scene, SpriteAtlas, Sprite, BackgroundMode, SkyBoxMaterial, PrimitiveMesh } from '@galacean/engine-core';
2
2
  import { SphericalHarmonics3, Vector2, Vector3, Vector4, Color, Quaternion, Matrix, Rect } from '@galacean/engine-math';
3
- import { DRACODecoder } from '@galacean/engine-draco';
4
3
  import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
4
+ import { DRACODecoder } from '@galacean/engine-draco';
5
5
 
6
6
  function extends_() {
7
7
  extends_ = Object.assign || function (target) {
@@ -103,10 +103,10 @@ function __generator(thisArg, body) {
103
103
  }
104
104
  }
105
105
 
106
- var AnimatorControllerLoader = /*#__PURE__*/ function(Loader) {
107
- _inherits(AnimatorControllerLoader, Loader);
106
+ var AnimatorControllerLoader = /*#__PURE__*/ function(Loader1) {
107
+ _inherits(AnimatorControllerLoader, Loader1);
108
108
  function AnimatorControllerLoader() {
109
- return Loader.apply(this, arguments);
109
+ return Loader1.apply(this, arguments);
110
110
  }
111
111
  var _proto = AnimatorControllerLoader.prototype;
112
112
  _proto.load = function load(item, resourceManager) {
@@ -127,13 +127,16 @@ var AnimatorControllerLoader = /*#__PURE__*/ function(Loader) {
127
127
  var states = stateMachineData.states;
128
128
  var stateMachine = layer.stateMachine = new AnimatorStateMachine();
129
129
  states.forEach(function(stateData, stateIndex) {
130
- var name = stateData.name, speed = stateData.speed, wrapMode = stateData.wrapMode, clipStartNormalizedTime = stateData.clipStartNormalizedTime, clipEndNormalizedTime = stateData.clipEndNormalizedTime, isDefaultState = stateData.isDefaultState, clipData = stateData.clip;
130
+ var name = stateData.name, speed = stateData.speed, wrapMode = stateData.wrapMode, clipStartNormalizedTime = stateData.clipStartNormalizedTime, clipEndNormalizedTime = stateData.clipEndNormalizedTime, isDefaultState = stateData.isDefaultState, clipData = stateData.clip, scripts = stateData.scripts;
131
131
  var state = stateMachine.addState(name);
132
132
  isDefaultState && (stateMachine.defaultState = state);
133
133
  state.speed = speed;
134
134
  state.wrapMode = wrapMode;
135
135
  state.clipStartTime = clipStartNormalizedTime;
136
136
  state.clipEndTime = clipEndNormalizedTime;
137
+ scripts == null ? void 0 : scripts.forEach(function(script) {
138
+ state.addStateMachineScript(Loader.getClass(script));
139
+ });
137
140
  if (clipData) {
138
141
  promises.push(new Promise(function(resolve) {
139
142
  //@ts-ignore
@@ -359,52 +362,192 @@ FontLoader = __decorate([
359
362
  ], false)
360
363
  ], FontLoader);
361
364
 
365
+ function _arrayLikeToArray(arr, len) {
366
+ if (len == null || len > arr.length) len = arr.length;
367
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
368
+ return arr2;
369
+ }
370
+
371
+ function _unsupportedIterableToArray(o, minLen) {
372
+ if (!o) return;
373
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
374
+ var n = Object.prototype.toString.call(o).slice(8, -1);
375
+ if (n === "Object" && o.constructor) n = o.constructor.name;
376
+ if (n === "Map" || n === "Set") return Array.from(n);
377
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
378
+ return _arrayLikeToArray(o, minLen);
379
+ }
380
+
381
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
382
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
383
+ if (it) return (it = it.call(o)).next.bind(it);
384
+ // Fallback for engines without symbol support
385
+ if (
386
+ Array.isArray(o) ||
387
+ (it = _unsupportedIterableToArray(o)) ||
388
+ (allowArrayLike && o && typeof o.length === "number")
389
+ ) {
390
+ if (it) o = it;
391
+ var i = 0;
392
+ return function () {
393
+ if (i >= o.length) return { done: true };
394
+ return { done: false, value: o[i++] };
395
+ }
396
+ }
397
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
398
+ }
399
+
362
400
  /**
363
401
  * @internal
364
- */ var ParserContext = /*#__PURE__*/ function() {
365
- function ParserContext(url) {
366
- this.hasSkinned = false;
367
- /** chain asset promise */ this.chainPromises = [];
368
- this.accessorBufferCache = {};
369
- this.texturesPromiseInfo = new PromiseInfo();
370
- this.materialsPromiseInfo = new PromiseInfo();
371
- this.meshesPromiseInfo = new PromiseInfo();
372
- this.animationClipsPromiseInfo = new PromiseInfo();
373
- this.defaultSceneRootPromiseInfo = new PromiseInfo();
374
- this.masterPromiseInfo = new PromiseInfo();
375
- this.promiseMap = {};
376
- var promiseMap = this.promiseMap;
377
- promiseMap["" + url + "?q=textures"] = this._initPromiseInfo(this.texturesPromiseInfo);
378
- promiseMap["" + url + "?q=materials"] = this._initPromiseInfo(this.materialsPromiseInfo);
379
- promiseMap["" + url + "?q=meshes"] = this._initPromiseInfo(this.meshesPromiseInfo);
380
- promiseMap["" + url + "?q=animations"] = this._initPromiseInfo(this.animationClipsPromiseInfo);
381
- promiseMap["" + url + "?q=defaultSceneRoot"] = this._initPromiseInfo(this.defaultSceneRootPromiseInfo);
382
- promiseMap["" + url] = this._initPromiseInfo(this.masterPromiseInfo);
402
+ */ var GLTFContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
403
+ _inherits(GLTFContentRestorer, ContentRestorer);
404
+ function GLTFContentRestorer() {
405
+ var _this;
406
+ _this = ContentRestorer.apply(this, arguments) || this;
407
+ _this.bufferRequests = [];
408
+ _this.glbBufferSlices = [];
409
+ _this.bufferTextures = [];
410
+ _this.meshes = [];
411
+ return _this;
383
412
  }
384
- var _proto = ParserContext.prototype;
385
- _proto._initPromiseInfo = function _initPromiseInfo(promiseInfo) {
386
- var promise = new AssetPromise(function(resolve, reject, setProgress, onCancel) {
387
- promiseInfo.resolve = resolve;
388
- promiseInfo.reject = reject;
389
- promiseInfo.setProgress = setProgress;
390
- promiseInfo.onCancel = onCancel;
413
+ var _proto = GLTFContentRestorer.prototype;
414
+ /**
415
+ * @override
416
+ */ _proto.restoreContent = function restoreContent() {
417
+ var _this = this;
418
+ return new AssetPromise(function(resolve, reject) {
419
+ Promise.all(_this.bufferRequests.map(function(bufferRequestInfo) {
420
+ return request(bufferRequestInfo.url, bufferRequestInfo.config);
421
+ })).then(function(buffers) {
422
+ // Buffer parse
423
+ if (_this.isGLB) {
424
+ var glbBufferSlice = _this.glbBufferSlices;
425
+ var bigBuffer = buffers[0];
426
+ var bufferCount = glbBufferSlice.length;
427
+ buffers.length = bufferCount;
428
+ for(var i = 0; i < bufferCount; i++){
429
+ var slice = glbBufferSlice[i];
430
+ buffers[i] = bigBuffer.slice(slice.x, slice.x + slice.y);
431
+ }
432
+ }
433
+ // Restore texture
434
+ AssetPromise.all(_this.bufferTextures.map(function(textureRestoreInfo) {
435
+ var bufferView = textureRestoreInfo.bufferView;
436
+ var buffer = buffers[bufferView.buffer];
437
+ var _bufferView_byteOffset;
438
+ var bufferData = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
439
+ return GLTFUtil.loadImageBuffer(bufferData, textureRestoreInfo.mimeType).then(function(image) {
440
+ textureRestoreInfo.texture.setImageSource(image);
441
+ textureRestoreInfo.texture.generateMipmaps();
442
+ });
443
+ })).then(function() {
444
+ // Restore mesh
445
+ for(var _iterator = _createForOfIteratorHelperLoose(_this.meshes), _step; !(_step = _iterator()).done;){
446
+ var meshInfo = _step.value;
447
+ var mesh = meshInfo.mesh;
448
+ for(var _iterator1 = _createForOfIteratorHelperLoose(meshInfo.vertexBuffers), _step1; !(_step1 = _iterator1()).done;){
449
+ var bufferRestoreInfo = _step1.value;
450
+ var vertexData = _this._getBufferData(buffers, bufferRestoreInfo.data);
451
+ bufferRestoreInfo.buffer.setData(vertexData);
452
+ }
453
+ if (meshInfo.indexBuffer) {
454
+ var indexData = _this._getBufferData(buffers, meshInfo.indexBuffer);
455
+ mesh.setIndices(indexData);
456
+ }
457
+ for(var _iterator2 = _createForOfIteratorHelperLoose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
458
+ var restoreInfo = _step2.value;
459
+ var frame = restoreInfo.blendShape.frames[0];
460
+ var positionData = _this._getBufferData(buffers, restoreInfo.position);
461
+ frame.deltaPositions = GLTFUtil.floatBufferToVector3Array(positionData);
462
+ if (restoreInfo.normal) {
463
+ var normalData = _this._getBufferData(buffers, restoreInfo.normal);
464
+ frame.deltaNormals = GLTFUtil.floatBufferToVector3Array(normalData);
465
+ }
466
+ if (restoreInfo.tangent) {
467
+ var tangentData = _this._getBufferData(buffers, restoreInfo.tangent);
468
+ frame.deltaTangents = GLTFUtil.floatBufferToVector3Array(tangentData);
469
+ }
470
+ }
471
+ mesh.uploadData(true);
472
+ }
473
+ resolve(_this.resource);
474
+ }).catch(reject);
475
+ }).catch(reject);
391
476
  });
392
- promiseInfo.promise = promise;
393
- return promise;
394
477
  };
395
- return ParserContext;
396
- }();
478
+ _proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
479
+ var main = restoreInfo.main;
480
+ var buffer = buffers[main.bufferIndex];
481
+ var data = new main.TypedArray(buffer, main.byteOffset, main.length);
482
+ var sparseCount = restoreInfo.sparseCount;
483
+ if (sparseCount) {
484
+ var sparseIndex = restoreInfo.sparseIndices;
485
+ var sparseIndexBuffer = buffers[sparseIndex.bufferIndex];
486
+ var sparseIndexData = new sparseIndex.TypedArray(sparseIndexBuffer, sparseIndex.byteOffset, sparseIndex.length);
487
+ var sparseValue = restoreInfo.sparseValues;
488
+ var sparseValueBuffer = buffers[sparseValue.bufferIndex];
489
+ var sparseValueData = new sparseValue.TypedArray(sparseValueBuffer, sparseValue.byteOffset, sparseValue.length);
490
+ var typeSize = restoreInfo.typeSize;
491
+ for(var i = 0; i < sparseCount; i++){
492
+ var replaceIndex = sparseIndexData[i];
493
+ for(var j = 0; j < typeSize; j++){
494
+ data[replaceIndex * typeSize + j] = sparseValueData[i * typeSize + j];
495
+ }
496
+ }
497
+ }
498
+ return data;
499
+ };
500
+ return GLTFContentRestorer;
501
+ }(ContentRestorer);
397
502
  /**
398
503
  * @internal
399
- */ var BufferInfo = function BufferInfo(data, interleaved, stride) {
504
+ */ var BufferRequestInfo = function BufferRequestInfo(url, config) {
505
+ this.url = url;
506
+ this.config = config;
507
+ };
508
+ /**
509
+ * @internal
510
+ */ var BufferTextureRestoreInfo = function BufferTextureRestoreInfo(texture, bufferView, mimeType) {
511
+ this.texture = texture;
512
+ this.bufferView = bufferView;
513
+ this.mimeType = mimeType;
514
+ };
515
+ /**
516
+ * @internal
517
+ */ var ModelMeshRestoreInfo = function ModelMeshRestoreInfo() {
518
+ this.vertexBuffers = [];
519
+ this.blendShapes = [];
520
+ };
521
+ /**
522
+ * @internal
523
+ */ var BufferRestoreInfo = function BufferRestoreInfo(buffer, data) {
524
+ this.buffer = buffer;
400
525
  this.data = data;
401
- this.interleaved = interleaved;
402
- this.stride = stride;
403
- this.vertexBindingInfos = {};
404
526
  };
405
527
  /**
406
528
  * @internal
407
- */ var PromiseInfo = function PromiseInfo() {
529
+ */ var BufferDataRestoreInfo = function BufferDataRestoreInfo(main, typeSize, sparseCount, sparseIndices, sparseValues) {
530
+ this.main = main;
531
+ this.typeSize = typeSize;
532
+ this.sparseCount = sparseCount;
533
+ this.sparseIndices = sparseIndices;
534
+ this.sparseValues = sparseValues;
535
+ };
536
+ /**
537
+ * @internal
538
+ */ var RestoreDataAccessor = function RestoreDataAccessor(bufferIndex, TypedArray, byteOffset, length) {
539
+ this.bufferIndex = bufferIndex;
540
+ this.TypedArray = TypedArray;
541
+ this.byteOffset = byteOffset;
542
+ this.length = length;
543
+ };
544
+ /**
545
+ * @internal
546
+ */ var BlendShapeRestoreInfo = function BlendShapeRestoreInfo(blendShape, position, normal, tangent) {
547
+ this.blendShape = blendShape;
548
+ this.position = position;
549
+ this.normal = normal;
550
+ this.tangent = tangent;
408
551
  };
409
552
 
410
553
  /**
@@ -554,6 +697,54 @@ var TextureWrapMode;
554
697
  */ "REPEAT"] = 10497] = "REPEAT";
555
698
  })(TextureWrapMode || (TextureWrapMode = {}));
556
699
 
700
+ /**
701
+ * @internal
702
+ */ var GLTFParserContext = /*#__PURE__*/ function() {
703
+ function GLTFParserContext(url) {
704
+ this.hasSkinned = false;
705
+ this.chainPromises = [];
706
+ this.accessorBufferCache = {};
707
+ this.texturesPromiseInfo = new PromiseInfo();
708
+ this.materialsPromiseInfo = new PromiseInfo();
709
+ this.meshesPromiseInfo = new PromiseInfo();
710
+ this.animationClipsPromiseInfo = new PromiseInfo();
711
+ this.defaultSceneRootPromiseInfo = new PromiseInfo();
712
+ this.masterPromiseInfo = new PromiseInfo();
713
+ this.promiseMap = {};
714
+ var promiseMap = this.promiseMap;
715
+ promiseMap["" + url + "?q=textures"] = this._initPromiseInfo(this.texturesPromiseInfo);
716
+ promiseMap["" + url + "?q=materials"] = this._initPromiseInfo(this.materialsPromiseInfo);
717
+ promiseMap["" + url + "?q=meshes"] = this._initPromiseInfo(this.meshesPromiseInfo);
718
+ promiseMap["" + url + "?q=animations"] = this._initPromiseInfo(this.animationClipsPromiseInfo);
719
+ promiseMap["" + url + "?q=defaultSceneRoot"] = this._initPromiseInfo(this.defaultSceneRootPromiseInfo);
720
+ promiseMap["" + url] = this._initPromiseInfo(this.masterPromiseInfo);
721
+ }
722
+ var _proto = GLTFParserContext.prototype;
723
+ _proto._initPromiseInfo = function _initPromiseInfo(promiseInfo) {
724
+ var promise = new AssetPromise(function(resolve, reject, setProgress, onCancel) {
725
+ promiseInfo.resolve = resolve;
726
+ promiseInfo.reject = reject;
727
+ promiseInfo.setProgress = setProgress;
728
+ promiseInfo.onCancel = onCancel;
729
+ });
730
+ promiseInfo.promise = promise;
731
+ return promise;
732
+ };
733
+ return GLTFParserContext;
734
+ }();
735
+ /**
736
+ * @internal
737
+ */ var BufferInfo = function BufferInfo(data, interleaved, stride) {
738
+ this.data = data;
739
+ this.interleaved = interleaved;
740
+ this.stride = stride;
741
+ this.vertexBindingInfos = {};
742
+ };
743
+ /**
744
+ * @internal
745
+ */ var PromiseInfo = function PromiseInfo() {
746
+ };
747
+
557
748
  /**
558
749
  * @internal
559
750
  */ var GLTFUtil = /*#__PURE__*/ function() {
@@ -662,18 +853,18 @@ var TextureWrapMode;
662
853
  throw new Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.");
663
854
  }
664
855
  };
665
- GLTFUtil.getAccessorBuffer = function getAccessorBuffer(context, gltf, accessor) {
856
+ GLTFUtil.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
666
857
  var buffers = context.buffers;
667
- var bufferViews = gltf.bufferViews;
668
858
  var componentType = accessor.componentType;
669
859
  var bufferView = bufferViews[accessor.bufferView];
670
- var buffer = buffers[bufferView.buffer];
860
+ var bufferIndex = bufferView.buffer;
861
+ var buffer = buffers[bufferIndex];
671
862
  var bufferByteOffset = bufferView.byteOffset || 0;
672
863
  var byteOffset = accessor.byteOffset || 0;
673
864
  var TypedArray = GLTFUtil.getComponentType(componentType);
674
- var dataElmentSize = GLTFUtil.getAccessorTypeSize(accessor.type);
865
+ var dataElementSize = GLTFUtil.getAccessorTypeSize(accessor.type);
675
866
  var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
676
- var elementStride = dataElmentSize * dataElementBytes;
867
+ var elementStride = dataElementSize * dataElementBytes;
677
868
  var accessorCount = accessor.count;
678
869
  var bufferStride = bufferView.byteStride;
679
870
  var bufferInfo;
@@ -688,24 +879,25 @@ var TextureWrapMode;
688
879
  var count = accessorCount * (bufferStride / dataElementBytes);
689
880
  var data = new TypedArray(buffer, offset, count);
690
881
  accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
882
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
691
883
  }
692
884
  } else {
693
885
  var offset1 = bufferByteOffset + byteOffset;
694
- var count1 = accessorCount * dataElmentSize;
886
+ var count1 = accessorCount * dataElementSize;
695
887
  var data1 = new TypedArray(buffer, offset1, count1);
696
888
  bufferInfo = new BufferInfo(data1, false, elementStride);
889
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
697
890
  }
698
891
  if (accessor.sparse) {
699
- var data2 = GLTFUtil.processingSparseData(gltf, accessor, buffers, bufferInfo.data);
700
- bufferInfo = new BufferInfo(data2, false, bufferInfo.stride);
892
+ GLTFUtil.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
701
893
  }
702
894
  return bufferInfo;
703
895
  };
704
896
  /**
705
897
  * @deprecated
706
898
  * Get accessor data.
707
- */ GLTFUtil.getAccessorData = function getAccessorData(gltf, accessor, buffers) {
708
- var bufferViews = gltf.bufferViews;
899
+ */ GLTFUtil.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
900
+ var bufferViews = glTF.bufferViews;
709
901
  var bufferView = bufferViews[accessor.bufferView];
710
902
  var arrayBuffer = buffers[bufferView.buffer];
711
903
  var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
@@ -755,38 +947,46 @@ var TextureWrapMode;
755
947
  return typedArray;
756
948
  };
757
949
  GLTFUtil.getBufferViewData = function getBufferViewData(bufferView, buffers) {
758
- var buffer = bufferView.buffer, _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset, byteLength = bufferView.byteLength;
759
- var arrayBuffer = buffers[buffer];
760
- return arrayBuffer.slice(byteOffset, byteOffset + byteLength);
950
+ var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
951
+ var arrayBuffer = buffers[bufferView.buffer];
952
+ return arrayBuffer.slice(byteOffset, byteOffset + bufferView.byteLength);
761
953
  };
762
954
  /**
763
955
  * Get accessor data.
764
- */ GLTFUtil.processingSparseData = function processingSparseData(gltf, accessor, buffers, originData) {
765
- var bufferViews = gltf.bufferViews;
956
+ */ GLTFUtil.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
957
+ var restoreInfo = bufferInfo.restoreInfo;
766
958
  var accessorTypeSize = GLTFUtil.getAccessorTypeSize(accessor.type);
767
959
  var TypedArray = GLTFUtil.getComponentType(accessor.componentType);
768
- var data = originData.slice();
960
+ var data = bufferInfo.data.slice();
769
961
  var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
770
962
  var indicesBufferView = bufferViews[indices.bufferView];
771
963
  var valuesBufferView = bufferViews[values.bufferView];
772
- var indicesArrayBuffer = buffers[indicesBufferView.buffer];
773
- var valuesArrayBuffer = buffers[valuesBufferView.buffer];
964
+ var indicesBufferIndex = indicesBufferView.buffer;
965
+ var valuesBufferIndex = valuesBufferView.buffer;
966
+ var indicesArrayBuffer = buffers[indicesBufferIndex];
967
+ var valuesArrayBuffer = buffers[valuesBufferIndex];
774
968
  var _indices_byteOffset, _indicesBufferView_byteOffset;
775
969
  var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesBufferView_byteOffset = indicesBufferView.byteOffset) != null ? _indicesBufferView_byteOffset : 0);
776
970
  var indicesByteLength = indicesBufferView.byteLength;
777
971
  var _values_byteOffset, _valuesBufferView_byteOffset;
778
972
  var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
779
973
  var valuesByteLength = valuesBufferView.byteLength;
974
+ restoreInfo.typeSize = accessorTypeSize;
975
+ restoreInfo.sparseCount = count;
780
976
  var IndexTypeArray = GLTFUtil.getComponentType(indices.componentType);
781
- var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT);
782
- var valuesArray = new TypedArray(valuesArrayBuffer, valuesByteOffset, valuesByteLength / TypedArray.BYTES_PER_ELEMENT);
977
+ var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
978
+ var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
979
+ restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
980
+ var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
981
+ var valuesArray = new TypedArray(valuesArrayBuffer, valuesByteOffset, valueLength);
982
+ restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferIndex, TypedArray, valuesByteOffset, valueLength);
783
983
  for(var i = 0; i < count; i++){
784
984
  var replaceIndex = indicesArray[i];
785
985
  for(var j = 0; j < accessorTypeSize; j++){
786
986
  data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
787
987
  }
788
988
  }
789
- return data;
989
+ bufferInfo.data = data;
790
990
  };
791
991
  GLTFUtil.getIndexFormat = function getIndexFormat(type) {
792
992
  switch(type){
@@ -884,7 +1084,7 @@ var TextureWrapMode;
884
1084
  };
885
1085
  /**
886
1086
  * Parse the glb format.
887
- */ GLTFUtil.parseGLB = function parseGLB(glb) {
1087
+ */ GLTFUtil.parseGLB = function parseGLB(context, glb) {
888
1088
  var UINT32_LENGTH = 4;
889
1089
  var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
890
1090
  var GLB_HEADER_LENGTH = 12;
@@ -912,10 +1112,11 @@ var TextureWrapMode;
912
1112
  return null;
913
1113
  }
914
1114
  var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
915
- var gltf = JSON.parse(GLTFUtil.decodeText(glTFData));
1115
+ var glTF = JSON.parse(GLTFUtil.decodeText(glTFData));
916
1116
  // read all buffers
917
1117
  var buffers = [];
918
1118
  var byteOffset = GLB_HEADER_LENGTH + 2 * UINT32_LENGTH + chunkLength;
1119
+ var restoreGLBBufferSlice = context.contentRestorer.glbBufferSlices;
919
1120
  while(byteOffset < header.length){
920
1121
  chunkLength = dataView.getUint32(byteOffset, true);
921
1122
  chunkType = dataView.getUint32(byteOffset + UINT32_LENGTH, true);
@@ -926,10 +1127,11 @@ var TextureWrapMode;
926
1127
  var currentOffset = byteOffset + 2 * UINT32_LENGTH;
927
1128
  var buffer = glb.slice(currentOffset, currentOffset + chunkLength);
928
1129
  buffers.push(buffer);
1130
+ restoreGLBBufferSlice.push(new Vector2(currentOffset, chunkLength));
929
1131
  byteOffset += chunkLength + 2 * UINT32_LENGTH;
930
1132
  }
931
1133
  return {
932
- gltf: gltf,
1134
+ glTF: glTF,
933
1135
  buffers: buffers
934
1136
  };
935
1137
  };
@@ -944,12 +1146,6 @@ var TextureWrapMode;
944
1146
  return GLTFUtil;
945
1147
  }();
946
1148
 
947
- function _arrayLikeToArray(arr, len) {
948
- if (len == null || len > arr.length) len = arr.length;
949
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
950
- return arr2;
951
- }
952
-
953
1149
  function _arrayWithoutHoles(arr) {
954
1150
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
955
1151
  }
@@ -962,604 +1158,325 @@ function _nonIterableSpread() {
962
1158
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
963
1159
  }
964
1160
 
965
- function _unsupportedIterableToArray(o, minLen) {
966
- if (!o) return;
967
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
968
- var n = Object.prototype.toString.call(o).slice(8, -1);
969
- if (n === "Object" && o.constructor) n = o.constructor.name;
970
- if (n === "Map" || n === "Set") return Array.from(n);
971
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
972
- return _arrayLikeToArray(o, minLen);
973
- }
974
-
975
1161
  function _toConsumableArray(arr) {
976
1162
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
977
1163
  }
978
1164
 
979
- var Parser = /*#__PURE__*/ function() {
980
- function Parser() {}
981
- Parser.parseEngineResource = function parseEngineResource(extensionName, extensionSchema, parseResource, context) {
1165
+ /**
1166
+ * Base class of glTF extension parser.
1167
+ */ var GLTFExtensionParser = /*#__PURE__*/ function() {
1168
+ function GLTFExtensionParser() {}
1169
+ var _proto = GLTFExtensionParser.prototype;
1170
+ /**
1171
+ * Initialize the parser.
1172
+ * @remarks Some plugins require initialization.
1173
+ * @returns The void or promise
1174
+ */ _proto.initialize = function initialize() {};
1175
+ /**
1176
+ * Create and parse the resource.
1177
+ * @remarks This method overrides the default resource creation.
1178
+ * @param context - The parser context
1179
+ * @param extensionSchema - The extension schema
1180
+ * @param extensionOwnerSchema - The extension owner schema
1181
+ * @returns The resource or promise
1182
+ */ _proto.createAndParse = function createAndParse(context, extensionSchema, extensionOwnerSchema) {
1183
+ for(var _len = arguments.length, extra = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
1184
+ extra[_key - 3] = arguments[_key];
1185
+ }
1186
+ throw "Not implemented.";
1187
+ };
1188
+ /**
1189
+ * Additive parse to the resource.
1190
+ * @param context - The parser context
1191
+ * @param parseResource - The parsed resource
1192
+ * @param extensionSchema - The extension schema
1193
+ * @param extensionOwnerSchema - The extension owner schema
1194
+ * @returns The void or promise
1195
+ */ _proto.additiveParse = function additiveParse(context, parseResource, extensionSchema, extensionOwnerSchema) {
982
1196
  for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
983
1197
  extra[_key - 4] = arguments[_key];
984
1198
  }
985
- var parsers = Parser._extensionParsers[extensionName];
986
- if (parsers == null ? void 0 : parsers.length) {
987
- for(var i = 0; i < parsers.length; i++){
988
- var _parsers_i;
989
- (_parsers_i = parsers[i]).parseEngineResource.apply(_parsers_i, [
990
- extensionSchema,
991
- parseResource,
992
- context
993
- ].concat(_toConsumableArray(extra)));
994
- }
1199
+ throw "Not implemented.";
1200
+ };
1201
+ return GLTFExtensionParser;
1202
+ }();
1203
+ var GLTFExtensionMode;
1204
+ (function(GLTFExtensionMode) {
1205
+ GLTFExtensionMode[GLTFExtensionMode[/**
1206
+ * Cerate instance and parse mode.
1207
+ * @remarks
1208
+ * If the glTF property has multiple extensions of `CreateAndParse` mode, only execute the last one.
1209
+ * If this method is registered, the default pipeline processing will be ignored.
1210
+ */ "CreateAndParse"] = 0] = "CreateAndParse";
1211
+ GLTFExtensionMode[GLTFExtensionMode[/** Additive parse mode. */ "AdditiveParse"] = 1] = "AdditiveParse";
1212
+ })(GLTFExtensionMode || (GLTFExtensionMode = {}));
1213
+
1214
+ /**
1215
+ * Base class of glTF parser.
1216
+ */ var GLTFParser = /*#__PURE__*/ function() {
1217
+ function GLTFParser() {}
1218
+ /**
1219
+ * Execute all parses of extension to initialize plugin.
1220
+ * @remarks Some plugins require initialization.
1221
+ * @returns The void or promise
1222
+ */ GLTFParser.executeExtensionsInitialize = function executeExtensionsInitialize(extensionName) {
1223
+ var parsers = GLTFParser._extensionParsers[extensionName];
1224
+ var length = parsers == null ? void 0 : parsers.length;
1225
+ if (length) {
1226
+ return parsers[length - 1].initialize();
995
1227
  }
996
1228
  };
997
- Parser.createEngineResource = function createEngineResource(extensionName, extensionSchema, context) {
1229
+ /**
1230
+ * Execute all parses of extension to create resource.
1231
+ * @param extensions - Related extensions field
1232
+ * @param context - The parser context
1233
+ * @param ownerSchema - The extension owner schema
1234
+ * @param extra - Extra params
1235
+ * @returns
1236
+ */ GLTFParser.executeExtensionsCreateAndParse = function executeExtensionsCreateAndParse(extensions, context, ownerSchema) {
1237
+ if (extensions === void 0) extensions = {};
998
1238
  for(var _len = arguments.length, extra = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
999
1239
  extra[_key - 3] = arguments[_key];
1000
1240
  }
1001
- var parsers = Parser._extensionParsers[extensionName];
1002
- if (parsers == null ? void 0 : parsers.length) {
1003
- var _parsers_;
1004
- return (_parsers_ = parsers[0]).createEngineResource.apply(_parsers_, [
1241
+ var resource = null;
1242
+ var extensionArray = Object.keys(extensions);
1243
+ for(var i = extensionArray.length - 1; i >= 0; --i){
1244
+ var _GLTFParser;
1245
+ var extensionName = extensionArray[i];
1246
+ var extensionSchema = extensions[extensionName];
1247
+ resource = (_GLTFParser = GLTFParser)._createAndParse.apply(_GLTFParser, [
1248
+ extensionName,
1249
+ context,
1250
+ extensionSchema,
1251
+ ownerSchema
1252
+ ].concat(_toConsumableArray(extra)));
1253
+ if (resource) {
1254
+ return resource;
1255
+ }
1256
+ }
1257
+ };
1258
+ /**
1259
+ * Execute all parses of extension to parse resource.
1260
+ * @param extensions - Related extensions field
1261
+ * @param context - The parser context
1262
+ * @param parseResource - The parsed resource
1263
+ * @param ownerSchema - The extension owner schema
1264
+ * @param extra - Extra params
1265
+ */ GLTFParser.executeExtensionsAdditiveAndParse = function executeExtensionsAdditiveAndParse(extensions, context, parseResource, ownerSchema) {
1266
+ for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
1267
+ extra[_key - 4] = arguments[_key];
1268
+ }
1269
+ for(var extensionName in extensions){
1270
+ var _GLTFParser;
1271
+ var extensionSchema = extensions[extensionName];
1272
+ (_GLTFParser = GLTFParser)._additiveParse.apply(_GLTFParser, [
1273
+ extensionName,
1274
+ context,
1275
+ parseResource,
1005
1276
  extensionSchema,
1006
- context
1277
+ ownerSchema
1007
1278
  ].concat(_toConsumableArray(extra)));
1008
1279
  }
1009
1280
  };
1010
- Parser.hasExtensionParser = function hasExtensionParser(extensionName) {
1011
- var parsers = Parser._extensionParsers[extensionName];
1012
- return !!(parsers == null ? void 0 : parsers.length);
1281
+ /**
1282
+ * Whether the plugin is registered.
1283
+ * @param extensionName - Extension name
1284
+ * @returns Boolean
1285
+ */ GLTFParser.hasExtensionParser = function hasExtensionParser(extensionName) {
1286
+ var _GLTFParser__extensionParsers_extensionName;
1287
+ return !!((_GLTFParser__extensionParsers_extensionName = GLTFParser._extensionParsers[extensionName]) == null ? void 0 : _GLTFParser__extensionParsers_extensionName.length);
1013
1288
  };
1014
- Parser.initialize = function initialize(extensionName) {
1015
- var parsers = Parser._extensionParsers[extensionName];
1016
- if (parsers == null ? void 0 : parsers.length) {
1017
- for(var i = 0; i < parsers.length; i++){
1018
- parsers[i].initialize();
1289
+ /**
1290
+ * Get the last plugin by glTF extension mode.
1291
+ * @param extensionName - Extension name
1292
+ * @param mode - GLTF extension mode
1293
+ * @returns GLTF extension parser
1294
+ */ GLTFParser.getExtensionParser = function getExtensionParser(extensionName, mode) {
1295
+ var parsers = GLTFParser._extensionParsers[extensionName];
1296
+ var length = parsers == null ? void 0 : parsers.length;
1297
+ if (length) {
1298
+ // only use the last parser.
1299
+ for(var i = length - 1; i >= 0; --i){
1300
+ var currentParser = parsers[i];
1301
+ if (currentParser._mode === mode) {
1302
+ return currentParser;
1303
+ }
1019
1304
  }
1020
1305
  }
1021
1306
  };
1022
1307
  /**
1023
1308
  * @internal
1024
- */ Parser._addExtensionParser = function _addExtensionParser(extensionName, extensionParser) {
1025
- if (!Parser._extensionParsers[extensionName]) {
1026
- Parser._extensionParsers[extensionName] = [];
1309
+ */ GLTFParser._addExtensionParser = function _addExtensionParser(extensionName, extensionParser) {
1310
+ if (!GLTFParser._extensionParsers[extensionName]) {
1311
+ GLTFParser._extensionParsers[extensionName] = [];
1312
+ }
1313
+ GLTFParser._extensionParsers[extensionName].push(extensionParser);
1314
+ };
1315
+ GLTFParser._createAndParse = function _createAndParse(extensionName, context, extensionSchema, ownerSchema) {
1316
+ for(var _len = arguments.length, extra = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++){
1317
+ extra[_key - 4] = arguments[_key];
1318
+ }
1319
+ var parser = GLTFParser.getExtensionParser(extensionName, GLTFExtensionMode.CreateAndParse);
1320
+ if (parser) {
1321
+ var _parser;
1322
+ return (_parser = parser).createAndParse.apply(_parser, [
1323
+ context,
1324
+ extensionSchema,
1325
+ ownerSchema
1326
+ ].concat(_toConsumableArray(extra)));
1327
+ }
1328
+ };
1329
+ GLTFParser._additiveParse = function _additiveParse(extensionName, context, parseResource, extensionSchema, ownerSchema) {
1330
+ for(var _len = arguments.length, extra = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++){
1331
+ extra[_key - 5] = arguments[_key];
1332
+ }
1333
+ var parser = GLTFParser.getExtensionParser(extensionName, GLTFExtensionMode.AdditiveParse);
1334
+ if (parser) {
1335
+ var _parser;
1336
+ (_parser = parser).additiveParse.apply(_parser, [
1337
+ context,
1338
+ parseResource,
1339
+ extensionSchema,
1340
+ ownerSchema
1341
+ ].concat(_toConsumableArray(extra)));
1027
1342
  }
1028
- Parser._extensionParsers[extensionName].push(extensionParser);
1029
1343
  };
1030
- return Parser;
1344
+ return GLTFParser;
1031
1345
  }();
1032
- Parser._extensionParsers = {};
1346
+ GLTFParser._extensionParsers = {};
1033
1347
  /**
1034
1348
  * Declare ExtensionParser's decorator.
1035
1349
  * @param extensionName - Extension name
1036
- */ function registerExtension(extensionName) {
1350
+ */ function registerGLTFExtension(extensionName, mode) {
1037
1351
  return function(parser) {
1038
1352
  var extensionParser = new parser();
1039
- Parser._addExtensionParser(extensionName, extensionParser);
1353
+ extensionParser._mode = mode;
1354
+ GLTFParser._addExtensionParser(extensionName, extensionParser);
1040
1355
  };
1041
1356
  }
1042
1357
 
1043
- var ExtensionParser = /*#__PURE__*/ function() {
1044
- function ExtensionParser() {}
1045
- var _proto = ExtensionParser.prototype;
1046
- _proto.initialize = function initialize() {};
1047
- _proto.parseEngineResource = function parseEngineResource(schema, parseResource, context) {
1048
- for(var _len = arguments.length, extra = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
1049
- extra[_key - 3] = arguments[_key];
1050
- }
1051
- };
1052
- _proto.createEngineResource = function createEngineResource(schema, context) {
1053
- for(var _len = arguments.length, extra = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
1054
- extra[_key - 2] = arguments[_key];
1055
- }
1056
- return null;
1057
- };
1058
- return ExtensionParser;
1059
- }();
1060
-
1061
- var KHR_draco_mesh_compression = /*#__PURE__*/ function(ExtensionParser) {
1062
- _inherits(KHR_draco_mesh_compression1, ExtensionParser);
1063
- function KHR_draco_mesh_compression1() {
1064
- return ExtensionParser.apply(this, arguments);
1358
+ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
1359
+ _inherits(GLTFAnimationParser, GLTFParser1);
1360
+ function GLTFAnimationParser() {
1361
+ return GLTFParser1.apply(this, arguments);
1065
1362
  }
1066
- var _proto = KHR_draco_mesh_compression1.prototype;
1067
- _proto.initialize = function initialize() {
1068
- if (!KHR_draco_mesh_compression._decoder) {
1069
- KHR_draco_mesh_compression._decoder = new DRACODecoder();
1070
- }
1071
- };
1072
- _proto.createEngineResource = function createEngineResource(schema, context, gltfPrimitive) {
1073
- var gltf = context.gltf, buffers = context.buffers;
1074
- var bufferViews = gltf.bufferViews, accessors = gltf.accessors;
1075
- var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
1076
- var attributeMap = {};
1077
- var attributeTypeMap = {};
1078
- for(var attributeName in gltfAttributeMap){
1079
- attributeMap[attributeName] = gltfAttributeMap[attributeName];
1363
+ var _proto = GLTFAnimationParser.prototype;
1364
+ _proto.parse = function parse(context) {
1365
+ var glTF = context.glTF; context.buffers; var glTFResource = context.glTFResource;
1366
+ glTFResource.entities;
1367
+ var animations = glTF.animations; glTF.accessors; glTF.bufferViews;
1368
+ if (!animations) {
1369
+ return;
1080
1370
  }
1081
- for(var attributeName1 in gltfPrimitive.attributes){
1082
- if (gltfAttributeMap[attributeName1] !== undefined) {
1083
- var accessorDef = accessors[gltfPrimitive.attributes[attributeName1]];
1084
- attributeTypeMap[attributeName1] = GLTFUtil.getComponentType(accessorDef.componentType).name;
1371
+ var animationClipsPromiseInfo = context.animationClipsPromiseInfo;
1372
+ var animationClipCount = animations.length;
1373
+ var animationClipPromises = [];
1374
+ new Array(animationClipCount);
1375
+ for(var i = 0; i < animationClipCount; i++){
1376
+ var animationInfo = animations[i];
1377
+ var _animationInfo_name = animationInfo.name, name = _animationInfo_name === void 0 ? "AnimationClip" + i : _animationInfo_name;
1378
+ var animationClip = GLTFParser.executeExtensionsCreateAndParse(animationInfo.extensions, context, animationInfo);
1379
+ if (!animationClip) {
1380
+ animationClip = new AnimationClip(name);
1381
+ GLTFAnimationParser._parseStandardProperty(context, animationClip, animationInfo);
1085
1382
  }
1383
+ animationClipPromises.push(animationClip);
1086
1384
  }
1087
- var indexAccessor = accessors[gltfPrimitive.indices];
1088
- var indexType = GLTFUtil.getComponentType(indexAccessor.componentType).name;
1089
- var taskConfig = {
1090
- attributeIDs: attributeMap,
1091
- attributeTypes: attributeTypeMap,
1092
- useUniqueIDs: true,
1093
- indexType: indexType
1094
- };
1095
- var buffer = GLTFUtil.getBufferViewData(bufferViews[bufferViewIndex], buffers);
1096
- return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(parsedGeometry) {
1097
- return parsedGeometry;
1385
+ return AssetPromise.all(animationClipPromises).then(function(animationClips) {
1386
+ glTFResource.animations = animationClips;
1387
+ for(var i = 0; i < glTF.animations.length; i++){
1388
+ var animationInfo = glTF.animations[i];
1389
+ GLTFParser.executeExtensionsAdditiveAndParse(animationInfo.extensions, context, animationClips[i], animationInfo);
1390
+ }
1391
+ animationClipsPromiseInfo.resolve(animationClips);
1392
+ return animationClipsPromiseInfo.promise;
1098
1393
  });
1099
1394
  };
1100
- return KHR_draco_mesh_compression1;
1101
- }(ExtensionParser);
1102
- KHR_draco_mesh_compression = __decorate([
1103
- registerExtension("KHR_draco_mesh_compression")
1104
- ], KHR_draco_mesh_compression);
1105
-
1106
- function _instanceof(left, right) {
1107
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1108
- return !!right[Symbol.hasInstance](left);
1109
- } else {
1110
- return left instanceof right;
1111
- }
1112
- }
1113
-
1114
- var KHR_lights_punctual = /*#__PURE__*/ function(ExtensionParser) {
1115
- _inherits(KHR_lights_punctual, ExtensionParser);
1116
- function KHR_lights_punctual() {
1117
- return ExtensionParser.apply(this, arguments);
1118
- }
1119
- var _proto = KHR_lights_punctual.prototype;
1120
- _proto.parseEngineResource = function parseEngineResource(schema, entity, context) {
1121
- var color = schema.color, _schema_intensity = schema.intensity, intensity = _schema_intensity === void 0 ? 1 : _schema_intensity, type = schema.type, range = schema.range, spot = schema.spot;
1122
- var glTFResource = context.glTFResource;
1123
- var light;
1124
- if (type === "directional") {
1125
- light = entity.addComponent(DirectLight);
1126
- } else if (type === "point") {
1127
- light = entity.addComponent(PointLight);
1128
- } else if (type === "spot") {
1129
- light = entity.addComponent(SpotLight);
1130
- }
1131
- if (color) {
1132
- light.color.set(color[0], color[1], color[2], 1);
1133
- }
1134
- light.intensity = intensity;
1135
- if (range && !_instanceof(light, DirectLight)) {
1136
- light.distance = range;
1137
- }
1138
- if (spot && _instanceof(light, SpotLight)) {
1139
- var _spot_innerConeAngle = spot.innerConeAngle, innerConeAngle = _spot_innerConeAngle === void 0 ? 0 : _spot_innerConeAngle, _spot_outerConeAngle = spot.outerConeAngle, outerConeAngle = _spot_outerConeAngle === void 0 ? Math.PI / 4 : _spot_outerConeAngle;
1140
- light.angle = innerConeAngle;
1141
- light.penumbra = outerConeAngle - innerConeAngle;
1142
- }
1143
- if (!glTFResource.lights) glTFResource.lights = [];
1144
- glTFResource.lights.push(light);
1145
- };
1146
- return KHR_lights_punctual;
1147
- }(ExtensionParser);
1148
- KHR_lights_punctual = __decorate([
1149
- registerExtension("KHR_lights_punctual")
1150
- ], KHR_lights_punctual);
1151
-
1152
- var MaterialParser = /*#__PURE__*/ function(Parser1) {
1153
- _inherits(MaterialParser, Parser1);
1154
- function MaterialParser() {
1155
- return Parser1.apply(this, arguments);
1156
- }
1157
- var _proto = MaterialParser.prototype;
1158
- _proto.parse = function parse(context) {
1159
- var gltf = context.gltf, glTFResource = context.glTFResource;
1160
- var engine = glTFResource.engine, textures = glTFResource.textures;
1161
- if (!gltf.materials) return;
1162
- var materialsPromiseInfo = context.materialsPromiseInfo;
1163
- var materials = [];
1164
- for(var i = 0; i < gltf.materials.length; i++){
1165
- var _gltf_materials_i = gltf.materials[i], _gltf_materials_i_extensions = _gltf_materials_i.extensions, extensions = _gltf_materials_i_extensions === void 0 ? {} : _gltf_materials_i_extensions, pbrMetallicRoughness = _gltf_materials_i.pbrMetallicRoughness, normalTexture = _gltf_materials_i.normalTexture, occlusionTexture = _gltf_materials_i.occlusionTexture, emissiveTexture = _gltf_materials_i.emissiveTexture, emissiveFactor = _gltf_materials_i.emissiveFactor, alphaMode = _gltf_materials_i.alphaMode, alphaCutoff = _gltf_materials_i.alphaCutoff, doubleSided = _gltf_materials_i.doubleSided, _gltf_materials_i_name = _gltf_materials_i.name, name = _gltf_materials_i_name === void 0 ? "" : _gltf_materials_i_name;
1166
- var KHR_materials_unlit = extensions.KHR_materials_unlit, KHR_materials_pbrSpecularGlossiness = extensions.KHR_materials_pbrSpecularGlossiness, KHR_materials_clearcoat = extensions.KHR_materials_clearcoat, OASIS_materials_remap = extensions.OASIS_materials_remap;
1167
- var material = null;
1168
- if (KHR_materials_unlit) {
1169
- material = Parser.createEngineResource("KHR_materials_unlit", KHR_materials_unlit, context);
1170
- } else if (KHR_materials_pbrSpecularGlossiness) {
1171
- material = Parser.createEngineResource("KHR_materials_pbrSpecularGlossiness", KHR_materials_pbrSpecularGlossiness, context);
1172
- } else {
1173
- material = new PBRMaterial(engine);
1174
- }
1175
- material.name = name;
1176
- if (KHR_materials_clearcoat) {
1177
- Parser.parseEngineResource("KHR_materials_clearcoat", KHR_materials_clearcoat, material, context);
1178
- }
1179
- if (pbrMetallicRoughness) {
1180
- var baseColorFactor = pbrMetallicRoughness.baseColorFactor, baseColorTexture = pbrMetallicRoughness.baseColorTexture, metallicFactor = pbrMetallicRoughness.metallicFactor, roughnessFactor = pbrMetallicRoughness.roughnessFactor, metallicRoughnessTexture = pbrMetallicRoughness.metallicRoughnessTexture;
1181
- if (baseColorFactor) {
1182
- material.baseColor = new Color(Color.linearToGammaSpace(baseColorFactor[0]), Color.linearToGammaSpace(baseColorFactor[1]), Color.linearToGammaSpace(baseColorFactor[2]), baseColorFactor[3]);
1183
- }
1184
- if (baseColorTexture) {
1185
- material.baseTexture = textures[baseColorTexture.index];
1186
- MaterialParser._parseTextureTransform(material, baseColorTexture.extensions, context);
1187
- }
1188
- if (!KHR_materials_unlit && !KHR_materials_pbrSpecularGlossiness) {
1189
- var m = material;
1190
- m.metallic = metallicFactor != null ? metallicFactor : 1;
1191
- m.roughness = roughnessFactor != null ? roughnessFactor : 1;
1192
- if (metallicRoughnessTexture) {
1193
- m.roughnessMetallicTexture = textures[metallicRoughnessTexture.index];
1194
- MaterialParser._parseTextureTransform(material, metallicRoughnessTexture.extensions, context);
1195
- }
1196
- }
1197
- }
1198
- if (!KHR_materials_unlit) {
1199
- var m1 = material;
1200
- if (emissiveTexture) {
1201
- m1.emissiveTexture = textures[emissiveTexture.index];
1202
- MaterialParser._parseTextureTransform(material, emissiveTexture.extensions, context);
1203
- }
1204
- if (emissiveFactor) {
1205
- m1.emissiveColor = new Color(Color.linearToGammaSpace(emissiveFactor[0]), Color.linearToGammaSpace(emissiveFactor[1]), Color.linearToGammaSpace(emissiveFactor[2]));
1206
- }
1207
- if (normalTexture) {
1208
- var index = normalTexture.index, scale = normalTexture.scale;
1209
- m1.normalTexture = textures[index];
1210
- MaterialParser._parseTextureTransform(material, normalTexture.extensions, context);
1211
- if (scale !== undefined) {
1212
- m1.normalTextureIntensity = scale;
1213
- }
1214
- }
1215
- if (occlusionTexture) {
1216
- var index1 = occlusionTexture.index, strength = occlusionTexture.strength, texCoord = occlusionTexture.texCoord;
1217
- m1.occlusionTexture = textures[index1];
1218
- MaterialParser._parseTextureTransform(material, occlusionTexture.extensions, context);
1219
- if (strength !== undefined) {
1220
- m1.occlusionTextureIntensity = strength;
1221
- }
1222
- if (texCoord === TextureCoordinate.UV1) {
1223
- m1.occlusionTextureCoord = TextureCoordinate.UV1;
1224
- } else if (texCoord > TextureCoordinate.UV1) {
1225
- Logger.warn("Occlusion texture uv coordinate must be UV0 or UV1.");
1226
- }
1395
+ /**
1396
+ * @internal
1397
+ */ GLTFAnimationParser._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
1398
+ var glTF = context.glTF, glTFResource = context.glTFResource;
1399
+ var entities = glTFResource.entities;
1400
+ var accessors = glTF.accessors, bufferViews = glTF.bufferViews;
1401
+ var channels = animationInfo.channels, samplers = animationInfo.samplers;
1402
+ var sampleDataCollection = new Array();
1403
+ // parse samplers
1404
+ for(var j = 0, m = samplers.length; j < m; j++){
1405
+ var gltfSampler = samplers[j];
1406
+ var inputAccessor = accessors[gltfSampler.input];
1407
+ var outputAccessor = accessors[gltfSampler.output];
1408
+ var input = GLTFUtil.getAccessorBuffer(context, bufferViews, inputAccessor).data;
1409
+ var output = GLTFUtil.getAccessorBuffer(context, bufferViews, outputAccessor).data;
1410
+ if (outputAccessor.normalized) {
1411
+ var scale = GLTFUtil.getNormalizedComponentScale(outputAccessor.componentType);
1412
+ var scaled = new Float32Array(output.length);
1413
+ for(var k = 0, v = output.length; k < v; k++){
1414
+ scaled[k] = output[k] * scale;
1227
1415
  }
1416
+ output = scaled;
1228
1417
  }
1229
- if (OASIS_materials_remap) {
1230
- var _gltf_extensions;
1231
- gltf.extensions = (_gltf_extensions = gltf.extensions) != null ? _gltf_extensions : {};
1232
- var _gltf_extensions_OASIS_materials_remap;
1233
- gltf.extensions["OASIS_materials_remap"] = (_gltf_extensions_OASIS_materials_remap = gltf.extensions["OASIS_materials_remap"]) != null ? _gltf_extensions_OASIS_materials_remap : {};
1234
- gltf.extensions["OASIS_materials_remap"][i] = Parser.createEngineResource("OASIS_materials_remap", OASIS_materials_remap, context);
1235
- }
1236
- if (doubleSided) {
1237
- material.renderFace = RenderFace.Double;
1238
- } else {
1239
- material.renderFace = RenderFace.Front;
1240
- }
1241
- switch(alphaMode){
1242
- case MaterialAlphaMode.OPAQUE:
1243
- material.isTransparent = false;
1418
+ var outputStride = output.length / input.length;
1419
+ var _gltfSampler_interpolation;
1420
+ var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
1421
+ var samplerInterpolation = void 0;
1422
+ switch(interpolation){
1423
+ case AnimationSamplerInterpolation.CubicSpine:
1424
+ samplerInterpolation = InterpolationType.CubicSpine;
1244
1425
  break;
1245
- case MaterialAlphaMode.BLEND:
1246
- material.isTransparent = true;
1426
+ case AnimationSamplerInterpolation.Step:
1427
+ samplerInterpolation = InterpolationType.Step;
1247
1428
  break;
1248
- case MaterialAlphaMode.MASK:
1249
- material.alphaCutoff = alphaCutoff != null ? alphaCutoff : 0.5;
1429
+ case AnimationSamplerInterpolation.Linear:
1430
+ samplerInterpolation = InterpolationType.Linear;
1250
1431
  break;
1251
1432
  }
1252
- materials[i] = material;
1253
- }
1254
- glTFResource.materials = materials;
1255
- materialsPromiseInfo.resolve(materials);
1256
- return materialsPromiseInfo.promise;
1257
- };
1258
- /** @internal */ MaterialParser._parseTextureTransform = function _parseTextureTransform(material, extensions, context) {
1259
- if (extensions === void 0) extensions = {};
1260
- var schema = extensions.KHR_texture_transform;
1261
- if (schema) {
1262
- Parser.parseEngineResource("KHR_texture_transform", schema, material, context);
1263
- }
1264
- };
1265
- return MaterialParser;
1266
- }(Parser);
1267
-
1268
- var KHR_materials_clearcoat = /*#__PURE__*/ function(ExtensionParser) {
1269
- _inherits(KHR_materials_clearcoat, ExtensionParser);
1270
- function KHR_materials_clearcoat() {
1271
- return ExtensionParser.apply(this, arguments);
1272
- }
1273
- var _proto = KHR_materials_clearcoat.prototype;
1274
- _proto.parseEngineResource = function parseEngineResource(schema, material, context) {
1275
- var textures = context.glTFResource.textures;
1276
- var _schema_clearcoatFactor = schema.clearcoatFactor, clearcoatFactor = _schema_clearcoatFactor === void 0 ? 0 : _schema_clearcoatFactor, clearcoatTexture = schema.clearcoatTexture, _schema_clearcoatRoughnessFactor = schema.clearcoatRoughnessFactor, clearcoatRoughnessFactor = _schema_clearcoatRoughnessFactor === void 0 ? 0 : _schema_clearcoatRoughnessFactor, clearcoatRoughnessTexture = schema.clearcoatRoughnessTexture, clearcoatNormalTexture = schema.clearcoatNormalTexture;
1277
- material.clearCoat = clearcoatFactor;
1278
- material.clearCoatRoughness = clearcoatRoughnessFactor;
1279
- if (clearcoatTexture) {
1280
- material.clearCoatTexture = textures[clearcoatTexture.index];
1281
- MaterialParser._parseTextureTransform(material, clearcoatTexture.extensions, context);
1282
- }
1283
- if (clearcoatRoughnessTexture) {
1284
- material.clearCoatRoughnessTexture = textures[clearcoatRoughnessTexture.index];
1285
- MaterialParser._parseTextureTransform(material, clearcoatRoughnessTexture.extensions, context);
1286
- }
1287
- if (clearcoatNormalTexture) {
1288
- material.clearCoatNormalTexture = textures[clearcoatNormalTexture.index];
1289
- MaterialParser._parseTextureTransform(material, clearcoatNormalTexture.extensions, context);
1290
- }
1291
- };
1292
- return KHR_materials_clearcoat;
1293
- }(ExtensionParser);
1294
- KHR_materials_clearcoat = __decorate([
1295
- registerExtension("KHR_materials_clearcoat")
1296
- ], KHR_materials_clearcoat);
1297
-
1298
- var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(ExtensionParser) {
1299
- _inherits(KHR_materials_pbrSpecularGlossiness, ExtensionParser);
1300
- function KHR_materials_pbrSpecularGlossiness() {
1301
- return ExtensionParser.apply(this, arguments);
1302
- }
1303
- var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
1304
- _proto.createEngineResource = function createEngineResource(schema, context) {
1305
- var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
1306
- var material = new PBRSpecularMaterial(engine);
1307
- var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
1308
- if (diffuseFactor) {
1309
- material.baseColor = new Color(Color.linearToGammaSpace(diffuseFactor[0]), Color.linearToGammaSpace(diffuseFactor[1]), Color.linearToGammaSpace(diffuseFactor[2]), diffuseFactor[3]);
1310
- }
1311
- if (diffuseTexture) {
1312
- material.baseTexture = textures[diffuseTexture.index];
1313
- MaterialParser._parseTextureTransform(material, diffuseTexture.extensions, context);
1314
- }
1315
- if (specularFactor) {
1316
- material.specularColor = new Color(Color.linearToGammaSpace(specularFactor[0]), Color.linearToGammaSpace(specularFactor[1]), Color.linearToGammaSpace(specularFactor[2]));
1317
- }
1318
- if (glossinessFactor !== undefined) {
1319
- material.glossiness = glossinessFactor;
1320
- }
1321
- if (specularGlossinessTexture) {
1322
- material.specularGlossinessTexture = textures[specularGlossinessTexture.index];
1323
- MaterialParser._parseTextureTransform(material, specularGlossinessTexture.extensions, context);
1324
- }
1325
- return material;
1326
- };
1327
- return KHR_materials_pbrSpecularGlossiness;
1328
- }(ExtensionParser);
1329
- KHR_materials_pbrSpecularGlossiness = __decorate([
1330
- registerExtension("KHR_materials_pbrSpecularGlossiness")
1331
- ], KHR_materials_pbrSpecularGlossiness);
1332
-
1333
- var KHR_materials_unlit = /*#__PURE__*/ function(ExtensionParser) {
1334
- _inherits(KHR_materials_unlit, ExtensionParser);
1335
- function KHR_materials_unlit() {
1336
- return ExtensionParser.apply(this, arguments);
1337
- }
1338
- var _proto = KHR_materials_unlit.prototype;
1339
- _proto.createEngineResource = function createEngineResource(schema, context) {
1340
- var engine = context.glTFResource.engine;
1341
- var material = new UnlitMaterial(engine);
1342
- return material;
1343
- };
1344
- return KHR_materials_unlit;
1345
- }(ExtensionParser);
1346
- KHR_materials_unlit = __decorate([
1347
- registerExtension("KHR_materials_unlit")
1348
- ], KHR_materials_unlit);
1349
-
1350
- var KHR_materials_variants = /*#__PURE__*/ function(ExtensionParser) {
1351
- _inherits(KHR_materials_variants, ExtensionParser);
1352
- function KHR_materials_variants() {
1353
- return ExtensionParser.apply(this, arguments);
1354
- }
1355
- var _proto = KHR_materials_variants.prototype;
1356
- _proto.parseEngineResource = function parseEngineResource(schema, renderer, context) {
1357
- 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;
1358
- var mappings = schema.mappings;
1359
- for(var i = 0; i < mappings.length; i++){
1360
- var _mappings_i = mappings[i], material = _mappings_i.material, variants = _mappings_i.variants;
1361
- if (!glTFResource.variants) glTFResource.variants = [];
1362
- glTFResource.variants.push({
1363
- renderer: renderer,
1364
- material: glTFResource.materials[material],
1365
- variants: variants.map(function(index) {
1366
- return variantNames[index].name;
1367
- })
1433
+ input[input.length - 1];
1434
+ sampleDataCollection.push({
1435
+ type: outputAccessor.type,
1436
+ interpolation: samplerInterpolation,
1437
+ input: input,
1438
+ output: output,
1439
+ outputSize: outputStride
1368
1440
  });
1369
1441
  }
1370
- };
1371
- return KHR_materials_variants;
1372
- }(ExtensionParser);
1373
- KHR_materials_variants = __decorate([
1374
- registerExtension("KHR_materials_variants")
1375
- ], KHR_materials_variants);
1376
-
1377
- var KHR_mesh_quantization = /*#__PURE__*/ function(ExtensionParser) {
1378
- _inherits(KHR_mesh_quantization, ExtensionParser);
1379
- function KHR_mesh_quantization() {
1380
- return ExtensionParser.apply(this, arguments);
1381
- }
1382
- return KHR_mesh_quantization;
1383
- }(ExtensionParser);
1384
- KHR_mesh_quantization = __decorate([
1385
- registerExtension("KHR_mesh_quantization")
1386
- ], KHR_mesh_quantization);
1387
-
1388
- var KHR_texture_transform = /*#__PURE__*/ function(ExtensionParser) {
1389
- _inherits(KHR_texture_transform, ExtensionParser);
1390
- function KHR_texture_transform() {
1391
- return ExtensionParser.apply(this, arguments);
1392
- }
1393
- var _proto = KHR_texture_transform.prototype;
1394
- _proto.parseEngineResource = function parseEngineResource(schema, material, context) {
1395
- var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
1396
- if (offset) {
1397
- material.tilingOffset.z = offset[0];
1398
- material.tilingOffset.w = offset[1];
1399
- }
1400
- if (scale) {
1401
- material.tilingOffset.x = scale[0];
1402
- material.tilingOffset.y = scale[1];
1403
- }
1404
- if (rotation) {
1405
- Logger.warn("rotation in KHR_texture_transform is not supported now");
1406
- }
1407
- if (texCoord) {
1408
- Logger.warn("texCoord in KHR_texture_transform is not supported now");
1409
- }
1410
- };
1411
- return KHR_texture_transform;
1412
- }(ExtensionParser);
1413
- KHR_texture_transform = __decorate([
1414
- registerExtension("KHR_texture_transform")
1415
- ], KHR_texture_transform);
1416
-
1417
- var GalaceanMaterialsRemap = /*#__PURE__*/ function(ExtensionParser) {
1418
- _inherits(GalaceanMaterialsRemap, ExtensionParser);
1419
- function GalaceanMaterialsRemap() {
1420
- return ExtensionParser.apply(this, arguments);
1421
- }
1422
- var _proto = GalaceanMaterialsRemap.prototype;
1423
- _proto.createEngineResource = function createEngineResource(schema, context) {
1424
- var engine = context.glTFResource.engine;
1425
- // @ts-ignore
1426
- return engine.resourceManager.getResourceByRef(schema);
1427
- };
1428
- return GalaceanMaterialsRemap;
1429
- }(ExtensionParser);
1430
- GalaceanMaterialsRemap = __decorate([
1431
- registerExtension("OASIS_materials_remap")
1432
- ], GalaceanMaterialsRemap);
1433
-
1434
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
1435
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1436
- if (it) return (it = it.call(o)).next.bind(it);
1437
- // Fallback for engines without symbol support
1438
- if (
1439
- Array.isArray(o) ||
1440
- (it = _unsupportedIterableToArray(o)) ||
1441
- (allowArrayLike && o && typeof o.length === "number")
1442
- ) {
1443
- if (it) o = it;
1444
- var i = 0;
1445
- return function () {
1446
- if (i >= o.length) return { done: true };
1447
- return { done: false, value: o[i++] };
1448
- }
1449
- }
1450
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1451
- }
1452
-
1453
- var AnimationParser = /*#__PURE__*/ function(Parser) {
1454
- _inherits(AnimationParser, Parser);
1455
- function AnimationParser() {
1456
- return Parser.apply(this, arguments);
1457
- }
1458
- var _proto = AnimationParser.prototype;
1459
- _proto.parse = function parse(context) {
1460
- var gltf = context.gltf; context.buffers; var glTFResource = context.glTFResource;
1461
- var entities = glTFResource.entities;
1462
- var animations = gltf.animations, accessors = gltf.accessors;
1463
- if (!animations) {
1464
- return;
1465
- }
1466
- var animationClipsPromiseInfo = context.animationClipsPromiseInfo;
1467
- var animationClipCount = animations.length;
1468
- var animationClips = new Array(animationClipCount);
1469
- var animationsIndices = new Array(animationClipCount);
1470
- for(var i = 0; i < animationClipCount; i++){
1471
- var gltfAnimation = animations[i];
1472
- var channels = gltfAnimation.channels, samplers = gltfAnimation.samplers, _gltfAnimation_name = gltfAnimation.name, name = _gltfAnimation_name === void 0 ? "AnimationClip" + i : _gltfAnimation_name;
1473
- var animationClip = new AnimationClip(name);
1474
- var sampleDataCollection = new Array();
1475
- // parse samplers
1476
- for(var j = 0, m = samplers.length; j < m; j++){
1477
- var gltfSampler = samplers[j];
1478
- var inputAccessor = accessors[gltfSampler.input];
1479
- var outputAccessor = accessors[gltfSampler.output];
1480
- var input = GLTFUtil.getAccessorBuffer(context, gltf, inputAccessor).data;
1481
- var output = GLTFUtil.getAccessorBuffer(context, gltf, outputAccessor).data;
1482
- if (outputAccessor.normalized) {
1483
- var scale = GLTFUtil.getNormalizedComponentScale(outputAccessor.componentType);
1484
- var scaled = new Float32Array(output.length);
1485
- for(var k = 0, v = output.length; k < v; k++){
1486
- scaled[k] = output[k] * scale;
1487
- }
1488
- output = scaled;
1489
- }
1490
- var outputStride = output.length / input.length;
1491
- var _gltfSampler_interpolation;
1492
- var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
1493
- var samplerInterpolation = void 0;
1494
- switch(interpolation){
1495
- case AnimationSamplerInterpolation.CubicSpine:
1496
- samplerInterpolation = InterpolationType.CubicSpine;
1497
- break;
1498
- case AnimationSamplerInterpolation.Step:
1499
- samplerInterpolation = InterpolationType.Step;
1500
- break;
1501
- case AnimationSamplerInterpolation.Linear:
1502
- samplerInterpolation = InterpolationType.Linear;
1503
- break;
1504
- }
1505
- input[input.length - 1];
1506
- sampleDataCollection.push({
1507
- type: outputAccessor.type,
1508
- interpolation: samplerInterpolation,
1509
- input: input,
1510
- output: output,
1511
- outputSize: outputStride
1512
- });
1442
+ for(var j1 = 0, m1 = channels.length; j1 < m1; j1++){
1443
+ var gltfChannel = channels[j1];
1444
+ var target = gltfChannel.target;
1445
+ var channelTargetEntity = entities[target.node];
1446
+ var relativePath = "";
1447
+ var entity = channelTargetEntity;
1448
+ while(entity.parent){
1449
+ relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
1450
+ entity = entity.parent;
1513
1451
  }
1514
- for(var j1 = 0, m1 = channels.length; j1 < m1; j1++){
1515
- var gltfChannel = channels[j1];
1516
- var target = gltfChannel.target;
1517
- var channelTargetEntity = entities[target.node];
1518
- var relativePath = "";
1519
- var entity = channelTargetEntity;
1520
- while(entity.parent){
1521
- relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
1522
- entity = entity.parent;
1523
- }
1524
- var ComponentType = void 0;
1525
- var propertyName = void 0;
1526
- switch(target.path){
1527
- case AnimationChannelTargetPath.TRANSLATION:
1528
- ComponentType = Transform;
1529
- propertyName = "position";
1530
- break;
1531
- case AnimationChannelTargetPath.ROTATION:
1532
- ComponentType = Transform;
1533
- propertyName = "rotationQuaternion";
1534
- break;
1535
- case AnimationChannelTargetPath.SCALE:
1536
- ComponentType = Transform;
1537
- propertyName = "scale";
1538
- break;
1539
- case AnimationChannelTargetPath.WEIGHTS:
1540
- ComponentType = SkinnedMeshRenderer;
1541
- propertyName = "blendShapeWeights";
1542
- break;
1543
- }
1544
- var curve = this._addCurve(target.path, gltfChannel, sampleDataCollection);
1545
- animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
1452
+ var ComponentType = void 0;
1453
+ var propertyName = void 0;
1454
+ switch(target.path){
1455
+ case AnimationChannelTargetPath.TRANSLATION:
1456
+ ComponentType = Transform;
1457
+ propertyName = "position";
1458
+ break;
1459
+ case AnimationChannelTargetPath.ROTATION:
1460
+ ComponentType = Transform;
1461
+ propertyName = "rotationQuaternion";
1462
+ break;
1463
+ case AnimationChannelTargetPath.SCALE:
1464
+ ComponentType = Transform;
1465
+ propertyName = "scale";
1466
+ break;
1467
+ case AnimationChannelTargetPath.WEIGHTS:
1468
+ ComponentType = SkinnedMeshRenderer;
1469
+ propertyName = "blendShapeWeights";
1470
+ break;
1546
1471
  }
1547
- animationClips[i] = animationClip;
1548
- animationsIndices[i] = {
1549
- name: name,
1550
- index: i
1551
- };
1472
+ var curve = this._addCurve(target.path, gltfChannel, sampleDataCollection);
1473
+ animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
1552
1474
  }
1553
- glTFResource.animations = animationClips;
1554
- // @ts-ignore for editor
1555
- glTFResource._animationsIndices = animationsIndices;
1556
- animationClipsPromiseInfo.resolve(animationClips);
1557
- return animationClipsPromiseInfo.promise;
1558
1475
  };
1559
- _proto._addCurve = function _addCurve(animationchannelTargetPath, gltfChannel, sampleDataCollection) {
1476
+ GLTFAnimationParser._addCurve = function _addCurve(animationChannelTargetPath, gltfChannel, sampleDataCollection) {
1560
1477
  var sampleData = sampleDataCollection[gltfChannel.sampler];
1561
1478
  var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
1562
- switch(animationchannelTargetPath){
1479
+ switch(animationChannelTargetPath){
1563
1480
  case AnimationChannelTargetPath.TRANSLATION:
1564
1481
  case AnimationChannelTargetPath.SCALE:
1565
1482
  {
@@ -1624,35 +1541,42 @@ var AnimationParser = /*#__PURE__*/ function(Parser) {
1624
1541
  }
1625
1542
  }
1626
1543
  };
1627
- return AnimationParser;
1628
- }(Parser);
1544
+ return GLTFAnimationParser;
1545
+ }(GLTFParser);
1629
1546
 
1630
- var BufferParser = /*#__PURE__*/ function(Parser) {
1631
- _inherits(BufferParser, Parser);
1632
- function BufferParser() {
1633
- return Parser.apply(this, arguments);
1547
+ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
1548
+ _inherits(GLTFBufferParser, GLTFParser);
1549
+ function GLTFBufferParser() {
1550
+ return GLTFParser.apply(this, arguments);
1634
1551
  }
1635
- var _proto = BufferParser.prototype;
1552
+ var _proto = GLTFBufferParser.prototype;
1636
1553
  _proto.parse = function parse(context) {
1637
- var glTFResource = context.glTFResource;
1554
+ var glTFResource = context.glTFResource, contentRestorer = context.contentRestorer;
1638
1555
  var url = glTFResource.url;
1639
- if (this._isGLB(url)) {
1640
- return request(url, {
1641
- type: "arraybuffer"
1642
- }).then(GLTFUtil.parseGLB).then(function(param) {
1643
- var gltf = param.gltf, buffers = param.buffers;
1644
- context.gltf = gltf;
1556
+ var restoreBufferRequests = contentRestorer.bufferRequests;
1557
+ var requestConfig = {
1558
+ type: "arraybuffer"
1559
+ };
1560
+ var isGLB = this._isGLB(url);
1561
+ contentRestorer.isGLB = isGLB;
1562
+ if (isGLB) {
1563
+ return request(url, requestConfig).then(function(glb) {
1564
+ restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
1565
+ return GLTFUtil.parseGLB(context, glb);
1566
+ }).then(function(param) {
1567
+ var glTF = param.glTF, buffers = param.buffers;
1568
+ context.glTF = glTF;
1645
1569
  context.buffers = buffers;
1646
1570
  });
1647
1571
  } else {
1648
1572
  return request(url, {
1649
1573
  type: "json"
1650
- }).then(function(gltf) {
1651
- context.gltf = gltf;
1652
- return Promise.all(gltf.buffers.map(function(buffer) {
1653
- return request(GLTFUtil.parseRelativeUrl(url, buffer.uri), {
1654
- type: "arraybuffer"
1655
- });
1574
+ }).then(function(glTF) {
1575
+ context.glTF = glTF;
1576
+ return Promise.all(glTF.buffers.map(function(buffer) {
1577
+ var absoluteUrl = GLTFUtil.parseRelativeUrl(url, buffer.uri);
1578
+ restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
1579
+ return request(absoluteUrl, requestConfig);
1656
1580
  })).then(function(buffers) {
1657
1581
  context.buffers = buffers;
1658
1582
  });
@@ -1663,24 +1587,24 @@ var BufferParser = /*#__PURE__*/ function(Parser) {
1663
1587
  var index = url.lastIndexOf(".");
1664
1588
  return url.substring(index + 1, index + 4) === "glb";
1665
1589
  };
1666
- return BufferParser;
1667
- }(Parser);
1590
+ return GLTFBufferParser;
1591
+ }(GLTFParser);
1668
1592
 
1669
- var EntityParser = /*#__PURE__*/ function(Parser) {
1670
- _inherits(EntityParser, Parser);
1671
- function EntityParser() {
1672
- return Parser.apply(this, arguments);
1593
+ var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser) {
1594
+ _inherits(GLTFEntityParser, GLTFParser);
1595
+ function GLTFEntityParser() {
1596
+ return GLTFParser.apply(this, arguments);
1673
1597
  }
1674
- var _proto = EntityParser.prototype;
1598
+ var _proto = GLTFEntityParser.prototype;
1675
1599
  _proto.parse = function parse(context) {
1676
- var glTFResource = context.glTFResource, nodes = context.gltf.nodes;
1600
+ var glTFResource = context.glTFResource, nodes = context.glTF.nodes;
1677
1601
  var engine = glTFResource.engine;
1678
1602
  if (!nodes) return;
1679
1603
  var entities = [];
1680
1604
  for(var i = 0; i < nodes.length; i++){
1681
1605
  var gltfNode = nodes[i];
1682
1606
  var matrix = gltfNode.matrix, translation = gltfNode.translation, rotation = gltfNode.rotation, scale = gltfNode.scale;
1683
- var entity = new Entity(engine, gltfNode.name || "" + EntityParser._defaultName + i);
1607
+ var entity = new Entity(engine, gltfNode.name || "" + GLTFEntityParser._defaultName + i);
1684
1608
  var transform = entity.transform;
1685
1609
  if (matrix) {
1686
1610
  var localMatrix = transform.localMatrix;
@@ -1704,7 +1628,7 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
1704
1628
  this._createSceneRoots(context, glTFResource);
1705
1629
  };
1706
1630
  _proto._buildEntityTree = function _buildEntityTree(context, glTFResource) {
1707
- var nodes = context.gltf.nodes;
1631
+ var nodes = context.glTF.nodes;
1708
1632
  var entities = glTFResource.entities;
1709
1633
  for(var i = 0; i < nodes.length; i++){
1710
1634
  var children = nodes[i].children;
@@ -1718,7 +1642,7 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
1718
1642
  }
1719
1643
  };
1720
1644
  _proto._createSceneRoots = function _createSceneRoots(context, glTFResource) {
1721
- var _context_gltf = context.gltf, tmp = _context_gltf.scene, sceneID = tmp === void 0 ? 0 : tmp, scenes = _context_gltf.scenes;
1645
+ var _context_glTF = context.glTF, tmp = _context_glTF.scene, sceneID = tmp === void 0 ? 0 : tmp, scenes = _context_glTF.scenes;
1722
1646
  var engine = glTFResource.engine, entities = glTFResource.entities;
1723
1647
  if (!scenes) return;
1724
1648
  var sceneRoots = [];
@@ -1738,94 +1662,210 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
1738
1662
  glTFResource.sceneRoots = sceneRoots;
1739
1663
  glTFResource.defaultSceneRoot = sceneRoots[sceneID];
1740
1664
  };
1741
- return EntityParser;
1742
- }(Parser);
1743
- /** @internal */ EntityParser._defaultName = "_GLTF_ENTITY_";
1665
+ return GLTFEntityParser;
1666
+ }(GLTFParser);
1667
+ /** @internal */ GLTFEntityParser._defaultName = "_GLTF_ENTITY_";
1744
1668
 
1745
- var MeshParser = /*#__PURE__*/ function(Parser1) {
1746
- _inherits(MeshParser, Parser1);
1747
- function MeshParser() {
1748
- return Parser1.apply(this, arguments);
1669
+ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
1670
+ _inherits(GLTFMaterialParser, GLTFParser1);
1671
+ function GLTFMaterialParser() {
1672
+ return GLTFParser1.apply(this, arguments);
1749
1673
  }
1750
- var _proto = MeshParser.prototype;
1674
+ var _proto = GLTFMaterialParser.prototype;
1751
1675
  _proto.parse = function parse(context) {
1752
- var _loop = function(i) {
1753
- var _loop = function(j) {
1754
- var gltfPrimitive = gltfMesh.primitives[j];
1755
- var _gltfPrimitive_extensions = gltfPrimitive.extensions, extensions = _gltfPrimitive_extensions === void 0 ? {} : _gltfPrimitive_extensions;
1756
- var KHR_draco_mesh_compression = extensions.KHR_draco_mesh_compression;
1757
- primitivePromises[j] = new Promise(function(resolve) {
1758
- var mesh = new ModelMesh(engine, gltfMesh.name || j + "");
1759
- if (KHR_draco_mesh_compression) {
1760
- Parser.createEngineResource("KHR_draco_mesh_compression", KHR_draco_mesh_compression, context, gltfPrimitive).then(function(decodedGeometry) {
1761
- return _this._parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, function(attributeSemantic) {
1762
- for(var j = 0; j < decodedGeometry.attributes.length; j++){
1763
- if (decodedGeometry.attributes[j].name === attributeSemantic) {
1764
- return decodedGeometry.attributes[j].array;
1765
- }
1766
- }
1767
- return null;
1768
- }, function(attributeSemantic, shapeIndex) {
1769
- throw "BlendShape animation is not supported when using draco.";
1770
- }, function() {
1771
- return decodedGeometry.index.array;
1772
- }, context.keepMeshData);
1773
- }).then(resolve);
1774
- } else {
1775
- _this._parseMeshFromGLTFPrimitive(context, mesh, gltfMesh, gltfPrimitive, gltf, function(attributeSemantic) {
1776
- return null;
1777
- }, function(attributeName, shapeIndex) {
1778
- var shapeAccessorIdx = gltfPrimitive.targets[shapeIndex];
1779
- var attributeAccessorIdx = shapeAccessorIdx[attributeName];
1780
- if (attributeAccessorIdx) {
1781
- var accessor = gltf.accessors[attributeAccessorIdx];
1782
- return GLTFUtil.getAccessorData(gltf, accessor, buffers);
1783
- } else {
1784
- return null;
1785
- }
1786
- }, function() {
1787
- var indexAccessor = gltf.accessors[gltfPrimitive.indices];
1788
- return GLTFUtil.getAccessorData(gltf, indexAccessor, buffers);
1789
- }, context.keepMeshData).then(resolve);
1790
- }
1791
- });
1792
- };
1793
- var gltfMesh = gltf.meshes[i];
1794
- var primitivePromises = [];
1795
- for(var j = 0; j < gltfMesh.primitives.length; j++)_loop(j);
1796
- meshPromises[i] = Promise.all(primitivePromises);
1797
- };
1798
- var _this = this;
1799
- var gltf = context.gltf, buffers = context.buffers, glTFResource = context.glTFResource;
1676
+ var glTF = context.glTF, glTFResource = context.glTFResource, materialsPromiseInfo = context.materialsPromiseInfo;
1677
+ if (!glTF.materials) return;
1800
1678
  var engine = glTFResource.engine;
1801
- if (!gltf.meshes) return;
1802
- var meshesPromiseInfo = context.meshesPromiseInfo;
1803
- var meshPromises = [];
1804
- for(var i = 0; i < gltf.meshes.length; i++)_loop(i);
1805
- AssetPromise.all(meshPromises).then(function(meshes) {
1806
- glTFResource.meshes = meshes;
1807
- meshesPromiseInfo.resolve(meshes);
1808
- }).catch(meshesPromiseInfo.reject);
1809
- return meshesPromiseInfo.promise;
1679
+ var materialPromises = [];
1680
+ for(var i = 0; i < glTF.materials.length; i++){
1681
+ var materialInfo = glTF.materials[i];
1682
+ var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
1683
+ if (!material) {
1684
+ material = new PBRMaterial(engine);
1685
+ material.name = materialInfo.name;
1686
+ GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
1687
+ }
1688
+ materialPromises.push(material);
1689
+ }
1690
+ return AssetPromise.all(materialPromises).then(function(materials) {
1691
+ glTFResource.materials = materials;
1692
+ for(var i = 0; i < glTF.materials.length; i++){
1693
+ var materialInfo = glTF.materials[i];
1694
+ GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, materials[i], materialInfo);
1695
+ }
1696
+ materialsPromiseInfo.resolve(materials);
1697
+ return materialsPromiseInfo.promise;
1698
+ });
1810
1699
  };
1811
- _proto._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
1812
- var accessors = gltf.accessors;
1813
- context.buffers;
1814
- var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
1815
- var engine = mesh.engine;
1816
- var vertexElements = new Array();
1700
+ /**
1701
+ * @internal
1702
+ */ GLTFMaterialParser._checkOtherTextureTransform = function _checkOtherTextureTransform(texture, textureName) {
1703
+ var _texture_extensions;
1704
+ if ((_texture_extensions = texture.extensions) == null ? void 0 : _texture_extensions.KHR_texture_transform) {
1705
+ Logger.warn("" + textureName + " texture always use the KHR_texture_transform of the base texture.");
1706
+ }
1707
+ };
1708
+ /**
1709
+ * @internal
1710
+ */ GLTFMaterialParser._parseStandardProperty = function _parseStandardProperty(context, material, materialInfo) {
1711
+ var textures = context.glTFResource.textures;
1712
+ var pbrMetallicRoughness = materialInfo.pbrMetallicRoughness, normalTexture = materialInfo.normalTexture, occlusionTexture = materialInfo.occlusionTexture, emissiveTexture = materialInfo.emissiveTexture, emissiveFactor = materialInfo.emissiveFactor, alphaMode = materialInfo.alphaMode, alphaCutoff = materialInfo.alphaCutoff, doubleSided = materialInfo.doubleSided;
1713
+ if (pbrMetallicRoughness) {
1714
+ var baseColorFactor = pbrMetallicRoughness.baseColorFactor, baseColorTexture = pbrMetallicRoughness.baseColorTexture, metallicFactor = pbrMetallicRoughness.metallicFactor, roughnessFactor = pbrMetallicRoughness.roughnessFactor, metallicRoughnessTexture = pbrMetallicRoughness.metallicRoughnessTexture;
1715
+ if (baseColorFactor) {
1716
+ material.baseColor = new Color(Color.linearToGammaSpace(baseColorFactor[0]), Color.linearToGammaSpace(baseColorFactor[1]), Color.linearToGammaSpace(baseColorFactor[2]), baseColorFactor[3]);
1717
+ }
1718
+ if (baseColorTexture) {
1719
+ material.baseTexture = textures[baseColorTexture.index];
1720
+ GLTFParser.executeExtensionsAdditiveAndParse(baseColorTexture.extensions, context, material, baseColorTexture);
1721
+ }
1722
+ if (material.constructor === PBRMaterial) {
1723
+ material.metallic = metallicFactor != null ? metallicFactor : 1;
1724
+ material.roughness = roughnessFactor != null ? roughnessFactor : 1;
1725
+ if (metallicRoughnessTexture) {
1726
+ material.roughnessMetallicTexture = textures[metallicRoughnessTexture.index];
1727
+ GLTFMaterialParser._checkOtherTextureTransform(metallicRoughnessTexture, "Roughness metallic");
1728
+ }
1729
+ }
1730
+ }
1731
+ if (material.constructor === PBRMaterial || material.constructor === PBRSpecularMaterial) {
1732
+ if (emissiveTexture) {
1733
+ material.emissiveTexture = textures[emissiveTexture.index];
1734
+ GLTFMaterialParser._checkOtherTextureTransform(emissiveTexture, "Emissive");
1735
+ }
1736
+ if (emissiveFactor) {
1737
+ material.emissiveColor = new Color(Color.linearToGammaSpace(emissiveFactor[0]), Color.linearToGammaSpace(emissiveFactor[1]), Color.linearToGammaSpace(emissiveFactor[2]));
1738
+ }
1739
+ if (normalTexture) {
1740
+ var index = normalTexture.index, scale = normalTexture.scale;
1741
+ material.normalTexture = textures[index];
1742
+ GLTFMaterialParser._checkOtherTextureTransform(normalTexture, "Normal");
1743
+ if (scale !== undefined) {
1744
+ material.normalTextureIntensity = scale;
1745
+ }
1746
+ }
1747
+ if (occlusionTexture) {
1748
+ var index1 = occlusionTexture.index, strength = occlusionTexture.strength, texCoord = occlusionTexture.texCoord;
1749
+ material.occlusionTexture = textures[index1];
1750
+ GLTFMaterialParser._checkOtherTextureTransform(occlusionTexture, "Occlusion");
1751
+ if (strength !== undefined) {
1752
+ material.occlusionTextureIntensity = strength;
1753
+ }
1754
+ if (texCoord === TextureCoordinate.UV1) {
1755
+ material.occlusionTextureCoord = TextureCoordinate.UV1;
1756
+ } else if (texCoord > TextureCoordinate.UV1) {
1757
+ Logger.warn("Occlusion texture uv coordinate must be UV0 or UV1.");
1758
+ }
1759
+ }
1760
+ }
1761
+ if (doubleSided) {
1762
+ material.renderFace = RenderFace.Double;
1763
+ } else {
1764
+ material.renderFace = RenderFace.Front;
1765
+ }
1766
+ switch(alphaMode){
1767
+ case MaterialAlphaMode.OPAQUE:
1768
+ material.isTransparent = false;
1769
+ break;
1770
+ case MaterialAlphaMode.BLEND:
1771
+ material.isTransparent = true;
1772
+ break;
1773
+ case MaterialAlphaMode.MASK:
1774
+ material.alphaCutoff = alphaCutoff != null ? alphaCutoff : 0.5;
1775
+ break;
1776
+ }
1777
+ };
1778
+ return GLTFMaterialParser;
1779
+ }(GLTFParser);
1780
+
1781
+ function _instanceof(left, right) {
1782
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1783
+ return !!right[Symbol.hasInstance](left);
1784
+ } else {
1785
+ return left instanceof right;
1786
+ }
1787
+ }
1788
+
1789
+ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
1790
+ _inherits(GLTFMeshParser, GLTFParser1);
1791
+ function GLTFMeshParser() {
1792
+ return GLTFParser1.apply(this, arguments);
1793
+ }
1794
+ var _proto = GLTFMeshParser.prototype;
1795
+ _proto.parse = function parse(context) {
1796
+ var _loop = function(i) {
1797
+ var _loop = function(j) {
1798
+ var gltfPrimitive = gltfMesh.primitives[j];
1799
+ primitivePromises[j] = new Promise(function(resolve) {
1800
+ var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, gltfMesh);
1801
+ if (mesh) {
1802
+ if (_instanceof(mesh, ModelMesh)) {
1803
+ resolve(mesh);
1804
+ } else {
1805
+ mesh.then(function(mesh) {
1806
+ return resolve(mesh);
1807
+ });
1808
+ }
1809
+ } else {
1810
+ var mesh1 = new ModelMesh(engine, gltfMesh.name || j + "");
1811
+ var meshRestoreInfo = new ModelMeshRestoreInfo();
1812
+ meshRestoreInfo.mesh = mesh1;
1813
+ context.contentRestorer.meshes.push(meshRestoreInfo);
1814
+ GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, gltfMesh, gltfPrimitive, glTF, function(attributeSemantic) {
1815
+ return null;
1816
+ }, function(attributeName, shapeIndex) {
1817
+ var shapeAccessorIdx = gltfPrimitive.targets[shapeIndex];
1818
+ var attributeAccessorIdx = shapeAccessorIdx[attributeName];
1819
+ if (attributeAccessorIdx) {
1820
+ var accessor = glTF.accessors[attributeAccessorIdx];
1821
+ return GLTFUtil.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
1822
+ } else {
1823
+ return null;
1824
+ }
1825
+ }, function() {
1826
+ var indexAccessor = glTF.accessors[gltfPrimitive.indices];
1827
+ return GLTFUtil.getAccessorData(glTF, indexAccessor, buffers);
1828
+ }, context.keepMeshData).then(resolve);
1829
+ }
1830
+ });
1831
+ };
1832
+ var gltfMesh = glTF.meshes[i];
1833
+ var primitivePromises = [];
1834
+ for(var j = 0; j < gltfMesh.primitives.length; j++)_loop(j);
1835
+ meshPromises[i] = Promise.all(primitivePromises);
1836
+ };
1837
+ var glTF = context.glTF, buffers = context.buffers, glTFResource = context.glTFResource;
1838
+ var engine = glTFResource.engine;
1839
+ if (!glTF.meshes) return;
1840
+ var meshesPromiseInfo = context.meshesPromiseInfo;
1841
+ var meshPromises = [];
1842
+ for(var i = 0; i < glTF.meshes.length; i++)_loop(i);
1843
+ AssetPromise.all(meshPromises).then(function(meshes) {
1844
+ glTFResource.meshes = meshes;
1845
+ meshesPromiseInfo.resolve(meshes);
1846
+ }).catch(meshesPromiseInfo.reject);
1847
+ return meshesPromiseInfo.promise;
1848
+ };
1849
+ /**
1850
+ * @internal
1851
+ */ GLTFMeshParser._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
1852
+ var accessors = gltf.accessors;
1853
+ context.buffers;
1854
+ var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
1855
+ var engine = mesh.engine;
1856
+ var vertexElements = new Array();
1817
1857
  var vertexCount;
1818
1858
  var bufferBindIndex = 0;
1819
1859
  for(var attribute in attributes){
1820
1860
  var accessor = accessors[attributes[attribute]];
1821
- var accessorBuffer = GLTFUtil.getAccessorBuffer(context, gltf, accessor);
1822
- var dataElmentSize = GLTFUtil.getAccessorTypeSize(accessor.type);
1861
+ var accessorBuffer = GLTFUtil.getAccessorBuffer(context, gltf.bufferViews, accessor);
1862
+ var dataElementSize = GLTFUtil.getAccessorTypeSize(accessor.type);
1823
1863
  var attributeCount = accessor.count;
1824
1864
  var vertices = accessorBuffer.data;
1825
1865
  var vertexElement = void 0;
1826
1866
  var meshId = mesh.instanceId;
1827
1867
  var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
1828
- var elementFormat = GLTFUtil.getElementFormat(accessor.componentType, dataElmentSize, accessor.normalized);
1868
+ var elementFormat = GLTFUtil.getElementFormat(accessor.componentType, dataElementSize, accessor.normalized);
1829
1869
  if (accessorBuffer.interleaved) {
1830
1870
  var byteOffset = accessor.byteOffset || 0;
1831
1871
  var stride = accessorBuffer.stride;
@@ -1837,6 +1877,7 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
1837
1877
  vertexBuffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices.byteLength, BufferUsage.Static);
1838
1878
  vertexBuffer.setData(vertices);
1839
1879
  accessorBuffer.vertexBuffer = vertexBuffer;
1880
+ meshRestoreInfo.vertexBuffers.push(new BufferRestoreInfo(vertexBuffer, accessorBuffer.restoreInfo));
1840
1881
  }
1841
1882
  mesh.setVertexBufferBinding(vertexBuffer, stride, bufferBindIndex);
1842
1883
  vertexBindingInfos[meshId] = bufferBindIndex++;
@@ -1847,6 +1888,7 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
1847
1888
  vertexElement = new VertexElement(attribute, 0, elementFormat, bufferBindIndex);
1848
1889
  var vertexBuffer1 = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices.byteLength, BufferUsage.Static);
1849
1890
  vertexBuffer1.setData(vertices);
1891
+ meshRestoreInfo.vertexBuffers.push(new BufferRestoreInfo(vertexBuffer1, accessorBuffer.restoreInfo));
1850
1892
  mesh.setVertexBufferBinding(vertexBuffer1, accessorBuffer.stride, bufferBindIndex);
1851
1893
  vertexBindingInfos[meshId] = bufferBindIndex++;
1852
1894
  }
@@ -1858,7 +1900,7 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
1858
1900
  min.copyFromArray(accessor.min);
1859
1901
  max.copyFromArray(accessor.max);
1860
1902
  } else {
1861
- var position = MeshParser._tempVector3;
1903
+ var position = GLTFMeshParser._tempVector3;
1862
1904
  min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
1863
1905
  max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
1864
1906
  var stride1 = vertices.length / attributeCount;
@@ -1870,9 +1912,9 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
1870
1912
  }
1871
1913
  }
1872
1914
  if (accessor.normalized) {
1873
- var sacleFactor = GLTFUtil.getNormalizedComponentScale(accessor.componentType);
1874
- min.scale(sacleFactor);
1875
- max.scale(sacleFactor);
1915
+ var scaleFactor = GLTFUtil.getNormalizedComponentScale(accessor.componentType);
1916
+ min.scale(scaleFactor);
1917
+ max.scale(scaleFactor);
1876
1918
  }
1877
1919
  }
1878
1920
  }
@@ -1880,175 +1922,68 @@ var MeshParser = /*#__PURE__*/ function(Parser1) {
1880
1922
  // Indices
1881
1923
  if (indices !== undefined) {
1882
1924
  var indexAccessor = gltf.accessors[indices];
1883
- var indexData = getIndexBufferData();
1884
- mesh.setIndices(indexData);
1925
+ var accessorBuffer1 = GLTFUtil.getAccessorBuffer(context, gltf.bufferViews, indexAccessor);
1926
+ mesh.setIndices(accessorBuffer1.data);
1885
1927
  mesh.addSubMesh(0, indexAccessor.count, mode);
1928
+ meshRestoreInfo.indexBuffer = accessorBuffer1.restoreInfo;
1886
1929
  } else {
1887
1930
  mesh.addSubMesh(0, vertexCount, mode);
1888
1931
  }
1889
1932
  // BlendShapes
1890
- targets && this._createBlendShape(mesh, gltfMesh, targets, getBlendShapeData);
1933
+ targets && GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, targets, getBlendShapeData);
1891
1934
  mesh.uploadData(!keepMeshData);
1892
1935
  return Promise.resolve(mesh);
1893
1936
  };
1894
- _proto._createBlendShape = function _createBlendShape(mesh, glTFMesh, glTFTargets, getBlendShapeData) {
1937
+ /**
1938
+ * @internal
1939
+ */ GLTFMeshParser._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, glTFTargets, getBlendShapeData) {
1895
1940
  var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
1896
1941
  for(var i = 0, n = glTFTargets.length; i < n; i++){
1897
1942
  var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
1898
- var deltaPosBuffer = getBlendShapeData("POSITION", i);
1899
- var deltaNorBuffer = getBlendShapeData("NORMAL", i);
1900
- var deltaTanBuffer = getBlendShapeData("TANGENT", i);
1901
- var deltaPositions = deltaPosBuffer ? GLTFUtil.floatBufferToVector3Array(deltaPosBuffer) : null;
1902
- var deltaNormals = deltaNorBuffer ? GLTFUtil.floatBufferToVector3Array(deltaNorBuffer) : null;
1903
- var deltaTangents = deltaTanBuffer ? GLTFUtil.floatBufferToVector3Array(deltaTanBuffer) : null;
1943
+ var deltaPosBufferInfo = getBlendShapeData("POSITION", i);
1944
+ var deltaNorBufferInfo = getBlendShapeData("NORMAL", i);
1945
+ var deltaTanBufferInfo = getBlendShapeData("TANGENT", i);
1946
+ var deltaPositions = deltaPosBufferInfo.data ? GLTFUtil.floatBufferToVector3Array(deltaPosBufferInfo.data) : null;
1947
+ var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ? GLTFUtil.floatBufferToVector3Array(deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) : null;
1948
+ var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ? GLTFUtil.floatBufferToVector3Array(deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) : null;
1904
1949
  var blendShape = new BlendShape(name);
1905
1950
  blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
1906
1951
  mesh.addBlendShape(blendShape);
1952
+ meshRestoreInfo.blendShapes.push(new BlendShapeRestoreInfo(blendShape, deltaPosBufferInfo.restoreInfo, deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.restoreInfo, deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.restoreInfo));
1907
1953
  }
1908
1954
  };
1909
- /**
1910
- * @deprecated
1911
- */ _proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
1912
- var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
1913
- var vertexCount;
1914
- var accessors = gltf.accessors;
1915
- var accessor = accessors[attributes["POSITION"]];
1916
- var positionBuffer = getVertexBufferData("POSITION");
1917
- var positions = GLTFUtil.floatBufferToVector3Array(positionBuffer);
1918
- mesh.setPositions(positions);
1919
- var bounds = mesh.bounds;
1920
- vertexCount = accessor.count;
1921
- if (accessor.min && accessor.max) {
1922
- bounds.min.copyFromArray(accessor.min);
1923
- bounds.max.copyFromArray(accessor.max);
1924
- } else {
1925
- var position = MeshParser._tempVector3;
1926
- var min = bounds.min, max = bounds.max;
1927
- min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
1928
- max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
1929
- var stride = positionBuffer.length / vertexCount;
1930
- for(var j = 0; j < vertexCount; j++){
1931
- var offset = j * stride;
1932
- position.copyFromArray(positionBuffer, offset);
1933
- Vector3.min(min, position, min);
1934
- Vector3.max(max, position, max);
1935
- }
1936
- }
1937
- for(var attributeSemantic in attributes){
1938
- if (attributeSemantic === "POSITION") {
1939
- continue;
1940
- }
1941
- var bufferData = getVertexBufferData(attributeSemantic);
1942
- switch(attributeSemantic){
1943
- case "NORMAL":
1944
- var normals = GLTFUtil.floatBufferToVector3Array(bufferData);
1945
- mesh.setNormals(normals);
1946
- break;
1947
- case "TEXCOORD_0":
1948
- var texturecoords = GLTFUtil.floatBufferToVector2Array(bufferData);
1949
- mesh.setUVs(texturecoords, 0);
1950
- break;
1951
- case "TEXCOORD_1":
1952
- var texturecoords1 = GLTFUtil.floatBufferToVector2Array(bufferData);
1953
- mesh.setUVs(texturecoords1, 1);
1954
- break;
1955
- case "TEXCOORD_2":
1956
- var texturecoords2 = GLTFUtil.floatBufferToVector2Array(bufferData);
1957
- mesh.setUVs(texturecoords2, 2);
1958
- break;
1959
- case "TEXCOORD_3":
1960
- var texturecoords3 = GLTFUtil.floatBufferToVector2Array(bufferData);
1961
- mesh.setUVs(texturecoords3, 3);
1962
- break;
1963
- case "TEXCOORD_4":
1964
- var texturecoords4 = GLTFUtil.floatBufferToVector2Array(bufferData);
1965
- mesh.setUVs(texturecoords4, 4);
1966
- break;
1967
- case "TEXCOORD_5":
1968
- var texturecoords5 = GLTFUtil.floatBufferToVector2Array(bufferData);
1969
- mesh.setUVs(texturecoords5, 5);
1970
- break;
1971
- case "TEXCOORD_6":
1972
- var texturecoords6 = GLTFUtil.floatBufferToVector2Array(bufferData);
1973
- mesh.setUVs(texturecoords6, 6);
1974
- break;
1975
- case "TEXCOORD_7":
1976
- var texturecoords7 = GLTFUtil.floatBufferToVector2Array(bufferData);
1977
- mesh.setUVs(texturecoords7, 7);
1978
- break;
1979
- case "COLOR_0":
1980
- var colors = GLTFUtil.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
1981
- mesh.setColors(colors);
1982
- break;
1983
- case "TANGENT":
1984
- var tangents = GLTFUtil.floatBufferToVector4Array(bufferData);
1985
- mesh.setTangents(tangents);
1986
- break;
1987
- case "JOINTS_0":
1988
- var joints = GLTFUtil.floatBufferToVector4Array(bufferData);
1989
- mesh.setBoneIndices(joints);
1990
- break;
1991
- case "WEIGHTS_0":
1992
- var weights = GLTFUtil.floatBufferToVector4Array(bufferData);
1993
- mesh.setBoneWeights(weights);
1994
- break;
1995
- }
1996
- }
1997
- // Indices
1998
- if (indices !== undefined) {
1999
- var indexAccessor = gltf.accessors[indices];
2000
- var indexData = getIndexBufferData();
2001
- mesh.setIndices(indexData);
2002
- mesh.addSubMesh(0, indexAccessor.count, mode);
2003
- } else {
2004
- mesh.addSubMesh(0, vertexCount, mode);
2005
- }
2006
- // BlendShapes
2007
- targets && this._createBlendShape(mesh, gltfMesh, targets, getBlendShapeData);
2008
- mesh.uploadData(!keepMeshData);
2009
- return Promise.resolve(mesh);
2010
- };
2011
- return MeshParser;
2012
- }(Parser);
2013
- MeshParser._tempVector3 = new Vector3();
1955
+ return GLTFMeshParser;
1956
+ }(GLTFParser);
1957
+ GLTFMeshParser._tempVector3 = new Vector3();
2014
1958
 
2015
- var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
2016
- _inherits(SceneParser, Parser1);
2017
- function SceneParser() {
2018
- return Parser1.apply(this, arguments);
1959
+ var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
1960
+ _inherits(GLTFSceneParser, GLTFParser1);
1961
+ function GLTFSceneParser() {
1962
+ return GLTFParser1.apply(this, arguments);
2019
1963
  }
2020
- var _proto = SceneParser.prototype;
1964
+ var _proto = GLTFSceneParser.prototype;
2021
1965
  _proto.parse = function parse(context) {
2022
- var glTFResource = context.glTFResource, gltf = context.gltf;
1966
+ var glTFResource = context.glTFResource, glTF = context.glTF;
2023
1967
  var entities = glTFResource.entities;
2024
- var nodes = gltf.nodes, gltfCameras = gltf.cameras;
1968
+ var nodes = glTF.nodes, cameras = glTF.cameras;
2025
1969
  if (!nodes) return;
2026
1970
  var defaultSceneRootPromiseInfo = context.defaultSceneRootPromiseInfo;
2027
- var promises = [];
2028
1971
  for(var i = 0; i < nodes.length; i++){
2029
- var gltfNode = nodes[i];
2030
- var cameraID = gltfNode.camera, meshID = gltfNode.mesh, _gltfNode_extensions = gltfNode.extensions, extensions = _gltfNode_extensions === void 0 ? {} : _gltfNode_extensions;
2031
- var KHR_lights_punctual = extensions.KHR_lights_punctual;
1972
+ var glTFNode = nodes[i];
1973
+ var cameraID = glTFNode.camera, meshID = glTFNode.mesh, extensions = glTFNode.extensions;
2032
1974
  var entity = entities[i];
2033
1975
  if (cameraID !== undefined) {
2034
- this._createCamera(glTFResource, gltfCameras[cameraID], entity);
1976
+ this._createCamera(glTFResource, cameras[cameraID], entity);
2035
1977
  }
2036
1978
  if (meshID !== undefined) {
2037
- promises.push(this._createRenderer(context, gltfNode, entity));
2038
- }
2039
- if (KHR_lights_punctual) {
2040
- var lightIndex = KHR_lights_punctual.light;
2041
- var lights = gltf.extensions.KHR_lights_punctual.lights;
2042
- Parser.parseEngineResource("KHR_lights_punctual", lights[lightIndex], entity, context);
1979
+ this._createRenderer(context, glTFNode, entity);
2043
1980
  }
1981
+ GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, entity, glTFNode);
2044
1982
  }
2045
1983
  if (glTFResource.defaultSceneRoot) {
2046
1984
  this._createAnimator(context);
2047
1985
  }
2048
- gltf.extensions && delete gltf.extensions["OASIS_materials_remap"];
2049
- AssetPromise.all(promises).then(function() {
2050
- return defaultSceneRootPromiseInfo.resolve(glTFResource.defaultSceneRoot);
2051
- }).catch(defaultSceneRootPromiseInfo.reject);
1986
+ defaultSceneRootPromiseInfo.resolve(glTFResource.defaultSceneRoot);
2052
1987
  return defaultSceneRootPromiseInfo.promise;
2053
1988
  };
2054
1989
  _proto._createCamera = function _createCamera(context, cameraSchema, entity) {
@@ -2084,8 +2019,16 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
2084
2019
  // @todo: use engine camera by default
2085
2020
  camera.enabled = false;
2086
2021
  };
2087
- _proto._createRenderer = function _createRenderer(context, gltfNode, entity) {
2088
- var _loop = function(i) {
2022
+ _proto._createRenderer = function _createRenderer(context, glTFNode, entity) {
2023
+ var glTFResource = context.glTFResource, glTF = context.glTF;
2024
+ var glTFMeshes = glTF.meshes;
2025
+ var engine = glTFResource.engine, meshes = glTFResource.meshes, materials = glTFResource.materials, skins = glTFResource.skins;
2026
+ var meshID = glTFNode.mesh, skinID = glTFNode.skin;
2027
+ var glTFMesh = glTFMeshes[meshID];
2028
+ var glTFMeshPrimitives = glTFMesh.primitives;
2029
+ var blendShapeWeights = glTFNode.weights || glTFMesh.weights;
2030
+ for(var i = 0; i < glTFMeshPrimitives.length; i++){
2031
+ var gltfPrimitive = glTFMeshPrimitives[i];
2089
2032
  var mesh = meshes[meshID][i];
2090
2033
  var renderer = void 0;
2091
2034
  if (skinID !== undefined || blendShapeWeights) {
@@ -2103,32 +2046,11 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
2103
2046
  renderer = entity.addComponent(MeshRenderer);
2104
2047
  renderer.mesh = mesh;
2105
2048
  }
2106
- var materialIndex = gltfMeshPrimitives[i].material;
2107
- var remapMaterials = gltf.extensions && gltf.extensions["OASIS_materials_remap"];
2108
- if (remapMaterials && remapMaterials[materialIndex]) {
2109
- promises.push(remapMaterials[materialIndex].then(function(mtl) {
2110
- renderer.setMaterial(mtl);
2111
- }));
2112
- } else {
2113
- var material = (materials == null ? void 0 : materials[materialIndex]) || SceneParser._getDefaultMaterial(engine);
2114
- renderer.setMaterial(material);
2115
- }
2116
- var _gltfMeshPrimitives_i = gltfMeshPrimitives[i], _gltfMeshPrimitives_i_extensions = _gltfMeshPrimitives_i.extensions, extensions = _gltfMeshPrimitives_i_extensions === void 0 ? {} : _gltfMeshPrimitives_i_extensions;
2117
- var KHR_materials_variants = extensions.KHR_materials_variants;
2118
- if (KHR_materials_variants) {
2119
- Parser.parseEngineResource("KHR_materials_variants", KHR_materials_variants, renderer, context);
2120
- }
2121
- };
2122
- var glTFResource = context.glTFResource, gltf = context.gltf;
2123
- var gltfMeshes = gltf.meshes;
2124
- var engine = glTFResource.engine, meshes = glTFResource.meshes, materials = glTFResource.materials, skins = glTFResource.skins;
2125
- var meshID = gltfNode.mesh, skinID = gltfNode.skin;
2126
- var glTFMesh = gltfMeshes[meshID];
2127
- var gltfMeshPrimitives = glTFMesh.primitives;
2128
- var blendShapeWeights = gltfNode.weights || glTFMesh.weights;
2129
- var promises = [];
2130
- for(var i = 0; i < gltfMeshPrimitives.length; i++)_loop(i);
2131
- return Promise.all(promises);
2049
+ var materialIndex = gltfPrimitive.material;
2050
+ var material = (materials == null ? void 0 : materials[materialIndex]) || GLTFSceneParser._getDefaultMaterial(engine);
2051
+ renderer.setMaterial(material);
2052
+ GLTFParser.executeExtensionsAdditiveAndParse(gltfPrimitive.extensions, context, renderer, gltfPrimitive);
2053
+ }
2132
2054
  };
2133
2055
  _proto._createAnimator = function _createAnimator(context) {
2134
2056
  if (!context.hasSkinned && !context.glTFResource.animations) {
@@ -2155,25 +2077,25 @@ var SceneParser$1 = /*#__PURE__*/ function(Parser1) {
2155
2077
  }
2156
2078
  }
2157
2079
  };
2158
- SceneParser._getDefaultMaterial = function _getDefaultMaterial(engine) {
2159
- if (!SceneParser._defaultMaterial) {
2160
- SceneParser._defaultMaterial = new BlinnPhongMaterial(engine);
2080
+ GLTFSceneParser._getDefaultMaterial = function _getDefaultMaterial(engine) {
2081
+ if (!GLTFSceneParser._defaultMaterial) {
2082
+ GLTFSceneParser._defaultMaterial = new BlinnPhongMaterial(engine);
2161
2083
  }
2162
- return SceneParser._defaultMaterial;
2084
+ return GLTFSceneParser._defaultMaterial;
2163
2085
  };
2164
- return SceneParser;
2165
- }(Parser);
2086
+ return GLTFSceneParser;
2087
+ }(GLTFParser);
2166
2088
 
2167
- var SkinParser = /*#__PURE__*/ function(Parser) {
2168
- _inherits(SkinParser, Parser);
2169
- function SkinParser() {
2170
- return Parser.apply(this, arguments);
2089
+ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
2090
+ _inherits(GLTFSkinParser, GLTFParser);
2091
+ function GLTFSkinParser() {
2092
+ return GLTFParser.apply(this, arguments);
2171
2093
  }
2172
- var _proto = SkinParser.prototype;
2094
+ var _proto = GLTFSkinParser.prototype;
2173
2095
  _proto.parse = function parse(context) {
2174
- var glTFResource = context.glTFResource, gltf = context.gltf; context.buffers;
2096
+ var glTFResource = context.glTFResource, glTF = context.glTF; context.buffers;
2175
2097
  var entities = glTFResource.entities;
2176
- var gltfSkins = gltf.skins;
2098
+ var gltfSkins = glTF.skins;
2177
2099
  if (!gltfSkins) return;
2178
2100
  var count = gltfSkins.length;
2179
2101
  var skins = new Array(count);
@@ -2183,8 +2105,8 @@ var SkinParser = /*#__PURE__*/ function(Parser) {
2183
2105
  var skin = new Skin(name);
2184
2106
  skin.inverseBindMatrices.length = jointCount;
2185
2107
  // parse IBM
2186
- var accessor = gltf.accessors[inverseBindMatrices];
2187
- var buffer = GLTFUtil.getAccessorBuffer(context, gltf, accessor).data;
2108
+ var accessor = glTF.accessors[inverseBindMatrices];
2109
+ var buffer = GLTFUtil.getAccessorBuffer(context, glTF.bufferViews, accessor).data;
2188
2110
  for(var i1 = 0; i1 < jointCount; i1++){
2189
2111
  var inverseBindMatrix = new Matrix();
2190
2112
  inverseBindMatrix.copyFromArray(buffer, i1 * 16);
@@ -2245,24 +2167,24 @@ var SkinParser = /*#__PURE__*/ function(Parser) {
2245
2167
  rootNode = entity1;
2246
2168
  }
2247
2169
  };
2248
- return SkinParser;
2249
- }(Parser);
2170
+ return GLTFSkinParser;
2171
+ }(GLTFParser);
2250
2172
 
2251
- var TextureParser = /*#__PURE__*/ function(Parser) {
2252
- _inherits(TextureParser, Parser);
2253
- function TextureParser() {
2254
- return Parser.apply(this, arguments);
2173
+ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
2174
+ _inherits(GLTFTextureParser, GLTFParser);
2175
+ function GLTFTextureParser() {
2176
+ return GLTFParser.apply(this, arguments);
2255
2177
  }
2256
- var _proto = TextureParser.prototype;
2178
+ var _proto = GLTFTextureParser.prototype;
2257
2179
  _proto.parse = function parse(context) {
2258
2180
  var _this = this;
2259
- var glTFResource = context.glTFResource, gltf = context.gltf, buffers = context.buffers;
2181
+ var glTFResource = context.glTFResource, glTF = context.glTF, buffers = context.buffers;
2260
2182
  var engine = glTFResource.engine, url = glTFResource.url;
2261
- if (gltf.textures) {
2183
+ if (glTF.textures) {
2262
2184
  var texturesPromiseInfo = context.texturesPromiseInfo;
2263
- AssetPromise.all(gltf.textures.map(function(param, index) {
2185
+ AssetPromise.all(glTF.textures.map(function(param, index) {
2264
2186
  var sampler = param.sampler, _param_source = param.source, source = _param_source === void 0 ? 0 : _param_source, textureName = param.name;
2265
- var _gltf_images_source = gltf.images[source], uri = _gltf_images_source.uri, bufferViewIndex = _gltf_images_source.bufferView, mimeType = _gltf_images_source.mimeType, imageName = _gltf_images_source.name;
2187
+ var _glTF_images_source = glTF.images[source], uri = _glTF_images_source.uri, bufferViewIndex = _glTF_images_source.bufferView, mimeType = _glTF_images_source.mimeType, imageName = _glTF_images_source.name;
2266
2188
  if (uri) {
2267
2189
  // TODO: support ktx extension https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md
2268
2190
  var index1 = uri.lastIndexOf(".");
@@ -2276,21 +2198,24 @@ var TextureParser = /*#__PURE__*/ function(Parser) {
2276
2198
  texture.name = textureName || imageName || "texture_" + index1;
2277
2199
  }
2278
2200
  if (sampler !== undefined) {
2279
- _this._parseSampler(texture, gltf.samplers[sampler]);
2201
+ _this._parseSampler(texture, glTF.samplers[sampler]);
2280
2202
  }
2281
2203
  return texture;
2282
2204
  });
2283
2205
  } else {
2284
- var bufferView = gltf.bufferViews[bufferViewIndex];
2285
- var bufferViewData = GLTFUtil.getBufferViewData(bufferView, buffers);
2286
- return GLTFUtil.loadImageBuffer(bufferViewData, mimeType).then(function(image) {
2206
+ var bufferView = glTF.bufferViews[bufferViewIndex];
2207
+ var buffer = buffers[bufferView.buffer];
2208
+ var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
2209
+ return GLTFUtil.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
2287
2210
  var texture = new Texture2D(engine, image.width, image.height);
2288
2211
  texture.setImageSource(image);
2289
2212
  texture.generateMipmaps();
2290
2213
  texture.name = textureName || imageName || "texture_" + index;
2291
2214
  if (sampler !== undefined) {
2292
- _this._parseSampler(texture, gltf.samplers[sampler]);
2215
+ _this._parseSampler(texture, glTF.samplers[sampler]);
2293
2216
  }
2217
+ var bufferTextureRestoreInfo = new BufferTextureRestoreInfo(texture, bufferView, mimeType);
2218
+ context.contentRestorer.bufferTextures.push(bufferTextureRestoreInfo);
2294
2219
  return texture;
2295
2220
  });
2296
2221
  }
@@ -2313,34 +2238,36 @@ var TextureParser = /*#__PURE__*/ function(Parser) {
2313
2238
  }
2314
2239
  }
2315
2240
  if (wrapS) {
2316
- texture.wrapModeU = TextureParser._wrapMap[wrapS];
2241
+ texture.wrapModeU = GLTFTextureParser._wrapMap[wrapS];
2317
2242
  }
2318
2243
  if (wrapT) {
2319
- texture.wrapModeV = TextureParser._wrapMap[wrapT];
2244
+ texture.wrapModeV = GLTFTextureParser._wrapMap[wrapT];
2320
2245
  }
2321
2246
  };
2322
- return TextureParser;
2323
- }(Parser);
2247
+ return GLTFTextureParser;
2248
+ }(GLTFParser);
2324
2249
  var _obj;
2325
- TextureParser._wrapMap = (_obj = {}, _obj[TextureWrapMode.CLAMP_TO_EDGE] = TextureWrapMode$1.Clamp, _obj[TextureWrapMode.MIRRORED_REPEAT] = TextureWrapMode$1.Mirror, _obj[TextureWrapMode.REPEAT] = TextureWrapMode$1.Repeat, _obj);
2250
+ GLTFTextureParser._wrapMap = (_obj = {}, _obj[TextureWrapMode.CLAMP_TO_EDGE] = TextureWrapMode$1.Clamp, _obj[TextureWrapMode.MIRRORED_REPEAT] = TextureWrapMode$1.Mirror, _obj[TextureWrapMode.REPEAT] = TextureWrapMode$1.Repeat, _obj);
2326
2251
 
2327
- var Validator = /*#__PURE__*/ function(Parser1) {
2328
- _inherits(Validator, Parser1);
2329
- function Validator() {
2330
- return Parser1.apply(this, arguments);
2252
+ var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
2253
+ _inherits(GLTFValidator, GLTFParser1);
2254
+ function GLTFValidator() {
2255
+ return GLTFParser1.apply(this, arguments);
2331
2256
  }
2332
- var _proto = Validator.prototype;
2257
+ var _proto = GLTFValidator.prototype;
2333
2258
  _proto.parse = function parse(context) {
2334
- var _context_gltf = context.gltf, version = _context_gltf.asset.version, extensionsUsed = _context_gltf.extensionsUsed, extensionsRequired = _context_gltf.extensionsRequired;
2335
- var gltfVersion = Number(version);
2336
- if (!(gltfVersion >= 2 && gltfVersion < 3)) {
2337
- throw "Only support gltf 2.x.";
2259
+ var _context_glTF = context.glTF, version = _context_glTF.asset.version, extensionsUsed = _context_glTF.extensionsUsed, extensionsRequired = _context_glTF.extensionsRequired;
2260
+ var glTFVersion = Number(version);
2261
+ if (!(glTFVersion >= 2 && glTFVersion < 3)) {
2262
+ throw "Only support glTF 2.x.";
2338
2263
  }
2264
+ var promises = [];
2339
2265
  if (extensionsUsed) {
2340
2266
  Logger.info("extensionsUsed: ", extensionsUsed);
2341
2267
  for(var i = 0; i < extensionsUsed.length; i++){
2342
- if (!Parser.hasExtensionParser(extensionsUsed[i])) {
2343
- Logger.warn("Extension " + extensionsUsed[i] + " is not implemented, you can customize this extension in gltf.");
2268
+ var extensionUsed = extensionsUsed[i];
2269
+ if (!GLTFParser.hasExtensionParser(extensionUsed)) {
2270
+ Logger.warn("Extension " + extensionUsed + " is not implemented, you can customize this extension in gltf.");
2344
2271
  }
2345
2272
  }
2346
2273
  }
@@ -2348,66 +2275,66 @@ var Validator = /*#__PURE__*/ function(Parser1) {
2348
2275
  Logger.info("extensionsRequired: " + extensionsRequired);
2349
2276
  for(var i1 = 0; i1 < extensionsRequired.length; i1++){
2350
2277
  var extensionRequired = extensionsRequired[i1];
2351
- if (!Parser.hasExtensionParser(extensionRequired)) {
2278
+ if (!GLTFParser.hasExtensionParser(extensionRequired)) {
2352
2279
  Logger.error("GLTF parser has not supported required extension " + extensionRequired + ".");
2353
2280
  } else {
2354
- Parser.initialize(extensionRequired);
2281
+ promises.push(GLTFParser.executeExtensionsInitialize(extensionRequired));
2355
2282
  }
2356
2283
  }
2357
2284
  }
2285
+ return AssetPromise.all(promises).then(null);
2358
2286
  };
2359
- return Validator;
2360
- }(Parser);
2287
+ return GLTFValidator;
2288
+ }(GLTFParser);
2361
2289
 
2362
- var GLTFParser = /*#__PURE__*/ function() {
2363
- function GLTFParser(pipes) {
2290
+ /**
2291
+ * GLTF pipeline.
2292
+ */ var GLTFPipeline = /*#__PURE__*/ function() {
2293
+ function GLTFPipeline() {
2294
+ for(var _len = arguments.length, parsers = new Array(_len), _key = 0; _key < _len; _key++){
2295
+ parsers[_key] = arguments[_key];
2296
+ }
2364
2297
  var _this = this;
2365
- this._pipes = [];
2366
- pipes.forEach(function(pipe, index) {
2367
- _this._pipes[index] = new pipe();
2298
+ this._parsers = [];
2299
+ parsers.forEach(function(pipe, index) {
2300
+ _this._parsers[index] = new pipe();
2368
2301
  });
2369
2302
  }
2370
- var _proto = GLTFParser.prototype;
2371
- _proto.parse = function parse(context) {
2303
+ var _proto = GLTFPipeline.prototype;
2304
+ /**
2305
+ * @internal
2306
+ */ _proto._parse = function _parse(context) {
2372
2307
  var _this = this;
2373
2308
  var glTFResource = context.glTFResource;
2374
- var lastPipe;
2309
+ var lastParser;
2375
2310
  return new AssetPromise(function(resolve, reject) {
2376
- _this._pipes.forEach(function(parser) {
2377
- if (lastPipe) {
2378
- lastPipe = lastPipe.then(function() {
2311
+ _this._parsers.forEach(function(parser) {
2312
+ if (lastParser) {
2313
+ lastParser = lastParser.then(function() {
2379
2314
  return parser.parse(context);
2380
2315
  });
2381
- if (lastPipe.cancel) {
2382
- context.chainPromises.push(lastPipe);
2316
+ if (lastParser.cancel) {
2317
+ context.chainPromises.push(lastParser);
2383
2318
  }
2384
2319
  } else {
2385
- lastPipe = parser.parse(context);
2320
+ lastParser = parser.parse(context);
2386
2321
  }
2387
2322
  });
2388
- if (lastPipe) {
2389
- lastPipe.then(function() {
2323
+ if (lastParser) {
2324
+ lastParser.then(function() {
2390
2325
  resolve(glTFResource);
2391
2326
  }).catch(reject);
2392
2327
  }
2393
2328
  });
2394
2329
  };
2395
- return GLTFParser;
2330
+ return GLTFPipeline;
2396
2331
  }();
2397
- GLTFParser.defaultPipeline = new GLTFParser([
2398
- BufferParser,
2399
- Validator,
2400
- TextureParser,
2401
- MaterialParser,
2402
- MeshParser,
2403
- EntityParser,
2404
- SkinParser,
2405
- AnimationParser,
2406
- SceneParser$1
2407
- ]);
2332
+ /**
2333
+ * Default pipeline.
2334
+ */ GLTFPipeline.defaultPipeline = new GLTFPipeline(GLTFBufferParser, GLTFValidator, GLTFTextureParser, GLTFMaterialParser, GLTFMeshParser, GLTFEntityParser, GLTFSkinParser, GLTFAnimationParser, GLTFSceneParser);
2408
2335
 
2409
2336
  /**
2410
- * Product after GLTF parser, usually, `defaultSceneRoot` is only needed to use.
2337
+ * Product after glTF parser, usually, `defaultSceneRoot` is only needed to use.
2411
2338
  */ var GLTFResource = /*#__PURE__*/ function(EngineObject) {
2412
2339
  _inherits(GLTFResource, EngineObject);
2413
2340
  function GLTFResource(engine, url) {
@@ -2419,11 +2346,8 @@ GLTFParser.defaultPipeline = new GLTFParser([
2419
2346
  var _proto = GLTFResource.prototype;
2420
2347
  /**
2421
2348
  * @override
2422
- */ _proto.destroy = function destroy() {
2423
- if (this._destroyed) {
2424
- return;
2425
- }
2426
- EngineObject.prototype.destroy.call(this);
2349
+ */ _proto._onDestroy = function _onDestroy() {
2350
+ EngineObject.prototype._onDestroy.call(this);
2427
2351
  this.defaultSceneRoot.destroy();
2428
2352
  this.textures = null;
2429
2353
  this.materials = null;
@@ -2434,7 +2358,7 @@ GLTFParser.defaultPipeline = new GLTFParser([
2434
2358
  this.cameras = null;
2435
2359
  this.lights = null;
2436
2360
  this.sceneRoots = null;
2437
- this.variants = null;
2361
+ this.extensionsData = null;
2438
2362
  };
2439
2363
  return GLTFResource;
2440
2364
  }(EngineObject);
@@ -2445,15 +2369,19 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
2445
2369
  return Loader.apply(this, arguments);
2446
2370
  }
2447
2371
  var _proto = GLTFLoader.prototype;
2448
- _proto.load = function load(item, resourceManager) {
2449
- var _item_params;
2372
+ /**
2373
+ * @override
2374
+ */ _proto.load = function load(item, resourceManager) {
2450
2375
  var url = item.url;
2451
- var context = new ParserContext(url);
2376
+ var params = item.params;
2377
+ var context = new GLTFParserContext(url);
2452
2378
  var glTFResource = new GLTFResource(resourceManager.engine, url);
2379
+ var restorer = new GLTFContentRestorer(glTFResource);
2453
2380
  var masterPromiseInfo = context.masterPromiseInfo;
2381
+ context.contentRestorer = restorer;
2454
2382
  context.glTFResource = glTFResource;
2455
- var _item_params_keepMeshData;
2456
- context.keepMeshData = (_item_params_keepMeshData = (_item_params = item.params) == null ? void 0 : _item_params.keepMeshData) != null ? _item_params_keepMeshData : false;
2383
+ var _params_keepMeshData;
2384
+ context.keepMeshData = (_params_keepMeshData = params == null ? void 0 : params.keepMeshData) != null ? _params_keepMeshData : false;
2457
2385
  masterPromiseInfo.onCancel(function() {
2458
2386
  var chainPromises = context.chainPromises;
2459
2387
  for(var _iterator = _createForOfIteratorHelperLoose(chainPromises), _step; !(_step = _iterator()).done;){
@@ -2461,7 +2389,10 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
2461
2389
  promise.cancel();
2462
2390
  }
2463
2391
  });
2464
- GLTFParser.defaultPipeline.parse(context).then(masterPromiseInfo.resolve).catch(function(e) {
2392
+ ((params == null ? void 0 : params.pipeline) || GLTFPipeline.defaultPipeline)._parse(context).then(function(glTFResource) {
2393
+ resourceManager.addContentRestorer(restorer);
2394
+ masterPromiseInfo.resolve(glTFResource);
2395
+ }).catch(function(e) {
2465
2396
  console.error(e);
2466
2397
  masterPromiseInfo.reject("Error loading glTF model from " + url + " .");
2467
2398
  });
@@ -2470,7 +2401,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
2470
2401
  return GLTFLoader;
2471
2402
  }(Loader);
2472
2403
  GLTFLoader = __decorate([
2473
- resourceLoader(AssetType.Prefab, [
2404
+ resourceLoader(AssetType.GLTF, [
2474
2405
  "gltf",
2475
2406
  "glb"
2476
2407
  ])
@@ -4218,28 +4149,57 @@ SpriteLoader = __decorate([
4218
4149
  ], false)
4219
4150
  ], SpriteLoader);
4220
4151
 
4152
+ /**
4153
+ * @internal
4154
+ */ var Texture2DContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
4155
+ _inherits(Texture2DContentRestorer, ContentRestorer);
4156
+ function Texture2DContentRestorer(resource, url, requestConfig) {
4157
+ var _this;
4158
+ _this = ContentRestorer.call(this, resource) || this;
4159
+ _this.url = url;
4160
+ _this.requestConfig = requestConfig;
4161
+ return _this;
4162
+ }
4163
+ var _proto = Texture2DContentRestorer.prototype;
4164
+ /**
4165
+ * @override
4166
+ */ _proto.restoreContent = function restoreContent() {
4167
+ var _this = this;
4168
+ return request(this.url, this.requestConfig).then(function(image) {
4169
+ var resource = _this.resource;
4170
+ resource.setImageSource(image);
4171
+ resource.generateMipmaps();
4172
+ return resource;
4173
+ });
4174
+ };
4175
+ return Texture2DContentRestorer;
4176
+ }(ContentRestorer);
4177
+
4221
4178
  var Texture2DLoader = /*#__PURE__*/ function(Loader) {
4222
4179
  _inherits(Texture2DLoader, Loader);
4223
4180
  function Texture2DLoader() {
4224
4181
  return Loader.apply(this, arguments);
4225
4182
  }
4226
4183
  var _proto = Texture2DLoader.prototype;
4227
- _proto.load = function load(item, resourceManager) {
4184
+ /**
4185
+ * @override
4186
+ */ _proto.load = function load(item, resourceManager) {
4228
4187
  var _this = this;
4229
4188
  return new AssetPromise(function(resolve, reject) {
4230
- _this.request(item.url, _extends({}, item, {
4189
+ var url = item.url;
4190
+ var requestConfig = _extends({}, item, {
4231
4191
  type: "image"
4232
- })).then(function(image) {
4233
- var _item_params;
4234
- var params = (_item_params = item.params) != null ? _item_params : {};
4235
- var texture = new Texture2D(resourceManager.engine, image.width, image.height, params.format, params.mipmap);
4236
- /** @ts-ignore */ if (!texture._platformTexture) return;
4192
+ });
4193
+ _this.request(url, requestConfig).then(function(image) {
4194
+ var params = item.params;
4195
+ var texture = new Texture2D(resourceManager.engine, image.width, image.height, params == null ? void 0 : params.format, params == null ? void 0 : params.mipmap);
4237
4196
  texture.setImageSource(image);
4238
4197
  texture.generateMipmaps();
4239
- if (item.url.indexOf("data:") !== 0) {
4240
- var splitPath = item.url.split("/");
4241
- texture.name = splitPath[splitPath.length - 1];
4198
+ if (url.indexOf("data:") !== 0) {
4199
+ var index = url.lastIndexOf("/");
4200
+ texture.name = url.substring(index + 1);
4242
4201
  }
4202
+ resourceManager.addContentRestorer(new Texture2DContentRestorer(texture, url, requestConfig));
4243
4203
  resolve(texture);
4244
4204
  }).catch(function(e) {
4245
4205
  reject(e);
@@ -4257,33 +4217,71 @@ Texture2DLoader = __decorate([
4257
4217
  ])
4258
4218
  ], Texture2DLoader);
4259
4219
 
4220
+ /**
4221
+ * @internal
4222
+ */ var TextureCubeContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
4223
+ _inherits(TextureCubeContentRestorer, ContentRestorer);
4224
+ function TextureCubeContentRestorer(resource, urls, requestConfig) {
4225
+ var _this;
4226
+ _this = ContentRestorer.call(this, resource) || this;
4227
+ _this.urls = urls;
4228
+ _this.requestConfig = requestConfig;
4229
+ return _this;
4230
+ }
4231
+ var _proto = TextureCubeContentRestorer.prototype;
4232
+ /**
4233
+ * @override
4234
+ */ _proto.restoreContent = function restoreContent() {
4235
+ var _this = this;
4236
+ return new AssetPromise(function(resolve, reject) {
4237
+ Promise.all(_this.urls.map(function(url) {
4238
+ return request(url, _this.requestConfig);
4239
+ })).then(function(images) {
4240
+ var resource = _this.resource;
4241
+ for(var faceIndex = 0; faceIndex < 6; faceIndex++){
4242
+ resource.setImageSource(TextureCubeFace.PositiveX + faceIndex, images[faceIndex], 0);
4243
+ }
4244
+ resource.generateMipmaps();
4245
+ resolve(resource);
4246
+ }).catch(function(e) {
4247
+ reject(e);
4248
+ });
4249
+ });
4250
+ };
4251
+ return TextureCubeContentRestorer;
4252
+ }(ContentRestorer);
4253
+
4260
4254
  var TextureCubeLoader = /*#__PURE__*/ function(Loader) {
4261
4255
  _inherits(TextureCubeLoader, Loader);
4262
4256
  function TextureCubeLoader() {
4263
4257
  return Loader.apply(this, arguments);
4264
4258
  }
4265
4259
  var _proto = TextureCubeLoader.prototype;
4266
- _proto.load = function load(item, resourceManager) {
4260
+ /**
4261
+ * @override
4262
+ */ _proto.load = function load(item, resourceManager) {
4267
4263
  var _this = this;
4268
4264
  return new AssetPromise(function(resolve, reject) {
4269
- Promise.all(item.urls.map(function(url) {
4270
- return _this.request(url, _extends({}, item, {
4271
- type: "image"
4272
- }));
4265
+ var urls = item.urls;
4266
+ var requestConfig = _extends({}, item, {
4267
+ type: "image"
4268
+ });
4269
+ Promise.all(urls.map(function(url) {
4270
+ return _this.request(url, requestConfig);
4273
4271
  })).then(function(images) {
4274
4272
  var _images_ = images[0], width = _images_.width, height = _images_.height;
4275
4273
  if (width !== height) {
4276
4274
  console.error("The cube texture must have the same width and height");
4277
4275
  return;
4278
4276
  }
4279
- var tex = new TextureCube(resourceManager.engine, width);
4280
- /** @ts-ignore */ if (!tex._platformTexture) return;
4277
+ var texture = new TextureCube(resourceManager.engine, width);
4281
4278
  for(var faceIndex = 0; faceIndex < 6; faceIndex++){
4282
- tex.setImageSource(TextureCubeFace.PositiveX + faceIndex, images[faceIndex], 0);
4279
+ texture.setImageSource(TextureCubeFace.PositiveX + faceIndex, images[faceIndex], 0);
4283
4280
  }
4284
- tex.generateMipmaps();
4285
- resolve(tex);
4286
- }).catch(function(e) {
4281
+ texture.generateMipmaps();
4282
+ resourceManager.addContentRestorer(new TextureCubeContentRestorer(texture, urls, requestConfig));
4283
+ resolve(texture);
4284
+ }).catch(function(e) {
4287
4285
  reject(e);
4288
4286
  });
4289
4287
  });
@@ -4296,6 +4294,30 @@ TextureCubeLoader = __decorate([
4296
4294
  ])
4297
4295
  ], TextureCubeLoader);
4298
4296
 
4297
+ var AnimationClipLoader = /*#__PURE__*/ function(Loader) {
4298
+ _inherits(AnimationClipLoader, Loader);
4299
+ function AnimationClipLoader() {
4300
+ return Loader.apply(this, arguments);
4301
+ }
4302
+ var _proto = AnimationClipLoader.prototype;
4303
+ _proto.load = function load(item, resourceManager) {
4304
+ var _this = this;
4305
+ return new AssetPromise(function(resolve, reject) {
4306
+ _this.request(item.url, _extends({}, item, {
4307
+ type: "arraybuffer"
4308
+ })).then(function(data) {
4309
+ return decode(data, resourceManager.engine);
4310
+ }).catch(reject);
4311
+ });
4312
+ };
4313
+ return AnimationClipLoader;
4314
+ }(Loader);
4315
+ AnimationClipLoader = __decorate([
4316
+ resourceLoader(AssetType.AnimationClip, [
4317
+ "ani"
4318
+ ])
4319
+ ], AnimationClipLoader);
4320
+
4299
4321
  var SceneLoader = /*#__PURE__*/ function(Loader) {
4300
4322
  _inherits(SceneLoader, Loader);
4301
4323
  function SceneLoader() {
@@ -4396,5 +4418,388 @@ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asy
4396
4418
  });
4397
4419
  }));
4398
4420
 
4399
- export { AnimationClipDecoder, ComponentMap, EditorTextureLoader, GLTFResource, InterpolableValueType, MeshDecoder, MeshLoader$1 as MeshLoader, PrefabParser, ReflectionParser, SceneParser, Texture2DDecoder, decode, parseSingleKTX };
4421
+ var _KHR_draco_mesh_compression;
4422
+ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ function(GLTFExtensionParser) {
4423
+ _inherits(KHR_draco_mesh_compression1, GLTFExtensionParser);
4424
+ function KHR_draco_mesh_compression1() {
4425
+ return GLTFExtensionParser.apply(this, arguments);
4426
+ }
4427
+ var _proto = KHR_draco_mesh_compression1.prototype;
4428
+ /**
4429
+ * @override
4430
+ */ _proto.initialize = function initialize() {
4431
+ if (!KHR_draco_mesh_compression._decoder) {
4432
+ KHR_draco_mesh_compression._decoder = new DRACODecoder();
4433
+ }
4434
+ };
4435
+ /**
4436
+ * @override
4437
+ */ _proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
4438
+ var _this = this;
4439
+ var glTF = context.glTF, buffers = context.buffers, engine = context.glTFResource.engine;
4440
+ var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
4441
+ var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
4442
+ var attributeMap = {};
4443
+ var attributeTypeMap = {};
4444
+ for(var attributeName in gltfAttributeMap){
4445
+ attributeMap[attributeName] = gltfAttributeMap[attributeName];
4446
+ }
4447
+ for(var attributeName1 in glTFPrimitive.attributes){
4448
+ if (gltfAttributeMap[attributeName1] !== undefined) {
4449
+ var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
4450
+ attributeTypeMap[attributeName1] = GLTFUtil.getComponentType(accessorDef.componentType).name;
4451
+ }
4452
+ }
4453
+ var indexAccessor = accessors[glTFPrimitive.indices];
4454
+ var indexType = GLTFUtil.getComponentType(indexAccessor.componentType).name;
4455
+ var taskConfig = {
4456
+ attributeIDs: attributeMap,
4457
+ attributeTypes: attributeTypeMap,
4458
+ useUniqueIDs: true,
4459
+ indexType: indexType
4460
+ };
4461
+ var buffer = GLTFUtil.getBufferViewData(bufferViews[bufferViewIndex], buffers);
4462
+ return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
4463
+ var mesh = new ModelMesh(engine, glTFMesh.name);
4464
+ return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
4465
+ for(var j = 0; j < decodedGeometry.attributes.length; j++){
4466
+ if (decodedGeometry.attributes[j].name === attributeSemantic) {
4467
+ return decodedGeometry.attributes[j].array;
4468
+ }
4469
+ }
4470
+ return null;
4471
+ }, function(attributeSemantic, shapeIndex) {
4472
+ throw "BlendShape animation is not supported when using draco.";
4473
+ }, function() {
4474
+ return decodedGeometry.index.array;
4475
+ }, context.keepMeshData);
4476
+ });
4477
+ };
4478
+ _proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
4479
+ var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
4480
+ var vertexCount;
4481
+ var accessors = gltf.accessors;
4482
+ var accessor = accessors[attributes["POSITION"]];
4483
+ var positionBuffer = getVertexBufferData("POSITION");
4484
+ var positions = GLTFUtil.floatBufferToVector3Array(positionBuffer);
4485
+ mesh.setPositions(positions);
4486
+ var bounds = mesh.bounds;
4487
+ vertexCount = accessor.count;
4488
+ if (accessor.min && accessor.max) {
4489
+ bounds.min.copyFromArray(accessor.min);
4490
+ bounds.max.copyFromArray(accessor.max);
4491
+ } else {
4492
+ var position = KHR_draco_mesh_compression._tempVector3;
4493
+ var min = bounds.min, max = bounds.max;
4494
+ min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
4495
+ max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
4496
+ var stride = positionBuffer.length / vertexCount;
4497
+ for(var j = 0; j < vertexCount; j++){
4498
+ var offset = j * stride;
4499
+ position.copyFromArray(positionBuffer, offset);
4500
+ Vector3.min(min, position, min);
4501
+ Vector3.max(max, position, max);
4502
+ }
4503
+ }
4504
+ for(var attributeSemantic in attributes){
4505
+ if (attributeSemantic === "POSITION") {
4506
+ continue;
4507
+ }
4508
+ var bufferData = getVertexBufferData(attributeSemantic);
4509
+ switch(attributeSemantic){
4510
+ case "NORMAL":
4511
+ var normals = GLTFUtil.floatBufferToVector3Array(bufferData);
4512
+ mesh.setNormals(normals);
4513
+ break;
4514
+ case "TEXCOORD_0":
4515
+ var texturecoords = GLTFUtil.floatBufferToVector2Array(bufferData);
4516
+ mesh.setUVs(texturecoords, 0);
4517
+ break;
4518
+ case "TEXCOORD_1":
4519
+ var texturecoords1 = GLTFUtil.floatBufferToVector2Array(bufferData);
4520
+ mesh.setUVs(texturecoords1, 1);
4521
+ break;
4522
+ case "TEXCOORD_2":
4523
+ var texturecoords2 = GLTFUtil.floatBufferToVector2Array(bufferData);
4524
+ mesh.setUVs(texturecoords2, 2);
4525
+ break;
4526
+ case "TEXCOORD_3":
4527
+ var texturecoords3 = GLTFUtil.floatBufferToVector2Array(bufferData);
4528
+ mesh.setUVs(texturecoords3, 3);
4529
+ break;
4530
+ case "TEXCOORD_4":
4531
+ var texturecoords4 = GLTFUtil.floatBufferToVector2Array(bufferData);
4532
+ mesh.setUVs(texturecoords4, 4);
4533
+ break;
4534
+ case "TEXCOORD_5":
4535
+ var texturecoords5 = GLTFUtil.floatBufferToVector2Array(bufferData);
4536
+ mesh.setUVs(texturecoords5, 5);
4537
+ break;
4538
+ case "TEXCOORD_6":
4539
+ var texturecoords6 = GLTFUtil.floatBufferToVector2Array(bufferData);
4540
+ mesh.setUVs(texturecoords6, 6);
4541
+ break;
4542
+ case "TEXCOORD_7":
4543
+ var texturecoords7 = GLTFUtil.floatBufferToVector2Array(bufferData);
4544
+ mesh.setUVs(texturecoords7, 7);
4545
+ break;
4546
+ case "COLOR_0":
4547
+ var colors = GLTFUtil.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
4548
+ mesh.setColors(colors);
4549
+ break;
4550
+ case "TANGENT":
4551
+ var tangents = GLTFUtil.floatBufferToVector4Array(bufferData);
4552
+ mesh.setTangents(tangents);
4553
+ break;
4554
+ case "JOINTS_0":
4555
+ var joints = GLTFUtil.floatBufferToVector4Array(bufferData);
4556
+ mesh.setBoneIndices(joints);
4557
+ break;
4558
+ case "WEIGHTS_0":
4559
+ var weights = GLTFUtil.floatBufferToVector4Array(bufferData);
4560
+ mesh.setBoneWeights(weights);
4561
+ break;
4562
+ }
4563
+ }
4564
+ // Indices
4565
+ if (indices !== undefined) {
4566
+ var indexAccessor = gltf.accessors[indices];
4567
+ var indexData = getIndexBufferData();
4568
+ mesh.setIndices(indexData);
4569
+ mesh.addSubMesh(0, indexAccessor.count, mode);
4570
+ } else {
4571
+ mesh.addSubMesh(0, vertexCount, mode);
4572
+ }
4573
+ // BlendShapes
4574
+ targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, targets, getBlendShapeData);
4575
+ mesh.uploadData(!keepMeshData);
4576
+ return Promise.resolve(mesh);
4577
+ };
4578
+ return KHR_draco_mesh_compression1;
4579
+ }(GLTFExtensionParser), _KHR_draco_mesh_compression._tempVector3 = new Vector3(), _KHR_draco_mesh_compression);
4580
+ KHR_draco_mesh_compression = __decorate([
4581
+ registerGLTFExtension("KHR_draco_mesh_compression", GLTFExtensionMode.CreateAndParse)
4582
+ ], KHR_draco_mesh_compression);
4583
+
4584
+ var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
4585
+ _inherits(KHR_lights_punctual, GLTFExtensionParser);
4586
+ function KHR_lights_punctual() {
4587
+ return GLTFExtensionParser.apply(this, arguments);
4588
+ }
4589
+ var _proto = KHR_lights_punctual.prototype;
4590
+ /**
4591
+ * @override
4592
+ */ _proto.additiveParse = function additiveParse(context, entity, extensionSchema) {
4593
+ var lightsSchema = context.glTF.extensions.KHR_lights_punctual.lights;
4594
+ var lightSchema = lightsSchema[extensionSchema.light];
4595
+ var color = lightSchema.color, _lightSchema_intensity = lightSchema.intensity, intensity = _lightSchema_intensity === void 0 ? 1 : _lightSchema_intensity, type = lightSchema.type, range = lightSchema.range, spot = lightSchema.spot;
4596
+ var glTFResource = context.glTFResource;
4597
+ var light;
4598
+ if (type === "directional") {
4599
+ light = entity.addComponent(DirectLight);
4600
+ } else if (type === "point") {
4601
+ light = entity.addComponent(PointLight);
4602
+ } else if (type === "spot") {
4603
+ light = entity.addComponent(SpotLight);
4604
+ }
4605
+ if (color) {
4606
+ light.color.set(color[0], color[1], color[2], 1);
4607
+ }
4608
+ light.intensity = intensity;
4609
+ if (range && !_instanceof(light, DirectLight)) {
4610
+ light.distance = range;
4611
+ }
4612
+ if (spot && _instanceof(light, SpotLight)) {
4613
+ var _spot_innerConeAngle = spot.innerConeAngle, innerConeAngle = _spot_innerConeAngle === void 0 ? 0 : _spot_innerConeAngle, _spot_outerConeAngle = spot.outerConeAngle, outerConeAngle = _spot_outerConeAngle === void 0 ? Math.PI / 4 : _spot_outerConeAngle;
4614
+ light.angle = innerConeAngle;
4615
+ light.penumbra = outerConeAngle - innerConeAngle;
4616
+ }
4617
+ if (!glTFResource.lights) glTFResource.lights = [];
4618
+ glTFResource.lights.push(light);
4619
+ };
4620
+ return KHR_lights_punctual;
4621
+ }(GLTFExtensionParser);
4622
+ KHR_lights_punctual = __decorate([
4623
+ registerGLTFExtension("KHR_lights_punctual", GLTFExtensionMode.AdditiveParse)
4624
+ ], KHR_lights_punctual);
4625
+
4626
+ var KHR_materials_clearcoat = /*#__PURE__*/ function(GLTFExtensionParser) {
4627
+ _inherits(KHR_materials_clearcoat, GLTFExtensionParser);
4628
+ function KHR_materials_clearcoat() {
4629
+ return GLTFExtensionParser.apply(this, arguments);
4630
+ }
4631
+ var _proto = KHR_materials_clearcoat.prototype;
4632
+ /**
4633
+ * @override
4634
+ */ _proto.additiveParse = function additiveParse(context, material, schema) {
4635
+ var textures = context.glTFResource.textures;
4636
+ var _schema_clearcoatFactor = schema.clearcoatFactor, clearcoatFactor = _schema_clearcoatFactor === void 0 ? 0 : _schema_clearcoatFactor, clearcoatTexture = schema.clearcoatTexture, _schema_clearcoatRoughnessFactor = schema.clearcoatRoughnessFactor, clearcoatRoughnessFactor = _schema_clearcoatRoughnessFactor === void 0 ? 0 : _schema_clearcoatRoughnessFactor, clearcoatRoughnessTexture = schema.clearcoatRoughnessTexture, clearcoatNormalTexture = schema.clearcoatNormalTexture;
4637
+ material.clearCoat = clearcoatFactor;
4638
+ material.clearCoatRoughness = clearcoatRoughnessFactor;
4639
+ if (clearcoatTexture) {
4640
+ material.clearCoatTexture = textures[clearcoatTexture.index];
4641
+ GLTFMaterialParser._checkOtherTextureTransform(clearcoatTexture, "Clear coat");
4642
+ }
4643
+ if (clearcoatRoughnessTexture) {
4644
+ material.clearCoatRoughnessTexture = textures[clearcoatRoughnessTexture.index];
4645
+ GLTFMaterialParser._checkOtherTextureTransform(clearcoatRoughnessTexture, "Clear coat roughness");
4646
+ }
4647
+ if (clearcoatNormalTexture) {
4648
+ material.clearCoatNormalTexture = textures[clearcoatNormalTexture.index];
4649
+ GLTFMaterialParser._checkOtherTextureTransform(clearcoatNormalTexture, "Clear coat normal");
4650
+ }
4651
+ };
4652
+ return KHR_materials_clearcoat;
4653
+ }(GLTFExtensionParser);
4654
+ KHR_materials_clearcoat = __decorate([
4655
+ registerGLTFExtension("KHR_materials_clearcoat", GLTFExtensionMode.AdditiveParse)
4656
+ ], KHR_materials_clearcoat);
4657
+
4658
+ var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionParser) {
4659
+ _inherits(KHR_materials_pbrSpecularGlossiness, GLTFExtensionParser);
4660
+ function KHR_materials_pbrSpecularGlossiness() {
4661
+ return GLTFExtensionParser.apply(this, arguments);
4662
+ }
4663
+ var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
4664
+ /**
4665
+ * @override
4666
+ */ _proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
4667
+ var _context_glTFResource = context.glTFResource, engine = _context_glTFResource.engine, textures = _context_glTFResource.textures;
4668
+ var material = new PBRSpecularMaterial(engine);
4669
+ var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
4670
+ if (diffuseFactor) {
4671
+ material.baseColor = new Color(Color.linearToGammaSpace(diffuseFactor[0]), Color.linearToGammaSpace(diffuseFactor[1]), Color.linearToGammaSpace(diffuseFactor[2]), diffuseFactor[3]);
4672
+ }
4673
+ if (diffuseTexture) {
4674
+ material.baseTexture = textures[diffuseTexture.index];
4675
+ GLTFParser.executeExtensionsAdditiveAndParse(diffuseTexture.extensions, context, material, diffuseTexture);
4676
+ }
4677
+ if (specularFactor) {
4678
+ material.specularColor = new Color(Color.linearToGammaSpace(specularFactor[0]), Color.linearToGammaSpace(specularFactor[1]), Color.linearToGammaSpace(specularFactor[2]));
4679
+ }
4680
+ if (glossinessFactor !== undefined) {
4681
+ material.glossiness = glossinessFactor;
4682
+ }
4683
+ if (specularGlossinessTexture) {
4684
+ material.specularGlossinessTexture = textures[specularGlossinessTexture.index];
4685
+ GLTFMaterialParser._checkOtherTextureTransform(specularGlossinessTexture, "Specular glossiness");
4686
+ }
4687
+ material.name = ownerSchema.name;
4688
+ GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
4689
+ return material;
4690
+ };
4691
+ return KHR_materials_pbrSpecularGlossiness;
4692
+ }(GLTFExtensionParser);
4693
+ KHR_materials_pbrSpecularGlossiness = __decorate([
4694
+ registerGLTFExtension("KHR_materials_pbrSpecularGlossiness", GLTFExtensionMode.CreateAndParse)
4695
+ ], KHR_materials_pbrSpecularGlossiness);
4696
+
4697
+ var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
4698
+ _inherits(KHR_materials_unlit, GLTFExtensionParser);
4699
+ function KHR_materials_unlit() {
4700
+ return GLTFExtensionParser.apply(this, arguments);
4701
+ }
4702
+ var _proto = KHR_materials_unlit.prototype;
4703
+ /**
4704
+ * @override
4705
+ */ _proto.createAndParse = function createAndParse(context, _, ownerSchema) {
4706
+ var engine = context.glTFResource.engine;
4707
+ var material = new UnlitMaterial(engine);
4708
+ material.name = ownerSchema.name;
4709
+ GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
4710
+ return material;
4711
+ };
4712
+ return KHR_materials_unlit;
4713
+ }(GLTFExtensionParser);
4714
+ KHR_materials_unlit = __decorate([
4715
+ registerGLTFExtension("KHR_materials_unlit", GLTFExtensionMode.CreateAndParse)
4716
+ ], KHR_materials_unlit);
4717
+
4718
+ var KHR_mesh_quantization = /*#__PURE__*/ function(GLTFExtensionParser) {
4719
+ _inherits(KHR_mesh_quantization, GLTFExtensionParser);
4720
+ function KHR_mesh_quantization() {
4721
+ return GLTFExtensionParser.apply(this, arguments);
4722
+ }
4723
+ return KHR_mesh_quantization;
4724
+ }(GLTFExtensionParser);
4725
+ KHR_mesh_quantization = __decorate([
4726
+ registerGLTFExtension("KHR_mesh_quantization", GLTFExtensionMode.AdditiveParse)
4727
+ ], KHR_mesh_quantization);
4728
+
4729
+ var KHR_texture_transform = /*#__PURE__*/ function(GLTFExtensionParser) {
4730
+ _inherits(KHR_texture_transform, GLTFExtensionParser);
4731
+ function KHR_texture_transform() {
4732
+ return GLTFExtensionParser.apply(this, arguments);
4733
+ }
4734
+ var _proto = KHR_texture_transform.prototype;
4735
+ /**
4736
+ * @override
4737
+ */ _proto.additiveParse = function additiveParse(context, material, schema) {
4738
+ var offset = schema.offset, rotation = schema.rotation, scale = schema.scale, texCoord = schema.texCoord;
4739
+ if (offset) {
4740
+ material.tilingOffset.z = offset[0];
4741
+ material.tilingOffset.w = offset[1];
4742
+ }
4743
+ if (scale) {
4744
+ material.tilingOffset.x = scale[0];
4745
+ material.tilingOffset.y = scale[1];
4746
+ }
4747
+ if (rotation) {
4748
+ Logger.warn("rotation in KHR_texture_transform is not supported now");
4749
+ }
4750
+ if (texCoord) {
4751
+ Logger.warn("texCoord in KHR_texture_transform is not supported now");
4752
+ }
4753
+ };
4754
+ return KHR_texture_transform;
4755
+ }(GLTFExtensionParser);
4756
+ KHR_texture_transform = __decorate([
4757
+ registerGLTFExtension("KHR_texture_transform", GLTFExtensionMode.AdditiveParse)
4758
+ ], KHR_texture_transform);
4759
+
4760
+ var GalaceanMaterialsRemap = /*#__PURE__*/ function(GLTFExtensionParser) {
4761
+ _inherits(GalaceanMaterialsRemap, GLTFExtensionParser);
4762
+ function GalaceanMaterialsRemap() {
4763
+ return GLTFExtensionParser.apply(this, arguments);
4764
+ }
4765
+ var _proto = GalaceanMaterialsRemap.prototype;
4766
+ /**
4767
+ * @override
4768
+ */ _proto.createAndParse = function createAndParse(context, schema) {
4769
+ var engine = context.glTFResource.engine;
4770
+ // @ts-ignore
4771
+ return engine.resourceManager.getResourceByRef(schema);
4772
+ };
4773
+ return GalaceanMaterialsRemap;
4774
+ }(GLTFExtensionParser);
4775
+ GalaceanMaterialsRemap = __decorate([
4776
+ registerGLTFExtension("OASIS_materials_remap", GLTFExtensionMode.CreateAndParse)
4777
+ ], GalaceanMaterialsRemap);
4778
+
4779
+ var OASIS_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
4780
+ _inherits(OASIS_animation_event, GLTFExtensionParser);
4781
+ function OASIS_animation_event() {
4782
+ return GLTFExtensionParser.apply(this, arguments);
4783
+ }
4784
+ var _proto = OASIS_animation_event.prototype;
4785
+ /**
4786
+ * @override
4787
+ */ _proto.additiveParse = function additiveParse(context, animationClip, schema) {
4788
+ context.glTFResource.engine;
4789
+ var events = schema.events;
4790
+ events.map(function(eventData) {
4791
+ var event = new AnimationEvent();
4792
+ event.functionName = eventData.functionName;
4793
+ event.time = eventData.time;
4794
+ event.parameter = eventData.parameter;
4795
+ animationClip.addEvent(event);
4796
+ });
4797
+ };
4798
+ return OASIS_animation_event;
4799
+ }(GLTFExtensionParser);
4800
+ OASIS_animation_event = __decorate([
4801
+ registerGLTFExtension("OASIS_animation_event", GLTFExtensionMode.AdditiveParse)
4802
+ ], OASIS_animation_event);
4803
+
4804
+ export { AnimationClipDecoder, ComponentMap, EditorTextureLoader, GLTFAnimationParser, GLTFBufferParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFPipeline, GLTFResource, GLTFSceneParser, GLTFSkinParser, GLTFTextureParser, GLTFUtil, GLTFValidator, InterpolableValueType, MeshDecoder, MeshLoader$1 as MeshLoader, PrefabParser, ReflectionParser, SceneParser, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension };
4400
4805
  //# sourceMappingURL=module.js.map