@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/douyin.mjs CHANGED
@@ -1480,144 +1480,6 @@ var PAnimPathType;
1480
1480
  PAnimPathType[PAnimPathType["scale"] = 2] = "scale";
1481
1481
  PAnimPathType[PAnimPathType["weights"] = 3] = "weights";
1482
1482
  })(PAnimPathType || (PAnimPathType = {}));
1483
- /**
1484
- * 动画轨道类
1485
- */ var PAnimTrack = /*#__PURE__*/ function() {
1486
- function PAnimTrack(options) {
1487
- /**
1488
- * 路径类型
1489
- */ this.path = 0;
1490
- /**
1491
- * 插值类型
1492
- */ this.interp = 0;
1493
- var node = options.node, input = options.input, output = options.output, path = options.path, interpolation = options.interpolation;
1494
- this.node = node;
1495
- this.timeArray = input;
1496
- this.dataArray = output;
1497
- //
1498
- if (path === "translation") {
1499
- this.path = 0;
1500
- this.component = 3;
1501
- } else if (path === "rotation") {
1502
- this.path = 1;
1503
- this.component = 4;
1504
- } else if (path === "scale") {
1505
- this.path = 2;
1506
- this.component = 3;
1507
- } else if (path === "weights") {
1508
- this.path = 3;
1509
- this.component = this.dataArray.length / this.timeArray.length;
1510
- // special checker for weights animation
1511
- if (this.component <= 0) {
1512
- console.error("Invalid weights component: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
1513
- } else if (this.timeArray.length * this.component != this.dataArray.length) {
1514
- console.error("Invalid weights array length: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
1515
- }
1516
- } else {
1517
- // should never happened
1518
- console.error("Invalid path status: " + path + ".");
1519
- }
1520
- if (this.timeArray.length * this.component > this.dataArray.length) {
1521
- throw new Error("Data length mismatch: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
1522
- }
1523
- if (interpolation === "LINEAR") {
1524
- this.interp = 0;
1525
- } else if (interpolation === "STEP") {
1526
- this.interp = 1;
1527
- } else {
1528
- this.interp = 2;
1529
- }
1530
- this.sampler = createAnimationSampler(this.getInterpInfo(), this.timeArray, this.dataArray, this.component, this.getPathInfo());
1531
- }
1532
- var _proto = PAnimTrack.prototype;
1533
- /**
1534
- * 销毁
1535
- */ _proto.dispose = function dispose() {
1536
- var _this_sampler;
1537
- // @ts-expect-error
1538
- this.timeArray = undefined;
1539
- // @ts-expect-error
1540
- this.dataArray = undefined;
1541
- (_this_sampler = this.sampler) == null ? void 0 : _this_sampler.dispose();
1542
- this.sampler = undefined;
1543
- };
1544
- /**
1545
- * 更新节点动画数据
1546
- * @param time - 当前播放时间
1547
- * @param treeItem - 节点树元素
1548
- * @param sceneManager - 3D 场景管理器
1549
- */ _proto.tick = function tick(time, treeItem, sceneManager) {
1550
- var _treeComponent_content;
1551
- var treeComponent = treeItem.getComponent(ModelTreeComponent);
1552
- var node = treeComponent == null ? void 0 : (_treeComponent_content = treeComponent.content) == null ? void 0 : _treeComponent_content.getNodeById(this.node);
1553
- if (this.sampler !== undefined && node !== undefined) {
1554
- var result = this.sampler.evaluate(time);
1555
- switch(this.path){
1556
- case 0:
1557
- node.transform.setPosition(result[0], result[1], result[2]);
1558
- break;
1559
- case 1:
1560
- node.transform.setQuaternion(result[0], result[1], result[2], result[3]);
1561
- break;
1562
- case 2:
1563
- node.transform.setScale(result[0], result[1], result[2]);
1564
- break;
1565
- case 3:
1566
- {
1567
- /**
1568
- * 先生成Mesh的父节点id,然后通过id查询Mesh对象
1569
- * 最后更新Mesh对象权重数据
1570
- */ var parentId = this.genParentId(treeItem.id, this.node);
1571
- var mesh = sceneManager == null ? void 0 : sceneManager.queryMesh(parentId);
1572
- if (mesh !== undefined) {
1573
- mesh.updateMorphWeights(result);
1574
- }
1575
- }
1576
- break;
1577
- }
1578
- } else {
1579
- if (this.sampler !== undefined) {
1580
- console.error("AnimTrack: error", this.sampler, node);
1581
- }
1582
- }
1583
- };
1584
- /**
1585
- * 获取动画结束时间
1586
- * @returns
1587
- */ _proto.getEndTime = function getEndTime() {
1588
- var index = this.timeArray.length - 1;
1589
- return this.timeArray[index];
1590
- };
1591
- /**
1592
- * 生成 Mesh 元素的父节点
1593
- *
1594
- * @param parentId - 父节点 id 名称
1595
- * @param nodeIndex - Mesh 节点索引
1596
- *
1597
- * @returns 生成的 Mesh 节点名称
1598
- */ _proto.genParentId = function genParentId(parentId, nodeIndex) {
1599
- return parentId + "^" + nodeIndex;
1600
- };
1601
- _proto.getPathInfo = function getPathInfo() {
1602
- if (this.path === 2) {
1603
- return "scale";
1604
- } else if (this.path === 1) {
1605
- return "rotation";
1606
- } else {
1607
- return "translation";
1608
- }
1609
- };
1610
- _proto.getInterpInfo = function getInterpInfo() {
1611
- if (this.interp === 2) {
1612
- return "CUBICSPLINE";
1613
- } else if (this.interp === 1) {
1614
- return "STEP";
1615
- } else {
1616
- return "LINEAR";
1617
- }
1618
- };
1619
- return PAnimTrack;
1620
- }();
1621
1483
  /**
1622
1484
  * 动画纹理类
1623
1485
  */ var PAnimTexture = /*#__PURE__*/ function() {
@@ -1704,148 +1566,6 @@ var PAnimPathType;
1704
1566
  };
1705
1567
  return PAnimTexture;
1706
1568
  }();
1707
- /**
1708
- * 动画类,负责动画数据创建、更新和销毁
1709
- */ var PAnimation = /*#__PURE__*/ function(PObject) {
1710
- _inherits(PAnimation, PObject);
1711
- function PAnimation() {
1712
- var _this;
1713
- _this = PObject.apply(this, arguments) || this;
1714
- _this.time = 0;
1715
- _this.duration = 0;
1716
- _this.tracks = [];
1717
- return _this;
1718
- }
1719
- var _proto = PAnimation.prototype;
1720
- /**
1721
- * 创建动画对象
1722
- * @param options - 动画参数
1723
- */ _proto.create = function create(options) {
1724
- var _this = this;
1725
- var _options_name;
1726
- this.name = this.genName((_options_name = options.name) != null ? _options_name : "Unnamed animation");
1727
- this.type = PObjectType.animation;
1728
- //
1729
- this.time = 0;
1730
- this.duration = 0;
1731
- //
1732
- this.tracks = [];
1733
- options.tracks.forEach(function(inTrack) {
1734
- var track = new PAnimTrack(inTrack);
1735
- _this.tracks.push(track);
1736
- _this.duration = Math.max(_this.duration, track.getEndTime());
1737
- });
1738
- };
1739
- /**
1740
- * 动画更新
1741
- * @param time - 当前时间
1742
- * @param treeItem - 场景树元素
1743
- * @param sceneManager - 3D 场景管理器
1744
- */ _proto.tick = function tick(time, treeItem, sceneManager) {
1745
- this.time = time;
1746
- // TODO: 这里时间事件定义不明确,先兼容原先实现
1747
- var newTime = this.time % this.duration;
1748
- this.tracks.forEach(function(track) {
1749
- track.tick(newTime, treeItem, sceneManager);
1750
- });
1751
- };
1752
- /**
1753
- * 销毁
1754
- */ _proto.dispose = function dispose() {
1755
- this.tracks.forEach(function(track) {
1756
- track.dispose();
1757
- });
1758
- this.tracks = [];
1759
- };
1760
- return PAnimation;
1761
- }(PObject);
1762
- /**
1763
- * 动画管理类,负责管理动画对象
1764
- */ var PAnimationManager = /*#__PURE__*/ function(PObject) {
1765
- _inherits(PAnimationManager, PObject);
1766
- function PAnimationManager(treeOptions, ownerItem) {
1767
- var _this;
1768
- _this = PObject.call(this) || this;
1769
- _this.animation = 0;
1770
- _this.speed = 0;
1771
- _this.delay = 0;
1772
- _this.time = 0;
1773
- _this.animations = [];
1774
- var _ownerItem_name;
1775
- _this.name = _this.genName((_ownerItem_name = ownerItem.name) != null ? _ownerItem_name : "Unnamed tree");
1776
- _this.type = PObjectType.animationManager;
1777
- //
1778
- _this.ownerItem = ownerItem;
1779
- var _treeOptions_animation;
1780
- _this.animation = (_treeOptions_animation = treeOptions.animation) != null ? _treeOptions_animation : -1;
1781
- _this.speed = 1.0;
1782
- var _ownerItem_start;
1783
- _this.delay = (_ownerItem_start = ownerItem.start) != null ? _ownerItem_start : 0;
1784
- _this.animations = [];
1785
- if (treeOptions.animations !== undefined) {
1786
- treeOptions.animations.forEach(function(animOpts) {
1787
- var anim = _this.createAnimation(animOpts);
1788
- _this.animations.push(anim);
1789
- });
1790
- }
1791
- return _this;
1792
- }
1793
- var _proto = PAnimationManager.prototype;
1794
- /**
1795
- * 设置场景管理器
1796
- * @param sceneManager - 场景管理器
1797
- */ _proto.setSceneManager = function setSceneManager(sceneManager) {
1798
- this.sceneManager = sceneManager;
1799
- };
1800
- /**
1801
- * 创建动画对象
1802
- * @param animationOpts - 动画参数
1803
- * @returns 动画对象
1804
- */ _proto.createAnimation = function createAnimation(animationOpts) {
1805
- var animation = new PAnimation();
1806
- animation.create(animationOpts);
1807
- return animation;
1808
- };
1809
- /**
1810
- * 动画更新
1811
- * @param deltaSeconds - 更新间隔
1812
- */ _proto.tick = function tick(deltaSeconds) {
1813
- var _this = this;
1814
- var newDeltaSeconds = deltaSeconds * this.speed * 0.001;
1815
- this.time += newDeltaSeconds;
1816
- // TODO: 需要合并到TreeItem中,通过lifetime进行计算
1817
- var itemTime = this.time - this.delay;
1818
- if (itemTime >= 0) {
1819
- if (this.animation >= 0 && this.animation < this.animations.length) {
1820
- var anim = this.animations[this.animation];
1821
- anim.tick(itemTime, this.ownerItem, this.sceneManager);
1822
- } else if (this.animation == -88888888) {
1823
- this.animations.forEach(function(anim) {
1824
- anim.tick(itemTime, _this.ownerItem, _this.sceneManager);
1825
- });
1826
- }
1827
- }
1828
- };
1829
- /**
1830
- * 销毁
1831
- */ _proto.dispose = function dispose() {
1832
- // @ts-expect-error
1833
- this.ownerItem = null;
1834
- this.animations.forEach(function(anim) {
1835
- anim.dispose();
1836
- });
1837
- this.animations = [];
1838
- // @ts-expect-error
1839
- this.sceneManager = null;
1840
- };
1841
- /**
1842
- * 获取场景树元素
1843
- * @returns
1844
- */ _proto.getTreeItem = function getTreeItem() {
1845
- return this.ownerItem;
1846
- };
1847
- return PAnimationManager;
1848
- }(PObject);
1849
1569
 
1850
1570
  var deg2rad = Math.PI / 180;
1851
1571
  /**
@@ -3495,15 +3215,6 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
3495
3215
  _proto.isHide = function isHide() {
3496
3216
  return this.data.hide === true;
3497
3217
  };
3498
- _proto.getParentNode = function getParentNode() {
3499
- var _this_parentItem;
3500
- var nodeIndex = this.getParentIndex();
3501
- var parentTree = (_this_parentItem = this.parentItem) == null ? void 0 : _this_parentItem.getComponent(ModelTreeComponent);
3502
- if (parentTree !== undefined && nodeIndex >= 0) {
3503
- return parentTree.content.getNodeById(nodeIndex);
3504
- }
3505
- return undefined;
3506
- };
3507
3218
  _proto.getParentIndex = function getParentIndex() {
3508
3219
  return -1;
3509
3220
  };
@@ -3941,7 +3652,7 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
3941
3652
 
3942
3653
  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}";
3943
3654
 
3944
- 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}";
3655
+ 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}";
3945
3656
 
3946
3657
  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}";
3947
3658
 
@@ -6174,31 +5885,6 @@ var normal = new Vector3();
6174
5885
  console.error("setupItem3DOptions: Invalid inverseBindMatrices type, " + inverseBindMatrices + ".");
6175
5886
  }
6176
5887
  }
6177
- } else if (item.type === spec.ItemType.tree) {
6178
- var jsonItem = item;
6179
- var studioItem = item;
6180
- var jsonAnimations = jsonItem.content.options.tree.animations;
6181
- var studioAnimations = studioItem.content.options.tree.animations;
6182
- if (jsonAnimations !== undefined && studioAnimations !== undefined) {
6183
- jsonAnimations.forEach(function(jsonAnim, i) {
6184
- var studioAnim = studioAnimations[i];
6185
- jsonAnim.tracks.forEach(function(jsonTrack, j) {
6186
- var inputArray = typedArrayFromBinary(scene.bins, jsonTrack.input);
6187
- var outputArray = typedArrayFromBinary(scene.bins, jsonTrack.output);
6188
- var studioTrack = studioAnim.tracks[j];
6189
- if (_instanceof1(inputArray, Float32Array)) {
6190
- studioTrack.input = inputArray;
6191
- } else {
6192
- console.error("setupItem3DOptions: Type of inputArray should be float32, " + inputArray + ".");
6193
- }
6194
- if (_instanceof1(outputArray, Float32Array)) {
6195
- studioTrack.output = outputArray;
6196
- } else {
6197
- console.error("setupItem3DOptions: Type of outputArray should be float32, " + outputArray + ".");
6198
- }
6199
- });
6200
- });
6201
- }
6202
5888
  } else if (item.type === spec.ItemType.skybox) {
6203
5889
  var skybox = item;
6204
5890
  var studioSkybox = item;
@@ -9921,117 +9607,6 @@ ModelPluginComponent = __decorate([
9921
9607
  return pluginComp == null ? void 0 : pluginComp.scene;
9922
9608
  }
9923
9609
 
9924
- /**
9925
- * 场景树元素类,支持插件中节点树相关的动画能力
9926
- */ var ModelTreeItem = /*#__PURE__*/ function() {
9927
- function ModelTreeItem(props, owner) {
9928
- this.baseTransform = owner.transform;
9929
- this.animationManager = new PAnimationManager(props, owner);
9930
- this.build(props);
9931
- }
9932
- var _proto = ModelTreeItem.prototype;
9933
- /**
9934
- * 场景树更新,主要是动画更新
9935
- * @param dt - 时间间隔
9936
- */ _proto.tick = function tick(dt) {
9937
- this.animationManager.tick(dt);
9938
- };
9939
- /**
9940
- * 获取所有节点
9941
- * @returns
9942
- */ _proto.getNodes = function getNodes() {
9943
- return this.nodes;
9944
- };
9945
- /**
9946
- * 根据节点编号,查询节点
9947
- * @param nodeId - 节点编号
9948
- * @returns
9949
- */ _proto.getNodeById = function getNodeById(nodeId) {
9950
- var cache = this.cacheMap;
9951
- if (!cache[nodeId]) {
9952
- var index = "^" + nodeId;
9953
- // @ts-expect-error
9954
- cache[nodeId] = this.allNodes.find(function(node) {
9955
- return node.id === index;
9956
- });
9957
- }
9958
- return cache[nodeId];
9959
- };
9960
- /**
9961
- * 根据节点名称,查询节点
9962
- * @param name - 名称
9963
- * @returns
9964
- */ _proto.getNodeByName = function getNodeByName(name) {
9965
- var cache = this.cacheMap;
9966
- if (!cache[name]) {
9967
- // @ts-expect-error
9968
- cache[name] = this.allNodes.find(function(node) {
9969
- return node.name === name;
9970
- });
9971
- }
9972
- return cache[name];
9973
- };
9974
- /**
9975
- * 根据节点 id 查询节点变换,如果查询不到节点就直接返回基础变换
9976
- * @param nodeId - 节点 id
9977
- * @returns
9978
- */ _proto.getNodeTransform = function getNodeTransform(nodeId) {
9979
- var node = this.getNodeById(nodeId);
9980
- return node ? node.transform : this.baseTransform;
9981
- };
9982
- /**
9983
- * 销毁场景树对象
9984
- */ _proto.dispose = function dispose() {
9985
- var _this_animationManager;
9986
- this.allNodes = [];
9987
- this.nodes = [];
9988
- this.cacheMap = {};
9989
- // @ts-expect-error
9990
- this.baseTransform = null;
9991
- (_this_animationManager = this.animationManager) == null ? void 0 : _this_animationManager.dispose();
9992
- // @ts-expect-error
9993
- this.animationManager = null;
9994
- };
9995
- _proto.build = function build(options) {
9996
- var _this = this;
9997
- var topTransform = this.baseTransform;
9998
- var nodes = options.nodes.map(function(node, i) {
9999
- return {
10000
- name: node.name || node.id || i + "",
10001
- transform: new Transform(_extends({}, node.transform, {
10002
- valid: true
10003
- }), topTransform),
10004
- id: "^" + (node.id || i),
10005
- children: [],
10006
- tree: _this
10007
- };
10008
- });
10009
- this.cacheMap = {};
10010
- nodes.forEach(function(node, i) {
10011
- var children = options.nodes[i].children;
10012
- // @ts-expect-error
10013
- node.transform.name = node.name;
10014
- node.transform.setValid(true);
10015
- if (children) {
10016
- children.forEach(function(index) {
10017
- var child = nodes[index];
10018
- if (child && child !== node) {
10019
- if (child.transform.parentTransform !== topTransform) {
10020
- console.error("Node parent has been set.");
10021
- }
10022
- child.transform.parentTransform = node.transform;
10023
- node.children.push(child);
10024
- }
10025
- });
10026
- }
10027
- });
10028
- this.allNodes = nodes;
10029
- this.nodes = options.children.map(function(i) {
10030
- return nodes[i];
10031
- });
10032
- };
10033
- return ModelTreeItem;
10034
- }();
10035
9610
  var ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
10036
9611
  _inherits(ModelTreeComponent, Behaviour);
10037
9612
  function ModelTreeComponent(engine, options) {
@@ -10049,56 +9624,6 @@ var ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
10049
9624
  */ _proto.fromData = function fromData(options) {
10050
9625
  Behaviour.prototype.fromData.call(this, options);
10051
9626
  this.options = options;
10052
- this.createContent();
10053
- };
10054
- /**
10055
- * 组件开始,查询合成中场景管理器并设置到动画管理器中
10056
- */ _proto.onStart = function onStart() {
10057
- this.item.type = spec.ItemType.tree;
10058
- this.content.baseTransform.setValid(true);
10059
- var sceneManager = getSceneManager(this);
10060
- if (sceneManager) {
10061
- this.content.animationManager.setSceneManager(sceneManager);
10062
- }
10063
- };
10064
- /**
10065
- * 组件更新,内部对象更新
10066
- * @param dt
10067
- */ _proto.onUpdate = function onUpdate(dt) {
10068
- var // this.timeline?.getRenderData(time, true);
10069
- // TODO: 需要使用lifetime
10070
- _this_content;
10071
- (_this_content = this.content) == null ? void 0 : _this_content.tick(dt);
10072
- };
10073
- /**
10074
- * 组件销毁,内部对象销毁
10075
- */ _proto.onDestroy = function onDestroy() {
10076
- var _this_content;
10077
- (_this_content = this.content) == null ? void 0 : _this_content.dispose();
10078
- };
10079
- /**
10080
- * 创建内部场景树元素
10081
- */ _proto.createContent = function createContent() {
10082
- if (this.options) {
10083
- var treeOptions = this.options.options.tree;
10084
- this.content = new ModelTreeItem(treeOptions, this.item);
10085
- }
10086
- };
10087
- /**
10088
- * 获取元素的变换
10089
- * @param itemId - 元素索引
10090
- * @returns
10091
- */ _proto.getNodeTransform = function getNodeTransform(itemId) {
10092
- if (this.content === undefined) {
10093
- return this.transform;
10094
- }
10095
- var idWithSubfix = this.item.id + "^";
10096
- if (itemId.indexOf(idWithSubfix) === 0) {
10097
- var nodeId = itemId.substring(idWithSubfix.length);
10098
- return this.content.getNodeTransform(nodeId);
10099
- } else {
10100
- return this.transform;
10101
- }
10102
9627
  };
10103
9628
  return ModelTreeComponent;
10104
9629
  }(Behaviour);
@@ -10106,24 +9631,6 @@ ModelTreeComponent = __decorate([
10106
9631
  effectsClass(spec.DataType.TreeComponent)
10107
9632
  ], ModelTreeComponent);
10108
9633
 
10109
- /**
10110
- * 场景树插件类,支持 3D 相关的节点动画和骨骼动画等
10111
- */ var ModelTreePlugin = /*#__PURE__*/ function(AbstractPlugin) {
10112
- _inherits(ModelTreePlugin, AbstractPlugin);
10113
- function ModelTreePlugin() {
10114
- var _this;
10115
- _this = AbstractPlugin.apply(this, arguments) || this;
10116
- /**
10117
- * 插件名称
10118
- */ _this.name = "tree";
10119
- /**
10120
- * 高优先级更新
10121
- */ _this.order = 2;
10122
- return _this;
10123
- }
10124
- return ModelTreePlugin;
10125
- }(AbstractPlugin);
10126
-
10127
9634
  var CameraGestureType;
10128
9635
  (function(CameraGestureType) {
10129
9636
  CameraGestureType[CameraGestureType["none"] = 0] = "none";
@@ -10661,7 +10168,7 @@ var JSONConverter = /*#__PURE__*/ function() {
10661
10168
  _proto.processScene = function processScene(sceneData) {
10662
10169
  var _this = this;
10663
10170
  return _async_to_generator(function() {
10664
- var sceneJSON, _tmp, oldScene, _oldScene_bins, oldBinUrls, binFiles, _iterator, _step, bin, _, newScene;
10171
+ var sceneJSON, _tmp, oldScene, _oldScene_bins, oldBinUrls, binFiles, v, _iterator, _step, bin, _, newScene;
10665
10172
  return __generator(this, function(_state) {
10666
10173
  switch(_state.label){
10667
10174
  case 0:
@@ -10698,6 +10205,14 @@ var JSONConverter = /*#__PURE__*/ function() {
10698
10205
  oldScene = getStandardJSON(sceneJSON);
10699
10206
  oldBinUrls = (_oldScene_bins = oldScene.bins) != null ? _oldScene_bins : [];
10700
10207
  binFiles = [];
10208
+ //@ts-expect-error
10209
+ v = sceneJSON.version.split(".");
10210
+ if (Number(v[0]) >= 3) {
10211
+ return [
10212
+ 2,
10213
+ oldScene
10214
+ ];
10215
+ }
10701
10216
  if (!oldScene.bins) return [
10702
10217
  3,
10703
10218
  7
@@ -10897,7 +10412,6 @@ var JSONConverter = /*#__PURE__*/ function() {
10897
10412
  this.createItemsFromTreeComponent(comp, newScene, oldScene);
10898
10413
  treeComp.options.tree.animation = undefined;
10899
10414
  treeComp.options.tree.animations = undefined;
10900
- newComponents.push(comp);
10901
10415
  } else if (comp.dataType !== spec.DataType.MeshComponent) {
10902
10416
  newComponents.push(comp);
10903
10417
  }
@@ -11335,6 +10849,7 @@ var JSONConverter = /*#__PURE__*/ function() {
11335
10849
  });
11336
10850
  });
11337
10851
  }
10852
+ treeItem.components = [];
11338
10853
  treeItem.components.push({
11339
10854
  id: animationComponent.id
11340
10855
  });
@@ -12672,6 +12187,59 @@ var LoaderImpl = /*#__PURE__*/ function() {
12672
12187
  this.items.push(item);
12673
12188
  this.components.push(component);
12674
12189
  };
12190
+ _proto.addSkybox = function addSkybox(skybox) {
12191
+ var _this_images, // @ts-expect-error
12192
+ _this_textures;
12193
+ var itemId = generateGUID();
12194
+ var skyboxInfo = PSkyboxCreator.createSkyboxComponentData(skybox);
12195
+ var imageList = skyboxInfo.imageList, textureOptionsList = skyboxInfo.textureOptionsList, component = skyboxInfo.component;
12196
+ component.item.id = itemId;
12197
+ if (skybox.intensity !== undefined) {
12198
+ component.intensity = skybox.intensity;
12199
+ }
12200
+ if (skybox.reflectionsIntensity !== undefined) {
12201
+ component.reflectionsIntensity = skybox.reflectionsIntensity;
12202
+ }
12203
+ var _skybox_renderable;
12204
+ component.renderable = (_skybox_renderable = skybox.renderable) != null ? _skybox_renderable : false;
12205
+ var item = {
12206
+ id: itemId,
12207
+ name: "Skybox-Customize",
12208
+ duration: 999,
12209
+ type: spec.ItemType.skybox,
12210
+ pn: 0,
12211
+ visible: true,
12212
+ endBehavior: spec.EndBehavior.freeze,
12213
+ transform: {
12214
+ position: {
12215
+ x: 0,
12216
+ y: 0,
12217
+ z: 0
12218
+ },
12219
+ eulerHint: {
12220
+ x: 0,
12221
+ y: 0,
12222
+ z: 0
12223
+ },
12224
+ scale: {
12225
+ x: 1,
12226
+ y: 1,
12227
+ z: 1
12228
+ }
12229
+ },
12230
+ components: [
12231
+ {
12232
+ id: component.id
12233
+ }
12234
+ ],
12235
+ content: {},
12236
+ dataType: spec.DataType.VFXItemData
12237
+ };
12238
+ (_this_images = this.images).push.apply(_this_images, [].concat(imageList));
12239
+ (_this_textures = this.textures).push.apply(_this_textures, [].concat(textureOptionsList));
12240
+ this.items.push(item);
12241
+ this.components.push(component);
12242
+ };
12675
12243
  _proto.tryAddSkybox = function tryAddSkybox(skybox) {
12676
12244
  var _this = this;
12677
12245
  return _async_to_generator(function() {
@@ -12806,43 +12374,6 @@ var LoaderImpl = /*#__PURE__*/ function() {
12806
12374
  });
12807
12375
  return sceneAABB;
12808
12376
  };
12809
- /**
12810
- * 按照传入的动画播放参数,计算需要播放的动画索引
12811
- *
12812
- * @param treeOptions 节点树属性,需要初始化animations列表。
12813
- * @returns 返回计算的动画索引,-1表示没有动画需要播放,-88888888表示播放所有动画。
12814
- */ _proto.getPlayAnimationIndex = function getPlayAnimationIndex(treeOptions) {
12815
- var animations = treeOptions.animations;
12816
- if (animations === undefined || animations.length <= 0) {
12817
- // 硬编码,内部指定的不播放动画的索引值
12818
- return -1;
12819
- }
12820
- if (this.isPlayAllAnimation()) {
12821
- // 硬编码,内部指定的播放全部动画的索引值
12822
- return -88888888;
12823
- }
12824
- var animationInfo = this.sceneOptions.effects.playAnimation;
12825
- if (animationInfo === undefined) {
12826
- return -1;
12827
- }
12828
- if (typeof animationInfo === "number") {
12829
- if (animationInfo >= 0 && animationInfo < animations.length) {
12830
- return animationInfo;
12831
- } else {
12832
- return -1;
12833
- }
12834
- } else {
12835
- // typeof animationInfo === 'string'
12836
- var animationIndex = -1;
12837
- // 通过动画名字查找动画索引
12838
- animations.forEach(function(anim, index) {
12839
- if (anim.name === animationInfo) {
12840
- animationIndex = index;
12841
- }
12842
- });
12843
- return animationIndex;
12844
- }
12845
- };
12846
12377
  _proto.isPlayAnimation = function isPlayAnimation() {
12847
12378
  return this.sceneOptions.effects.playAnimation !== undefined;
12848
12379
  };
@@ -12984,64 +12515,6 @@ var LoaderImpl = /*#__PURE__*/ function() {
12984
12515
  }
12985
12516
  });
12986
12517
  };
12987
- _proto.createTreeOptions = function createTreeOptions(scene) {
12988
- var nodeList = scene.nodes.map(function(node, nodeIndex) {
12989
- var children = node.children.map(function(child) {
12990
- if (child.nodeIndex === undefined) {
12991
- throw new Error("Undefined nodeIndex for child " + child);
12992
- }
12993
- return child.nodeIndex;
12994
- });
12995
- var pos;
12996
- var quat;
12997
- var scale;
12998
- if (node.matrix !== undefined) {
12999
- if (node.matrix.length !== 16) {
13000
- throw new Error("Invalid matrix length " + node.matrix.length + " for node " + node);
13001
- }
13002
- var mat = Matrix4.fromArray(node.matrix);
13003
- var transform = mat.getTransform();
13004
- pos = transform.translation.toArray();
13005
- quat = transform.rotation.toArray();
13006
- scale = transform.scale.toArray();
13007
- } else {
13008
- if (node.translation !== undefined) {
13009
- pos = node.translation;
13010
- }
13011
- if (node.rotation !== undefined) {
13012
- quat = node.rotation;
13013
- }
13014
- if (node.scale !== undefined) {
13015
- scale = node.scale;
13016
- }
13017
- }
13018
- node.nodeIndex = nodeIndex;
13019
- var treeNode = {
13020
- name: node.name,
13021
- transform: {
13022
- position: pos,
13023
- quat: quat,
13024
- scale: scale
13025
- },
13026
- children: children,
13027
- id: "" + node.nodeIndex
13028
- };
13029
- return treeNode;
13030
- });
13031
- var rootNodes = scene.rootNodes.map(function(root) {
13032
- if (root.nodeIndex === undefined) {
13033
- throw new Error("Undefined nodeIndex for root " + root);
13034
- }
13035
- return root.nodeIndex;
13036
- });
13037
- var treeOptions = {
13038
- nodes: nodeList,
13039
- children: rootNodes,
13040
- animation: -1,
13041
- animations: []
13042
- };
13043
- return treeOptions;
13044
- };
13045
12518
  _proto.createAnimations = function createAnimations(animations) {
13046
12519
  return animations.map(function(anim) {
13047
12520
  var tracks = anim.channels.map(function(channel) {
@@ -13791,13 +13264,12 @@ var GLTFHelper = /*#__PURE__*/ function() {
13791
13264
  return GLTFHelper;
13792
13265
  }();
13793
13266
 
13794
- registerPlugin("tree", ModelTreePlugin, VFXItem, true);
13795
13267
  registerPlugin("model", ModelPlugin, VFXItem);
13796
- var version = "2.1.0-alpha.7";
13268
+ var version = "2.1.0-alpha.9";
13797
13269
  logger.info("Plugin model version: " + version + ".");
13798
13270
  if (version !== EFFECTS.version) {
13799
13271
  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!");
13800
13272
  }
13801
13273
 
13802
- export { AnimationComponent, Box3, BoxMesh, CameraGestureHandlerImp, CameraGestureType, CheckerHelper, Color, CompositionCache, CompositionHitTest, DEG2RAD, Euler, EulerOrder, FBOOptions, Float16ArrayWrapper, GeometryBoxProxy, HitTestingProxy, HookOGLFunc, InterpolationSampler, JSONConverter, LoaderHelper, LoaderImpl, Matrix3, Matrix4, MeshHelper, ModelCameraComponent, ModelLightComponent, ModelMeshComponent, ModelPlugin, ModelPluginComponent, ModelSkyboxComponent, ModelTreeComponent, ModelTreeItem, ModelTreePlugin, PAnimInterpType, PAnimPathType, PAnimTexture, PAnimTrack, PAnimation, PAnimationManager, PBRShaderGUID, PBlendMode, PCamera, PCameraManager, PCoordinate, PEntity, PFaceSideMode, PGeometry, PGlobalState, PLight, PLightManager, PLightType, PMaterialBase, PMaterialPBR, PMaterialSkyboxFilter, PMaterialType, PMaterialUnlit, PMesh, PMorph, PObject, PObjectType, PSceneManager, PShaderManager, PShadowType, PSkin, PSkybox, PSkyboxCreator, PSkyboxType, PSubMesh, PTextureType, PTransform, PluginHelper, Quaternion, Ray, RayBoxTesting, RayIntersectsBoxWithRotation, RayTriangleTesting, Sphere, TextureDataMode, ToggleItemBounding, TwoStatesSet, UnlitShaderGUID, VFX_ITEM_TYPE_3D, Vector2, Vector3, Vector4, VertexAttribBuffer, WebGLHelper, WebHelper, createAnimationSampler, createPluginMaterial, fetchPBRShaderCode, fetchUnlitShaderCode, getDefaultEffectsGLTFLoader, getDefaultPBRMaterialData, getDefaultUnlitMaterialData, getDiffuseOnlyShaderCode, getGaussianBlurShaderCodeV1, getGaussianBlurShaderCodeV2, getGeometryDataFromOptions, getGeometryDataFromPropsList, getKawaseBlurShaderCode, getNormalVisShaderCode, getPBRPassShaderCode, getPBRShaderProperties, getPMeshList, getQuadFilterShaderCode, getRendererGPUInfo, getSceneManager, getShadowPassShaderCode, getSimpleFilterShaderCode, getSkyBoxShaderCode, getTransparecyBaseShader, getTransparecyFilterShader, getUnlitShaderProperties, setDefaultEffectsGLTFLoader, version };
13274
+ export { AnimationComponent, Box3, BoxMesh, CameraGestureHandlerImp, CameraGestureType, CheckerHelper, Color, CompositionCache, CompositionHitTest, DEG2RAD, Euler, EulerOrder, FBOOptions, Float16ArrayWrapper, GeometryBoxProxy, HitTestingProxy, HookOGLFunc, InterpolationSampler, JSONConverter, LoaderHelper, LoaderImpl, Matrix3, Matrix4, MeshHelper, ModelCameraComponent, ModelLightComponent, ModelMeshComponent, ModelPlugin, ModelPluginComponent, ModelSkyboxComponent, ModelTreeComponent, PAnimInterpType, PAnimPathType, PAnimTexture, PBRShaderGUID, PBlendMode, PCamera, PCameraManager, PCoordinate, PEntity, PFaceSideMode, PGeometry, PGlobalState, PLight, PLightManager, PLightType, PMaterialBase, PMaterialPBR, PMaterialSkyboxFilter, PMaterialType, PMaterialUnlit, PMesh, PMorph, PObject, PObjectType, PSceneManager, PShaderManager, PShadowType, PSkin, PSkybox, PSkyboxCreator, PSkyboxType, PSubMesh, PTextureType, PTransform, PluginHelper, Quaternion, Ray, RayBoxTesting, RayIntersectsBoxWithRotation, RayTriangleTesting, Sphere, TextureDataMode, ToggleItemBounding, TwoStatesSet, UnlitShaderGUID, VFX_ITEM_TYPE_3D, Vector2, Vector3, Vector4, VertexAttribBuffer, WebGLHelper, WebHelper, createAnimationSampler, createPluginMaterial, fetchPBRShaderCode, fetchUnlitShaderCode, getDefaultEffectsGLTFLoader, getDefaultPBRMaterialData, getDefaultUnlitMaterialData, getDiffuseOnlyShaderCode, getGaussianBlurShaderCodeV1, getGaussianBlurShaderCodeV2, getGeometryDataFromOptions, getGeometryDataFromPropsList, getKawaseBlurShaderCode, getNormalVisShaderCode, getPBRPassShaderCode, getPBRShaderProperties, getPMeshList, getQuadFilterShaderCode, getRendererGPUInfo, getSceneManager, getShadowPassShaderCode, getSimpleFilterShaderCode, getSkyBoxShaderCode, getTransparecyBaseShader, getTransparecyFilterShader, getUnlitShaderProperties, setDefaultEffectsGLTFLoader, version };
13803
13275
  //# sourceMappingURL=douyin.mjs.map