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