@galacean/effects-plugin-model 2.0.0-alpha.21 → 2.0.0-alpha.23

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.mjs CHANGED
@@ -11990,11 +11990,11 @@ var vertexBufferSemanticMap = {
11990
11990
  a_Target_Tangent3: "TANGENT_BS3"
11991
11991
  };
11992
11992
 
11993
- function getDefaultEffectsGLTFLoader(options) {
11993
+ function getDefaultEffectsGLTFLoader(engine, options) {
11994
11994
  if (!defaultGLTFLoader) {
11995
11995
  defaultGLTFLoader = new LoaderImpl();
11996
11996
  }
11997
- defaultGLTFLoader.initial(options);
11997
+ defaultGLTFLoader.initial(engine, options);
11998
11998
  return defaultGLTFLoader;
11999
11999
  }
12000
12000
  function setDefaultEffectsGLTFLoader(loader) {
@@ -12187,11 +12187,8 @@ var LoaderImpl = /*#__PURE__*/ function() {
12187
12187
  });
12188
12188
  if (texData) {
12189
12189
  var newId = generateGUID();
12190
- // @ts-expect-error
12191
- var newTexData = _extends({}, texData);
12192
- newTexData.textureOptions = _extends({}, texData.textureOptions, {
12193
- id: newId
12194
- });
12190
+ var newTexData = texData.clone();
12191
+ newTexData.textureOptions.id = newId;
12195
12192
  textures.push(newTexData);
12196
12193
  textureDataMap[newId] = newTexData.textureOptions;
12197
12194
  textureIdMap[baseColorId] = newId;
@@ -12455,7 +12452,8 @@ var LoaderImpl = /*#__PURE__*/ function() {
12455
12452
  options.premultiplyAlpha = premultiplyAlpha;
12456
12453
  options.generateMipmap = generateMipmap;
12457
12454
  };
12458
- _proto.initial = function initial(options) {
12455
+ _proto.initial = function initial(engine, options) {
12456
+ this.engine = engine;
12459
12457
  this.loaderOptions = options != null ? options : {};
12460
12458
  };
12461
12459
  _proto.checkMeshComponentData = function checkMeshComponentData(mesh, resource) {
@@ -12855,6 +12853,286 @@ var LoaderImpl = /*#__PURE__*/ function() {
12855
12853
  return false;
12856
12854
  }
12857
12855
  };
12856
+ /**
12857
+ * for old scene compatibility
12858
+ */ _proto.processLight = function processLight(lights, fromGLTF) {
12859
+ var _this = this;
12860
+ lights.forEach(function(l) {
12861
+ if (l.color === undefined) {
12862
+ if (fromGLTF) {
12863
+ l.color = [
12864
+ 255,
12865
+ 255,
12866
+ 255,
12867
+ 255
12868
+ ];
12869
+ } else {
12870
+ l.color = [
12871
+ 1,
12872
+ 1,
12873
+ 1,
12874
+ 1
12875
+ ];
12876
+ }
12877
+ } else {
12878
+ l.color[0] = _this.scaleColorVal(l.color[0], fromGLTF);
12879
+ l.color[1] = _this.scaleColorVal(l.color[1], fromGLTF);
12880
+ l.color[2] = _this.scaleColorVal(l.color[2], fromGLTF);
12881
+ l.color[3] = _this.scaleColorVal(l.color[3], fromGLTF);
12882
+ }
12883
+ });
12884
+ };
12885
+ _proto.processCamera = function processCamera(cameras, fromGLTF) {
12886
+ var scale = fromGLTF ? 180.0 / Math.PI : Math.PI / 180.0;
12887
+ cameras.forEach(function(camera) {
12888
+ if (camera.perspective !== undefined) {
12889
+ camera.perspective.yfov *= scale;
12890
+ }
12891
+ });
12892
+ };
12893
+ _proto.processMaterial = function processMaterial(materials, fromGLTF) {
12894
+ var _this = this;
12895
+ materials.forEach(function(mat) {
12896
+ if (mat.baseColorFactor === undefined) {
12897
+ if (fromGLTF) {
12898
+ mat.baseColorFactor = [
12899
+ 255,
12900
+ 255,
12901
+ 255,
12902
+ 255
12903
+ ];
12904
+ } else {
12905
+ mat.baseColorFactor = [
12906
+ 1,
12907
+ 1,
12908
+ 1,
12909
+ 1
12910
+ ];
12911
+ }
12912
+ } else {
12913
+ mat.baseColorFactor[0] = _this.scaleColorVal(mat.baseColorFactor[0], fromGLTF);
12914
+ mat.baseColorFactor[1] = _this.scaleColorVal(mat.baseColorFactor[1], fromGLTF);
12915
+ mat.baseColorFactor[2] = _this.scaleColorVal(mat.baseColorFactor[2], fromGLTF);
12916
+ mat.baseColorFactor[3] = _this.scaleColorVal(mat.baseColorFactor[3], fromGLTF);
12917
+ }
12918
+ if (mat.emissiveFactor === undefined) {
12919
+ if (fromGLTF) {
12920
+ mat.emissiveFactor = [
12921
+ 255,
12922
+ 255,
12923
+ 255,
12924
+ 255
12925
+ ];
12926
+ } else {
12927
+ mat.emissiveFactor = [
12928
+ 1,
12929
+ 1,
12930
+ 1,
12931
+ 1
12932
+ ];
12933
+ }
12934
+ } else {
12935
+ mat.emissiveFactor[0] = _this.scaleColorVal(mat.emissiveFactor[0], fromGLTF);
12936
+ mat.emissiveFactor[1] = _this.scaleColorVal(mat.emissiveFactor[1], fromGLTF);
12937
+ mat.emissiveFactor[2] = _this.scaleColorVal(mat.emissiveFactor[2], fromGLTF);
12938
+ mat.emissiveFactor[3] = _this.scaleColorVal(mat.emissiveFactor[3], fromGLTF);
12939
+ }
12940
+ if (fromGLTF && mat.occlusionTexture !== undefined && mat.occlusionTexture.strength === undefined) {
12941
+ mat.occlusionTexture.strength = _this.isTiny3dMode() ? 0 : 1;
12942
+ }
12943
+ });
12944
+ };
12945
+ _proto.createTreeOptions = function createTreeOptions(scene) {
12946
+ var nodeList = scene.nodes.map(function(node, nodeIndex) {
12947
+ var children = node.children.map(function(child) {
12948
+ if (child.nodeIndex === undefined) {
12949
+ throw new Error("Undefined nodeIndex for child " + child);
12950
+ }
12951
+ return child.nodeIndex;
12952
+ });
12953
+ var pos;
12954
+ var quat;
12955
+ var scale;
12956
+ if (node.matrix !== undefined) {
12957
+ if (node.matrix.length !== 16) {
12958
+ throw new Error("Invalid matrix length " + node.matrix.length + " for node " + node);
12959
+ }
12960
+ var mat = Matrix4.fromArray(node.matrix);
12961
+ var transform = mat.getTransform();
12962
+ pos = transform.translation.toArray();
12963
+ quat = transform.rotation.toArray();
12964
+ scale = transform.scale.toArray();
12965
+ } else {
12966
+ if (node.translation !== undefined) {
12967
+ pos = node.translation;
12968
+ }
12969
+ if (node.rotation !== undefined) {
12970
+ quat = node.rotation;
12971
+ }
12972
+ if (node.scale !== undefined) {
12973
+ scale = node.scale;
12974
+ }
12975
+ }
12976
+ node.nodeIndex = nodeIndex;
12977
+ var treeNode = {
12978
+ name: node.name,
12979
+ transform: {
12980
+ position: pos,
12981
+ quat: quat,
12982
+ scale: scale
12983
+ },
12984
+ children: children,
12985
+ id: "" + node.nodeIndex
12986
+ };
12987
+ return treeNode;
12988
+ });
12989
+ var rootNodes = scene.rootNodes.map(function(root) {
12990
+ if (root.nodeIndex === undefined) {
12991
+ throw new Error("Undefined nodeIndex for root " + root);
12992
+ }
12993
+ return root.nodeIndex;
12994
+ });
12995
+ var treeOptions = {
12996
+ nodes: nodeList,
12997
+ children: rootNodes,
12998
+ animation: -1,
12999
+ animations: []
13000
+ };
13001
+ return treeOptions;
13002
+ };
13003
+ _proto.createAnimations = function createAnimations(animations) {
13004
+ return animations.map(function(anim) {
13005
+ var tracks = anim.channels.map(function(channel) {
13006
+ var track = {
13007
+ input: channel.input.array,
13008
+ output: channel.output.array,
13009
+ node: channel.target.node,
13010
+ path: channel.target.path,
13011
+ interpolation: channel.interpolation
13012
+ };
13013
+ return track;
13014
+ });
13015
+ var newAnim = {
13016
+ name: anim.name,
13017
+ tracks: tracks
13018
+ };
13019
+ return newAnim;
13020
+ });
13021
+ };
13022
+ _proto.createGeometry = function createGeometry(primitive, hasSkinAnim) {
13023
+ var proxy = new GeometryProxy(this.engine, primitive, hasSkinAnim);
13024
+ return proxy.geometry;
13025
+ };
13026
+ _proto.createMaterial = function createMaterial(material) {
13027
+ var proxy = new MaterialProxy(material, [], this.isTiny3dMode());
13028
+ return proxy.material;
13029
+ };
13030
+ _proto.createTexture2D = function createTexture2D(image, texture, isBaseColor) {
13031
+ return WebGLHelper.createTexture2D(this.engine, image, texture, isBaseColor, this.isTiny3dMode());
13032
+ };
13033
+ _proto.createTextureCube = function createTextureCube(cubeImages, level0Size) {
13034
+ var _this = this;
13035
+ if (cubeImages.length == 0) {
13036
+ throw new Error("createTextureCube: Invalid cubeImages length " + cubeImages);
13037
+ }
13038
+ var mipmaps = [];
13039
+ cubeImages.forEach(function(cubeImage) {
13040
+ if (cubeImage.length != 6) {
13041
+ throw new Error("createTextureCube: cubeimage count should always be 6, " + cubeImage);
13042
+ }
13043
+ //
13044
+ var imgList = [];
13045
+ cubeImage.forEach(function(img) {
13046
+ if (img.imageData === undefined) {
13047
+ throw new Error("createTextureCube: Invalid image data from " + img);
13048
+ }
13049
+ //
13050
+ imgList.push({
13051
+ type: "buffer",
13052
+ data: img.imageData,
13053
+ mimeType: img.mimeType
13054
+ });
13055
+ });
13056
+ if (_this.isTiny3dMode()) {
13057
+ var ref;
13058
+ ref = [
13059
+ imgList[5],
13060
+ imgList[4]
13061
+ ], imgList[4] = ref[0], imgList[5] = ref[1];
13062
+ }
13063
+ mipmaps.push(imgList);
13064
+ });
13065
+ //
13066
+ if (mipmaps.length == 1) {
13067
+ // no mipmaps
13068
+ return WebGLHelper.createTextureCubeFromBuffer(this.engine, mipmaps[0]);
13069
+ } else {
13070
+ // has mipmaps
13071
+ return WebGLHelper.createTextureCubeMipmapFromBuffer(this.engine, mipmaps, level0Size != null ? level0Size : Math.pow(2, mipmaps.length - 1));
13072
+ }
13073
+ };
13074
+ _proto.createSkybox = function createSkybox(ibl) {
13075
+ var _this = this;
13076
+ var _ibl_reflectionsIntensity;
13077
+ var reflectionsIntensity = (_ibl_reflectionsIntensity = ibl.reflectionsIntensity) != null ? _ibl_reflectionsIntensity : ibl.intensity;
13078
+ var irradianceCoeffs = ibl.irradianceCoefficients;
13079
+ var inSpecularImages = ibl.specularImages;
13080
+ var specularImages = inSpecularImages.map(function(images) {
13081
+ var newImages = images.map(function(img) {
13082
+ var outImg = {
13083
+ type: "buffer",
13084
+ data: img.imageData,
13085
+ mimeType: img.mimeType
13086
+ };
13087
+ return outImg;
13088
+ });
13089
+ if (_this.isTiny3dMode()) {
13090
+ var ref;
13091
+ ref = [
13092
+ newImages[5],
13093
+ newImages[4]
13094
+ ], newImages[4] = ref[0], newImages[5] = ref[1];
13095
+ }
13096
+ return newImages;
13097
+ });
13098
+ var specularMipCount = specularImages.length - 1;
13099
+ var _ibl_specularImageSize;
13100
+ var specularImageSize = (_ibl_specularImageSize = ibl.specularImageSize) != null ? _ibl_specularImageSize : Math.pow(2, specularMipCount);
13101
+ var newIrradianceCoeffs = [];
13102
+ irradianceCoeffs.forEach(function(coeffs) {
13103
+ var _newIrradianceCoeffs;
13104
+ (_newIrradianceCoeffs = newIrradianceCoeffs).push.apply(_newIrradianceCoeffs, [].concat(coeffs));
13105
+ });
13106
+ var params = {
13107
+ type: "buffer",
13108
+ renderable: this.isSkyboxVis(),
13109
+ intensity: ibl.intensity,
13110
+ reflectionsIntensity: reflectionsIntensity,
13111
+ irradianceCoeffs: newIrradianceCoeffs,
13112
+ specularImage: specularImages,
13113
+ specularMipCount: specularMipCount,
13114
+ specularImageSize: specularImageSize
13115
+ };
13116
+ return PSkyboxCreator.createSkyboxOptions(this.engine, params);
13117
+ };
13118
+ _proto.createDefaultSkybox = function createDefaultSkybox(typeName) {
13119
+ if (typeName !== "NFT" && typeName !== "FARM") {
13120
+ throw new Error("Invalid skybox type name " + typeName);
13121
+ }
13122
+ //
13123
+ var typ = typeName === "NFT" ? PSkyboxType.NFT : PSkyboxType.FARM;
13124
+ var params = PSkyboxCreator.getSkyboxParams(typ);
13125
+ return PSkyboxCreator.createSkyboxOptions(this.engine, params);
13126
+ };
13127
+ _proto.scaleColorVal = function scaleColorVal(val, fromGLTF) {
13128
+ return fromGLTF ? LoaderHelper.scaleTo255(val) : LoaderHelper.scaleTo1(val);
13129
+ };
13130
+ _proto.scaleColorVec = function scaleColorVec(vec, fromGLTF) {
13131
+ var _this = this;
13132
+ return vec.map(function(val) {
13133
+ return _this.scaleColorVal(val, fromGLTF);
13134
+ });
13135
+ };
12858
13136
  return LoaderImpl;
12859
13137
  }();
12860
13138
  function getPBRShaderProperties() {
@@ -12939,10 +13217,541 @@ function getDefaultUnlitMaterialData() {
12939
13217
  };
12940
13218
  return material;
12941
13219
  }
13220
+ var GeometryProxy = /*#__PURE__*/ function() {
13221
+ function GeometryProxy(engine, gltfGeometry, hasSkinAnimation) {
13222
+ this.engine = engine;
13223
+ this.gltfGeometry = gltfGeometry;
13224
+ this.hasSkinAnimation = hasSkinAnimation;
13225
+ }
13226
+ var _proto = GeometryProxy.prototype;
13227
+ _proto._getBufferAttrib = function _getBufferAttrib(inAttrib) {
13228
+ var attrib = {
13229
+ type: inAttrib.type,
13230
+ size: inAttrib.itemSize,
13231
+ //stride: inAttrib.stride,
13232
+ //offset: inAttrib.offset,
13233
+ data: inAttrib.array,
13234
+ normalize: inAttrib.normalized
13235
+ };
13236
+ return attrib;
13237
+ };
13238
+ _proto.texCoordAttrib = function texCoordAttrib(index) {
13239
+ return this.gltfGeometry.getTexCoord(index);
13240
+ };
13241
+ _proto.getTargetPosition = function getTargetPosition(index) {
13242
+ return this.gltfGeometry.getAttribute("POSITION" + index);
13243
+ };
13244
+ _proto.getTargetNormal = function getTargetNormal(index) {
13245
+ return this.gltfGeometry.getAttribute("NORMAL" + index);
13246
+ };
13247
+ _proto.getTargetTangent = function getTargetTangent(index) {
13248
+ return this.gltfGeometry.getAttribute("TANGENT" + index);
13249
+ };
13250
+ _create_class(GeometryProxy, [
13251
+ {
13252
+ key: "geometry",
13253
+ get: function get() {
13254
+ var _this = this;
13255
+ var attributes = {};
13256
+ if (this.hasPosition) {
13257
+ var attrib = this.positionAttrib;
13258
+ attributes["a_Position"] = this._getBufferAttrib(attrib);
13259
+ } else {
13260
+ throw new Error("Position attribute missing");
13261
+ }
13262
+ if (this.hasNormal) {
13263
+ var attrib1 = this.normalAttrib;
13264
+ if (attrib1 !== undefined) {
13265
+ attributes["a_Normal"] = this._getBufferAttrib(attrib1);
13266
+ }
13267
+ }
13268
+ if (this.hasTangent) {
13269
+ var attrib2 = this.tangentAttrib;
13270
+ if (attrib2 !== undefined) {
13271
+ attributes["a_Tangent"] = this._getBufferAttrib(attrib2);
13272
+ }
13273
+ }
13274
+ this.texCoordList.forEach(function(val) {
13275
+ var attrib = _this.texCoordAttrib(val);
13276
+ var attribName = "a_UV" + (val + 1);
13277
+ attributes[attribName] = _this._getBufferAttrib(attrib);
13278
+ });
13279
+ if (this.hasSkinAnimation) {
13280
+ var jointAttrib = this.jointAttribute;
13281
+ if (jointAttrib !== undefined) {
13282
+ attributes["a_Joint1"] = this._getBufferAttrib(jointAttrib);
13283
+ }
13284
+ var weightAttrib = this.weightAttribute;
13285
+ if (weightAttrib !== undefined) {
13286
+ attributes["a_Weight1"] = this._getBufferAttrib(weightAttrib);
13287
+ }
13288
+ }
13289
+ /**
13290
+ * 设置Morph动画需要的Attribute,主要包括Position,Normal和Tangent
13291
+ */ for(var i = 0; i < 8; i++){
13292
+ var positionAttrib = this.getTargetPosition(i);
13293
+ if (positionAttrib !== undefined) {
13294
+ attributes["a_Target_Position" + i] = this._getBufferAttrib(positionAttrib);
13295
+ }
13296
+ var normalAttrib = this.getTargetNormal(i);
13297
+ if (normalAttrib !== undefined) {
13298
+ attributes["a_Target_Normal" + i] = this._getBufferAttrib(normalAttrib);
13299
+ }
13300
+ var tangentAttrib = this.getTargetTangent(i);
13301
+ if (tangentAttrib !== undefined) {
13302
+ attributes["a_Target_Tangent" + i] = this._getBufferAttrib(tangentAttrib);
13303
+ }
13304
+ }
13305
+ var indexArray = this.indexArray;
13306
+ if (indexArray !== undefined) {
13307
+ return Geometry.create(this.engine, {
13308
+ attributes: attributes,
13309
+ indices: {
13310
+ data: indexArray
13311
+ },
13312
+ drawStart: 0,
13313
+ drawCount: indexArray.length,
13314
+ mode: glContext.TRIANGLES
13315
+ });
13316
+ } else {
13317
+ return Geometry.create(this.engine, {
13318
+ attributes: attributes,
13319
+ drawStart: 0,
13320
+ drawCount: this.positionAttrib.array.length / 3,
13321
+ mode: glContext.TRIANGLES
13322
+ });
13323
+ }
13324
+ }
13325
+ },
13326
+ {
13327
+ key: "positionAttrib",
13328
+ get: function get() {
13329
+ return this.gltfGeometry.getPosition();
13330
+ }
13331
+ },
13332
+ {
13333
+ key: "normalAttrib",
13334
+ get: function get() {
13335
+ return this.gltfGeometry.getNormal();
13336
+ }
13337
+ },
13338
+ {
13339
+ key: "tangentAttrib",
13340
+ get: function get() {
13341
+ return this.gltfGeometry.getTangent();
13342
+ }
13343
+ },
13344
+ {
13345
+ key: "jointAttribute",
13346
+ get: function get() {
13347
+ return this.gltfGeometry.getJoints(0);
13348
+ }
13349
+ },
13350
+ {
13351
+ key: "weightAttribute",
13352
+ get: function get() {
13353
+ return this.gltfGeometry.getWeights(0);
13354
+ }
13355
+ },
13356
+ {
13357
+ key: "hasPosition",
13358
+ get: function get() {
13359
+ return this.positionAttrib !== undefined;
13360
+ }
13361
+ },
13362
+ {
13363
+ key: "hasNormal",
13364
+ get: function get() {
13365
+ return this.normalAttrib !== undefined;
13366
+ }
13367
+ },
13368
+ {
13369
+ key: "hasTangent",
13370
+ get: function get() {
13371
+ return this.tangentAttrib !== undefined;
13372
+ }
13373
+ },
13374
+ {
13375
+ key: "hasTexCoord",
13376
+ get: function get() {
13377
+ return this.texCoordCount > 0;
13378
+ }
13379
+ },
13380
+ {
13381
+ key: "texCoordCount",
13382
+ get: function get() {
13383
+ for(var i = 0; i < 10; i++){
13384
+ if (this.texCoordAttrib(i) === undefined) {
13385
+ return i;
13386
+ }
13387
+ }
13388
+ return 0;
13389
+ }
13390
+ },
13391
+ {
13392
+ key: "hasJointAttribute",
13393
+ get: function get() {
13394
+ return this.jointAttribute !== undefined;
13395
+ }
13396
+ },
13397
+ {
13398
+ key: "hasWeightAttribute",
13399
+ get: function get() {
13400
+ return this.weightAttribute !== undefined;
13401
+ }
13402
+ },
13403
+ {
13404
+ key: "indexArray",
13405
+ get: function get() {
13406
+ if (this.gltfGeometry.indices === undefined) {
13407
+ return undefined;
13408
+ }
13409
+ switch(this.gltfGeometry.indices.type){
13410
+ case WebGLRenderingContext["UNSIGNED_INT"]:
13411
+ return this.gltfGeometry.indices.array;
13412
+ case WebGLRenderingContext["UNSIGNED_SHORT"]:
13413
+ return this.gltfGeometry.indices.array;
13414
+ case WebGLRenderingContext["UNSIGNED_BYTE"]:
13415
+ return this.gltfGeometry.indices.array;
13416
+ }
13417
+ return undefined;
13418
+ }
13419
+ },
13420
+ {
13421
+ key: "indexCount",
13422
+ get: function get() {
13423
+ if (this.gltfGeometry.indices !== undefined) {
13424
+ return this.gltfGeometry.indices.array.length;
13425
+ } else {
13426
+ return 0;
13427
+ }
13428
+ }
13429
+ },
13430
+ {
13431
+ key: "texCoordList",
13432
+ get: function get() {
13433
+ var texCoords = [];
13434
+ for(var i = 0; i < 10; i++){
13435
+ if (this.texCoordAttrib(i) !== undefined) {
13436
+ texCoords.push(i);
13437
+ } else {
13438
+ break;
13439
+ }
13440
+ }
13441
+ return texCoords;
13442
+ }
13443
+ }
13444
+ ]);
13445
+ return GeometryProxy;
13446
+ }();
13447
+ var MaterialProxy = /*#__PURE__*/ function() {
13448
+ function MaterialProxy(material, textures, tiny3dMode) {
13449
+ this.gltfMaterial = material;
13450
+ this.textures = textures;
13451
+ this.tiny3dMode = tiny3dMode;
13452
+ }
13453
+ var _proto = MaterialProxy.prototype;
13454
+ _proto.getTextureObject = function getTextureObject(index) {
13455
+ if (index < 0 || index >= this.textures.length) {
13456
+ return;
13457
+ }
13458
+ return this.textures[index];
13459
+ };
13460
+ _proto.getTextureObj = function getTextureObj(texInfo) {
13461
+ return texInfo ? this.getTextureObject(texInfo.index) : undefined;
13462
+ };
13463
+ _proto.getTextureCoord = function getTextureCoord(texInfo) {
13464
+ return texInfo ? texInfo.texCoord : undefined;
13465
+ };
13466
+ _proto.getTextureTransform = function getTextureTransform(texInfo) {
13467
+ var _texInfo_extensions;
13468
+ var transform = texInfo == null ? void 0 : (_texInfo_extensions = texInfo.extensions) == null ? void 0 : _texInfo_extensions.KHR_texture_transform;
13469
+ if (transform === undefined) {
13470
+ return;
13471
+ }
13472
+ if (transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined) {
13473
+ return;
13474
+ }
13475
+ return {
13476
+ offset: transform.offset,
13477
+ rotation: transform.rotation,
13478
+ scale: transform.scale
13479
+ };
13480
+ };
13481
+ _proto.getSpecularAA = function getSpecularAA() {
13482
+ var _this_gltfMaterial_extras;
13483
+ return (_this_gltfMaterial_extras = this.gltfMaterial.extras) == null ? void 0 : _this_gltfMaterial_extras.useSpecularAA;
13484
+ };
13485
+ _create_class(MaterialProxy, [
13486
+ {
13487
+ key: "material",
13488
+ get: function get() {
13489
+ var mat = this.gltfMaterial;
13490
+ var isUnlit = GLTFHelper.isUnlitMaterial(mat);
13491
+ var blending = spec.MaterialBlending.opaque;
13492
+ switch(mat.alphaMode){
13493
+ case "OPAQUE":
13494
+ blending = spec.MaterialBlending.opaque;
13495
+ break;
13496
+ case "MASK":
13497
+ blending = spec.MaterialBlending.masked;
13498
+ break;
13499
+ case "BLEND":
13500
+ blending = spec.MaterialBlending.translucent;
13501
+ break;
13502
+ }
13503
+ var side = mat.doubleSided ? spec.SideMode.DOUBLE : spec.SideMode.FRONT;
13504
+ var enableShadow = false;
13505
+ var _mat_alphaCutOff;
13506
+ var alphaCutOff = (_mat_alphaCutOff = mat.alphaCutOff) != null ? _mat_alphaCutOff : 0.5;
13507
+ var name = mat.name;
13508
+ if (isUnlit) {
13509
+ var _mat_extras;
13510
+ return {
13511
+ name: name,
13512
+ type: spec.MaterialType.unlit,
13513
+ baseColorTexture: this.baseColorTextureObj,
13514
+ baseColorTextureCoordinate: this.baseColorTextureCoord,
13515
+ baseColorTextureTransform: this.baseColorTextureTransfrom,
13516
+ baseColorFactor: this.baseColorFactor,
13517
+ //
13518
+ depthMask: (_mat_extras = mat.extras) == null ? void 0 : _mat_extras.depthMask,
13519
+ blending: blending,
13520
+ alphaCutOff: alphaCutOff,
13521
+ side: side
13522
+ };
13523
+ } else {
13524
+ var _mat_extras1;
13525
+ return {
13526
+ name: name,
13527
+ type: spec.MaterialType.pbr,
13528
+ baseColorTexture: this.baseColorTextureObj,
13529
+ baseColorTextureCoordinate: this.baseColorTextureCoord,
13530
+ baseColorTextureTransform: this.baseColorTextureTransfrom,
13531
+ baseColorFactor: this.baseColorFactor,
13532
+ //
13533
+ useSpecularAA: this.getSpecularAA(),
13534
+ //
13535
+ metallicRoughnessTexture: this.metallicRoughnessTextureObj,
13536
+ metallicRoughnessTextureCoordinate: this.metallicRoughnessTextureCoord,
13537
+ metallicRoughnessTextureTransform: this.metallicRoughnessTextureTransfrom,
13538
+ metallicFactor: this.metalicFactor,
13539
+ roughnessFactor: this.roughnessFactor,
13540
+ //
13541
+ normalTexture: this.normalTextureObj,
13542
+ normalTextureCoordinate: this.normalTextureCoord,
13543
+ normalTextureTransform: this.normalTextureTransfrom,
13544
+ normalTextureScale: this.normalTextureScale,
13545
+ //
13546
+ occlusionTexture: this.occlusionTextureObj,
13547
+ occlusionTextureCoordinate: this.occlusionTextureCoord,
13548
+ occlusionTextureTransform: this.occlusionTextureTransfrom,
13549
+ occlusionTextureStrength: this.occlusionTextureStrength,
13550
+ //
13551
+ emissiveTexture: this.emissiveTextureObj,
13552
+ emissiveTextureCoordinate: this.emissiveTextureCoord,
13553
+ emissiveTextureTransform: this.emissiveTextureTransfrom,
13554
+ emissiveFactor: this.emissiveFactor,
13555
+ emissiveIntensity: 1.0,
13556
+ //
13557
+ depthMask: (_mat_extras1 = mat.extras) == null ? void 0 : _mat_extras1.depthMask,
13558
+ blending: blending,
13559
+ alphaCutOff: alphaCutOff,
13560
+ side: side,
13561
+ enableShadow: enableShadow
13562
+ };
13563
+ }
13564
+ }
13565
+ },
13566
+ {
13567
+ key: "baseColorTextureObj",
13568
+ get: function get() {
13569
+ return this.getTextureObj(this.gltfMaterial.baseColorTexture);
13570
+ }
13571
+ },
13572
+ {
13573
+ key: "baseColorTextureCoord",
13574
+ get: function get() {
13575
+ return this.getTextureCoord(this.gltfMaterial.baseColorTexture);
13576
+ }
13577
+ },
13578
+ {
13579
+ key: "baseColorTextureTransfrom",
13580
+ get: function get() {
13581
+ return this.getTextureTransform(this.gltfMaterial.baseColorTexture);
13582
+ }
13583
+ },
13584
+ {
13585
+ key: "metallicRoughnessTextureObj",
13586
+ get: function get() {
13587
+ return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture);
13588
+ }
13589
+ },
13590
+ {
13591
+ key: "metallicRoughnessTextureCoord",
13592
+ get: function get() {
13593
+ return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture);
13594
+ }
13595
+ },
13596
+ {
13597
+ key: "metallicRoughnessTextureTransfrom",
13598
+ get: function get() {
13599
+ return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture);
13600
+ }
13601
+ },
13602
+ {
13603
+ key: "normalTextureObj",
13604
+ get: function get() {
13605
+ return this.getTextureObj(this.gltfMaterial.normalTexture);
13606
+ }
13607
+ },
13608
+ {
13609
+ key: "normalTextureCoord",
13610
+ get: function get() {
13611
+ return this.getTextureCoord(this.gltfMaterial.normalTexture);
13612
+ }
13613
+ },
13614
+ {
13615
+ key: "normalTextureTransfrom",
13616
+ get: function get() {
13617
+ return this.getTextureTransform(this.gltfMaterial.normalTexture);
13618
+ }
13619
+ },
13620
+ {
13621
+ key: "occlusionTextureObj",
13622
+ get: function get() {
13623
+ return this.getTextureObj(this.gltfMaterial.occlusionTexture);
13624
+ }
13625
+ },
13626
+ {
13627
+ key: "occlusionTextureCoord",
13628
+ get: function get() {
13629
+ return this.getTextureCoord(this.gltfMaterial.occlusionTexture);
13630
+ }
13631
+ },
13632
+ {
13633
+ key: "occlusionTextureTransfrom",
13634
+ get: function get() {
13635
+ return this.getTextureTransform(this.gltfMaterial.occlusionTexture);
13636
+ }
13637
+ },
13638
+ {
13639
+ key: "emissiveTextureObj",
13640
+ get: function get() {
13641
+ return this.getTextureObj(this.gltfMaterial.emissiveTexture);
13642
+ }
13643
+ },
13644
+ {
13645
+ key: "emissiveTextureCoord",
13646
+ get: function get() {
13647
+ return this.getTextureCoord(this.gltfMaterial.emissiveTexture);
13648
+ }
13649
+ },
13650
+ {
13651
+ key: "emissiveTextureTransfrom",
13652
+ get: function get() {
13653
+ return this.getTextureTransform(this.gltfMaterial.emissiveTexture);
13654
+ }
13655
+ },
13656
+ {
13657
+ key: "hasEmissive",
13658
+ get: function get() {
13659
+ var factor = this.emissiveFactor;
13660
+ return factor[0] + factor[1] + factor[2] > 0;
13661
+ }
13662
+ },
13663
+ {
13664
+ key: "baseColorFactor",
13665
+ get: function get() {
13666
+ var f = this.gltfMaterial.baseColorFactor;
13667
+ if (f === undefined || f.length != 4) {
13668
+ return [
13669
+ 1,
13670
+ 1,
13671
+ 1,
13672
+ 1
13673
+ ];
13674
+ } else {
13675
+ return [
13676
+ f[0],
13677
+ f[1],
13678
+ f[2],
13679
+ f[3]
13680
+ ];
13681
+ }
13682
+ }
13683
+ },
13684
+ {
13685
+ key: "metalicFactor",
13686
+ get: function get() {
13687
+ var _this_gltfMaterial_metallicFactor;
13688
+ return (_this_gltfMaterial_metallicFactor = this.gltfMaterial.metallicFactor) != null ? _this_gltfMaterial_metallicFactor : 1;
13689
+ }
13690
+ },
13691
+ {
13692
+ key: "roughnessFactor",
13693
+ get: function get() {
13694
+ var _this_gltfMaterial_roughnessFactor;
13695
+ return (_this_gltfMaterial_roughnessFactor = this.gltfMaterial.roughnessFactor) != null ? _this_gltfMaterial_roughnessFactor : 1;
13696
+ }
13697
+ },
13698
+ {
13699
+ key: "normalTextureScale",
13700
+ get: function get() {
13701
+ var _this_gltfMaterial_normalTexture;
13702
+ var _this_gltfMaterial_normalTexture_scale;
13703
+ return (_this_gltfMaterial_normalTexture_scale = (_this_gltfMaterial_normalTexture = this.gltfMaterial.normalTexture) == null ? void 0 : _this_gltfMaterial_normalTexture.scale) != null ? _this_gltfMaterial_normalTexture_scale : 1;
13704
+ }
13705
+ },
13706
+ {
13707
+ key: "occlusionTextureStrength",
13708
+ get: function get() {
13709
+ var _this_gltfMaterial_occlusionTexture;
13710
+ var _this_gltfMaterial_occlusionTexture_strength;
13711
+ return (_this_gltfMaterial_occlusionTexture_strength = (_this_gltfMaterial_occlusionTexture = this.gltfMaterial.occlusionTexture) == null ? void 0 : _this_gltfMaterial_occlusionTexture.strength) != null ? _this_gltfMaterial_occlusionTexture_strength : 1;
13712
+ }
13713
+ },
13714
+ {
13715
+ key: "emissiveFactor",
13716
+ get: function get() {
13717
+ var f = this.gltfMaterial.emissiveFactor;
13718
+ if (f === undefined || f.length != 4) {
13719
+ return [
13720
+ 0,
13721
+ 0,
13722
+ 0,
13723
+ 1
13724
+ ];
13725
+ } else {
13726
+ return [
13727
+ f[0],
13728
+ f[1],
13729
+ f[2],
13730
+ 1.0
13731
+ ];
13732
+ }
13733
+ }
13734
+ }
13735
+ ]);
13736
+ return MaterialProxy;
13737
+ }();
13738
+ var GLTFHelper = /*#__PURE__*/ function() {
13739
+ function GLTFHelper() {}
13740
+ GLTFHelper.isUnlitMaterial = function isUnlitMaterial(mat) {
13741
+ var _mat_extensions;
13742
+ return ((_mat_extensions = mat.extensions) == null ? void 0 : _mat_extensions.KHR_materials_unlit) !== undefined;
13743
+ };
13744
+ GLTFHelper.createBoxFromGLTFBound = function createBoxFromGLTFBound(bound) {
13745
+ var boxMin = Vector3.fromArray(bound.box.min);
13746
+ var boxMax = Vector3.fromArray(bound.box.max);
13747
+ return new Box3(boxMin, boxMax);
13748
+ };
13749
+ return GLTFHelper;
13750
+ }();
12942
13751
 
12943
13752
  registerPlugin("tree", ModelTreePlugin, VFXItem, true);
12944
13753
  registerPlugin("model", ModelPlugin, VFXItem);
12945
- var version = "2.0.0-alpha.21";
13754
+ var version = "2.0.0-alpha.23";
12946
13755
  logger.info("Plugin model version: " + version + ".");
12947
13756
  if (version !== EFFECTS.version) {
12948
13757
  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!");