@galacean/effects-plugin-model 2.0.0-alpha.7 → 2.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +407 -99
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +405 -101
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +4601 -4297
- package/dist/loader.mjs.map +1 -1
- package/dist/runtime/common.d.ts +2 -0
- package/dist/runtime/material.d.ts +6 -12
- package/dist/runtime/mesh.d.ts +5 -0
- package/dist/runtime/shader-libs/standard-shader-source.d.ts +1 -0
- package/dist/runtime/shader-libs/standard-shader.d.ts +8 -0
- package/dist/utility/shader-helper.d.ts +2 -0
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Description: Galacean Effects player model plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 飂兮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.8
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { math, Transform, PLAYER_OPTIONS_ENV_EDITOR, spec, glContext, Texture, TextureSourceType, RenderPassAttachmentStorageType, Material, Mesh, Geometry,
|
|
9
|
+
import { math, Transform, PLAYER_OPTIONS_ENV_EDITOR, spec, glContext, Texture, TextureSourceType, RenderPassAttachmentStorageType, Material, Mesh, Geometry, GLSLVersion, DestroyOptions, addItem, removeItem, effectsClass, RendererComponent, ItemBehaviour, TimelineComponent, HitTestType, RenderPass, TextureLoadAction, RenderPassDestroyAttachmentType, Player, Renderer, getDefaultTextureFactory, loadImage, VFXItem, AbstractPlugin, registerPlugin, logger } from '@galacean/effects';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Model 插件元素类型
|
|
@@ -264,6 +264,8 @@ var PShadowType;
|
|
|
264
264
|
PShadowType[PShadowType["variance"] = 2] = "variance";
|
|
265
265
|
PShadowType[PShadowType["expVariance"] = 3] = "expVariance";
|
|
266
266
|
})(PShadowType || (PShadowType = {}));
|
|
267
|
+
var PBRShaderGUID = "pbr00000000000000000000000000000";
|
|
268
|
+
var UnlitShaderGUID = "unlit000000000000000000000000000";
|
|
267
269
|
/**
|
|
268
270
|
* 插件变换类
|
|
269
271
|
*/ var PTransform = /*#__PURE__*/ function() {
|
|
@@ -2081,11 +2083,11 @@ var deg2rad = Math.PI / 180;
|
|
|
2081
2083
|
var color = data.color;
|
|
2082
2084
|
_this.color = new Vector3(color.r, color.g, color.b);
|
|
2083
2085
|
_this.intensity = data.intensity;
|
|
2084
|
-
if (data.lightType ===
|
|
2086
|
+
if (data.lightType === spec.LightType.point) {
|
|
2085
2087
|
_this.lightType = PLightType.point;
|
|
2086
2088
|
var _data_range;
|
|
2087
2089
|
_this.range = (_data_range = data.range) != null ? _data_range : -1;
|
|
2088
|
-
} else if (data.lightType ===
|
|
2090
|
+
} else if (data.lightType === spec.LightType.spot) {
|
|
2089
2091
|
_this.lightType = PLightType.spot;
|
|
2090
2092
|
var _data_range1;
|
|
2091
2093
|
_this.range = (_data_range1 = data.range) != null ? _data_range1 : -1;
|
|
@@ -2093,7 +2095,7 @@ var deg2rad = Math.PI / 180;
|
|
|
2093
2095
|
_this.outerConeAngle = (_data_outerConeAngle = data.outerConeAngle) != null ? _data_outerConeAngle : Math.PI;
|
|
2094
2096
|
var _data_innerConeAngle;
|
|
2095
2097
|
_this.innerConeAngle = (_data_innerConeAngle = data.innerConeAngle) != null ? _data_innerConeAngle : 0;
|
|
2096
|
-
} else if (data.lightType ===
|
|
2098
|
+
} else if (data.lightType === spec.LightType.directional) {
|
|
2097
2099
|
_this.lightType = PLightType.directional;
|
|
2098
2100
|
} else {
|
|
2099
2101
|
_this.lightType = PLightType.ambient;
|
|
@@ -2797,8 +2799,8 @@ function _assert_this_initialized(self) {
|
|
|
2797
2799
|
* @param skybox - 天空盒
|
|
2798
2800
|
*/ _proto.build = function build(lightCount, uniformSemantics, skybox) {
|
|
2799
2801
|
var globalState = PGlobalState.getInstance();
|
|
2800
|
-
var
|
|
2801
|
-
this.material.
|
|
2802
|
+
var primitiveMacroList = this.getMacroList(lightCount, true, skybox);
|
|
2803
|
+
var materialMacroList = this.material.getMacroList(primitiveMacroList);
|
|
2802
2804
|
var newSemantics = uniformSemantics != null ? uniformSemantics : {};
|
|
2803
2805
|
newSemantics["_ViewProjectionMatrix"] = "VIEWPROJECTION";
|
|
2804
2806
|
//newSemantics["uView"] = 'VIEWINVERSE';
|
|
@@ -2810,19 +2812,10 @@ function _assert_this_initialized(self) {
|
|
|
2810
2812
|
material = this.material.material;
|
|
2811
2813
|
// @ts-expect-error
|
|
2812
2814
|
material.uniformSemantics = newSemantics;
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
//id: 'pbr00000000000000000000000000000',
|
|
2817
|
-
id: generateGUID(),
|
|
2818
|
-
dataType: "Shader",
|
|
2819
|
-
vertex: this.material.vertexShaderCode,
|
|
2820
|
-
fragment: this.material.fragmentShaderCode,
|
|
2821
|
-
// @ts-expect-error
|
|
2822
|
-
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
2815
|
+
materialMacroList.forEach(function(macro) {
|
|
2816
|
+
var name = macro.name, value = macro.value;
|
|
2817
|
+
material.enableMacro(name, value);
|
|
2823
2818
|
});
|
|
2824
|
-
// @ts-expect-error
|
|
2825
|
-
material.shader = shader;
|
|
2826
2819
|
this.material.setMaterialStates(material);
|
|
2827
2820
|
} else {
|
|
2828
2821
|
material = Material.create(this.engine, {
|
|
@@ -2888,11 +2881,14 @@ function _assert_this_initialized(self) {
|
|
|
2888
2881
|
}
|
|
2889
2882
|
}
|
|
2890
2883
|
if (this.material.materialType !== PMaterialType.unlit) {
|
|
2884
|
+
// let hasLight = false;
|
|
2891
2885
|
if (lightCount > 0 && this.geometry.hasNormals()) {
|
|
2886
|
+
// hasLight = true;
|
|
2892
2887
|
featureList.push("USE_PUNCTUAL 1");
|
|
2893
2888
|
featureList.push("LIGHT_COUNT " + lightCount);
|
|
2894
2889
|
}
|
|
2895
2890
|
if (skybox !== undefined && skybox.available) {
|
|
2891
|
+
// hasLight = true;
|
|
2896
2892
|
featureList.push("USE_IBL 1");
|
|
2897
2893
|
featureList.push("USE_TEX_LOD 1");
|
|
2898
2894
|
if (skybox.hasDiffuseImage) ; else {
|
|
@@ -2912,6 +2908,116 @@ function _assert_this_initialized(self) {
|
|
|
2912
2908
|
}
|
|
2913
2909
|
return featureList;
|
|
2914
2910
|
};
|
|
2911
|
+
_proto.getMacroList = function getMacroList(lightCount, pbrPass, skybox) {
|
|
2912
|
+
var macroList = [];
|
|
2913
|
+
if (this.geometry.hasNormals()) {
|
|
2914
|
+
macroList.push({
|
|
2915
|
+
name: "HAS_NORMALS"
|
|
2916
|
+
});
|
|
2917
|
+
}
|
|
2918
|
+
if (this.geometry.hasTangents()) {
|
|
2919
|
+
macroList.push({
|
|
2920
|
+
name: "HAS_TANGENTS"
|
|
2921
|
+
});
|
|
2922
|
+
}
|
|
2923
|
+
if (this.geometry.hasUVCoords(1)) {
|
|
2924
|
+
macroList.push({
|
|
2925
|
+
name: "HAS_UV_SET1"
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
if (this.geometry.hasUVCoords(2)) {
|
|
2929
|
+
macroList.push({
|
|
2930
|
+
name: "HAS_UV_SET2"
|
|
2931
|
+
});
|
|
2932
|
+
}
|
|
2933
|
+
if (this.morph !== undefined && this.morph.hasMorph()) {
|
|
2934
|
+
// 存在 Morph 动画,需要配置 Morph 动画相关的 Shader 宏定义
|
|
2935
|
+
// USE_MORPHING 是总开关,WEIGHT_COUNT 是 weights 数组长度(Shader)
|
|
2936
|
+
macroList.push({
|
|
2937
|
+
name: "USE_MORPHING"
|
|
2938
|
+
});
|
|
2939
|
+
macroList.push({
|
|
2940
|
+
name: "WEIGHT_COUNT",
|
|
2941
|
+
value: this.morph.morphWeightsLength
|
|
2942
|
+
});
|
|
2943
|
+
for(var i = 0; i < this.morph.morphWeightsLength; i++){
|
|
2944
|
+
if (this.morph.hasPositionMorph) {
|
|
2945
|
+
macroList.push({
|
|
2946
|
+
name: "HAS_TARGET_POSITION" + i
|
|
2947
|
+
});
|
|
2948
|
+
}
|
|
2949
|
+
if (this.morph.hasNormalMorph) {
|
|
2950
|
+
macroList.push({
|
|
2951
|
+
name: "HAS_TARGET_NORMAL" + i
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2954
|
+
if (this.morph.hasTangentMorph) {
|
|
2955
|
+
macroList.push({
|
|
2956
|
+
name: "HAS_TARGET_TANGENT" + i
|
|
2957
|
+
});
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
if (this.skin !== undefined) {
|
|
2962
|
+
macroList.push({
|
|
2963
|
+
name: "USE_SKINNING"
|
|
2964
|
+
});
|
|
2965
|
+
macroList.push({
|
|
2966
|
+
name: "JOINT_COUNT",
|
|
2967
|
+
value: this.skin.getJointCount()
|
|
2968
|
+
});
|
|
2969
|
+
macroList.push({
|
|
2970
|
+
name: "HAS_JOINT_SET1"
|
|
2971
|
+
});
|
|
2972
|
+
macroList.push({
|
|
2973
|
+
name: "HAS_WEIGHT_SET1"
|
|
2974
|
+
});
|
|
2975
|
+
if (this.skin.textureDataMode) {
|
|
2976
|
+
macroList.push({
|
|
2977
|
+
name: "USE_SKINNING_TEXTURE"
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
if (this.material.materialType !== PMaterialType.unlit) {
|
|
2982
|
+
if (lightCount > 0 && this.geometry.hasNormals()) {
|
|
2983
|
+
macroList.push({
|
|
2984
|
+
name: "USE_PUNCTUAL"
|
|
2985
|
+
});
|
|
2986
|
+
macroList.push({
|
|
2987
|
+
name: "LIGHT_COUNT",
|
|
2988
|
+
value: lightCount
|
|
2989
|
+
});
|
|
2990
|
+
}
|
|
2991
|
+
if (skybox !== undefined && skybox.available) {
|
|
2992
|
+
macroList.push({
|
|
2993
|
+
name: "USE_IBL"
|
|
2994
|
+
});
|
|
2995
|
+
macroList.push({
|
|
2996
|
+
name: "USE_TEX_LOD"
|
|
2997
|
+
});
|
|
2998
|
+
if (skybox.hasDiffuseImage) ; else {
|
|
2999
|
+
macroList.push({
|
|
3000
|
+
name: "IRRADIANCE_COEFFICIENTS"
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
// if(!hasLight){
|
|
3005
|
+
// featureList.push('MATERIAL_UNLIT 1');
|
|
3006
|
+
// }
|
|
3007
|
+
}
|
|
3008
|
+
// 渲染中间结果输出,用于渲染效果调试,支持 pbr 和 unlit
|
|
3009
|
+
var renderMode = PGlobalState.getInstance().renderMode3D;
|
|
3010
|
+
var outputDefine = this.getRenderMode3DDefine(renderMode);
|
|
3011
|
+
if (outputDefine !== undefined) {
|
|
3012
|
+
macroList.push({
|
|
3013
|
+
name: "DEBUG_OUTPUT"
|
|
3014
|
+
});
|
|
3015
|
+
macroList.push({
|
|
3016
|
+
name: outputDefine
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
return macroList;
|
|
3020
|
+
};
|
|
2915
3021
|
/**
|
|
2916
3022
|
* 销毁,需要释放创建的 GE 对象
|
|
2917
3023
|
*/ _proto.dispose = function dispose() {
|
|
@@ -3776,7 +3882,7 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3776
3882
|
return PSceneManager;
|
|
3777
3883
|
}();
|
|
3778
3884
|
|
|
3779
|
-
var primitiveVert = "precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\n#include <animation.vert.glsl>\nvsIn vec4 aPos;vsOut vec3 v_Position;\n#ifdef HAS_NORMALS\nvsIn vec4 aNormal;\n#endif\n#ifdef HAS_TANGENTS\nvsIn vec4 a_Tangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvsOut mat3 v_TBN;\n#else\nvsOut vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nvsIn vec2 aUV;\n#endif\n#ifdef HAS_UV_SET2\nvsIn vec2
|
|
3885
|
+
var primitiveVert = "precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\n#include <animation.vert.glsl>\nvsIn vec4 aPos;vsOut vec3 v_Position;\n#ifdef HAS_NORMALS\nvsIn vec4 aNormal;\n#endif\n#ifdef HAS_TANGENTS\nvsIn vec4 a_Tangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvsOut mat3 v_TBN;\n#else\nvsOut vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nvsIn vec2 aUV;\n#endif\n#ifdef HAS_UV_SET2\nvsIn vec2 aUV2;\n#endif\nvsOut vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvsOut vec2 v_UVCoord2;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nvsIn vec3 a_Color;vsOut vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvsIn vec4 a_Color;vsOut vec4 v_Color;\n#endif\nuniform mat4 _ViewProjectionMatrix;uniform mat4 _ModelMatrix;uniform mat4 _NormalMatrix;\n#ifdef EDITOR_TRANSFORM\nuniform vec4 uEditorTransform;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 _LightViewProjectionMatrix;uniform float _DeltaSceneSize;vsOut vec4 v_PositionLightSpace;vsOut 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=a_Tangent;\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=_ModelMatrix*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(_ModelMatrix*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=a_Color;\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=_ViewProjectionMatrix*pos;\n#ifdef EDITOR_TRANSFORM\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
|
|
3780
3886
|
|
|
3781
3887
|
var metallicRoughnessFrag = "\n#define FEATURES\n#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n#if !defined(WEBGL2) && 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#if !defined(WEBGL2) && defined(USE_WBOIT)\n#extension GL_EXT_draw_buffers: require\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\n#ifdef USE_WBOIT\nlayout(location=0)out vec4 outFragColor0;layout(location=1)out vec4 outFragColor1;\n#else\nout vec4 outFragColor;\n#endif\n#else\n#ifdef USE_WBOIT\n#define outFragColor0 gl_FragData[0]\n#define outFragColor1 gl_FragData[1]\n#else\n#define outFragColor gl_FragColor\n#endif\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#include <tonemapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadowCommon.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 writeFragmentColor(vec4 fragColor){\n#if !defined(ALPHAMODE_OPAQUE) && defined(USE_WBOIT)\nfloat w=weight(gl_FragCoord.z,fragColor.a);fragColor.rgb*=fragColor.a;outFragColor0=vec4(fragColor.rgb*w,fragColor.a);outFragColor1=vec4(fragColor.a*w);\n#else\noutFragColor=fragColor;\n#endif\n}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\nwriteFragmentColor(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\nwriteFragmentColor(fragColorUnlit);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\noutFragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\noutFragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.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;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\nwriteFragmentColor(fragColorOut);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\noutFragColor.rgb=vec3(mix(1.0,ao,_OcclusionStrength));\n#else\noutFragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=_EmissiveFactor.rgb;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb;\n#endif\noutFragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\noutFragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\n}";
|
|
3782
3888
|
|
|
@@ -3835,6 +3941,18 @@ var StandardShaderSource;
|
|
|
3835
3941
|
* @param isWebGL2 - 是否 WebGL2
|
|
3836
3942
|
* @returns 最终代码
|
|
3837
3943
|
*/ StandardShaderSource.build = build;
|
|
3944
|
+
function getSourceCode(source, isWebGL2) {
|
|
3945
|
+
var match;
|
|
3946
|
+
while((match = /#include <(.+)>/gm.exec(source)) !== null){
|
|
3947
|
+
source = source.replace(match[0], glsl[match[1]]);
|
|
3948
|
+
}
|
|
3949
|
+
if (isWebGL2) {
|
|
3950
|
+
return "#version 300 es\n" + source;
|
|
3951
|
+
} else {
|
|
3952
|
+
return "#version 100\n" + source;
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
StandardShaderSource.getSourceCode = getSourceCode;
|
|
3838
3956
|
})(StandardShaderSource || (StandardShaderSource = {}));
|
|
3839
3957
|
|
|
3840
3958
|
/**
|
|
@@ -3880,12 +3998,57 @@ var StandardShaderSource;
|
|
|
3880
3998
|
throw new Error("Invalid material type " + materialType + " for getFragmentShaderString!");
|
|
3881
3999
|
}
|
|
3882
4000
|
};
|
|
4001
|
+
StandardShader.genVertexShaderCode = function genVertexShaderCode(materialType, isWebGL2) {
|
|
4002
|
+
switch(materialType){
|
|
4003
|
+
case PMaterialType.unlit:
|
|
4004
|
+
case PMaterialType.pbr:
|
|
4005
|
+
case PMaterialType.shadowBase:
|
|
4006
|
+
return StandardShaderSource.getSourceCode(primitiveVert, isWebGL2);
|
|
4007
|
+
case PMaterialType.skyboxFilter:
|
|
4008
|
+
return StandardShaderSource.getSourceCode(skyboxVert, isWebGL2);
|
|
4009
|
+
default:
|
|
4010
|
+
throw new Error("Invalid material type " + materialType + " for genVertexShaderCode!");
|
|
4011
|
+
}
|
|
4012
|
+
};
|
|
4013
|
+
/**
|
|
4014
|
+
* 获取片段着色器代码
|
|
4015
|
+
* @param materialType - 材质类型
|
|
4016
|
+
* @returns
|
|
4017
|
+
*/ StandardShader.genFragmentShaderCode = function genFragmentShaderCode(materialType, isWebGL2) {
|
|
4018
|
+
switch(materialType){
|
|
4019
|
+
case PMaterialType.unlit:
|
|
4020
|
+
case PMaterialType.pbr:
|
|
4021
|
+
return StandardShaderSource.getSourceCode(metallicRoughnessFrag, isWebGL2);
|
|
4022
|
+
case PMaterialType.shadowBase:
|
|
4023
|
+
return StandardShaderSource.getSourceCode(shadowPassFrag, isWebGL2);
|
|
4024
|
+
case PMaterialType.skyboxFilter:
|
|
4025
|
+
return StandardShaderSource.getSourceCode(skyboxFrag, isWebGL2);
|
|
4026
|
+
default:
|
|
4027
|
+
throw new Error("Invalid material type " + materialType + " for genFragmentShaderCode!");
|
|
4028
|
+
}
|
|
4029
|
+
};
|
|
3883
4030
|
return StandardShader;
|
|
3884
4031
|
}();
|
|
3885
4032
|
/**
|
|
3886
4033
|
* WebGL 环境
|
|
3887
4034
|
*/ StandardShader.environment = "webgl1";
|
|
3888
4035
|
|
|
4036
|
+
function fetchPBRShaderCode(isWebGL2) {
|
|
4037
|
+
var vertexShaderCode = StandardShader.genVertexShaderCode(PMaterialType.pbr, isWebGL2);
|
|
4038
|
+
var fragmentShaderCode = StandardShader.genFragmentShaderCode(PMaterialType.pbr, isWebGL2);
|
|
4039
|
+
return {
|
|
4040
|
+
vertexShaderCode: vertexShaderCode,
|
|
4041
|
+
fragmentShaderCode: fragmentShaderCode
|
|
4042
|
+
};
|
|
4043
|
+
}
|
|
4044
|
+
function fetchUnlitShaderCode(isWebGL2) {
|
|
4045
|
+
var vertexShaderCode = StandardShader.genVertexShaderCode(PMaterialType.unlit, isWebGL2);
|
|
4046
|
+
var fragmentShaderCode = StandardShader.genFragmentShaderCode(PMaterialType.unlit, isWebGL2);
|
|
4047
|
+
return {
|
|
4048
|
+
vertexShaderCode: vertexShaderCode,
|
|
4049
|
+
fragmentShaderCode: fragmentShaderCode
|
|
4050
|
+
};
|
|
4051
|
+
}
|
|
3889
4052
|
/**
|
|
3890
4053
|
* 获取 PBR 材质着色器代码
|
|
3891
4054
|
* @param context - 着色器上下文
|
|
@@ -4341,7 +4504,7 @@ var ModelMeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
4341
4504
|
return ModelMeshComponent;
|
|
4342
4505
|
}(RendererComponent);
|
|
4343
4506
|
ModelMeshComponent = __decorate([
|
|
4344
|
-
effectsClass(DataType.MeshComponent)
|
|
4507
|
+
effectsClass(spec.DataType.MeshComponent)
|
|
4345
4508
|
], ModelMeshComponent);
|
|
4346
4509
|
var ModelSkyboxComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
4347
4510
|
_inherits(ModelSkyboxComponent, RendererComponent);
|
|
@@ -4415,7 +4578,7 @@ var ModelSkyboxComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
4415
4578
|
return ModelSkyboxComponent;
|
|
4416
4579
|
}(RendererComponent);
|
|
4417
4580
|
ModelSkyboxComponent = __decorate([
|
|
4418
|
-
effectsClass(DataType.SkyboxComponent)
|
|
4581
|
+
effectsClass(spec.DataType.SkyboxComponent)
|
|
4419
4582
|
], ModelSkyboxComponent);
|
|
4420
4583
|
var ModelLightComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
4421
4584
|
_inherits(ModelLightComponent, ItemBehaviour);
|
|
@@ -4480,7 +4643,7 @@ var ModelLightComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
4480
4643
|
return ModelLightComponent;
|
|
4481
4644
|
}(ItemBehaviour);
|
|
4482
4645
|
ModelLightComponent = __decorate([
|
|
4483
|
-
effectsClass(DataType.LightComponent)
|
|
4646
|
+
effectsClass(spec.DataType.LightComponent)
|
|
4484
4647
|
], ModelLightComponent);
|
|
4485
4648
|
var ModelCameraComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
4486
4649
|
_inherits(ModelCameraComponent, ItemBehaviour);
|
|
@@ -4568,9 +4731,21 @@ var ModelCameraComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
4568
4731
|
return ModelCameraComponent;
|
|
4569
4732
|
}(ItemBehaviour);
|
|
4570
4733
|
ModelCameraComponent = __decorate([
|
|
4571
|
-
effectsClass(DataType.CameraComponent)
|
|
4734
|
+
effectsClass(spec.DataType.CameraComponent)
|
|
4572
4735
|
], ModelCameraComponent);
|
|
4573
4736
|
|
|
4737
|
+
// 射线与带旋转的包围盒求交
|
|
4738
|
+
// function transformDirection (m: Matrix4, direction: Vector3) {
|
|
4739
|
+
// const x = direction.x;
|
|
4740
|
+
// const y = direction.y;
|
|
4741
|
+
// const z = direction.z;
|
|
4742
|
+
// const me = m.elements;
|
|
4743
|
+
// const result = new Vector3();
|
|
4744
|
+
// result.x = me[0] * x + me[4] * y + me[8] * z;
|
|
4745
|
+
// result.y = me[1] * x + me[5] * y + me[9] * z;
|
|
4746
|
+
// result.z = me[2] * x + me[6] * y + me[10] * z;
|
|
4747
|
+
// return result.normalize();
|
|
4748
|
+
// }
|
|
4574
4749
|
/**
|
|
4575
4750
|
* 带旋转的射线与包围盒求交
|
|
4576
4751
|
* @param ray - 射线
|
|
@@ -5494,14 +5669,13 @@ var normal = new Vector3();
|
|
|
5494
5669
|
if (camera.perspective === undefined) {
|
|
5495
5670
|
return;
|
|
5496
5671
|
}
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
});
|
|
5672
|
+
// const p = camera.perspective;
|
|
5673
|
+
// const options: ModelCameraOptions = {
|
|
5674
|
+
// near: p.znear,
|
|
5675
|
+
// far: p.zfar ?? 1000,
|
|
5676
|
+
// fov: p.yfov,
|
|
5677
|
+
// clipMode: 0,
|
|
5678
|
+
// };
|
|
5505
5679
|
};
|
|
5506
5680
|
/**
|
|
5507
5681
|
* 转成播放器中 [0, 255] 区间的颜色值
|
|
@@ -5682,7 +5856,7 @@ var normal = new Vector3();
|
|
|
5682
5856
|
var textures = scene.textureOptions;
|
|
5683
5857
|
jsonScene.compositions.forEach(function(comp) {
|
|
5684
5858
|
comp.items.forEach(function(item) {
|
|
5685
|
-
if (item.type ===
|
|
5859
|
+
if (item.type === spec.ItemType.mesh) {
|
|
5686
5860
|
var meshItem = item;
|
|
5687
5861
|
var primitives = meshItem.content.options.primitives;
|
|
5688
5862
|
primitives.forEach(function(prim) {
|
|
@@ -5709,7 +5883,7 @@ var normal = new Vector3();
|
|
|
5709
5883
|
}
|
|
5710
5884
|
}
|
|
5711
5885
|
});
|
|
5712
|
-
} else if (item.type ===
|
|
5886
|
+
} else if (item.type === spec.ItemType.skybox) {
|
|
5713
5887
|
loadSkybox = true;
|
|
5714
5888
|
//
|
|
5715
5889
|
var skyboxItem = item;
|
|
@@ -5724,7 +5898,7 @@ var normal = new Vector3();
|
|
|
5724
5898
|
} else {
|
|
5725
5899
|
jsonScene.compositions.forEach(function(comp) {
|
|
5726
5900
|
comp.items.forEach(function(item) {
|
|
5727
|
-
if (item.type ===
|
|
5901
|
+
if (item.type === spec.ItemType.skybox) {
|
|
5728
5902
|
loadSkybox = true;
|
|
5729
5903
|
}
|
|
5730
5904
|
});
|
|
@@ -5734,7 +5908,7 @@ var normal = new Vector3();
|
|
|
5734
5908
|
jsonScene.compositions.forEach(function(comp) {
|
|
5735
5909
|
var lightCount = 0;
|
|
5736
5910
|
comp.items.forEach(function(item) {
|
|
5737
|
-
if (item.type ===
|
|
5911
|
+
if (item.type === spec.ItemType.light || item.type === spec.ItemType.skybox) {
|
|
5738
5912
|
++lightCount;
|
|
5739
5913
|
}
|
|
5740
5914
|
});
|
|
@@ -5861,7 +6035,7 @@ var normal = new Vector3();
|
|
|
5861
6035
|
sceneComp.items.forEach(function(data) {
|
|
5862
6036
|
var itemId = data.id;
|
|
5863
6037
|
var item = composition.getEngine().jsonSceneData[itemId];
|
|
5864
|
-
if (item.type ===
|
|
6038
|
+
if (item.type === spec.ItemType.mesh) {
|
|
5865
6039
|
var meshItem = item;
|
|
5866
6040
|
var skin = meshItem.content.options.skin;
|
|
5867
6041
|
var primitives = meshItem.content.options.primitives;
|
|
@@ -5896,7 +6070,7 @@ var normal = new Vector3();
|
|
|
5896
6070
|
console.error("setupItem3DOptions: Invalid inverseBindMatrices type, " + inverseBindMatrices);
|
|
5897
6071
|
}
|
|
5898
6072
|
}
|
|
5899
|
-
} else if (item.type ===
|
|
6073
|
+
} else if (item.type === spec.ItemType.tree) {
|
|
5900
6074
|
var jsonItem = item;
|
|
5901
6075
|
var studioItem = item;
|
|
5902
6076
|
var jsonAnimations = jsonItem.content.options.tree.animations;
|
|
@@ -5921,7 +6095,7 @@ var normal = new Vector3();
|
|
|
5921
6095
|
});
|
|
5922
6096
|
});
|
|
5923
6097
|
}
|
|
5924
|
-
} else if (item.type ===
|
|
6098
|
+
} else if (item.type === spec.ItemType.skybox) {
|
|
5925
6099
|
var skybox = item;
|
|
5926
6100
|
var studioSkybox = item;
|
|
5927
6101
|
var options = skybox.content.options;
|
|
@@ -7564,6 +7738,24 @@ var toHalf = function() {
|
|
|
7564
7738
|
}
|
|
7565
7739
|
return featureList;
|
|
7566
7740
|
};
|
|
7741
|
+
_proto.getShaderMacros = function getShaderMacros() {
|
|
7742
|
+
var macroList = [];
|
|
7743
|
+
if (this.isOpaque()) {
|
|
7744
|
+
macroList.push({
|
|
7745
|
+
name: "ALPHAMODE_OPAQUE"
|
|
7746
|
+
});
|
|
7747
|
+
} else if (this.isMasked()) {
|
|
7748
|
+
macroList.push({
|
|
7749
|
+
name: "ALPHAMODE_MASK"
|
|
7750
|
+
});
|
|
7751
|
+
}
|
|
7752
|
+
if (this.faceSideMode === PFaceSideMode.both) {
|
|
7753
|
+
macroList.push({
|
|
7754
|
+
name: "DOUBLE_SIDED"
|
|
7755
|
+
});
|
|
7756
|
+
}
|
|
7757
|
+
return macroList;
|
|
7758
|
+
};
|
|
7567
7759
|
/**
|
|
7568
7760
|
* 根据材质状态,更新 GE 材质状态
|
|
7569
7761
|
* @param material - GE 材质
|
|
@@ -7615,6 +7807,30 @@ var toHalf = function() {
|
|
|
7615
7807
|
}
|
|
7616
7808
|
return finalFeatureList;
|
|
7617
7809
|
};
|
|
7810
|
+
_proto.getMacroList = function getMacroList(inMacroList) {
|
|
7811
|
+
var finalMacroList = this.getShaderMacros();
|
|
7812
|
+
if (inMacroList !== undefined) {
|
|
7813
|
+
var _finalMacroList;
|
|
7814
|
+
(_finalMacroList = finalMacroList).push.apply(_finalMacroList, [].concat(inMacroList));
|
|
7815
|
+
}
|
|
7816
|
+
var isWebGL2 = PGlobalState.getInstance().isWebGL2;
|
|
7817
|
+
if (isWebGL2) {
|
|
7818
|
+
finalMacroList.push({
|
|
7819
|
+
name: "WEBGL2"
|
|
7820
|
+
});
|
|
7821
|
+
}
|
|
7822
|
+
// 目前只有 PRB 和 Unlit 是需要 EDITOR_TRANSFORM,适配编辑器的视口 Offset
|
|
7823
|
+
// 阴影 Pass 的渲染是不需要,所以这里特殊处理下
|
|
7824
|
+
if (this.materialType !== PMaterialType.shadowBase) {
|
|
7825
|
+
var isEditorEvn = PGlobalState.getInstance().isEditorEnv;
|
|
7826
|
+
if (isEditorEvn) {
|
|
7827
|
+
finalMacroList.push({
|
|
7828
|
+
name: "EDITOR_TRANSFORM"
|
|
7829
|
+
});
|
|
7830
|
+
}
|
|
7831
|
+
}
|
|
7832
|
+
return finalMacroList;
|
|
7833
|
+
};
|
|
7618
7834
|
/**
|
|
7619
7835
|
* 获取混合模式,根据 GE 混合模式
|
|
7620
7836
|
* @param mode - GE 混合模式
|
|
@@ -7764,10 +7980,7 @@ var toHalf = function() {
|
|
|
7764
7980
|
*/ var PMaterialUnlit = /*#__PURE__*/ function(PMaterialBase) {
|
|
7765
7981
|
_inherits(PMaterialUnlit, PMaterialBase);
|
|
7766
7982
|
function PMaterialUnlit() {
|
|
7767
|
-
|
|
7768
|
-
_this = PMaterialBase.apply(this, arguments) || this;
|
|
7769
|
-
_this.baseColorFactor = new Vector4(1, 1, 1, 1);
|
|
7770
|
-
return _this;
|
|
7983
|
+
return PMaterialBase.apply(this, arguments);
|
|
7771
7984
|
}
|
|
7772
7985
|
var _proto = PMaterialUnlit.prototype;
|
|
7773
7986
|
/**
|
|
@@ -7781,7 +7994,6 @@ var toHalf = function() {
|
|
|
7781
7994
|
if (options.baseColorTexture) {
|
|
7782
7995
|
this.baseColorTexture = options.baseColorTexture;
|
|
7783
7996
|
}
|
|
7784
|
-
this.setBaseColorFactor(PluginHelper.toPluginColor4(options.baseColorFactor));
|
|
7785
7997
|
/**
|
|
7786
7998
|
* 默认需要写入深度值,只有传入false才是false
|
|
7787
7999
|
*/ if (options.depthMask === false) {
|
|
@@ -7794,6 +8006,25 @@ var toHalf = function() {
|
|
|
7794
8006
|
this.alphaCutOff = (_options_alphaCutOff = options.alphaCutOff) != null ? _options_alphaCutOff : 0;
|
|
7795
8007
|
this.faceSideMode = this.getFaceSideMode(options.side);
|
|
7796
8008
|
};
|
|
8009
|
+
_proto.createFromMaterial = function createFromMaterial(mat) {
|
|
8010
|
+
this.fromMaterial = true;
|
|
8011
|
+
this.material = mat;
|
|
8012
|
+
this.name = mat.name;
|
|
8013
|
+
this.type = PObjectType.material;
|
|
8014
|
+
this.materialType = PMaterialType.unlit;
|
|
8015
|
+
var _mat_getTexture;
|
|
8016
|
+
//
|
|
8017
|
+
this.baseColorTexture = (_mat_getTexture = mat.getTexture("_BaseColorSampler")) != null ? _mat_getTexture : undefined;
|
|
8018
|
+
this.depthMask = true;
|
|
8019
|
+
var _mat_getInt;
|
|
8020
|
+
var blending = (_mat_getInt = mat.getInt("blending")) != null ? _mat_getInt : spec.MaterialBlending.opaque;
|
|
8021
|
+
this.blendMode = this.getBlendMode(blending);
|
|
8022
|
+
var _mat_getFloat;
|
|
8023
|
+
this.alphaCutOff = (_mat_getFloat = mat.getFloat("_AlphaCutoff")) != null ? _mat_getFloat : 0;
|
|
8024
|
+
var _mat_getInt1;
|
|
8025
|
+
var side = (_mat_getInt1 = mat.getInt("side")) != null ? _mat_getInt1 : spec.SideMode.FRONT;
|
|
8026
|
+
this.faceSideMode = this.getFaceSideMode(side);
|
|
8027
|
+
};
|
|
7797
8028
|
/**
|
|
7798
8029
|
* 销毁材质
|
|
7799
8030
|
*/ _proto.dispose = function dispose() {
|
|
@@ -7812,6 +8043,21 @@ var toHalf = function() {
|
|
|
7812
8043
|
featureList.push("MATERIAL_UNLIT 1");
|
|
7813
8044
|
return featureList;
|
|
7814
8045
|
};
|
|
8046
|
+
_proto.getShaderMacros = function getShaderMacros() {
|
|
8047
|
+
var macroList = PMaterialBase.prototype.getShaderMacros.call(this);
|
|
8048
|
+
macroList.push({
|
|
8049
|
+
name: "MATERIAL_METALLICROUGHNESS"
|
|
8050
|
+
});
|
|
8051
|
+
if (this.hasBaseColorTexture()) {
|
|
8052
|
+
macroList.push({
|
|
8053
|
+
name: "HAS_BASE_COLOR_MAP"
|
|
8054
|
+
});
|
|
8055
|
+
}
|
|
8056
|
+
macroList.push({
|
|
8057
|
+
name: "MATERIAL_UNLIT"
|
|
8058
|
+
});
|
|
8059
|
+
return macroList;
|
|
8060
|
+
};
|
|
7815
8061
|
/**
|
|
7816
8062
|
* 更新对应的 GE 材质中着色器的 Uniform 数据
|
|
7817
8063
|
* @param material - GE 材质
|
|
@@ -7819,14 +8065,12 @@ var toHalf = function() {
|
|
|
7819
8065
|
PMaterialBase.prototype.updateUniforms.call(this, material);
|
|
7820
8066
|
//
|
|
7821
8067
|
var uvTransform = new Matrix3().identity();
|
|
7822
|
-
material.setVector4("_BaseColorFactor", this.baseColorFactor);
|
|
7823
8068
|
if (this.hasBaseColorTexture()) {
|
|
7824
|
-
material.setTexture("_BaseColorSampler", this.getBaseColorTexture());
|
|
7825
8069
|
material.setInt("_BaseColorUVSet", 0);
|
|
7826
8070
|
material.setMatrix3("_BaseColorUVTransform", uvTransform);
|
|
7827
8071
|
}
|
|
7828
|
-
material.setFloat("_MetallicFactor", 0
|
|
7829
|
-
material.setFloat("_RoughnessFactor", 0
|
|
8072
|
+
material.setFloat("_MetallicFactor", 0);
|
|
8073
|
+
material.setFloat("_RoughnessFactor", 0);
|
|
7830
8074
|
material.setFloat("_Exposure", 1.0);
|
|
7831
8075
|
};
|
|
7832
8076
|
/**
|
|
@@ -7847,22 +8091,6 @@ var toHalf = function() {
|
|
|
7847
8091
|
*/ _proto.setBaseColorTexture = function setBaseColorTexture(val) {
|
|
7848
8092
|
this.baseColorTexture = val;
|
|
7849
8093
|
};
|
|
7850
|
-
/**
|
|
7851
|
-
* 获取基础颜色值
|
|
7852
|
-
* @returns
|
|
7853
|
-
*/ _proto.getBaseColorFactor = function getBaseColorFactor() {
|
|
7854
|
-
return this.baseColorFactor;
|
|
7855
|
-
};
|
|
7856
|
-
/**
|
|
7857
|
-
* 设置基础颜色值
|
|
7858
|
-
* @param val - 颜色值
|
|
7859
|
-
*/ _proto.setBaseColorFactor = function setBaseColorFactor(val) {
|
|
7860
|
-
if (_instanceof1(val, Vector4)) {
|
|
7861
|
-
this.baseColorFactor.set(val.x, val.y, val.z, val.w);
|
|
7862
|
-
} else {
|
|
7863
|
-
this.baseColorFactor.set(val[0], val[1], val[2], val[3]);
|
|
7864
|
-
}
|
|
7865
|
-
};
|
|
7866
8094
|
return PMaterialUnlit;
|
|
7867
8095
|
}(PMaterialBase);
|
|
7868
8096
|
/**
|
|
@@ -7962,8 +8190,6 @@ var toHalf = function() {
|
|
|
7962
8190
|
this.depthMask = true;
|
|
7963
8191
|
}
|
|
7964
8192
|
this.blendMode = this.getBlendMode(options.blending);
|
|
7965
|
-
var _options_alphaCutOff;
|
|
7966
|
-
this.alphaCutOff = (_options_alphaCutOff = options.alphaCutOff) != null ? _options_alphaCutOff : 0;
|
|
7967
8193
|
this.faceSideMode = this.getFaceSideMode(options.side);
|
|
7968
8194
|
};
|
|
7969
8195
|
_proto.createFromMaterial = function createFromMaterial(mat) {
|
|
@@ -7971,7 +8197,7 @@ var toHalf = function() {
|
|
|
7971
8197
|
this.material = mat;
|
|
7972
8198
|
this.name = mat.name;
|
|
7973
8199
|
this.type = PObjectType.material;
|
|
7974
|
-
this.materialType =
|
|
8200
|
+
this.materialType = PMaterialType.pbr;
|
|
7975
8201
|
var _mat_getTexture;
|
|
7976
8202
|
//
|
|
7977
8203
|
this.baseColorTexture = (_mat_getTexture = mat.getTexture("_BaseColorSampler")) != null ? _mat_getTexture : undefined;
|
|
@@ -8064,6 +8290,72 @@ var toHalf = function() {
|
|
|
8064
8290
|
}
|
|
8065
8291
|
return featureList;
|
|
8066
8292
|
};
|
|
8293
|
+
_proto.getShaderMacros = function getShaderMacros() {
|
|
8294
|
+
var macroList = PMaterialBase.prototype.getShaderMacros.call(this);
|
|
8295
|
+
macroList.push({
|
|
8296
|
+
name: "MATERIAL_METALLICROUGHNESS"
|
|
8297
|
+
});
|
|
8298
|
+
if (this.hasBaseColorTexture()) {
|
|
8299
|
+
macroList.push({
|
|
8300
|
+
name: "HAS_BASE_COLOR_MAP"
|
|
8301
|
+
});
|
|
8302
|
+
if (this.baseColorTextureTrans !== undefined) {
|
|
8303
|
+
macroList.push({
|
|
8304
|
+
name: "HAS_BASECOLOR_UV_TRANSFORM"
|
|
8305
|
+
});
|
|
8306
|
+
}
|
|
8307
|
+
}
|
|
8308
|
+
if (this.hasMetallicRoughnessTexture()) {
|
|
8309
|
+
macroList.push({
|
|
8310
|
+
name: "HAS_METALLIC_ROUGHNESS_MAP"
|
|
8311
|
+
});
|
|
8312
|
+
if (this.metallicRoughnessTextureTrans !== undefined) {
|
|
8313
|
+
macroList.push({
|
|
8314
|
+
name: "HAS_METALLICROUGHNESS_UV_TRANSFORM"
|
|
8315
|
+
});
|
|
8316
|
+
}
|
|
8317
|
+
}
|
|
8318
|
+
if (this.useSpecularAA) {
|
|
8319
|
+
macroList.push({
|
|
8320
|
+
name: "USE_SPECULAR_AA"
|
|
8321
|
+
});
|
|
8322
|
+
}
|
|
8323
|
+
if (this.hasNormalTexture()) {
|
|
8324
|
+
macroList.push({
|
|
8325
|
+
name: "HAS_NORMAL_MAP"
|
|
8326
|
+
});
|
|
8327
|
+
if (this.normalTextureTrans !== undefined) {
|
|
8328
|
+
macroList.push({
|
|
8329
|
+
name: "HAS_NORMAL_UV_TRANSFORM"
|
|
8330
|
+
});
|
|
8331
|
+
}
|
|
8332
|
+
}
|
|
8333
|
+
if (this.hasOcclusionTexture()) {
|
|
8334
|
+
macroList.push({
|
|
8335
|
+
name: "HAS_OCCLUSION_MAP"
|
|
8336
|
+
});
|
|
8337
|
+
if (this.occlusionTextureTrans !== undefined) {
|
|
8338
|
+
macroList.push({
|
|
8339
|
+
name: "HAS_OCCLUSION_UV_TRANSFORM"
|
|
8340
|
+
});
|
|
8341
|
+
}
|
|
8342
|
+
}
|
|
8343
|
+
if (this.hasEmissiveTexture()) {
|
|
8344
|
+
macroList.push({
|
|
8345
|
+
name: "HAS_EMISSIVE_MAP"
|
|
8346
|
+
});
|
|
8347
|
+
if (this.emissiveTextureTrans !== undefined) {
|
|
8348
|
+
macroList.push({
|
|
8349
|
+
name: "HAS_EMISSIVE_UV_TRANSFORM"
|
|
8350
|
+
});
|
|
8351
|
+
}
|
|
8352
|
+
} else if (this.hasEmissiveFactor()) {
|
|
8353
|
+
macroList.push({
|
|
8354
|
+
name: "HAS_EMISSIVE"
|
|
8355
|
+
});
|
|
8356
|
+
}
|
|
8357
|
+
return macroList;
|
|
8358
|
+
};
|
|
8067
8359
|
/**
|
|
8068
8360
|
* 更新关联的 GE 材质中着色器的 Uniform 数据
|
|
8069
8361
|
* @param material - GE 材质
|
|
@@ -8336,18 +8628,24 @@ var toHalf = function() {
|
|
|
8336
8628
|
* @returns 材质对象
|
|
8337
8629
|
*/ function createPluginMaterial(options) {
|
|
8338
8630
|
if (_instanceof1(options, Material)) {
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8631
|
+
if (options.shader.getInstanceId() === PBRShaderGUID) {
|
|
8632
|
+
var materialPBR = new PMaterialPBR();
|
|
8633
|
+
materialPBR.createFromMaterial(options);
|
|
8634
|
+
return materialPBR;
|
|
8635
|
+
} else {
|
|
8636
|
+
var materialUnlit = new PMaterialUnlit();
|
|
8637
|
+
materialUnlit.createFromMaterial(options);
|
|
8638
|
+
return materialUnlit;
|
|
8639
|
+
}
|
|
8342
8640
|
} else {
|
|
8343
8641
|
if (options.type === spec.MaterialType.pbr) {
|
|
8344
8642
|
var materialPBR1 = new PMaterialPBR();
|
|
8345
8643
|
materialPBR1.create(options);
|
|
8346
8644
|
return materialPBR1;
|
|
8347
8645
|
} else {
|
|
8348
|
-
var
|
|
8349
|
-
|
|
8350
|
-
return
|
|
8646
|
+
var materialUnlit1 = new PMaterialUnlit();
|
|
8647
|
+
materialUnlit1.create(options);
|
|
8648
|
+
return materialUnlit1;
|
|
8351
8649
|
}
|
|
8352
8650
|
}
|
|
8353
8651
|
}
|
|
@@ -8806,12 +9104,12 @@ var PSkyboxType;
|
|
|
8806
9104
|
*/ PSkyboxCreator.createSpecularCubeMap = function createSpecularCubeMap(engine, params) {
|
|
8807
9105
|
return _async_to_generator(function() {
|
|
8808
9106
|
return __generator(this, function(_state) {
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
}
|
|
9107
|
+
// const configOptions: TextureConfigOptions = {
|
|
9108
|
+
// wrapS: glContext.CLAMP_TO_EDGE,
|
|
9109
|
+
// wrapT: glContext.CLAMP_TO_EDGE,
|
|
9110
|
+
// magFilter: glContext.LINEAR,
|
|
9111
|
+
// minFilter: glContext.LINEAR_MIPMAP_LINEAR,
|
|
9112
|
+
// };
|
|
8815
9113
|
if (params.type === "url") {
|
|
8816
9114
|
return [
|
|
8817
9115
|
2,
|
|
@@ -8877,7 +9175,9 @@ var PSkyboxType;
|
|
|
8877
9175
|
var dataArray = [];
|
|
8878
9176
|
switch(skyboxType){
|
|
8879
9177
|
case 0:
|
|
8880
|
-
|
|
9178
|
+
{
|
|
9179
|
+
return undefined;
|
|
9180
|
+
}
|
|
8881
9181
|
case 1:
|
|
8882
9182
|
dataArray = [
|
|
8883
9183
|
0.2665672302246094,
|
|
@@ -9367,7 +9667,7 @@ var PSkyboxType;
|
|
|
9367
9667
|
* @param options - 加载选项
|
|
9368
9668
|
*/ ModelPlugin.prepareResource = function prepareResource(scene, options) {
|
|
9369
9669
|
return _async_to_generator(function() {
|
|
9370
|
-
var
|
|
9670
|
+
var keyList, pluginData, _options_env, runtimeEnv;
|
|
9371
9671
|
return __generator(this, function(_state) {
|
|
9372
9672
|
switch(_state.label){
|
|
9373
9673
|
case 0:
|
|
@@ -9389,8 +9689,8 @@ var PSkyboxType;
|
|
|
9389
9689
|
//
|
|
9390
9690
|
runtimeEnv = (_options_env = options.env) != null ? _options_env : "";
|
|
9391
9691
|
scene.storage["runtimeEnv"] = runtimeEnv;
|
|
9392
|
-
|
|
9393
|
-
|
|
9692
|
+
// const compatibleMode = options.pluginData?.['compatibleMode'] ?? 'gltf';
|
|
9693
|
+
// const autoAdjustScene = options.pluginData?.['autoAdjustScene'] ?? false;
|
|
9394
9694
|
//
|
|
9395
9695
|
//PluginHelper.preprocessScene(scene, runtimeEnv, compatibleMode, autoAdjustScene);
|
|
9396
9696
|
return [
|
|
@@ -9408,24 +9708,28 @@ var PSkyboxType;
|
|
|
9408
9708
|
};
|
|
9409
9709
|
ModelPlugin.precompile = function precompile(compositions, renderer) {
|
|
9410
9710
|
var isWebGL2 = renderer.engine.gpuCapability.level === 2;
|
|
9411
|
-
var
|
|
9711
|
+
var pbrShaderCode = fetchPBRShaderCode(isWebGL2);
|
|
9712
|
+
var unlitShaderCode = fetchUnlitShaderCode(isWebGL2);
|
|
9713
|
+
var pbrShaderData = {
|
|
9714
|
+
id: PBRShaderGUID,
|
|
9715
|
+
name: "PBR Shader",
|
|
9716
|
+
dataType: spec.DataType.Shader,
|
|
9717
|
+
fragment: pbrShaderCode.fragmentShaderCode,
|
|
9718
|
+
vertex: pbrShaderCode.vertexShaderCode,
|
|
9412
9719
|
// @ts-expect-error
|
|
9413
|
-
|
|
9414
|
-
materialType: PMaterialType.pbr
|
|
9415
|
-
},
|
|
9416
|
-
isWebGL2: isWebGL2,
|
|
9417
|
-
featureList: []
|
|
9720
|
+
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
9418
9721
|
};
|
|
9419
|
-
var
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9722
|
+
var unlitShaderData = {
|
|
9723
|
+
id: UnlitShaderGUID,
|
|
9724
|
+
name: "Unlit Shader",
|
|
9725
|
+
dataType: spec.DataType.Shader,
|
|
9726
|
+
fragment: unlitShaderCode.fragmentShaderCode,
|
|
9727
|
+
vertex: unlitShaderCode.vertexShaderCode,
|
|
9424
9728
|
// @ts-expect-error
|
|
9425
|
-
fragment: pbrShader.fragmentShaderCode,
|
|
9426
|
-
vertex: pbrShader.vertexShaderCode,
|
|
9427
9729
|
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
9428
|
-
}
|
|
9730
|
+
};
|
|
9731
|
+
renderer.engine.addEffectsObjectData(pbrShaderData);
|
|
9732
|
+
renderer.engine.addEffectsObjectData(unlitShaderData);
|
|
9429
9733
|
return Promise.resolve();
|
|
9430
9734
|
};
|
|
9431
9735
|
return ModelPlugin;
|
|
@@ -9585,7 +9889,7 @@ var ModelPluginComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
9585
9889
|
return ModelPluginComponent;
|
|
9586
9890
|
}(ItemBehaviour);
|
|
9587
9891
|
ModelPluginComponent = __decorate([
|
|
9588
|
-
effectsClass(DataType.ModelPluginComponent)
|
|
9892
|
+
effectsClass(spec.DataType.ModelPluginComponent)
|
|
9589
9893
|
], ModelPluginComponent);
|
|
9590
9894
|
/**
|
|
9591
9895
|
* 获取场景管理器,从合成中查找
|
|
@@ -9781,7 +10085,7 @@ var ModelTreeComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
9781
10085
|
return ModelTreeComponent;
|
|
9782
10086
|
}(ItemBehaviour);
|
|
9783
10087
|
ModelTreeComponent = __decorate([
|
|
9784
|
-
effectsClass(DataType.TreeComponent)
|
|
10088
|
+
effectsClass(spec.DataType.TreeComponent)
|
|
9785
10089
|
], ModelTreeComponent);
|
|
9786
10090
|
|
|
9787
10091
|
/**
|
|
@@ -11701,8 +12005,8 @@ var GLTFHelper = /*#__PURE__*/ function() {
|
|
|
11701
12005
|
|
|
11702
12006
|
registerPlugin("tree", ModelTreePlugin, VFXItem, true);
|
|
11703
12007
|
registerPlugin("model", ModelPlugin, VFXItem);
|
|
11704
|
-
var version = "2.0.0-alpha.
|
|
12008
|
+
var version = "2.0.0-alpha.8";
|
|
11705
12009
|
logger.info("plugin model version: " + version);
|
|
11706
12010
|
|
|
11707
|
-
export { BoxMesh, CameraGestureHandlerImp, CameraGestureType, CheckerHelper, CompositionCache, CompositionHitTest, FBOOptions, Float16ArrayWrapper, GeometryBoxProxy, HitTestingProxy, HookOGLFunc, InterpolationSampler, LoaderHelper, LoaderImpl, MeshHelper, ModelCameraComponent, ModelLightComponent, ModelMeshComponent, ModelPlugin, ModelPluginComponent, ModelSkyboxComponent, ModelTreeComponent, ModelTreeItem, ModelTreePlugin, PAnimInterpType, PAnimPathType, PAnimTexture, PAnimTrack, PAnimation, PAnimationManager, PBlendMode, PCamera, PCameraManager, PCoordinate, PEntity, PFaceSideMode, PGeometry, PGlobalState, PLight, PLightManager, PLightType, PMaterialBase, PMaterialPBR, PMaterialSkyboxFilter, PMaterialType, PMaterialUnlit, PMesh, PMorph, PObject, PObjectType, PPrimitive, PSceneManager, PShaderManager, PShadowType, PSkin, PSkybox, PSkyboxCreator, PSkyboxType, PTextureType, PTransform, PluginHelper, RayBoxTesting, RayIntersectsBoxWithRotation, RayTriangleTesting, TextureDataMode, ToggleItemBounding, TwoStatesSet, VFX_ITEM_TYPE_3D, VertexAttribBuffer, WebGLHelper, WebHelper, createAnimationSampler, createInternalMaterial, createPluginMaterial, getDefaultEffectsGLTFLoader, getDiffuseOnlyShaderCode, getGaussianBlurShaderCodeV1, getGaussianBlurShaderCodeV2, getKawaseBlurShaderCode, getNormalVisShaderCode, getPBRPassShaderCode, getPMeshList, getQuadFilterShaderCode, getRendererGPUInfo, getSceneManager, getShadowPassShaderCode, getSimpleFilterShaderCode, getSkyBoxShaderCode, getTransparecyBaseShader, getTransparecyFilterShader, setDefaultEffectsGLTFLoader, version };
|
|
12011
|
+
export { BoxMesh, CameraGestureHandlerImp, CameraGestureType, CheckerHelper, CompositionCache, CompositionHitTest, FBOOptions, Float16ArrayWrapper, GeometryBoxProxy, HitTestingProxy, HookOGLFunc, InterpolationSampler, LoaderHelper, LoaderImpl, 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, PPrimitive, PSceneManager, PShaderManager, PShadowType, PSkin, PSkybox, PSkyboxCreator, PSkyboxType, PTextureType, PTransform, PluginHelper, RayBoxTesting, RayIntersectsBoxWithRotation, RayTriangleTesting, TextureDataMode, ToggleItemBounding, TwoStatesSet, UnlitShaderGUID, VFX_ITEM_TYPE_3D, VertexAttribBuffer, WebGLHelper, WebHelper, createAnimationSampler, createInternalMaterial, createPluginMaterial, fetchPBRShaderCode, fetchUnlitShaderCode, getDefaultEffectsGLTFLoader, getDiffuseOnlyShaderCode, getGaussianBlurShaderCodeV1, getGaussianBlurShaderCodeV2, getKawaseBlurShaderCode, getNormalVisShaderCode, getPBRPassShaderCode, getPMeshList, getQuadFilterShaderCode, getRendererGPUInfo, getSceneManager, getShadowPassShaderCode, getSimpleFilterShaderCode, getSkyBoxShaderCode, getTransparecyBaseShader, getTransparecyFilterShader, setDefaultEffectsGLTFLoader, version };
|
|
11708
12012
|
//# sourceMappingURL=index.mjs.map
|