@galacean/engine-loader 1.4.0-alpha.1 → 1.4.0-alpha.2
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 +123 -36
- package/dist/main.js.map +1 -1
- package/dist/module.js +124 -37
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/PhysicsMaterialLoader.d.ts +1 -0
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +10 -1
- package/types/gltf/extensions/KHR_materials_transmission.d.ts +1 -0
- package/types/gltf/extensions/KHR_materials_volume.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/resource-deserialize/resources/parser/ParserContext.d.ts +5 -10
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +1 -0
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +4 -0
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils, ModelMesh, BlendShape, Texture2D, Loader, Entity, AnimationClip, AnimationEvent, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ReferResource, Scene, resourceLoader, AssetPromise, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, AmbientLight, DiffuseMode, TextureCube, TextureFilterMode, TextureCubeFace, request, ContentRestorer, Font, Animator, IndexFormat, VertexElementFormat, GLCapabilityType, Logger, TextureFormat, InterpolationType, SkinnedMeshRenderer, Transform, PBRMaterial, BlinnPhongMaterial, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Camera, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, AnimatorStateMachine, SystemInfo, Shader, Material, PrimitiveMesh, SpriteAtlas, Sprite, AudioClip, AudioManager, ShaderFactory, ShaderLib, BackgroundMode, DirectLight, PointLight, SpotLight, UnlitMaterial } from '@galacean/engine-core';
|
|
1
|
+
import { Utils, ModelMesh, BlendShape, Texture2D, Loader, Entity, AnimationClip, AnimationEvent, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, ReferResource, Scene, resourceLoader, AssetPromise, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateTransition, AmbientLight, DiffuseMode, TextureCube, TextureFilterMode, TextureCubeFace, request, ContentRestorer, Font, Animator, IndexFormat, VertexElementFormat, GLCapabilityType, Logger, TextureFormat, InterpolationType, SkinnedMeshRenderer, Transform, PBRMaterial, BlinnPhongMaterial, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Camera, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, AnimatorStateMachine, SystemInfo, Shader, Material, PrimitiveMesh, SpriteAtlas, Sprite, AudioClip, AudioManager, ShaderFactory, ShaderLib, PhysicsMaterial, 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
|
|
|
@@ -533,11 +533,7 @@ var ParserType = /*#__PURE__*/ function(ParserType) {
|
|
|
533
533
|
return ParserType;
|
|
534
534
|
}({});
|
|
535
535
|
/**
|
|
536
|
-
*
|
|
537
|
-
* @export
|
|
538
|
-
* @class ParserContext
|
|
539
|
-
* @template T
|
|
540
|
-
* @template I
|
|
536
|
+
* @internal
|
|
541
537
|
*/ var ParserContext = /*#__PURE__*/ function() {
|
|
542
538
|
function ParserContext(engine, type, resource) {
|
|
543
539
|
if (type === void 0) type = 1;
|
|
@@ -549,13 +545,39 @@ var ParserType = /*#__PURE__*/ function(ParserType) {
|
|
|
549
545
|
this.components = new Map();
|
|
550
546
|
this.rootIds = [];
|
|
551
547
|
this.strippedIds = [];
|
|
548
|
+
this.componentWaitingMap = new Map();
|
|
552
549
|
this.resourceManager = engine.resourceManager;
|
|
553
550
|
}
|
|
554
551
|
var _proto = ParserContext.prototype;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
552
|
+
_proto.addComponent = function addComponent(id, component) {
|
|
553
|
+
this.components.set(id, component);
|
|
554
|
+
var waitingList = this.componentWaitingMap.get(id);
|
|
555
|
+
if (waitingList == null ? void 0 : waitingList.length) {
|
|
556
|
+
waitingList.forEach(function(resolve) {
|
|
557
|
+
return resolve(component);
|
|
558
|
+
});
|
|
559
|
+
this.componentWaitingMap.delete(id);
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
_proto.getComponentByRef = function getComponentByRef(ref) {
|
|
563
|
+
var _this = this;
|
|
564
|
+
return new Promise(function(resolve, reject) {
|
|
565
|
+
var component = _this.components.get(ref.componentId);
|
|
566
|
+
if (component) {
|
|
567
|
+
resolve(component);
|
|
568
|
+
} else {
|
|
569
|
+
var resolves = _this.componentWaitingMap.get(ref.componentId);
|
|
570
|
+
if (resolves) {
|
|
571
|
+
resolves.push(resolve);
|
|
572
|
+
} else {
|
|
573
|
+
_this.componentWaitingMap.set(ref.componentId, [
|
|
574
|
+
resolve
|
|
575
|
+
]);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
_proto.clear = function clear() {
|
|
559
581
|
this.entityMap.clear();
|
|
560
582
|
this.components.clear();
|
|
561
583
|
this.entityConfigMap.clear();
|
|
@@ -655,6 +677,8 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
655
677
|
}
|
|
656
678
|
return resource;
|
|
657
679
|
});
|
|
680
|
+
} else if (ReflectionParser._isComponentRef(value)) {
|
|
681
|
+
return this._context.getComponentByRef(value);
|
|
658
682
|
} else if (ReflectionParser._isEntityRef(value)) {
|
|
659
683
|
// entity reference
|
|
660
684
|
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
@@ -716,13 +740,16 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
716
740
|
this.customParseComponentHandles[componentType] = handle;
|
|
717
741
|
};
|
|
718
742
|
ReflectionParser._isClass = function _isClass(value) {
|
|
719
|
-
return value["class"]
|
|
743
|
+
return value["class"] !== undefined;
|
|
720
744
|
};
|
|
721
745
|
ReflectionParser._isAssetRef = function _isAssetRef(value) {
|
|
722
|
-
return value["refId"]
|
|
746
|
+
return value["refId"] !== undefined;
|
|
723
747
|
};
|
|
724
748
|
ReflectionParser._isEntityRef = function _isEntityRef(value) {
|
|
725
|
-
return value["entityId"]
|
|
749
|
+
return value["entityId"] !== undefined;
|
|
750
|
+
};
|
|
751
|
+
ReflectionParser._isComponentRef = function _isComponentRef(value) {
|
|
752
|
+
return value["ownerId"] !== undefined && value["componentId"] !== undefined;
|
|
726
753
|
};
|
|
727
754
|
return ReflectionParser;
|
|
728
755
|
}();
|
|
@@ -1079,7 +1106,6 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
1079
1106
|
_proto._parseComponents = function _parseComponents() {
|
|
1080
1107
|
var entitiesConfig = this.data.entities;
|
|
1081
1108
|
var entityMap = this.context.entityMap;
|
|
1082
|
-
var components = this.context.components;
|
|
1083
1109
|
var promises = [];
|
|
1084
1110
|
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
1085
1111
|
var entityConfig = entitiesConfig[i];
|
|
@@ -1088,11 +1114,17 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
1088
1114
|
var componentConfig = entityConfig.components[i1];
|
|
1089
1115
|
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
1090
1116
|
var component = entity.addComponent(Loader.getClass(key));
|
|
1091
|
-
|
|
1117
|
+
this.context.addComponent(componentConfig.id, component);
|
|
1092
1118
|
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
1093
1119
|
promises.push(promise);
|
|
1094
1120
|
}
|
|
1095
1121
|
}
|
|
1122
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.context.componentWaitingMap.values()), _step; !(_step = _iterator()).done;){
|
|
1123
|
+
var waitingList = _step.value;
|
|
1124
|
+
waitingList.forEach(function(resolve) {
|
|
1125
|
+
return resolve(null);
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1096
1128
|
return Promise.all(promises);
|
|
1097
1129
|
};
|
|
1098
1130
|
_proto._parsePrefabModification = function _parsePrefabModification() {
|
|
@@ -6469,6 +6501,34 @@ ShaderLoader = __decorate([
|
|
|
6469
6501
|
])
|
|
6470
6502
|
], ShaderLoader);
|
|
6471
6503
|
|
|
6504
|
+
var PhysicsMaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
6505
|
+
_inherits(PhysicsMaterialLoader, Loader);
|
|
6506
|
+
function PhysicsMaterialLoader() {
|
|
6507
|
+
return Loader.apply(this, arguments) || this;
|
|
6508
|
+
}
|
|
6509
|
+
var _proto = PhysicsMaterialLoader.prototype;
|
|
6510
|
+
_proto.load = function load(item, resourceManager) {
|
|
6511
|
+
return resourceManager// @ts-ignore
|
|
6512
|
+
._request(item.url, _extends({}, item, {
|
|
6513
|
+
type: "json"
|
|
6514
|
+
})).then(function(data) {
|
|
6515
|
+
var physicsMaterial = new PhysicsMaterial();
|
|
6516
|
+
physicsMaterial.bounciness = data.bounciness;
|
|
6517
|
+
physicsMaterial.dynamicFriction = data.dynamicFriction;
|
|
6518
|
+
physicsMaterial.staticFriction = data.staticFriction;
|
|
6519
|
+
physicsMaterial.bounceCombine = data.bounceCombine;
|
|
6520
|
+
physicsMaterial.frictionCombine = data.frictionCombine;
|
|
6521
|
+
return physicsMaterial;
|
|
6522
|
+
});
|
|
6523
|
+
};
|
|
6524
|
+
return PhysicsMaterialLoader;
|
|
6525
|
+
}(Loader);
|
|
6526
|
+
PhysicsMaterialLoader = __decorate([
|
|
6527
|
+
resourceLoader(AssetType.PhysicsMaterial, [
|
|
6528
|
+
"mesh"
|
|
6529
|
+
])
|
|
6530
|
+
], PhysicsMaterialLoader);
|
|
6531
|
+
|
|
6472
6532
|
var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
6473
6533
|
_inherits(SceneLoader, Loader);
|
|
6474
6534
|
function SceneLoader() {
|
|
@@ -6576,28 +6636,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6576
6636
|
// Post Process
|
|
6577
6637
|
var postProcessData = data.scene.postProcess;
|
|
6578
6638
|
if (postProcessData) {
|
|
6579
|
-
|
|
6580
|
-
var postProcessManager = scene._postProcessManager;
|
|
6581
|
-
var bloomEffect = postProcessManager._bloomEffect;
|
|
6582
|
-
var tonemappingEffect = postProcessManager._tonemappingEffect;
|
|
6583
|
-
postProcessManager.isActive = postProcessData.isActive;
|
|
6584
|
-
bloomEffect.enabled = postProcessData.bloom.enabled;
|
|
6585
|
-
bloomEffect.downScale = postProcessData.bloom.downScale;
|
|
6586
|
-
bloomEffect.threshold = postProcessData.bloom.threshold;
|
|
6587
|
-
bloomEffect.scatter = postProcessData.bloom.scatter;
|
|
6588
|
-
bloomEffect.intensity = postProcessData.bloom.intensity;
|
|
6589
|
-
bloomEffect.tint.copyFrom(postProcessData.bloom.tint);
|
|
6590
|
-
bloomEffect.dirtIntensity = postProcessData.bloom.dirtIntensity;
|
|
6591
|
-
tonemappingEffect.enabled = postProcessData.tonemapping.enabled;
|
|
6592
|
-
tonemappingEffect.mode = postProcessData.tonemapping.mode;
|
|
6593
|
-
if (postProcessData.bloom.dirtTexture) {
|
|
6594
|
-
// @ts-ignore
|
|
6595
|
-
// prettier-ignore
|
|
6596
|
-
var dirtTexturePromise = resourceManager.getResourceByRef(postProcessData.bloom.dirtTexture).then(function(texture) {
|
|
6597
|
-
bloomEffect.dirtTexture = texture;
|
|
6598
|
-
});
|
|
6599
|
-
promises.push(dirtTexturePromise);
|
|
6600
|
-
}
|
|
6639
|
+
Logger.warn("Post Process is not supported in scene yet, please add PostProcess component in entity instead.");
|
|
6601
6640
|
}
|
|
6602
6641
|
return Promise.all(promises).then(function() {
|
|
6603
6642
|
resolve(scene);
|
|
@@ -6792,6 +6831,28 @@ KHR_materials_sheen = __decorate([
|
|
|
6792
6831
|
registerGLTFExtension("KHR_materials_sheen", GLTFExtensionMode.AdditiveParse)
|
|
6793
6832
|
], KHR_materials_sheen);
|
|
6794
6833
|
|
|
6834
|
+
var KHR_materials_transmission = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6835
|
+
_inherits(KHR_materials_transmission, GLTFExtensionParser);
|
|
6836
|
+
function KHR_materials_transmission() {
|
|
6837
|
+
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
6838
|
+
}
|
|
6839
|
+
var _proto = KHR_materials_transmission.prototype;
|
|
6840
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
6841
|
+
var _schema_transmissionFactor = schema.transmissionFactor, transmissionFactor = _schema_transmissionFactor === void 0 ? 0 : _schema_transmissionFactor, transmissionTexture = schema.transmissionTexture;
|
|
6842
|
+
material.transmission = transmissionFactor;
|
|
6843
|
+
if (transmissionTexture) {
|
|
6844
|
+
GLTFMaterialParser._checkOtherTextureTransform(transmissionTexture, "Transmission texture");
|
|
6845
|
+
context.get(GLTFParserType.Texture, transmissionTexture.index).then(function(texture) {
|
|
6846
|
+
material.transmissionTexture = texture;
|
|
6847
|
+
});
|
|
6848
|
+
}
|
|
6849
|
+
};
|
|
6850
|
+
return KHR_materials_transmission;
|
|
6851
|
+
}(GLTFExtensionParser);
|
|
6852
|
+
KHR_materials_transmission = __decorate([
|
|
6853
|
+
registerGLTFExtension("KHR_materials_transmission", GLTFExtensionMode.AdditiveParse)
|
|
6854
|
+
], KHR_materials_transmission);
|
|
6855
|
+
|
|
6795
6856
|
var KHR_materials_unlit = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6796
6857
|
_inherits(KHR_materials_unlit, GLTFExtensionParser);
|
|
6797
6858
|
function KHR_materials_unlit() {
|
|
@@ -6844,6 +6905,32 @@ KHR_materials_variants = __decorate([
|
|
|
6844
6905
|
registerGLTFExtension("KHR_materials_variants", GLTFExtensionMode.AdditiveParse)
|
|
6845
6906
|
], KHR_materials_variants);
|
|
6846
6907
|
|
|
6908
|
+
var KHR_materials_volume = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6909
|
+
_inherits(KHR_materials_volume, GLTFExtensionParser);
|
|
6910
|
+
function KHR_materials_volume() {
|
|
6911
|
+
return GLTFExtensionParser.apply(this, arguments) || this;
|
|
6912
|
+
}
|
|
6913
|
+
var _proto = KHR_materials_volume.prototype;
|
|
6914
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
6915
|
+
var _schema_thicknessFactor = schema.thicknessFactor, thicknessFactor = _schema_thicknessFactor === void 0 ? 0 : _schema_thicknessFactor, thicknessTexture = schema.thicknessTexture, _schema_attenuationDistance = schema.attenuationDistance, attenuationDistance = _schema_attenuationDistance === void 0 ? Infinity : _schema_attenuationDistance, attenuationColor = schema.attenuationColor;
|
|
6916
|
+
material.thickness = thicknessFactor;
|
|
6917
|
+
material.attenuationDistance = attenuationDistance;
|
|
6918
|
+
if (attenuationColor) {
|
|
6919
|
+
material.attenuationColor.set(Color.linearToGammaSpace(attenuationColor[0]), Color.linearToGammaSpace(attenuationColor[1]), Color.linearToGammaSpace(attenuationColor[2]), undefined);
|
|
6920
|
+
}
|
|
6921
|
+
if (thicknessTexture) {
|
|
6922
|
+
GLTFMaterialParser._checkOtherTextureTransform(thicknessTexture, "Thickness texture");
|
|
6923
|
+
context.get(GLTFParserType.Texture, thicknessTexture.index).then(function(texture) {
|
|
6924
|
+
material.thicknessTexture = texture;
|
|
6925
|
+
});
|
|
6926
|
+
}
|
|
6927
|
+
};
|
|
6928
|
+
return KHR_materials_volume;
|
|
6929
|
+
}(GLTFExtensionParser);
|
|
6930
|
+
KHR_materials_volume = __decorate([
|
|
6931
|
+
registerGLTFExtension("KHR_materials_volume", GLTFExtensionMode.AdditiveParse)
|
|
6932
|
+
], KHR_materials_volume);
|
|
6933
|
+
|
|
6847
6934
|
var KHR_mesh_quantization = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
6848
6935
|
_inherits(KHR_mesh_quantization, GLTFExtensionParser);
|
|
6849
6936
|
function KHR_mesh_quantization() {
|