@galacean/effects-plugin-model 2.0.0-alpha.18 → 2.0.0-alpha.19
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/alipay.js +1147 -96
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +1141 -97
- package/dist/alipay.mjs.map +1 -1
- package/dist/gltf/index.d.ts +1 -0
- package/dist/gltf/loader-ecs-ext.d.ts +4 -2
- package/dist/gltf/loader-ecs.d.ts +9 -3
- package/dist/gltf/loader-ext.d.ts +1 -1
- package/dist/gltf/protocol.d.ts +1 -1
- package/dist/index.js +1148 -97
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +1142 -98
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +1142 -98
- package/dist/loader.mjs.map +1 -1
- package/dist/runtime/material.d.ts +11 -17
- package/dist/runtime/scene.d.ts +2 -1
- package/dist/utility/plugin-helper.d.ts +3 -3
- package/package.json +5 -5
package/dist/alipay.js
CHANGED
|
@@ -3136,7 +3136,7 @@ function _assert_this_initialized(self) {
|
|
|
3136
3136
|
});
|
|
3137
3137
|
}
|
|
3138
3138
|
var proxy = new HitTestingProxy();
|
|
3139
|
-
var doubleSided = this.material.
|
|
3139
|
+
var doubleSided = this.material.isBothSide();
|
|
3140
3140
|
proxy.create(this.geometry.geometry, doubleSided, bindMatrices);
|
|
3141
3141
|
return proxy.getHitPoint(newOrigin, newDirection);
|
|
3142
3142
|
};
|
|
@@ -3277,8 +3277,7 @@ function _assert_this_initialized(self) {
|
|
|
3277
3277
|
material.setVector3("_shCoefficients." + n, Vector3.fromArray(coeffs[i]));
|
|
3278
3278
|
});
|
|
3279
3279
|
}
|
|
3280
|
-
|
|
3281
|
-
material.setInt("_MipCount", (_skybox_specularMipCount = skybox.specularMipCount) != null ? _skybox_specularMipCount : 1);
|
|
3280
|
+
material.setInt("_MipCount", skybox.specularMipCount - 1);
|
|
3282
3281
|
material.setTexture("_SpecularEnvSampler", skybox.specularImage);
|
|
3283
3282
|
}
|
|
3284
3283
|
}
|
|
@@ -3784,9 +3783,9 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3784
3783
|
maxLightCount: this.maxLightCount,
|
|
3785
3784
|
skybox: this.skybox
|
|
3786
3785
|
};
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3786
|
+
if (this.enableDynamicSort) {
|
|
3787
|
+
this.dynamicSortMeshes(this.sceneStates);
|
|
3788
|
+
}
|
|
3790
3789
|
this.tickCount += 1;
|
|
3791
3790
|
this.lastTickSecond += deltaSeconds;
|
|
3792
3791
|
};
|
|
@@ -3795,12 +3794,14 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3795
3794
|
* 主要是为了和 Tiny 渲染对齐,正常渲染不进行调整
|
|
3796
3795
|
* @param states - 场景中的状态数据
|
|
3797
3796
|
*/ _proto.dynamicSortMeshes = function dynamicSortMeshes(states) {
|
|
3798
|
-
var
|
|
3797
|
+
var meshComponents = [];
|
|
3799
3798
|
var priorityList = [];
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3799
|
+
this.meshList.forEach(function(mesh) {
|
|
3800
|
+
if (mesh.owner && mesh.owner.enabled) {
|
|
3801
|
+
var component = mesh.owner;
|
|
3802
|
+
meshComponents.push(component);
|
|
3803
|
+
priorityList.push(component.priority);
|
|
3804
|
+
}
|
|
3804
3805
|
});
|
|
3805
3806
|
priorityList.sort(function(a, b) {
|
|
3806
3807
|
return a - b;
|
|
@@ -3808,26 +3809,30 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3808
3809
|
// 按照 Tiny 排序算法,对 Mesh 对象进行排序
|
|
3809
3810
|
// 将透明和不透明物体拆开,从而渲染正确
|
|
3810
3811
|
var viewMatrix = states.viewMatrix;
|
|
3811
|
-
|
|
3812
|
+
meshComponents.sort(function(a, b) {
|
|
3812
3813
|
var atransparent = WebGLHelper.isTransparentMesh(a);
|
|
3813
3814
|
var btransparent = WebGLHelper.isTransparentMesh(b);
|
|
3814
3815
|
if (atransparent && btransparent) {
|
|
3815
|
-
var aposition =
|
|
3816
|
-
var bposition =
|
|
3816
|
+
var aposition = a.transform.getWorldPosition();
|
|
3817
|
+
var bposition = b.transform.getWorldPosition();
|
|
3817
3818
|
var anewPos = viewMatrix.transformPoint(aposition);
|
|
3818
3819
|
var bnewPos = viewMatrix.transformPoint(bposition);
|
|
3819
|
-
|
|
3820
|
+
if (anewPos.z === bnewPos.z) {
|
|
3821
|
+
return a.priority - b.priority;
|
|
3822
|
+
} else {
|
|
3823
|
+
return anewPos.z - bnewPos.z;
|
|
3824
|
+
}
|
|
3820
3825
|
} else if (atransparent) {
|
|
3821
3826
|
return 1;
|
|
3822
3827
|
} else if (btransparent) {
|
|
3823
3828
|
return -1;
|
|
3824
3829
|
} else {
|
|
3825
|
-
return
|
|
3830
|
+
return a.priority - b.priority;
|
|
3826
3831
|
}
|
|
3827
3832
|
});
|
|
3828
3833
|
// 重新赋值渲染优先级
|
|
3829
|
-
for(var i = 0; i <
|
|
3830
|
-
var mesh =
|
|
3834
|
+
for(var i = 0; i < meshComponents.length; i++){
|
|
3835
|
+
var mesh = meshComponents[i];
|
|
3831
3836
|
var priority = priorityList[i];
|
|
3832
3837
|
mesh.priority = priority;
|
|
3833
3838
|
}
|
|
@@ -3972,7 +3977,7 @@ var StandardShaderSource;
|
|
|
3972
3977
|
if (isWebGL2) {
|
|
3973
3978
|
return "#version 300 es\n" + source;
|
|
3974
3979
|
} else {
|
|
3975
|
-
return
|
|
3980
|
+
return source;
|
|
3976
3981
|
}
|
|
3977
3982
|
}
|
|
3978
3983
|
/**
|
|
@@ -3990,7 +3995,7 @@ var StandardShaderSource;
|
|
|
3990
3995
|
if (isWebGL2) {
|
|
3991
3996
|
return "#version 300 es\n" + source;
|
|
3992
3997
|
}
|
|
3993
|
-
return
|
|
3998
|
+
return source;
|
|
3994
3999
|
}
|
|
3995
4000
|
StandardShaderSource.getSourceCode = getSourceCode;
|
|
3996
4001
|
})(StandardShaderSource || (StandardShaderSource = {}));
|
|
@@ -4718,7 +4723,8 @@ exports.ModelCameraComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
4718
4723
|
/**
|
|
4719
4724
|
* 组件销毁
|
|
4720
4725
|
*/ _proto.onDestroy = function onDestroy() {
|
|
4721
|
-
|
|
4726
|
+
var _this_content;
|
|
4727
|
+
(_this_content = this.content) == null ? void 0 : _this_content.dispose();
|
|
4722
4728
|
};
|
|
4723
4729
|
/**
|
|
4724
4730
|
* 反序列化,记录传入参数
|
|
@@ -4835,29 +4841,25 @@ var ModelAnimationClip = /*#__PURE__*/ function(AnimationClip) {
|
|
|
4835
4841
|
var life = Math.max(0, time) % duration;
|
|
4836
4842
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.positionCurves), _step; !(_step = _iterator()).done;){
|
|
4837
4843
|
var curve = _step.value;
|
|
4838
|
-
var
|
|
4839
|
-
var value = curve.keyFrames.getValue(life % maxTime);
|
|
4844
|
+
var value = curve.keyFrames.getValue(life % this.duration);
|
|
4840
4845
|
var target = this.getTargetItem(vfxItem, curve.path);
|
|
4841
4846
|
target == null ? void 0 : target.transform.setPosition(value.x, value.y, value.z);
|
|
4842
4847
|
}
|
|
4843
4848
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.rotationCurves), _step1; !(_step1 = _iterator1()).done;){
|
|
4844
4849
|
var curve1 = _step1.value;
|
|
4845
|
-
var
|
|
4846
|
-
var value1 = curve1.keyFrames.getValue(life % maxTime1);
|
|
4850
|
+
var value1 = curve1.keyFrames.getValue(life % this.duration);
|
|
4847
4851
|
var target1 = this.getTargetItem(vfxItem, curve1.path);
|
|
4848
4852
|
target1 == null ? void 0 : target1.transform.setQuaternion(value1.x, value1.y, value1.z, value1.w);
|
|
4849
4853
|
}
|
|
4850
4854
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(this.scaleCurves), _step2; !(_step2 = _iterator2()).done;){
|
|
4851
4855
|
var curve2 = _step2.value;
|
|
4852
|
-
var
|
|
4853
|
-
var value2 = curve2.keyFrames.getValue(life % maxTime2);
|
|
4856
|
+
var value2 = curve2.keyFrames.getValue(life % this.duration);
|
|
4854
4857
|
var target2 = this.getTargetItem(vfxItem, curve2.path);
|
|
4855
4858
|
target2 == null ? void 0 : target2.transform.setScale(value2.x, value2.y, value2.z);
|
|
4856
4859
|
}
|
|
4857
4860
|
for(var _iterator3 = _create_for_of_iterator_helper_loose(this.floatCurves), _step3; !(_step3 = _iterator3()).done;){
|
|
4858
4861
|
var curve3 = _step3.value;
|
|
4859
|
-
var
|
|
4860
|
-
var value3 = curve3.keyFrames.getValue(life % maxTime3);
|
|
4862
|
+
var value3 = curve3.keyFrames.getValue(life % this.duration);
|
|
4861
4863
|
var target3 = this.getTargetItem(vfxItem, curve3.path);
|
|
4862
4864
|
if (curve3.className === "ModelMeshComponent") {
|
|
4863
4865
|
var component = target3 == null ? void 0 : target3.getComponent(exports.ModelMeshComponent);
|
|
@@ -4873,6 +4875,7 @@ var ModelAnimationClip = /*#__PURE__*/ function(AnimationClip) {
|
|
|
4873
4875
|
}
|
|
4874
4876
|
};
|
|
4875
4877
|
_proto.setFromAnimationClip = function setFromAnimationClip(clip) {
|
|
4878
|
+
this.duration = clip.duration;
|
|
4876
4879
|
this.positionCurves = clip.positionCurves.slice();
|
|
4877
4880
|
this.rotationCurves = clip.rotationCurves.slice();
|
|
4878
4881
|
this.scaleCurves = clip.scaleCurves.slice();
|
|
@@ -5628,10 +5631,10 @@ var normal = new Vector3();
|
|
|
5628
5631
|
};
|
|
5629
5632
|
/**
|
|
5630
5633
|
* 返回 Mesh 是否半透明
|
|
5631
|
-
* @param
|
|
5634
|
+
* @param component - ModelMeshComponent 对象
|
|
5632
5635
|
* @return 是否半透明
|
|
5633
|
-
*/ WebGLHelper.isTransparentMesh = function isTransparentMesh(
|
|
5634
|
-
return
|
|
5636
|
+
*/ WebGLHelper.isTransparentMesh = function isTransparentMesh(component) {
|
|
5637
|
+
return component.material.blending === true;
|
|
5635
5638
|
};
|
|
5636
5639
|
/**
|
|
5637
5640
|
* renderer 是否支持 Float 纹理
|
|
@@ -6093,10 +6096,17 @@ var normal = new Vector3();
|
|
|
6093
6096
|
texOptions.wrapT = EFFECTS.glContext.REPEAT;
|
|
6094
6097
|
texOptions.magFilter = EFFECTS.glContext.LINEAR;
|
|
6095
6098
|
texOptions.minFilter = EFFECTS.glContext.LINEAR_MIPMAP_LINEAR;
|
|
6096
|
-
texOptions.generateMipmap = true;
|
|
6097
6099
|
if (!isBaseColor) {
|
|
6098
6100
|
texOptions.premultiplyAlpha = true;
|
|
6099
6101
|
}
|
|
6102
|
+
var newOptions = texOptions;
|
|
6103
|
+
newOptions.generateMipmap = true;
|
|
6104
|
+
var image = newOptions.image;
|
|
6105
|
+
if (image && image.width && image.height) {
|
|
6106
|
+
if (!WebGLHelper.isPow2(image.width) || !WebGLHelper.isPow2(image.height)) {
|
|
6107
|
+
texOptions.minFilter = EFFECTS.glContext.LINEAR;
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6100
6110
|
} else if (texOptions.target === EFFECTS.glContext.TEXTURE_CUBE_MAP) {
|
|
6101
6111
|
texOptions.wrapS = EFFECTS.glContext.CLAMP_TO_EDGE;
|
|
6102
6112
|
texOptions.wrapT = EFFECTS.glContext.CLAMP_TO_EDGE;
|
|
@@ -7795,18 +7805,6 @@ var toHalf = function() {
|
|
|
7795
7805
|
};
|
|
7796
7806
|
}();
|
|
7797
7807
|
|
|
7798
|
-
exports.RenderType = void 0;
|
|
7799
|
-
(function(RenderType) {
|
|
7800
|
-
RenderType["Opaque"] = "Opaque";
|
|
7801
|
-
RenderType["Mask"] = "Mask";
|
|
7802
|
-
RenderType["Blend"] = "Blend";
|
|
7803
|
-
})(exports.RenderType || (exports.RenderType = {}));
|
|
7804
|
-
exports.CullMode = void 0;
|
|
7805
|
-
(function(CullMode) {
|
|
7806
|
-
CullMode["Front"] = "Front";
|
|
7807
|
-
CullMode["Back"] = "Back";
|
|
7808
|
-
CullMode["Double"] = "Double";
|
|
7809
|
-
})(exports.CullMode || (exports.CullMode = {}));
|
|
7810
7808
|
/**
|
|
7811
7809
|
* 3D 材质基础类,支持公共的材质功能
|
|
7812
7810
|
*/ var PMaterialBase = /*#__PURE__*/ function(PObject) {
|
|
@@ -7831,13 +7829,16 @@ exports.CullMode = void 0;
|
|
|
7831
7829
|
*/ _this.ZTest = true;
|
|
7832
7830
|
/**
|
|
7833
7831
|
* 渲染类型,默认是不透明
|
|
7834
|
-
*/ _this.renderType =
|
|
7832
|
+
*/ _this.renderType = EFFECTS.spec.RenderType.Opaque;
|
|
7833
|
+
/**
|
|
7834
|
+
* 是否 Alpha 裁剪,默认关闭
|
|
7835
|
+
*/ _this.alphaClip = false;
|
|
7835
7836
|
/**
|
|
7836
7837
|
* Alpha 测试截断值
|
|
7837
|
-
*/ _this.
|
|
7838
|
+
*/ _this.alphaCutoff = 0.5;
|
|
7838
7839
|
/**
|
|
7839
7840
|
* 面侧模式,默认是正面
|
|
7840
|
-
*/ _this.
|
|
7841
|
+
*/ _this.renderFace = EFFECTS.spec.RenderFace.Front;
|
|
7841
7842
|
return _this;
|
|
7842
7843
|
}
|
|
7843
7844
|
var _proto = PMaterialBase.prototype;
|
|
@@ -7846,28 +7847,28 @@ exports.CullMode = void 0;
|
|
|
7846
7847
|
* @returns 特性列表
|
|
7847
7848
|
*/ _proto.getShaderFeatures = function getShaderFeatures() {
|
|
7848
7849
|
var featureList = [];
|
|
7849
|
-
if (this.
|
|
7850
|
-
featureList.push("ALPHAMODE_OPAQUE 1");
|
|
7851
|
-
} else if (this.isMasked()) {
|
|
7850
|
+
if (this.isAlphaClip()) {
|
|
7852
7851
|
featureList.push("ALPHAMODE_MASK 1");
|
|
7852
|
+
} else if (this.isOpaque()) {
|
|
7853
|
+
featureList.push("ALPHAMODE_OPAQUE 1");
|
|
7853
7854
|
}
|
|
7854
|
-
if (this.
|
|
7855
|
+
if (this.renderFace === EFFECTS.spec.RenderFace.Both) {
|
|
7855
7856
|
featureList.push("DOUBLE_SIDED 1");
|
|
7856
7857
|
}
|
|
7857
7858
|
return featureList;
|
|
7858
7859
|
};
|
|
7859
7860
|
_proto.getShaderMacros = function getShaderMacros() {
|
|
7860
7861
|
var macroList = [];
|
|
7861
|
-
if (this.
|
|
7862
|
+
if (this.isAlphaClip()) {
|
|
7862
7863
|
macroList.push({
|
|
7863
|
-
name: "
|
|
7864
|
+
name: "ALPHAMODE_MASK"
|
|
7864
7865
|
});
|
|
7865
|
-
} else if (this.
|
|
7866
|
+
} else if (this.isOpaque()) {
|
|
7866
7867
|
macroList.push({
|
|
7867
|
-
name: "
|
|
7868
|
+
name: "ALPHAMODE_OPAQUE"
|
|
7868
7869
|
});
|
|
7869
7870
|
}
|
|
7870
|
-
if (this.
|
|
7871
|
+
if (this.renderFace === EFFECTS.spec.RenderFace.Both) {
|
|
7871
7872
|
macroList.push({
|
|
7872
7873
|
name: "DOUBLE_SIDED"
|
|
7873
7874
|
});
|
|
@@ -7950,7 +7951,7 @@ exports.CullMode = void 0;
|
|
|
7950
7951
|
* 设置材质状态,根据 GE 材质状态
|
|
7951
7952
|
* @param material - GE 材质
|
|
7952
7953
|
*/ _proto.setMaterialStates = function setMaterialStates(material) {
|
|
7953
|
-
if (this.renderType ===
|
|
7954
|
+
if (this.renderType === EFFECTS.spec.RenderType.Transparent) {
|
|
7954
7955
|
material.blending = true;
|
|
7955
7956
|
material.depthTest = this.ZTest;
|
|
7956
7957
|
material.depthMask = this.ZWrite;
|
|
@@ -7979,7 +7980,7 @@ exports.CullMode = void 0;
|
|
|
7979
7980
|
this.setFaceSideStates(material);
|
|
7980
7981
|
};
|
|
7981
7982
|
_proto.setFaceSideStates = function setFaceSideStates(material) {
|
|
7982
|
-
if (this.
|
|
7983
|
+
if (this.isBothSide()) {
|
|
7983
7984
|
material.culling = false;
|
|
7984
7985
|
} else if (this.isBackSide()) {
|
|
7985
7986
|
material.cullFace = EFFECTS.glContext.FRONT;
|
|
@@ -8007,37 +8008,37 @@ exports.CullMode = void 0;
|
|
|
8007
8008
|
* 是否不透明
|
|
8008
8009
|
* @returns
|
|
8009
8010
|
*/ _proto.isOpaque = function isOpaque() {
|
|
8010
|
-
return this.renderType ===
|
|
8011
|
+
return this.renderType === EFFECTS.spec.RenderType.Opaque;
|
|
8011
8012
|
};
|
|
8012
8013
|
/**
|
|
8013
|
-
*
|
|
8014
|
+
* 是否 Alpha 裁剪
|
|
8014
8015
|
* @returns
|
|
8015
|
-
*/ _proto.
|
|
8016
|
-
return this.
|
|
8016
|
+
*/ _proto.isAlphaClip = function isAlphaClip() {
|
|
8017
|
+
return this.alphaClip;
|
|
8017
8018
|
};
|
|
8018
8019
|
/**
|
|
8019
8020
|
* 是否半透明
|
|
8020
8021
|
* @returns
|
|
8021
|
-
*/ _proto.
|
|
8022
|
-
return this.renderType ===
|
|
8022
|
+
*/ _proto.isTransparent = function isTransparent() {
|
|
8023
|
+
return this.renderType === EFFECTS.spec.RenderType.Transparent;
|
|
8023
8024
|
};
|
|
8024
8025
|
/**
|
|
8025
8026
|
* 是否正面模式
|
|
8026
8027
|
* @returns
|
|
8027
8028
|
*/ _proto.isFrontSide = function isFrontSide() {
|
|
8028
|
-
return this.
|
|
8029
|
+
return this.renderFace === EFFECTS.spec.RenderFace.Front;
|
|
8029
8030
|
};
|
|
8030
8031
|
/**
|
|
8031
8032
|
* 是否背面模式
|
|
8032
8033
|
* @returns
|
|
8033
8034
|
*/ _proto.isBackSide = function isBackSide() {
|
|
8034
|
-
return this.
|
|
8035
|
+
return this.renderFace === EFFECTS.spec.RenderFace.Back;
|
|
8035
8036
|
};
|
|
8036
8037
|
/**
|
|
8037
8038
|
* 是否双面模式
|
|
8038
8039
|
* @returns
|
|
8039
|
-
*/ _proto.
|
|
8040
|
-
return this.
|
|
8040
|
+
*/ _proto.isBothSide = function isBothSide() {
|
|
8041
|
+
return this.renderFace === EFFECTS.spec.RenderFace.Both;
|
|
8041
8042
|
};
|
|
8042
8043
|
return PMaterialBase;
|
|
8043
8044
|
}(PObject);
|
|
@@ -8069,14 +8070,15 @@ exports.CullMode = void 0;
|
|
|
8069
8070
|
var _material_getColor;
|
|
8070
8071
|
this.baseColorFactor = (_material_getColor = material.getColor("_BaseColorFactor")) != null ? _material_getColor : new Color(1.0, 1.0, 1.0, 1.0);
|
|
8071
8072
|
//
|
|
8072
|
-
this.ZWrite = material.
|
|
8073
|
-
this.ZTest = material.
|
|
8073
|
+
this.ZWrite = material.getFloat("ZWrite") !== 0;
|
|
8074
|
+
this.ZTest = material.getFloat("ZTest") !== 0;
|
|
8074
8075
|
var _material_stringTags_RenderType;
|
|
8075
|
-
this.renderType = (_material_stringTags_RenderType = material.stringTags["RenderType"]) != null ? _material_stringTags_RenderType :
|
|
8076
|
+
this.renderType = (_material_stringTags_RenderType = material.stringTags["RenderType"]) != null ? _material_stringTags_RenderType : EFFECTS.spec.RenderType.Opaque;
|
|
8077
|
+
this.alphaClip = material.getFloat("AlphaClip") === 1;
|
|
8076
8078
|
var _material_getFloat;
|
|
8077
|
-
this.
|
|
8078
|
-
var
|
|
8079
|
-
this.
|
|
8079
|
+
this.alphaCutoff = (_material_getFloat = material.getFloat("_AlphaCutoff")) != null ? _material_getFloat : 0;
|
|
8080
|
+
var _material_stringTags_RenderFace;
|
|
8081
|
+
this.renderFace = (_material_stringTags_RenderFace = material.stringTags["RenderFace"]) != null ? _material_stringTags_RenderFace : EFFECTS.spec.RenderFace.Front;
|
|
8080
8082
|
};
|
|
8081
8083
|
/**
|
|
8082
8084
|
* 销毁材质
|
|
@@ -8244,14 +8246,15 @@ exports.CullMode = void 0;
|
|
|
8244
8246
|
var _material_getFloat4;
|
|
8245
8247
|
this.emissiveIntensity = (_material_getFloat4 = material.getFloat("_EmissiveIntensity")) != null ? _material_getFloat4 : 1;
|
|
8246
8248
|
//
|
|
8247
|
-
this.ZWrite = material.
|
|
8248
|
-
this.ZTest = material.
|
|
8249
|
+
this.ZWrite = material.getFloat("ZWrite") !== 0;
|
|
8250
|
+
this.ZTest = material.getFloat("ZTest") !== 0;
|
|
8249
8251
|
var _material_stringTags_RenderType;
|
|
8250
|
-
this.renderType = (_material_stringTags_RenderType = material.stringTags["RenderType"]) != null ? _material_stringTags_RenderType :
|
|
8252
|
+
this.renderType = (_material_stringTags_RenderType = material.stringTags["RenderType"]) != null ? _material_stringTags_RenderType : EFFECTS.spec.RenderType.Opaque;
|
|
8253
|
+
this.alphaClip = material.getFloat("AlphaClip") === 1;
|
|
8251
8254
|
var _material_getFloat5;
|
|
8252
|
-
this.
|
|
8253
|
-
var
|
|
8254
|
-
this.
|
|
8255
|
+
this.alphaCutoff = (_material_getFloat5 = material.getFloat("_AlphaCutoff")) != null ? _material_getFloat5 : 0;
|
|
8256
|
+
var _material_stringTags_RenderFace;
|
|
8257
|
+
this.renderFace = (_material_stringTags_RenderFace = material.stringTags["RenderFace"]) != null ? _material_stringTags_RenderFace : EFFECTS.spec.RenderFace.Front;
|
|
8255
8258
|
};
|
|
8256
8259
|
/**
|
|
8257
8260
|
* 销毁材质
|
|
@@ -8698,7 +8701,7 @@ exports.CullMode = void 0;
|
|
|
8698
8701
|
if (this.irradianceCoeffs === undefined && this.diffuseImage === undefined) {
|
|
8699
8702
|
return false;
|
|
8700
8703
|
}
|
|
8701
|
-
return this.specularImage !== undefined && this.specularMipCount
|
|
8704
|
+
return this.specularImage !== undefined && this.specularMipCount >= 0;
|
|
8702
8705
|
}
|
|
8703
8706
|
},
|
|
8704
8707
|
{
|
|
@@ -8825,7 +8828,7 @@ exports.CullMode = void 0;
|
|
|
8825
8828
|
material.setVector3("_shCoefficients." + n, Vector3.fromArray(coeffs[i]));
|
|
8826
8829
|
});
|
|
8827
8830
|
}
|
|
8828
|
-
material.setInt("_MipCount", this.specularMipCount);
|
|
8831
|
+
material.setInt("_MipCount", this.specularMipCount - 1);
|
|
8829
8832
|
material.setTexture("_SpecularEnvSampler", this.specularImage);
|
|
8830
8833
|
};
|
|
8831
8834
|
/**
|
|
@@ -9191,7 +9194,7 @@ exports.PSkyboxType = void 0;
|
|
|
9191
9194
|
diffuseImage: this.getDiffuseImageList(skyboxType, specularImage),
|
|
9192
9195
|
specularImage: specularImage,
|
|
9193
9196
|
specularImageSize: Math.pow(2, specularImage.length - 1),
|
|
9194
|
-
specularMipCount: specularImage.length
|
|
9197
|
+
specularMipCount: specularImage.length
|
|
9195
9198
|
};
|
|
9196
9199
|
return params;
|
|
9197
9200
|
};
|
|
@@ -10900,9 +10903,9 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
10900
10903
|
}
|
|
10901
10904
|
return newImages;
|
|
10902
10905
|
});
|
|
10903
|
-
var specularMipCount = specularImages.length
|
|
10906
|
+
var specularMipCount = specularImages.length;
|
|
10904
10907
|
var _ibl_specularImageSize;
|
|
10905
|
-
var specularImageSize = (_ibl_specularImageSize = ibl.specularImageSize) != null ? _ibl_specularImageSize : Math.pow(2, specularMipCount);
|
|
10908
|
+
var specularImageSize = (_ibl_specularImageSize = ibl.specularImageSize) != null ? _ibl_specularImageSize : Math.pow(2, specularMipCount - 1);
|
|
10906
10909
|
var params = {
|
|
10907
10910
|
type: "buffer",
|
|
10908
10911
|
renderable: this.isSkyboxVis(),
|
|
@@ -11478,11 +11481,11 @@ var TextureManager = /*#__PURE__*/ function() {
|
|
|
11478
11481
|
this._textureMap.clear();
|
|
11479
11482
|
};
|
|
11480
11483
|
_proto.addTexture = function addTexture(matIndex, texIndex, tex, isBaseColor) {
|
|
11481
|
-
var index = isBaseColor ? matIndex * 100000 + texIndex : texIndex;
|
|
11484
|
+
var index = isBaseColor ? (matIndex + 1) * 100000 + texIndex : texIndex;
|
|
11482
11485
|
this._textureMap.set(index, tex);
|
|
11483
11486
|
};
|
|
11484
11487
|
_proto.getTexture = function getTexture(matIndex, texIndex, isBaseColor) {
|
|
11485
|
-
var index = isBaseColor ? matIndex * 100000 + texIndex : texIndex;
|
|
11488
|
+
var index = isBaseColor ? (matIndex + 1) * 100000 + texIndex : texIndex;
|
|
11486
11489
|
return this._textureMap.get(index);
|
|
11487
11490
|
};
|
|
11488
11491
|
return TextureManager;
|
|
@@ -12356,7 +12359,7 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
12356
12359
|
id: scene.textures[skyboxOptions.specularImage].id
|
|
12357
12360
|
},
|
|
12358
12361
|
specularImageSize: skyboxOptions.specularImageSize,
|
|
12359
|
-
specularMipCount: skyboxOptions.specularMipCount
|
|
12362
|
+
specularMipCount: skyboxOptions.specularMipCount + 1
|
|
12360
12363
|
};
|
|
12361
12364
|
return skyboxComponent;
|
|
12362
12365
|
};
|
|
@@ -12788,7 +12791,7 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
12788
12791
|
if (oldMat.blending === EFFECTS.spec.MaterialBlending.masked) {
|
|
12789
12792
|
newMat.floats["AlphaClip"] = 1;
|
|
12790
12793
|
var _oldMat_alphaCutOff;
|
|
12791
|
-
newMat.floats["
|
|
12794
|
+
newMat.floats["_AlphaCutoff"] = (_oldMat_alphaCutOff = oldMat.alphaCutOff) != null ? _oldMat_alphaCutOff : 0;
|
|
12792
12795
|
} else {
|
|
12793
12796
|
newMat.floats["AlphaClip"] = 0;
|
|
12794
12797
|
}
|
|
@@ -12805,9 +12808,8 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
12805
12808
|
if (oldMat.type === EFFECTS.spec.MaterialType.pbr) {
|
|
12806
12809
|
newMat.floats["_SpecularAA"] = oldMat.useSpecularAA ? 1 : 0;
|
|
12807
12810
|
}
|
|
12808
|
-
|
|
12809
|
-
newMat.
|
|
12810
|
-
newMat.stringTags["ZTest"] = String(true);
|
|
12811
|
+
newMat.floats["ZWrite"] = oldMat.depthMask !== false ? 1 : 0;
|
|
12812
|
+
newMat.floats["ZTest"] = 1;
|
|
12811
12813
|
};
|
|
12812
12814
|
_proto.getTextureData = function getTextureData(scene, floats, texIndex, texTransform) {
|
|
12813
12815
|
var _scene_textures_texIndex_id;
|
|
@@ -13214,8 +13216,8 @@ function createGeometryData(props, subMeshes) {
|
|
|
13214
13216
|
},
|
|
13215
13217
|
subMeshes: subMeshes,
|
|
13216
13218
|
mode: EFFECTS.spec.GeometryType.TRIANGLES,
|
|
13217
|
-
indexFormat: EFFECTS.spec.IndexFormatType.
|
|
13218
|
-
indexOffset:
|
|
13219
|
+
indexFormat: EFFECTS.spec.IndexFormatType.None,
|
|
13220
|
+
indexOffset: 0,
|
|
13219
13221
|
buffer: ""
|
|
13220
13222
|
};
|
|
13221
13223
|
if (props.indices) {
|
|
@@ -13225,6 +13227,8 @@ function createGeometryData(props, subMeshes) {
|
|
|
13225
13227
|
geometryData.indexOffset = bufferOffset;
|
|
13226
13228
|
if (_instanceof1(indices, Uint32Array)) {
|
|
13227
13229
|
geometryData.indexFormat = EFFECTS.spec.IndexFormatType.UInt32;
|
|
13230
|
+
} else {
|
|
13231
|
+
geometryData.indexFormat = EFFECTS.spec.IndexFormatType.UInt16;
|
|
13228
13232
|
}
|
|
13229
13233
|
}
|
|
13230
13234
|
geometryData.buffer = toBase64String(buffer);
|
|
@@ -13379,9 +13383,1049 @@ var vertexBufferSemanticMap = {
|
|
|
13379
13383
|
a_Target_Tangent3: "TANGENT_BS3"
|
|
13380
13384
|
};
|
|
13381
13385
|
|
|
13386
|
+
var LoaderECSImpl = /*#__PURE__*/ function() {
|
|
13387
|
+
function LoaderECSImpl(composition) {
|
|
13388
|
+
this.gltfSkins = [];
|
|
13389
|
+
this.gltfMeshs = [];
|
|
13390
|
+
this.gltfLights = [];
|
|
13391
|
+
this.gltfCameras = [];
|
|
13392
|
+
this.gltfImages = [];
|
|
13393
|
+
this.gltfTextures = [];
|
|
13394
|
+
this.gltfMaterials = [];
|
|
13395
|
+
this.gltfAnimations = [];
|
|
13396
|
+
this.gltfImageBasedLights = [];
|
|
13397
|
+
this.timelineAssetId = "";
|
|
13398
|
+
this.images = [];
|
|
13399
|
+
this.imageElements = [];
|
|
13400
|
+
this.textures = [];
|
|
13401
|
+
this.items = [];
|
|
13402
|
+
this.components = [];
|
|
13403
|
+
this.materials = [];
|
|
13404
|
+
this.shaders = [];
|
|
13405
|
+
this.geometries = [];
|
|
13406
|
+
this.animations = [];
|
|
13407
|
+
if (composition) {
|
|
13408
|
+
this.composition = composition;
|
|
13409
|
+
} else {
|
|
13410
|
+
this.timelineAssetId = EFFECTS.generateGUID();
|
|
13411
|
+
this.composition = {
|
|
13412
|
+
id: "1",
|
|
13413
|
+
name: "test1",
|
|
13414
|
+
duration: 9999,
|
|
13415
|
+
endBehavior: EFFECTS.spec.CompositionEndBehavior.restart,
|
|
13416
|
+
camera: {
|
|
13417
|
+
fov: 45,
|
|
13418
|
+
far: 2000,
|
|
13419
|
+
near: 0.001,
|
|
13420
|
+
position: [
|
|
13421
|
+
0,
|
|
13422
|
+
0,
|
|
13423
|
+
8
|
|
13424
|
+
],
|
|
13425
|
+
rotation: [
|
|
13426
|
+
0,
|
|
13427
|
+
0,
|
|
13428
|
+
0
|
|
13429
|
+
],
|
|
13430
|
+
clipMode: EFFECTS.spec.CameraClipMode.portrait
|
|
13431
|
+
},
|
|
13432
|
+
items: [],
|
|
13433
|
+
timelineAsset: {
|
|
13434
|
+
id: this.timelineAssetId
|
|
13435
|
+
},
|
|
13436
|
+
sceneBindings: []
|
|
13437
|
+
};
|
|
13438
|
+
}
|
|
13439
|
+
}
|
|
13440
|
+
var _proto = LoaderECSImpl.prototype;
|
|
13441
|
+
_proto.initial = function initial(engine, options) {
|
|
13442
|
+
this.engine = engine;
|
|
13443
|
+
this.loaderOptions = options != null ? options : {};
|
|
13444
|
+
};
|
|
13445
|
+
_proto.loadScene = function loadScene(options) {
|
|
13446
|
+
var _this = this;
|
|
13447
|
+
return _async_to_generator(function() {
|
|
13448
|
+
var _this_components, _this_components1, _this_components2, _this_items, _options_effects_renderer, gltfResource, gltfScene, component, clips, index;
|
|
13449
|
+
return __generator(this, function(_state) {
|
|
13450
|
+
switch(_state.label){
|
|
13451
|
+
case 0:
|
|
13452
|
+
_this.clear();
|
|
13453
|
+
_this.sceneOptions = options;
|
|
13454
|
+
_this.engine = (_options_effects_renderer = options.effects.renderer) == null ? void 0 : _options_effects_renderer.engine;
|
|
13455
|
+
_this.loaderOptions = {
|
|
13456
|
+
compatibleMode: options.gltf.compatibleMode
|
|
13457
|
+
};
|
|
13458
|
+
gltfResource = options.gltf.resource;
|
|
13459
|
+
if (typeof gltfResource === "string" || _instanceof1(gltfResource, Uint8Array)) {
|
|
13460
|
+
throw new Error("Please load the resource using GLTFTools first.");
|
|
13461
|
+
}
|
|
13462
|
+
_this.images = gltfResource.images.map(function(gltfImage) {
|
|
13463
|
+
var _gltfImage_mimeType;
|
|
13464
|
+
var blob = new Blob([
|
|
13465
|
+
gltfImage.imageData.buffer
|
|
13466
|
+
], {
|
|
13467
|
+
type: (_gltfImage_mimeType = gltfImage.mimeType) != null ? _gltfImage_mimeType : "image/png"
|
|
13468
|
+
});
|
|
13469
|
+
return {
|
|
13470
|
+
id: gltfImage.id,
|
|
13471
|
+
url: URL.createObjectURL(blob)
|
|
13472
|
+
};
|
|
13473
|
+
});
|
|
13474
|
+
return [
|
|
13475
|
+
4,
|
|
13476
|
+
Promise.all(_this.images.map(/*#__PURE__*/ _async_to_generator(function(image) {
|
|
13477
|
+
return __generator(this, function(_state) {
|
|
13478
|
+
return [
|
|
13479
|
+
2,
|
|
13480
|
+
EFFECTS.loadImage(image.url)
|
|
13481
|
+
];
|
|
13482
|
+
});
|
|
13483
|
+
})))
|
|
13484
|
+
];
|
|
13485
|
+
case 1:
|
|
13486
|
+
_this.imageElements = _state.sent();
|
|
13487
|
+
_this.processGLTFResource(gltfResource);
|
|
13488
|
+
_this.gltfScene = gltfResource.scenes[0];
|
|
13489
|
+
_this.gltfSkins = _this.gltfScene.skins;
|
|
13490
|
+
_this.gltfMeshs = gltfResource.meshes;
|
|
13491
|
+
_this.gltfLights = _this.gltfScene.lights;
|
|
13492
|
+
_this.gltfCameras = _this.gltfScene.cameras;
|
|
13493
|
+
_this.gltfImages = gltfResource.images;
|
|
13494
|
+
_this.gltfTextures = gltfResource.textures;
|
|
13495
|
+
_this.gltfMaterials = gltfResource.materials;
|
|
13496
|
+
_this.gltfAnimations = gltfResource.animations;
|
|
13497
|
+
_this.gltfImageBasedLights = gltfResource.imageBasedLights;
|
|
13498
|
+
_this.textures = _this.gltfTextures.map(function(texture) {
|
|
13499
|
+
var textureOptions = texture.textureOptions;
|
|
13500
|
+
var source = textureOptions.source;
|
|
13501
|
+
if (typeof source === "number") {
|
|
13502
|
+
// @ts-expect-error
|
|
13503
|
+
textureOptions.source = {
|
|
13504
|
+
id: _this.images[source].id
|
|
13505
|
+
};
|
|
13506
|
+
}
|
|
13507
|
+
return textureOptions;
|
|
13508
|
+
});
|
|
13509
|
+
_this.materials = _this.gltfMaterials.map(function(material) {
|
|
13510
|
+
return material.materialData;
|
|
13511
|
+
});
|
|
13512
|
+
gltfResource.meshes.forEach(function(mesh) {
|
|
13513
|
+
_this.geometries.push(mesh.geometryData);
|
|
13514
|
+
});
|
|
13515
|
+
gltfScene = gltfResource.scenes[0];
|
|
13516
|
+
gltfScene.meshesComponentData.forEach(function(mesh) {
|
|
13517
|
+
return _this.checkMeshComponentData(mesh, gltfResource);
|
|
13518
|
+
});
|
|
13519
|
+
(_this_components = _this.components).push.apply(_this_components, [].concat(gltfScene.camerasComponentData));
|
|
13520
|
+
(_this_components1 = _this.components).push.apply(_this_components1, [].concat(gltfScene.lightsComponentData));
|
|
13521
|
+
(_this_components2 = _this.components).push.apply(_this_components2, [].concat(gltfScene.meshesComponentData));
|
|
13522
|
+
if (gltfScene.animationsComponentData.length === 1) {
|
|
13523
|
+
component = gltfScene.animationsComponentData[0];
|
|
13524
|
+
if (!options.effects.playAllAnimation && options.effects.playAnimation !== undefined) {
|
|
13525
|
+
clips = component.animationClips;
|
|
13526
|
+
index = options.effects.playAnimation;
|
|
13527
|
+
if (index >= 0 && index < clips.length) {
|
|
13528
|
+
component.animationClips = [
|
|
13529
|
+
clips[index]
|
|
13530
|
+
];
|
|
13531
|
+
} else {
|
|
13532
|
+
component.animationClips = [];
|
|
13533
|
+
}
|
|
13534
|
+
}
|
|
13535
|
+
_this.components.push(component);
|
|
13536
|
+
} else if (gltfScene.animationsComponentData.length > 1) {
|
|
13537
|
+
throw new Error("Find many animation component data " + gltfScene.animationsComponentData.length);
|
|
13538
|
+
}
|
|
13539
|
+
_this.animations = [];
|
|
13540
|
+
_this.gltfAnimations.forEach(function(anim) {
|
|
13541
|
+
_this.animations.push(anim.animationClipData);
|
|
13542
|
+
});
|
|
13543
|
+
_this.items = [];
|
|
13544
|
+
return [
|
|
13545
|
+
4,
|
|
13546
|
+
_this.tryAddSkybox({
|
|
13547
|
+
skyboxType: options.gltf.skyboxType,
|
|
13548
|
+
renderable: options.gltf.skyboxVis
|
|
13549
|
+
})
|
|
13550
|
+
];
|
|
13551
|
+
case 2:
|
|
13552
|
+
_state.sent();
|
|
13553
|
+
(_this_items = _this.items).push.apply(_this_items, [].concat(gltfResource.scenes[0].vfxItemData));
|
|
13554
|
+
_this.items.forEach(function(item) {
|
|
13555
|
+
if (item.type === "root") {
|
|
13556
|
+
item.type = "ECS";
|
|
13557
|
+
}
|
|
13558
|
+
});
|
|
13559
|
+
return [
|
|
13560
|
+
2,
|
|
13561
|
+
_this.getLoadResult()
|
|
13562
|
+
];
|
|
13563
|
+
}
|
|
13564
|
+
});
|
|
13565
|
+
})();
|
|
13566
|
+
};
|
|
13567
|
+
_proto.checkMeshComponentData = function checkMeshComponentData(mesh, resource) {
|
|
13568
|
+
if (mesh.materials.length <= 0) {
|
|
13569
|
+
throw new Error("Submesh array is empty for mesh with ID: " + mesh.id + ".");
|
|
13570
|
+
}
|
|
13571
|
+
var geometryData;
|
|
13572
|
+
resource.meshes.forEach(function(meshData) {
|
|
13573
|
+
if (meshData.geometryData.id === mesh.geometry.id) {
|
|
13574
|
+
geometryData = meshData.geometryData;
|
|
13575
|
+
}
|
|
13576
|
+
});
|
|
13577
|
+
if (geometryData === undefined) {
|
|
13578
|
+
throw new Error("Unable to find geometry data for mesh with ID: " + mesh.geometry.id + ".");
|
|
13579
|
+
}
|
|
13580
|
+
if (geometryData.subMeshes.length !== mesh.materials.length) {
|
|
13581
|
+
throw new Error("Mismatch between submeshes count (" + geometryData.subMeshes.length + ") and materials count (" + mesh.materials.length + ").");
|
|
13582
|
+
}
|
|
13583
|
+
//mesh.materials.length !=
|
|
13584
|
+
};
|
|
13585
|
+
_proto.processGLTFResource = function processGLTFResource(resource) {
|
|
13586
|
+
var _loop = function() {
|
|
13587
|
+
var baseColorId = _step.value;
|
|
13588
|
+
if (emissiveIdSet.has(baseColorId)) {
|
|
13589
|
+
var texData = textures.find(function(tex) {
|
|
13590
|
+
return tex.textureOptions.id === baseColorId;
|
|
13591
|
+
});
|
|
13592
|
+
if (texData) {
|
|
13593
|
+
var newId = EFFECTS.generateGUID();
|
|
13594
|
+
// @ts-expect-error
|
|
13595
|
+
var newTexData = _extends({}, texData);
|
|
13596
|
+
newTexData.textureOptions = _extends({}, texData.textureOptions, {
|
|
13597
|
+
id: newId
|
|
13598
|
+
});
|
|
13599
|
+
textures.push(newTexData);
|
|
13600
|
+
dataMap[newId] = newTexData.textureOptions;
|
|
13601
|
+
textureIdMap[baseColorId] = newId;
|
|
13602
|
+
mapCount += 1;
|
|
13603
|
+
}
|
|
13604
|
+
}
|
|
13605
|
+
};
|
|
13606
|
+
var _this = this;
|
|
13607
|
+
var dataMap = {};
|
|
13608
|
+
var textures = resource.textures, materials = resource.materials, scenes = resource.scenes, imageBasedLights = resource.imageBasedLights;
|
|
13609
|
+
textures.forEach(function(tex) {
|
|
13610
|
+
var texData = tex.textureOptions;
|
|
13611
|
+
var texId = texData.id;
|
|
13612
|
+
if (texId) {
|
|
13613
|
+
if (dataMap[texId]) {
|
|
13614
|
+
console.error("Duplicate GUID found: " + texId + ", old " + dataMap[texId] + ", new " + texData + ".");
|
|
13615
|
+
}
|
|
13616
|
+
dataMap[texId] = texData;
|
|
13617
|
+
} else {
|
|
13618
|
+
console.error("No GUID in texture Data: " + texData + ".");
|
|
13619
|
+
}
|
|
13620
|
+
});
|
|
13621
|
+
var baseColorIdSet = new Set();
|
|
13622
|
+
var emissiveIdSet = new Set();
|
|
13623
|
+
materials.forEach(function(mat) {
|
|
13624
|
+
var _materialData_textures__BaseColorSampler, _materialData_textures__EmissiveSampler;
|
|
13625
|
+
var materialData = mat.materialData;
|
|
13626
|
+
var baseColorTexture = (_materialData_textures__BaseColorSampler = materialData.textures["_BaseColorSampler"]) == null ? void 0 : _materialData_textures__BaseColorSampler.texture;
|
|
13627
|
+
var emissiveTexture = (_materialData_textures__EmissiveSampler = materialData.textures["_EmissiveSampler"]) == null ? void 0 : _materialData_textures__EmissiveSampler.texture;
|
|
13628
|
+
if (baseColorTexture) {
|
|
13629
|
+
baseColorIdSet.add(baseColorTexture.id);
|
|
13630
|
+
}
|
|
13631
|
+
if (emissiveTexture) {
|
|
13632
|
+
emissiveIdSet.add(emissiveTexture.id);
|
|
13633
|
+
}
|
|
13634
|
+
});
|
|
13635
|
+
var mapCount = 0;
|
|
13636
|
+
var textureIdMap = {};
|
|
13637
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(baseColorIdSet), _step; !(_step = _iterator()).done;)_loop();
|
|
13638
|
+
if (mapCount > 0) {
|
|
13639
|
+
console.warn("Duplicate emissive texture " + mapCount);
|
|
13640
|
+
}
|
|
13641
|
+
materials.forEach(function(mat) {
|
|
13642
|
+
var _materialData_shader, _materialData_shader1;
|
|
13643
|
+
var materialData = mat.materialData;
|
|
13644
|
+
_this.processMaterialData(materialData);
|
|
13645
|
+
if (((_materialData_shader = materialData.shader) == null ? void 0 : _materialData_shader.id) === UnlitShaderGUID) {
|
|
13646
|
+
_this.processMaterialTexture(materialData, "_BaseColorSampler", true, dataMap);
|
|
13647
|
+
} else if (((_materialData_shader1 = materialData.shader) == null ? void 0 : _materialData_shader1.id) === PBRShaderGUID) {
|
|
13648
|
+
var _materialData_textures__EmissiveSampler;
|
|
13649
|
+
var emissiveTexture = (_materialData_textures__EmissiveSampler = materialData.textures["_EmissiveSampler"]) == null ? void 0 : _materialData_textures__EmissiveSampler.texture;
|
|
13650
|
+
if (emissiveTexture && textureIdMap[emissiveTexture.id]) {
|
|
13651
|
+
emissiveTexture.id = textureIdMap[emissiveTexture.id];
|
|
13652
|
+
}
|
|
13653
|
+
_this.processMaterialTexture(materialData, "_BaseColorSampler", true, dataMap);
|
|
13654
|
+
_this.processMaterialTexture(materialData, "_MetallicRoughnessSampler", false, dataMap);
|
|
13655
|
+
_this.processMaterialTexture(materialData, "_NormalSampler", false, dataMap);
|
|
13656
|
+
_this.processMaterialTexture(materialData, "_OcclusionSampler", false, dataMap);
|
|
13657
|
+
_this.processMaterialTexture(materialData, "_EmissiveSampler", false, dataMap);
|
|
13658
|
+
}
|
|
13659
|
+
});
|
|
13660
|
+
var gltfScene = scenes[0];
|
|
13661
|
+
gltfScene.camerasComponentData.forEach(function(comp) {
|
|
13662
|
+
return _this.processCameraComponentData(comp);
|
|
13663
|
+
});
|
|
13664
|
+
gltfScene.lightsComponentData.forEach(function(comp) {
|
|
13665
|
+
return _this.processLightComponentData(comp);
|
|
13666
|
+
});
|
|
13667
|
+
gltfScene.meshesComponentData.forEach(function(comp) {
|
|
13668
|
+
return _this.processMeshComponentData(comp);
|
|
13669
|
+
});
|
|
13670
|
+
var cubeTextures = [];
|
|
13671
|
+
imageBasedLights.forEach(function(ibl) {
|
|
13672
|
+
var data = ibl.imageBaseLightData;
|
|
13673
|
+
if (data.reflectionsIntensity === undefined) {
|
|
13674
|
+
data.reflectionsIntensity = data.intensity;
|
|
13675
|
+
}
|
|
13676
|
+
if (data.diffuseImage) {
|
|
13677
|
+
var diffuseTexture = dataMap[data.diffuseImage.id];
|
|
13678
|
+
EFFECTS.addItem(cubeTextures, diffuseTexture);
|
|
13679
|
+
}
|
|
13680
|
+
if (data.specularImage) {
|
|
13681
|
+
var specularImage = dataMap[data.specularImage.id];
|
|
13682
|
+
EFFECTS.addItem(cubeTextures, specularImage);
|
|
13683
|
+
}
|
|
13684
|
+
});
|
|
13685
|
+
cubeTextures.forEach(function(tex) {
|
|
13686
|
+
if (tex.target === EFFECTS.glContext.TEXTURE_CUBE_MAP) {
|
|
13687
|
+
var cube = tex;
|
|
13688
|
+
cube.mipmaps.forEach(function(mipmap) {
|
|
13689
|
+
var ref;
|
|
13690
|
+
ref = [
|
|
13691
|
+
mipmap[5],
|
|
13692
|
+
mipmap[4]
|
|
13693
|
+
], mipmap[4] = ref[0], mipmap[5] = ref[1];
|
|
13694
|
+
});
|
|
13695
|
+
if (cube.mipmaps.length === 1) {
|
|
13696
|
+
cube.minFilter = EFFECTS.glContext.LINEAR;
|
|
13697
|
+
cube.magFilter = EFFECTS.glContext.LINEAR;
|
|
13698
|
+
} else {
|
|
13699
|
+
cube.minFilter = EFFECTS.glContext.LINEAR_MIPMAP_LINEAR;
|
|
13700
|
+
cube.magFilter = EFFECTS.glContext.LINEAR;
|
|
13701
|
+
}
|
|
13702
|
+
}
|
|
13703
|
+
});
|
|
13704
|
+
};
|
|
13705
|
+
_proto.processComponentData = function processComponentData(components) {
|
|
13706
|
+
var _this = this;
|
|
13707
|
+
components.forEach(function(comp) {
|
|
13708
|
+
if (comp.dataType === EFFECTS.spec.DataType.LightComponent) {
|
|
13709
|
+
_this.processLightComponentData(comp);
|
|
13710
|
+
} else if (comp.dataType === EFFECTS.spec.DataType.CameraComponent) {
|
|
13711
|
+
_this.processCameraComponentData(comp);
|
|
13712
|
+
} else if (comp.dataType === EFFECTS.spec.DataType.MeshComponent) {
|
|
13713
|
+
_this.processMeshComponentData(comp);
|
|
13714
|
+
} else if (comp.dataType === EFFECTS.spec.DataType.SkyboxComponent) {
|
|
13715
|
+
_this.processSkyboxComponentData(comp);
|
|
13716
|
+
}
|
|
13717
|
+
});
|
|
13718
|
+
};
|
|
13719
|
+
_proto.processLightComponentData = function processLightComponentData(light) {
|
|
13720
|
+
if (!light.color) {
|
|
13721
|
+
light.color = {
|
|
13722
|
+
r: 1,
|
|
13723
|
+
g: 1,
|
|
13724
|
+
b: 1,
|
|
13725
|
+
a: 1
|
|
13726
|
+
};
|
|
13727
|
+
}
|
|
13728
|
+
if (!light.intensity) {
|
|
13729
|
+
light.intensity = 1;
|
|
13730
|
+
}
|
|
13731
|
+
if (light.lightType === EFFECTS.spec.LightType.point) {
|
|
13732
|
+
if (!light.range) {
|
|
13733
|
+
light.range = 0;
|
|
13734
|
+
}
|
|
13735
|
+
} else if (light.lightType === EFFECTS.spec.LightType.spot) {
|
|
13736
|
+
if (!light.range) {
|
|
13737
|
+
light.range = 0;
|
|
13738
|
+
}
|
|
13739
|
+
if (!light.innerConeAngle) {
|
|
13740
|
+
light.innerConeAngle = 0;
|
|
13741
|
+
}
|
|
13742
|
+
if (!light.outerConeAngle) {
|
|
13743
|
+
light.outerConeAngle = Math.PI / 4;
|
|
13744
|
+
}
|
|
13745
|
+
}
|
|
13746
|
+
};
|
|
13747
|
+
_proto.processCameraComponentData = function processCameraComponentData(camera) {
|
|
13748
|
+
if (camera.type === EFFECTS.spec.CameraType.perspective) {
|
|
13749
|
+
if (camera.fov) {
|
|
13750
|
+
camera.fov *= Math.PI / 180;
|
|
13751
|
+
}
|
|
13752
|
+
}
|
|
13753
|
+
};
|
|
13754
|
+
_proto.processMeshComponentData = function processMeshComponentData(mesh) {};
|
|
13755
|
+
_proto.processSkyboxComponentData = function processSkyboxComponentData(skybox) {
|
|
13756
|
+
if (skybox.intensity === undefined) {
|
|
13757
|
+
skybox.intensity = 1;
|
|
13758
|
+
}
|
|
13759
|
+
if (skybox.reflectionsIntensity === undefined) {
|
|
13760
|
+
skybox.reflectionsIntensity = 1;
|
|
13761
|
+
}
|
|
13762
|
+
};
|
|
13763
|
+
_proto.processMaterialData = function processMaterialData(material) {
|
|
13764
|
+
var _material_shader, _material_shader1;
|
|
13765
|
+
if (((_material_shader = material.shader) == null ? void 0 : _material_shader.id) === UnlitShaderGUID) {
|
|
13766
|
+
if (!material.colors["_BaseColorFactor"]) {
|
|
13767
|
+
material.colors["_BaseColorFactor"] = {
|
|
13768
|
+
r: 1,
|
|
13769
|
+
g: 1,
|
|
13770
|
+
b: 1,
|
|
13771
|
+
a: 1
|
|
13772
|
+
};
|
|
13773
|
+
}
|
|
13774
|
+
if (material.floats["_AlphaCutoff"] === undefined) {
|
|
13775
|
+
material.floats["_AlphaCutoff"] = 0;
|
|
13776
|
+
}
|
|
13777
|
+
if (material.floats["ZWrite"] === undefined) {
|
|
13778
|
+
material.floats["ZWrite"] = 1;
|
|
13779
|
+
}
|
|
13780
|
+
if (material.floats["ZTest"] === undefined) {
|
|
13781
|
+
material.floats["ZTest"] = 1;
|
|
13782
|
+
}
|
|
13783
|
+
if (!material.stringTags["RenderType"]) {
|
|
13784
|
+
material.stringTags["RenderType"] = EFFECTS.spec.RenderType.Opaque;
|
|
13785
|
+
}
|
|
13786
|
+
if (!material.stringTags["RenderFace"]) {
|
|
13787
|
+
material.stringTags["RenderFace"] = EFFECTS.spec.RenderFace.Front;
|
|
13788
|
+
}
|
|
13789
|
+
} else if (((_material_shader1 = material.shader) == null ? void 0 : _material_shader1.id) === PBRShaderGUID) {
|
|
13790
|
+
if (!material.colors["_BaseColorFactor"]) {
|
|
13791
|
+
material.colors["_BaseColorFactor"] = {
|
|
13792
|
+
r: 1,
|
|
13793
|
+
g: 1,
|
|
13794
|
+
b: 1,
|
|
13795
|
+
a: 1
|
|
13796
|
+
};
|
|
13797
|
+
}
|
|
13798
|
+
if (material.floats["_SpecularAA"] === undefined) {
|
|
13799
|
+
material.floats["_SpecularAA"] = 0;
|
|
13800
|
+
}
|
|
13801
|
+
if (material.floats["_MetallicFactor"] === undefined) {
|
|
13802
|
+
material.floats["_MetallicFactor"] = 1;
|
|
13803
|
+
}
|
|
13804
|
+
if (material.floats["_RoughnessFactor"] === undefined) {
|
|
13805
|
+
material.floats["_RoughnessFactor"] = 0;
|
|
13806
|
+
}
|
|
13807
|
+
if (material.floats["_NormalScale"] === undefined) {
|
|
13808
|
+
material.floats["_NormalScale"] = 1;
|
|
13809
|
+
}
|
|
13810
|
+
if (material.floats["_OcclusionStrength"] === undefined) {
|
|
13811
|
+
material.floats["_OcclusionStrength"] = this.isTiny3dMode() ? 0 : 1;
|
|
13812
|
+
}
|
|
13813
|
+
if (!material.colors["_EmissiveFactor"]) {
|
|
13814
|
+
material.colors["_EmissiveFactor"] = {
|
|
13815
|
+
r: 0,
|
|
13816
|
+
g: 0,
|
|
13817
|
+
b: 0,
|
|
13818
|
+
a: 1
|
|
13819
|
+
};
|
|
13820
|
+
}
|
|
13821
|
+
if (material.floats["_EmissiveIntensity"] === undefined) {
|
|
13822
|
+
material.floats["_EmissiveIntensity"] = 1;
|
|
13823
|
+
}
|
|
13824
|
+
if (material.floats["_AlphaCutoff"] === undefined) {
|
|
13825
|
+
material.floats["_AlphaCutoff"] = 0;
|
|
13826
|
+
}
|
|
13827
|
+
if (material.floats["ZWrite"] === undefined) {
|
|
13828
|
+
material.floats["ZWrite"] = 1;
|
|
13829
|
+
}
|
|
13830
|
+
if (material.floats["ZTest"] === undefined) {
|
|
13831
|
+
material.floats["ZTest"] = 1;
|
|
13832
|
+
}
|
|
13833
|
+
if (!material.stringTags["RenderType"]) {
|
|
13834
|
+
material.stringTags["RenderType"] = EFFECTS.spec.RenderType.Opaque;
|
|
13835
|
+
}
|
|
13836
|
+
if (!material.stringTags["RenderFace"]) {
|
|
13837
|
+
material.stringTags["RenderFace"] = EFFECTS.spec.RenderFace.Front;
|
|
13838
|
+
}
|
|
13839
|
+
} else {
|
|
13840
|
+
console.error("Encountered unknown shader ID in material with ID: " + material.id + ".");
|
|
13841
|
+
}
|
|
13842
|
+
};
|
|
13843
|
+
_proto.processTextureOptions = function processTextureOptions(options, isBaseColor, image) {
|
|
13844
|
+
var premultiplyAlpha = false;
|
|
13845
|
+
var _options_minFilter;
|
|
13846
|
+
var minFilter = (_options_minFilter = options.minFilter) != null ? _options_minFilter : EFFECTS.glContext.LINEAR_MIPMAP_LINEAR;
|
|
13847
|
+
if (this.isTiny3dMode()) {
|
|
13848
|
+
minFilter = EFFECTS.glContext.LINEAR_MIPMAP_LINEAR;
|
|
13849
|
+
if (image) {
|
|
13850
|
+
if (!WebGLHelper.isPow2(image.width) || !WebGLHelper.isPow2(image.height)) {
|
|
13851
|
+
minFilter = EFFECTS.glContext.LINEAR;
|
|
13852
|
+
}
|
|
13853
|
+
}
|
|
13854
|
+
premultiplyAlpha = isBaseColor ? false : true;
|
|
13855
|
+
}
|
|
13856
|
+
var generateMipmap = minFilter == EFFECTS.glContext.NEAREST_MIPMAP_NEAREST || minFilter == EFFECTS.glContext.LINEAR_MIPMAP_NEAREST || minFilter == EFFECTS.glContext.NEAREST_MIPMAP_LINEAR || minFilter == EFFECTS.glContext.LINEAR_MIPMAP_LINEAR;
|
|
13857
|
+
var _options_wrapS;
|
|
13858
|
+
options.wrapS = (_options_wrapS = options.wrapS) != null ? _options_wrapS : EFFECTS.glContext.REPEAT;
|
|
13859
|
+
var _options_wrapT;
|
|
13860
|
+
options.wrapT = (_options_wrapT = options.wrapT) != null ? _options_wrapT : EFFECTS.glContext.REPEAT;
|
|
13861
|
+
var _options_magFilter;
|
|
13862
|
+
options.magFilter = (_options_magFilter = options.magFilter) != null ? _options_magFilter : EFFECTS.glContext.LINEAR;
|
|
13863
|
+
options.minFilter = minFilter;
|
|
13864
|
+
options.anisotropic = 1;
|
|
13865
|
+
options.premultiplyAlpha = premultiplyAlpha;
|
|
13866
|
+
options.generateMipmap = generateMipmap;
|
|
13867
|
+
};
|
|
13868
|
+
_proto.processMaterialTexture = function processMaterialTexture(material, textureName, isBaseColor, dataMap) {
|
|
13869
|
+
var texture = material.textures[textureName];
|
|
13870
|
+
if (texture) {
|
|
13871
|
+
var id = texture.texture.id;
|
|
13872
|
+
var texData = dataMap[id];
|
|
13873
|
+
var imageObj;
|
|
13874
|
+
// @ts-expect-error
|
|
13875
|
+
if (typeof texData.source !== "number") {
|
|
13876
|
+
// @ts-expect-error
|
|
13877
|
+
throw new Error("Invalid texture option source data, " + texData.source);
|
|
13878
|
+
} else {
|
|
13879
|
+
// @ts-expect-error
|
|
13880
|
+
imageObj = this.imageElements[texData.source];
|
|
13881
|
+
}
|
|
13882
|
+
if (texData) {
|
|
13883
|
+
this.processTextureOptions(texData, isBaseColor, imageObj);
|
|
13884
|
+
}
|
|
13885
|
+
}
|
|
13886
|
+
};
|
|
13887
|
+
_proto.getLoadResult = function getLoadResult() {
|
|
13888
|
+
var itemIds = [];
|
|
13889
|
+
this.items.forEach(function(item) {
|
|
13890
|
+
return itemIds.push({
|
|
13891
|
+
id: item.id
|
|
13892
|
+
});
|
|
13893
|
+
});
|
|
13894
|
+
this.composition.items = itemIds;
|
|
13895
|
+
var jsonScene = {
|
|
13896
|
+
version: "3.0",
|
|
13897
|
+
playerVersion: {
|
|
13898
|
+
web: "2.0",
|
|
13899
|
+
native: "2.0"
|
|
13900
|
+
},
|
|
13901
|
+
type: "ge",
|
|
13902
|
+
compositionId: this.composition.id,
|
|
13903
|
+
compositions: [
|
|
13904
|
+
this.composition
|
|
13905
|
+
],
|
|
13906
|
+
images: this.images,
|
|
13907
|
+
shapes: [],
|
|
13908
|
+
plugins: [
|
|
13909
|
+
"model"
|
|
13910
|
+
],
|
|
13911
|
+
textures: this.textures,
|
|
13912
|
+
items: this.items,
|
|
13913
|
+
components: this.components,
|
|
13914
|
+
materials: this.materials,
|
|
13915
|
+
shaders: this.shaders,
|
|
13916
|
+
geometries: this.geometries,
|
|
13917
|
+
animations: this.animations,
|
|
13918
|
+
miscs: [
|
|
13919
|
+
{
|
|
13920
|
+
id: this.timelineAssetId,
|
|
13921
|
+
dataType: EFFECTS.spec.DataType.TimelineAsset
|
|
13922
|
+
}
|
|
13923
|
+
]
|
|
13924
|
+
};
|
|
13925
|
+
return {
|
|
13926
|
+
source: this.getRemarkString(),
|
|
13927
|
+
jsonScene: jsonScene,
|
|
13928
|
+
sceneAABB: {
|
|
13929
|
+
min: [
|
|
13930
|
+
-1,
|
|
13931
|
+
-1,
|
|
13932
|
+
-1
|
|
13933
|
+
],
|
|
13934
|
+
max: [
|
|
13935
|
+
1,
|
|
13936
|
+
1,
|
|
13937
|
+
1
|
|
13938
|
+
]
|
|
13939
|
+
}
|
|
13940
|
+
};
|
|
13941
|
+
};
|
|
13942
|
+
_proto.addLight = function addLight(data) {
|
|
13943
|
+
var itemId = EFFECTS.generateGUID();
|
|
13944
|
+
var component = {
|
|
13945
|
+
id: EFFECTS.generateGUID(),
|
|
13946
|
+
item: {
|
|
13947
|
+
id: itemId
|
|
13948
|
+
},
|
|
13949
|
+
dataType: EFFECTS.spec.DataType.LightComponent,
|
|
13950
|
+
//
|
|
13951
|
+
lightType: data.lightType,
|
|
13952
|
+
color: data.color,
|
|
13953
|
+
intensity: data.intensity,
|
|
13954
|
+
range: data.range,
|
|
13955
|
+
innerConeAngle: data.innerConeAngle,
|
|
13956
|
+
outerConeAngle: data.outerConeAngle
|
|
13957
|
+
};
|
|
13958
|
+
var item = {
|
|
13959
|
+
id: itemId,
|
|
13960
|
+
name: data.name,
|
|
13961
|
+
duration: data.duration,
|
|
13962
|
+
type: EFFECTS.spec.ItemType.light,
|
|
13963
|
+
pn: 0,
|
|
13964
|
+
visible: true,
|
|
13965
|
+
endBehavior: data.endBehavior,
|
|
13966
|
+
transform: {
|
|
13967
|
+
position: {
|
|
13968
|
+
x: data.position[0],
|
|
13969
|
+
y: data.position[1],
|
|
13970
|
+
z: data.position[2]
|
|
13971
|
+
},
|
|
13972
|
+
eulerHint: {
|
|
13973
|
+
x: data.rotation[0],
|
|
13974
|
+
y: data.rotation[1],
|
|
13975
|
+
z: data.rotation[2]
|
|
13976
|
+
},
|
|
13977
|
+
scale: {
|
|
13978
|
+
x: data.scale[0],
|
|
13979
|
+
y: data.scale[1],
|
|
13980
|
+
z: data.scale[2]
|
|
13981
|
+
}
|
|
13982
|
+
},
|
|
13983
|
+
components: [
|
|
13984
|
+
{
|
|
13985
|
+
id: component.id
|
|
13986
|
+
}
|
|
13987
|
+
],
|
|
13988
|
+
content: {},
|
|
13989
|
+
dataType: EFFECTS.spec.DataType.VFXItemData
|
|
13990
|
+
};
|
|
13991
|
+
this.items.push(item);
|
|
13992
|
+
this.components.push(component);
|
|
13993
|
+
};
|
|
13994
|
+
_proto.addCamera = function addCamera(camera) {
|
|
13995
|
+
var itemId = EFFECTS.generateGUID();
|
|
13996
|
+
var component = {
|
|
13997
|
+
id: EFFECTS.generateGUID(),
|
|
13998
|
+
item: {
|
|
13999
|
+
id: itemId
|
|
14000
|
+
},
|
|
14001
|
+
dataType: EFFECTS.spec.DataType.CameraComponent,
|
|
14002
|
+
fov: camera.fov,
|
|
14003
|
+
near: camera.near,
|
|
14004
|
+
far: camera.far,
|
|
14005
|
+
clipMode: camera.clipMode
|
|
14006
|
+
};
|
|
14007
|
+
var item = {
|
|
14008
|
+
id: itemId,
|
|
14009
|
+
name: camera.name,
|
|
14010
|
+
duration: camera.duration,
|
|
14011
|
+
// @ts-expect-error
|
|
14012
|
+
type: "camera",
|
|
14013
|
+
pn: 0,
|
|
14014
|
+
visible: true,
|
|
14015
|
+
endBehavior: camera.endBehavior,
|
|
14016
|
+
transform: {
|
|
14017
|
+
position: {
|
|
14018
|
+
x: camera.position[0],
|
|
14019
|
+
y: camera.position[1],
|
|
14020
|
+
z: camera.position[2]
|
|
14021
|
+
},
|
|
14022
|
+
eulerHint: {
|
|
14023
|
+
x: camera.rotation[0],
|
|
14024
|
+
y: camera.rotation[1],
|
|
14025
|
+
z: camera.rotation[2]
|
|
14026
|
+
},
|
|
14027
|
+
scale: {
|
|
14028
|
+
x: 1,
|
|
14029
|
+
y: 1,
|
|
14030
|
+
z: 1
|
|
14031
|
+
}
|
|
14032
|
+
},
|
|
14033
|
+
components: [
|
|
14034
|
+
{
|
|
14035
|
+
id: component.id
|
|
14036
|
+
}
|
|
14037
|
+
],
|
|
14038
|
+
content: {},
|
|
14039
|
+
dataType: EFFECTS.spec.DataType.VFXItemData
|
|
14040
|
+
};
|
|
14041
|
+
this.items.push(item);
|
|
14042
|
+
this.components.push(component);
|
|
14043
|
+
};
|
|
14044
|
+
_proto.tryAddSkybox = function tryAddSkybox(skybox) {
|
|
14045
|
+
var _this = this;
|
|
14046
|
+
return _async_to_generator(function() {
|
|
14047
|
+
var ibl, _this_images, // @ts-expect-error
|
|
14048
|
+
_this_textures, itemId, skyboxInfo, imageList, textureOptionsList, component, _skybox_renderable, _skybox_duration, item;
|
|
14049
|
+
return __generator(this, function(_state) {
|
|
14050
|
+
if (_this.gltfImageBasedLights.length > 0 && !_this.ignoreSkybox()) {
|
|
14051
|
+
ibl = _this.gltfImageBasedLights[0];
|
|
14052
|
+
_this.components.push(ibl.imageBaseLightData);
|
|
14053
|
+
} else if (skybox.skyboxType !== undefined) {
|
|
14054
|
+
itemId = EFFECTS.generateGUID();
|
|
14055
|
+
skyboxInfo = _this.createSkyboxComponentData(skybox.skyboxType);
|
|
14056
|
+
imageList = skyboxInfo.imageList, textureOptionsList = skyboxInfo.textureOptionsList, component = skyboxInfo.component;
|
|
14057
|
+
component.item.id = itemId;
|
|
14058
|
+
if (skybox.intensity !== undefined) {
|
|
14059
|
+
component.intensity = skybox.intensity;
|
|
14060
|
+
}
|
|
14061
|
+
if (skybox.reflectionsIntensity !== undefined) {
|
|
14062
|
+
component.reflectionsIntensity = skybox.reflectionsIntensity;
|
|
14063
|
+
}
|
|
14064
|
+
component.renderable = (_skybox_renderable = skybox.renderable) != null ? _skybox_renderable : false;
|
|
14065
|
+
item = {
|
|
14066
|
+
id: itemId,
|
|
14067
|
+
name: "Skybox-" + skybox.skyboxType,
|
|
14068
|
+
duration: (_skybox_duration = skybox.duration) != null ? _skybox_duration : 999,
|
|
14069
|
+
type: EFFECTS.spec.ItemType.skybox,
|
|
14070
|
+
pn: 0,
|
|
14071
|
+
visible: true,
|
|
14072
|
+
endBehavior: EFFECTS.spec.ItemEndBehavior.freeze,
|
|
14073
|
+
transform: {
|
|
14074
|
+
position: {
|
|
14075
|
+
x: 0,
|
|
14076
|
+
y: 0,
|
|
14077
|
+
z: 0
|
|
14078
|
+
},
|
|
14079
|
+
eulerHint: {
|
|
14080
|
+
x: 0,
|
|
14081
|
+
y: 0,
|
|
14082
|
+
z: 0
|
|
14083
|
+
},
|
|
14084
|
+
scale: {
|
|
14085
|
+
x: 1,
|
|
14086
|
+
y: 1,
|
|
14087
|
+
z: 1
|
|
14088
|
+
}
|
|
14089
|
+
},
|
|
14090
|
+
components: [
|
|
14091
|
+
{
|
|
14092
|
+
id: component.id
|
|
14093
|
+
}
|
|
14094
|
+
],
|
|
14095
|
+
content: {},
|
|
14096
|
+
dataType: EFFECTS.spec.DataType.VFXItemData
|
|
14097
|
+
};
|
|
14098
|
+
(_this_images = _this.images).push.apply(_this_images, [].concat(imageList));
|
|
14099
|
+
(_this_textures = _this.textures).push.apply(_this_textures, [].concat(textureOptionsList));
|
|
14100
|
+
_this.items.push(item);
|
|
14101
|
+
_this.components.push(component);
|
|
14102
|
+
}
|
|
14103
|
+
return [
|
|
14104
|
+
2
|
|
14105
|
+
];
|
|
14106
|
+
});
|
|
14107
|
+
})();
|
|
14108
|
+
};
|
|
14109
|
+
_proto.createTreeOptions = function createTreeOptions(scene) {
|
|
14110
|
+
var nodeList = scene.nodes.map(function(node, nodeIndex) {
|
|
14111
|
+
var children = node.children.map(function(child) {
|
|
14112
|
+
if (child.nodeIndex === undefined) {
|
|
14113
|
+
throw new Error("Undefined nodeIndex for child " + child + ".");
|
|
14114
|
+
}
|
|
14115
|
+
return child.nodeIndex;
|
|
14116
|
+
});
|
|
14117
|
+
var pos = [
|
|
14118
|
+
0,
|
|
14119
|
+
0,
|
|
14120
|
+
0
|
|
14121
|
+
];
|
|
14122
|
+
var quat = [
|
|
14123
|
+
0,
|
|
14124
|
+
0,
|
|
14125
|
+
0,
|
|
14126
|
+
0
|
|
14127
|
+
];
|
|
14128
|
+
var scale = [
|
|
14129
|
+
0,
|
|
14130
|
+
0,
|
|
14131
|
+
0
|
|
14132
|
+
];
|
|
14133
|
+
if (node.matrix !== undefined) {
|
|
14134
|
+
if (node.matrix.length !== 16) {
|
|
14135
|
+
throw new Error("Invalid matrix length " + node.matrix.length + " for node " + node + ".");
|
|
14136
|
+
}
|
|
14137
|
+
var mat = Matrix4.fromArray(node.matrix);
|
|
14138
|
+
var transform = mat.getTransform();
|
|
14139
|
+
pos = transform.translation.toArray();
|
|
14140
|
+
quat = transform.rotation.toArray();
|
|
14141
|
+
scale = transform.scale.toArray();
|
|
14142
|
+
} else {
|
|
14143
|
+
if (node.translation !== undefined) {
|
|
14144
|
+
pos = node.translation;
|
|
14145
|
+
}
|
|
14146
|
+
if (node.rotation !== undefined) {
|
|
14147
|
+
quat = node.rotation;
|
|
14148
|
+
}
|
|
14149
|
+
if (node.scale !== undefined) {
|
|
14150
|
+
scale = node.scale;
|
|
14151
|
+
}
|
|
14152
|
+
}
|
|
14153
|
+
node.nodeIndex = nodeIndex;
|
|
14154
|
+
var treeNode = {
|
|
14155
|
+
name: node.name,
|
|
14156
|
+
transform: {
|
|
14157
|
+
position: pos,
|
|
14158
|
+
quat: quat,
|
|
14159
|
+
scale: scale
|
|
14160
|
+
},
|
|
14161
|
+
children: children,
|
|
14162
|
+
id: "" + node.nodeIndex
|
|
14163
|
+
};
|
|
14164
|
+
return treeNode;
|
|
14165
|
+
});
|
|
14166
|
+
var rootNodes = scene.rootNodes.map(function(root) {
|
|
14167
|
+
if (root.nodeIndex === undefined) {
|
|
14168
|
+
throw new Error("Undefined nodeIndex for root " + root + ".");
|
|
14169
|
+
}
|
|
14170
|
+
return root.nodeIndex;
|
|
14171
|
+
});
|
|
14172
|
+
var treeOptions = {
|
|
14173
|
+
nodes: nodeList,
|
|
14174
|
+
children: rootNodes,
|
|
14175
|
+
animation: -1,
|
|
14176
|
+
animations: []
|
|
14177
|
+
};
|
|
14178
|
+
return treeOptions;
|
|
14179
|
+
};
|
|
14180
|
+
_proto.createAnimations = function createAnimations(animations) {
|
|
14181
|
+
return animations.map(function(anim) {
|
|
14182
|
+
var tracks = anim.channels.map(function(channel) {
|
|
14183
|
+
var track = {
|
|
14184
|
+
input: channel.input.array,
|
|
14185
|
+
output: channel.output.array,
|
|
14186
|
+
node: channel.target.node,
|
|
14187
|
+
path: channel.target.path,
|
|
14188
|
+
interpolation: channel.interpolation
|
|
14189
|
+
};
|
|
14190
|
+
return track;
|
|
14191
|
+
});
|
|
14192
|
+
var newAnim = {
|
|
14193
|
+
name: anim.name,
|
|
14194
|
+
tracks: tracks
|
|
14195
|
+
};
|
|
14196
|
+
return newAnim;
|
|
14197
|
+
});
|
|
14198
|
+
};
|
|
14199
|
+
_proto.createTexture2D = function createTexture2D(image, texture, isBaseColor) {
|
|
14200
|
+
return WebGLHelper.createTexture2D(this.engine, image, texture, isBaseColor, this.isTiny3dMode());
|
|
14201
|
+
};
|
|
14202
|
+
_proto.createSkyboxComponentData = function createSkyboxComponentData(typeName) {
|
|
14203
|
+
if (typeName !== "NFT" && typeName !== "FARM") {
|
|
14204
|
+
throw new Error("Invalid skybox type specified: '" + typeName + "'. Valid types are: 'NFT', 'FARM'.");
|
|
14205
|
+
}
|
|
14206
|
+
//
|
|
14207
|
+
var typ = typeName === "NFT" ? exports.PSkyboxType.NFT : exports.PSkyboxType.FARM;
|
|
14208
|
+
var params = PSkyboxCreator.getSkyboxParams(typ);
|
|
14209
|
+
return PSkyboxCreator.createSkyboxComponentData(this.engine, params);
|
|
14210
|
+
};
|
|
14211
|
+
_proto.scaleColorVal = function scaleColorVal(val, fromGLTF) {
|
|
14212
|
+
return fromGLTF ? LoaderHelper.scaleTo255(val) : LoaderHelper.scaleTo1(val);
|
|
14213
|
+
};
|
|
14214
|
+
_proto.scaleColorVec = function scaleColorVec(vec, fromGLTF) {
|
|
14215
|
+
var _this = this;
|
|
14216
|
+
return vec.map(function(val) {
|
|
14217
|
+
return _this.scaleColorVal(val, fromGLTF);
|
|
14218
|
+
});
|
|
14219
|
+
};
|
|
14220
|
+
_proto.createLightOptions = function createLightOptions(light) {
|
|
14221
|
+
return PluginHelper.createLightOptions(light);
|
|
14222
|
+
};
|
|
14223
|
+
_proto.createCameraOptions = function createCameraOptions(camera) {
|
|
14224
|
+
var _PluginHelper_createCameraOptions;
|
|
14225
|
+
return (_PluginHelper_createCameraOptions = PluginHelper.createCameraOptions(camera)) != null ? _PluginHelper_createCameraOptions : {
|
|
14226
|
+
fov: 45,
|
|
14227
|
+
far: 1000,
|
|
14228
|
+
near: 0.01,
|
|
14229
|
+
clipMode: EFFECTS.spec.CameraClipMode.portrait
|
|
14230
|
+
};
|
|
14231
|
+
};
|
|
14232
|
+
_proto.clear = function clear() {
|
|
14233
|
+
this.images = [];
|
|
14234
|
+
this.textures = [];
|
|
14235
|
+
this.items = [];
|
|
14236
|
+
this.components = [];
|
|
14237
|
+
this.materials = [];
|
|
14238
|
+
this.shaders = [];
|
|
14239
|
+
this.geometries = [];
|
|
14240
|
+
};
|
|
14241
|
+
/**
|
|
14242
|
+
* 按照传入的动画播放参数,计算需要播放的动画索引
|
|
14243
|
+
*
|
|
14244
|
+
* @param treeOptions 节点树属性,需要初始化animations列表。
|
|
14245
|
+
* @returns 返回计算的动画索引,-1表示没有动画需要播放,-88888888表示播放所有动画。
|
|
14246
|
+
*/ _proto.getPlayAnimationIndex = function getPlayAnimationIndex(treeOptions) {
|
|
14247
|
+
var animations = treeOptions.animations;
|
|
14248
|
+
if (animations === undefined || animations.length <= 0) {
|
|
14249
|
+
// 硬编码,内部指定的不播放动画的索引值
|
|
14250
|
+
return -1;
|
|
14251
|
+
}
|
|
14252
|
+
if (this.isPlayAllAnimation()) {
|
|
14253
|
+
// 硬编码,内部指定的播放全部动画的索引值
|
|
14254
|
+
return -88888888;
|
|
14255
|
+
}
|
|
14256
|
+
var animationInfo = this.sceneOptions.effects.playAnimation;
|
|
14257
|
+
if (animationInfo === undefined) {
|
|
14258
|
+
return -1;
|
|
14259
|
+
}
|
|
14260
|
+
if (typeof animationInfo === "number") {
|
|
14261
|
+
if (animationInfo >= 0 && animationInfo < animations.length) {
|
|
14262
|
+
return animationInfo;
|
|
14263
|
+
} else {
|
|
14264
|
+
return -1;
|
|
14265
|
+
}
|
|
14266
|
+
} else {
|
|
14267
|
+
// typeof animationInfo === 'string'
|
|
14268
|
+
var animationIndex = -1;
|
|
14269
|
+
// 通过动画名字查找动画索引
|
|
14270
|
+
animations.forEach(function(anim, index) {
|
|
14271
|
+
if (anim.name === animationInfo) {
|
|
14272
|
+
animationIndex = index;
|
|
14273
|
+
}
|
|
14274
|
+
});
|
|
14275
|
+
return animationIndex;
|
|
14276
|
+
}
|
|
14277
|
+
};
|
|
14278
|
+
_proto.isPlayAnimation = function isPlayAnimation() {
|
|
14279
|
+
return this.sceneOptions.effects.playAnimation !== undefined;
|
|
14280
|
+
};
|
|
14281
|
+
_proto.isPlayAllAnimation = function isPlayAllAnimation() {
|
|
14282
|
+
return this.sceneOptions.effects.playAllAnimation === true;
|
|
14283
|
+
};
|
|
14284
|
+
_proto.getRemarkString = function getRemarkString() {
|
|
14285
|
+
var remark = this.sceneOptions.gltf.remark;
|
|
14286
|
+
if (remark === undefined) {
|
|
14287
|
+
return "Unknown";
|
|
14288
|
+
} else if (typeof remark === "string") {
|
|
14289
|
+
return remark;
|
|
14290
|
+
} else {
|
|
14291
|
+
return "BinaryBuffer";
|
|
14292
|
+
}
|
|
14293
|
+
};
|
|
14294
|
+
_proto.getCompositionDuration = function getCompositionDuration() {
|
|
14295
|
+
return this.composition.duration;
|
|
14296
|
+
};
|
|
14297
|
+
_proto.isTiny3dMode = function isTiny3dMode() {
|
|
14298
|
+
return this.loaderOptions.compatibleMode === "tiny3d";
|
|
14299
|
+
};
|
|
14300
|
+
_proto.getItemDuration = function getItemDuration() {
|
|
14301
|
+
var _this_sceneOptions_effects_duration;
|
|
14302
|
+
return (_this_sceneOptions_effects_duration = this.sceneOptions.effects.duration) != null ? _this_sceneOptions_effects_duration : 9999;
|
|
14303
|
+
};
|
|
14304
|
+
_proto.getItemEndBehavior = function getItemEndBehavior() {
|
|
14305
|
+
var _this_sceneOptions_effects_endBehavior;
|
|
14306
|
+
return (_this_sceneOptions_effects_endBehavior = this.sceneOptions.effects.endBehavior) != null ? _this_sceneOptions_effects_endBehavior : EFFECTS.spec.ItemEndBehavior.loop;
|
|
14307
|
+
};
|
|
14308
|
+
_proto.getSkyboxType = function getSkyboxType() {
|
|
14309
|
+
var typeName = this.sceneOptions.gltf.skyboxType;
|
|
14310
|
+
switch(typeName){
|
|
14311
|
+
case "NFT":
|
|
14312
|
+
return exports.PSkyboxType.NFT;
|
|
14313
|
+
case "FARM":
|
|
14314
|
+
return exports.PSkyboxType.FARM;
|
|
14315
|
+
}
|
|
14316
|
+
};
|
|
14317
|
+
_proto.isSkyboxVis = function isSkyboxVis() {
|
|
14318
|
+
return this.sceneOptions.gltf.skyboxVis === true;
|
|
14319
|
+
};
|
|
14320
|
+
_proto.ignoreSkybox = function ignoreSkybox() {
|
|
14321
|
+
return this.sceneOptions.gltf.ignoreSkybox === true;
|
|
14322
|
+
};
|
|
14323
|
+
_proto.isEnvironmentTest = function isEnvironmentTest() {
|
|
14324
|
+
if (typeof this.sceneOptions.gltf.remark === "string") {
|
|
14325
|
+
return this.sceneOptions.gltf.remark.includes("EnvironmentTest");
|
|
14326
|
+
} else {
|
|
14327
|
+
return false;
|
|
14328
|
+
}
|
|
14329
|
+
};
|
|
14330
|
+
return LoaderECSImpl;
|
|
14331
|
+
}();
|
|
14332
|
+
var globalLoader;
|
|
14333
|
+
function getDefaultEffectsGLTFLoaderECS(engine, options) {
|
|
14334
|
+
if (!globalLoader) {
|
|
14335
|
+
globalLoader = new LoaderECSImpl();
|
|
14336
|
+
}
|
|
14337
|
+
globalLoader.initial(engine, options);
|
|
14338
|
+
return globalLoader;
|
|
14339
|
+
}
|
|
14340
|
+
function setDefaultEffectsGLTFLoaderECS(loader) {
|
|
14341
|
+
globalLoader = loader;
|
|
14342
|
+
}
|
|
14343
|
+
function getPBRShaderProperties() {
|
|
14344
|
+
return '\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _MetallicRoughnessSampler ("金属贴图", 2D) = "" {}\n _MetallicFactor ("金属度", Range(0, 1)) = 1\n _RoughnessFactor ("粗糙度", Range(0, 1)) = 1\n [Toggle] _SpecularAA ("高光抗锯齿", Float) = 0\n _NormalSampler ("法线贴图", 2D) = "" {}\n _NormalScale ("法线贴图强度", Range(0, 2)) = 1\n _OcclusionSampler ("AO贴图", 2D) = "" {}\n _OcclusionStrength ("AO贴图强度", Range(0, 1)) = 1\n _EmissiveSampler ("自发光贴图", 2D) = "" {}\n _EmissiveIntensity ("自发光贴图强度", Float) = 1\n _EmissiveFactor ("自发光颜色", Color) = (0, 0, 0, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n ';
|
|
14345
|
+
}
|
|
14346
|
+
function getUnlitShaderProperties() {
|
|
14347
|
+
return '\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n ';
|
|
14348
|
+
}
|
|
14349
|
+
function getDefaultPBRMaterialData() {
|
|
14350
|
+
var material = {
|
|
14351
|
+
"id": "00000000000000000000000000000000",
|
|
14352
|
+
"name": "PBR Material",
|
|
14353
|
+
"dataType": EFFECTS.spec.DataType.Material,
|
|
14354
|
+
"stringTags": {
|
|
14355
|
+
"RenderType": EFFECTS.spec.RenderType.Opaque,
|
|
14356
|
+
"RenderFace": "Front"
|
|
14357
|
+
},
|
|
14358
|
+
"macros": [],
|
|
14359
|
+
"shader": {
|
|
14360
|
+
"id": "pbr00000000000000000000000000000"
|
|
14361
|
+
},
|
|
14362
|
+
"ints": {},
|
|
14363
|
+
"floats": {
|
|
14364
|
+
"ZWrite": 1,
|
|
14365
|
+
"ZTest": 1,
|
|
14366
|
+
"_SpecularAA": 0,
|
|
14367
|
+
"_MetallicFactor": 1,
|
|
14368
|
+
"_RoughnessFactor": 0.0,
|
|
14369
|
+
"_NormalScale": 1,
|
|
14370
|
+
"_OcclusionStrength": 1,
|
|
14371
|
+
"_EmissiveIntensity": 1,
|
|
14372
|
+
"_AlphaCutoff": 0.5
|
|
14373
|
+
},
|
|
14374
|
+
"vector4s": {},
|
|
14375
|
+
"colors": {
|
|
14376
|
+
"_BaseColorFactor": {
|
|
14377
|
+
"r": 1,
|
|
14378
|
+
"g": 1,
|
|
14379
|
+
"b": 1,
|
|
14380
|
+
"a": 1
|
|
14381
|
+
},
|
|
14382
|
+
"_EmissiveFactor": {
|
|
14383
|
+
"r": 0,
|
|
14384
|
+
"g": 0,
|
|
14385
|
+
"b": 0,
|
|
14386
|
+
"a": 1
|
|
14387
|
+
}
|
|
14388
|
+
},
|
|
14389
|
+
"textures": {}
|
|
14390
|
+
};
|
|
14391
|
+
return material;
|
|
14392
|
+
}
|
|
14393
|
+
function getDefaultUnlitMaterialData() {
|
|
14394
|
+
var material = {
|
|
14395
|
+
"id": "00000000000000000000000000000000",
|
|
14396
|
+
"name": "Unlit Material",
|
|
14397
|
+
"dataType": EFFECTS.spec.DataType.Material,
|
|
14398
|
+
"stringTags": {
|
|
14399
|
+
"ZWrite": "true",
|
|
14400
|
+
"ZTest": "true",
|
|
14401
|
+
"RenderType": EFFECTS.spec.RenderType.Opaque,
|
|
14402
|
+
"Cull": "Front"
|
|
14403
|
+
},
|
|
14404
|
+
"macros": [],
|
|
14405
|
+
"shader": {
|
|
14406
|
+
"id": "unlit000000000000000000000000000"
|
|
14407
|
+
},
|
|
14408
|
+
"ints": {},
|
|
14409
|
+
"floats": {
|
|
14410
|
+
"_AlphaCutoff": 0.5
|
|
14411
|
+
},
|
|
14412
|
+
"vector4s": {},
|
|
14413
|
+
"colors": {
|
|
14414
|
+
"_BaseColorFactor": {
|
|
14415
|
+
"r": 1,
|
|
14416
|
+
"g": 1,
|
|
14417
|
+
"b": 1,
|
|
14418
|
+
"a": 1
|
|
14419
|
+
}
|
|
14420
|
+
},
|
|
14421
|
+
"textures": {}
|
|
14422
|
+
};
|
|
14423
|
+
return material;
|
|
14424
|
+
}
|
|
14425
|
+
|
|
13382
14426
|
EFFECTS.registerPlugin("tree", ModelTreePlugin, EFFECTS.VFXItem, true);
|
|
13383
14427
|
EFFECTS.registerPlugin("model", ModelPlugin, EFFECTS.VFXItem);
|
|
13384
|
-
var version = "2.0.0-alpha.
|
|
14428
|
+
var version = "2.0.0-alpha.19";
|
|
13385
14429
|
EFFECTS.logger.info("Plugin model version: " + version + ".");
|
|
13386
14430
|
if (version !== EFFECTS__namespace.version) {
|
|
13387
14431
|
console.error("注意:请统一 Model 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Model plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
|
|
@@ -13404,6 +14448,7 @@ exports.HitTestingProxy = HitTestingProxy;
|
|
|
13404
14448
|
exports.HookOGLFunc = HookOGLFunc;
|
|
13405
14449
|
exports.InterpolationSampler = InterpolationSampler;
|
|
13406
14450
|
exports.JSONConverter = JSONConverter;
|
|
14451
|
+
exports.LoaderECSImpl = LoaderECSImpl;
|
|
13407
14452
|
exports.LoaderHelper = LoaderHelper;
|
|
13408
14453
|
exports.LoaderImpl = LoaderImpl;
|
|
13409
14454
|
exports.Matrix3 = Matrix3;
|
|
@@ -13461,6 +14506,9 @@ exports.createPluginMaterial = createPluginMaterial;
|
|
|
13461
14506
|
exports.fetchPBRShaderCode = fetchPBRShaderCode;
|
|
13462
14507
|
exports.fetchUnlitShaderCode = fetchUnlitShaderCode;
|
|
13463
14508
|
exports.getDefaultEffectsGLTFLoader = getDefaultEffectsGLTFLoader;
|
|
14509
|
+
exports.getDefaultEffectsGLTFLoaderECS = getDefaultEffectsGLTFLoaderECS;
|
|
14510
|
+
exports.getDefaultPBRMaterialData = getDefaultPBRMaterialData;
|
|
14511
|
+
exports.getDefaultUnlitMaterialData = getDefaultUnlitMaterialData;
|
|
13464
14512
|
exports.getDiffuseOnlyShaderCode = getDiffuseOnlyShaderCode;
|
|
13465
14513
|
exports.getGaussianBlurShaderCodeV1 = getGaussianBlurShaderCodeV1;
|
|
13466
14514
|
exports.getGaussianBlurShaderCodeV2 = getGaussianBlurShaderCodeV2;
|
|
@@ -13469,6 +14517,7 @@ exports.getGeometryDataFromPropsList = getGeometryDataFromPropsList;
|
|
|
13469
14517
|
exports.getKawaseBlurShaderCode = getKawaseBlurShaderCode;
|
|
13470
14518
|
exports.getNormalVisShaderCode = getNormalVisShaderCode;
|
|
13471
14519
|
exports.getPBRPassShaderCode = getPBRPassShaderCode;
|
|
14520
|
+
exports.getPBRShaderProperties = getPBRShaderProperties;
|
|
13472
14521
|
exports.getPMeshList = getPMeshList;
|
|
13473
14522
|
exports.getQuadFilterShaderCode = getQuadFilterShaderCode;
|
|
13474
14523
|
exports.getRendererGPUInfo = getRendererGPUInfo;
|
|
@@ -13478,6 +14527,8 @@ exports.getSimpleFilterShaderCode = getSimpleFilterShaderCode;
|
|
|
13478
14527
|
exports.getSkyBoxShaderCode = getSkyBoxShaderCode;
|
|
13479
14528
|
exports.getTransparecyBaseShader = getTransparecyBaseShader;
|
|
13480
14529
|
exports.getTransparecyFilterShader = getTransparecyFilterShader;
|
|
14530
|
+
exports.getUnlitShaderProperties = getUnlitShaderProperties;
|
|
13481
14531
|
exports.setDefaultEffectsGLTFLoader = setDefaultEffectsGLTFLoader;
|
|
14532
|
+
exports.setDefaultEffectsGLTFLoaderECS = setDefaultEffectsGLTFLoaderECS;
|
|
13482
14533
|
exports.version = version;
|
|
13483
14534
|
//# sourceMappingURL=alipay.js.map
|