@galacean/engine 1.0.0-beta.15 → 1.0.0-beta.16
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/browser.js +192 -90
- package/dist/browser.min.js +1 -1
- package/dist/main.js +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/browser.js
CHANGED
|
@@ -4656,10 +4656,11 @@
|
|
|
4656
4656
|
if (y === void 0) y = 0;
|
|
4657
4657
|
if (width === void 0) width = 0;
|
|
4658
4658
|
if (height === void 0) height = 0;
|
|
4659
|
-
this.
|
|
4660
|
-
this.
|
|
4661
|
-
this.
|
|
4662
|
-
this.
|
|
4659
|
+
/** @internal */ this._onValueChanged = null;
|
|
4660
|
+
this._x = x;
|
|
4661
|
+
this._y = y;
|
|
4662
|
+
this._width = width;
|
|
4663
|
+
this._height = height;
|
|
4663
4664
|
};
|
|
4664
4665
|
var _proto = Rect.prototype;
|
|
4665
4666
|
/**
|
|
@@ -4670,10 +4671,11 @@
|
|
|
4670
4671
|
* @param height - The height of the rectangle, measured from the y position
|
|
4671
4672
|
* @returns This rectangle
|
|
4672
4673
|
*/ _proto.set = function set(x, y, width, height) {
|
|
4673
|
-
this.
|
|
4674
|
-
this.
|
|
4675
|
-
this.
|
|
4676
|
-
this.
|
|
4674
|
+
this._x = x;
|
|
4675
|
+
this._y = y;
|
|
4676
|
+
this._width = width;
|
|
4677
|
+
this._height = height;
|
|
4678
|
+
this._onValueChanged && this._onValueChanged();
|
|
4677
4679
|
return this;
|
|
4678
4680
|
};
|
|
4679
4681
|
/**
|
|
@@ -4687,12 +4689,63 @@
|
|
|
4687
4689
|
* @param source - The specified rect
|
|
4688
4690
|
* @returns This rect
|
|
4689
4691
|
*/ _proto.copyFrom = function copyFrom(source) {
|
|
4690
|
-
this.
|
|
4691
|
-
this.
|
|
4692
|
-
this.
|
|
4693
|
-
this.
|
|
4692
|
+
this._x = source.x;
|
|
4693
|
+
this._y = source.y;
|
|
4694
|
+
this._width = source.width;
|
|
4695
|
+
this._height = source.height;
|
|
4696
|
+
this._onValueChanged && this._onValueChanged();
|
|
4694
4697
|
return this;
|
|
4695
4698
|
};
|
|
4699
|
+
_create_class$4(Rect, [
|
|
4700
|
+
{
|
|
4701
|
+
key: "x",
|
|
4702
|
+
get: /**
|
|
4703
|
+
* The x coordinate of the rectangle.
|
|
4704
|
+
*/ function get() {
|
|
4705
|
+
return this._x;
|
|
4706
|
+
},
|
|
4707
|
+
set: function set(value) {
|
|
4708
|
+
this._x = value;
|
|
4709
|
+
this._onValueChanged && this._onValueChanged();
|
|
4710
|
+
}
|
|
4711
|
+
},
|
|
4712
|
+
{
|
|
4713
|
+
key: "y",
|
|
4714
|
+
get: /**
|
|
4715
|
+
* The y coordinate of the rectangle.
|
|
4716
|
+
*/ function get() {
|
|
4717
|
+
return this._y;
|
|
4718
|
+
},
|
|
4719
|
+
set: function set(value) {
|
|
4720
|
+
this._y = value;
|
|
4721
|
+
this._onValueChanged && this._onValueChanged();
|
|
4722
|
+
}
|
|
4723
|
+
},
|
|
4724
|
+
{
|
|
4725
|
+
key: "width",
|
|
4726
|
+
get: /**
|
|
4727
|
+
* The width of the rectangle, measured from the x position.
|
|
4728
|
+
*/ function get() {
|
|
4729
|
+
return this._width;
|
|
4730
|
+
},
|
|
4731
|
+
set: function set(value) {
|
|
4732
|
+
this._width = value;
|
|
4733
|
+
this._onValueChanged && this._onValueChanged();
|
|
4734
|
+
}
|
|
4735
|
+
},
|
|
4736
|
+
{
|
|
4737
|
+
key: "height",
|
|
4738
|
+
get: /**
|
|
4739
|
+
* The height of the rectangle, measured from the y position.
|
|
4740
|
+
*/ function get() {
|
|
4741
|
+
return this._height;
|
|
4742
|
+
},
|
|
4743
|
+
set: function set(value) {
|
|
4744
|
+
this._height = value;
|
|
4745
|
+
this._onValueChanged && this._onValueChanged();
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4748
|
+
]);
|
|
4696
4749
|
return Rect;
|
|
4697
4750
|
}();
|
|
4698
4751
|
/**
|
|
@@ -7824,15 +7877,24 @@
|
|
|
7824
7877
|
};
|
|
7825
7878
|
var _proto = DisorderedArray.prototype;
|
|
7826
7879
|
_proto.add = function add(element) {
|
|
7827
|
-
if (this.length === this._elements.length)
|
|
7828
|
-
|
|
7880
|
+
if (this.length === this._elements.length) {
|
|
7881
|
+
this._elements.push(element);
|
|
7882
|
+
} else {
|
|
7883
|
+
this._elements[this.length] = element;
|
|
7884
|
+
}
|
|
7829
7885
|
this.length++;
|
|
7830
7886
|
};
|
|
7831
7887
|
_proto.delete = function _delete(element) {
|
|
7832
|
-
//
|
|
7888
|
+
// @todo: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
7833
7889
|
var index = this._elements.indexOf(element);
|
|
7834
7890
|
this.deleteByIndex(index);
|
|
7835
7891
|
};
|
|
7892
|
+
_proto.set = function set(index, element) {
|
|
7893
|
+
if (index >= this.length) {
|
|
7894
|
+
throw "Index is out of range.";
|
|
7895
|
+
}
|
|
7896
|
+
this._elements[index] = element;
|
|
7897
|
+
};
|
|
7836
7898
|
_proto.get = function get(index) {
|
|
7837
7899
|
if (index >= this.length) {
|
|
7838
7900
|
throw "Index is out of range.";
|
|
@@ -7840,9 +7902,9 @@
|
|
|
7840
7902
|
return this._elements[index];
|
|
7841
7903
|
};
|
|
7842
7904
|
/**
|
|
7843
|
-
*
|
|
7844
|
-
* @param index
|
|
7845
|
-
* @returns The replaced item is used to reset its index
|
|
7905
|
+
* Delete the element at the specified index.
|
|
7906
|
+
* @param index - The index of the element to be deleted
|
|
7907
|
+
* @returns The replaced item is used to reset its index
|
|
7846
7908
|
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
7847
7909
|
var elements = this._elements;
|
|
7848
7910
|
var end = null;
|
|
@@ -13154,31 +13216,18 @@
|
|
|
13154
13216
|
};
|
|
13155
13217
|
/**
|
|
13156
13218
|
* @internal
|
|
13157
|
-
*/ _proto.
|
|
13219
|
+
*/ _proto._updateSunLightIndex = function _updateSunLightIndex() {
|
|
13158
13220
|
var directLights = this._directLights;
|
|
13159
|
-
var
|
|
13160
|
-
|
|
13161
|
-
|
|
13162
|
-
|
|
13163
|
-
var
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
var intensity = directLight.intensity * directLight.color.getBrightness();
|
|
13169
|
-
if (hasShadowLight) {
|
|
13170
|
-
if (directLight.shadowType !== exports.ShadowType.None && maxIntensity < intensity) {
|
|
13171
|
-
maxIntensity = intensity;
|
|
13172
|
-
sunLightIndex = i;
|
|
13173
|
-
}
|
|
13174
|
-
} else {
|
|
13175
|
-
if (maxIntensity < intensity) {
|
|
13176
|
-
maxIntensity = intensity;
|
|
13177
|
-
sunLightIndex = i;
|
|
13178
|
-
}
|
|
13179
|
-
}
|
|
13221
|
+
var index = this._getSunLightIndex();
|
|
13222
|
+
// -1 means no sun light, 0 means the first direct light already is sun light
|
|
13223
|
+
if (index > 0) {
|
|
13224
|
+
var firstLight = directLights.get(0);
|
|
13225
|
+
var sunLight = directLights.get(index);
|
|
13226
|
+
directLights.set(0, sunLight);
|
|
13227
|
+
directLights.set(index, firstLight);
|
|
13228
|
+
sunLight._lightIndex = 0;
|
|
13229
|
+
firstLight._lightIndex = index;
|
|
13180
13230
|
}
|
|
13181
|
-
return sunLightIndex;
|
|
13182
13231
|
};
|
|
13183
13232
|
/**
|
|
13184
13233
|
* @internal
|
|
@@ -13227,6 +13276,32 @@
|
|
|
13227
13276
|
this._pointLights.garbageCollection();
|
|
13228
13277
|
this._directLights.garbageCollection();
|
|
13229
13278
|
};
|
|
13279
|
+
_proto._getSunLightIndex = function _getSunLightIndex() {
|
|
13280
|
+
var directLights = this._directLights;
|
|
13281
|
+
var sunLightIndex = -1;
|
|
13282
|
+
var maxIntensity = Number.NEGATIVE_INFINITY;
|
|
13283
|
+
var hasShadowLight = false;
|
|
13284
|
+
for(var i = 0, n = directLights.length; i < n; i++){
|
|
13285
|
+
var directLight = directLights.get(i);
|
|
13286
|
+
if (directLight.shadowType !== exports.ShadowType.None && !hasShadowLight) {
|
|
13287
|
+
maxIntensity = Number.NEGATIVE_INFINITY;
|
|
13288
|
+
hasShadowLight = true;
|
|
13289
|
+
}
|
|
13290
|
+
var intensity = directLight.intensity * directLight.color.getBrightness();
|
|
13291
|
+
if (hasShadowLight) {
|
|
13292
|
+
if (directLight.shadowType !== exports.ShadowType.None && maxIntensity < intensity) {
|
|
13293
|
+
maxIntensity = intensity;
|
|
13294
|
+
sunLightIndex = i;
|
|
13295
|
+
}
|
|
13296
|
+
} else {
|
|
13297
|
+
if (maxIntensity < intensity) {
|
|
13298
|
+
maxIntensity = intensity;
|
|
13299
|
+
sunLightIndex = i;
|
|
13300
|
+
}
|
|
13301
|
+
}
|
|
13302
|
+
}
|
|
13303
|
+
return sunLightIndex;
|
|
13304
|
+
};
|
|
13230
13305
|
return LightManager;
|
|
13231
13306
|
}();
|
|
13232
13307
|
/**
|
|
@@ -14383,7 +14458,7 @@
|
|
|
14383
14458
|
var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n"; // eslint-disable-line
|
|
14384
14459
|
var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;"; // eslint-disable-line
|
|
14385
14460
|
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n"; // eslint-disable-line
|
|
14386
|
-
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap()
|
|
14461
|
+
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i]))continue;pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i]))continue;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
|
|
14387
14462
|
var noise_cellular = "#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n"; // eslint-disable-line
|
|
14388
14463
|
var noise_cellular_2D = "#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}"; // eslint-disable-line
|
|
14389
14464
|
var noise_cellular_2x2 = "#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}"; // eslint-disable-line
|
|
@@ -14403,7 +14478,7 @@
|
|
|
14403
14478
|
var pbr_frag_define = "#define GLSLIFY 1\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
|
|
14404
14479
|
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(F0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
14405
14480
|
var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
|
|
14406
|
-
var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap()
|
|
14481
|
+
var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i]))continue;pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i]))continue;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}\n#endif\n}"; // eslint-disable-line
|
|
14407
14482
|
var ibl_frag_define = "#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}"; // eslint-disable-line
|
|
14408
14483
|
var pbr_frag = "#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"; // eslint-disable-line
|
|
14409
14484
|
var PBRShaderLib = {
|
|
@@ -20617,20 +20692,25 @@
|
|
|
20617
20692
|
})(exports.DiffuseMode || (exports.DiffuseMode = {}));
|
|
20618
20693
|
/**
|
|
20619
20694
|
* Ambient light.
|
|
20620
|
-
*/ var AmbientLight = /*#__PURE__*/ function() {
|
|
20621
|
-
var AmbientLight = function AmbientLight() {
|
|
20622
|
-
|
|
20623
|
-
|
|
20624
|
-
|
|
20625
|
-
|
|
20626
|
-
|
|
20627
|
-
|
|
20628
|
-
|
|
20695
|
+
*/ var AmbientLight = /*#__PURE__*/ function(ReferResource) {
|
|
20696
|
+
var AmbientLight = function AmbientLight(engine) {
|
|
20697
|
+
var _this;
|
|
20698
|
+
_this = ReferResource.call(this, engine) || this;
|
|
20699
|
+
_this._diffuseSolidColor = new Color$1(0.212, 0.227, 0.259);
|
|
20700
|
+
_this._diffuseIntensity = 1.0;
|
|
20701
|
+
_this._specularIntensity = 1.0;
|
|
20702
|
+
_this._diffuseMode = exports.DiffuseMode.SolidColor;
|
|
20703
|
+
_this._shArray = new Float32Array(27);
|
|
20704
|
+
_this._scenes = [];
|
|
20705
|
+
_this._specularTextureDecodeRGBM = false;
|
|
20706
|
+
return _this;
|
|
20629
20707
|
};
|
|
20708
|
+
_inherits$2(AmbientLight, ReferResource);
|
|
20630
20709
|
var _proto = AmbientLight.prototype;
|
|
20631
20710
|
/**
|
|
20632
20711
|
* @internal
|
|
20633
20712
|
*/ _proto._addToScene = function _addToScene(scene) {
|
|
20713
|
+
this._addReferCount(1);
|
|
20634
20714
|
this._scenes.push(scene);
|
|
20635
20715
|
var shaderData = scene.shaderData;
|
|
20636
20716
|
shaderData.setColor(AmbientLight._diffuseColorProperty, this._diffuseSolidColor);
|
|
@@ -20644,9 +20724,13 @@
|
|
|
20644
20724
|
/**
|
|
20645
20725
|
* @internal
|
|
20646
20726
|
*/ _proto._removeFromScene = function _removeFromScene(scene) {
|
|
20727
|
+
this._addReferCount(-1);
|
|
20647
20728
|
var scenes = this._scenes;
|
|
20648
20729
|
var index = scenes.indexOf(scene);
|
|
20649
20730
|
scenes.splice(index, 1);
|
|
20731
|
+
var shaderData = scene.shaderData;
|
|
20732
|
+
shaderData.setTexture(AmbientLight._specularTextureProperty, null);
|
|
20733
|
+
shaderData.disableMacro(AmbientLight._specularMacro);
|
|
20650
20734
|
};
|
|
20651
20735
|
_proto._setDiffuseMode = function _setDiffuseMode(sceneShaderData) {
|
|
20652
20736
|
if (this._diffuseMode === exports.DiffuseMode.SphericalHarmonics) {
|
|
@@ -20834,7 +20918,7 @@
|
|
|
20834
20918
|
}
|
|
20835
20919
|
]);
|
|
20836
20920
|
return AmbientLight;
|
|
20837
|
-
}();
|
|
20921
|
+
}(ReferResource);
|
|
20838
20922
|
(function() {
|
|
20839
20923
|
AmbientLight._shMacro = ShaderMacro.getByName("SCENE_USE_SH");
|
|
20840
20924
|
})();
|
|
@@ -20890,7 +20974,7 @@
|
|
|
20890
20974
|
_this.name = name || "";
|
|
20891
20975
|
var shaderData = _this.shaderData;
|
|
20892
20976
|
shaderData._addReferCount(1);
|
|
20893
|
-
_this.ambientLight = new AmbientLight();
|
|
20977
|
+
_this.ambientLight = new AmbientLight(engine);
|
|
20894
20978
|
engine.sceneManager._allScenes.push(_assert_this_initialized(_this));
|
|
20895
20979
|
shaderData.enableMacro("SCENE_FOG_MODE", _this._fogMode.toString());
|
|
20896
20980
|
shaderData.enableMacro("SCENE_SHADOW_CASCADED_COUNT", _this.shadowCascades.toString());
|
|
@@ -20998,6 +21082,7 @@
|
|
|
20998
21082
|
if (this._destroyed) {
|
|
20999
21083
|
return;
|
|
21000
21084
|
}
|
|
21085
|
+
EngineObject.prototype.destroy.call(this);
|
|
21001
21086
|
this._destroy();
|
|
21002
21087
|
var allScenes = this.engine.sceneManager._allScenes;
|
|
21003
21088
|
allScenes.splice(allScenes.indexOf(this), 1);
|
|
@@ -21040,9 +21125,9 @@
|
|
|
21040
21125
|
var lightManager = engine._lightManager;
|
|
21041
21126
|
engine.time._updateSceneShaderData(shaderData);
|
|
21042
21127
|
lightManager._updateShaderData(this.shaderData);
|
|
21043
|
-
|
|
21044
|
-
if (
|
|
21045
|
-
var sunlight = lightManager._directLights.get(
|
|
21128
|
+
lightManager._updateSunLightIndex();
|
|
21129
|
+
if (lightManager._directLights.length > 0) {
|
|
21130
|
+
var sunlight = lightManager._directLights.get(0);
|
|
21046
21131
|
shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
|
|
21047
21132
|
shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
|
|
21048
21133
|
this._sunLight = sunlight;
|
|
@@ -21077,6 +21162,7 @@
|
|
|
21077
21162
|
}
|
|
21078
21163
|
this._activeCameras.length = 0;
|
|
21079
21164
|
this.background.destroy();
|
|
21165
|
+
this._ambientLight && this._ambientLight._removeFromScene(this);
|
|
21080
21166
|
this.shaderData._addReferCount(-1);
|
|
21081
21167
|
};
|
|
21082
21168
|
_proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
|
|
@@ -21303,10 +21389,9 @@
|
|
|
21303
21389
|
* @internal
|
|
21304
21390
|
*/ _proto._destroyAllScene = function _destroyAllScene() {
|
|
21305
21391
|
var allScenes = this._allScenes;
|
|
21306
|
-
|
|
21307
|
-
allScenes[
|
|
21392
|
+
while(allScenes[0]){
|
|
21393
|
+
allScenes[0].destroy();
|
|
21308
21394
|
}
|
|
21309
|
-
allScenes.length = 0;
|
|
21310
21395
|
};
|
|
21311
21396
|
_create_class$3(SceneManager, [
|
|
21312
21397
|
{
|
|
@@ -23048,9 +23133,8 @@
|
|
|
23048
23133
|
var lightUp = this._lightUp;
|
|
23049
23134
|
var lightSide = this._lightSide;
|
|
23050
23135
|
var lightForward = shadowSliceData.virtualCamera.forward;
|
|
23051
|
-
var
|
|
23052
|
-
if (
|
|
23053
|
-
var light = camera.scene._sunLight;
|
|
23136
|
+
var light = camera.scene._sunLight;
|
|
23137
|
+
if (light) {
|
|
23054
23138
|
var shadowFar = Math.min(camera.scene.shadowDistance, camera.farClipPlane);
|
|
23055
23139
|
this._getCascadesSplitDistance(shadowFar);
|
|
23056
23140
|
// prepare render target
|
|
@@ -23063,7 +23147,7 @@
|
|
|
23063
23147
|
rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, CascadedShadowCasterPass._clearColor);
|
|
23064
23148
|
}
|
|
23065
23149
|
this._shadowInfos.x = light.shadowStrength;
|
|
23066
|
-
this._shadowInfos.z =
|
|
23150
|
+
this._shadowInfos.z = 0; // @todo: sun light index always 0
|
|
23067
23151
|
// prepare light and camera direction
|
|
23068
23152
|
Matrix.rotationQuaternion(light.entity.transform.worldRotationQuaternion, lightWorld);
|
|
23069
23153
|
lightSide.set(lightWorldE[0], lightWorldE[1], lightWorldE[2]);
|
|
@@ -25376,6 +25460,15 @@
|
|
|
25376
25460
|
_this._dirtyUpdateFlag = 0x7;
|
|
25377
25461
|
/** @internal */ _this._updateFlagManager = new UpdateFlagManager();
|
|
25378
25462
|
_this._texture = texture;
|
|
25463
|
+
_this._onRegionChange = _this._onRegionChange.bind(_assert_this_initialized(_this));
|
|
25464
|
+
_this._onPivotChange = _this._onPivotChange.bind(_assert_this_initialized(_this));
|
|
25465
|
+
_this._onBorderChange = _this._onBorderChange.bind(_assert_this_initialized(_this));
|
|
25466
|
+
// @ts-ignore
|
|
25467
|
+
_this._region._onValueChanged = _this._onRegionChange;
|
|
25468
|
+
// @ts-ignore
|
|
25469
|
+
_this._pivot._onValueChanged = _this._onPivotChange;
|
|
25470
|
+
// @ts-ignore
|
|
25471
|
+
_this._border._onValueChanged = _this._onBorderChange;
|
|
25379
25472
|
region && _this._region.copyFrom(region);
|
|
25380
25473
|
pivot && _this._pivot.copyFrom(pivot);
|
|
25381
25474
|
border && _this._border.copyFrom(border);
|
|
@@ -25516,6 +25609,34 @@
|
|
|
25516
25609
|
}
|
|
25517
25610
|
this._updateFlagManager.dispatch(type);
|
|
25518
25611
|
};
|
|
25612
|
+
_proto._onRegionChange = function _onRegionChange() {
|
|
25613
|
+
var _this = this, region = _this._region;
|
|
25614
|
+
// @ts-ignore
|
|
25615
|
+
region._onValueChanged = null;
|
|
25616
|
+
var x = MathUtil$1.clamp(region.x, 0, 1);
|
|
25617
|
+
var y = MathUtil$1.clamp(region.y, 0, 1);
|
|
25618
|
+
region.set(x, y, MathUtil$1.clamp(region.width, 0, 1 - x), MathUtil$1.clamp(region.height, 0, 1 - y));
|
|
25619
|
+
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
25620
|
+
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
25621
|
+
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
25622
|
+
}
|
|
25623
|
+
// @ts-ignore
|
|
25624
|
+
region._onValueChanged = this._onRegionChange;
|
|
25625
|
+
};
|
|
25626
|
+
_proto._onPivotChange = function _onPivotChange() {
|
|
25627
|
+
this._dispatchSpriteChange(SpriteModifyFlags.pivot);
|
|
25628
|
+
};
|
|
25629
|
+
_proto._onBorderChange = function _onBorderChange() {
|
|
25630
|
+
var _this = this, border = _this._border;
|
|
25631
|
+
// @ts-ignore
|
|
25632
|
+
border._onValueChanged = null;
|
|
25633
|
+
var x = MathUtil$1.clamp(border.x, 0, 1);
|
|
25634
|
+
var y = MathUtil$1.clamp(border.y, 0, 1);
|
|
25635
|
+
border.set(x, y, MathUtil$1.clamp(border.z, 0, 1 - x), MathUtil$1.clamp(border.w, 0, 1 - y));
|
|
25636
|
+
this._dispatchSpriteChange(SpriteModifyFlags.border);
|
|
25637
|
+
// @ts-ignore
|
|
25638
|
+
border._onValueChanged = this._onBorderChange;
|
|
25639
|
+
};
|
|
25519
25640
|
_create_class$3(Sprite, [
|
|
25520
25641
|
{
|
|
25521
25642
|
key: "texture",
|
|
@@ -25635,14 +25756,7 @@
|
|
|
25635
25756
|
return this._region;
|
|
25636
25757
|
},
|
|
25637
25758
|
set: function set(value) {
|
|
25638
|
-
|
|
25639
|
-
var x = MathUtil$1.clamp(value.x, 0, 1);
|
|
25640
|
-
var y = MathUtil$1.clamp(value.y, 0, 1);
|
|
25641
|
-
region.set(x, y, MathUtil$1.clamp(value.width, 0, 1 - x), MathUtil$1.clamp(value.height, 0, 1 - y));
|
|
25642
|
-
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
25643
|
-
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
25644
|
-
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
25645
|
-
}
|
|
25759
|
+
this._region !== value && this._region.copyFrom(value);
|
|
25646
25760
|
}
|
|
25647
25761
|
},
|
|
25648
25762
|
{
|
|
@@ -25654,16 +25768,7 @@
|
|
|
25654
25768
|
return this._pivot;
|
|
25655
25769
|
},
|
|
25656
25770
|
set: function set(value) {
|
|
25657
|
-
|
|
25658
|
-
if (pivot === value) {
|
|
25659
|
-
this._dispatchSpriteChange(SpriteModifyFlags.pivot);
|
|
25660
|
-
} else {
|
|
25661
|
-
var x = value.x, y = value.y;
|
|
25662
|
-
if (pivot.x !== x || pivot.y !== y) {
|
|
25663
|
-
pivot.set(x, y);
|
|
25664
|
-
this._dispatchSpriteChange(SpriteModifyFlags.pivot);
|
|
25665
|
-
}
|
|
25666
|
-
}
|
|
25771
|
+
this._pivot !== value && this._pivot.copyFrom(value);
|
|
25667
25772
|
}
|
|
25668
25773
|
},
|
|
25669
25774
|
{
|
|
@@ -25678,11 +25783,7 @@
|
|
|
25678
25783
|
return this._border;
|
|
25679
25784
|
},
|
|
25680
25785
|
set: function set(value) {
|
|
25681
|
-
|
|
25682
|
-
var x = MathUtil$1.clamp(value.x, 0, 1);
|
|
25683
|
-
var y = MathUtil$1.clamp(value.y, 0, 1);
|
|
25684
|
-
border.set(x, y, MathUtil$1.clamp(value.z, 0, 1 - x), MathUtil$1.clamp(value.w, 0, 1 - y));
|
|
25685
|
-
this._dispatchSpriteChange(SpriteModifyFlags.border);
|
|
25786
|
+
this._border !== value && this._border.copyFrom(value);
|
|
25686
25787
|
}
|
|
25687
25788
|
}
|
|
25688
25789
|
]);
|
|
@@ -33728,7 +33829,8 @@
|
|
|
33728
33829
|
var shArray = new Float32Array(arraybuffer, 0, 27);
|
|
33729
33830
|
var shByteLength = 27 * 4;
|
|
33730
33831
|
var size = (_ref = new Uint16Array(arraybuffer, shByteLength, 1)) == null ? void 0 : _ref[0];
|
|
33731
|
-
var
|
|
33832
|
+
var engine = resourceManager.engine;
|
|
33833
|
+
var texture = new TextureCube(engine, size);
|
|
33732
33834
|
texture.filterMode = exports.TextureFilterMode.Trilinear;
|
|
33733
33835
|
var mipmapCount = texture.mipmapCount;
|
|
33734
33836
|
var offset = shByteLength + 2;
|
|
@@ -33741,7 +33843,7 @@
|
|
|
33741
33843
|
texture.setPixelBuffer(exports.TextureCubeFace.PositiveX + face, data, mipLevel);
|
|
33742
33844
|
}
|
|
33743
33845
|
}
|
|
33744
|
-
var ambientLight = new AmbientLight();
|
|
33846
|
+
var ambientLight = new AmbientLight(engine);
|
|
33745
33847
|
var sh = new SphericalHarmonics3();
|
|
33746
33848
|
ambientLight.diffuseMode = exports.DiffuseMode.SphericalHarmonics;
|
|
33747
33849
|
sh.copyFromArray(shArray);
|
|
@@ -38303,7 +38405,7 @@
|
|
|
38303
38405
|
], GALACEAN_animation_event);
|
|
38304
38406
|
|
|
38305
38407
|
//@ts-ignore
|
|
38306
|
-
var version = "1.0.0-beta.
|
|
38408
|
+
var version = "1.0.0-beta.16";
|
|
38307
38409
|
console.log("Galacean engine version: " + version);
|
|
38308
38410
|
for(var key in CoreObjects){
|
|
38309
38411
|
Loader.registerClass(key, CoreObjects[key]);
|