@galacean/engine-loader 1.1.0-alpha.2 → 1.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js
CHANGED
|
@@ -680,6 +680,8 @@ exports.InterpolableValueType = void 0;
|
|
|
680
680
|
InterpolableValueType[InterpolableValueType["Color"] = 6] = "Color";
|
|
681
681
|
InterpolableValueType[InterpolableValueType["Array"] = 7] = "Array";
|
|
682
682
|
InterpolableValueType[InterpolableValueType["Boolean"] = 8] = "Boolean";
|
|
683
|
+
InterpolableValueType[InterpolableValueType["Rect"] = 9] = "Rect";
|
|
684
|
+
InterpolableValueType[InterpolableValueType["ReferResource"] = 10] = "ReferResource";
|
|
683
685
|
})(exports.InterpolableValueType || (exports.InterpolableValueType = {}));
|
|
684
686
|
exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
685
687
|
function AnimationClipDecoder() {}
|
|
@@ -708,7 +710,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
708
710
|
switch(curveType){
|
|
709
711
|
case "AnimationFloatCurve":
|
|
710
712
|
{
|
|
711
|
-
curve =
|
|
713
|
+
curve = new engineCore.AnimationFloatCurve();
|
|
712
714
|
curve.interpolation = interpolation;
|
|
713
715
|
for(var j = 0; j < keysLen; ++j){
|
|
714
716
|
var keyframe = new engineCore.Keyframe();
|
|
@@ -722,7 +724,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
722
724
|
}
|
|
723
725
|
case "AnimationArrayCurve":
|
|
724
726
|
{
|
|
725
|
-
curve =
|
|
727
|
+
curve = new engineCore.AnimationArrayCurve();
|
|
726
728
|
curve.interpolation = interpolation;
|
|
727
729
|
for(var j1 = 0; j1 < keysLen; ++j1){
|
|
728
730
|
var keyframe1 = new engineCore.Keyframe();
|
|
@@ -737,7 +739,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
737
739
|
}
|
|
738
740
|
case "AnimationFloatArrayCurve":
|
|
739
741
|
{
|
|
740
|
-
curve =
|
|
742
|
+
curve = new engineCore.AnimationFloatArrayCurve();
|
|
741
743
|
curve.interpolation = interpolation;
|
|
742
744
|
for(var j2 = 0; j2 < keysLen; ++j2){
|
|
743
745
|
var keyframe2 = new engineCore.Keyframe();
|
|
@@ -752,7 +754,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
752
754
|
}
|
|
753
755
|
case "AnimationVector2Curve":
|
|
754
756
|
{
|
|
755
|
-
curve =
|
|
757
|
+
curve = new engineCore.AnimationVector2Curve();
|
|
756
758
|
curve.interpolation = interpolation;
|
|
757
759
|
for(var j3 = 0; j3 < keysLen; ++j3){
|
|
758
760
|
var keyframe3 = new engineCore.Keyframe();
|
|
@@ -766,7 +768,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
766
768
|
}
|
|
767
769
|
case "AnimationVector3Curve":
|
|
768
770
|
{
|
|
769
|
-
curve =
|
|
771
|
+
curve = new engineCore.AnimationVector3Curve();
|
|
770
772
|
curve.interpolation = interpolation;
|
|
771
773
|
for(var j4 = 0; j4 < keysLen; ++j4){
|
|
772
774
|
var keyframe4 = new engineCore.Keyframe();
|
|
@@ -780,7 +782,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
780
782
|
}
|
|
781
783
|
case "AnimationVector4Curve":
|
|
782
784
|
{
|
|
783
|
-
curve =
|
|
785
|
+
curve = new engineCore.AnimationVector4Curve();
|
|
784
786
|
curve.interpolation = interpolation;
|
|
785
787
|
var keyframe5 = new engineCore.Keyframe();
|
|
786
788
|
keyframe5.time = bufferReader.nextFloat32();
|
|
@@ -792,7 +794,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
792
794
|
}
|
|
793
795
|
case "AnimationColorCurve":
|
|
794
796
|
{
|
|
795
|
-
curve =
|
|
797
|
+
curve = new engineCore.AnimationColorCurve();
|
|
796
798
|
curve.interpolation = interpolation;
|
|
797
799
|
for(var j5 = 0; j5 < keysLen; ++j5){
|
|
798
800
|
var keyframe6 = new engineCore.Keyframe();
|
|
@@ -806,7 +808,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
806
808
|
}
|
|
807
809
|
case "AnimationQuaternionCurve":
|
|
808
810
|
{
|
|
809
|
-
curve =
|
|
811
|
+
curve = new engineCore.AnimationQuaternionCurve();
|
|
810
812
|
curve.interpolation = interpolation;
|
|
811
813
|
for(var j6 = 0; j6 < keysLen; ++j6){
|
|
812
814
|
var keyframe7 = new engineCore.Keyframe();
|
|
@@ -818,6 +820,18 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
818
820
|
}
|
|
819
821
|
break;
|
|
820
822
|
}
|
|
823
|
+
case "AnimationRefCurve":
|
|
824
|
+
{
|
|
825
|
+
curve = new engineCore.AnimationRefCurve();
|
|
826
|
+
curve.interpolation = interpolation;
|
|
827
|
+
for(var j7 = 0; j7 < keysLen; ++j7){
|
|
828
|
+
var keyframe8 = new engineCore.Keyframe();
|
|
829
|
+
keyframe8.time = bufferReader.nextFloat32();
|
|
830
|
+
keyframe8.value = JSON.parse(bufferReader.nextStr());
|
|
831
|
+
curve.addKey(keyframe8);
|
|
832
|
+
}
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
821
835
|
}
|
|
822
836
|
clip.addCurveBinding(relativePath, componentType, property, curve);
|
|
823
837
|
}
|
|
@@ -1065,7 +1079,27 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader) {
|
|
|
1065
1079
|
_this.request(item.url, _extends({}, item, {
|
|
1066
1080
|
type: "arraybuffer"
|
|
1067
1081
|
})).then(function(data) {
|
|
1068
|
-
return decode(data, resourceManager.engine).then(
|
|
1082
|
+
return decode(data, resourceManager.engine).then(function(clip) {
|
|
1083
|
+
var curveBindingPromises = clip.curveBindings.map(function(curveBinding) {
|
|
1084
|
+
var curve = curveBinding.curve;
|
|
1085
|
+
var promises = curve.keys.map(function(key) {
|
|
1086
|
+
var value = key.value;
|
|
1087
|
+
if (typeof value === "object" && value.refId) {
|
|
1088
|
+
return new Promise(function(resolve) {
|
|
1089
|
+
resourceManager// @ts-ignore
|
|
1090
|
+
.getResourceByRef(value).then(function(asset) {
|
|
1091
|
+
key.value = asset;
|
|
1092
|
+
resolve(key);
|
|
1093
|
+
}).catch(reject);
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
return Promise.all(promises);
|
|
1098
|
+
});
|
|
1099
|
+
return Promise.all(curveBindingPromises).then(function() {
|
|
1100
|
+
resolve(clip);
|
|
1101
|
+
});
|
|
1102
|
+
});
|
|
1069
1103
|
}).catch(reject);
|
|
1070
1104
|
});
|
|
1071
1105
|
};
|
|
@@ -3607,16 +3641,16 @@ exports.GLTFBufferParser = __decorate([
|
|
|
3607
3641
|
registerGLTFParser(exports.GLTFParserType.Buffer)
|
|
3608
3642
|
], exports.GLTFBufferParser);
|
|
3609
3643
|
|
|
3610
|
-
exports.GLTFEntityParser = /*#__PURE__*/ function(
|
|
3611
|
-
_inherits(GLTFEntityParser,
|
|
3644
|
+
exports.GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
3645
|
+
_inherits(GLTFEntityParser, GLTFParser1);
|
|
3612
3646
|
function GLTFEntityParser() {
|
|
3613
|
-
return
|
|
3647
|
+
return GLTFParser1.apply(this, arguments);
|
|
3614
3648
|
}
|
|
3615
3649
|
var _proto = GLTFEntityParser.prototype;
|
|
3616
3650
|
_proto.parse = function parse(context, index) {
|
|
3617
3651
|
var entityInfo = context.glTF.nodes[index];
|
|
3618
3652
|
var engine = context.glTFResource.engine;
|
|
3619
|
-
var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale;
|
|
3653
|
+
var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
|
|
3620
3654
|
var entity = new engineCore.Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
|
|
3621
3655
|
var transform = entity.transform;
|
|
3622
3656
|
if (matrix) {
|
|
@@ -3642,6 +3676,7 @@ exports.GLTFEntityParser = /*#__PURE__*/ function(GLTFParser) {
|
|
|
3642
3676
|
entity.addChild(childEntity);
|
|
3643
3677
|
}
|
|
3644
3678
|
}
|
|
3679
|
+
GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, entity, entityInfo);
|
|
3645
3680
|
return entity;
|
|
3646
3681
|
};
|
|
3647
3682
|
return GLTFEntityParser;
|
|
@@ -4040,7 +4075,7 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4040
4075
|
var _this = this;
|
|
4041
4076
|
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
4042
4077
|
var entityInfo = glTF.nodes[index];
|
|
4043
|
-
var cameraID = entityInfo.camera, meshID = entityInfo.mesh
|
|
4078
|
+
var cameraID = entityInfo.camera, meshID = entityInfo.mesh;
|
|
4044
4079
|
var entity = context.get(exports.GLTFParserType.Entity, index);
|
|
4045
4080
|
var promise;
|
|
4046
4081
|
if (cameraID !== undefined) {
|
|
@@ -4057,7 +4092,6 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4057
4092
|
promises.push(_this._parseEntityComponent(context, children[i]));
|
|
4058
4093
|
}
|
|
4059
4094
|
}
|
|
4060
|
-
GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, entity, entityInfo);
|
|
4061
4095
|
return Promise.all(promises);
|
|
4062
4096
|
});
|
|
4063
4097
|
};
|
|
@@ -5433,8 +5467,6 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
5433
5467
|
_this.request(item.url, {
|
|
5434
5468
|
type: "json"
|
|
5435
5469
|
}).then(function(data) {
|
|
5436
|
-
// @ts-ignore
|
|
5437
|
-
engine.resourceManager.initVirtualResources(data.files);
|
|
5438
5470
|
return SceneParser.parse(engine, data).then(function(scene) {
|
|
5439
5471
|
var promises = [];
|
|
5440
5472
|
// parse ambient light
|
|
@@ -5462,6 +5494,10 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
|
5462
5494
|
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5463
5495
|
});
|
|
5464
5496
|
promises.push(ambientLightPromise);
|
|
5497
|
+
} else {
|
|
5498
|
+
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5499
|
+
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5500
|
+
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5465
5501
|
}
|
|
5466
5502
|
var background = data.scene.background;
|
|
5467
5503
|
scene.background.mode = background.mode;
|