@galacean/effects-plugin-model 2.1.0-alpha.7 → 2.1.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/alipay.js CHANGED
@@ -1503,144 +1503,6 @@ exports.PAnimPathType = void 0;
1503
1503
  PAnimPathType[PAnimPathType["scale"] = 2] = "scale";
1504
1504
  PAnimPathType[PAnimPathType["weights"] = 3] = "weights";
1505
1505
  })(exports.PAnimPathType || (exports.PAnimPathType = {}));
1506
- /**
1507
- * 动画轨道类
1508
- */ var PAnimTrack = /*#__PURE__*/ function() {
1509
- function PAnimTrack(options) {
1510
- /**
1511
- * 路径类型
1512
- */ this.path = 0;
1513
- /**
1514
- * 插值类型
1515
- */ this.interp = 0;
1516
- var node = options.node, input = options.input, output = options.output, path = options.path, interpolation = options.interpolation;
1517
- this.node = node;
1518
- this.timeArray = input;
1519
- this.dataArray = output;
1520
- //
1521
- if (path === "translation") {
1522
- this.path = 0;
1523
- this.component = 3;
1524
- } else if (path === "rotation") {
1525
- this.path = 1;
1526
- this.component = 4;
1527
- } else if (path === "scale") {
1528
- this.path = 2;
1529
- this.component = 3;
1530
- } else if (path === "weights") {
1531
- this.path = 3;
1532
- this.component = this.dataArray.length / this.timeArray.length;
1533
- // special checker for weights animation
1534
- if (this.component <= 0) {
1535
- console.error("Invalid weights component: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
1536
- } else if (this.timeArray.length * this.component != this.dataArray.length) {
1537
- console.error("Invalid weights array length: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
1538
- }
1539
- } else {
1540
- // should never happened
1541
- console.error("Invalid path status: " + path + ".");
1542
- }
1543
- if (this.timeArray.length * this.component > this.dataArray.length) {
1544
- throw new Error("Data length mismatch: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
1545
- }
1546
- if (interpolation === "LINEAR") {
1547
- this.interp = 0;
1548
- } else if (interpolation === "STEP") {
1549
- this.interp = 1;
1550
- } else {
1551
- this.interp = 2;
1552
- }
1553
- this.sampler = createAnimationSampler(this.getInterpInfo(), this.timeArray, this.dataArray, this.component, this.getPathInfo());
1554
- }
1555
- var _proto = PAnimTrack.prototype;
1556
- /**
1557
- * 销毁
1558
- */ _proto.dispose = function dispose() {
1559
- var _this_sampler;
1560
- // @ts-expect-error
1561
- this.timeArray = undefined;
1562
- // @ts-expect-error
1563
- this.dataArray = undefined;
1564
- (_this_sampler = this.sampler) == null ? void 0 : _this_sampler.dispose();
1565
- this.sampler = undefined;
1566
- };
1567
- /**
1568
- * 更新节点动画数据
1569
- * @param time - 当前播放时间
1570
- * @param treeItem - 节点树元素
1571
- * @param sceneManager - 3D 场景管理器
1572
- */ _proto.tick = function tick(time, treeItem, sceneManager) {
1573
- var _treeComponent_content;
1574
- var treeComponent = treeItem.getComponent(exports.ModelTreeComponent);
1575
- var node = treeComponent == null ? void 0 : (_treeComponent_content = treeComponent.content) == null ? void 0 : _treeComponent_content.getNodeById(this.node);
1576
- if (this.sampler !== undefined && node !== undefined) {
1577
- var result = this.sampler.evaluate(time);
1578
- switch(this.path){
1579
- case 0:
1580
- node.transform.setPosition(result[0], result[1], result[2]);
1581
- break;
1582
- case 1:
1583
- node.transform.setQuaternion(result[0], result[1], result[2], result[3]);
1584
- break;
1585
- case 2:
1586
- node.transform.setScale(result[0], result[1], result[2]);
1587
- break;
1588
- case 3:
1589
- {
1590
- /**
1591
- * 先生成Mesh的父节点id,然后通过id查询Mesh对象
1592
- * 最后更新Mesh对象权重数据
1593
- */ var parentId = this.genParentId(treeItem.id, this.node);
1594
- var mesh = sceneManager == null ? void 0 : sceneManager.queryMesh(parentId);
1595
- if (mesh !== undefined) {
1596
- mesh.updateMorphWeights(result);
1597
- }
1598
- }
1599
- break;
1600
- }
1601
- } else {
1602
- if (this.sampler !== undefined) {
1603
- console.error("AnimTrack: error", this.sampler, node);
1604
- }
1605
- }
1606
- };
1607
- /**
1608
- * 获取动画结束时间
1609
- * @returns
1610
- */ _proto.getEndTime = function getEndTime() {
1611
- var index = this.timeArray.length - 1;
1612
- return this.timeArray[index];
1613
- };
1614
- /**
1615
- * 生成 Mesh 元素的父节点
1616
- *
1617
- * @param parentId - 父节点 id 名称
1618
- * @param nodeIndex - Mesh 节点索引
1619
- *
1620
- * @returns 生成的 Mesh 节点名称
1621
- */ _proto.genParentId = function genParentId(parentId, nodeIndex) {
1622
- return parentId + "^" + nodeIndex;
1623
- };
1624
- _proto.getPathInfo = function getPathInfo() {
1625
- if (this.path === 2) {
1626
- return "scale";
1627
- } else if (this.path === 1) {
1628
- return "rotation";
1629
- } else {
1630
- return "translation";
1631
- }
1632
- };
1633
- _proto.getInterpInfo = function getInterpInfo() {
1634
- if (this.interp === 2) {
1635
- return "CUBICSPLINE";
1636
- } else if (this.interp === 1) {
1637
- return "STEP";
1638
- } else {
1639
- return "LINEAR";
1640
- }
1641
- };
1642
- return PAnimTrack;
1643
- }();
1644
1506
  /**
1645
1507
  * 动画纹理类
1646
1508
  */ var PAnimTexture = /*#__PURE__*/ function() {
@@ -1727,148 +1589,6 @@ exports.PAnimPathType = void 0;
1727
1589
  };
1728
1590
  return PAnimTexture;
1729
1591
  }();
1730
- /**
1731
- * 动画类,负责动画数据创建、更新和销毁
1732
- */ var PAnimation = /*#__PURE__*/ function(PObject) {
1733
- _inherits(PAnimation, PObject);
1734
- function PAnimation() {
1735
- var _this;
1736
- _this = PObject.apply(this, arguments) || this;
1737
- _this.time = 0;
1738
- _this.duration = 0;
1739
- _this.tracks = [];
1740
- return _this;
1741
- }
1742
- var _proto = PAnimation.prototype;
1743
- /**
1744
- * 创建动画对象
1745
- * @param options - 动画参数
1746
- */ _proto.create = function create(options) {
1747
- var _this = this;
1748
- var _options_name;
1749
- this.name = this.genName((_options_name = options.name) != null ? _options_name : "Unnamed animation");
1750
- this.type = exports.PObjectType.animation;
1751
- //
1752
- this.time = 0;
1753
- this.duration = 0;
1754
- //
1755
- this.tracks = [];
1756
- options.tracks.forEach(function(inTrack) {
1757
- var track = new PAnimTrack(inTrack);
1758
- _this.tracks.push(track);
1759
- _this.duration = Math.max(_this.duration, track.getEndTime());
1760
- });
1761
- };
1762
- /**
1763
- * 动画更新
1764
- * @param time - 当前时间
1765
- * @param treeItem - 场景树元素
1766
- * @param sceneManager - 3D 场景管理器
1767
- */ _proto.tick = function tick(time, treeItem, sceneManager) {
1768
- this.time = time;
1769
- // TODO: 这里时间事件定义不明确,先兼容原先实现
1770
- var newTime = this.time % this.duration;
1771
- this.tracks.forEach(function(track) {
1772
- track.tick(newTime, treeItem, sceneManager);
1773
- });
1774
- };
1775
- /**
1776
- * 销毁
1777
- */ _proto.dispose = function dispose() {
1778
- this.tracks.forEach(function(track) {
1779
- track.dispose();
1780
- });
1781
- this.tracks = [];
1782
- };
1783
- return PAnimation;
1784
- }(PObject);
1785
- /**
1786
- * 动画管理类,负责管理动画对象
1787
- */ var PAnimationManager = /*#__PURE__*/ function(PObject) {
1788
- _inherits(PAnimationManager, PObject);
1789
- function PAnimationManager(treeOptions, ownerItem) {
1790
- var _this;
1791
- _this = PObject.call(this) || this;
1792
- _this.animation = 0;
1793
- _this.speed = 0;
1794
- _this.delay = 0;
1795
- _this.time = 0;
1796
- _this.animations = [];
1797
- var _ownerItem_name;
1798
- _this.name = _this.genName((_ownerItem_name = ownerItem.name) != null ? _ownerItem_name : "Unnamed tree");
1799
- _this.type = exports.PObjectType.animationManager;
1800
- //
1801
- _this.ownerItem = ownerItem;
1802
- var _treeOptions_animation;
1803
- _this.animation = (_treeOptions_animation = treeOptions.animation) != null ? _treeOptions_animation : -1;
1804
- _this.speed = 1.0;
1805
- var _ownerItem_start;
1806
- _this.delay = (_ownerItem_start = ownerItem.start) != null ? _ownerItem_start : 0;
1807
- _this.animations = [];
1808
- if (treeOptions.animations !== undefined) {
1809
- treeOptions.animations.forEach(function(animOpts) {
1810
- var anim = _this.createAnimation(animOpts);
1811
- _this.animations.push(anim);
1812
- });
1813
- }
1814
- return _this;
1815
- }
1816
- var _proto = PAnimationManager.prototype;
1817
- /**
1818
- * 设置场景管理器
1819
- * @param sceneManager - 场景管理器
1820
- */ _proto.setSceneManager = function setSceneManager(sceneManager) {
1821
- this.sceneManager = sceneManager;
1822
- };
1823
- /**
1824
- * 创建动画对象
1825
- * @param animationOpts - 动画参数
1826
- * @returns 动画对象
1827
- */ _proto.createAnimation = function createAnimation(animationOpts) {
1828
- var animation = new PAnimation();
1829
- animation.create(animationOpts);
1830
- return animation;
1831
- };
1832
- /**
1833
- * 动画更新
1834
- * @param deltaSeconds - 更新间隔
1835
- */ _proto.tick = function tick(deltaSeconds) {
1836
- var _this = this;
1837
- var newDeltaSeconds = deltaSeconds * this.speed * 0.001;
1838
- this.time += newDeltaSeconds;
1839
- // TODO: 需要合并到TreeItem中,通过lifetime进行计算
1840
- var itemTime = this.time - this.delay;
1841
- if (itemTime >= 0) {
1842
- if (this.animation >= 0 && this.animation < this.animations.length) {
1843
- var anim = this.animations[this.animation];
1844
- anim.tick(itemTime, this.ownerItem, this.sceneManager);
1845
- } else if (this.animation == -88888888) {
1846
- this.animations.forEach(function(anim) {
1847
- anim.tick(itemTime, _this.ownerItem, _this.sceneManager);
1848
- });
1849
- }
1850
- }
1851
- };
1852
- /**
1853
- * 销毁
1854
- */ _proto.dispose = function dispose() {
1855
- // @ts-expect-error
1856
- this.ownerItem = null;
1857
- this.animations.forEach(function(anim) {
1858
- anim.dispose();
1859
- });
1860
- this.animations = [];
1861
- // @ts-expect-error
1862
- this.sceneManager = null;
1863
- };
1864
- /**
1865
- * 获取场景树元素
1866
- * @returns
1867
- */ _proto.getTreeItem = function getTreeItem() {
1868
- return this.ownerItem;
1869
- };
1870
- return PAnimationManager;
1871
- }(PObject);
1872
1592
 
1873
1593
  var deg2rad = Math.PI / 180;
1874
1594
  /**
@@ -3518,15 +3238,6 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
3518
3238
  _proto.isHide = function isHide() {
3519
3239
  return this.data.hide === true;
3520
3240
  };
3521
- _proto.getParentNode = function getParentNode() {
3522
- var _this_parentItem;
3523
- var nodeIndex = this.getParentIndex();
3524
- var parentTree = (_this_parentItem = this.parentItem) == null ? void 0 : _this_parentItem.getComponent(exports.ModelTreeComponent);
3525
- if (parentTree !== undefined && nodeIndex >= 0) {
3526
- return parentTree.content.getNodeById(nodeIndex);
3527
- }
3528
- return undefined;
3529
- };
3530
3241
  _proto.getParentIndex = function getParentIndex() {
3531
3242
  return -1;
3532
3243
  };
@@ -3964,7 +3675,7 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
3964
3675
 
3965
3676
  var primitiveVert = "precision highp float;\n#define FEATURES\n#include <animation.vert.glsl>\nattribute vec4 aPos;varying vec3 v_Position;\n#ifdef HAS_NORMALS\nattribute vec4 aNormal;\n#endif\n#ifdef HAS_TANGENTS\nattribute vec4 aTangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 v_TBN;\n#else\nvarying vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nattribute vec2 aUV;\n#endif\n#ifdef HAS_UV_SET2\nattribute vec2 aUV2;\n#endif\nvarying vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvarying vec2 v_UVCoord2;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nattribute vec3 aColor;varying vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nattribute vec4 aColor;varying vec4 v_Color;\n#endif\nuniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 _NormalMatrix;\n#ifdef EDITOR_TRANSFORM\nuniform vec4 uEditorTransform;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 _LightViewProjectionMatrix;uniform float _DeltaSceneSize;varying vec4 v_PositionLightSpace;varying vec4 v_dPositionLightSpace;\n#endif\nvec4 getPosition(){vec4 pos=vec4(aPos.xyz,1.0);\n#ifdef USE_MORPHING\npos+=getTargetPosition();\n#endif\n#ifdef USE_SKINNING\npos=getSkinningMatrix()*pos;\n#endif\nreturn pos;}\n#ifdef HAS_NORMALS\nvec4 getNormal(){vec4 normal=aNormal;\n#ifdef USE_MORPHING\nnormal+=getTargetNormal();\n#endif\n#ifdef USE_SKINNING\nnormal=getSkinningNormalMatrix()*normal;\n#endif\nreturn normalize(normal);}\n#endif\n#ifdef HAS_TANGENTS\nvec4 getTangent(){vec4 tangent=aTangent;\n#ifdef USE_MORPHING\ntangent+=getTargetTangent();\n#endif\n#ifdef USE_SKINNING\ntangent=getSkinningMatrix()*tangent;\n#endif\nreturn normalize(tangent);}\n#endif\nvoid main(){vec4 pos=effects_ObjectToWorld*getPosition();v_Position=vec3(pos.xyz)/pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec4 tangent=getTangent();vec3 normalW=normalize(vec3(_NormalMatrix*vec4(getNormal().xyz,0.0)));vec3 tangentW=normalize(vec3(effects_ObjectToWorld*vec4(tangent.xyz,0.0)));vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#else\nv_Normal=normalize(vec3(_NormalMatrix*vec4(getNormal().xyz,0.0)));\n#endif\n#endif\nv_UVCoord1=vec2(0.0,0.0);\n#ifdef HAS_UV_SET1\nv_UVCoord1=aUV;\n#endif\n#ifdef HAS_UV_SET2\nv_UVCoord2=aUV2;\n#endif\n#if defined(HAS_VERTEX_COLOR_VEC3) || defined(HAS_VERTEX_COLOR_VEC4)\nv_Color=aColor;\n#endif\n#ifdef USE_SHADOW_MAPPING\nv_PositionLightSpace=_LightViewProjectionMatrix*pos;vec3 dpos=vec3(_DeltaSceneSize);v_dPositionLightSpace=_LightViewProjectionMatrix*(pos+vec4(dpos,0));\n#endif\ngl_Position=effects_MatrixVP*pos;\n#ifdef EDITOR_TRANSFORM\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
3966
3677
 
3967
- var metallicRoughnessFrag = "\n#define FEATURES\n#extension GL_OES_standard_derivatives : enable\n#if defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef USE_HDR\n#extension GL_OES_texture_float : enable\n#extension GL_OES_texture_float_linear : enable\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include <extensions.frag.glsl>\n#include <tone-mapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadow-common.vert.glsl>\n#include <shadow.frag.glsl>\nstruct Light{vec3 direction;float range;vec3 color;float intensity;vec3 position;float innerConeCos;float outerConeCos;int type;vec2 padding;};const int LightType_Directional=0;const int LightType_Point=1;const int LightType_Spot=2;const int LightType_Ambient=3;\n#ifdef USE_PUNCTUAL\nuniform Light _Lights[LIGHT_COUNT];\n#endif\n#if defined(MATERIAL_SPECULARGLOSSINESS) || defined(MATERIAL_METALLICROUGHNESS)\nuniform float _MetallicFactor;uniform float _RoughnessFactor;uniform vec4 _BaseColorFactor;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\nuniform vec3 _SpecularFactor;uniform vec4 _DiffuseFactor;uniform float _GlossinessFactor;\n#endif\n#ifdef ALPHAMODE_MASK\nuniform float _AlphaCutoff;\n#endif\n#ifdef ADD_FOG\nuniform vec4 _FogColor;\n#ifdef LINEAR_FOG\nuniform float _FogNear;uniform float _FogFar;\n#endif\n#ifdef EXP_FOG\nuniform float _FogDensity;\n#endif\n#endif\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\nuniform vec3 _Camera;uniform int _MipCount;struct MaterialInfo{float perceptualRoughness;vec3 reflectance0;float alphaRoughness;vec3 diffuseColor;vec3 reflectance90;vec3 specularColor;};\n#ifdef ADD_FOG\nvec3 getMixFogColor(vec3 baseColor){vec3 distance=_Camera-v_Position;float fogAmount=0.0;\n#ifdef LINEAR_FOG\nfogAmount=smoothstep(_FogNear,_FogFar,distance[2]);\n#endif\n#ifdef EXP_FOG\n#define LOG2 1.442695\nfogAmount=1.-exp2(-_FogDensity*_FogDensity*distance[2]*distance[2]*LOG2);fogAmount=clamp(fogAmount,0.,1.);\n#endif\nvec3 mixColor=baseColor.rgb+(vec3(_FogColor)-baseColor.rgb)*fogAmount;return mixColor;}\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\n#ifdef USE_IBL\nvec3 getIBLContribution(MaterialInfo materialInfo,vec3 n,vec3 v){float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(materialInfo.perceptualRoughness*float(_MipCount),0.0,float(_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,materialInfo.perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(_brdfLUT,brdfSamplePoint).rg;vec4 diffuseColor=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,_shCoefficients);diffuseColor=vec4(irradiance,1.0);\n#else\ndiffuseColor=textureCube(_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(_SpecularEnvSampler,reflection,lod);\n#endif\n#ifdef USE_HDR\nvec3 diffuseLight=diffuseColor.rgb;vec3 specularLight=specularSample.rgb;\n#else\nvec3 diffuseLight=SRGBtoLINEAR(diffuseColor).rgb;vec3 specularLight=SRGBtoLINEAR(specularSample).rgb;\n#endif\nvec3 diffuse=diffuseLight*materialInfo.diffuseColor;vec3 specular=specularLight*(materialInfo.specularColor*brdf.x+brdf.y);return diffuse*_IblIntensity[0]+specular*_IblIntensity[1];}\n#endif\nvec3 diffuse(MaterialInfo materialInfo){return materialInfo.diffuseColor/M_PI;}vec3 specularReflection(MaterialInfo materialInfo,AngularInfo angularInfo){return materialInfo.reflectance0+(materialInfo.reflectance90-materialInfo.reflectance0)*pow(clamp(1.0-angularInfo.VdotH,0.0,1.0),5.0);}float visibilityOcclusion(MaterialInfo materialInfo,AngularInfo angularInfo){float NdotL=angularInfo.NdotL;float NdotV=angularInfo.NdotV;float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGX=GGXV+GGXL;if(GGX>0.0){return 0.5/GGX;}return 0.0;}float microfacetDistribution(MaterialInfo materialInfo,AngularInfo angularInfo){float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float f=(angularInfo.NdotH*alphaRoughnessSq-angularInfo.NdotH)*angularInfo.NdotH+1.0;return alphaRoughnessSq/(M_PI*f*f);}vec3 getPointShade(vec3 pointToLight,MaterialInfo materialInfo,vec3 normal,vec3 view){AngularInfo angularInfo=getAngularInfo(pointToLight,normal,view);if(angularInfo.NdotL>0.0||angularInfo.NdotV>0.0){vec3 F=specularReflection(materialInfo,angularInfo);float Vis=visibilityOcclusion(materialInfo,angularInfo);float D=microfacetDistribution(materialInfo,angularInfo);vec3 diffuseContrib=(1.0-F)*diffuse(materialInfo);vec3 specContrib=F*Vis*D;return angularInfo.NdotL*(diffuseContrib+specContrib);}return vec3(0.0,0.0,0.0);}float getRangeAttenuation(float range,float distance){if(range<=0.0){return 1.0;}return 1.0/(pow(5.0*distance/range,2.0)+1.0);}float getSpotAttenuation(vec3 pointToLight,vec3 spotDirection,float outerConeCos,float innerConeCos){float actualCos=dot(normalize(spotDirection),normalize(-pointToLight));if(actualCos>outerConeCos){if(actualCos<innerConeCos){return smoothstep(outerConeCos,innerConeCos,actualCos);}return 1.0;}return 0.0;}vec3 applyDirectionalLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=-light.direction;vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return light.intensity*light.color*shade;}vec3 applyPointLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float attenuation=getRangeAttenuation(light.range,distance);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view);return light.color*shade*attenuation*light.intensity;}vec3 applySpotLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float rangeAttenuation=getRangeAttenuation(light.range,distance);float spotAttenuation=getSpotAttenuation(pointToLight,light.direction,light.outerConeCos,light.innerConeCos);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return rangeAttenuation*spotAttenuation*light.intensity*light.color*shade;}vec3 applyAmbientLight(Light light,MaterialInfo materialInfo){return light.intensity*light.color*diffuse(materialInfo);}float weight(float z,float a){return clamp(pow(min(1.0,a*10.0)+0.01,3.0)*1e8*pow(1.0-z*0.9,3.0),1e-2,3e3);}void main(){float perceptualRoughness=0.0;float metallic=0.0;vec4 baseColor=vec4(0.0,0.0,0.0,1.0);vec3 diffuseColor=vec3(0.0);vec3 specularColor=vec3(0.0);vec3 f0=vec3(0.04);\n#ifdef PREVIEW_BORDER\ngl_FragColor=uPreviewColor;return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(_SpecularGlossinessSampler,getSpecularGlossinessUV()));perceptualRoughness=(1.0-sgSample.a*_GlossinessFactor);f0=sgSample.rgb*_SpecularFactor;\n#else\nf0=_SpecularFactor;perceptualRoughness=1.0-_GlossinessFactor;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_DiffuseSampler,getDiffuseUV()))*_DiffuseFactor;\n#else\nbaseColor=SRGBtoLINEAR(_DiffuseFactor);\n#endif\nbaseColor*=getVertexColor();specularColor=f0;float oneMinusSpecularStrength=1.0-max(max(f0.r,f0.g),f0.b);diffuseColor=baseColor.rgb*oneMinusSpecularStrength;\n#ifdef DEBUG_METALLIC\nmetallic=solveMetallic(baseColor.rgb,specularColor,oneMinusSpecularStrength);\n#endif\n#endif\n#ifdef MATERIAL_METALLICROUGHNESS\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nvec4 mrSample=texture2D(_MetallicRoughnessSampler,getMetallicRoughnessUV());perceptualRoughness=mrSample.g*_RoughnessFactor;metallic=mrSample.b*_MetallicFactor;\n#else\nmetallic=_MetallicFactor;perceptualRoughness=_RoughnessFactor;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_BaseColorSampler,getBaseColorUV()))*_BaseColorFactor;\n#else\nbaseColor=SRGBtoLINEAR(_BaseColorFactor);\n#endif\nbaseColor*=getVertexColor();diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);specularColor=mix(f0,baseColor.rgb,metallic);\n#endif\n#ifdef ALPHAMODE_MASK\nif(baseColor.a<_AlphaCutoff){discard;}baseColor.a=1.0;\n#endif\n#ifdef ALPHAMODE_OPAQUE\nbaseColor.a=1.0;\n#endif\n#ifdef MATERIAL_UNLIT\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec3 mixColor=getMixFogColor(baseColor.rgb);vec4 fragColorUnlit=vec4(LINEARtoSRGB(mixColor)*baseColor.a,baseColor.a);\n#else\nvec4 fragColorUnlit=vec4(LINEARtoSRGB(baseColor.rgb)*baseColor.a,baseColor.a);\n#endif\ngl_FragColor=fragColorUnlit;\n#else\n#ifdef DEBUG_UV\ngl_FragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\ngl_FragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\ngl_FragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\ngl_FragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\ngl_FragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\ngl_FragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\ngl_FragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\ngl_FragColor.rgb=vec3(baseColor.a);\n#endif\ngl_FragColor.a=1.0;\n#endif\nreturn;\n#endif\nmetallic=clamp(metallic,0.0,1.0);float alphaRoughness=perceptualRoughness*perceptualRoughness;vec3 normal=getNormal();\n#ifdef USE_SPECULAR_AA\nfloat AARoughnessFactor=getAARoughnessFactor(normal);perceptualRoughness+=AARoughnessFactor;alphaRoughness+=AARoughnessFactor;\n#endif\nperceptualRoughness=clamp(perceptualRoughness,0.04,1.0);alphaRoughness=clamp(alphaRoughness,0.04,1.0);float reflectance=max(max(specularColor.r,specularColor.g),specularColor.b);vec3 specularEnvironmentR0=specularColor.rgb;vec3 specularEnvironmentR90=vec3(clamp(reflectance*50.0,0.0,1.0));MaterialInfo materialInfo=MaterialInfo(perceptualRoughness,specularEnvironmentR0,alphaRoughness,diffuseColor,specularEnvironmentR90,specularColor);vec3 color=vec3(0.0,0.0,0.0);vec3 view=normalize(_Camera-v_Position);float shadow=1.0;\n#ifdef USE_SHADOW_MAPPING\nshadow=getShadowContribution();\n#endif\n#ifdef USE_PUNCTUAL\nfor(int i=0;i<LIGHT_COUNT;++i){Light light=_Lights[i];if(light.type==LightType_Directional){color+=applyDirectionalLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Point){color+=applyPointLight(light,materialInfo,normal,view);}else if(light.type==LightType_Spot){color+=applySpotLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){color+=applyAmbientLight(light,materialInfo);}}\n#endif\n#ifdef USE_IBL\ncolor+=getIBLContribution(materialInfo,normal,view);\n#endif\nfloat ao=1.0;\n#ifdef HAS_OCCLUSION_MAP\nao=texture2D(_OcclusionSampler,getOcclusionUV()).r;color=mix(color,color*ao,_OcclusionStrength);\n#endif\nvec3 emissive=vec3(0);\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec4 toneMapColor=SRGBtoLINEAR(vec4(toneMap(color),baseColor.a));color=getMixFogColor(toneMapColor.rgb);vec4 fragColorOut=vec4(LINEARtoSRGB(color.rgb)*baseColor.a,baseColor.a);\n#else\ncolor=toneMap(color)*baseColor.a;\n#ifdef HAS_EMISSIVE\ncolor+=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\ngl_FragColor=fragColorOut;\n#else\n#ifdef DEBUG_UV\ngl_FragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\ngl_FragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\ngl_FragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\ngl_FragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\ngl_FragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\ngl_FragColor.rgb=vec3(mix(1.0,ao,_OcclusionStrength));\n#else\ngl_FragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\ngl_FragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\ngl_FragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\ngl_FragColor.rgb=vec3(baseColor.a);\n#endif\n#ifdef DEBUG_DIFFUSE\nvec3 debugDiffuse=vec3(0.0);\n#ifdef USE_PUNCTUAL\nvec3 newBaseColor=vec3(dot(_BaseColorFactor.xyz,vec3(0.3)));MaterialInfo diffuseMaterialInfo=MaterialInfo(1.0,vec3(0.0),1.0,newBaseColor,vec3(0.0),vec3(0.0));for(int i=0;i<LIGHT_COUNT;++i){Light light=_Lights[i];if(light.type==LightType_Directional){debugDiffuse+=applyDirectionalLight(light,diffuseMaterialInfo,normal,view,shadow);}else if(light.type==LightType_Point){debugDiffuse+=applyPointLight(light,diffuseMaterialInfo,normal,view);}else if(light.type==LightType_Spot){debugDiffuse+=applySpotLight(light,diffuseMaterialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){debugDiffuse+=applyAmbientLight(light,diffuseMaterialInfo);}}\n#endif\ngl_FragColor.rgb=toneMap(debugDiffuse);\n#endif\ngl_FragColor.a=1.0;\n#endif\n}";
3678
+ var metallicRoughnessFrag = "\n#define FEATURES\n#extension GL_OES_standard_derivatives : enable\n#if defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef USE_HDR\n#extension GL_OES_texture_float : enable\n#extension GL_OES_texture_float_linear : enable\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include <extensions.frag.glsl>\n#include <tone-mapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadow-common.vert.glsl>\n#include <shadow.frag.glsl>\nstruct Light{vec3 direction;float range;vec3 color;float intensity;vec3 position;float innerConeCos;float outerConeCos;int type;vec2 padding;};const int LightType_Directional=0;const int LightType_Point=1;const int LightType_Spot=2;const int LightType_Ambient=3;\n#ifdef USE_PUNCTUAL\nuniform Light _Lights[LIGHT_COUNT];\n#endif\n#if defined(MATERIAL_SPECULARGLOSSINESS) || defined(MATERIAL_METALLICROUGHNESS)\nuniform float _MetallicFactor;uniform float _RoughnessFactor;uniform vec4 _BaseColorFactor;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\nuniform vec3 _SpecularFactor;uniform vec4 _DiffuseFactor;uniform float _GlossinessFactor;\n#endif\n#ifdef ALPHAMODE_MASK\nuniform float _AlphaCutoff;\n#endif\n#ifdef ADD_FOG\nuniform vec4 _FogColor;\n#ifdef LINEAR_FOG\nuniform float _FogNear;uniform float _FogFar;\n#endif\n#ifdef EXP_FOG\nuniform float _FogDensity;\n#endif\n#endif\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\nuniform vec3 _Camera;uniform int _MipCount;struct MaterialInfo{float perceptualRoughness;vec3 reflectance0;float alphaRoughness;vec3 diffuseColor;vec3 reflectance90;vec3 specularColor;};\n#ifdef ADD_FOG\nvec3 getMixFogColor(vec3 baseColor){vec3 distance=_Camera-v_Position;float fogAmount=0.0;\n#ifdef LINEAR_FOG\nfogAmount=smoothstep(_FogNear,_FogFar,distance[2]);\n#endif\n#ifdef EXP_FOG\n#define LOG2 1.442695\nfogAmount=1.-exp2(-_FogDensity*_FogDensity*distance[2]*distance[2]*LOG2);fogAmount=clamp(fogAmount,0.,1.);\n#endif\nvec3 mixColor=baseColor.rgb+(vec3(_FogColor)-baseColor.rgb)*fogAmount;return mixColor;}\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\n#ifdef USE_IBL\nvec3 getIBLContribution(MaterialInfo materialInfo,vec3 n,vec3 v){float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(materialInfo.perceptualRoughness*float(_MipCount),0.0,float(_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,materialInfo.perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(_brdfLUT,brdfSamplePoint).rg;vec4 diffuseColor=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,_shCoefficients);diffuseColor=vec4(irradiance,1.0);\n#else\ndiffuseColor=textureCube(_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(_SpecularEnvSampler,reflection,lod);\n#endif\n#ifdef USE_HDR\nvec3 diffuseLight=diffuseColor.rgb;vec3 specularLight=specularSample.rgb;\n#else\nvec3 diffuseLight=SRGBtoLINEAR(diffuseColor).rgb;vec3 specularLight=SRGBtoLINEAR(specularSample).rgb;\n#endif\nvec3 diffuse=diffuseLight*materialInfo.diffuseColor;vec3 specular=specularLight*(materialInfo.specularColor*brdf.x+brdf.y);return diffuse*_IblIntensity[0]+specular*_IblIntensity[1];}\n#endif\nvec3 diffuse(MaterialInfo materialInfo){return materialInfo.diffuseColor/M_PI;}vec3 specularReflection(MaterialInfo materialInfo,AngularInfo angularInfo){return materialInfo.reflectance0+(materialInfo.reflectance90-materialInfo.reflectance0)*pow(clamp(1.0-angularInfo.VdotH,0.0,1.0),5.0);}float visibilityOcclusion(MaterialInfo materialInfo,AngularInfo angularInfo){float NdotL=angularInfo.NdotL;float NdotV=angularInfo.NdotV;float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGX=GGXV+GGXL;if(GGX>0.0){return 0.5/GGX;}return 0.0;}float microfacetDistribution(MaterialInfo materialInfo,AngularInfo angularInfo){float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float f=(angularInfo.NdotH*alphaRoughnessSq-angularInfo.NdotH)*angularInfo.NdotH+1.0;return alphaRoughnessSq/(M_PI*f*f);}vec3 getPointShade(vec3 pointToLight,MaterialInfo materialInfo,vec3 normal,vec3 view){AngularInfo angularInfo=getAngularInfo(pointToLight,normal,view);if(angularInfo.NdotL>0.0||angularInfo.NdotV>0.0){vec3 F=specularReflection(materialInfo,angularInfo);float Vis=visibilityOcclusion(materialInfo,angularInfo);float D=microfacetDistribution(materialInfo,angularInfo);vec3 diffuseContrib=(1.0-F)*diffuse(materialInfo);vec3 specContrib=F*Vis*D;return angularInfo.NdotL*(diffuseContrib+specContrib);}return vec3(0.0,0.0,0.0);}float getRangeAttenuation(float range,float distance){if(range<=0.0){return 1.0;}return 1.0/(pow(5.0*distance/range,2.0)+1.0);}float getSpotAttenuation(vec3 pointToLight,vec3 spotDirection,float outerConeCos,float innerConeCos){float actualCos=dot(normalize(spotDirection),normalize(-pointToLight));if(actualCos>outerConeCos){if(actualCos<innerConeCos){return smoothstep(outerConeCos,innerConeCos,actualCos);}return 1.0;}return 0.0;}vec3 applyDirectionalLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=-light.direction;vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return light.intensity*light.color*shade;}vec3 applyPointLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float attenuation=getRangeAttenuation(light.range,distance);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view);return light.color*shade*attenuation*light.intensity;}vec3 applySpotLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float rangeAttenuation=getRangeAttenuation(light.range,distance);float spotAttenuation=getSpotAttenuation(pointToLight,light.direction,light.outerConeCos,light.innerConeCos);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return rangeAttenuation*spotAttenuation*light.intensity*light.color*shade;}vec3 applyAmbientLight(Light light,MaterialInfo materialInfo){return light.intensity*light.color*diffuse(materialInfo);}float weight(float z,float a){return clamp(pow(min(1.0,a*10.0)+0.01,3.0)*1e8*pow(1.0-z*0.9,3.0),1e-2,3e3);}void main(){float perceptualRoughness=0.0;float metallic=0.0;vec4 baseColor=vec4(0.0,0.0,0.0,1.0);vec3 diffuseColor=vec3(0.0);vec3 specularColor=vec3(0.0);vec3 f0=vec3(0.04);\n#ifdef PREVIEW_BORDER\ngl_FragColor=uPreviewColor;return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(_SpecularGlossinessSampler,getSpecularGlossinessUV()));perceptualRoughness=(1.0-sgSample.a*_GlossinessFactor);f0=sgSample.rgb*_SpecularFactor;\n#else\nf0=_SpecularFactor;perceptualRoughness=1.0-_GlossinessFactor;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_DiffuseSampler,getDiffuseUV()))*_DiffuseFactor;\n#else\nbaseColor=SRGBtoLINEAR(_DiffuseFactor);\n#endif\nbaseColor*=getVertexColor();specularColor=f0;float oneMinusSpecularStrength=1.0-max(max(f0.r,f0.g),f0.b);diffuseColor=baseColor.rgb*oneMinusSpecularStrength;\n#ifdef DEBUG_METALLIC\nmetallic=solveMetallic(baseColor.rgb,specularColor,oneMinusSpecularStrength);\n#endif\n#endif\n#ifdef MATERIAL_METALLICROUGHNESS\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nvec4 mrSample=texture2D(_MetallicRoughnessSampler,getMetallicRoughnessUV());perceptualRoughness=mrSample.g*_RoughnessFactor;metallic=mrSample.b*_MetallicFactor;\n#else\nmetallic=_MetallicFactor;perceptualRoughness=_RoughnessFactor;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_BaseColorSampler,getBaseColorUV()))*_BaseColorFactor;\n#else\nbaseColor=SRGBtoLINEAR(_BaseColorFactor);\n#endif\nbaseColor*=getVertexColor();diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);specularColor=mix(f0,baseColor.rgb,metallic);\n#endif\n#ifdef ALPHAMODE_MASK\nif(baseColor.a<_AlphaCutoff){discard;}baseColor.a=1.0;\n#endif\n#ifdef ALPHAMODE_OPAQUE\nbaseColor.a=1.0;\n#endif\n#ifdef MATERIAL_UNLIT\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec3 mixColor=getMixFogColor(baseColor.rgb);vec4 fragColorUnlit=vec4(LINEARtoSRGB(mixColor)*baseColor.a,baseColor.a);\n#else\nvec4 fragColorUnlit=vec4(LINEARtoSRGB(baseColor.rgb)*baseColor.a,baseColor.a);\n#endif\ngl_FragColor=fragColorUnlit;\n#else\n#ifdef DEBUG_UV\ngl_FragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\ngl_FragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\ngl_FragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\ngl_FragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\ngl_FragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\ngl_FragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\ngl_FragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\ngl_FragColor.rgb=vec3(baseColor.a);\n#endif\ngl_FragColor.a=1.0;\n#endif\nreturn;\n#endif\nmetallic=clamp(metallic,0.0,1.0);float alphaRoughness=perceptualRoughness*perceptualRoughness;vec3 normal=getNormal();\n#ifdef USE_SPECULAR_AA\nfloat AARoughnessFactor=getAARoughnessFactor(normal);perceptualRoughness+=AARoughnessFactor;alphaRoughness+=AARoughnessFactor;\n#endif\nperceptualRoughness=clamp(perceptualRoughness,0.04,1.0);alphaRoughness=clamp(alphaRoughness,0.04,1.0);float reflectance=max(max(specularColor.r,specularColor.g),specularColor.b);vec3 specularEnvironmentR0=specularColor.rgb;vec3 specularEnvironmentR90=vec3(clamp(reflectance*50.0,0.0,1.0));MaterialInfo materialInfo=MaterialInfo(perceptualRoughness,specularEnvironmentR0,alphaRoughness,diffuseColor,specularEnvironmentR90,specularColor);vec3 color=vec3(0.0,0.0,0.0);vec3 view=normalize(_Camera-v_Position);float shadow=1.0;\n#ifdef USE_SHADOW_MAPPING\nshadow=getShadowContribution();\n#endif\n#ifdef USE_PUNCTUAL\nfor(int i=0;i<LIGHT_COUNT;++i){Light light=_Lights[i];if(light.type==LightType_Directional){color+=applyDirectionalLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Point){color+=applyPointLight(light,materialInfo,normal,view);}else if(light.type==LightType_Spot){color+=applySpotLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){color+=applyAmbientLight(light,materialInfo);}}\n#endif\n#ifdef USE_IBL\ncolor+=getIBLContribution(materialInfo,normal,view);\n#endif\nfloat ao=1.0;\n#ifdef HAS_OCCLUSION_MAP\nao=texture2D(_OcclusionSampler,getOcclusionUV()).r;color=mix(color,color*ao,_OcclusionStrength);\n#endif\nvec3 emissive=vec3(0);\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec4 toneMapColor=SRGBtoLINEAR(vec4(toneMap(color),baseColor.a));color=getMixFogColor(toneMapColor.rgb);vec4 fragColorOut=vec4(LINEARtoSRGB(color.rgb)*baseColor.a,baseColor.a);\n#else\ncolor=toneMap(color)*baseColor.a;\n#ifdef HAS_EMISSIVE\ncolor+=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\ngl_FragColor=fragColorOut;\n#else\n#ifdef DEBUG_UV\ngl_FragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\ngl_FragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\ngl_FragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\ngl_FragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\ngl_FragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\ngl_FragColor.rgb=vec3(mix(1.0,ao,_OcclusionStrength));\n#else\ngl_FragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\ngl_FragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\ngl_FragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\ngl_FragColor.rgb=vec3(baseColor.a);\n#endif\n#ifdef DEBUG_DIFFUSE\nvec3 debugDiffuse=vec3(0.0);\n#ifdef USE_PUNCTUAL\nMaterialInfo diffuseMaterialInfo=MaterialInfo(1.0,f0,1.0,vec3(0.35),f0,f0);for(int i=0;i<LIGHT_COUNT;++i){Light light=_Lights[i];if(light.type==LightType_Directional){debugDiffuse+=applyDirectionalLight(light,diffuseMaterialInfo,normal,view,shadow);}else if(light.type==LightType_Point){debugDiffuse+=applyPointLight(light,diffuseMaterialInfo,normal,view);}else if(light.type==LightType_Spot){debugDiffuse+=applySpotLight(light,diffuseMaterialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){debugDiffuse+=applyAmbientLight(light,diffuseMaterialInfo);}}\n#ifdef USE_IBL\ndebugDiffuse+=getIBLContribution(diffuseMaterialInfo,normal,view);\n#endif\n#endif\ngl_FragColor.rgb=toneMap(debugDiffuse);\n#endif\ngl_FragColor.a=1.0;\n#endif\n}";
3968
3679
 
3969
3680
  var shadowPassFrag = "#define FEATURES\n#include <shadow-common.vert.glsl>\n#if defined(SHADOWMAP_VSM)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nvec4 CalcMomentVSM(float depth){float dx=0.0;float dy=0.0;\n#if defined(SHADOWMAP_VSM) && (defined(GL_OES_standard_derivatives) || defined(WEBGL2))\ndx=dFdx(depth);dy=dFdy(depth);\n#endif\nfloat moment2=depth*depth+0.25*(dx*dx+dy*dy);return vec4(1.0-depth,1.0-moment2,0.0,1.0);}vec4 CalcMomentEVSM(float depth){float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);return vec4(pos,pos*pos,neg,neg*neg);}void main(){\n#if defined(SHADOWMAP_STANDARD) || defined(SHADOWMAP_VSM)\ngl_FragColor=CalcMomentVSM(gl_FragCoord.z);\n#else\ngl_FragColor=CalcMomentEVSM(gl_FragCoord.z);\n#endif\n}";
3970
3681
 
@@ -6197,31 +5908,6 @@ var normal = new Vector3();
6197
5908
  console.error("setupItem3DOptions: Invalid inverseBindMatrices type, " + inverseBindMatrices + ".");
6198
5909
  }
6199
5910
  }
6200
- } else if (item.type === EFFECTS.spec.ItemType.tree) {
6201
- var jsonItem = item;
6202
- var studioItem = item;
6203
- var jsonAnimations = jsonItem.content.options.tree.animations;
6204
- var studioAnimations = studioItem.content.options.tree.animations;
6205
- if (jsonAnimations !== undefined && studioAnimations !== undefined) {
6206
- jsonAnimations.forEach(function(jsonAnim, i) {
6207
- var studioAnim = studioAnimations[i];
6208
- jsonAnim.tracks.forEach(function(jsonTrack, j) {
6209
- var inputArray = typedArrayFromBinary(scene.bins, jsonTrack.input);
6210
- var outputArray = typedArrayFromBinary(scene.bins, jsonTrack.output);
6211
- var studioTrack = studioAnim.tracks[j];
6212
- if (_instanceof1(inputArray, Float32Array)) {
6213
- studioTrack.input = inputArray;
6214
- } else {
6215
- console.error("setupItem3DOptions: Type of inputArray should be float32, " + inputArray + ".");
6216
- }
6217
- if (_instanceof1(outputArray, Float32Array)) {
6218
- studioTrack.output = outputArray;
6219
- } else {
6220
- console.error("setupItem3DOptions: Type of outputArray should be float32, " + outputArray + ".");
6221
- }
6222
- });
6223
- });
6224
- }
6225
5911
  } else if (item.type === EFFECTS.spec.ItemType.skybox) {
6226
5912
  var skybox = item;
6227
5913
  var studioSkybox = item;
@@ -9944,117 +9630,6 @@ exports.ModelPluginComponent = __decorate([
9944
9630
  return pluginComp == null ? void 0 : pluginComp.scene;
9945
9631
  }
9946
9632
 
9947
- /**
9948
- * 场景树元素类,支持插件中节点树相关的动画能力
9949
- */ var ModelTreeItem = /*#__PURE__*/ function() {
9950
- function ModelTreeItem(props, owner) {
9951
- this.baseTransform = owner.transform;
9952
- this.animationManager = new PAnimationManager(props, owner);
9953
- this.build(props);
9954
- }
9955
- var _proto = ModelTreeItem.prototype;
9956
- /**
9957
- * 场景树更新,主要是动画更新
9958
- * @param dt - 时间间隔
9959
- */ _proto.tick = function tick(dt) {
9960
- this.animationManager.tick(dt);
9961
- };
9962
- /**
9963
- * 获取所有节点
9964
- * @returns
9965
- */ _proto.getNodes = function getNodes() {
9966
- return this.nodes;
9967
- };
9968
- /**
9969
- * 根据节点编号,查询节点
9970
- * @param nodeId - 节点编号
9971
- * @returns
9972
- */ _proto.getNodeById = function getNodeById(nodeId) {
9973
- var cache = this.cacheMap;
9974
- if (!cache[nodeId]) {
9975
- var index = "^" + nodeId;
9976
- // @ts-expect-error
9977
- cache[nodeId] = this.allNodes.find(function(node) {
9978
- return node.id === index;
9979
- });
9980
- }
9981
- return cache[nodeId];
9982
- };
9983
- /**
9984
- * 根据节点名称,查询节点
9985
- * @param name - 名称
9986
- * @returns
9987
- */ _proto.getNodeByName = function getNodeByName(name) {
9988
- var cache = this.cacheMap;
9989
- if (!cache[name]) {
9990
- // @ts-expect-error
9991
- cache[name] = this.allNodes.find(function(node) {
9992
- return node.name === name;
9993
- });
9994
- }
9995
- return cache[name];
9996
- };
9997
- /**
9998
- * 根据节点 id 查询节点变换,如果查询不到节点就直接返回基础变换
9999
- * @param nodeId - 节点 id
10000
- * @returns
10001
- */ _proto.getNodeTransform = function getNodeTransform(nodeId) {
10002
- var node = this.getNodeById(nodeId);
10003
- return node ? node.transform : this.baseTransform;
10004
- };
10005
- /**
10006
- * 销毁场景树对象
10007
- */ _proto.dispose = function dispose() {
10008
- var _this_animationManager;
10009
- this.allNodes = [];
10010
- this.nodes = [];
10011
- this.cacheMap = {};
10012
- // @ts-expect-error
10013
- this.baseTransform = null;
10014
- (_this_animationManager = this.animationManager) == null ? void 0 : _this_animationManager.dispose();
10015
- // @ts-expect-error
10016
- this.animationManager = null;
10017
- };
10018
- _proto.build = function build(options) {
10019
- var _this = this;
10020
- var topTransform = this.baseTransform;
10021
- var nodes = options.nodes.map(function(node, i) {
10022
- return {
10023
- name: node.name || node.id || i + "",
10024
- transform: new EFFECTS.Transform(_extends({}, node.transform, {
10025
- valid: true
10026
- }), topTransform),
10027
- id: "^" + (node.id || i),
10028
- children: [],
10029
- tree: _this
10030
- };
10031
- });
10032
- this.cacheMap = {};
10033
- nodes.forEach(function(node, i) {
10034
- var children = options.nodes[i].children;
10035
- // @ts-expect-error
10036
- node.transform.name = node.name;
10037
- node.transform.setValid(true);
10038
- if (children) {
10039
- children.forEach(function(index) {
10040
- var child = nodes[index];
10041
- if (child && child !== node) {
10042
- if (child.transform.parentTransform !== topTransform) {
10043
- console.error("Node parent has been set.");
10044
- }
10045
- child.transform.parentTransform = node.transform;
10046
- node.children.push(child);
10047
- }
10048
- });
10049
- }
10050
- });
10051
- this.allNodes = nodes;
10052
- this.nodes = options.children.map(function(i) {
10053
- return nodes[i];
10054
- });
10055
- };
10056
- return ModelTreeItem;
10057
- }();
10058
9633
  exports.ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
10059
9634
  _inherits(ModelTreeComponent, Behaviour);
10060
9635
  function ModelTreeComponent(engine, options) {
@@ -10072,56 +9647,6 @@ exports.ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
10072
9647
  */ _proto.fromData = function fromData(options) {
10073
9648
  Behaviour.prototype.fromData.call(this, options);
10074
9649
  this.options = options;
10075
- this.createContent();
10076
- };
10077
- /**
10078
- * 组件开始,查询合成中场景管理器并设置到动画管理器中
10079
- */ _proto.onStart = function onStart() {
10080
- this.item.type = EFFECTS.spec.ItemType.tree;
10081
- this.content.baseTransform.setValid(true);
10082
- var sceneManager = getSceneManager(this);
10083
- if (sceneManager) {
10084
- this.content.animationManager.setSceneManager(sceneManager);
10085
- }
10086
- };
10087
- /**
10088
- * 组件更新,内部对象更新
10089
- * @param dt
10090
- */ _proto.onUpdate = function onUpdate(dt) {
10091
- var // this.timeline?.getRenderData(time, true);
10092
- // TODO: 需要使用lifetime
10093
- _this_content;
10094
- (_this_content = this.content) == null ? void 0 : _this_content.tick(dt);
10095
- };
10096
- /**
10097
- * 组件销毁,内部对象销毁
10098
- */ _proto.onDestroy = function onDestroy() {
10099
- var _this_content;
10100
- (_this_content = this.content) == null ? void 0 : _this_content.dispose();
10101
- };
10102
- /**
10103
- * 创建内部场景树元素
10104
- */ _proto.createContent = function createContent() {
10105
- if (this.options) {
10106
- var treeOptions = this.options.options.tree;
10107
- this.content = new ModelTreeItem(treeOptions, this.item);
10108
- }
10109
- };
10110
- /**
10111
- * 获取元素的变换
10112
- * @param itemId - 元素索引
10113
- * @returns
10114
- */ _proto.getNodeTransform = function getNodeTransform(itemId) {
10115
- if (this.content === undefined) {
10116
- return this.transform;
10117
- }
10118
- var idWithSubfix = this.item.id + "^";
10119
- if (itemId.indexOf(idWithSubfix) === 0) {
10120
- var nodeId = itemId.substring(idWithSubfix.length);
10121
- return this.content.getNodeTransform(nodeId);
10122
- } else {
10123
- return this.transform;
10124
- }
10125
9650
  };
10126
9651
  return ModelTreeComponent;
10127
9652
  }(EFFECTS.Behaviour);
@@ -10129,24 +9654,6 @@ exports.ModelTreeComponent = __decorate([
10129
9654
  EFFECTS.effectsClass(EFFECTS.spec.DataType.TreeComponent)
10130
9655
  ], exports.ModelTreeComponent);
10131
9656
 
10132
- /**
10133
- * 场景树插件类,支持 3D 相关的节点动画和骨骼动画等
10134
- */ var ModelTreePlugin = /*#__PURE__*/ function(AbstractPlugin) {
10135
- _inherits(ModelTreePlugin, AbstractPlugin);
10136
- function ModelTreePlugin() {
10137
- var _this;
10138
- _this = AbstractPlugin.apply(this, arguments) || this;
10139
- /**
10140
- * 插件名称
10141
- */ _this.name = "tree";
10142
- /**
10143
- * 高优先级更新
10144
- */ _this.order = 2;
10145
- return _this;
10146
- }
10147
- return ModelTreePlugin;
10148
- }(EFFECTS.AbstractPlugin);
10149
-
10150
9657
  exports.CameraGestureType = void 0;
10151
9658
  (function(CameraGestureType) {
10152
9659
  CameraGestureType[CameraGestureType["none"] = 0] = "none";
@@ -10684,7 +10191,7 @@ var JSONConverter = /*#__PURE__*/ function() {
10684
10191
  _proto.processScene = function processScene(sceneData) {
10685
10192
  var _this = this;
10686
10193
  return _async_to_generator(function() {
10687
- var sceneJSON, _tmp, oldScene, _oldScene_bins, oldBinUrls, binFiles, _iterator, _step, bin, _, newScene;
10194
+ var sceneJSON, _tmp, oldScene, _oldScene_bins, oldBinUrls, binFiles, v, _iterator, _step, bin, _, newScene;
10688
10195
  return __generator(this, function(_state) {
10689
10196
  switch(_state.label){
10690
10197
  case 0:
@@ -10721,6 +10228,14 @@ var JSONConverter = /*#__PURE__*/ function() {
10721
10228
  oldScene = EFFECTS.getStandardJSON(sceneJSON);
10722
10229
  oldBinUrls = (_oldScene_bins = oldScene.bins) != null ? _oldScene_bins : [];
10723
10230
  binFiles = [];
10231
+ //@ts-expect-error
10232
+ v = sceneJSON.version.split(".");
10233
+ if (Number(v[0]) >= 3) {
10234
+ return [
10235
+ 2,
10236
+ oldScene
10237
+ ];
10238
+ }
10724
10239
  if (!oldScene.bins) return [
10725
10240
  3,
10726
10241
  7
@@ -10920,7 +10435,6 @@ var JSONConverter = /*#__PURE__*/ function() {
10920
10435
  this.createItemsFromTreeComponent(comp, newScene, oldScene);
10921
10436
  treeComp.options.tree.animation = undefined;
10922
10437
  treeComp.options.tree.animations = undefined;
10923
- newComponents.push(comp);
10924
10438
  } else if (comp.dataType !== EFFECTS.spec.DataType.MeshComponent) {
10925
10439
  newComponents.push(comp);
10926
10440
  }
@@ -11358,6 +10872,7 @@ var JSONConverter = /*#__PURE__*/ function() {
11358
10872
  });
11359
10873
  });
11360
10874
  }
10875
+ treeItem.components = [];
11361
10876
  treeItem.components.push({
11362
10877
  id: animationComponent.id
11363
10878
  });
@@ -12695,6 +12210,59 @@ var LoaderImpl = /*#__PURE__*/ function() {
12695
12210
  this.items.push(item);
12696
12211
  this.components.push(component);
12697
12212
  };
12213
+ _proto.addSkybox = function addSkybox(skybox) {
12214
+ var _this_images, // @ts-expect-error
12215
+ _this_textures;
12216
+ var itemId = EFFECTS.generateGUID();
12217
+ var skyboxInfo = PSkyboxCreator.createSkyboxComponentData(skybox);
12218
+ var imageList = skyboxInfo.imageList, textureOptionsList = skyboxInfo.textureOptionsList, component = skyboxInfo.component;
12219
+ component.item.id = itemId;
12220
+ if (skybox.intensity !== undefined) {
12221
+ component.intensity = skybox.intensity;
12222
+ }
12223
+ if (skybox.reflectionsIntensity !== undefined) {
12224
+ component.reflectionsIntensity = skybox.reflectionsIntensity;
12225
+ }
12226
+ var _skybox_renderable;
12227
+ component.renderable = (_skybox_renderable = skybox.renderable) != null ? _skybox_renderable : false;
12228
+ var item = {
12229
+ id: itemId,
12230
+ name: "Skybox-Customize",
12231
+ duration: 999,
12232
+ type: EFFECTS.spec.ItemType.skybox,
12233
+ pn: 0,
12234
+ visible: true,
12235
+ endBehavior: EFFECTS.spec.EndBehavior.freeze,
12236
+ transform: {
12237
+ position: {
12238
+ x: 0,
12239
+ y: 0,
12240
+ z: 0
12241
+ },
12242
+ eulerHint: {
12243
+ x: 0,
12244
+ y: 0,
12245
+ z: 0
12246
+ },
12247
+ scale: {
12248
+ x: 1,
12249
+ y: 1,
12250
+ z: 1
12251
+ }
12252
+ },
12253
+ components: [
12254
+ {
12255
+ id: component.id
12256
+ }
12257
+ ],
12258
+ content: {},
12259
+ dataType: EFFECTS.spec.DataType.VFXItemData
12260
+ };
12261
+ (_this_images = this.images).push.apply(_this_images, [].concat(imageList));
12262
+ (_this_textures = this.textures).push.apply(_this_textures, [].concat(textureOptionsList));
12263
+ this.items.push(item);
12264
+ this.components.push(component);
12265
+ };
12698
12266
  _proto.tryAddSkybox = function tryAddSkybox(skybox) {
12699
12267
  var _this = this;
12700
12268
  return _async_to_generator(function() {
@@ -12829,43 +12397,6 @@ var LoaderImpl = /*#__PURE__*/ function() {
12829
12397
  });
12830
12398
  return sceneAABB;
12831
12399
  };
12832
- /**
12833
- * 按照传入的动画播放参数,计算需要播放的动画索引
12834
- *
12835
- * @param treeOptions 节点树属性,需要初始化animations列表。
12836
- * @returns 返回计算的动画索引,-1表示没有动画需要播放,-88888888表示播放所有动画。
12837
- */ _proto.getPlayAnimationIndex = function getPlayAnimationIndex(treeOptions) {
12838
- var animations = treeOptions.animations;
12839
- if (animations === undefined || animations.length <= 0) {
12840
- // 硬编码,内部指定的不播放动画的索引值
12841
- return -1;
12842
- }
12843
- if (this.isPlayAllAnimation()) {
12844
- // 硬编码,内部指定的播放全部动画的索引值
12845
- return -88888888;
12846
- }
12847
- var animationInfo = this.sceneOptions.effects.playAnimation;
12848
- if (animationInfo === undefined) {
12849
- return -1;
12850
- }
12851
- if (typeof animationInfo === "number") {
12852
- if (animationInfo >= 0 && animationInfo < animations.length) {
12853
- return animationInfo;
12854
- } else {
12855
- return -1;
12856
- }
12857
- } else {
12858
- // typeof animationInfo === 'string'
12859
- var animationIndex = -1;
12860
- // 通过动画名字查找动画索引
12861
- animations.forEach(function(anim, index) {
12862
- if (anim.name === animationInfo) {
12863
- animationIndex = index;
12864
- }
12865
- });
12866
- return animationIndex;
12867
- }
12868
- };
12869
12400
  _proto.isPlayAnimation = function isPlayAnimation() {
12870
12401
  return this.sceneOptions.effects.playAnimation !== undefined;
12871
12402
  };
@@ -13007,64 +12538,6 @@ var LoaderImpl = /*#__PURE__*/ function() {
13007
12538
  }
13008
12539
  });
13009
12540
  };
13010
- _proto.createTreeOptions = function createTreeOptions(scene) {
13011
- var nodeList = scene.nodes.map(function(node, nodeIndex) {
13012
- var children = node.children.map(function(child) {
13013
- if (child.nodeIndex === undefined) {
13014
- throw new Error("Undefined nodeIndex for child " + child);
13015
- }
13016
- return child.nodeIndex;
13017
- });
13018
- var pos;
13019
- var quat;
13020
- var scale;
13021
- if (node.matrix !== undefined) {
13022
- if (node.matrix.length !== 16) {
13023
- throw new Error("Invalid matrix length " + node.matrix.length + " for node " + node);
13024
- }
13025
- var mat = Matrix4.fromArray(node.matrix);
13026
- var transform = mat.getTransform();
13027
- pos = transform.translation.toArray();
13028
- quat = transform.rotation.toArray();
13029
- scale = transform.scale.toArray();
13030
- } else {
13031
- if (node.translation !== undefined) {
13032
- pos = node.translation;
13033
- }
13034
- if (node.rotation !== undefined) {
13035
- quat = node.rotation;
13036
- }
13037
- if (node.scale !== undefined) {
13038
- scale = node.scale;
13039
- }
13040
- }
13041
- node.nodeIndex = nodeIndex;
13042
- var treeNode = {
13043
- name: node.name,
13044
- transform: {
13045
- position: pos,
13046
- quat: quat,
13047
- scale: scale
13048
- },
13049
- children: children,
13050
- id: "" + node.nodeIndex
13051
- };
13052
- return treeNode;
13053
- });
13054
- var rootNodes = scene.rootNodes.map(function(root) {
13055
- if (root.nodeIndex === undefined) {
13056
- throw new Error("Undefined nodeIndex for root " + root);
13057
- }
13058
- return root.nodeIndex;
13059
- });
13060
- var treeOptions = {
13061
- nodes: nodeList,
13062
- children: rootNodes,
13063
- animation: -1,
13064
- animations: []
13065
- };
13066
- return treeOptions;
13067
- };
13068
12541
  _proto.createAnimations = function createAnimations(animations) {
13069
12542
  return animations.map(function(anim) {
13070
12543
  var tracks = anim.channels.map(function(channel) {
@@ -13814,9 +13287,8 @@ var GLTFHelper = /*#__PURE__*/ function() {
13814
13287
  return GLTFHelper;
13815
13288
  }();
13816
13289
 
13817
- EFFECTS.registerPlugin("tree", ModelTreePlugin, EFFECTS.VFXItem, true);
13818
13290
  EFFECTS.registerPlugin("model", ModelPlugin, EFFECTS.VFXItem);
13819
- var version = "2.1.0-alpha.7";
13291
+ var version = "2.1.0-alpha.9";
13820
13292
  EFFECTS.logger.info("Plugin model version: " + version + ".");
13821
13293
  if (version !== EFFECTS__namespace.version) {
13822
13294
  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!");
@@ -13845,12 +13317,7 @@ exports.Matrix3 = Matrix3;
13845
13317
  exports.Matrix4 = Matrix4;
13846
13318
  exports.MeshHelper = MeshHelper;
13847
13319
  exports.ModelPlugin = ModelPlugin;
13848
- exports.ModelTreeItem = ModelTreeItem;
13849
- exports.ModelTreePlugin = ModelTreePlugin;
13850
13320
  exports.PAnimTexture = PAnimTexture;
13851
- exports.PAnimTrack = PAnimTrack;
13852
- exports.PAnimation = PAnimation;
13853
- exports.PAnimationManager = PAnimationManager;
13854
13321
  exports.PBRShaderGUID = PBRShaderGUID;
13855
13322
  exports.PCamera = PCamera;
13856
13323
  exports.PCameraManager = PCameraManager;