@galacean/effects-plugin-model 2.0.0-alpha.22 → 2.0.0-alpha.24

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 CHANGED
@@ -1890,6 +1890,9 @@ var deg2rad = Math.PI / 180;
1890
1890
  * Y 轴上视角
1891
1891
  */ _this.fov = 45;
1892
1892
  /**
1893
+ * fov 缩放大小
1894
+ */ _this.fovScaleRatio = 1;
1895
+ /**
1893
1896
  * 纵横比
1894
1897
  */ _this.aspect = 1.0;
1895
1898
  /**
@@ -1929,7 +1932,7 @@ var deg2rad = Math.PI / 180;
1929
1932
  this.transform.fromEffectsTransform(this.owner.transform);
1930
1933
  }
1931
1934
  var reverse = this.clipMode === EFFECTS.spec.CameraClipMode.portrait;
1932
- this.projectionMatrix.perspective(this.fov * deg2rad, this.aspect, this.nearPlane, this.farPlane, reverse);
1935
+ this.projectionMatrix.perspective(this.fov * deg2rad * this.fovScaleRatio, this.aspect, this.nearPlane, this.farPlane, reverse);
1933
1936
  this.viewMatrix = this.matrix.invert();
1934
1937
  };
1935
1938
  /**
@@ -1938,14 +1941,14 @@ var deg2rad = Math.PI / 180;
1938
1941
  * @returns 投影矩阵
1939
1942
  */ _proto.getNewProjectionMatrix = function getNewProjectionMatrix(fov) {
1940
1943
  var reverse = this.clipMode === EFFECTS.spec.CameraClipMode.portrait;
1941
- return new Matrix4().perspective(Math.min(fov * 1.25, 140) * deg2rad, this.aspect, this.nearPlane, this.farPlane, reverse);
1944
+ return new Matrix4().perspective(Math.min(fov * 1.25, 140) * deg2rad * this.fovScaleRatio, this.aspect, this.nearPlane, this.farPlane, reverse);
1942
1945
  };
1943
1946
  /**
1944
1947
  * 计算视角中的包围盒大小
1945
1948
  * @param box - 包围盒
1946
1949
  * @returns 视角中的包围盒
1947
1950
  */ _proto.computeViewAABB = function computeViewAABB(box) {
1948
- var tanTheta = Math.tan(this.fov * deg2rad * 0.5);
1951
+ var tanTheta = Math.tan(this.fov * deg2rad * this.fovScaleRatio * 0.5);
1949
1952
  var aspect = this.aspect;
1950
1953
  var yFarCoord = 0;
1951
1954
  var yNearCoord = 0;
@@ -2075,15 +2078,17 @@ var deg2rad = Math.PI / 180;
2075
2078
  };
