@galacean/engine-loader 1.2.0-alpha.1 → 1.2.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +483 -219
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +483 -219
- package/dist/module.js +484 -220
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/PrimitiveMeshLoader.d.ts +1 -0
- package/types/gltf/GLTFUtils.d.ts +4 -3
- package/types/gltf/parser/GLTFJSONParser.d.ts +7 -0
- package/types/gltf/parser/GLTFSchemaParser.d.ts +0 -1
- package/types/index.d.ts +3 -2
- package/types/resource-deserialize/index.d.ts +2 -1
- package/types/resource-deserialize/resources/animationClip/AnimationClipDecoder.d.ts +0 -1
- package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +36 -0
- package/types/resource-deserialize/resources/parser/ParserContext.d.ts +29 -0
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +4 -4
- package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +13 -4
- package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
- package/types/resource-deserialize/resources/scene/SceneParser.d.ts +3 -17
- package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +6 -12
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +24 -1
- package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +1 -0
- package/types/ktx2/BinomialLLCTranscoder/BinomialLLCTranscoder.d.ts +0 -13
- package/types/ktx2/BinomialLLCTranscoder/TranscodeWorkerCode.d.ts +0 -33
- package/types/ktx2/KhronosTranscoder/KhronosTranscoder.d.ts +0 -17
- package/types/ktx2/KhronosTranscoder/TranscoderWorkerCode.d.ts +0 -34
- package/types/ktx2/TranscodeResult.d.ts +0 -10
- package/types/ktx2/constants.d.ts +0 -7
- package/types/ktx2/zstddec.d.ts +0 -62
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils, ModelMesh, BlendShape, Texture2D, Loader, Entity,
|
|
1
|
+
import { Utils, ModelMesh, BlendShape, Texture2D, Loader, Entity, AnimationClip, AnimationEvent, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, Scene, resourceLoader, AssetPromise, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, ReferResource, Animator, IndexFormat, VertexElementFormat, GLCapabilityType, Logger, TextureFormat, request, ContentRestorer, InterpolationType, SkinnedMeshRenderer, Transform, PBRMaterial, BlinnPhongMaterial, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Camera, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, SystemInfo, Material, Shader, PrimitiveMesh, SpriteAtlas, Sprite, BackgroundMode, DirectLight, PointLight, SpotLight, UnlitMaterial } from '@galacean/engine-core';
|
|
2
2
|
import { Color, Vector4, Vector3, Vector2, Quaternion, SphericalHarmonics3, MathUtil, BoundingBox, Matrix, Rect } from '@galacean/engine-math';
|
|
3
3
|
import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
|
|
4
4
|
|
|
@@ -636,8 +636,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
636
636
|
var assetRefId = entityConfig.assetRefId;
|
|
637
637
|
var engine = this._context.engine;
|
|
638
638
|
if (assetRefId) {
|
|
639
|
-
return engine.resourceManager
|
|
640
|
-
.getResourceByRef({
|
|
639
|
+
return engine.resourceManager.getResourceByRef({
|
|
641
640
|
refId: assetRefId,
|
|
642
641
|
key: entityConfig.key,
|
|
643
642
|
isClone: entityConfig.isClone
|
|
@@ -668,37 +667,372 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
668
667
|
ReflectionParser.customParseComponentHandles = new Map();
|
|
669
668
|
})();
|
|
670
669
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
670
|
+
/**
|
|
671
|
+
* Parser context
|
|
672
|
+
* @export
|
|
673
|
+
* @abstract
|
|
674
|
+
* @class ParserContext
|
|
675
|
+
* @template T
|
|
676
|
+
* @template I
|
|
677
|
+
*/ var ParserContext = /*#__PURE__*/ function() {
|
|
678
|
+
function ParserContext(originalData, engine, target) {
|
|
679
|
+
this.originalData = originalData;
|
|
680
|
+
this.engine = engine;
|
|
681
|
+
this.target = target;
|
|
682
|
+
this.entityMap = new Map();
|
|
683
|
+
this.components = new Map();
|
|
684
|
+
this.assets = new Map();
|
|
685
|
+
this.entityConfigMap = new Map();
|
|
686
|
+
this.rootIds = [];
|
|
687
|
+
this.strippedIds = [];
|
|
688
|
+
this.resourceManager = engine.resourceManager;
|
|
689
|
+
}
|
|
690
|
+
var _proto = ParserContext.prototype;
|
|
691
|
+
/**
|
|
692
|
+
* Destroy the context.
|
|
693
|
+
* @abstract
|
|
694
|
+
* @memberof ParserContext
|
|
695
|
+
*/ _proto.destroy = function destroy() {
|
|
696
|
+
this.entityMap.clear();
|
|
697
|
+
this.components.clear();
|
|
698
|
+
this.assets.clear();
|
|
699
|
+
this.entityConfigMap.clear();
|
|
700
|
+
this.rootIds.length = 0;
|
|
701
|
+
};
|
|
702
|
+
return ParserContext;
|
|
703
|
+
}();
|
|
704
|
+
|
|
705
|
+
var PrefabParserContext = /*#__PURE__*/ function(ParserContext1) {
|
|
706
|
+
_inherits(PrefabParserContext, ParserContext1);
|
|
707
|
+
function PrefabParserContext() {
|
|
708
|
+
return ParserContext1.apply(this, arguments);
|
|
709
|
+
}
|
|
710
|
+
return PrefabParserContext;
|
|
711
|
+
}(ParserContext);
|
|
712
|
+
|
|
713
|
+
function _array_like_to_array(arr, len) {
|
|
714
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
715
|
+
|
|
716
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
717
|
+
|
|
718
|
+
return arr2;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
722
|
+
if (!o) return;
|
|
723
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
724
|
+
|
|
725
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
726
|
+
|
|
727
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
728
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
729
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
733
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
734
|
+
|
|
735
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
736
|
+
// Fallback for engines without symbol support
|
|
737
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
738
|
+
if (it) o = it;
|
|
739
|
+
|
|
740
|
+
var i = 0;
|
|
741
|
+
|
|
742
|
+
return function() {
|
|
743
|
+
if (i >= o.length) return { done: true };
|
|
744
|
+
|
|
745
|
+
return { done: false, value: o[i++] };
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
var HierarchyParser = /*#__PURE__*/ function() {
|
|
753
|
+
function HierarchyParser(context) {
|
|
754
|
+
var _this = this;
|
|
755
|
+
this.context = context;
|
|
756
|
+
this.prefabContextMap = new WeakMap();
|
|
757
|
+
this.prefabPromiseMap = new Map();
|
|
758
|
+
this._engine = this.context.engine;
|
|
759
|
+
this._organizeEntities = this._organizeEntities.bind(this);
|
|
760
|
+
this._parseComponents = this._parseComponents.bind(this);
|
|
761
|
+
this._parsePrefabModification = this._parsePrefabModification.bind(this);
|
|
762
|
+
this._parsePrefabRemovedEntities = this._parsePrefabRemovedEntities.bind(this);
|
|
763
|
+
this._parsePrefabRemovedComponents = this._parsePrefabRemovedComponents.bind(this);
|
|
764
|
+
this._clearAndResolve = this._clearAndResolve.bind(this);
|
|
765
|
+
this.promise = new Promise(function(resolve, reject) {
|
|
766
|
+
_this._reject = reject;
|
|
767
|
+
_this._resolve = resolve;
|
|
768
|
+
});
|
|
769
|
+
this._reflectionParser = new ReflectionParser(context);
|
|
770
|
+
}
|
|
771
|
+
var _proto = HierarchyParser.prototype;
|
|
772
|
+
/** start parse the scene or prefab or others */ _proto.start = function start() {
|
|
773
|
+
this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject);
|
|
774
|
+
};
|
|
775
|
+
_proto._parseEntities = function _parseEntities() {
|
|
776
|
+
var _this = this;
|
|
777
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
778
|
+
var entityConfigMap = this.context.entityConfigMap;
|
|
779
|
+
var entityMap = this.context.entityMap;
|
|
780
|
+
var engine = this._engine;
|
|
781
|
+
var promises = entitiesConfig.map(function(entityConfig) {
|
|
782
|
+
var _entityConfig_strippedId;
|
|
783
|
+
var id = (_entityConfig_strippedId = entityConfig.strippedId) != null ? _entityConfig_strippedId : entityConfig.id;
|
|
784
|
+
entityConfig.id = id;
|
|
785
|
+
entityConfigMap.set(id, entityConfig);
|
|
786
|
+
return _this._getEntityByConfig(entityConfig, engine);
|
|
787
|
+
});
|
|
788
|
+
return Promise.all(promises).then(function(entities) {
|
|
789
|
+
for(var i = 0, l = entities.length; i < l; i++){
|
|
790
|
+
entityMap.set(entitiesConfig[i].id, entities[i]);
|
|
791
|
+
}
|
|
792
|
+
return entities;
|
|
793
|
+
});
|
|
794
|
+
};
|
|
795
|
+
_proto._parseComponents = function _parseComponents() {
|
|
796
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
797
|
+
var entityMap = this.context.entityMap;
|
|
798
|
+
var components = this.context.components;
|
|
799
|
+
var promises = [];
|
|
800
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
801
|
+
var entityConfig = entitiesConfig[i];
|
|
802
|
+
var entity = entityMap.get(entityConfig.id);
|
|
803
|
+
for(var i1 = 0; i1 < entityConfig.components.length; i1++){
|
|
804
|
+
var componentConfig = entityConfig.components[i1];
|
|
805
|
+
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
806
|
+
var component = entity.addComponent(Loader.getClass(key));
|
|
807
|
+
components.set(componentConfig.id, component);
|
|
808
|
+
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
809
|
+
promises.push(promise);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return Promise.all(promises);
|
|
813
|
+
};
|
|
814
|
+
_proto._parsePrefabModification = function _parsePrefabModification() {
|
|
815
|
+
var _loop = function(i, l) {
|
|
816
|
+
var _modifications;
|
|
817
|
+
var entityConfig = entitiesConfig[i];
|
|
818
|
+
var id = entityConfig.id, modifications = entityConfig.modifications;
|
|
819
|
+
if ((_modifications = modifications) == null ? void 0 : _modifications.length) {
|
|
820
|
+
var _promises;
|
|
821
|
+
var rootEntity = entityMap.get(id);
|
|
822
|
+
(_promises = promises).push.apply(_promises, [].concat(modifications.map(function(modification) {
|
|
823
|
+
var target = modification.target, props = modification.props, methods = modification.methods;
|
|
824
|
+
var entityId = target.entityId, componentId = target.componentId;
|
|
825
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
826
|
+
var targetEntity = context.entityMap.get(entityId);
|
|
827
|
+
var targetComponent = context.components.get(componentId);
|
|
828
|
+
if (targetComponent) {
|
|
829
|
+
return _this._reflectionParser.parsePropsAndMethods(targetComponent, {
|
|
830
|
+
props: props,
|
|
831
|
+
methods: methods
|
|
832
|
+
});
|
|
833
|
+
} else if (targetEntity) {
|
|
834
|
+
return Promise.resolve(_this._applyEntityData(targetEntity, props));
|
|
835
|
+
}
|
|
836
|
+
})));
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
var _this = this;
|
|
840
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
841
|
+
var entityMap = this.context.entityMap;
|
|
842
|
+
var promises = [];
|
|
843
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
844
|
+
return Promise.all(promises);
|
|
845
|
+
};
|
|
846
|
+
_proto._parsePrefabRemovedEntities = function _parsePrefabRemovedEntities() {
|
|
847
|
+
var _loop = function(i, l) {
|
|
848
|
+
var _removedEntities;
|
|
849
|
+
var entityConfig = entitiesConfig[i];
|
|
850
|
+
var id = entityConfig.id, removedEntities = entityConfig.removedEntities;
|
|
851
|
+
if ((_removedEntities = removedEntities) == null ? void 0 : _removedEntities.length) {
|
|
852
|
+
var _promises;
|
|
853
|
+
var rootEntity = entityMap.get(id);
|
|
854
|
+
(_promises = promises).push.apply(_promises, [].concat(removedEntities.map(function(target) {
|
|
855
|
+
var entityId = target.entityId;
|
|
856
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
857
|
+
var targetEntity = context.entityMap.get(entityId);
|
|
858
|
+
if (targetEntity) {
|
|
859
|
+
targetEntity.destroy();
|
|
860
|
+
}
|
|
861
|
+
})));
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
var _this = this;
|
|
865
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
866
|
+
var entityMap = this.context.entityMap;
|
|
867
|
+
var promises = [];
|
|
868
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
869
|
+
return Promise.all(promises);
|
|
870
|
+
};
|
|
871
|
+
_proto._parsePrefabRemovedComponents = function _parsePrefabRemovedComponents() {
|
|
872
|
+
var _loop = function(i, l) {
|
|
873
|
+
var _removedComponents;
|
|
874
|
+
var entityConfig = entitiesConfig[i];
|
|
875
|
+
var id = entityConfig.id, removedComponents = entityConfig.removedComponents;
|
|
876
|
+
if ((_removedComponents = removedComponents) == null ? void 0 : _removedComponents.length) {
|
|
877
|
+
var _promises;
|
|
878
|
+
var rootEntity = entityMap.get(id);
|
|
879
|
+
(_promises = promises).concat.apply(_promises, [].concat(removedComponents.map(function(target) {
|
|
880
|
+
var componentId = target.componentId;
|
|
881
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
882
|
+
var targetComponent = context.components.get(componentId);
|
|
883
|
+
if (targetComponent) {
|
|
884
|
+
targetComponent.destroy();
|
|
885
|
+
}
|
|
886
|
+
})));
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
var _this = this;
|
|
890
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
891
|
+
var entityMap = this.context.entityMap;
|
|
892
|
+
var promises = [];
|
|
893
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
894
|
+
return Promise.all(promises);
|
|
895
|
+
};
|
|
896
|
+
_proto._clearAndResolve = function _clearAndResolve() {
|
|
897
|
+
var target = this.context.target;
|
|
898
|
+
return target;
|
|
899
|
+
};
|
|
900
|
+
_proto._organizeEntities = function _organizeEntities() {
|
|
901
|
+
var _this_context = this.context, rootIds = _this_context.rootIds, strippedIds = _this_context.strippedIds;
|
|
902
|
+
var parentIds = rootIds.concat(strippedIds);
|
|
903
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(parentIds), _step; !(_step = _iterator()).done;){
|
|
904
|
+
var parentId = _step.value;
|
|
905
|
+
this._parseChildren(parentId);
|
|
906
|
+
}
|
|
907
|
+
for(var i = 0; i < rootIds.length; i++){
|
|
908
|
+
this.handleRootEntity(rootIds[i]);
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
_proto._getEntityByConfig = function _getEntityByConfig(entityConfig, engine) {
|
|
912
|
+
var _this = this;
|
|
913
|
+
var entityPromise;
|
|
914
|
+
if (entityConfig.assetRefId) {
|
|
915
|
+
entityPromise = this._parseGLTF(entityConfig, engine);
|
|
916
|
+
} else if (entityConfig.strippedId) {
|
|
917
|
+
entityPromise = this._parseStrippedEntity(entityConfig);
|
|
918
|
+
} else {
|
|
919
|
+
entityPromise = this._parseEntity(entityConfig, engine);
|
|
920
|
+
}
|
|
921
|
+
return entityPromise.then(function(entity) {
|
|
922
|
+
return _this._applyEntityData(entity, entityConfig);
|
|
923
|
+
});
|
|
924
|
+
};
|
|
925
|
+
_proto._parseEntity = function _parseEntity(entityConfig, engine) {
|
|
926
|
+
var entity = new Entity(engine, entityConfig.name);
|
|
927
|
+
if (!entityConfig.parent) this.context.rootIds.push(entityConfig.id);
|
|
928
|
+
return Promise.resolve(entity);
|
|
929
|
+
};
|
|
930
|
+
_proto._parseGLTF = function _parseGLTF(entityConfig, engine) {
|
|
931
|
+
var _this = this;
|
|
932
|
+
var assetRefId = entityConfig.assetRefId;
|
|
933
|
+
var context = new ParserContext(null, engine);
|
|
934
|
+
return engine.resourceManager// @ts-ignore
|
|
935
|
+
.getResourceByRef({
|
|
936
|
+
refId: assetRefId
|
|
937
|
+
}).then(function(glTFResource) {
|
|
938
|
+
var entity = glTFResource.instantiateSceneRoot();
|
|
939
|
+
if (!entityConfig.parent) _this.context.rootIds.push(entityConfig.id);
|
|
940
|
+
_this._traverseAddEntityToMap(entity, context, "");
|
|
941
|
+
_this.prefabContextMap.set(entity, context);
|
|
942
|
+
var cbArray = _this.prefabPromiseMap.get(entityConfig.id);
|
|
943
|
+
cbArray && cbArray.forEach(function(cb) {
|
|
944
|
+
cb.resolve(context);
|
|
945
|
+
});
|
|
946
|
+
return entity;
|
|
947
|
+
});
|
|
948
|
+
};
|
|
949
|
+
_proto._parseStrippedEntity = function _parseStrippedEntity(entityConfig) {
|
|
950
|
+
var _this = this;
|
|
951
|
+
this.context.strippedIds.push(entityConfig.id);
|
|
952
|
+
return new Promise(function(resolve, reject) {
|
|
953
|
+
var _this_prefabPromiseMap_get;
|
|
954
|
+
var cbArray = (_this_prefabPromiseMap_get = _this.prefabPromiseMap.get(entityConfig.prefabInstanceId)) != null ? _this_prefabPromiseMap_get : [];
|
|
955
|
+
cbArray.push({
|
|
956
|
+
resolve: resolve,
|
|
957
|
+
reject: reject
|
|
958
|
+
});
|
|
959
|
+
_this.prefabPromiseMap.set(entityConfig.prefabInstanceId, cbArray);
|
|
960
|
+
}).then(function(context) {
|
|
961
|
+
var entityId = entityConfig.prefabSource.entityId;
|
|
962
|
+
return context.entityMap.get(entityId);
|
|
963
|
+
});
|
|
964
|
+
};
|
|
965
|
+
_proto._parseChildren = function _parseChildren(parentId) {
|
|
966
|
+
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap;
|
|
967
|
+
var children = entityConfigMap.get(parentId).children;
|
|
675
968
|
if (children && children.length > 0) {
|
|
676
|
-
var parent =
|
|
969
|
+
var parent = entityMap.get(parentId);
|
|
677
970
|
for(var i = 0; i < children.length; i++){
|
|
678
971
|
var childId = children[i];
|
|
679
|
-
var entity =
|
|
972
|
+
var entity = entityMap.get(childId);
|
|
680
973
|
parent.addChild(entity);
|
|
681
|
-
this.
|
|
974
|
+
this._parseChildren(childId);
|
|
682
975
|
}
|
|
683
976
|
}
|
|
684
977
|
};
|
|
685
|
-
|
|
978
|
+
_proto._applyEntityData = function _applyEntityData(entity, entityConfig) {
|
|
979
|
+
if (entityConfig === void 0) entityConfig = {};
|
|
980
|
+
var _entityConfig_isActive;
|
|
981
|
+
entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
|
|
982
|
+
var _entityConfig_name;
|
|
983
|
+
entity.name = (_entityConfig_name = entityConfig.name) != null ? _entityConfig_name : entity.name;
|
|
984
|
+
var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
|
|
985
|
+
if (position) entity.transform.position.copyFrom(position);
|
|
986
|
+
if (rotation) entity.transform.rotation.copyFrom(rotation);
|
|
987
|
+
if (scale) entity.transform.scale.copyFrom(scale);
|
|
988
|
+
return entity;
|
|
989
|
+
};
|
|
990
|
+
_proto._traverseAddEntityToMap = function _traverseAddEntityToMap(entity, context, path) {
|
|
991
|
+
var entityMap = context.entityMap, components = context.components;
|
|
992
|
+
var componentsMap = {};
|
|
993
|
+
var componentIndexMap = {};
|
|
994
|
+
entityMap.set(path, entity);
|
|
995
|
+
// @ts-ignore
|
|
996
|
+
entity._components.forEach(function(component) {
|
|
997
|
+
// @ts-ignore
|
|
998
|
+
var name = Loader.getClassName(component.constructor);
|
|
999
|
+
if (!componentsMap[name]) {
|
|
1000
|
+
componentsMap[name] = entity.getComponents(component.constructor, []);
|
|
1001
|
+
componentIndexMap[name] = 0;
|
|
1002
|
+
}
|
|
1003
|
+
components.set(path + ":" + name + "/" + componentIndexMap[name]++, component);
|
|
1004
|
+
});
|
|
1005
|
+
for(var i = 0, n = entity.children.length; i < n; i++){
|
|
1006
|
+
var child = entity.children[i];
|
|
1007
|
+
var childPath = path ? path + "/" + i : "" + i;
|
|
1008
|
+
this._traverseAddEntityToMap(child, context, childPath);
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
return HierarchyParser;
|
|
686
1012
|
}();
|
|
687
1013
|
|
|
688
|
-
var
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
1014
|
+
var PrefabParser = /*#__PURE__*/ function(HierarchyParser1) {
|
|
1015
|
+
_inherits(PrefabParser, HierarchyParser1);
|
|
1016
|
+
function PrefabParser() {
|
|
1017
|
+
return HierarchyParser1.apply(this, arguments);
|
|
1018
|
+
}
|
|
1019
|
+
var _proto = PrefabParser.prototype;
|
|
1020
|
+
_proto.handleRootEntity = function handleRootEntity(id) {
|
|
1021
|
+
this.context.target = this.context.entityMap.get(id);
|
|
1022
|
+
};
|
|
1023
|
+
/**
|
|
1024
|
+
* Parse prefab data.
|
|
1025
|
+
* @param engine - the engine of the parser context
|
|
1026
|
+
* @param prefabData - prefab data which is exported by editor
|
|
1027
|
+
* @returns a promise of prefab
|
|
1028
|
+
*/ PrefabParser.parse = function parse(engine, prefabData) {
|
|
1029
|
+
var context = new PrefabParserContext(prefabData, engine);
|
|
1030
|
+
var parser = new PrefabParser(context);
|
|
1031
|
+
parser.start();
|
|
1032
|
+
return parser;
|
|
1033
|
+
};
|
|
1034
|
+
return PrefabParser;
|
|
1035
|
+
}(HierarchyParser);
|
|
702
1036
|
|
|
703
1037
|
var InterpolableValueType;
|
|
704
1038
|
(function(InterpolableValueType) {
|
|
@@ -732,7 +1066,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
732
1066
|
for(var i1 = 0; i1 < curveBindingsLen; ++i1){
|
|
733
1067
|
var relativePath = bufferReader.nextStr();
|
|
734
1068
|
var componentStr = bufferReader.nextStr();
|
|
735
|
-
var componentType =
|
|
1069
|
+
var componentType = Loader.getClass(componentStr);
|
|
736
1070
|
var property = bufferReader.nextStr();
|
|
737
1071
|
var getProperty = bufferReader.nextStr();
|
|
738
1072
|
var curve = void 0;
|
|
@@ -911,145 +1245,28 @@ var SpecularMode;
|
|
|
911
1245
|
SpecularMode["Custom"] = "Custom";
|
|
912
1246
|
})(SpecularMode || (SpecularMode = {}));
|
|
913
1247
|
|
|
914
|
-
function
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
if (!o) return;
|
|
924
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
925
|
-
|
|
926
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
927
|
-
|
|
928
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
929
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
930
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
934
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
935
|
-
|
|
936
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
937
|
-
// Fallback for engines without symbol support
|
|
938
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
939
|
-
if (it) o = it;
|
|
940
|
-
|
|
941
|
-
var i = 0;
|
|
942
|
-
|
|
943
|
-
return function() {
|
|
944
|
-
if (i >= o.length) return { done: true };
|
|
945
|
-
|
|
946
|
-
return { done: false, value: o[i++] };
|
|
947
|
-
};
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
var SceneParserContext = /*#__PURE__*/ function() {
|
|
954
|
-
function SceneParserContext(originalData, scene) {
|
|
955
|
-
this.originalData = originalData;
|
|
956
|
-
this.scene = scene;
|
|
957
|
-
this.entityMap = new Map();
|
|
958
|
-
this.components = new Map();
|
|
959
|
-
this.assets = new Map();
|
|
960
|
-
this.entityConfigMap = new Map();
|
|
961
|
-
this.rootIds = [];
|
|
962
|
-
this.engine = scene.engine;
|
|
963
|
-
this.resourceManager = scene.engine.resourceManager;
|
|
1248
|
+
var SceneParserContext = /*#__PURE__*/ function(ParserContext1) {
|
|
1249
|
+
_inherits(SceneParserContext, ParserContext1);
|
|
1250
|
+
function SceneParserContext(originalData, engine, scene) {
|
|
1251
|
+
var _this;
|
|
1252
|
+
_this = ParserContext1.call(this, originalData, engine, scene) || this;
|
|
1253
|
+
_this.originalData = originalData;
|
|
1254
|
+
_this.engine = engine;
|
|
1255
|
+
_this.scene = scene;
|
|
1256
|
+
return _this;
|
|
964
1257
|
}
|
|
965
|
-
var _proto = SceneParserContext.prototype;
|
|
966
|
-
_proto.destroy = function destroy() {
|
|
967
|
-
this.entityMap.clear();
|
|
968
|
-
this.components.clear();
|
|
969
|
-
this.assets.clear();
|
|
970
|
-
this.entityConfigMap.clear();
|
|
971
|
-
this.rootIds.length = 0;
|
|
972
|
-
};
|
|
973
1258
|
return SceneParserContext;
|
|
974
|
-
}();
|
|
1259
|
+
}(ParserContext);
|
|
975
1260
|
|
|
976
|
-
/** @Internal */ var SceneParser = /*#__PURE__*/ function() {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
this
|
|
980
|
-
this._engine = context.scene.engine;
|
|
981
|
-
this._organizeEntities = this._organizeEntities.bind(this);
|
|
982
|
-
this._parseComponents = this._parseComponents.bind(this);
|
|
983
|
-
this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
|
|
984
|
-
this.promise = new Promise(function(resolve, reject) {
|
|
985
|
-
_this._reject = reject;
|
|
986
|
-
_this._resolve = resolve;
|
|
987
|
-
});
|
|
988
|
-
this._reflectionParser = new ReflectionParser(context);
|
|
1261
|
+
/** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser1) {
|
|
1262
|
+
_inherits(SceneParser, HierarchyParser1);
|
|
1263
|
+
function SceneParser() {
|
|
1264
|
+
return HierarchyParser1.apply(this, arguments);
|
|
989
1265
|
}
|
|
990
1266
|
var _proto = SceneParser.prototype;
|
|
991
|
-
|
|
992
|
-
this.
|
|
993
|
-
|
|
994
|
-
_proto._parseEntities = function _parseEntities() {
|
|
995
|
-
var _this = this;
|
|
996
|
-
var entitiesConfig = this.context.originalData.entities;
|
|
997
|
-
var entityConfigMap = this.context.entityConfigMap;
|
|
998
|
-
var entitiesMap = this.context.entityMap;
|
|
999
|
-
var rootIds = this.context.rootIds;
|
|
1000
|
-
this._engine;
|
|
1001
|
-
var promises = entitiesConfig.map(function(entityConfig) {
|
|
1002
|
-
entityConfigMap.set(entityConfig.id, entityConfig);
|
|
1003
|
-
// record root entities
|
|
1004
|
-
if (!entityConfig.parent) rootIds.push(entityConfig.id);
|
|
1005
|
-
return _this._reflectionParser.parseEntity(entityConfig);
|
|
1006
|
-
});
|
|
1007
|
-
return Promise.all(promises).then(function(entities) {
|
|
1008
|
-
for(var i = 0, l = entities.length; i < l; i++){
|
|
1009
|
-
entitiesMap.set(entitiesConfig[i].id, entities[i]);
|
|
1010
|
-
}
|
|
1011
|
-
return entities;
|
|
1012
|
-
});
|
|
1013
|
-
};
|
|
1014
|
-
_proto._organizeEntities = function _organizeEntities() {
|
|
1015
|
-
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
|
|
1016
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
|
|
1017
|
-
var rootId = _step.value;
|
|
1018
|
-
PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
|
|
1019
|
-
}
|
|
1020
|
-
var rootEntities = rootIds.map(function(id) {
|
|
1021
|
-
return entityMap.get(id);
|
|
1022
|
-
});
|
|
1023
|
-
for(var i = 0; i < rootEntities.length; i++){
|
|
1024
|
-
scene.addRootEntity(rootEntities[i]);
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
_proto._parseComponents = function _parseComponents() {
|
|
1028
|
-
var entitiesConfig = this.context.originalData.entities;
|
|
1029
|
-
var entityMap = this.context.entityMap;
|
|
1030
|
-
var promises = [];
|
|
1031
|
-
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
1032
|
-
var entityConfig = entitiesConfig[i];
|
|
1033
|
-
var entity = entityMap.get(entityConfig.id);
|
|
1034
|
-
for(var i1 = 0; i1 < entityConfig.components.length; i1++){
|
|
1035
|
-
var componentConfig = entityConfig.components[i1];
|
|
1036
|
-
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
1037
|
-
var component = void 0;
|
|
1038
|
-
// TODO: remove hack code when support additional edit
|
|
1039
|
-
if (key === "Animator") {
|
|
1040
|
-
component = entity.getComponent(Loader.getClass(key));
|
|
1041
|
-
}
|
|
1042
|
-
component = component || entity.addComponent(Loader.getClass(key));
|
|
1043
|
-
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
1044
|
-
promises.push(promise);
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
return Promise.all(promises);
|
|
1048
|
-
};
|
|
1049
|
-
_proto._clearAndResolveScene = function _clearAndResolveScene() {
|
|
1050
|
-
var scene = this.context.scene;
|
|
1051
|
-
this.context.destroy();
|
|
1052
|
-
return scene;
|
|
1267
|
+
_proto.handleRootEntity = function handleRootEntity(id) {
|
|
1268
|
+
var _this_context = this.context, target = _this_context.target, entityMap = _this_context.entityMap;
|
|
1269
|
+
target.addRootEntity(entityMap.get(id));
|
|
1053
1270
|
};
|
|
1054
1271
|
/**
|
|
1055
1272
|
* Parse scene data.
|
|
@@ -1058,13 +1275,13 @@ var SceneParserContext = /*#__PURE__*/ function() {
|
|
|
1058
1275
|
* @returns a promise of scene
|
|
1059
1276
|
*/ SceneParser.parse = function parse(engine, sceneData) {
|
|
1060
1277
|
var scene = new Scene(engine);
|
|
1061
|
-
var context = new SceneParserContext(sceneData, scene);
|
|
1278
|
+
var context = new SceneParserContext(sceneData, engine, scene);
|
|
1062
1279
|
var parser = new SceneParser(context);
|
|
1063
1280
|
parser.start();
|
|
1064
1281
|
return parser.promise;
|
|
1065
1282
|
};
|
|
1066
1283
|
return SceneParser;
|
|
1067
|
-
}();
|
|
1284
|
+
}(HierarchyParser);
|
|
1068
1285
|
|
|
1069
1286
|
var MeshLoader$1 = /*#__PURE__*/ function(Loader1) {
|
|
1070
1287
|
_inherits(MeshLoader, Loader1);
|
|
@@ -1169,7 +1386,7 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
1169
1386
|
resourceManager// @ts-ignore
|
|
1170
1387
|
.getResourceByRef(value).then(function(asset) {
|
|
1171
1388
|
keyframe.value = asset;
|
|
1172
|
-
resolve(keyframe);
|
|
1389
|
+
resolve(keyframe.value);
|
|
1173
1390
|
});
|
|
1174
1391
|
});
|
|
1175
1392
|
} else {
|
|
@@ -2181,7 +2398,7 @@ function registerGLTFParser(pipeline) {
|
|
|
2181
2398
|
};
|
|
2182
2399
|
/**
|
|
2183
2400
|
* Parse the glb format.
|
|
2184
|
-
*/ GLTFUtils.parseGLB = function parseGLB(context,
|
|
2401
|
+
*/ GLTFUtils.parseGLB = function parseGLB(context, originBuffer) {
|
|
2185
2402
|
var UINT32_LENGTH = 4;
|
|
2186
2403
|
var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
|
|
2187
2404
|
var GLB_HEADER_LENGTH = 12;
|
|
@@ -2189,7 +2406,7 @@ function registerGLTFParser(pipeline) {
|
|
|
2189
2406
|
JSON: 0x4e4f534a,
|
|
2190
2407
|
BIN: 0x004e4942
|
|
2191
2408
|
};
|
|
2192
|
-
var dataView = new DataView(
|
|
2409
|
+
var dataView = new DataView(originBuffer);
|
|
2193
2410
|
// read header
|
|
2194
2411
|
var header = {
|
|
2195
2412
|
magic: dataView.getUint32(0, true),
|
|
@@ -2197,8 +2414,9 @@ function registerGLTFParser(pipeline) {
|
|
|
2197
2414
|
length: dataView.getUint32(2 * UINT32_LENGTH, true)
|
|
2198
2415
|
};
|
|
2199
2416
|
if (header.magic !== GLB_HEADER_MAGIC) {
|
|
2200
|
-
|
|
2201
|
-
|
|
2417
|
+
return {
|
|
2418
|
+
originBuffer: originBuffer
|
|
2419
|
+
};
|
|
2202
2420
|
}
|
|
2203
2421
|
// read main data
|
|
2204
2422
|
var chunkLength = dataView.getUint32(GLB_HEADER_LENGTH, true);
|
|
@@ -2208,7 +2426,7 @@ function registerGLTFParser(pipeline) {
|
|
|
2208
2426
|
console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x" + chunkType.toString(16));
|
|
2209
2427
|
return null;
|
|
2210
2428
|
}
|
|
2211
|
-
var glTFData = new Uint8Array(
|
|
2429
|
+
var glTFData = new Uint8Array(originBuffer, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
|
|
2212
2430
|
var glTF = JSON.parse(Utils.decodeText(glTFData));
|
|
2213
2431
|
// read all buffers
|
|
2214
2432
|
var buffers = [];
|
|
@@ -2222,7 +2440,7 @@ function registerGLTFParser(pipeline) {
|
|
|
2222
2440
|
return null;
|
|
2223
2441
|
}
|
|
2224
2442
|
var currentOffset = byteOffset + 2 * UINT32_LENGTH;
|
|
2225
|
-
var buffer =
|
|
2443
|
+
var buffer = originBuffer.slice(currentOffset, currentOffset + chunkLength);
|
|
2226
2444
|
buffers.push(buffer);
|
|
2227
2445
|
restoreGLBBufferSlice.push(new Vector2(currentOffset, chunkLength));
|
|
2228
2446
|
byteOffset += chunkLength + 2 * UINT32_LENGTH;
|
|
@@ -3636,23 +3854,20 @@ var GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3636
3854
|
var requestConfig = {
|
|
3637
3855
|
type: "arraybuffer"
|
|
3638
3856
|
};
|
|
3639
|
-
|
|
3640
|
-
contentRestorer.isGLB = isGLB;
|
|
3641
|
-
var promise = isGLB ? request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(glb) {
|
|
3857
|
+
return request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(buffer) {
|
|
3642
3858
|
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
3643
|
-
return GLTFUtils.parseGLB(context,
|
|
3644
|
-
}).then(function(
|
|
3645
|
-
var
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
return url.substring(index + 1, index + 4) === "glb";
|
|
3859
|
+
return GLTFUtils.parseGLB(context, buffer);
|
|
3860
|
+
}).then(function(result) {
|
|
3861
|
+
var _result;
|
|
3862
|
+
if ((_result = result) == null ? void 0 : _result.glTF) {
|
|
3863
|
+
contentRestorer.isGLB = true;
|
|
3864
|
+
context.buffers = result.buffers;
|
|
3865
|
+
return result.glTF;
|
|
3866
|
+
} else {
|
|
3867
|
+
contentRestorer.isGLB = false;
|
|
3868
|
+
return JSON.parse(Utils.decodeText(new Uint8Array(result.originBuffer)));
|
|
3869
|
+
}
|
|
3870
|
+
});
|
|
3656
3871
|
};
|
|
3657
3872
|
return GLTFSchemaParser;
|
|
3658
3873
|
}(GLTFParser);
|
|
@@ -5624,6 +5839,86 @@ MeshLoader = __decorate([
|
|
|
5624
5839
|
])
|
|
5625
5840
|
], MeshLoader);
|
|
5626
5841
|
|
|
5842
|
+
var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader1) {
|
|
5843
|
+
_inherits(PrimitiveMeshLoader, Loader1);
|
|
5844
|
+
function PrimitiveMeshLoader() {
|
|
5845
|
+
return Loader1.apply(this, arguments);
|
|
5846
|
+
}
|
|
5847
|
+
var _proto = PrimitiveMeshLoader.prototype;
|
|
5848
|
+
_proto.load = function load(item, param) {
|
|
5849
|
+
var engine = param.engine;
|
|
5850
|
+
return this.request(item.url, _extends({}, item, {
|
|
5851
|
+
type: "json"
|
|
5852
|
+
})).then(function(data) {
|
|
5853
|
+
switch(data.type){
|
|
5854
|
+
case "sphere":
|
|
5855
|
+
return PrimitiveMesh.createSubdivisionSurfaceSphere(engine, data.sphereRadius, data.sphereStep);
|
|
5856
|
+
case "capsule":
|
|
5857
|
+
return PrimitiveMesh.createCapsule(engine, data.capsuleRadius, data.capsuleHeight, data.capsuleRadialSegments, data.capsuleHeightSegments);
|
|
5858
|
+
case "cone":
|
|
5859
|
+
return PrimitiveMesh.createCone(engine, data.coneRadius, data.coneHeight, data.coneRadialSegment, data.coneHeightSegment);
|
|
5860
|
+
case "cuboid":
|
|
5861
|
+
return PrimitiveMesh.createCuboid(engine, data.cuboidWidth, data.cuboidHeight, data.cuboidDepth);
|
|
5862
|
+
case "cylinder":
|
|
5863
|
+
return PrimitiveMesh.createCylinder(engine, data.cylinderRadiusTop, data.cylinderRadiusBottom, data.cylinderHeight, data.cylinderRadialSegment, data.cylinderHeightSegment);
|
|
5864
|
+
case "plane":
|
|
5865
|
+
return PrimitiveMesh.createPlane(engine, data.planeWidth, data.planeHeight, data.planeHorizontalSegments, data.planeVerticalSegments);
|
|
5866
|
+
case "torus":
|
|
5867
|
+
return PrimitiveMesh.createTorus(engine, data.torusRadius, data.torusTubeRadius, data.torusRadialSegments, data.torusTubularSegments, data.torusArc);
|
|
5868
|
+
}
|
|
5869
|
+
});
|
|
5870
|
+
};
|
|
5871
|
+
return PrimitiveMeshLoader;
|
|
5872
|
+
}(Loader);
|
|
5873
|
+
PrimitiveMeshLoader = __decorate([
|
|
5874
|
+
resourceLoader(AssetType.PrimitiveMesh, [
|
|
5875
|
+
"mesh"
|
|
5876
|
+
], false)
|
|
5877
|
+
], PrimitiveMeshLoader);
|
|
5878
|
+
var /** @internal */ PrimitiveMeshType;
|
|
5879
|
+
(function(PrimitiveMeshType) {
|
|
5880
|
+
PrimitiveMeshType["Sphere"] = "sphere";
|
|
5881
|
+
PrimitiveMeshType["Cuboid"] = "cuboid";
|
|
5882
|
+
PrimitiveMeshType["Plane"] = "plane";
|
|
5883
|
+
PrimitiveMeshType["Cylinder"] = "cylinder";
|
|
5884
|
+
PrimitiveMeshType["Torus"] = "torus";
|
|
5885
|
+
PrimitiveMeshType["Cone"] = "cone";
|
|
5886
|
+
PrimitiveMeshType["Capsule"] = "capsule";
|
|
5887
|
+
})(PrimitiveMeshType || (PrimitiveMeshType = {}));
|
|
5888
|
+
|
|
5889
|
+
var ProjectLoader = /*#__PURE__*/ function(Loader1) {
|
|
5890
|
+
_inherits(ProjectLoader, Loader1);
|
|
5891
|
+
function ProjectLoader() {
|
|
5892
|
+
return Loader1.apply(this, arguments);
|
|
5893
|
+
}
|
|
5894
|
+
var _proto = ProjectLoader.prototype;
|
|
5895
|
+
_proto.load = function load(item, resourceManager) {
|
|
5896
|
+
var _this = this;
|
|
5897
|
+
var engine = resourceManager.engine;
|
|
5898
|
+
return new AssetPromise(function(resolve, reject) {
|
|
5899
|
+
_this.request(item.url, {
|
|
5900
|
+
type: "json"
|
|
5901
|
+
}).then(function(data) {
|
|
5902
|
+
// @ts-ignore
|
|
5903
|
+
engine.resourceManager.initVirtualResources(data.files);
|
|
5904
|
+
return resourceManager.load({
|
|
5905
|
+
type: AssetType.Scene,
|
|
5906
|
+
url: data.scene
|
|
5907
|
+
}).then(function(scene) {
|
|
5908
|
+
engine.sceneManager.activeScene = scene;
|
|
5909
|
+
resolve();
|
|
5910
|
+
});
|
|
5911
|
+
}).catch(reject);
|
|
5912
|
+
});
|
|
5913
|
+
};
|
|
5914
|
+
return ProjectLoader;
|
|
5915
|
+
}(Loader);
|
|
5916
|
+
ProjectLoader = __decorate([
|
|
5917
|
+
resourceLoader(AssetType.Project, [
|
|
5918
|
+
"proj"
|
|
5919
|
+
], false)
|
|
5920
|
+
], ProjectLoader);
|
|
5921
|
+
|
|
5627
5922
|
var SourceFontLoader = /*#__PURE__*/ function(Loader1) {
|
|
5628
5923
|
_inherits(SourceFontLoader, Loader1);
|
|
5629
5924
|
function SourceFontLoader() {
|
|
@@ -5959,39 +6254,6 @@ TextureCubeLoader = __decorate([
|
|
|
5959
6254
|
])
|
|
5960
6255
|
], TextureCubeLoader);
|
|
5961
6256
|
|
|
5962
|
-
var ProjectLoader = /*#__PURE__*/ function(Loader1) {
|
|
5963
|
-
_inherits(ProjectLoader, Loader1);
|
|
5964
|
-
function ProjectLoader() {
|
|
5965
|
-
return Loader1.apply(this, arguments);
|
|
5966
|
-
}
|
|
5967
|
-
var _proto = ProjectLoader.prototype;
|
|
5968
|
-
_proto.load = function load(item, resourceManager) {
|
|
5969
|
-
var _this = this;
|
|
5970
|
-
var engine = resourceManager.engine;
|
|
5971
|
-
return new AssetPromise(function(resolve, reject) {
|
|
5972
|
-
_this.request(item.url, {
|
|
5973
|
-
type: "json"
|
|
5974
|
-
}).then(function(data) {
|
|
5975
|
-
// @ts-ignore
|
|
5976
|
-
engine.resourceManager.initVirtualResources(data.files);
|
|
5977
|
-
return resourceManager.load({
|
|
5978
|
-
type: AssetType.Scene,
|
|
5979
|
-
url: data.scene
|
|
5980
|
-
}).then(function(scene) {
|
|
5981
|
-
engine.sceneManager.activeScene = scene;
|
|
5982
|
-
resolve();
|
|
5983
|
-
});
|
|
5984
|
-
}).catch(reject);
|
|
5985
|
-
});
|
|
5986
|
-
};
|
|
5987
|
-
return ProjectLoader;
|
|
5988
|
-
}(Loader);
|
|
5989
|
-
ProjectLoader = __decorate([
|
|
5990
|
-
resourceLoader(AssetType.Project, [
|
|
5991
|
-
"proj"
|
|
5992
|
-
], false)
|
|
5993
|
-
], ProjectLoader);
|
|
5994
|
-
|
|
5995
6257
|
var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
5996
6258
|
_inherits(SceneLoader, Loader1);
|
|
5997
6259
|
function SceneLoader() {
|
|
@@ -6010,7 +6272,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
6010
6272
|
// parse ambient light
|
|
6011
6273
|
var ambient = data.scene.ambient;
|
|
6012
6274
|
if (ambient) {
|
|
6013
|
-
var useCustomAmbient = ambient.specularMode ===
|
|
6275
|
+
var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
|
|
6014
6276
|
var useSH = ambient.diffuseMode === DiffuseMode.SphericalHarmonics;
|
|
6015
6277
|
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
6016
6278
|
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
@@ -6081,6 +6343,8 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
6081
6343
|
var _shadow_shadowTwoCascadeSplits;
|
|
6082
6344
|
scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
|
|
6083
6345
|
shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
|
|
6346
|
+
var _shadow_shadowFadeBorder;
|
|
6347
|
+
scene.shadowFadeBorder = (_shadow_shadowFadeBorder = shadow.shadowFadeBorder) != null ? _shadow_shadowFadeBorder : scene.shadowFadeBorder;
|
|
6084
6348
|
}
|
|
6085
6349
|
return Promise.all(promises).then(function() {
|
|
6086
6350
|
resolve(scene);
|
|
@@ -6483,5 +6747,5 @@ KHR_materials_anisotropy = __decorate([
|
|
|
6483
6747
|
registerGLTFExtension("KHR_materials_anisotropy", GLTFExtensionMode.AdditiveParse)
|
|
6484
6748
|
], KHR_materials_anisotropy);
|
|
6485
6749
|
|
|
6486
|
-
export { AccessorType, AnimationClipDecoder, BufferInfo,
|
|
6750
|
+
export { AccessorType, AnimationClipDecoder, BufferInfo, EditorTextureLoader, GLTFAnimationParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, InterpolableValueType, KTX2Loader, KTX2TargetFormat, KTX2Transcoder, MeshDecoder, MeshLoader$1 as MeshLoader, ParserContext, PrefabParser, ReflectionParser, SceneParser, SpecularMode, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension, registerGLTFParser };
|
|
6487
6751
|
//# sourceMappingURL=module.js.map
|