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