2076
2079
  /**
2077
2080
  * 更新默认相机状态,并计算新的透视和相机矩阵
2078
- * @param fovy - 视角
2081
+ * @param fov - 视角
2082
+ * @param fovScaleRatio - 视角缩放比例
2079
2083
  * @param aspect - 纵横比
2080
2084
  * @param nearPlane - 近裁剪平面
2081
2085
  * @param farPlane - 远裁剪平面
2082
2086
  * @param position - 位置
2083
2087
  * @param rotation - 旋转
2084
2088
  * @param clipMode - 剪裁模式
2085
- */ _proto.updateDefaultCamera = function updateDefaultCamera(fovy, aspect, nearPlane, farPlane, position, rotation, clipMode) {
2086
- this.defaultCamera.fov = fovy;
2089
+ */ _proto.updateDefaultCamera = function updateDefaultCamera(fov, fovScaleRatio, aspect, nearPlane, farPlane, position, rotation, clipMode) {
2090
+ this.defaultCamera.fov = fov;
2091
+ this.defaultCamera.fovScaleRatio = fovScaleRatio;
2087
2092
  this.defaultCamera.aspect = aspect;
2088
2093
  this.defaultCamera.nearPlane = nearPlane;
2089
2094
  this.defaultCamera.farPlane = farPlane;
@@ -3751,12 +3756,12 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
3751
3756
  /**
3752
3757
  * 更新默认相机状态,根据传入的相机参数
3753
3758
  * @param camera - 相机参数
3754
- */ _proto.updateDefaultCamera = function updateDefaultCamera(camera) {
3759
+ */ _proto.updateDefaultCamera = function updateDefaultCamera(camera, fovScaleRatio) {
3755
3760
  var effectsTransfrom = new EFFECTS.Transform(_extends({}, camera, {
3756
3761
  valid: true
3757
3762
  }));
3758
3763
  var newTransform = new PTransform().fromEffectsTransform(effectsTransfrom);
3759
- this.cameraManager.updateDefaultCamera(camera.fov, camera.aspect, camera.near, camera.far, newTransform.getPosition(), newTransform.getRotation(), camera.clipMode);
3764
+ this.cameraManager.updateDefaultCamera(camera.fov, fovScaleRatio, camera.aspect, camera.near, camera.far, newTransform.getPosition(), newTransform.getRotation(), camera.clipMode);
3760
3765
  };
3761
3766
  /**
3762
3767
  * 更新插件场景,需要更新内部的相关的插件对象,特别是 Mesh 对象的骨骼动画
@@ -9898,7 +9903,7 @@ exports.ModelPluginComponent = /*#__PURE__*/ function(ItemBehaviour) {
9898
9903
  * @param composition - 当前合成对象
9899
9904
  * @param sceneManager - 当前合成对象绑定的 SceneManager
9900
9905
  */ _proto.updateSceneCamera = function updateSceneCamera(composition) {
9901
- this.scene.updateDefaultCamera(composition.camera.getOptions());
9906
+ this.scene.updateDefaultCamera(composition.camera.getOptions(), composition.camera.getFovScaleRatio());
9902
9907
  };
9903
9908
  _proto.getLightItemCount = function getLightItemCount() {
9904
9909
  var _this_item_composition;
@@ -12013,11 +12018,11 @@ var vertexBufferSemanticMap = {
12013
12018
  a_Target_Tangent3: "TANGENT_BS3"
12014
12019
  };
12015
12020
 
12016
- function getDefaultEffectsGLTFLoader(options) {
12021
+ function getDefaultEffectsGLTFLoader(engine, options) {
12017
12022
  if (!defaultGLTFLoader) {
12018
12023
  defaultGLTFLoader = new LoaderImpl();
12019
12024
  }
12020
- defaultGLTFLoader.initial(options);
12025
+ defaultGLTFLoader.initial(engine, options);
12021
12026
  return defaultGLTFLoader;
12022
12027
  }
12023
12028
  function setDefaultEffectsGLTFLoader(loader) {
@@ -12475,7 +12480,8 @@ var LoaderImpl = /*#__PURE__*/ function() {
12475
12480
  options.premultiplyAlpha = premultiplyAlpha;
12476
12481
  options.generateMipmap = generateMipmap;
12477
12482
  };
12478
- _proto.initial = function initial(options) {
12483
+ _proto.initial = function initial(engine, options) {
12484
+ this.engine = engine;
12479
12485
  this.loaderOptions = options != null ? options : {};
12480
12486
  };
12481
12487
  _proto.checkMeshComponentData = function checkMeshComponentData(mesh, resource) {
@@ -12875,6 +12881,286 @@ var LoaderImpl = /*#__PURE__*/ function() {
12875
12881
  return false;
12876
12882
  }
12877
12883
  };
12884
+ /**
12885
+ * for old scene compatibility
12886
+ */ _proto.processLight = function processLight(lights, fromGLTF) {
12887
+ var _this = this;
12888
+ lights.forEach(function(l) {
12889
+ if (l.color === undefined) {
12890
+ if (fromGLTF) {
12891
+ l.color = [
12892
+ 255,
12893
+ 255,
12894
+ 255,
12895
+ 255
12896
+ ];
12897
+ } else {
12898
+ l.color = [
12899
+ 1,
12900
+ 1,
12901
+ 1,
12902
+ 1
12903
+ ];
12904
+ }
12905
+ } else {
12906
+ l.color[0] = _this.scaleColorVal(l.color[0], fromGLTF);
12907
+ l.color[1] = _this.scaleColorVal(l.color[1], fromGLTF);
12908
+ l.color[2] = _this.scaleColorVal(l.color[2], fromGLTF);
12909
+ l.color[3] = _this.scaleColorVal(l.color[3], fromGLTF);
12910
+ }
12911
+ });
12912
+ };
12913
+ _proto.processCamera = function processCamera(cameras, fromGLTF) {
12914
+ var scale = fromGLTF ? 180.0 / Math.PI : Math.PI / 180.0;
12915
+ cameras.forEach(function(camera) {
12916
+ if (camera.perspective !== undefined) {
12917
+ camera.perspective.yfov *= scale;
12918
+ }
12919
+ });
12920
+ };
12921
+ _proto.processMaterial = function processMaterial(materials, fromGLTF) {
12922
+ var _this = this;
12923
+ materials.forEach(function(mat) {
12924
+ if (mat.baseColorFactor === undefined) {
12925
+ if (fromGLTF) {
12926
+ mat.baseColorFactor = [
12927
+ 255,
12928
+ 255,
12929
+ 255,
12930
+ 255
12931
+ ];
12932
+ } else {
12933
+ mat.baseColorFactor = [
12934
+ 1,
12935
+ 1,
12936
+ 1,
12937
+ 1
12938
+ ];
12939
+ }
12940
+ } else {
12941
+ mat.baseColorFactor[0] = _this.scaleColorVal(mat.baseColorFactor[0], fromGLTF);
12942
+ mat.baseColorFactor[1] = _this.scaleColorVal(mat.baseColorFactor[1], fromGLTF);
12943
+ mat.baseColorFactor[2] = _this.scaleColorVal(mat.baseColorFactor[2], fromGLTF);
12944
+ mat.baseColorFactor[3] = _this.scaleColorVal(mat.baseColorFactor[3], fromGLTF);
12945
+ }
12946
+ if (mat.emissiveFactor === undefined) {
12947
+ if (fromGLTF) {
12948
+ mat.emissiveFactor = [
12949
+ 255,
12950
+ 255,
12951
+ 255,
12952
+ 255
12953
+ ];
12954
+ } else {
12955
+ mat.emissiveFactor = [
12956
+ 1,
12957
+ 1,
12958
+ 1,
12959
+ 1
12960
+ ];
12961
+ }
12962
+ } else {
12963
+ mat.emissiveFactor[0] = _this.scaleColorVal(mat.emissiveFactor[0], fromGLTF);
12964
+ mat.emissiveFactor[1] = _this.scaleColorVal(mat.emissiveFactor[1], fromGLTF);
12965
+ mat.emissiveFactor[2] = _this.scaleColorVal(mat.emissiveFactor[2], fromGLTF);
12966
+ mat.emissiveFactor[3] = _this.scaleColorVal(mat.emissiveFactor[3], fromGLTF);
12967
+ }
12968
+ if (fromGLTF && mat.occlusionTexture !== undefined && mat.occlusionTexture.strength === undefined) {
12969
+ mat.occlusionTexture.strength = _this.isTiny3dMode() ? 0 : 1;
12970
+ }
12971
+ });
12972
+ };
12973
+ _proto.createTreeOptions = function createTreeOptions(scene) {
12974
+ var nodeList = scene.nodes.map(function(node, nodeIndex) {
12975
+ var children = node.children.map(function(child) {
12976
+ if (child.nodeIndex === undefined) {
12977
+ throw new Error("Undefined nodeIndex for child " + child);
12978
+ }
12979
+ return child.nodeIndex;
12980
+ });
12981
+ var pos;
12982
+ var quat;
12983
+ var scale;
12984
+ if (node.matrix !== undefined) {
12985
+ if (node.matrix.length !== 16) {
12986
+ throw new Error("Invalid matrix length " + node.matrix.length + " for node " + node);
12987
+ }
12988
+ var mat = Matrix4.fromArray(node.matrix);
12989
+ var transform = mat.getTransform();
12990
+ pos = transform.translation.toArray();
12991
+ quat = transform.rotation.toArray();
12992
+ scale = transform.scale.toArray();
12993
+ } else {
12994
+ if (node.translation !== undefined) {
12995
+ pos = node.translation;
12996
+ }
12997
+ if (node.rotation !== undefined) {
12998
+ quat = node.rotation;
12999
+ }
13000
+ if (node.scale !== undefined) {
13001
+ scale = node.scale;
13002
+ }
13003
+ }
13004
+ node.nodeIndex = nodeIndex;
13005
+ var treeNode = {
13006
+ name: node.name,
13007
+ transform: {
13008
+ position: pos,
13009
+ quat: quat,
13010
+ scale: scale
13011
+ },
13012
+ children: children,
13013
+ id: "" + node.nodeIndex
13014
+ };
13015
+ return treeNode;
13016
+ });
13017
+ var rootNodes = scene.rootNodes.map(function(root) {
13018
+ if (root.nodeIndex === undefined) {
13019
+ throw new Error("Undefined nodeIndex for root " + root);
13020
+ }
13021
+ return root.nodeIndex;
13022
+ });
13023
+ var treeOptions = {
13024
+ nodes: nodeList,
13025
+ children: rootNodes,
13026
+ animation: -1,
13027
+ animations: []
13028
+ };
13029
+ return treeOptions;
13030
+ };
13031
+ _proto.createAnimations = function createAnimations(animations) {
13032
+ return animations.map(function(anim) {
13033
+ var tracks = anim.channels.map(function(channel) {
13034
+ var track = {
13035
+ input: channel.input.array,
13036
+ output: channel.output.array,
13037
+ node: channel.target.node,
13038
+ path: channel.target.path,
13039
+ interpolation: channel.interpolation
13040
+ };
13041
+ return track;
13042
+ });
13043
+ var newAnim = {
13044
+ name: anim.name,
13045
+ tracks: tracks
13046
+ };
13047
+ return newAnim;
13048
+ });
13049
+ };
13050
+ _proto.createGeometry = function createGeometry(primitive, hasSkinAnim) {
13051
+ var proxy = new GeometryProxy(this.engine, primitive, hasSkinAnim);
13052
+ return proxy.geometry;
13053
+ };
13054
+ _proto.createMaterial = function createMaterial(material) {
13055
+ var proxy = new MaterialProxy(material, [], this.isTiny3dMode());
13056
+ return proxy.material;
13057
+ };
13058
+ _proto.createTexture2D = function createTexture2D(image, texture, isBaseColor) {
13059
+ return WebGLHelper.createTexture2D(this.engine, image, texture, isBaseColor, this.isTiny3dMode());
13060
+ };
13061
+ _proto.createTextureCube = function createTextureCube(cubeImages, level0Size) {
13062
+ var _this = this;
13063
+ if (cubeImages.length == 0) {
13064
+ throw new Error("createTextureCube: Invalid cubeImages length " + cubeImages);
13065
+ }
13066
+ var mipmaps = [];
13067
+ cubeImages.forEach(function(cubeImage) {
13068
+ if (cubeImage.length != 6) {
13069
+ throw new Error("createTextureCube: cubeimage count should always be 6, " + cubeImage);
13070
+ }
13071
+ //
13072
+ var imgList = [];
13073
+ cubeImage.forEach(function(img) {
13074
+ if (img.imageData === undefined) {
13075
+ throw new Error("createTextureCube: Invalid image data from " + img);
13076
+ }
13077
+ //
13078
+ imgList.push({
13079
+ type: "buffer",
13080
+ data: img.imageData,
13081
+ mimeType: img.mimeType
13082
+ });
13083
+ });
13084
+ if (_this.isTiny3dMode()) {
13085
+ var ref;
13086
+ ref = [
13087
+ imgList[5],
13088
+ imgList[4]
13089
+ ], imgList[4] = ref[0], imgList[5] = ref[1];
13090
+ }
13091
+ mipmaps.push(imgList);
13092
+ });
13093
+ //
13094
+ if (mipmaps.length == 1) {
13095
+ // no mipmaps
13096
+ return WebGLHelper.createTextureCubeFromBuffer(this.engine, mipmaps[0]);
13097
+ } else {
13098
+ // has mipmaps
13099
+ return WebGLHelper.createTextureCubeMipmapFromBuffer(this.engine, mipmaps, level0Size != null ? level0Size : Math.pow(2, mipmaps.length - 1));
13100
+ }
13101
+ };
13102
+ _proto.createSkybox = function createSkybox(ibl) {
13103
+ var _this = this;
13104
+ var _ibl_reflectionsIntensity;
13105
+ var reflectionsIntensity = (_ibl_reflectionsIntensity = ibl.reflectionsIntensity) != null ? _ibl_reflectionsIntensity : ibl.intensity;
13106
+ var irradianceCoeffs = ibl.irradianceCoefficients;
13107
+ var inSpecularImages = ibl.specularImages;
13108
+ var specularImages = inSpecularImages.map(function(images) {
13109
+ var newImages = images.map(function(img) {
13110
+ var outImg = {
13111
+ type: "buffer",
13112
+ data: img.imageData,
13113
+ mimeType: img.mimeType
13114
+ };
13115
+ return outImg;
13116
+ });
13117
+ if (_this.isTiny3dMode()) {
13118
+ var ref;
13119
+ ref = [
13120
+ newImages[5],
13121
+ newImages[4]
13122
+ ], newImages[4] = ref[0], newImages[5] = ref[1];
13123
+ }
13124
+ return newImages;
13125
+ });
13126
+ var specularMipCount = specularImages.length - 1;
13127
+ var _ibl_specularImageSize;
13128
+ var specularImageSize = (_ibl_specularImageSize = ibl.specularImageSize) != null ? _ibl_specularImageSize : Math.pow(2, specularMipCount);
13129
+ var newIrradianceCoeffs = [];
13130
+ irradianceCoeffs.forEach(function(coeffs) {
13131
+ var _newIrradianceCoeffs;
13132
+ (_newIrradianceCoeffs = newIrradianceCoeffs).push.apply(_newIrradianceCoeffs, [].concat(coeffs));
13133
+ });
13134
+ var params = {
13135
+ type: "buffer",
13136
+ renderable: this.isSkyboxVis(),
13137
+ intensity: ibl.intensity,
13138
+ reflectionsIntensity: reflectionsIntensity,
13139
+ irradianceCoeffs: newIrradianceCoeffs,
13140
+ specularImage: specularImages,
13141
+ specularMipCount: specularMipCount,
13142
+ specularImageSize: specularImageSize
13143
+ };
13144
+ return PSkyboxCreator.createSkyboxOptions(this.engine, params);
13145
+ };
13146
+ _proto.createDefaultSkybox = function createDefaultSkybox(typeName) {
13147
+ if (typeName !== "NFT" && typeName !== "FARM") {
13148
+ throw new Error("Invalid skybox type name " + typeName);
13149
+ }
13150
+ //
13151
+ var typ = typeName === "NFT" ? exports.PSkyboxType.NFT : exports.PSkyboxType.FARM;
13152
+ var params = PSkyboxCreator.getSkyboxParams(typ);
13153
+ return PSkyboxCreator.createSkyboxOptions(this.engine, params);
13154
+ };
13155
+ _proto.scaleColorVal = function scaleColorVal(val, fromGLTF) {
13156
+ return fromGLTF ? LoaderHelper.scaleTo255(val) : LoaderHelper.scaleTo1(val);
13157
+ };
13158
+ _proto.scaleColorVec = function scaleColorVec(vec, fromGLTF) {
13159
+ var _this = this;
13160
+ return vec.map(function(val) {
13161
+ return _this.scaleColorVal(val, fromGLTF);
13162
+ });
13163
+ };
12878
13164
  return LoaderImpl;
12879
13165
  }();
12880
13166
  function getPBRShaderProperties() {
@@ -12959,10 +13245,541 @@ function getDefaultUnlitMaterialData() {
12959
13245
  };
12960
13246
  return material;
12961
13247
  }
13248
+ var GeometryProxy = /*#__PURE__*/ function() {
13249
+ function GeometryProxy(engine, gltfGeometry, hasSkinAnimation) {
13250
+ this.engine = engine;
13251
+ this.gltfGeometry = gltfGeometry;
13252
+ this.hasSkinAnimation = hasSkinAnimation;
13253
+ }
13254
+ var _proto = GeometryProxy.prototype;
13255
+ _proto._getBufferAttrib = function _getBufferAttrib(inAttrib) {
13256
+ var attrib = {
13257
+ type: inAttrib.type,
13258
+ size: inAttrib.itemSize,
13259
+ //stride: inAttrib.stride,
13260
+ //offset: inAttrib.offset,
13261
+ data: inAttrib.array,
13262
+ normalize: inAttrib.normalized
13263
+ };
13264
+ return attrib;
13265
+ };
13266
+ _proto.texCoordAttrib = function texCoordAttrib(index) {
13267
+ return this.gltfGeometry.getTexCoord(index);
13268
+ };
13269
+ _proto.getTargetPosition = function getTargetPosition(index) {
13270
+ return this.gltfGeometry.getAttribute("POSITION" + index);
13271
+ };
13272
+ _proto.getTargetNormal = function getTargetNormal(index) {
13273
+ return this.gltfGeometry.getAttribute("NORMAL" + index);
13274
+ };
13275
+ _proto.getTargetTangent = function getTargetTangent(index) {
13276
+ return this.gltfGeometry.getAttribute("TANGENT" + index);
13277
+ };
13278
+ _create_class(GeometryProxy, [
13279
+ {
13280
+ key: "geometry",
13281
+ get: function get() {
13282
+ var _this = this;
13283
+ var attributes = {};
13284
+ if (this.hasPosition) {
13285
+ var attrib = this.positionAttrib;
13286
+ attributes["a_Position"] = this._getBufferAttrib(attrib);
13287
+ } else {
13288
+ throw new Error("Position attribute missing");
13289
+ }
13290
+ if (this.hasNormal) {
13291
+ var attrib1 = this.normalAttrib;
13292
+ if (attrib1 !== undefined) {
13293
+ attributes["a_Normal"] = this._getBufferAttrib(attrib1);
13294
+ }
13295
+ }
13296
+ if (this.hasTangent) {
13297
+ var attrib2 = this.tangentAttrib;
13298
+ if (attrib2 !== undefined) {
13299
+ attributes["a_Tangent"] = this._getBufferAttrib(attrib2);
13300
+ }
13301
+ }
13302
+ this.texCoordList.forEach(function(val) {
13303
+ var attrib = _this.texCoordAttrib(val);
13304
+ var attribName = "a_UV" + (val + 1);
13305
+ attributes[attribName] = _this._getBufferAttrib(attrib);
13306
+ });
13307
+ if (this.hasSkinAnimation) {
13308
+ var jointAttrib = this.jointAttribute;
13309
+ if (jointAttrib !== undefined) {
13310
+ attributes["a_Joint1"] = this._getBufferAttrib(jointAttrib);
13311
+ }
13312
+ var weightAttrib = this.weightAttribute;
13313
+ if (weightAttrib !== undefined) {
13314
+ attributes["a_Weight1"] = this._getBufferAttrib(weightAttrib);
13315
+ }
13316
+ }
13317
+ /**
13318
+ * 设置Morph动画需要的Attribute,主要包括Position,Normal和Tangent
13319
+ */ for(var i = 0; i < 8; i++){
13320
+ var positionAttrib = this.getTargetPosition(i);
13321
+ if (positionAttrib !== undefined) {
13322
+ attributes["a_Target_Position" + i] = this._getBufferAttrib(positionAttrib);
13323
+ }
13324
+ var normalAttrib = this.getTargetNormal(i);
13325
+ if (normalAttrib !== undefined) {
13326
+ attributes["a_Target_Normal" + i] = this._getBufferAttrib(normalAttrib);
13327
+ }
13328
+ var tangentAttrib = this.getTargetTangent(i);
13329
+ if (tangentAttrib !== undefined) {
13330
+ attributes["a_Target_Tangent" + i] = this._getBufferAttrib(tangentAttrib);
13331
+ }
13332
+ }
13333
+ var indexArray = this.indexArray;
13334
+ if (indexArray !== undefined) {
13335
+ return EFFECTS.Geometry.create(this.engine, {
13336
+ attributes: attributes,
13337
+ indices: {
13338
+ data: indexArray
13339
+ },
13340
+ drawStart: 0,
13341
+ drawCount: indexArray.length,
13342
+ mode: EFFECTS.glContext.TRIANGLES
13343
+ });
13344
+ } else {
13345
+ return EFFECTS.Geometry.create(this.engine, {
13346
+ attributes: attributes,
13347
+ drawStart: 0,
13348
+ drawCount: this.positionAttrib.array.length / 3,
13349
+ mode: EFFECTS.glContext.TRIANGLES
13350
+ });
13351
+ }
13352
+ }
13353
+ },
13354
+ {
13355
+ key: "positionAttrib",
13356
+ get: function get() {
13357
+ return this.gltfGeometry.getPosition();
13358
+ }
13359
+ },
13360
+ {
13361
+ key: "normalAttrib",
13362
+ get: function get() {
13363
+ return this.gltfGeometry.getNormal();
13364
+ }
13365
+ },
13366
+ {
13367
+ key: "tangentAttrib",
13368
+ get: function get() {
13369
+ return this.gltfGeometry.getTangent();
13370
+ }
13371
+ },
13372
+ {
13373
+ key: "jointAttribute",
13374
+ get: function get() {
13375
+ return this.gltfGeometry.getJoints(0);
13376
+ }
13377
+ },
13378
+ {
13379
+ key: "weightAttribute",
13380
+ get: function get() {
13381
+ return this.gltfGeometry.getWeights(0);
13382
+ }
13383
+ },
13384
+ {
13385
+ key: "hasPosition",
13386
+ get: function get() {
13387
+ return this.positionAttrib !== undefined;
13388
+ }
13389
+ },
13390
+ {
13391
+ key: "hasNormal",
13392
+ get: function get() {
13393
+ return this.normalAttrib !== undefined;
13394
+ }
13395
+ },
13396
+ {
13397
+ key: "hasTangent",
13398
+ get: function get() {
13399
+ return this.tangentAttrib !== undefined;
13400
+ }
13401
+ },
13402
+ {
13403
+ key: "hasTexCoord",
13404
+ get: function get() {
13405
+ return this.texCoordCount > 0;
13406
+ }
13407
+ },
13408
+ {
13409
+ key: "texCoordCount",
13410
+ get: function get() {
13411
+ for(var i = 0; i < 10; i++){
13412
+ if (this.texCoordAttrib(i) === undefined) {
13413
+ return i;
13414
+ }
13415
+ }
13416
+ return 0;
13417
+ }
13418
+ },
13419
+ {
13420
+ key: "hasJointAttribute",
13421
+ get: function get() {
13422
+ return this.jointAttribute !== undefined;
13423
+ }
13424
+ },
13425
+ {
13426
+ key: "hasWeightAttribute",
13427
+ get: function get() {
13428
+ return this.weightAttribute !== undefined;
13429
+ }
13430
+ },
13431
+ {
13432
+ key: "indexArray",
13433
+ get: function get() {
13434
+ if (this.gltfGeometry.indices === undefined) {
13435
+ return undefined;
13436
+ }
13437
+ switch(this.gltfGeometry.indices.type){
13438
+ case WebGLRenderingContext["UNSIGNED_INT"]:
13439
+ return this.gltfGeometry.indices.array;
13440
+ case WebGLRenderingContext["UNSIGNED_SHORT"]:
13441
+ return this.gltfGeometry.indices.array;
13442
+ case WebGLRenderingContext["UNSIGNED_BYTE"]:
13443
+ return this.gltfGeometry.indices.array;
13444
+ }
13445
+ return undefined;
13446
+ }
13447
+ },
13448
+ {
13449
+ key: "indexCount",
13450
+ get: function get() {
13451
+ if (this.gltfGeometry.indices !== undefined) {
13452
+ return this.gltfGeometry.indices.array.length;
13453
+ } else {
13454
+ return 0;
13455
+ }
13456
+ }
13457
+ },
13458
+ {
13459
+ key: "texCoordList",
13460
+ get: function get() {
13461
+ var texCoords = [];
13462
+ for(var i = 0; i < 10; i++){
13463
+ if (this.texCoordAttrib(i) !== undefined) {
13464
+ texCoords.push(i);
13465
+ } else {
13466
+ break;
13467
+ }
13468
+ }
13469
+ return texCoords;
13470
+ }
13471
+ }
13472
+ ]);
13473
+ return GeometryProxy;
13474
+ }();
13475
+ var MaterialProxy = /*#__PURE__*/ function() {
13476
+ function MaterialProxy(material, textures, tiny3dMode) {
13477
+ this.gltfMaterial = material;
13478
+ this.textures = textures;
13479
+ this.tiny3dMode = tiny3dMode;
13480
+ }
13481
+ var _proto = MaterialProxy.prototype;
13482
+ _proto.getTextureObject = function getTextureObject(index) {
13483
+ if (index < 0 || index >= this.textures.length) {
13484
+ return;
13485
+ }
13486
+ return this.textures[index];
13487
+ };
13488
+ _proto.getTextureObj = function getTextureObj(texInfo) {
13489
+ return texInfo ? this.getTextureObject(texInfo.index) : undefined;
13490
+ };
13491
+ _proto.getTextureCoord = function getTextureCoord(texInfo) {
13492
+ return texInfo ? texInfo.texCoord : undefined;
13493
+ };
13494
+ _proto.getTextureTransform = function getTextureTransform(texInfo) {
13495
+ var _texInfo_extensions;
13496
+ var transform = texInfo == null ? void 0 : (_texInfo_extensions = texInfo.extensions) == null ? void 0 : _texInfo_extensions.KHR_texture_transform;
13497
+ if (transform === undefined) {
13498
+ return;
13499
+ }
13500
+ if (transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined) {
13501
+ return;
13502
+ }
13503
+ return {
13504
+ offset: transform.offset,
13505
+ rotation: transform.rotation,
13506
+ scale: transform.scale
13507
+ };
13508
+ };
13509
+ _proto.getSpecularAA = function getSpecularAA() {
13510
+ var _this_gltfMaterial_extras;
13511
+ return (_this_gltfMaterial_extras = this.gltfMaterial.extras) == null ? void 0 : _this_gltfMaterial_extras.useSpecularAA;
13512
+ };
13513
+ _create_class(MaterialProxy, [
13514
+ {
13515
+ key: "material",
13516
+ get: function get() {
13517
+ var mat = this.gltfMaterial;
13518
+ var isUnlit = GLTFHelper.isUnlitMaterial(mat);
13519
+ var blending = EFFECTS.spec.MaterialBlending.opaque;
13520
+ switch(mat.alphaMode){
13521
+ case "OPAQUE":
13522
+ blending = EFFECTS.spec.MaterialBlending.opaque;
13523
+ break;
13524
+ case "MASK":
13525
+ blending = EFFECTS.spec.MaterialBlending.masked;
13526
+ break;
13527
+ case "BLEND":
13528
+ blending = EFFECTS.spec.MaterialBlending.translucent;
13529
+ break;
13530
+ }
13531
+ var side = mat.doubleSided ? EFFECTS.spec.SideMode.DOUBLE : EFFECTS.spec.SideMode.FRONT;
13532
+ var enableShadow = false;
13533
+ var _mat_alphaCutOff;
13534
+ var alphaCutOff = (_mat_alphaCutOff = mat.alphaCutOff) != null ? _mat_alphaCutOff : 0.5;
13535
+ var name = mat.name;
13536
+ if (isUnlit) {
13537
+ var _mat_extras;
13538
+ return {
13539
+ name: name,
13540
+ type: EFFECTS.spec.MaterialType.unlit,
13541
+ baseColorTexture: this.baseColorTextureObj,
13542
+ baseColorTextureCoordinate: this.baseColorTextureCoord,
13543
+ baseColorTextureTransform: this.baseColorTextureTransfrom,
13544
+ baseColorFactor: this.baseColorFactor,
13545
+ //
13546
+ depthMask: (_mat_extras = mat.extras) == null ? void 0 : _mat_extras.depthMask,
13547
+ blending: blending,
13548
+ alphaCutOff: alphaCutOff,
13549
+ side: side
13550
+ };
13551
+ } else {
13552
+ var _mat_extras1;
13553
+ return {
13554
+ name: name,
13555
+ type: EFFECTS.spec.MaterialType.pbr,
13556
+ baseColorTexture: this.baseColorTextureObj,
13557
+ baseColorTextureCoordinate: this.baseColorTextureCoord,
13558
+ baseColorTextureTransform: this.baseColorTextureTransfrom,
13559
+ baseColorFactor: this.baseColorFactor,
13560
+ //
13561
+ useSpecularAA: this.getSpecularAA(),
13562
+ //
13563
+ metallicRoughnessTexture: this.metallicRoughnessTextureObj,
13564
+ metallicRoughnessTextureCoordinate: this.metallicRoughnessTextureCoord,
13565
+ metallicRoughnessTextureTransform: this.metallicRoughnessTextureTransfrom,
13566
+ metallicFactor: this.metalicFactor,
13567
+ roughnessFactor: this.roughnessFactor,
13568
+ //
13569
+ normalTexture: this.normalTextureObj,
13570
+ normalTextureCoordinate: this.normalTextureCoord,
13571
+ normalTextureTransform: this.normalTextureTransfrom,
13572
+ normalTextureScale: this.normalTextureScale,
13573
+ //
13574
+ occlusionTexture: this.occlusionTextureObj,
13575
+ occlusionTextureCoordinate: this.occlusionTextureCoord,
13576
+ occlusionTextureTransform: this.occlusionTextureTransfrom,
13577
+ occlusionTextureStrength: this.occlusionTextureStrength,
13578
+ //
13579
+ emissiveTexture: this.emissiveTextureObj,
13580
+ emissiveTextureCoordinate: this.emissiveTextureCoord,
13581
+ emissiveTextureTransform: this.emissiveTextureTransfrom,
13582
+ emissiveFactor: this.emissiveFactor,
13583
+ emissiveIntensity: 1.0,
13584
+ //
13585
+ depthMask: (_mat_extras1 = mat.extras) == null ? void 0 : _mat_extras1.depthMask,
13586
+ blending: blending,
13587
+ alphaCutOff: alphaCutOff,
13588
+ side: side,
13589
+ enableShadow: enableShadow
13590
+ };
13591
+ }
13592
+ }
13593
+ },
13594
+ {
13595
+ key: "baseColorTextureObj",
13596
+ get: function get() {
13597
+ return this.getTextureObj(this.gltfMaterial.baseColorTexture);
13598
+ }
13599
+ },
13600
+ {
13601
+ key: "baseColorTextureCoord",
13602
+ get: function get() {
13603
+ return this.getTextureCoord(this.gltfMaterial.baseColorTexture);
13604
+ }
13605
+ },
13606
+ {
13607
+ key: "baseColorTextureTransfrom",
13608
+ get: function get() {
13609
+ return this.getTextureTransform(this.gltfMaterial.baseColorTexture);
13610
+ }
13611
+ },
13612
+ {
13613
+ key: "metallicRoughnessTextureObj",
13614
+ get: function get() {
13615
+ return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture);
13616
+ }
13617
+ },
13618
+ {
13619
+ key: "metallicRoughnessTextureCoord",
13620
+ get: function get() {
13621
+ return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture);
13622
+ }
13623
+ },
13624
+ {
13625
+ key: "metallicRoughnessTextureTransfrom",
13626
+ get: function get() {
13627
+ return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture);
13628
+ }
13629
+ },
13630
+ {
13631
+ key: "normalTextureObj",
13632
+ get: function get() {
13633
+ return this.getTextureObj(this.gltfMaterial.normalTexture);
13634
+ }
13635
+ },
13636
+ {
13637
+ key: "normalTextureCoord",
13638
+ get: function get() {
13639
+ return this.getTextureCoord(this.gltfMaterial.normalTexture);
13640
+ }
13641
+ },
13642
+ {
13643
+ key: "normalTextureTransfrom",
13644
+ get: function get() {
13645
+ return this.getTextureTransform(this.gltfMaterial.normalTexture);
13646
+ }
13647
+ },
13648
+ {
13649
+ key: "occlusionTextureObj",
13650
+ get: function get() {
13651
+ return this.getTextureObj(this.gltfMaterial.occlusionTexture);
13652
+ }
13653
+ },
13654
+ {
13655
+ key: "occlusionTextureCoord",
13656
+ get: function get() {
13657
+ return this.getTextureCoord(this.gltfMaterial.occlusionTexture);
13658
+ }
13659
+ },
13660
+ {
13661
+ key: "occlusionTextureTransfrom",
13662
+ get: function get() {
13663
+ return this.getTextureTransform(this.gltfMaterial.occlusionTexture);
13664
+ }
13665
+ },
13666
+ {
13667
+ key: "emissiveTextureObj",
13668
+ get: function get() {
13669
+ return this.getTextureObj(this.gltfMaterial.emissiveTexture);
13670
+ }
13671
+ },
13672
+ {
13673
+ key: "emissiveTextureCoord",
13674
+ get: function get() {
13675
+ return this.getTextureCoord(this.gltfMaterial.emissiveTexture);
13676
+ }
13677
+ },
13678
+ {
13679
+ key: "emissiveTextureTransfrom",
13680
+ get: function get() {
13681
+ return this.getTextureTransform(this.gltfMaterial.emissiveTexture);
13682
+ }
13683
+ },
13684
+ {
13685
+ key: "hasEmissive",
13686
+ get: function get() {
13687
+ var factor = this.emissiveFactor;
13688
+ return factor[0] + factor[1] + factor[2] > 0;
13689
+ }
13690
+ },
13691
+ {
13692
+ key: "baseColorFactor",
13693
+ get: function get() {
13694
+ var f = this.gltfMaterial.baseColorFactor;
13695
+ if (f === undefined || f.length != 4) {
13696
+ return [
13697
+ 1,
13698
+ 1,
13699
+ 1,
13700
+ 1
13701
+ ];
13702
+ } else {
13703
+ return [
13704
+ f[0],
13705
+ f[1],
13706
+ f[2],
13707
+ f[3]
13708
+ ];
13709
+ }
13710
+ }
13711
+ },
13712
+ {
13713
+ key: "metalicFactor",
13714
+ get: function get() {
13715
+ var _this_gltfMaterial_metallicFactor;
13716
+ return (_this_gltfMaterial_metallicFactor = this.gltfMaterial.metallicFactor) != null ? _this_gltfMaterial_metallicFactor : 1;
13717
+ }
13718
+ },
13719
+ {
13720
+ key: "roughnessFactor",
13721
+ get: function get() {
13722
+ var _this_gltfMaterial_roughnessFactor;
13723
+ return (_this_gltfMaterial_roughnessFactor = this.gltfMaterial.roughnessFactor) != null ? _this_gltfMaterial_roughnessFactor : 1;
13724
+ }
13725
+ },
13726
+ {
13727
+ key: "normalTextureScale",
13728
+ get: function get() {
13729
+ var _this_gltfMaterial_normalTexture;
13730
+ var _this_gltfMaterial_normalTexture_scale;
13731
+ return (_this_gltfMaterial_normalTexture_scale = (_this_gltfMaterial_normalTexture = this.gltfMaterial.normalTexture) == null ? void 0 : _this_gltfMaterial_normalTexture.scale) != null ? _this_gltfMaterial_normalTexture_scale : 1;
13732
+ }
13733
+ },
13734
+ {
13735
+ key: "occlusionTextureStrength",
13736
+ get: function get() {
13737
+ var _this_gltfMaterial_occlusionTexture;
13738
+ var _this_gltfMaterial_occlusionTexture_strength;
13739
+ return (_this_gltfMaterial_occlusionTexture_strength = (_this_gltfMaterial_occlusionTexture = this.gltfMaterial.occlusionTexture) == null ? void 0 : _this_gltfMaterial_occlusionTexture.strength) != null ? _this_gltfMaterial_occlusionTexture_strength : 1;
13740
+ }
13741
+ },
13742
+ {
13743
+ key: "emissiveFactor",
13744
+ get: function get() {
13745
+ var f = this.gltfMaterial.emissiveFactor;
13746
+ if (f === undefined || f.length != 4) {
13747
+ return [
13748
+ 0,
13749
+ 0,
13750
+ 0,
13751
+ 1
13752
+ ];
13753
+ } else {
13754
+ return [
13755
+ f[0],
13756
+ f[1],
13757
+ f[2],
13758
+ 1.0
13759
+ ];
13760
+ }
13761
+ }
13762
+ }
13763
+ ]);
13764
+ return MaterialProxy;
13765
+ }();
13766
+ var GLTFHelper = /*#__PURE__*/ function() {
13767
+ function GLTFHelper() {}
13768
+ GLTFHelper.isUnlitMaterial = function isUnlitMaterial(mat) {
13769
+ var _mat_extensions;
13770
+ return ((_mat_extensions = mat.extensions) == null ? void 0 : _mat_extensions.KHR_materials_unlit) !== undefined;
13771
+ };
13772
+ GLTFHelper.createBoxFromGLTFBound = function createBoxFromGLTFBound(bound) {
13773
+ var boxMin = Vector3.fromArray(bound.box.min);
13774
+ var boxMax = Vector3.fromArray(bound.box.max);
13775
+ return new Box3(boxMin, boxMax);
13776
+ };
13777
+ return GLTFHelper;
13778
+ }();
12962
13779
 
12963
13780
  EFFECTS.registerPlugin("tree", ModelTreePlugin, EFFECTS.VFXItem, true);
12964
13781
  EFFECTS.registerPlugin("model", ModelPlugin, EFFECTS.VFXItem);
12965
- var version = "2.0.0-alpha.22";
13782
+ var version = "2.0.0-alpha.24";
12966
13783
  EFFECTS.logger.info("Plugin model version: " + version + ".");
12967
13784
  if (version !== EFFECTS__namespace.version) {
12968
13785
  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!");