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