@galacean/engine-core 0.0.0-experimental-2.0-game.2 → 0.0.0-experimental-2.0-game.3
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/main.js +224 -619
- package/dist/main.js.map +1 -1
- package/dist/module.js +225 -619
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/asset/AssetType.d.ts +4 -2
- package/types/audio/AudioManager.d.ts +4 -1
- package/types/audio/AudioSource.d.ts +1 -0
- package/types/particle/ParticleGenerator.d.ts +0 -3
- package/types/particle/enums/ParticleScaleMode.d.ts +5 -5
- package/types/particle/index.d.ts +0 -1
- package/types/particle/modules/Burst.d.ts +1 -21
- package/types/particle/modules/shape/BaseShape.d.ts +0 -30
- package/types/particle/modules/shape/BoxShape.d.ts +1 -0
- package/types/particle/modules/shape/CircleShape.d.ts +1 -0
- package/types/particle/modules/shape/ConeShape.d.ts +4 -0
- package/types/shaderlib/ShaderLib.d.ts +14 -1
- package/types/shaderlib/particle/index.d.ts +0 -1
- package/types/particle/modules/NoiseModule.d.ts +0 -90
package/dist/main.js
CHANGED
|
@@ -1400,12 +1400,6 @@ SystemInfo._initialize();
|
|
|
1400
1400
|
case TextureFormat.ETC2_RGB:
|
|
1401
1401
|
case TextureFormat.ETC2_RGBA8:
|
|
1402
1402
|
case TextureFormat.ASTC_4x4:
|
|
1403
|
-
case TextureFormat.ASTC_5x5:
|
|
1404
|
-
case TextureFormat.ASTC_6x6:
|
|
1405
|
-
case TextureFormat.ASTC_8x8:
|
|
1406
|
-
case TextureFormat.ASTC_10x10:
|
|
1407
|
-
case TextureFormat.ASTC_12x12:
|
|
1408
|
-
case TextureFormat.ETC2_RGBA5:
|
|
1409
1403
|
return true;
|
|
1410
1404
|
default:
|
|
1411
1405
|
return false;
|
|
@@ -1944,7 +1938,7 @@ SystemInfo._initialize();
|
|
|
1944
1938
|
_this = ReferResource.call(this, engine) || this, _this._charInfoMap = {}, _this._space = 1, _this._curX = 1, _this._curY = 1, _this._nextY = 1;
|
|
1945
1939
|
_this.isGCIgnored = true;
|
|
1946
1940
|
var format = engine._hardwareRenderer.isWebGL2 ? TextureFormat.R8 : TextureFormat.Alpha8;
|
|
1947
|
-
var texture = new Texture2D(engine, 512, 512, format, false
|
|
1941
|
+
var texture = new Texture2D(engine, 512, 512, format, false);
|
|
1948
1942
|
texture.filterMode = TextureFilterMode.Bilinear;
|
|
1949
1943
|
texture.isGCIgnored = true;
|
|
1950
1944
|
_this.texture = texture;
|
|
@@ -4458,7 +4452,7 @@ exports.TiledSpriteAssembler = __decorate([
|
|
|
4458
4452
|
sprite.name === name && outSprites.push(sprite);
|
|
4459
4453
|
}
|
|
4460
4454
|
} else {
|
|
4461
|
-
console.warn("
|
|
4455
|
+
console.warn("There is no sprite named " + name + " in the atlas.");
|
|
4462
4456
|
}
|
|
4463
4457
|
return outSprites;
|
|
4464
4458
|
};
|
|
@@ -5437,9 +5431,37 @@ var begin_viewdir_frag = "#ifdef CAMERA_ORTHOGRAPHIC\n vec3 V = -camera_Forwa
|
|
|
5437
5431
|
|
|
5438
5432
|
var mobile_blinnphong_frag = " #ifdef MATERIAL_HAS_NORMALTEXTURE\n mat3 tbn = getTBN(gl_FrontFacing);\n vec3 N = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v_uv, gl_FrontFacing);\n #else\n vec3 N = getNormal(gl_FrontFacing);\n #endif\n\n vec3 lightDiffuse = vec3( 0.0, 0.0, 0.0 );\n vec3 lightSpecular = vec3( 0.0, 0.0, 0.0 );\n float shadowAttenuation = 1.0;\n\n #ifdef SCENE_DIRECT_LIGHT_COUNT\n shadowAttenuation = 1.0;\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n shadowAttenuation *= sampleShadowMap();\n #endif\n\n DirectLight directionalLight;\n for( int i = 0; i < SCENE_DIRECT_LIGHT_COUNT; i++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_DirectLightCullingMask[i])){\n directionalLight.color = scene_DirectLightColor[i];\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n if (i == 0) { // Sun light index is always 0\n directionalLight.color *= shadowAttenuation;\n }\n #endif\n directionalLight.direction = scene_DirectLightDirection[i];\n \n float d = max(dot(N, -directionalLight.direction), 0.0);\n lightDiffuse += directionalLight.color * d;\n \n vec3 halfDir = normalize( V - directionalLight.direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess );\n lightSpecular += directionalLight.color * s;\n }\n }\n\n #endif\n\n #ifdef SCENE_POINT_LIGHT_COUNT\n PointLight pointLight;\n for( int i = 0; i < SCENE_POINT_LIGHT_COUNT; i++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_PointLightCullingMask[i])){\n pointLight.color = scene_PointLightColor[i];\n pointLight.position = scene_PointLightPosition[i];\n pointLight.distance = scene_PointLightDistance[i];\n\n vec3 direction = v_pos - pointLight.position;\n float dist = length( direction );\n direction /= dist;\n float decay = clamp(1.0 - pow(dist / pointLight.distance, 4.0), 0.0, 1.0);\n\n float d = max( dot( N, -direction ), 0.0 ) * decay;\n lightDiffuse += pointLight.color * d;\n\n vec3 halfDir = normalize( V - direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess ) * decay;\n lightSpecular += pointLight.color * s;\n }\n }\n\n #endif\n\n #ifdef SCENE_SPOT_LIGHT_COUNT\n SpotLight spotLight;\n for( int i = 0; i < SCENE_SPOT_LIGHT_COUNT; i++) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_SpotLightCullingMask[i])){\n spotLight.color = scene_SpotLightColor[i];\n spotLight.position = scene_SpotLightPosition[i];\n spotLight.direction = scene_SpotLightDirection[i];\n spotLight.distance = scene_SpotLightDistance[i];\n spotLight.angleCos = scene_SpotLightAngleCos[i];\n spotLight.penumbraCos = scene_SpotLightPenumbraCos[i];\n\n vec3 direction = spotLight.position - v_pos;\n float lightDistance = length( direction );\n direction /= lightDistance;\n float angleCos = dot( direction, -spotLight.direction );\n float decay = clamp(1.0 - pow(lightDistance/spotLight.distance, 4.0), 0.0, 1.0);\n float spotEffect = smoothstep( spotLight.penumbraCos, spotLight.angleCos, angleCos );\n float decayTotal = decay * spotEffect;\n float d = max( dot( N, direction ), 0.0 ) * decayTotal;\n lightDiffuse += spotLight.color * d;\n\n vec3 halfDir = normalize( V + direction );\n float s = pow( clamp( dot( N, halfDir ), 0.0, 1.0 ), material_Shininess ) * decayTotal;\n lightSpecular += spotLight.color * s;\n }\n }\n\n #endif\n\n diffuse *= vec4( lightDiffuse, 1.0 );\n specular *= vec4( lightSpecular, 1.0 );\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( diffuse.a < material_AlphaCutoff ) {\n discard;\n }\n #endif\n"; // eslint-disable-line
|
|
5439
5433
|
|
|
5440
|
-
var
|
|
5434
|
+
var noise_cellular = "#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n"; // eslint-disable-line
|
|
5435
|
+
|
|
5436
|
+
var noise_cellular_2D = "\n// Cellular noise (\"Worley noise\") in 2D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Standard 3x3 search window for good F1 and F2 values\nvec2 cellular( vec2 P ) {\n\n\tvec2 Pi = mod289( floor( P ) );\n \tvec2 Pf = fract( P );\n\tvec3 oi = vec3( -1.0, 0.0, 1.0);\n\tvec3 of = vec3( -0.5, 0.5, 1.5);\n\tvec3 px = permute( Pi.x + oi );\n\tvec3 p = permute( px.x + Pi.y + oi ); // p11, p12, p13\n\tvec3 ox = fract( p * K ) - Ko;\n\tvec3 oy = mod7( floor( p * K ) ) * K - Ko;\n\tvec3 dx = Pf.x + 0.5 + jitter * ox;\n\tvec3 dy = Pf.y - of + jitter * oy;\n\tvec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared\n\tp = permute( px.y + Pi.y + oi ); // p21, p22, p23\n\tox = fract( p * K ) - Ko;\n\toy = mod7( floor( p * K ) ) * K - Ko;\n\tdx = Pf.x - 0.5 + jitter * ox;\n\tdy = Pf.y - of + jitter * oy;\n\tvec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared\n\tp = permute( px.z + Pi.y + oi ); // p31, p32, p33\n\tox = fract( p * K ) - Ko;\n\toy = mod7( floor( p * K ) ) * K - Ko;\n\tdx = Pf.x - 1.5 + jitter * ox;\n\tdy = Pf.y - of + jitter * oy;\n\tvec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared\n\t// Sort out the two smallest distances (F1, F2)\n\tvec3 d1a = min( d1, d2 );\n\td2 = max( d1, d2 ); // Swap to keep candidates for F2\n\td2 = min( d2, d3 ); // neither F1 nor F2 are now in d3\n\td1 = min( d1a, d2 ); // F1 is now in d1\n\td2 = max( d1a, d2 ); // Swap to keep candidates for F2\n\td1.xy = ( d1.x < d1.y ) ? d1.xy : d1.yx; // Swap if smaller\n\td1.xz = ( d1.x < d1.z ) ? d1.xz : d1.zx; // F1 is in d1.x\n\td1.yz = min( d1.yz, d2.yz ); // F2 is now not in d2.yz\n\td1.y = min( d1.y, d1.z ); // nor in d1.z\n\td1.y = min( d1.y, d2.x ); // F2 is in d1.y, we're done.\n\treturn sqrt( d1.xy );\n\n}\n"; // eslint-disable-line
|
|
5437
|
+
|
|
5438
|
+
var noise_cellular_2x2 = "\n// Cellular noise (\"Worley noise\") in 2D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Speeded up by using 2x2 search window instead of 3x3,\n// at the expense of some strong pattern artifacts.\n// F2 is often wrong and has sharp discontinuities.\n// If you need a smooth F2, use the slower 3x3 version.\n// F1 is sometimes wrong, too, but OK for most purposes.\nvec2 cellular2x2( vec2 P ) {\n\n\tvec2 Pi = mod289( floor( P ) );\n \tvec2 Pf = fract( P );\n\tvec4 Pfx = Pf.x + vec4( -0.5, -1.5, -0.5, -1.5 );\n\tvec4 Pfy = Pf.y + vec4( -0.5, -0.5, -1.5, -1.5 );\n\tvec4 p = permute( Pi.x + vec4( 0.0, 1.0, 0.0, 1.0 ) );\n\tp = permute( p + Pi.y + vec4( 0.0, 0.0, 1.0, 1.0 ) );\n\tvec4 ox = mod7( p ) * K + Kd2;\n\tvec4 oy = mod7( floor( p * K ) ) * K + Kd2;\n\tvec4 dx = Pfx + jitter1 * ox;\n\tvec4 dy = Pfy + jitter1 * oy;\n\tvec4 d = dx * dx + dy * dy; // d11, d12, d21 and d22, squared\n\n\t// Do it right and find both F1 and F2\n\td.xy = ( d.x < d.y ) ? d.xy : d.yx; // Swap if smaller\n\td.xz = ( d.x < d.z ) ? d.xz : d.zx;\n\td.xw = ( d.x < d.w ) ? d.xw : d.wx;\n\td.y = min( d.y, d.z );\n\td.y = min( d.y, d.w );\n\treturn sqrt( d.xy );\n\n}\n"; // eslint-disable-line
|
|
5439
|
+
|
|
5440
|
+
var noise_cellular_2x2x2 = "\n// Cellular noise (\"Worley noise\") in 3D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// Speeded up by using 2x2x2 search window instead of 3x3x3,\n// at the expense of some pattern artifacts.\n// F2 is often wrong and has sharp discontinuities.\n// If you need a good F2, use the slower 3x3x3 version.\nvec2 cellular2x2x2(vec3 P) {\n\n\tvec3 Pi = mod289( floor( P ) );\n \tvec3 Pf = fract( P );\n\tvec4 Pfx = Pf.x + vec4( 0.0, -1.0, 0.0, -1.0 );\n\tvec4 Pfy = Pf.y + vec4( 0.0, 0.0, -1.0, -1.0 );\n\tvec4 p = permute( Pi.x + vec4( 0.0, 1.0, 0.0, 1.0 ) );\n\tp = permute( p + Pi.y + vec4( 0.0, 0.0, 1.0, 1.0 ) );\n\tvec4 p1 = permute( p + Pi.z ); // z+0\n\tvec4 p2 = permute( p + Pi.z + vec4( 1.0 ) ); // z+1\n\tvec4 ox1 = fract( p1 * K ) - Ko;\n\tvec4 oy1 = mod7( floor( p1 * K ) ) * K - Ko;\n\tvec4 oz1 = floor( p1 * K2 ) * Kz - Kzo; // p1 < 289 guaranteed\n\tvec4 ox2 = fract( p2 * K ) - Ko;\n\tvec4 oy2 = mod7( floor( p2 * K ) ) * K - Ko;\n\tvec4 oz2 = floor( p2 * K2 ) * Kz - Kzo;\n\tvec4 dx1 = Pfx + jitter1 * ox1;\n\tvec4 dy1 = Pfy + jitter1 * oy1;\n\tvec4 dz1 = Pf.z + jitter1 * oz1;\n\tvec4 dx2 = Pfx + jitter1 * ox2;\n\tvec4 dy2 = Pfy + jitter1 * oy2;\n\tvec4 dz2 = Pf.z - 1.0 + jitter1 * oz2;\n\tvec4 d1 = dx1 * dx1 + dy1 * dy1 + dz1 * dz1; // z+0\n\tvec4 d2 = dx2 * dx2 + dy2 * dy2 + dz2 * dz2; // z+1\n\n\t// Do it right and sort out both F1 and F2\n\tvec4 d = min( d1, d2 ); // F1 is now in d\n\td2 = max( d1, d2 ); // Make sure we keep all candidates for F2\n\td.xy = ( d.x < d.y ) ? d.xy : d.yx; // Swap smallest to d.x\n\td.xz = ( d.x < d.z ) ? d.xz : d.zx;\n\td.xw = ( d.x < d.w ) ? d.xw : d.wx; // F1 is now in d.x\n\td.yzw = min( d.yzw, d2.yzw ); // F2 now not in d2.yzw\n\td.y = min( d.y, d.z ); // nor in d.z\n\td.y = min( d.y, d.w ); // nor in d.w\n\td.y = min( d.y, d2.x ); // F2 is now in d.y\n\treturn sqrt( d.xy ); // F1 and F2\n\n}\n"; // eslint-disable-line
|
|
5441
|
+
|
|
5442
|
+
var noise_cellular_3D = "\n// Cellular noise (\"Worley noise\") in 3D in GLSL.\n// Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.\n// This code is released under the conditions of the MIT license.\n// See LICENSE file for details.\n// https://github.com/stegu/webgl-noise\n\n// Cellular noise, returning F1 and F2 in a vec2.\n// 3x3x3 search region for good F2 everywhere, but a lot\n// slower than the 2x2x2 version.\n// The code below is a bit scary even to its author,\n// but it has at least half decent performance on a\n// modern GPU. In any case, it beats any software\n// implementation of Worley noise hands down.\n\nvec2 cellular( vec3 P ) {\n\n\tvec3 Pi = mod289( floor( P ) );\n \tvec3 Pf = fract( P ) - 0.5;\n\n\tvec3 Pfx = Pf.x + vec3( 1.0, 0.0, -1.0 );\n\tvec3 Pfy = Pf.y + vec3( 1.0, 0.0, -1.0 );\n\tvec3 Pfz = Pf.z + vec3( 1.0, 0.0, -1.0 );\n\n\tvec3 p = permute( Pi.x + vec3( -1.0, 0.0, 1.0 ) );\n\tvec3 p1 = permute( p + Pi.y - 1.0 );\n\tvec3 p2 = permute( p + Pi.y );\n\tvec3 p3 = permute( p + Pi.y + 1.0 );\n\n\tvec3 p11 = permute( p1 + Pi.z - 1.0 );\n\tvec3 p12 = permute( p1 + Pi.z );\n\tvec3 p13 = permute( p1 + Pi.z + 1.0 );\n\n\tvec3 p21 = permute( p2 + Pi.z - 1.0 );\n\tvec3 p22 = permute( p2 + Pi.z );\n\tvec3 p23 = permute( p2 + Pi.z + 1.0 );\n\n\tvec3 p31 = permute( p3 + Pi.z - 1.0 );\n\tvec3 p32 = permute( p3 + Pi.z );\n\tvec3 p33 = permute( p3 + Pi.z + 1.0 );\n\n\tvec3 ox11 = fract( p11 * K ) - Ko;\n\tvec3 oy11 = mod7( floor( p11 * K ) ) * K - Ko;\n\tvec3 oz11 = floor( p11 * K2 ) * Kz - Kzo; // p11 < 289 guaranteed\n\n\tvec3 ox12 = fract( p12 * K ) - Ko;\n\tvec3 oy12 = mod7( floor( p12 * K ) ) * K - Ko;\n\tvec3 oz12 = floor( p12 * K2 ) * Kz - Kzo;\n\n\tvec3 ox13 = fract( p13 * K ) - Ko;\n\tvec3 oy13 = mod7( floor( p13 * K ) ) * K - Ko;\n\tvec3 oz13 = floor( p13 * K2 ) * Kz - Kzo;\n\n\tvec3 ox21 = fract( p21 * K ) - Ko;\n\tvec3 oy21 = mod7( floor( p21 * K ) ) * K - Ko;\n\tvec3 oz21 = floor( p21 * K2 ) * Kz - Kzo;\n\n\tvec3 ox22 = fract( p22 * K ) - Ko;\n\tvec3 oy22 = mod7( floor( p22 * K ) ) * K - Ko;\n\tvec3 oz22 = floor( p22 * K2 ) * Kz - Kzo;\n\n\tvec3 ox23 = fract( p23 * K ) - Ko;\n\tvec3 oy23 = mod7( floor( p23 * K ) ) * K - Ko;\n\tvec3 oz23 = floor( p23 * K2 ) * Kz - Kzo;\n\n\tvec3 ox31 = fract( p31 * K ) - Ko;\n\tvec3 oy31 = mod7( floor( p31 * K ) ) * K - Ko;\n\tvec3 oz31 = floor( p31 * K2 ) * Kz - Kzo;\n\n\tvec3 ox32 = fract( p32 * K ) - Ko;\n\tvec3 oy32 = mod7( floor( p32 * K ) ) * K - Ko;\n\tvec3 oz32 = floor( p32 * K2 ) * Kz - Kzo;\n\n\tvec3 ox33 = fract( p33 * K ) - Ko;\n\tvec3 oy33 = mod7( floor( p33 * K ) ) * K - Ko;\n\tvec3 oz33 = floor( p33 * K2 ) * Kz - Kzo;\n\n\tvec3 dx11 = Pfx + jitter * ox11;\n\tvec3 dy11 = Pfy.x + jitter * oy11;\n\tvec3 dz11 = Pfz.x + jitter * oz11;\n\n\tvec3 dx12 = Pfx + jitter * ox12;\n\tvec3 dy12 = Pfy.x + jitter * oy12;\n\tvec3 dz12 = Pfz.y + jitter * oz12;\n\n\tvec3 dx13 = Pfx + jitter * ox13;\n\tvec3 dy13 = Pfy.x + jitter * oy13;\n\tvec3 dz13 = Pfz.z + jitter * oz13;\n\n\tvec3 dx21 = Pfx + jitter * ox21;\n\tvec3 dy21 = Pfy.y + jitter * oy21;\n\tvec3 dz21 = Pfz.x + jitter * oz21;\n\n\tvec3 dx22 = Pfx + jitter * ox22;\n\tvec3 dy22 = Pfy.y + jitter * oy22;\n\tvec3 dz22 = Pfz.y + jitter * oz22;\n\n\tvec3 dx23 = Pfx + jitter * ox23;\n\tvec3 dy23 = Pfy.y + jitter * oy23;\n\tvec3 dz23 = Pfz.z + jitter * oz23;\n\n\tvec3 dx31 = Pfx + jitter * ox31;\n\tvec3 dy31 = Pfy.z + jitter * oy31;\n\tvec3 dz31 = Pfz.x + jitter * oz31;\n\n\tvec3 dx32 = Pfx + jitter * ox32;\n\tvec3 dy32 = Pfy.z + jitter * oy32;\n\tvec3 dz32 = Pfz.y + jitter * oz32;\n\n\tvec3 dx33 = Pfx + jitter * ox33;\n\tvec3 dy33 = Pfy.z + jitter * oy33;\n\tvec3 dz33 = Pfz.z + jitter * oz33;\n\n\tvec3 d11 = dx11 * dx11 + dy11 * dy11 + dz11 * dz11;\n\tvec3 d12 = dx12 * dx12 + dy12 * dy12 + dz12 * dz12;\n\tvec3 d13 = dx13 * dx13 + dy13 * dy13 + dz13 * dz13;\n\tvec3 d21 = dx21 * dx21 + dy21 * dy21 + dz21 * dz21;\n\tvec3 d22 = dx22 * dx22 + dy22 * dy22 + dz22 * dz22;\n\tvec3 d23 = dx23 * dx23 + dy23 * dy23 + dz23 * dz23;\n\tvec3 d31 = dx31 * dx31 + dy31 * dy31 + dz31 * dz31;\n\tvec3 d32 = dx32 * dx32 + dy32 * dy32 + dz32 * dz32;\n\tvec3 d33 = dx33 * dx33 + dy33 * dy33 + dz33 * dz33;\n\n\t// Do it right and sort out both F1 and F2\n\tvec3 d1a = min( d11, d12 );\n\td12 = max( d11, d12 );\n\td11 = min( d1a, d13 ); // Smallest now not in d12 or d13\n\td13 = max( d1a, d13 );\n\td12 = min( d12, d13 ); // 2nd smallest now not in d13\n\tvec3 d2a = min( d21, d22 );\n\td22 = max( d21, d22 );\n\td21 = min( d2a, d23 ); // Smallest now not in d22 or d23\n\td23 = max( d2a, d23 );\n\td22 = min( d22, d23 ); // 2nd smallest now not in d23\n\tvec3 d3a = min( d31, d32 );\n\td32 = max( d31, d32 );\n\td31 = min( d3a, d33 ); // Smallest now not in d32 or d33\n\td33 = max( d3a, d33 );\n\td32 = min( d32, d33 ); // 2nd smallest now not in d33\n\tvec3 da = min( d11, d21 );\n\td21 = max( d11, d21 );\n\td11 = min( da, d31 ); // Smallest now in d11\n\td31 = max( da, d31 ); // 2nd smallest now not in d31\n\td11.xy = ( d11.x < d11.y ) ? d11.xy : d11.yx;\n\td11.xz = ( d11.x < d11.z ) ? d11.xz : d11.zx; // d11.x now smallest\n\td12 = min( d12, d21 ); // 2nd smallest now not in d21\n\td12 = min( d12, d22 ); // nor in d22\n\td12 = min( d12, d31 ); // nor in d31\n\td12 = min( d12, d32 ); // nor in d32\n\td11.yz = min( d11.yz, d12.xy ); // nor in d12.yz\n\td11.y = min( d11.y, d12.z ); // Only two more to go\n\td11.y = min( d11.y, d11.z ); // Done! (Phew! )\n\treturn sqrt( d11.xy ); // F1, F2\n\n}\n"; // eslint-disable-line
|
|
5441
5443
|
|
|
5442
|
-
var
|
|
5444
|
+
var noise_common = "// Modulo 289 without a division (only multiplications)\nvec4 mod289( vec4 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nvec3 mod289( vec3 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nvec2 mod289( vec2 x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\nfloat mod289( float x ) {\n\n return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0;\n\n}\n\n// Modulo 7 without a division\nvec4 mod7( vec4 x ) {\n\n return x - floor( x * ( 1.0 / 7.0 ) ) * 7.0;\n\n}\n\nvec3 mod7( vec3 x ) {\n\n return x - floor( x * ( 1.0 / 7.0 ) ) * 7.0;\n\n}\n\n// Permutation polynomial: (34x^2 + x) mod 289\nvec4 permute( vec4 x ) {\n\n return mod289( ( 34.0 * x + 1.0 ) * x);\n\n}\n\nvec3 permute( vec3 x ) {\n\n return mod289( ( 34.0 * x + 1.0 ) * x );\n\n}\n\nfloat permute( float x ) {\n\n return mod289( ( ( x * 34.0 ) + 1.0 ) * x );\n\n}\n\nvec4 taylorInvSqrt( vec4 r ) {\n\n return 1.79284291400159 - 0.85373472095314 * r;\n\n}\n\nfloat taylorInvSqrt( float r ) {\n\n return 1.79284291400159 - 0.85373472095314 * r;\n\n}\n\nvec4 fade( vec4 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\nvec3 fade( vec3 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\nvec2 fade( vec2 t ) {\n\n return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );\n\n}\n\n#define K 0.142857142857 // 1/7\n#define Ko 0.428571428571 // 1/2-K/2\n#define K2 0.020408163265306 // 1/(7*7)\n#define Kd2 0.0714285714285 // K/2\n#define Kz 0.166666666667 // 1/6\n#define Kzo 0.416666666667 // 1/2-1/6*2\n#define jitter 1.0 // smaller jitter gives more regular pattern\n#define jitter1 0.8 // smaller jitter gives less errors in F1 F2\n"; // eslint-disable-line
|
|
5445
|
+
|
|
5446
|
+
var noise_perlin = "#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n"; // eslint-disable-line
|
|
5447
|
+
|
|
5448
|
+
var noise_perlin_2D = "//\n// GLSL textureless classic 2D noise \"cnoise\",\n// with an RSL-style periodic variant \"pnoise\".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec2 P ) {\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;\n vec4 gy = abs(gx) - 0.5 ;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x,gy.x);\n vec2 g10 = vec2(gx.y,gy.y);\n vec2 g01 = vec2(gx.z,gy.z);\n vec2 g11 = vec2(gx.w,gy.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return 2.3 * n_xy;\n\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin( vec2 P, vec2 rep ) {\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod(Pi, rep.xyxy); // To create noise with explicit period\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;\n vec4 gy = abs(gx) - 0.5 ;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x,gy.x);\n vec2 g10 = vec2(gx.y,gy.y);\n vec2 g01 = vec2(gx.z,gy.z);\n vec2 g11 = vec2(gx.w,gy.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return 2.3 * n_xy;\n\n}\n"; // eslint-disable-line
|
|
5449
|
+
|
|
5450
|
+
var noise_perlin_3D = "//\n// GLSL textureless classic 3D noise \"cnoise\",\n// with an RSL-style periodic variant \"pnoise\".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-10-11\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec3 P ) {\n\n vec3 Pi0 = floor(P); // Integer part for indexing\n vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin( vec3 P, vec3 rep ) {\n\n vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period\n vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n\n}\n"; // eslint-disable-line
|
|
5451
|
+
|
|
5452
|
+
var noise_perlin_4D = "//\n// GLSL textureless classic 4D noise \"cnoise\",\n// with an RSL-style periodic variant \"pnoise\".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Classic Perlin noise\nfloat perlin( vec4 P ) {\n\n vec4 Pi0 = floor(P); // Integer part for indexing\n vec4 Pi1 = Pi0 + 1.0; // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec4 Pf0 = fract(P); // Fractional part for interpolation\n vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = vec4(Pi0.zzzz);\n vec4 iz1 = vec4(Pi1.zzzz);\n vec4 iw0 = vec4(Pi0.wwww);\n vec4 iw1 = vec4(Pi1.wwww);\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n vec4 ixy00 = permute(ixy0 + iw0);\n vec4 ixy01 = permute(ixy0 + iw1);\n vec4 ixy10 = permute(ixy1 + iw0);\n vec4 ixy11 = permute(ixy1 + iw1);\n\n vec4 gx00 = ixy00 * (1.0 / 7.0);\n vec4 gy00 = floor(gx00) * (1.0 / 7.0);\n vec4 gz00 = floor(gy00) * (1.0 / 6.0);\n gx00 = fract(gx00) - 0.5;\n gy00 = fract(gy00) - 0.5;\n gz00 = fract(gz00) - 0.5;\n vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00);\n vec4 sw00 = step(gw00, vec4(0.0));\n gx00 -= sw00 * (step(0.0, gx00) - 0.5);\n gy00 -= sw00 * (step(0.0, gy00) - 0.5);\n\n vec4 gx01 = ixy01 * (1.0 / 7.0);\n vec4 gy01 = floor(gx01) * (1.0 / 7.0);\n vec4 gz01 = floor(gy01) * (1.0 / 6.0);\n gx01 = fract(gx01) - 0.5;\n gy01 = fract(gy01) - 0.5;\n gz01 = fract(gz01) - 0.5;\n vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01);\n vec4 sw01 = step(gw01, vec4(0.0));\n gx01 -= sw01 * (step(0.0, gx01) - 0.5);\n gy01 -= sw01 * (step(0.0, gy01) - 0.5);\n\n vec4 gx10 = ixy10 * (1.0 / 7.0);\n vec4 gy10 = floor(gx10) * (1.0 / 7.0);\n vec4 gz10 = floor(gy10) * (1.0 / 6.0);\n gx10 = fract(gx10) - 0.5;\n gy10 = fract(gy10) - 0.5;\n gz10 = fract(gz10) - 0.5;\n vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10);\n vec4 sw10 = step(gw10, vec4(0.0));\n gx10 -= sw10 * (step(0.0, gx10) - 0.5);\n gy10 -= sw10 * (step(0.0, gy10) - 0.5);\n\n vec4 gx11 = ixy11 * (1.0 / 7.0);\n vec4 gy11 = floor(gx11) * (1.0 / 7.0);\n vec4 gz11 = floor(gy11) * (1.0 / 6.0);\n gx11 = fract(gx11) - 0.5;\n gy11 = fract(gy11) - 0.5;\n gz11 = fract(gz11) - 0.5;\n vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11);\n vec4 sw11 = step(gw11, vec4(0.0));\n gx11 -= sw11 * (step(0.0, gx11) - 0.5);\n gy11 -= sw11 * (step(0.0, gy11) - 0.5);\n\n vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x);\n vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y);\n vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z);\n vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w);\n vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x);\n vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y);\n vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z);\n vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w);\n vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x);\n vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y);\n vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z);\n vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w);\n vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x);\n vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y);\n vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z);\n vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w);\n\n vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));\n g0000 *= norm00.x;\n g0100 *= norm00.y;\n g1000 *= norm00.z;\n g1100 *= norm00.w;\n\n vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));\n g0001 *= norm01.x;\n g0101 *= norm01.y;\n g1001 *= norm01.z;\n g1101 *= norm01.w;\n\n vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));\n g0010 *= norm10.x;\n g0110 *= norm10.y;\n g1010 *= norm10.z;\n g1110 *= norm10.w;\n\n vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));\n g0011 *= norm11.x;\n g0111 *= norm11.y;\n g1011 *= norm11.z;\n g1111 *= norm11.w;\n\n float n0000 = dot(g0000, Pf0);\n float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw));\n float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw));\n float n1100 = dot(g1100, vec4(Pf1.xy, Pf0.zw));\n float n0010 = dot(g0010, vec4(Pf0.xy, Pf1.z, Pf0.w));\n float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w));\n float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz, Pf0.w));\n float n1110 = dot(g1110, vec4(Pf1.xyz, Pf0.w));\n float n0001 = dot(g0001, vec4(Pf0.xyz, Pf1.w));\n float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz, Pf1.w));\n float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w));\n float n1101 = dot(g1101, vec4(Pf1.xy, Pf0.z, Pf1.w));\n float n0011 = dot(g0011, vec4(Pf0.xy, Pf1.zw));\n float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw));\n float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw));\n float n1111 = dot(g1111, Pf1);\n\n vec4 fade_xyzw = fade(Pf0);\n vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w);\n vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w);\n vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z);\n vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y);\n float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);\n return 2.2 * n_xyzw;\n\n}\n\n// Classic Perlin noise, periodic version\nfloat perlin( vec4 P, vec4 rep ) {\n\n vec4 Pi0 = mod(floor(P), rep); // Integer part modulo rep\n vec4 Pi1 = mod(Pi0 + 1.0, rep); // Integer part + 1 mod rep\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec4 Pf0 = fract(P); // Fractional part for interpolation\n vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = vec4(Pi0.zzzz);\n vec4 iz1 = vec4(Pi1.zzzz);\n vec4 iw0 = vec4(Pi0.wwww);\n vec4 iw1 = vec4(Pi1.wwww);\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n vec4 ixy00 = permute(ixy0 + iw0);\n vec4 ixy01 = permute(ixy0 + iw1);\n vec4 ixy10 = permute(ixy1 + iw0);\n vec4 ixy11 = permute(ixy1 + iw1);\n\n vec4 gx00 = ixy00 * (1.0 / 7.0);\n vec4 gy00 = floor(gx00) * (1.0 / 7.0);\n vec4 gz00 = floor(gy00) * (1.0 / 6.0);\n gx00 = fract(gx00) - 0.5;\n gy00 = fract(gy00) - 0.5;\n gz00 = fract(gz00) - 0.5;\n vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00);\n vec4 sw00 = step(gw00, vec4(0.0));\n gx00 -= sw00 * (step(0.0, gx00) - 0.5);\n gy00 -= sw00 * (step(0.0, gy00) - 0.5);\n\n vec4 gx01 = ixy01 * (1.0 / 7.0);\n vec4 gy01 = floor(gx01) * (1.0 / 7.0);\n vec4 gz01 = floor(gy01) * (1.0 / 6.0);\n gx01 = fract(gx01) - 0.5;\n gy01 = fract(gy01) - 0.5;\n gz01 = fract(gz01) - 0.5;\n vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01);\n vec4 sw01 = step(gw01, vec4(0.0));\n gx01 -= sw01 * (step(0.0, gx01) - 0.5);\n gy01 -= sw01 * (step(0.0, gy01) - 0.5);\n\n vec4 gx10 = ixy10 * (1.0 / 7.0);\n vec4 gy10 = floor(gx10) * (1.0 / 7.0);\n vec4 gz10 = floor(gy10) * (1.0 / 6.0);\n gx10 = fract(gx10) - 0.5;\n gy10 = fract(gy10) - 0.5;\n gz10 = fract(gz10) - 0.5;\n vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10);\n vec4 sw10 = step(gw10, vec4(0.0));\n gx10 -= sw10 * (step(0.0, gx10) - 0.5);\n gy10 -= sw10 * (step(0.0, gy10) - 0.5);\n\n vec4 gx11 = ixy11 * (1.0 / 7.0);\n vec4 gy11 = floor(gx11) * (1.0 / 7.0);\n vec4 gz11 = floor(gy11) * (1.0 / 6.0);\n gx11 = fract(gx11) - 0.5;\n gy11 = fract(gy11) - 0.5;\n gz11 = fract(gz11) - 0.5;\n vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11);\n vec4 sw11 = step(gw11, vec4(0.0));\n gx11 -= sw11 * (step(0.0, gx11) - 0.5);\n gy11 -= sw11 * (step(0.0, gy11) - 0.5);\n\n vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x);\n vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y);\n vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z);\n vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w);\n vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x);\n vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y);\n vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z);\n vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w);\n vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x);\n vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y);\n vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z);\n vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w);\n vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x);\n vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y);\n vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z);\n vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w);\n\n vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));\n g0000 *= norm00.x;\n g0100 *= norm00.y;\n g1000 *= norm00.z;\n g1100 *= norm00.w;\n\n vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));\n g0001 *= norm01.x;\n g0101 *= norm01.y;\n g1001 *= norm01.z;\n g1101 *= norm01.w;\n\n vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));\n g0010 *= norm10.x;\n g0110 *= norm10.y;\n g1010 *= norm10.z;\n g1110 *= norm10.w;\n\n vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));\n g0011 *= norm11.x;\n g0111 *= norm11.y;\n g1011 *= norm11.z;\n g1111 *= norm11.w;\n\n float n0000 = dot(g0000, Pf0);\n float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw));\n float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw));\n float n1100 = dot(g1100, vec4(Pf1.xy, Pf0.zw));\n float n0010 = dot(g0010, vec4(Pf0.xy, Pf1.z, Pf0.w));\n float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w));\n float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz, Pf0.w));\n float n1110 = dot(g1110, vec4(Pf1.xyz, Pf0.w));\n float n0001 = dot(g0001, vec4(Pf0.xyz, Pf1.w));\n float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz, Pf1.w));\n float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w));\n float n1101 = dot(g1101, vec4(Pf1.xy, Pf0.z, Pf1.w));\n float n0011 = dot(g0011, vec4(Pf0.xy, Pf1.zw));\n float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw));\n float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw));\n float n1111 = dot(g1111, Pf1);\n\n vec4 fade_xyzw = fade(Pf0);\n vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w);\n vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w);\n vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z);\n vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y);\n float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);\n return 2.2 * n_xyzw;\n\n}\n"; // eslint-disable-line
|
|
5453
|
+
|
|
5454
|
+
var noise_psrd_2D = "// Periodic (tiling) 2-D simplex noise (hexagonal lattice gradient noise)\n// with rotating gradients and analytic derivatives.\n// Variants also without the derivative (no \"d\" in the name), without\n// the tiling property (no \"p\" in the name) and without the rotating\n// gradients (no \"r\" in the name).\n//\n// This is (yet) another variation on simplex noise. It's similar to the\n// version presented by Ken Perlin, but the grid is axis-aligned and\n// slightly stretched in the y direction to permit rectangular tiling.\n//\n// The noise can be made to tile seamlessly to any integer period in x and\n// any even integer period in y. Odd periods may be specified for y, but\n// then the actual tiling period will be twice that number.\n//\n// The rotating gradients give the appearance of a swirling motion, and can\n// serve a similar purpose for animation as motion along z in 3-D noise.\n// The rotating gradients in conjunction with the analytic derivatives\n// can make \"flow noise\" effects as presented by Perlin and Neyret.\n//\n// vec3 {p}s{r}dnoise(vec2 pos {, vec2 per} {, float rot})\n// \"pos\" is the input (x,y) coordinate\n// \"per\" is the x and y period, where per.x is a positive integer\n// and per.y is a positive even integer\n// \"rot\" is the angle to rotate the gradients (any float value,\n// where 0.0 is no rotation and 1.0 is one full turn)\n// The first component of the 3-element return vector is the noise value.\n// The second and third components are the x and y partial derivatives.\n//\n// float {p}s{r}noise(vec2 pos {, vec2 per} {, float rot})\n// \"pos\" is the input (x,y) coordinate\n// \"per\" is the x and y period, where per.x is a positive integer\n// and per.y is a positive even integer\n// \"rot\" is the angle to rotate the gradients (any float value,\n// where 0.0 is no rotation and 1.0 is one full turn)\n// The return value is the noise value.\n// Partial derivatives are not computed, making these functions faster.\n//\n// Author: Stefan Gustavson (stefan.gustavson@gmail.com)\n// Version 2016-05-10.\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// idea of using a permutation polynomial.\n//\n// Copyright (c) 2016 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/stegu/webgl-noise\n//\n\n// Hashed 2-D gradients with an extra rotation.\n// (The constant 0.0243902439 is 1/41)\nvec2 rgrad2( vec2 p, float rot ) {\n\n // For more isotropic gradients, sin/cos can be used instead.\n float u = permute( permute( p.x ) + p.y ) * 0.0243902439 + rot; // Rotate by shift\n u = fract( u ) * 6.28318530718; // 2*pi\n return vec2( cos( u ), sin( u ));\n\n}\n\n//\n// 2-D tiling simplex noise with rotating gradients and analytical derivative.\n// The first component of the 3-element return vector is the noise value,\n// and the second and third components are the x and y partial derivatives.\n//\nvec3 psrdnoise(vec2 pos, vec2 per, float rot) {\n // Hack: offset y slightly to hide some rare artifacts\n pos.y += 0.01;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 xw = mod(vec3(p0.x, p1.x, p2.x), per.x);\n vec3 yw = mod(vec3(p0.y, p1.y, p2.y), per.y);\n vec3 iuw = xw + 0.5 * yw;\n vec3 ivw = yw;\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Partial derivatives for analytical gradient computation\n vec3 dtdx = -2.0 * vec3(d0.x, d1.x, d2.x);\n vec3 dtdy = -2.0 * vec3(d0.y, d1.y, d2.y);\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n if (t.x < 0.0) {\n dtdx.x = 0.0;\n dtdy.x = 0.0;\n\tt.x = 0.0;\n }\n if (t.y < 0.0) {\n dtdx.y = 0.0;\n dtdy.y = 0.0;\n\tt.y = 0.0;\n }\n if (t.z < 0.0) {\n dtdx.z = 0.0;\n dtdy.z = 0.0;\n\tt.z = 0.0;\n }\n\n // Fourth power of t (and third power for derivative)\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n vec3 t3 = t2 * t;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Final analytical derivative (gradient of a sum of scalar products)\n vec2 dt0 = vec2(dtdx.x, dtdy.x) * 4.0 * t3.x;\n vec2 dn0 = t4.x * g0 + dt0 * w.x;\n vec2 dt1 = vec2(dtdx.y, dtdy.y) * 4.0 * t3.y;\n vec2 dn1 = t4.y * g1 + dt1 * w.y;\n vec2 dt2 = vec2(dtdx.z, dtdy.z) * 4.0 * t3.z;\n vec2 dn2 = t4.z * g2 + dt2 * w.z;\n\n return 11.0*vec3(n, dn0 + dn1 + dn2);\n}\n\n//\n// 2-D tiling simplex noise with fixed gradients\n// and analytical derivative.\n// This function is implemented as a wrapper to \"psrdnoise\",\n// at the minimal cost of three extra additions.\n//\nvec3 psdnoise(vec2 pos, vec2 per) {\n return psrdnoise(pos, per, 0.0);\n}\n\n//\n// 2-D tiling simplex noise with rotating gradients,\n// but without the analytical derivative.\n//\nfloat psrnoise(vec2 pos, vec2 per, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 xw = mod(vec3(p0.x, p1.x, p2.x), per.x);\n vec3 yw = mod(vec3(p0.y, p1.y, p2.y), per.y);\n vec3 iuw = xw + 0.5 * yw;\n vec3 ivw = yw;\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n t = max(t, 0.0);\n\n // Fourth power of t\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Rescale to cover the range [-1,1] reasonably well\n return 11.0*n;\n}\n\n//\n// 2-D tiling simplex noise with fixed gradients,\n// without the analytical derivative.\n// This function is implemented as a wrapper to \"psrnoise\",\n// at the minimal cost of three extra additions.\n//\nfloat psnoise(vec2 pos, vec2 per) {\n return psrnoise(pos, per, 0.0);\n}\n\n//\n// 2-D non-tiling simplex noise with rotating gradients and analytical derivative.\n// The first component of the 3-element return vector is the noise value,\n// and the second and third components are the x and y partial derivatives.\n//\nvec3 srdnoise(vec2 pos, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n vec3 x = vec3(p0.x, p1.x, p2.x);\n vec3 y = vec3(p0.y, p1.y, p2.y);\n vec3 iuw = x + 0.5 * y;\n vec3 ivw = y;\n\n // Avoid precision issues in permutation\n iuw = mod289(iuw);\n ivw = mod289(ivw);\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Partial derivatives for analytical gradient computation\n vec3 dtdx = -2.0 * vec3(d0.x, d1.x, d2.x);\n vec3 dtdy = -2.0 * vec3(d0.y, d1.y, d2.y);\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n if (t.x < 0.0) {\n dtdx.x = 0.0;\n dtdy.x = 0.0;\n\tt.x = 0.0;\n }\n if (t.y < 0.0) {\n dtdx.y = 0.0;\n dtdy.y = 0.0;\n\tt.y = 0.0;\n }\n if (t.z < 0.0) {\n dtdx.z = 0.0;\n dtdy.z = 0.0;\n\tt.z = 0.0;\n }\n\n // Fourth power of t (and third power for derivative)\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n vec3 t3 = t2 * t;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Final analytical derivative (gradient of a sum of scalar products)\n vec2 dt0 = vec2(dtdx.x, dtdy.x) * 4.0 * t3.x;\n vec2 dn0 = t4.x * g0 + dt0 * w.x;\n vec2 dt1 = vec2(dtdx.y, dtdy.y) * 4.0 * t3.y;\n vec2 dn1 = t4.y * g1 + dt1 * w.y;\n vec2 dt2 = vec2(dtdx.z, dtdy.z) * 4.0 * t3.z;\n vec2 dn2 = t4.z * g2 + dt2 * w.z;\n\n return 11.0*vec3(n, dn0 + dn1 + dn2);\n}\n\n//\n// 2-D non-tiling simplex noise with fixed gradients and analytical derivative.\n// This function is implemented as a wrapper to \"srdnoise\",\n// at the minimal cost of three extra additions.\n//\nvec3 sdnoise(vec2 pos) {\n return srdnoise(pos, 0.0);\n}\n\n//\n// 2-D non-tiling simplex noise with rotating gradients,\n// without the analytical derivative.\n//\nfloat srnoise(vec2 pos, float rot) {\n // Offset y slightly to hide some rare artifacts\n pos.y += 0.001;\n // Skew to hexagonal grid\n vec2 uv = vec2(pos.x + pos.y*0.5, pos.y);\n\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n // Traversal order\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n\n // Unskewed grid points in (x,y) space\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n\n // Integer grid point indices in (u,v) space\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n\n // Vectors in unskewed (x,y) coordinates from\n // each of the simplex corners to the evaluation point\n vec2 d0 = pos - p0;\n vec2 d1 = pos - p1;\n vec2 d2 = pos - p2;\n\n // Wrap i0, i1 and i2 to the desired period before gradient hashing:\n // wrap points in (x,y), map to (u,v)\n vec3 x = vec3(p0.x, p1.x, p2.x);\n vec3 y = vec3(p0.y, p1.y, p2.y);\n vec3 iuw = x + 0.5 * y;\n vec3 ivw = y;\n\n // Avoid precision issues in permutation\n iuw = mod289(iuw);\n ivw = mod289(ivw);\n\n // Create gradients from indices\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), rot);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), rot);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), rot);\n\n // Gradients dot vectors to corresponding corners\n // (The derivatives of this are simply the gradients)\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n\n // Radial weights from corners\n // 0.8 is the square of 2/sqrt(5), the distance from\n // a grid point to the nearest simplex boundary\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n\n // Set influence of each surflet to zero outside radius sqrt(0.8)\n t = max(t, 0.0);\n\n // Fourth power of t\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n\n // Final noise value is:\n // sum of ((radial weights) times (gradient dot vector from corner))\n float n = dot(t4, w);\n\n // Rescale to cover the range [-1,1] reasonably well\n return 11.0*n;\n}\n\n//\n// 2-D non-tiling simplex noise with fixed gradients,\n// without the analytical derivative.\n// This function is implemented as a wrapper to \"srnoise\",\n// at the minimal cost of three extra additions.\n// Note: if this kind of noise is all you want, there are faster\n// GLSL implementations of non-tiling simplex noise out there.\n// This one is included mainly for completeness and compatibility\n// with the other functions in the file.\n//\nfloat snoise(vec2 pos) {\n return srnoise(pos, 0.0);\n}\n"; // eslint-disable-line
|
|
5455
|
+
|
|
5456
|
+
var noise_simplex = "#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"; // eslint-disable-line
|
|
5457
|
+
|
|
5458
|
+
var noise_simplex_2D = "//\n// Description : Array and textureless GLSL 2D simplex noise function.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec2 v ) {\n\n const vec4 C = vec4( 0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439 ); // 1.0 / 41.0\n // First corner\n vec2 i = floor( v + dot( v, C.yy ) );\n vec2 x0 = v - i + dot( i, C.xx );\n\n // Other corners\n vec2 i1;\n //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0\n //i1.y = 1.0 - i1.x;\n i1 = ( x0.x > x0.y ) ? vec2( 1.0, 0.0 ) : vec2( 0.0, 1.0 );\n // x0 = x0 - 0.0 + 0.0 * C.xx ;\n // x1 = x0 - i1 + 1.0 * C.xx ;\n // x2 = x0 - 1.0 + 2.0 * C.xx ;\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n\n // Permutations\n i = mod289( i ); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3( 0.0, i1.y, 1.0 ) )\n + i.x + vec3( 0.0, i1.x, 1.0 ) );\n\n vec3 m = max( 0.5 - vec3( dot( x0, x0 ), dot( x12.xy, x12.xy ), dot( x12.zw, x12.zw ) ), 0.0 );\n m = m*m ;\n m = m*m ;\n\n // Gradients: 41 points uniformly over a line, mapped onto a diamond.\n // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)\n\n vec3 x = 2.0 * fract( p * C.www ) - 1.0;\n vec3 h = abs( x ) - 0.5;\n vec3 ox = floor( x + 0.5 );\n vec3 a0 = x - ox;\n\n // Normalise gradients implicitly by scaling m\n // Approximation of: m *= inversesqrt( a0*a0 + h*h );\n m *= 1.79284291400159 - 0.85373472095314 * ( a0 * a0 + h * h );\n\n // Compute final noise value at P\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot( m, g );\n\n}\n"; // eslint-disable-line
|
|
5459
|
+
|
|
5460
|
+
var noise_simplex_3D = "//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec3 v ) {\n\n const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );\n const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );\n\n // First corner\n vec3 i = floor( v + dot( v, C.yyy ) );\n vec3 x0 = v - i + dot( i, C.xxx );\n\n // Other corners\n vec3 g = step( x0.yzx, x0.xyz );\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n // Permutations\n i = mod289( i );\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n // Gradients: 7x7 points over a square, mapped onto an octahedron.\n // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor( p * ns.z * ns.z ); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs( x ) - abs( y );\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n vec4 s0 = floor( b0 ) * 2.0 + 1.0;\n vec4 s1 = floor( b1 ) * 2.0 + 1.0;\n vec4 sh = - step( h, vec4( 0.0 ) );\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww ;\n\n vec3 p0 = vec3( a0.xy, h.x );\n vec3 p1 = vec3( a0.zw, h.y );\n vec3 p2 = vec3( a1.xy, h.z );\n vec3 p3 = vec3( a1.zw, h.w );\n\n //Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot( p0, x0 ), dot( p1, x1 ),\n dot( p2, x2 ), dot( p3, x3 ) ) );\n\n}\n"; // eslint-disable-line
|
|
5461
|
+
|
|
5462
|
+
var noise_simplex_3D_grad = "//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20150104 (JcBernack)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nfloat simplex( vec3 v, out vec3 gradient ) {\n\n const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );\n const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );\n\n // First corner\n vec3 i = floor( v + dot( v, C.yyy ) );\n vec3 x0 = v - i + dot( i, C.xxx ) ;\n\n // Other corners\n vec3 g = step( x0.yzx, x0.xyz );\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n // Permutations\n i = mod289( i );\n vec4 p = permute( permute( permute(\n i.z + vec4( 0.0, i1.z, i2.z, 1.0 ) )\n + i.y + vec4( 0.0, i1.y, i2.y, 1.0 ) )\n + i.x + vec4( 0.0, i1.x, i2.x, 1.0 ) );\n\n // Gradients: 7x7 points over a square, mapped onto an octahedron.\n // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs( x ) - abs( y );\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n vec4 s0 = floor( b0 ) * 2.0 + 1.0;\n vec4 s1 = floor( b1 ) * 2.0 + 1.0;\n vec4 sh = - step( h, vec4( 0.0 ) );\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww ;\n\n vec3 p0 = vec3( a0.xy, h.x );\n vec3 p1 = vec3( a0.zw, h.y );\n vec3 p2 = vec3( a1.xy, h.z );\n vec3 p3 = vec3( a1.zw, h.w );\n\n //Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );\n vec4 m2 = m * m;\n vec4 m4 = m2 * m2;\n vec4 pdotx = vec4( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 ), dot( p3, x3 ) );\n\n // Determine noise gradient\n vec4 temp = m2 * m * pdotx;\n gradient = - 8.0 * ( temp.x * x0 + temp.y * x1 + temp.z * x2 + temp.w * x3 );\n gradient += m4.x * p0 + m4.y * p1 + m4.z * p2 + m4.w * p3;\n gradient *= 42.0;\n\n return 42.0 * dot( m4, pdotx );\n\n}\n"; // eslint-disable-line
|
|
5463
|
+
|
|
5464
|
+
var noise_simplex_4D = "//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : stegu\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n// https://github.com/stegu/webgl-noise\n//\n\nvec4 grad4( float j, vec4 ip ) {\n\n const vec4 ones = vec4( 1.0, 1.0, 1.0, -1.0 );\n vec4 p, s;\n\n p.xyz = floor( fract( vec3( j ) * ip.xyz ) * 7.0 ) * ip.z - 1.0;\n p.w = 1.5 - dot( abs( p.xyz ), ones.xyz );\n s = vec4( lessThan( p, vec4( 0.0 ) ) );\n p.xyz = p.xyz + ( s.xyz * 2.0 - 1.0 ) * s.www;\n\n return p;\n\n}\n\n// (sqrt(5) - 1)/4 = F4, used once below\n#define F4 0.309016994374947451\n\nfloat simplex(vec4 v) {\n\n const vec4 C = vec4( 0.138196601125011, // (5 - sqrt(5))/20 G4\n 0.276393202250021, // 2 * G4\n 0.414589803375032, // 3 * G4\n -0.447213595499958); // -1 + 4 * G4\n\n // First corner\n vec4 i = floor( v + dot( v, vec4( F4 ) ) );\n vec4 x0 = v - i + dot( i, C.xxxx );\n\n // Other corners\n\n // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)\n vec4 i0;\n vec3 isX = step( x0.yzw, x0.xxx );\n vec3 isYZ = step( x0.zww, x0.yyz );\n i0.x = isX.x + isX.y + isX.z;\n i0.yzw = 1.0 - isX;\n i0.y += isYZ.x + isYZ.y;\n i0.zw += 1.0 - isYZ.xy;\n i0.z += isYZ.z;\n i0.w += 1.0 - isYZ.z;\n\n vec4 i3 = clamp( i0, 0.0, 1.0 );\n vec4 i2 = clamp( i0 - 1.0, 0.0, 1.0 );\n vec4 i1 = clamp( i0 - 2.0, 0.0, 1.0 );\n\n vec4 x1 = x0 - i1 + C.xxxx;\n vec4 x2 = x0 - i2 + C.yyyy;\n vec4 x3 = x0 - i3 + C.zzzz;\n vec4 x4 = x0 + C.wwww;\n\n // Permutations\n i = mod289( i );\n float j0 = permute( permute( permute( permute( i.w ) + i.z ) + i.y ) + i.x );\n vec4 j1 = permute( permute( permute( permute (\n i.w + vec4(i1.w, i2.w, i3.w, 1.0 ))\n + i.z + vec4(i1.z, i2.z, i3.z, 1.0 ))\n + i.y + vec4(i1.y, i2.y, i3.y, 1.0 ))\n + i.x + vec4(i1.x, i2.x, i3.x, 1.0 ));\n\n // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope\n // 7*7*6 = 294, which is close to the ring size 17*17 = 289.\n vec4 ip = vec4( 1.0 / 294.0, 1.0 / 49.0, 1.0 / 7.0, 0.0 );\n\n vec4 p0 = grad4(j0, ip);\n vec4 p1 = grad4(j1.x, ip);\n vec4 p2 = grad4(j1.y, ip);\n vec4 p3 = grad4(j1.z, ip);\n vec4 p4 = grad4(j1.w, ip);\n\n // Normalise gradients\n vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) );\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n p4 *= taylorInvSqrt( dot( p4, p4 ) );\n\n // Mix contributions from the five corners\n vec3 m0 = max( 0.6 - vec3( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ) ), 0.0 );\n vec2 m1 = max( 0.6 - vec2( dot( x3, x3 ), dot( x4, x4 ) ), 0.0 );\n m0 = m0 * m0;\n m1 = m1 * m1;\n return 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))\n + dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;\n\n}\n"; // eslint-disable-line
|
|
5443
5465
|
|
|
5444
5466
|
var pbr_frag_define = "#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\n\nuniform float material_AlphaCutoff;\nuniform vec4 material_BaseColor;\nuniform float material_Metal;\nuniform float material_Roughness;\nuniform float material_IOR;\nuniform vec3 material_EmissiveColor;\nuniform float material_NormalIntensity;\nuniform float material_OcclusionIntensity;\nuniform float material_OcclusionTextureCoord;\nuniform float material_SpecularIntensity;\nuniform vec3 material_SpecularColor;\n\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n uniform float material_ClearCoat;\n uniform float material_ClearCoatRoughness;\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\n uniform sampler2D material_ClearCoatTexture;\n #endif\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\n uniform sampler2D material_ClearCoatRoughnessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\n uniform sampler2D material_ClearCoatNormalTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n uniform vec3 material_AnisotropyInfo;\n #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\n uniform sampler2D material_AnisotropyTexture;\n #endif\n#endif\n\n// Texture\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\n#ifdef MATERIAL_HAS_NORMALTEXTURE\n uniform sampler2D material_NormalTexture;\n#endif\n\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\n uniform sampler2D material_RoughnessMetallicTexture;\n#endif\n\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\n uniform sampler2D material_SpecularIntensityTexture;\n#endif\n\n#ifdef MATERIAL_HAS_SPECULAR_COLOR_TEXTURE\n uniform sampler2D material_SpecularColorTexture;\n#endif\n\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n uniform sampler2D material_OcclusionTexture;\n#endif\n\n\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform float material_SheenRoughness;\n uniform vec3 material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n uniform sampler2D material_SheenTexture;\n #endif\n\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n uniform sampler2D material_SheenRoughnessTexture;\n #endif\n#endif\n\n\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\n uniform vec4 material_IridescenceInfo;\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n uniform sampler2D material_IridescenceThicknessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n uniform sampler2D material_IridescenceTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION\n uniform float material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n uniform sampler2D material_TransmissionTexture;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n uniform vec3 material_AttenuationColor;\n uniform float material_AttenuationDistance;\n uniform float material_Thickness;\n\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n uniform sampler2D material_ThicknessTexture;\n #endif\n #endif\n#endif\n\n// Runtime\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n\nstruct Geometry {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n float dotNV;\n \n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatNormal;\n float clearCoatDotNV;\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 anisotropicT;\n vec3 anisotropicB;\n vec3 anisotropicN;\n float anisotropy;\n #endif\n};\n\nstruct Material {\n vec3 diffuseColor;\n float roughness;\n vec3 specularF0;\n vec3 resolvedSpecularF0;\n float specularF90;\n float specularIntensity;\n vec3 specularColor;\n float opacity;\n float diffuseAO;\n float specularAO;\n vec3 envSpecularDFG;\n vec3 energyCompensation; // Multi-scattering energy compensation factor\n float IOR;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoat;\n float clearCoatRoughness;\n #endif\n\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float iridescenceIOR;\n float iridescenceFactor;\n float iridescenceThickness;\n vec3 iridescenceSpecularColor;\n #endif\n\n #ifdef MATERIAL_ENABLE_SHEEN\n float sheenRoughness;\n vec3 sheenColor;\n float sheenScaling;\n float approxIBLSheenDG;\n #endif\n\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n vec3 absorptionCoefficient;\n float transmission;\n float thickness;\n #endif\n};\n"; // eslint-disable-line
|
|
5445
5467
|
|
|
@@ -5449,7 +5471,7 @@ var brdf = "\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform sampler2D scene_Prefilte
|
|
|
5449
5471
|
|
|
5450
5472
|
var direct_irradiance_frag_define = "#include <ShadowFragmentDeclaration>\n\nvoid sheenLobe(Geometry geometry, Material material, vec3 incidentDirection, vec3 attenuationIrradiance, inout vec3 diffuseColor, inout vec3 specularColor){\n #ifdef MATERIAL_ENABLE_SHEEN\n diffuseColor *= material.sheenScaling;\n specularColor *= material.sheenScaling;\n\n specularColor += attenuationIrradiance * sheenBRDF(incidentDirection, geometry, material.sheenColor, material.sheenRoughness);\n #endif\n}\n\nvoid addDirectRadiance(vec3 incidentDirection, vec3 color, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n float attenuation = 1.0;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoatDotNL = saturate( dot( geometry.clearCoatNormal, incidentDirection ) );\n vec3 clearCoatIrradiance = clearCoatDotNL * color;\n\n reflectedLight.directSpecular += material.clearCoat * clearCoatIrradiance * BRDF_Specular_GGX( incidentDirection, geometry, material, geometry.clearCoatNormal, vec3( 0.04 ), material.clearCoatRoughness );\n attenuation -= material.clearCoat * F_Schlick(0.04, 1.0, geometry.clearCoatDotNV);\n #endif\n\n float dotNL = saturate( dot( geometry.normal, incidentDirection ) );\n vec3 irradiance = dotNL * color * PI;\n\n reflectedLight.directSpecular += attenuation * irradiance * BRDF_Specular_GGX( incidentDirection, geometry, material, geometry.normal, material.specularF0, material.roughness) * material.energyCompensation;\n reflectedLight.directDiffuse += attenuation * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n // Sheen Lobe\n sheenLobe(geometry, material, incidentDirection, attenuation * irradiance, reflectedLight.directDiffuse, reflectedLight.directSpecular);\n\n}\n\n#ifdef SCENE_DIRECT_LIGHT_COUNT\n\n void addDirectionalDirectLightRadiance(DirectLight directionalLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n vec3 color = directionalLight.color;\n vec3 direction = -directionalLight.direction;\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n }\n\n#endif\n\n#ifdef SCENE_POINT_LIGHT_COUNT\n\n\tvoid addPointDirectLightRadiance(PointLight pointLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tvec3 direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tvec3 color = pointLight.color;\n\t\tcolor *= clamp(1.0 - pow(lightDistance/pointLight.distance, 4.0), 0.0, 1.0);\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#ifdef SCENE_SPOT_LIGHT_COUNT\n\n\tvoid addSpotDirectLightRadiance(SpotLight spotLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tvec3 direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( direction, -spotLight.direction );\n\n\t\tfloat spotEffect = smoothstep( spotLight.penumbraCos, spotLight.angleCos, angleCos );\n\t\tfloat decayEffect = clamp(1.0 - pow(lightDistance/spotLight.distance, 4.0), 0.0, 1.0);\n\n\t\tvec3 color = spotLight.color;\n\t\tcolor *= spotEffect * decayEffect;\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n\t}\n\n\n#endif\n\nvoid addTotalDirectRadiance(Geometry geometry, Material material, inout ReflectedLight reflectedLight){\n float shadowAttenuation = 1.0;\n\n #ifdef SCENE_DIRECT_LIGHT_COUNT\n shadowAttenuation = 1.0;\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n shadowAttenuation *= sampleShadowMap();\n #endif\n\n DirectLight directionalLight;\n for ( int i = 0; i < SCENE_DIRECT_LIGHT_COUNT; i ++ ) {\n // warning: use `continue` syntax may trigger flickering bug in safri 16.1.\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_DirectLightCullingMask[i])){\n directionalLight.color = scene_DirectLightColor[i];\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n if (i == 0) { // Sun light index is always 0\n directionalLight.color *= shadowAttenuation;\n }\n #endif\n directionalLight.direction = scene_DirectLightDirection[i];\n addDirectionalDirectLightRadiance( directionalLight, geometry, material, reflectedLight );\n }\n }\n\n #endif\n\n #ifdef SCENE_POINT_LIGHT_COUNT\n\n PointLight pointLight;\n\n for ( int i = 0; i < SCENE_POINT_LIGHT_COUNT; i ++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_PointLightCullingMask[i])){\n pointLight.color = scene_PointLightColor[i];\n pointLight.position = scene_PointLightPosition[i];\n pointLight.distance = scene_PointLightDistance[i];\n\n addPointDirectLightRadiance( pointLight, geometry, material, reflectedLight );\n } \n }\n\n #endif\n\n #ifdef SCENE_SPOT_LIGHT_COUNT\n\n SpotLight spotLight;\n\n for ( int i = 0; i < SCENE_SPOT_LIGHT_COUNT; i ++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_SpotLightCullingMask[i])){\n spotLight.color = scene_SpotLightColor[i];\n spotLight.position = scene_SpotLightPosition[i];\n spotLight.direction = scene_SpotLightDirection[i];\n spotLight.distance = scene_SpotLightDistance[i];\n spotLight.angleCos = scene_SpotLightAngleCos[i];\n spotLight.penumbraCos = scene_SpotLightPenumbraCos[i];\n\n addSpotDirectLightRadiance( spotLight, geometry, material, reflectedLight );\n } \n }\n\n #endif\n}"; // eslint-disable-line
|
|
5451
5473
|
|
|
5452
|
-
var ibl_frag_define = "// ------------------------Diffuse------------------------\n\n// sh need be pre-scaled in CPU.\nvec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){\n vec3 result = sh[0] +\n\n sh[1] * (normal.y) +\n sh[2] * (normal.z) +\n sh[3] * (normal.x) +\n\n sh[4] * (normal.y * normal.x) +\n sh[5] * (normal.y * normal.z) +\n sh[6] * (3.0 * normal.z * normal.z - 1.0) +\n sh[7] * (normal.z * normal.x) +\n sh[8] * (normal.x * normal.x - normal.y * normal.y);\n \n return max(result, vec3(0.0));\n\n}\n\n// ------------------------Specular------------------------\n\n// Returns raw DFG approximation coefficients (split-sum LUT approximation)\nvec2 envDFGApprox(float roughness, float dotNV) {\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n return vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 envBRDFApprox(vec3 f0, float f90, float roughness, float dotNV ) {\n vec2 AB = envDFGApprox(roughness, dotNV);\n return f0 * AB.x + f90 * AB.y;\n}\n\n\nfloat getSpecularMIPLevel(float roughness, int maxMIPLevel ) {\n return roughness * float(maxMIPLevel);\n}\n\nvec3 getReflectedVector(Geometry geometry, vec3 n) {\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 r = reflect(-geometry.viewDir, geometry.anisotropicN);\n #else\n vec3 r = reflect(-geometry.viewDir, n);\n #endif\n\n return r;\n}\n\nvec3 getLightProbeRadiance(Geometry geometry, vec3 normal, float roughness, int maxMIPLevel, float specularIntensity) {\n\n #ifndef SCENE_USE_SPECULAR_ENV\n return vec3(0);\n #else\n vec3 reflectVec = getReflectedVector(geometry, normal);\n\n float specularMIPLevel = getSpecularMIPLevel(roughness, maxMIPLevel );\n\n #ifdef HAS_TEX_LOD\n vec4 envMapColor = textureCubeLodEXT( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #endif\n\n #ifdef ENGINE_NO_SRGB\n envMapColor = sRGBToLinear(envMapColor);\n #endif\n \n return envMapColor.rgb * specularIntensity;\n\n #endif\n\n}\n\n\nvoid evaluateSheenIBL(Geometry geometry, Material material, float radianceAttenuation, inout vec3 diffuseColor, inout vec3 specularColor){\n #ifdef MATERIAL_ENABLE_SHEEN\n diffuseColor *= material.sheenScaling;\n specularColor *= material.sheenScaling;\n\n vec3 reflectance = material.specularAO * radianceAttenuation * material.approxIBLSheenDG * material.sheenColor;\n specularColor += reflectance;\n #endif\n}"; // eslint-disable-line
|
|
5474
|
+
var ibl_frag_define = "// ------------------------Diffuse------------------------\n\n// sh need be pre-scaled in CPU.\nvec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){\n normal.x = -normal.x;\n vec3 result = sh[0] +\n\n sh[1] * (normal.y) +\n sh[2] * (normal.z) +\n sh[3] * (normal.x) +\n\n sh[4] * (normal.y * normal.x) +\n sh[5] * (normal.y * normal.z) +\n sh[6] * (3.0 * normal.z * normal.z - 1.0) +\n sh[7] * (normal.z * normal.x) +\n sh[8] * (normal.x * normal.x - normal.y * normal.y);\n \n return max(result, vec3(0.0));\n\n}\n\n// ------------------------Specular------------------------\n\n// Returns raw DFG approximation coefficients (split-sum LUT approximation)\nvec2 envDFGApprox(float roughness, float dotNV) {\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n return vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 envBRDFApprox(vec3 f0, float f90, float roughness, float dotNV ) {\n vec2 AB = envDFGApprox(roughness, dotNV);\n return f0 * AB.x + f90 * AB.y;\n}\n\n\nfloat getSpecularMIPLevel(float roughness, int maxMIPLevel ) {\n return roughness * float(maxMIPLevel);\n}\n\nvec3 getReflectedVector(Geometry geometry, vec3 n) {\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 r = reflect(-geometry.viewDir, geometry.anisotropicN);\n #else\n vec3 r = reflect(-geometry.viewDir, n);\n #endif\n\n return r;\n}\n\nvec3 getLightProbeRadiance(Geometry geometry, vec3 normal, float roughness, int maxMIPLevel, float specularIntensity) {\n\n #ifndef SCENE_USE_SPECULAR_ENV\n return vec3(0);\n #else\n vec3 reflectVec = getReflectedVector(geometry, normal);\n reflectVec.x = -reflectVec.x; // TextureCube is left-hand,so x need inverse\n \n float specularMIPLevel = getSpecularMIPLevel(roughness, maxMIPLevel );\n\n #ifdef HAS_TEX_LOD\n vec4 envMapColor = textureCubeLodEXT( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #endif\n\n #ifdef ENGINE_NO_SRGB\n envMapColor = sRGBToLinear(envMapColor);\n #endif\n \n return envMapColor.rgb * specularIntensity;\n\n #endif\n\n}\n\n\nvoid evaluateSheenIBL(Geometry geometry, Material material, float radianceAttenuation, inout vec3 diffuseColor, inout vec3 specularColor){\n #ifdef MATERIAL_ENABLE_SHEEN\n diffuseColor *= material.sheenScaling;\n specularColor *= material.sheenScaling;\n\n vec3 reflectance = material.specularAO * radianceAttenuation * material.approxIBLSheenDG * material.sheenColor;\n specularColor += reflectance;\n #endif\n}"; // eslint-disable-line
|
|
5453
5475
|
|
|
5454
5476
|
var pbr_frag = "Geometry geometry;\nMaterial material;\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\ninitGeometry(geometry, gl_FrontFacing);\ninitMaterial(material, geometry);\n\n// Direct Light\naddTotalDirectRadiance(geometry, material, reflectedLight);\n\n// IBL diffuse\n#ifdef SCENE_USE_SH\n vec3 irradiance = getLightProbeIrradiance(scene_EnvSH, geometry.normal);\n irradiance *= scene_EnvMapLight.diffuseIntensity;\n#else\n vec3 irradiance = scene_EnvMapLight.diffuse * scene_EnvMapLight.diffuseIntensity;\n irradiance *= PI;\n#endif\n\nreflectedLight.indirectDiffuse += material.diffuseAO * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n// IBL specular\nvec3 radiance = getLightProbeRadiance(geometry, geometry.normal, material.roughness, int(scene_EnvMapLight.mipMapLevel), scene_EnvMapLight.specularIntensity);\nfloat radianceAttenuation = 1.0;\n\n// IBL Clear Coat\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatRadiance = getLightProbeRadiance( geometry, geometry.clearCoatNormal, material.clearCoatRoughness, int(scene_EnvMapLight.mipMapLevel), scene_EnvMapLight.specularIntensity );\n\n reflectedLight.indirectSpecular += material.specularAO * clearCoatRadiance * material.clearCoat * envBRDFApprox(vec3( 0.04 ), 1.0, material.clearCoatRoughness, geometry.clearCoatDotNV);\n radianceAttenuation -= material.clearCoat * F_Schlick(0.04, 1.0, geometry.clearCoatDotNV);\n#endif\n\nreflectedLight.indirectSpecular += material.specularAO * radianceAttenuation * radiance * envBRDFApprox(material.resolvedSpecularF0, material.specularF90, material.roughness, geometry.dotNV) * material.energyCompensation;\n\n\n// IBL Sheen\nevaluateSheenIBL(geometry, material, radianceAttenuation, reflectedLight.indirectDiffuse, reflectedLight.indirectSpecular);\n\n\n// Final color\nvec3 totalDiffuseColor = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nvec3 totalSpecularColor = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION \n vec3 refractionTransmitted = evaluateTransmission(geometry, material);\n totalDiffuseColor = mix(totalDiffuseColor, refractionTransmitted, material.transmission);\n#endif\n\nvec4 finalColor = vec4(totalDiffuseColor + totalSpecularColor, material.opacity);\n\n\n// Emissive\nvec3 emissiveRadiance = material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n emissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_uv).rgb;\n#endif\n\nfinalColor.rgb += emissiveRadiance;\n\n\ngl_FragColor = finalColor;\n"; // eslint-disable-line
|
|
5455
5477
|
|
|
@@ -5502,9 +5524,7 @@ var force_over_lifetime_module = "#if defined(RENDERER_FOL_CONSTANT_MODE) || def
|
|
|
5502
5524
|
|
|
5503
5525
|
var limit_velocity_over_lifetime_module = "#ifdef RENDERER_LVL_MODULE_ENABLED\n uniform int renderer_LVLSpace;\n uniform float renderer_LVLDampen;\n\n // Scalar limit\n #ifndef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform float renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform float renderer_LVLSpeedMinConst;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedMinCurve[4];\n #endif\n #endif\n #endif\n\n // Per-axis limit\n #ifdef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform vec3 renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec3 renderer_LVLSpeedMinConstVector;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedXMaxCurve[4];\n uniform vec2 renderer_LVLSpeedYMaxCurve[4];\n uniform vec2 renderer_LVLSpeedZMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedXMinCurve[4];\n uniform vec2 renderer_LVLSpeedYMinCurve[4];\n uniform vec2 renderer_LVLSpeedZMinCurve[4];\n #endif\n #endif\n #endif\n\n // Drag curve\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n uniform vec2 renderer_LVLDragMaxCurve[4];\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n uniform vec2 renderer_LVLDragMinCurve[4];\n #endif\n #endif\n\n float evaluateLVLDrag(float normalizedAge, float dragRand) {\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n float dragMax = evaluateParticleCurve(renderer_LVLDragMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n float dragMin = evaluateParticleCurve(renderer_LVLDragMinCurve, normalizedAge);\n return mix(dragMin, dragMax, dragRand);\n #else\n return dragMax;\n #endif\n #else\n return mix(renderer_LVLDragConstant.x, renderer_LVLDragConstant.y, dragRand);\n #endif\n }\n\n vec3 applyLVLSpeedLimitTF(vec3 velocity, float normalizedAge, float limitRand, float effectiveDampen) {\n #ifdef RENDERER_LVL_SEPARATE_AXES\n vec3 limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConstVector, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMaxCurve, normalizedAge)\n );\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n vec3 minLimitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMinCurve, normalizedAge)\n );\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n vec3 absVel = abs(velocity);\n vec3 excess = max(absVel - limitSpeed, vec3(0.0));\n velocity = sign(velocity) * (absVel - excess * effectiveDampen);\n #else\n float limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConst, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = evaluateParticleCurve(renderer_LVLSpeedMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n float minLimitSpeed = evaluateParticleCurve(renderer_LVLSpeedMinCurve, normalizedAge);\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n float speed = length(velocity);\n if (speed > limitSpeed && speed > 0.0) {\n float excess = speed - limitSpeed;\n velocity = velocity * ((speed - excess * effectiveDampen) / speed);\n }\n #endif\n return velocity;\n }\n\n#endif\n"; // eslint-disable-line
|
|
5504
5526
|
|
|
5505
|
-
var noise_module = "#ifdef RENDERER_NOISE_MODULE_ENABLED\n\n#include <noise_common>\n#include <noise_simplex_3D_grad>\n\nuniform vec4 renderer_NoiseParams; // xyz = strength (constant mode only), w = frequency\nuniform vec4 renderer_NoiseOctaveParams; // x = scrollSpeed, y = octaveCount, z = octaveIntensityMultiplier, w = octaveFrequencyMultiplier\n\n#ifdef RENDERER_NOISE_STRENGTH_CURVE\n uniform vec2 renderer_NoiseStrengthMaxCurveX[4];\n #ifdef RENDERER_NOISE_IS_SEPARATE\n uniform vec2 renderer_NoiseStrengthMaxCurveY[4];\n uniform vec2 renderer_NoiseStrengthMaxCurveZ[4];\n #endif\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n uniform vec2 renderer_NoiseStrengthMinCurveX[4];\n #ifdef RENDERER_NOISE_IS_SEPARATE\n uniform vec2 renderer_NoiseStrengthMinCurveY[4];\n uniform vec2 renderer_NoiseStrengthMinCurveZ[4];\n #endif\n #endif\n#else\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n uniform vec3 renderer_NoiseStrengthMinConst;\n #endif\n#endif\n\nvec3 sampleCurlNoise3D(vec3 coord) {\n float axisOffset = 100.0;\n vec3 gradX = simplexGrad(vec3(coord.z, coord.y, coord.x));\n vec3 gradY = simplexGrad(vec3(coord.x + axisOffset, coord.z, coord.y));\n vec3 gradZ = simplexGrad(vec3(coord.y, coord.x + axisOffset, coord.z));\n return vec3(\n gradZ.x - gradY.y,\n gradX.x - gradZ.y,\n gradY.x - gradX.y\n );\n}\n\nvec3 computeNoiseVelocity(vec3 currentPosition, float normalizedAge) {\n vec3 coord = currentPosition * renderer_NoiseParams.w\n + vec3(renderer_CurrentTime * renderer_NoiseOctaveParams.x);\n\n int octaveCount = int(renderer_NoiseOctaveParams.y);\n float octaveIntensityMultiplier = renderer_NoiseOctaveParams.z;\n float octaveFrequencyMultiplier = renderer_NoiseOctaveParams.w;\n\n vec3 noiseValue = sampleCurlNoise3D(coord);\n float totalAmplitude = 1.0;\n\n // Unrolled octave loop (GLSL ES 1.0 requires constant loop bounds)\n if (octaveCount >= 2) {\n float amplitude = octaveIntensityMultiplier;\n totalAmplitude += amplitude;\n noiseValue += amplitude * sampleCurlNoise3D(coord * octaveFrequencyMultiplier);\n\n if (octaveCount >= 3) {\n amplitude *= octaveIntensityMultiplier;\n totalAmplitude += amplitude;\n noiseValue += amplitude * sampleCurlNoise3D(coord * octaveFrequencyMultiplier * octaveFrequencyMultiplier);\n }\n }\n\n // Evaluate strength (supports Constant, TwoConstants, Curve, TwoCurves).\n vec3 strength;\n #ifdef RENDERER_NOISE_STRENGTH_CURVE\n float sx = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveX, normalizedAge);\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n sx = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveX, normalizedAge), sx, a_Random0.z);\n #endif\n #ifdef RENDERER_NOISE_IS_SEPARATE\n float sy = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveY, normalizedAge);\n float sz = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveZ, normalizedAge);\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n sy = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveY, normalizedAge), sy, a_Random0.z);\n sz = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveZ, normalizedAge), sz, a_Random0.z);\n #endif\n strength = vec3(sx, sy, sz);\n #else\n strength = vec3(sx);\n #endif\n #else\n strength = renderer_NoiseParams.xyz;\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n strength = mix(renderer_NoiseStrengthMinConst, strength, a_Random0.z);\n #endif\n #endif\n\n return (noiseValue / totalAmplitude) * strength;\n}\n\n#endif\n"; // eslint-disable-line
|
|
5506
|
-
|
|
5507
|
-
var particle_feedback_simulation = "// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n#include <noise_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // VOL and Noise overlays are added here (not persisted).\n\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n totalVelocity = localVelocity + volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n #ifdef RENDERER_NOISE_MODULE_ENABLED\n // Use analytical base position (birth + initial velocity * age) instead of\n // a_FeedbackPosition to avoid feedback loop: position → noise → velocity → position\n vec3 noiseBasePos;\n if (renderer_SimulationSpace == 0) {\n noiseBasePos = a_ShapePositionStartLifeTime.xyz + a_DirectionTime.xyz * a_StartSpeed * age;\n } else {\n noiseBasePos = rotationByQuaternions(\n a_ShapePositionStartLifeTime.xyz + a_DirectionTime.xyz * a_StartSpeed * age,\n worldRotation) + a_SimulationWorldPosition;\n }\n totalVelocity += computeNoiseVelocity(noiseBasePos, normalizedAge);\n #endif\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n"; // eslint-disable-line
|
|
5527
|
+
var particle_feedback_simulation = "// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // Only VOL overlay needs to be added here.\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n // Local: integrate in local space\n totalVelocity = localVelocity + volLocal\n + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n // World: integrate in world space\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n"; // eslint-disable-line
|
|
5508
5528
|
|
|
5509
5529
|
var sphere_billboard = "#ifdef RENDERER_MODE_SPHERE_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n\tvec3 sideVector = normalize(cross(camera_Forward, camera_Up));\n\tvec3 upVector = normalize(cross(sideVector, camera_Forward));\n\tcorner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n if (renderer_ThreeDStartRotation) {\n vec3 rotation = radians(vec3(a_StartRotation0.xy, computeParticleRotationFloat(a_StartRotation0.z, age, normalizedAge)));\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, rotation);\n } else {\n float rot = radians(computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge));\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #else\n if (renderer_ThreeDStartRotation) {\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, radians(a_StartRotation0));\n } else {\n float c = cos(radians(a_StartRotation0.x));\n float s = sin(radians(a_StartRotation0.x));\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #endif\n#endif"; // eslint-disable-line
|
|
5510
5530
|
|
|
@@ -5525,7 +5545,6 @@ var ParticleShaderLib = {
|
|
|
5525
5545
|
texture_sheet_animation_module: texture_sheet_animation_module,
|
|
5526
5546
|
force_over_lifetime_module: force_over_lifetime_module,
|
|
5527
5547
|
limit_velocity_over_lifetime_module: limit_velocity_over_lifetime_module,
|
|
5528
|
-
noise_module: noise_module,
|
|
5529
5548
|
particle_feedback_simulation: particle_feedback_simulation,
|
|
5530
5549
|
sphere_billboard: sphere_billboard,
|
|
5531
5550
|
stretched_billboard: stretched_billboard,
|
|
@@ -5567,7 +5586,21 @@ var ShaderLib = _extends({
|
|
|
5567
5586
|
begin_viewdir_frag: begin_viewdir_frag,
|
|
5568
5587
|
mobile_blinnphong_frag: mobile_blinnphong_frag,
|
|
5569
5588
|
noise_common: noise_common,
|
|
5570
|
-
|
|
5589
|
+
noise_cellular_2D: noise_cellular_2D,
|
|
5590
|
+
noise_cellular_2x2: noise_cellular_2x2,
|
|
5591
|
+
noise_cellular_2x2x2: noise_cellular_2x2x2,
|
|
5592
|
+
noise_cellular_3D: noise_cellular_3D,
|
|
5593
|
+
noise_cellular: noise_cellular,
|
|
5594
|
+
noise_perlin_2D: noise_perlin_2D,
|
|
5595
|
+
noise_perlin_3D: noise_perlin_3D,
|
|
5596
|
+
noise_perlin_4D: noise_perlin_4D,
|
|
5597
|
+
noise_perlin: noise_perlin,
|
|
5598
|
+
noise_psrd_2D: noise_psrd_2D,
|
|
5599
|
+
noise_simplex_2D: noise_simplex_2D,
|
|
5600
|
+
noise_simplex_3D_grad: noise_simplex_3D_grad,
|
|
5601
|
+
noise_simplex_3D: noise_simplex_3D,
|
|
5602
|
+
noise_simplex_4D: noise_simplex_4D,
|
|
5603
|
+
noise_simplex: noise_simplex
|
|
5571
5604
|
}, ShadowLib, PBRShaderLib, {
|
|
5572
5605
|
normal_get: normal_get
|
|
5573
5606
|
}, ParticleShaderLib);
|
|
@@ -23882,13 +23915,6 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
23882
23915
|
if (!splits.length) {
|
|
23883
23916
|
return this;
|
|
23884
23917
|
}
|
|
23885
|
-
// Some imported animation clips are normalized to include the single scene root
|
|
23886
|
-
// name (for example "mixamorig:Hips/..."), while the Animator may already sit on
|
|
23887
|
-
// that root entity. Accept a self-name prefix so wrapped model roots and
|
|
23888
|
-
// standalone single-root clips resolve through the same path convention.
|
|
23889
|
-
if (splits[0] === this.name) {
|
|
23890
|
-
return splits.length === 1 ? this : Entity._findChildByName(this, 0, splits, 1);
|
|
23891
|
-
}
|
|
23892
23918
|
return Entity._findChildByName(this, 0, splits, 0);
|
|
23893
23919
|
};
|
|
23894
23920
|
/**
|
|
@@ -23909,11 +23935,17 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
23909
23935
|
for(var i = children.length - 1; i >= 0; i--){
|
|
23910
23936
|
var child = children[i];
|
|
23911
23937
|
child._parent = null;
|
|
23938
|
+
child._siblingIndex = -1;
|
|
23939
|
+
// Dispatch `Child` to the old parent before `_processInActive` (which unregisters
|
|
23940
|
+
// UI listeners via `cleanRootCanvas`), so subscribers such as UICanvas can react
|
|
23941
|
+
// to the hierarchy change while still attached.
|
|
23942
|
+
this._dispatchModify(EntityModifyFlags.Child, this);
|
|
23912
23943
|
var activeChangeFlag = ActiveChangeFlag.None;
|
|
23913
23944
|
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
23914
23945
|
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
23915
23946
|
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
23916
23947
|
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
23948
|
+
child._setParentChange();
|
|
23917
23949
|
}
|
|
23918
23950
|
children.length = 0;
|
|
23919
23951
|
};
|
|
@@ -24850,7 +24882,8 @@ PrimitiveChunk.subMeshPool = new ReturnableObjectPool(SubMesh, 10);
|
|
|
24850
24882
|
/** Plain text. */ AssetType["Text"] = "Text";
|
|
24851
24883
|
/** JSON. */ AssetType["JSON"] = "JSON";
|
|
24852
24884
|
/** ArrayBuffer. */ AssetType["Buffer"] = "Buffer";
|
|
24853
|
-
/** Texture. */ AssetType["
|
|
24885
|
+
/** 2D Texture. */ AssetType["Texture2D"] = "Texture2D";
|
|
24886
|
+
/** Cube Texture. */ AssetType["TextureCube"] = "TextureCube";
|
|
24854
24887
|
/** Material. */ AssetType["Material"] = "Material";
|
|
24855
24888
|
/** Shader. */ AssetType["Shader"] = "Shader";
|
|
24856
24889
|
/** Mesh. */ AssetType["Mesh"] = "Mesh";
|
|
@@ -25012,7 +25045,20 @@ var SafeLoopArray = /*#__PURE__*/ function() {
|
|
|
25012
25045
|
*/ _proto.loadScene = function loadScene(url, destroyOldScene) {
|
|
25013
25046
|
var _this = this;
|
|
25014
25047
|
if (destroyOldScene === void 0) destroyOldScene = true;
|
|
25015
|
-
var
|
|
25048
|
+
var resourceManager = this.engine.resourceManager;
|
|
25049
|
+
// Evict the Scene asset cache for managed scenes about to be destroyed, so a fresh Scene
|
|
25050
|
+
// instance is created by the loader instead of returning the same instance we're about to
|
|
25051
|
+
// destroy (self-destroy would leave the active scene in a zombie state).
|
|
25052
|
+
if (destroyOldScene) {
|
|
25053
|
+
var _resourceManager__virtualPathResourceMap_url;
|
|
25054
|
+
var _resourceManager__virtualPathResourceMap_url_path;
|
|
25055
|
+
var realPath = (_resourceManager__virtualPathResourceMap_url_path = (_resourceManager__virtualPathResourceMap_url = resourceManager._virtualPathResourceMap[url]) == null ? void 0 : _resourceManager__virtualPathResourceMap_url.path) != null ? _resourceManager__virtualPathResourceMap_url_path : url;
|
|
25056
|
+
var cached = resourceManager.getFromCache(realPath);
|
|
25057
|
+
if (cached && this._scenes.indexOf(cached) !== -1) {
|
|
25058
|
+
resourceManager._deleteAsset(cached);
|
|
25059
|
+
}
|
|
25060
|
+
}
|
|
25061
|
+
var scenePromise = resourceManager.load({
|
|
25016
25062
|
url: url,
|
|
25017
25063
|
type: AssetType.Scene
|
|
25018
25064
|
});
|
|
@@ -27087,7 +27133,7 @@ var depthOnlyVs = "#define MATERIAL_OMIT_NORMAL\n#include <common>\n#include <co
|
|
|
27087
27133
|
|
|
27088
27134
|
var particleFs = "#include <common>\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D material_BaseTexture;\nuniform vec4 material_BaseColor;\n \nuniform mediump vec3 material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n\tvarying vec4 v_MeshColor;\n#endif\n\nvoid main() {\n\tvec4 color = material_BaseColor * v_Color;\n\n\t#if defined(RENDERER_MODE_MESH) && defined(RENDERER_ENABLE_VERTEXCOLOR)\n\t\tcolor *= v_MeshColor;\n\t#endif\n\n\t#ifdef MATERIAL_HAS_BASETEXTURE\n\t\tcolor *= texture2DSRGB(material_BaseTexture, v_TextureCoordinate);\n\t#endif\n\t\n\t// Emissive\n\tvec3 emissiveRadiance = material_EmissiveColor;\n\t#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n\t\temissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_TextureCoordinate).rgb;\n\t#endif\n\n\tcolor.rgb += emissiveRadiance;\n\n\tgl_FragColor = color;\n}"; // eslint-disable-line
|
|
27089
27135
|
|
|
27090
|
-
var particleVs = "#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\n#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE) || defined(RENDERER_LVL_MODULE_ENABLED)\n attribute vec4 a_Random2;\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\n#ifdef RENDERER_TRANSFORM_FEEDBACK\n attribute vec3 a_FeedbackPosition;\n attribute vec3 a_FeedbackVelocity;\n#endif\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\n
|
|
27136
|
+
var particleVs = "#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\n#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE) || defined(RENDERER_LVL_MODULE_ENABLED)\n attribute vec4 a_Random2;\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\n#ifdef RENDERER_TRANSFORM_FEEDBACK\n attribute vec3 a_FeedbackPosition;\n attribute vec3 a_FeedbackVelocity;\n#endif\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\n\nvec3 computeParticlePosition(in vec3 startVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, inout vec3 localVelocity, inout vec3 worldVelocity) {\n vec3 startPosition = startVelocity * age;\n\n vec3 finalPosition;\n vec3 localPositionOffset = startPosition;\n vec3 worldPositionOffset;\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 lifeVelocity; \n vec3 velocityPositionOffset = computeVelocityPositionOffset(normalizedAge, age, lifeVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += lifeVelocity;\n localPositionOffset += velocityPositionOffset;\n } else {\n worldVelocity += lifeVelocity;\n worldPositionOffset += velocityPositionOffset;\n }\n #endif\n\n #ifdef _FOL_MODULE_ENABLED\n vec3 forceVelocity;\n vec3 forcePositionOffset = computeForcePositionOffset(normalizedAge, age, forceVelocity);\n if (renderer_FOLSpace == 0) {\n localVelocity += forceVelocity;\n localPositionOffset += forcePositionOffset;\n } else {\n worldVelocity += forceVelocity;\n worldPositionOffset += forcePositionOffset;\n }\n #endif\n\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + localPositionOffset, worldRotation) + worldPositionOffset;\n\n if (renderer_SimulationSpace == 0) {\n finalPosition = finalPosition + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n\t finalPosition = finalPosition + a_SimulationWorldPosition;\n\t}\n\n finalPosition += 0.5 * gravityVelocity * age;\n\n return finalPosition;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n // normalizedAge >= 0.0: skip stale TF slots whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 0.0 && normalizedAge < 1.0) {\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n vec3 localVelocity;\n vec3 worldVelocity;\n\n #ifdef RENDERER_TRANSFORM_FEEDBACK\n // Transform Feedback mode: position in simulation space (local or world).\n // Local: transform to world; World: use directly.\n vec3 center;\n if (renderer_SimulationSpace == 0) {\n center = rotationByQuaternions(a_FeedbackPosition, worldRotation) + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n center = a_FeedbackPosition;\n }\n localVelocity = a_FeedbackVelocity;\n worldVelocity = vec3(0.0);\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 instantVOLVelocity;\n computeVelocityPositionOffset(normalizedAge, age, instantVOLVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += instantVOLVelocity;\n } else {\n worldVelocity += instantVOLVelocity;\n }\n #endif\n #else\n // Original analytical path\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n localVelocity = startVelocity;\n worldVelocity = gravityVelocity;\n vec3 center = computeParticlePosition(startVelocity, age, normalizedAge, gravityVelocity, worldRotation, localVelocity, worldVelocity);\n #endif\n\n #include <sphere_billboard>\n #include <stretched_billboard>\n #include <horizontal_billboard>\n #include <vertical_billboard>\n #include <particle_mesh>\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4(center, 1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec2 simulateUV;\n #if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n simulateUV = a_CornerTextureCoordinate.zw * a_SimulationUV.xy + a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #ifdef RENDERER_MODE_MESH\n simulateUV = a_SimulationUV.zw + TEXCOORD_0 * a_SimulationUV.xy;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #endif\n } else {\n\t gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Discard use out of X(-1,1),Y(-1,1),Z(0,1)\n }\n}"; // eslint-disable-line
|
|
27091
27137
|
|
|
27092
27138
|
var pbrSpecularFs = "#include <common>\n#include <camera_declare>\n\n#include <FogFragmentDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n}\n"; // eslint-disable-line
|
|
27093
27139
|
|
|
@@ -27101,7 +27147,7 @@ var shadowMapVs = "#include <common>\n#include <common_vert>\n#include <blendSha
|
|
|
27101
27147
|
|
|
27102
27148
|
var skyboxFs = "#include <common>\nuniform samplerCube material_CubeTexture;\n\nvarying vec3 v_cubeUV;\nuniform float material_Exposure;\nuniform vec4 material_TintColor;\n\nvoid main() {\n vec4 textureColor = textureCube( material_CubeTexture, v_cubeUV );\n\n #ifdef ENGINE_NO_SRGB\n textureColor = sRGBToLinear(textureColor);\n #endif\n\n textureColor.rgb *= material_Exposure * material_TintColor.rgb;\n \n gl_FragColor = textureColor;\n}\n"; // eslint-disable-line
|
|
27103
27149
|
|
|
27104
|
-
var skyboxVs = "#include <common_vert>\n\nuniform mat4 camera_VPMat;\n\nvarying vec3 v_cubeUV;\nuniform float material_Rotation;\n\nvec4 rotateY(vec4 v, float angle) {\n\tconst float deg2rad = 3.1415926 / 180.0;\n\tfloat radian = angle * deg2rad;\n\tfloat sina = sin(radian);\n\tfloat cosa = cos(radian);\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\n\treturn vec4(m * v.xz, v.yw).xzyw;\n}\n\nvoid main() {\n v_cubeUV = POSITION
|
|
27150
|
+
var skyboxVs = "#include <common_vert>\n\nuniform mat4 camera_VPMat;\n\nvarying vec3 v_cubeUV;\nuniform float material_Rotation;\n\nvec4 rotateY(vec4 v, float angle) {\n\tconst float deg2rad = 3.1415926 / 180.0;\n\tfloat radian = angle * deg2rad;\n\tfloat sina = sin(radian);\n\tfloat cosa = cos(radian);\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\n\treturn vec4(m * v.xz, v.yw).xzyw;\n}\n\nvoid main() {\n v_cubeUV = vec3( -POSITION.x, POSITION.yz ); // TextureCube is left-hand,so x need inverse\n gl_Position = camera_VPMat * rotateY(vec4(POSITION, 1.0), material_Rotation);\n}\n"; // eslint-disable-line
|
|
27105
27151
|
|
|
27106
27152
|
var spriteMaskFs = "uniform sampler2D renderer_MaskTexture;\nuniform float renderer_MaskAlphaCutoff;\nvarying vec2 v_uv;\n\nvoid main()\n{\n vec4 color = texture2D(renderer_MaskTexture, v_uv);\n if (color.a < renderer_MaskAlphaCutoff) {\n discard;\n }\n\n gl_FragColor = color;\n}\n"; // eslint-disable-line
|
|
27107
27153
|
|
|
@@ -34659,7 +34705,6 @@ ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName
|
|
|
34659
34705
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 2759560269] = "GravityModifier";
|
|
34660
34706
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["ForceOverLifetime"] = 3875246972] = "ForceOverLifetime";
|
|
34661
34707
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["LimitVelocityOverLifetime"] = 3047300990] = "LimitVelocityOverLifetime";
|
|
34662
|
-
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Noise"] = 4105357473] = "Noise";
|
|
34663
34708
|
return ParticleRandomSubSeeds;
|
|
34664
34709
|
}({});
|
|
34665
34710
|
|
|
@@ -35455,48 +35500,30 @@ __decorate([
|
|
|
35455
35500
|
}
|
|
35456
35501
|
this._emitBySubBurst(middleTime, playTime, duration);
|
|
35457
35502
|
} else {
|
|
35458
|
-
|
|
35459
|
-
this._emitBySubBurst(lastPlayTime, Math.min(playTime, duration), duration);
|
|
35460
|
-
}
|
|
35503
|
+
this._emitBySubBurst(lastPlayTime, playTime, duration);
|
|
35461
35504
|
}
|
|
35462
35505
|
};
|
|
35463
35506
|
_proto._emitBySubBurst = function _emitBySubBurst(lastPlayTime, playTime, duration) {
|
|
35464
|
-
var
|
|
35507
|
+
var generator = this._generator;
|
|
35508
|
+
var rand = this._burstRand;
|
|
35509
|
+
var bursts = this.bursts;
|
|
35510
|
+
// Calculate the relative time of the burst
|
|
35465
35511
|
var baseTime = Math.floor(lastPlayTime / duration) * duration;
|
|
35466
35512
|
var startTime = lastPlayTime % duration;
|
|
35467
35513
|
var endTime = startTime + (playTime - lastPlayTime);
|
|
35468
|
-
var pendingIndex = -1;
|
|
35469
35514
|
var index = this._currentBurstIndex;
|
|
35470
35515
|
for(var n = bursts.length; index < n; index++){
|
|
35471
35516
|
var burst = bursts[index];
|
|
35472
35517
|
var burstTime = burst.time;
|
|
35473
|
-
if (burstTime
|
|
35474
|
-
|
|
35475
|
-
|
|
35476
|
-
|
|
35477
|
-
|
|
35478
|
-
|
|
35479
|
-
} else {
|
|
35480
|
-
var maxCycles = cycles === Infinity ? Math.ceil((duration - burstTime) / repeatInterval) : cycles;
|
|
35481
|
-
// Absorb float drift: (startTime - burstTime) / repeatInterval may land at cycle + 1e-15
|
|
35482
|
-
// when it should be exactly cycle, and ceil would then skip ahead to cycle + 1.
|
|
35483
|
-
var tolerance = engineMath.MathUtil.zeroTolerance;
|
|
35484
|
-
var lastCycle = Math.ceil((endTime - burstTime) / repeatInterval - tolerance) - 1;
|
|
35485
|
-
var first = Math.max(0, Math.ceil((startTime - burstTime) / repeatInterval - tolerance));
|
|
35486
|
-
var last = Math.min(maxCycles - 1, lastCycle);
|
|
35487
|
-
for(var c = first; c <= last; c++){
|
|
35488
|
-
var effectiveTime = burstTime + c * repeatInterval;
|
|
35489
|
-
if (effectiveTime >= duration) break;
|
|
35490
|
-
generator._emit(baseTime + effectiveTime, burst.count.evaluate(undefined, rand.random()));
|
|
35491
|
-
}
|
|
35492
|
-
// `_currentBurstIndex` caches next frame's scan start, so only the earliest unfinished
|
|
35493
|
-
// burst can be the entry point — skipping past it would drop its remaining cycles
|
|
35494
|
-
if (pendingIndex < 0 && lastCycle < maxCycles - 1) {
|
|
35495
|
-
pendingIndex = index;
|
|
35496
|
-
}
|
|
35518
|
+
if (burstTime > endTime) {
|
|
35519
|
+
break;
|
|
35520
|
+
}
|
|
35521
|
+
if (burstTime >= startTime) {
|
|
35522
|
+
var count = burst.count.evaluate(undefined, rand.random());
|
|
35523
|
+
generator._emit(baseTime + burstTime, count);
|
|
35497
35524
|
}
|
|
35498
35525
|
}
|
|
35499
|
-
this._currentBurstIndex =
|
|
35526
|
+
this._currentBurstIndex = index;
|
|
35500
35527
|
};
|
|
35501
35528
|
_create_class(EmissionModule, [
|
|
35502
35529
|
{
|
|
@@ -36061,7 +36088,7 @@ __decorate([
|
|
|
36061
36088
|
return;
|
|
36062
36089
|
}
|
|
36063
36090
|
this._enabled = value;
|
|
36064
|
-
this._generator._setTransformFeedback();
|
|
36091
|
+
this._generator._setTransformFeedback(value);
|
|
36065
36092
|
this._generator._renderer._onGeneratorParamsChanged();
|
|
36066
36093
|
}
|
|
36067
36094
|
}
|
|
@@ -36147,9 +36174,9 @@ __decorate([
|
|
|
36147
36174
|
/**
|
|
36148
36175
|
* Control how Particle Generator apply transform scale.
|
|
36149
36176
|
*/ var ParticleScaleMode = /*#__PURE__*/ function(ParticleScaleMode) {
|
|
36150
|
-
/** Scale the Particle Generator using the
|
|
36151
|
-
/** Scale the Particle Generator using only its own transform scale
|
|
36152
|
-
/**
|
|
36177
|
+
/** Scale the Particle Generator using the entire transform hierarchy. */ ParticleScaleMode[ParticleScaleMode["Hierarchy"] = 0] = "Hierarchy";
|
|
36178
|
+
/** Scale the Particle Generator using only its own transform scale. (Ignores parent scale). */ ParticleScaleMode[ParticleScaleMode["Local"] = 1] = "Local";
|
|
36179
|
+
/** Only apply transform scale to the shape component, which controls where particles are spawned, but does not affect their size or movement. */ ParticleScaleMode[ParticleScaleMode["World"] = 2] = "World";
|
|
36153
36180
|
return ParticleScaleMode;
|
|
36154
36181
|
}({});
|
|
36155
36182
|
|
|
@@ -36201,8 +36228,8 @@ var MainModule = /*#__PURE__*/ function() {
|
|
|
36201
36228
|
*/ _proto._getPositionScale = function _getPositionScale() {
|
|
36202
36229
|
var transform = this._generator._renderer.entity.transform;
|
|
36203
36230
|
switch(this.scalingMode){
|
|
36231
|
+
case ParticleScaleMode.Hierarchy:
|
|
36204
36232
|
case ParticleScaleMode.World:
|
|
36205
|
-
case ParticleScaleMode.Shape:
|
|
36206
36233
|
return transform.lossyWorldScale;
|
|
36207
36234
|
case ParticleScaleMode.Local:
|
|
36208
36235
|
return transform.scale;
|
|
@@ -36226,7 +36253,7 @@ var MainModule = /*#__PURE__*/ function() {
|
|
|
36226
36253
|
throw new Error("ParticleRenderer: SimulationSpace value is invalid.");
|
|
36227
36254
|
}
|
|
36228
36255
|
switch(this.scalingMode){
|
|
36229
|
-
case ParticleScaleMode.
|
|
36256
|
+
case ParticleScaleMode.Hierarchy:
|
|
36230
36257
|
var scale = transform.lossyWorldScale;
|
|
36231
36258
|
shaderData.setVector3(MainModule._positionScale, scale);
|
|
36232
36259
|
shaderData.setVector3(MainModule._sizeScale, scale);
|
|
@@ -36236,7 +36263,7 @@ var MainModule = /*#__PURE__*/ function() {
|
|
|
36236
36263
|
shaderData.setVector3(MainModule._positionScale, scale);
|
|
36237
36264
|
shaderData.setVector3(MainModule._sizeScale, scale);
|
|
36238
36265
|
break;
|
|
36239
|
-
case ParticleScaleMode.
|
|
36266
|
+
case ParticleScaleMode.World:
|
|
36240
36267
|
shaderData.setVector3(MainModule._positionScale, transform.lossyWorldScale);
|
|
36241
36268
|
shaderData.setVector3(MainModule._sizeScale, MainModule._vector3One);
|
|
36242
36269
|
break;
|
|
@@ -37007,298 +37034,6 @@ __decorate([
|
|
|
37007
37034
|
ignoreClone
|
|
37008
37035
|
], TextureSheetAnimationModule.prototype, "_onTilingChanged", null);
|
|
37009
37036
|
|
|
37010
|
-
/**
|
|
37011
|
-
* Noise module for particle system.
|
|
37012
|
-
* Adds simplex noise-based turbulence displacement to particles.
|
|
37013
|
-
*/ var NoiseModule = /*#__PURE__*/ function(ParticleGeneratorModule) {
|
|
37014
|
-
_inherits(NoiseModule, ParticleGeneratorModule);
|
|
37015
|
-
function NoiseModule(generator) {
|
|
37016
|
-
var _this;
|
|
37017
|
-
_this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._noiseRand = new engineMath.Rand(0, ParticleRandomSubSeeds.Noise), _this._noiseParams = new engineMath.Vector4(), _this._noiseOctaveParams = new engineMath.Vector4(), _this._strengthMinConst = new engineMath.Vector3(), _this._scrollSpeed = 0, _this._separateAxes = false, _this._frequency = 0.5, _this._octaveCount = 1, _this._octaveIntensityMultiplier = 0.5, _this._octaveFrequencyMultiplier = 2.0;
|
|
37018
|
-
_this.strengthX = new ParticleCompositeCurve(1);
|
|
37019
|
-
_this.strengthY = new ParticleCompositeCurve(1);
|
|
37020
|
-
_this.strengthZ = new ParticleCompositeCurve(1);
|
|
37021
|
-
return _this;
|
|
37022
|
-
}
|
|
37023
|
-
var _proto = NoiseModule.prototype;
|
|
37024
|
-
/**
|
|
37025
|
-
* @internal
|
|
37026
|
-
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
37027
|
-
var enabledMacro = null;
|
|
37028
|
-
var strengthCurveMacro = null;
|
|
37029
|
-
var strengthIsRandomTwoMacro = null;
|
|
37030
|
-
var separateAxesMacro = null;
|
|
37031
|
-
if (this.enabled) {
|
|
37032
|
-
enabledMacro = NoiseModule._enabledMacro;
|
|
37033
|
-
var strengthX = this._strengthX;
|
|
37034
|
-
var strengthY = this._strengthY;
|
|
37035
|
-
var strengthZ = this._strengthZ;
|
|
37036
|
-
var separateAxes = this._separateAxes;
|
|
37037
|
-
// Determine strength curve mode (following SOL pattern)
|
|
37038
|
-
var isRandomCurveMode = separateAxes ? strengthX.mode === ParticleCurveMode.TwoCurves && strengthY.mode === ParticleCurveMode.TwoCurves && strengthZ.mode === ParticleCurveMode.TwoCurves : strengthX.mode === ParticleCurveMode.TwoCurves;
|
|
37039
|
-
var isCurveMode = isRandomCurveMode || (separateAxes ? strengthX.mode === ParticleCurveMode.Curve && strengthY.mode === ParticleCurveMode.Curve && strengthZ.mode === ParticleCurveMode.Curve : strengthX.mode === ParticleCurveMode.Curve);
|
|
37040
|
-
var isRandomConstMode = separateAxes ? strengthX.mode === ParticleCurveMode.TwoConstants && strengthY.mode === ParticleCurveMode.TwoConstants && strengthZ.mode === ParticleCurveMode.TwoConstants : strengthX.mode === ParticleCurveMode.TwoConstants;
|
|
37041
|
-
// noiseParams.w = frequency (always needed)
|
|
37042
|
-
var noiseParams = this._noiseParams;
|
|
37043
|
-
if (isCurveMode) {
|
|
37044
|
-
// Curve/TwoCurves: encode curve data as float arrays
|
|
37045
|
-
shaderData.setFloatArray(NoiseModule._strengthMaxCurveXProperty, strengthX.curveMax._getTypeArray());
|
|
37046
|
-
if (separateAxes) {
|
|
37047
|
-
shaderData.setFloatArray(NoiseModule._strengthMaxCurveYProperty, strengthY.curveMax._getTypeArray());
|
|
37048
|
-
shaderData.setFloatArray(NoiseModule._strengthMaxCurveZProperty, strengthZ.curveMax._getTypeArray());
|
|
37049
|
-
}
|
|
37050
|
-
if (isRandomCurveMode) {
|
|
37051
|
-
shaderData.setFloatArray(NoiseModule._strengthMinCurveXProperty, strengthX.curveMin._getTypeArray());
|
|
37052
|
-
if (separateAxes) {
|
|
37053
|
-
shaderData.setFloatArray(NoiseModule._strengthMinCurveYProperty, strengthY.curveMin._getTypeArray());
|
|
37054
|
-
shaderData.setFloatArray(NoiseModule._strengthMinCurveZProperty, strengthZ.curveMin._getTypeArray());
|
|
37055
|
-
}
|
|
37056
|
-
strengthIsRandomTwoMacro = NoiseModule._strengthIsRandomTwoMacro;
|
|
37057
|
-
}
|
|
37058
|
-
strengthCurveMacro = NoiseModule._strengthCurveMacro;
|
|
37059
|
-
// xyz unused in curve mode, just set frequency
|
|
37060
|
-
noiseParams.set(0, 0, 0, this._frequency);
|
|
37061
|
-
} else {
|
|
37062
|
-
// Constant/TwoConstants: pack strength into noiseParams.xyz
|
|
37063
|
-
if (separateAxes) {
|
|
37064
|
-
noiseParams.set(strengthX.constantMax, strengthY.constantMax, strengthZ.constantMax, this._frequency);
|
|
37065
|
-
} else {
|
|
37066
|
-
var s = strengthX.constantMax;
|
|
37067
|
-
noiseParams.set(s, s, s, this._frequency);
|
|
37068
|
-
}
|
|
37069
|
-
if (isRandomConstMode) {
|
|
37070
|
-
var minConst = this._strengthMinConst;
|
|
37071
|
-
if (separateAxes) {
|
|
37072
|
-
minConst.set(strengthX.constantMin, strengthY.constantMin, strengthZ.constantMin);
|
|
37073
|
-
} else {
|
|
37074
|
-
var sMin = strengthX.constantMin;
|
|
37075
|
-
minConst.set(sMin, sMin, sMin);
|
|
37076
|
-
}
|
|
37077
|
-
shaderData.setVector3(NoiseModule._strengthMinConstProperty, minConst);
|
|
37078
|
-
strengthIsRandomTwoMacro = NoiseModule._strengthIsRandomTwoMacro;
|
|
37079
|
-
}
|
|
37080
|
-
}
|
|
37081
|
-
shaderData.setVector4(NoiseModule._noiseProperty, noiseParams);
|
|
37082
|
-
if (separateAxes) {
|
|
37083
|
-
separateAxesMacro = NoiseModule._separateAxesMacro;
|
|
37084
|
-
}
|
|
37085
|
-
var noiseOctaveParams = this._noiseOctaveParams;
|
|
37086
|
-
noiseOctaveParams.set(this._scrollSpeed, this._octaveCount, this._octaveIntensityMultiplier, this._octaveFrequencyMultiplier);
|
|
37087
|
-
shaderData.setVector4(NoiseModule._noiseOctaveProperty, noiseOctaveParams);
|
|
37088
|
-
}
|
|
37089
|
-
this._enabledModuleMacro = this._enableMacro(shaderData, this._enabledModuleMacro, enabledMacro);
|
|
37090
|
-
this._strengthCurveModeMacro = this._enableMacro(shaderData, this._strengthCurveModeMacro, strengthCurveMacro);
|
|
37091
|
-
this._strengthIsRandomTwoModeMacro = this._enableMacro(shaderData, this._strengthIsRandomTwoModeMacro, strengthIsRandomTwoMacro);
|
|
37092
|
-
this._separateAxesModeMacro = this._enableMacro(shaderData, this._separateAxesModeMacro, separateAxesMacro);
|
|
37093
|
-
};
|
|
37094
|
-
/**
|
|
37095
|
-
* @internal
|
|
37096
|
-
*/ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
|
|
37097
|
-
this._noiseRand.reset(seed, ParticleRandomSubSeeds.Noise);
|
|
37098
|
-
};
|
|
37099
|
-
_create_class(NoiseModule, [
|
|
37100
|
-
{
|
|
37101
|
-
key: "separateAxes",
|
|
37102
|
-
get: /**
|
|
37103
|
-
* Specifies whether the strength is separate on each axis, when disabled, only `strength` is used.
|
|
37104
|
-
*/ function get() {
|
|
37105
|
-
return this._separateAxes;
|
|
37106
|
-
},
|
|
37107
|
-
set: function set(value) {
|
|
37108
|
-
if (value !== this._separateAxes) {
|
|
37109
|
-
this._separateAxes = value;
|
|
37110
|
-
this._generator._renderer._onGeneratorParamsChanged();
|
|
37111
|
-
}
|
|
37112
|
-
}
|
|
37113
|
-
},
|
|
37114
|
-
{
|
|
37115
|
-
key: "strengthX",
|
|
37116
|
-
get: /**
|
|
37117
|
-
* Noise strength. When `separateAxes` is disabled, applies to all axes.
|
|
37118
|
-
* When `separateAxes` is enabled, applies only to x axis.
|
|
37119
|
-
*/ function get() {
|
|
37120
|
-
return this._strengthX;
|
|
37121
|
-
},
|
|
37122
|
-
set: function set(value) {
|
|
37123
|
-
var lastValue = this._strengthX;
|
|
37124
|
-
if (value !== lastValue) {
|
|
37125
|
-
this._strengthX = value;
|
|
37126
|
-
this._onCompositeCurveChange(lastValue, value);
|
|
37127
|
-
}
|
|
37128
|
-
}
|
|
37129
|
-
},
|
|
37130
|
-
{
|
|
37131
|
-
key: "strengthY",
|
|
37132
|
-
get: /**
|
|
37133
|
-
* Noise strength for y axis, used when `separateAxes` is enabled.
|
|
37134
|
-
*/ function get() {
|
|
37135
|
-
return this._strengthY;
|
|
37136
|
-
},
|
|
37137
|
-
set: function set(value) {
|
|
37138
|
-
var lastValue = this._strengthY;
|
|
37139
|
-
if (value !== lastValue) {
|
|
37140
|
-
this._strengthY = value;
|
|
37141
|
-
this._onCompositeCurveChange(lastValue, value);
|
|
37142
|
-
}
|
|
37143
|
-
}
|
|
37144
|
-
},
|
|
37145
|
-
{
|
|
37146
|
-
key: "strengthZ",
|
|
37147
|
-
get: /**
|
|
37148
|
-
* Noise strength for z axis, used when `separateAxes` is enabled.
|
|
37149
|
-
*/ function get() {
|
|
37150
|
-
return this._strengthZ;
|
|
37151
|
-
},
|
|
37152
|
-
set: function set(value) {
|
|
37153
|
-
var lastValue = this._strengthZ;
|
|
37154
|
-
if (value !== lastValue) {
|
|
37155
|
-
this._strengthZ = value;
|
|
37156
|
-
this._onCompositeCurveChange(lastValue, value);
|
|
37157
|
-
}
|
|
37158
|
-
}
|
|
37159
|
-
},
|
|
37160
|
-
{
|
|
37161
|
-
key: "frequency",
|
|
37162
|
-
get: /**
|
|
37163
|
-
* Noise spatial frequency.
|
|
37164
|
-
*/ function get() {
|
|
37165
|
-
return this._frequency;
|
|
37166
|
-
},
|
|
37167
|
-
set: function set(value) {
|
|
37168
|
-
value = Math.max(1e-6, value);
|
|
37169
|
-
if (value !== this._frequency) {
|
|
37170
|
-
this._frequency = value;
|
|
37171
|
-
this._generator._renderer._onGeneratorParamsChanged();
|
|
37172
|
-
}
|
|
37173
|
-
}
|
|
37174
|
-
},
|
|
37175
|
-
{
|
|
37176
|
-
key: "scrollSpeed",
|
|
37177
|
-
get: /**
|
|
37178
|
-
* Noise field scroll speed over time.
|
|
37179
|
-
*/ function get() {
|
|
37180
|
-
return this._scrollSpeed;
|
|
37181
|
-
},
|
|
37182
|
-
set: function set(value) {
|
|
37183
|
-
if (value !== this._scrollSpeed) {
|
|
37184
|
-
this._scrollSpeed = value;
|
|
37185
|
-
this._generator._renderer._onGeneratorParamsChanged();
|
|
37186
|
-
}
|
|
37187
|
-
}
|
|
37188
|
-
},
|
|
37189
|
-
{
|
|
37190
|
-
key: "octaveCount",
|
|
37191
|
-
get: /**
|
|
37192
|
-
* Number of noise octave layers (1-3).
|
|
37193
|
-
*/ function get() {
|
|
37194
|
-
return this._octaveCount;
|
|
37195
|
-
},
|
|
37196
|
-
set: function set(value) {
|
|
37197
|
-
value = Math.max(1, Math.min(3, Math.floor(value)));
|
|
37198
|
-
if (value !== this._octaveCount) {
|
|
37199
|
-
this._octaveCount = value;
|
|
37200
|
-
this._generator._renderer._onGeneratorParamsChanged();
|
|
37201
|
-
}
|
|
37202
|
-
}
|
|
37203
|
-
},
|
|
37204
|
-
{
|
|
37205
|
-
key: "octaveIntensityMultiplier",
|
|
37206
|
-
get: /**
|
|
37207
|
-
* Intensity multiplier for each successive octave, only effective when `octaveCount` > 1.
|
|
37208
|
-
* Each layer's contribution is scaled by this factor relative to the previous layer, range [0, 1].
|
|
37209
|
-
*/ function get() {
|
|
37210
|
-
return this._octaveIntensityMultiplier;
|
|
37211
|
-
},
|
|
37212
|
-
set: function set(value) {
|
|
37213
|
-
value = Math.max(0, Math.min(1, value));
|
|
37214
|
-
if (value !== this._octaveIntensityMultiplier) {
|
|
37215
|
-
this._octaveIntensityMultiplier = value;
|
|
37216
|
-
this._generator._renderer._onGeneratorParamsChanged();
|
|
37217
|
-
}
|
|
37218
|
-
}
|
|
37219
|
-
},
|
|
37220
|
-
{
|
|
37221
|
-
key: "octaveFrequencyMultiplier",
|
|
37222
|
-
get: /**
|
|
37223
|
-
* Frequency multiplier for each successive octave, only effective when `octaveCount` > 1.
|
|
37224
|
-
* Each layer samples at this multiple of the previous layer's frequency, range [1, 4].
|
|
37225
|
-
*/ function get() {
|
|
37226
|
-
return this._octaveFrequencyMultiplier;
|
|
37227
|
-
},
|
|
37228
|
-
set: function set(value) {
|
|
37229
|
-
value = Math.max(1, Math.min(4, value));
|
|
37230
|
-
if (value !== this._octaveFrequencyMultiplier) {
|
|
37231
|
-
this._octaveFrequencyMultiplier = value;
|
|
37232
|
-
this._generator._renderer._onGeneratorParamsChanged();
|
|
37233
|
-
}
|
|
37234
|
-
}
|
|
37235
|
-
},
|
|
37236
|
-
{
|
|
37237
|
-
key: "enabled",
|
|
37238
|
-
get: function get() {
|
|
37239
|
-
return this._enabled;
|
|
37240
|
-
},
|
|
37241
|
-
set: function set(value) {
|
|
37242
|
-
if (value !== this._enabled) {
|
|
37243
|
-
if (value && !this._generator._renderer.engine._hardwareRenderer.isWebGL2) {
|
|
37244
|
-
return;
|
|
37245
|
-
}
|
|
37246
|
-
this._enabled = value;
|
|
37247
|
-
this._generator._setTransformFeedback();
|
|
37248
|
-
this._generator._renderer._onGeneratorParamsChanged();
|
|
37249
|
-
}
|
|
37250
|
-
}
|
|
37251
|
-
}
|
|
37252
|
-
]);
|
|
37253
|
-
return NoiseModule;
|
|
37254
|
-
}(ParticleGeneratorModule);
|
|
37255
|
-
NoiseModule._enabledMacro = ShaderMacro.getByName("RENDERER_NOISE_MODULE_ENABLED");
|
|
37256
|
-
NoiseModule._strengthCurveMacro = ShaderMacro.getByName("RENDERER_NOISE_STRENGTH_CURVE");
|
|
37257
|
-
NoiseModule._strengthIsRandomTwoMacro = ShaderMacro.getByName("RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO");
|
|
37258
|
-
NoiseModule._separateAxesMacro = ShaderMacro.getByName("RENDERER_NOISE_IS_SEPARATE");
|
|
37259
|
-
NoiseModule._noiseProperty = ShaderProperty.getByName("renderer_NoiseParams");
|
|
37260
|
-
NoiseModule._noiseOctaveProperty = ShaderProperty.getByName("renderer_NoiseOctaveParams");
|
|
37261
|
-
NoiseModule._strengthMinConstProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinConst");
|
|
37262
|
-
NoiseModule._strengthMaxCurveXProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveX");
|
|
37263
|
-
NoiseModule._strengthMaxCurveYProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveY");
|
|
37264
|
-
NoiseModule._strengthMaxCurveZProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveZ");
|
|
37265
|
-
NoiseModule._strengthMinCurveXProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveX");
|
|
37266
|
-
NoiseModule._strengthMinCurveYProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveY");
|
|
37267
|
-
NoiseModule._strengthMinCurveZProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveZ");
|
|
37268
|
-
__decorate([
|
|
37269
|
-
ignoreClone
|
|
37270
|
-
], NoiseModule.prototype, "_enabledModuleMacro", void 0);
|
|
37271
|
-
__decorate([
|
|
37272
|
-
ignoreClone
|
|
37273
|
-
], NoiseModule.prototype, "_strengthCurveModeMacro", void 0);
|
|
37274
|
-
__decorate([
|
|
37275
|
-
ignoreClone
|
|
37276
|
-
], NoiseModule.prototype, "_strengthIsRandomTwoModeMacro", void 0);
|
|
37277
|
-
__decorate([
|
|
37278
|
-
ignoreClone
|
|
37279
|
-
], NoiseModule.prototype, "_separateAxesModeMacro", void 0);
|
|
37280
|
-
__decorate([
|
|
37281
|
-
ignoreClone
|
|
37282
|
-
], NoiseModule.prototype, "_noiseRand", void 0);
|
|
37283
|
-
__decorate([
|
|
37284
|
-
ignoreClone
|
|
37285
|
-
], NoiseModule.prototype, "_noiseParams", void 0);
|
|
37286
|
-
__decorate([
|
|
37287
|
-
ignoreClone
|
|
37288
|
-
], NoiseModule.prototype, "_noiseOctaveParams", void 0);
|
|
37289
|
-
__decorate([
|
|
37290
|
-
ignoreClone
|
|
37291
|
-
], NoiseModule.prototype, "_strengthMinConst", void 0);
|
|
37292
|
-
__decorate([
|
|
37293
|
-
deepClone
|
|
37294
|
-
], NoiseModule.prototype, "_strengthX", void 0);
|
|
37295
|
-
__decorate([
|
|
37296
|
-
deepClone
|
|
37297
|
-
], NoiseModule.prototype, "_strengthY", void 0);
|
|
37298
|
-
__decorate([
|
|
37299
|
-
deepClone
|
|
37300
|
-
], NoiseModule.prototype, "_strengthZ", void 0);
|
|
37301
|
-
|
|
37302
37037
|
/**
|
|
37303
37038
|
* Velocity over lifetime module.
|
|
37304
37039
|
*/ var VelocityOverLifetimeModule = /*#__PURE__*/ function(ParticleGeneratorModule) {
|
|
@@ -37505,7 +37240,6 @@ __decorate([
|
|
|
37505
37240
|
this.forceOverLifetime = new ForceOverLifetimeModule(this);
|
|
37506
37241
|
this.sizeOverLifetime = new SizeOverLifetimeModule(this);
|
|
37507
37242
|
this.limitVelocityOverLifetime = new LimitVelocityOverLifetimeModule(this);
|
|
37508
|
-
this.noise = new NoiseModule(this);
|
|
37509
37243
|
this.emission.enabled = true;
|
|
37510
37244
|
}
|
|
37511
37245
|
var _proto = ParticleGenerator.prototype;
|
|
@@ -37813,7 +37547,6 @@ __decorate([
|
|
|
37813
37547
|
this.sizeOverLifetime._updateShaderData(shaderData);
|
|
37814
37548
|
this.rotationOverLifetime._updateShaderData(shaderData);
|
|
37815
37549
|
this.colorOverLifetime._updateShaderData(shaderData);
|
|
37816
|
-
this.noise._updateShaderData(shaderData);
|
|
37817
37550
|
};
|
|
37818
37551
|
/**
|
|
37819
37552
|
* @internal
|
|
@@ -37827,19 +37560,16 @@ __decorate([
|
|
|
37827
37560
|
this.limitVelocityOverLifetime._resetRandomSeed(seed);
|
|
37828
37561
|
this.rotationOverLifetime._resetRandomSeed(seed);
|
|
37829
37562
|
this.colorOverLifetime._resetRandomSeed(seed);
|
|
37830
|
-
this.noise._resetRandomSeed(seed);
|
|
37831
37563
|
};
|
|
37832
37564
|
/**
|
|
37833
37565
|
* @internal
|
|
37834
|
-
*/ _proto._setTransformFeedback = function _setTransformFeedback() {
|
|
37835
|
-
|
|
37836
|
-
if (needed === this._useTransformFeedback) return;
|
|
37837
|
-
this._useTransformFeedback = needed;
|
|
37566
|
+
*/ _proto._setTransformFeedback = function _setTransformFeedback(enabled) {
|
|
37567
|
+
this._useTransformFeedback = enabled;
|
|
37838
37568
|
// Switching TF mode invalidates all active particle state: feedback buffers and instance
|
|
37839
37569
|
// buffer layout are incompatible between the two paths. Clear rather than show a one-frame
|
|
37840
37570
|
// jump; new particles will fill in naturally from the next emit cycle.
|
|
37841
37571
|
this._clearActiveParticles();
|
|
37842
|
-
if (
|
|
37572
|
+
if (enabled) {
|
|
37843
37573
|
if (!this._feedbackSimulator) {
|
|
37844
37574
|
this._feedbackSimulator = new ParticleTransformFeedbackSimulator(this._renderer.engine);
|
|
37845
37575
|
}
|
|
@@ -37889,7 +37619,9 @@ __decorate([
|
|
|
37889
37619
|
/**
|
|
37890
37620
|
* @internal
|
|
37891
37621
|
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
37892
|
-
target.
|
|
37622
|
+
if (target.limitVelocityOverLifetime.enabled) {
|
|
37623
|
+
target._setTransformFeedback(true);
|
|
37624
|
+
}
|
|
37893
37625
|
};
|
|
37894
37626
|
/**
|
|
37895
37627
|
* @internal
|
|
@@ -38051,6 +37783,10 @@ __decorate([
|
|
|
38051
37783
|
// Start rotation
|
|
38052
37784
|
var startRotationRand = main._startRotationRand, flipRotation = main.flipRotation;
|
|
38053
37785
|
var isFlip = flipRotation > startRotationRand.random();
|
|
37786
|
+
// @todo:None-Mesh mode should inverse the rotation, maybe should unify it
|
|
37787
|
+
if (this._renderer.renderMode !== ParticleRenderMode.Mesh) {
|
|
37788
|
+
isFlip = !isFlip;
|
|
37789
|
+
}
|
|
38054
37790
|
var rotationZ = main.startRotationZ.evaluate(undefined, startRotationRand.random());
|
|
38055
37791
|
if (main.startRotation3D) {
|
|
38056
37792
|
var rotationX = main.startRotationX.evaluate(undefined, startRotationRand.random());
|
|
@@ -38076,9 +37812,7 @@ __decorate([
|
|
|
38076
37812
|
if (colorOverLifetime.enabled && colorOverLifetime.color.mode === ParticleGradientMode.TwoGradients) {
|
|
38077
37813
|
instanceVertices[offset + 20] = colorOverLifetime._colorGradientRand.random();
|
|
38078
37814
|
}
|
|
38079
|
-
|
|
38080
|
-
instanceVertices[offset + 21] = this.noise._noiseRand.random();
|
|
38081
|
-
}
|
|
37815
|
+
// instanceVertices[offset + 21] = rand.random();
|
|
38082
37816
|
var rotationOverLifetime = this.rotationOverLifetime;
|
|
38083
37817
|
if (rotationOverLifetime.enabled && rotationOverLifetime.rotationZ.mode === ParticleCurveMode.TwoConstants) {
|
|
38084
37818
|
instanceVertices[offset + 22] = rotationOverLifetime._rotationRand.random();
|
|
@@ -38271,7 +38005,7 @@ __decorate([
|
|
|
38271
38005
|
// StartSpeed's impact
|
|
38272
38006
|
var shape = this.emission.shape;
|
|
38273
38007
|
if (shape == null ? void 0 : shape.enabled) {
|
|
38274
|
-
shape._getPositionRange(
|
|
38008
|
+
shape._getPositionRange(min, max);
|
|
38275
38009
|
shape._getDirectionRange(directionMin, directionMax);
|
|
38276
38010
|
} else {
|
|
38277
38011
|
min.set(0, 0, 0);
|
|
@@ -38366,21 +38100,6 @@ __decorate([
|
|
|
38366
38100
|
out.transform(rotateMat);
|
|
38367
38101
|
min.add(worldOffsetMin);
|
|
38368
38102
|
max.add(worldOffsetMax);
|
|
38369
|
-
// Noise module impact: noise output is normalized to [-1, 1],
|
|
38370
|
-
// max displacement = |strength_max|
|
|
38371
|
-
var noise = this.noise;
|
|
38372
|
-
if (noise.enabled) {
|
|
38373
|
-
var noiseMaxX, noiseMaxY, noiseMaxZ;
|
|
38374
|
-
if (noise.separateAxes) {
|
|
38375
|
-
noiseMaxX = Math.abs(noise.strengthX._getMax());
|
|
38376
|
-
noiseMaxY = Math.abs(noise.strengthY._getMax());
|
|
38377
|
-
noiseMaxZ = Math.abs(noise.strengthZ._getMax());
|
|
38378
|
-
} else {
|
|
38379
|
-
noiseMaxX = noiseMaxY = noiseMaxZ = Math.abs(noise.strengthX._getMax());
|
|
38380
|
-
}
|
|
38381
|
-
min.set(min.x - noiseMaxX, min.y - noiseMaxY, min.z - noiseMaxZ);
|
|
38382
|
-
max.set(max.x + noiseMaxX, max.y + noiseMaxY, max.z + noiseMaxZ);
|
|
38383
|
-
}
|
|
38384
38103
|
min.add(worldPosition);
|
|
38385
38104
|
max.add(worldPosition);
|
|
38386
38105
|
};
|
|
@@ -38478,9 +38197,6 @@ __decorate([
|
|
|
38478
38197
|
__decorate([
|
|
38479
38198
|
deepClone
|
|
38480
38199
|
], ParticleGenerator.prototype, "textureSheetAnimation", void 0);
|
|
38481
|
-
__decorate([
|
|
38482
|
-
deepClone
|
|
38483
|
-
], ParticleGenerator.prototype, "noise", void 0);
|
|
38484
38200
|
__decorate([
|
|
38485
38201
|
ignoreClone
|
|
38486
38202
|
], ParticleGenerator.prototype, "_playTime", void 0);
|
|
@@ -38646,39 +38362,10 @@ __decorate([
|
|
|
38646
38362
|
|
|
38647
38363
|
/**
|
|
38648
38364
|
* A burst is a particle emission event, where a number of particles are all emitted at the same time
|
|
38649
|
-
*/ var Burst =
|
|
38650
|
-
|
|
38651
|
-
|
|
38652
|
-
|
|
38653
|
-
this._cycles = Math.max(cycles != null ? cycles : 1, 1);
|
|
38654
|
-
this._repeatInterval = Math.max(repeatInterval != null ? repeatInterval : 0.01, 0.01);
|
|
38655
|
-
}
|
|
38656
|
-
_create_class(Burst, [
|
|
38657
|
-
{
|
|
38658
|
-
key: "cycles",
|
|
38659
|
-
get: /**
|
|
38660
|
-
* Number of times to repeat the burst.
|
|
38661
|
-
*/ function get() {
|
|
38662
|
-
return this._cycles;
|
|
38663
|
-
},
|
|
38664
|
-
set: function set(value) {
|
|
38665
|
-
this._cycles = Math.max(value, 1);
|
|
38666
|
-
}
|
|
38667
|
-
},
|
|
38668
|
-
{
|
|
38669
|
-
key: "repeatInterval",
|
|
38670
|
-
get: /**
|
|
38671
|
-
* Time interval between each repeated burst.
|
|
38672
|
-
*/ function get() {
|
|
38673
|
-
return this._repeatInterval;
|
|
38674
|
-
},
|
|
38675
|
-
set: function set(value) {
|
|
38676
|
-
this._repeatInterval = Math.max(value, 0.01);
|
|
38677
|
-
}
|
|
38678
|
-
}
|
|
38679
|
-
]);
|
|
38680
|
-
return Burst;
|
|
38681
|
-
}();
|
|
38365
|
+
*/ var Burst = function Burst(time, count) {
|
|
38366
|
+
this.time = time;
|
|
38367
|
+
this.count = count;
|
|
38368
|
+
};
|
|
38682
38369
|
__decorate([
|
|
38683
38370
|
deepClone
|
|
38684
38371
|
], Burst.prototype, "count", void 0);
|
|
@@ -38687,28 +38374,9 @@ __decorate([
|
|
|
38687
38374
|
* Base class for all particle shapes.
|
|
38688
38375
|
*/ var BaseShape = /*#__PURE__*/ function() {
|
|
38689
38376
|
function BaseShape() {
|
|
38690
|
-
var _this = this;
|
|
38691
38377
|
this._updateManager = new UpdateFlagManager();
|
|
38692
38378
|
this._enabled = true;
|
|
38693
38379
|
this._randomDirectionAmount = 0;
|
|
38694
|
-
this._position = new engineMath.Vector3(0, 0, 0);
|
|
38695
|
-
this._rotation = new engineMath.Vector3(0, 0, 0);
|
|
38696
|
-
this._scale = new engineMath.Vector3(1, 1, 1);
|
|
38697
|
-
this._matrix = new engineMath.Matrix();
|
|
38698
|
-
this._transformDirty = false;
|
|
38699
|
-
this._hasShapeTransform = false;
|
|
38700
|
-
this._onTransformChanged = function() {
|
|
38701
|
-
_this._transformDirty = true;
|
|
38702
|
-
var p = _this._position, r = _this._rotation, s = _this._scale;
|
|
38703
|
-
_this._hasShapeTransform = p.x !== 0 || p.y !== 0 || p.z !== 0 || r.x !== 0 || r.y !== 0 || r.z !== 0 || s.x !== 1 || s.y !== 1 || s.z !== 1;
|
|
38704
|
-
_this._updateManager.dispatch();
|
|
38705
|
-
};
|
|
38706
|
-
// @ts-ignore
|
|
38707
|
-
this._position._onValueChanged = this._onTransformChanged;
|
|
38708
|
-
// @ts-ignore
|
|
38709
|
-
this._rotation._onValueChanged = this._onTransformChanged;
|
|
38710
|
-
// @ts-ignore
|
|
38711
|
-
this._scale._onValueChanged = this._onTransformChanged;
|
|
38712
38380
|
}
|
|
38713
38381
|
var _proto = BaseShape.prototype;
|
|
38714
38382
|
/**
|
|
@@ -38721,53 +38389,6 @@ __decorate([
|
|
|
38721
38389
|
*/ _proto._unRegisterOnValueChanged = function _unRegisterOnValueChanged(listener) {
|
|
38722
38390
|
this._updateManager.removeListener(listener);
|
|
38723
38391
|
};
|
|
38724
|
-
/**
|
|
38725
|
-
* @internal
|
|
38726
|
-
*/ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
|
|
38727
|
-
this._generateLocalPositionAndDirection(rand, emitTime, position, direction);
|
|
38728
|
-
if (this._hasShapeTransform) {
|
|
38729
|
-
var matrix = this._getMatrix();
|
|
38730
|
-
engineMath.Vector3.transformToVec3(position, matrix, position);
|
|
38731
|
-
engineMath.Vector3.transformNormal(direction, matrix, direction);
|
|
38732
|
-
direction.normalize();
|
|
38733
|
-
}
|
|
38734
|
-
};
|
|
38735
|
-
/**
|
|
38736
|
-
* @internal
|
|
38737
|
-
*/ _proto._getPositionRange = function _getPositionRange(bounds) {
|
|
38738
|
-
this._getLocalPositionRange(bounds.min, bounds.max);
|
|
38739
|
-
if (this._hasShapeTransform) {
|
|
38740
|
-
engineMath.BoundingBox.transform(bounds, this._getMatrix(), bounds);
|
|
38741
|
-
}
|
|
38742
|
-
};
|
|
38743
|
-
/**
|
|
38744
|
-
* @internal
|
|
38745
|
-
*/ _proto._getDirectionRange = function _getDirectionRange(outMin, outMax) {
|
|
38746
|
-
this._getLocalDirectionRange(outMin, outMax);
|
|
38747
|
-
if (this._hasShapeTransform) {
|
|
38748
|
-
this._transformDirectionRange(outMin, outMax);
|
|
38749
|
-
}
|
|
38750
|
-
};
|
|
38751
|
-
_proto._getMatrix = function _getMatrix() {
|
|
38752
|
-
if (this._transformDirty) {
|
|
38753
|
-
var _this = this, r = _this._rotation;
|
|
38754
|
-
var q = BaseShape._tempQuaternion;
|
|
38755
|
-
engineMath.Quaternion.rotationEuler(engineMath.MathUtil.degreeToRadian(r.x), engineMath.MathUtil.degreeToRadian(r.y), engineMath.MathUtil.degreeToRadian(r.z), q);
|
|
38756
|
-
engineMath.Matrix.affineTransformation(this._scale, q, this._position, this._matrix);
|
|
38757
|
-
this._transformDirty = false;
|
|
38758
|
-
}
|
|
38759
|
-
return this._matrix;
|
|
38760
|
-
};
|
|
38761
|
-
// Arvo min/max method without translation, only apply RS part of the matrix
|
|
38762
|
-
_proto._transformDirectionRange = function _transformDirectionRange(outMin, outMax) {
|
|
38763
|
-
var e = this._getMatrix().elements;
|
|
38764
|
-
var minX = outMin.x, minY = outMin.y, minZ = outMin.z;
|
|
38765
|
-
var maxX = outMax.x, maxY = outMax.y, maxZ = outMax.z;
|
|
38766
|
-
// prettier-ignore
|
|
38767
|
-
var e0 = e[0], e1 = e[1], e2 = e[2], e4 = e[4], e5 = e[5], e6 = e[6], e8 = e[8], e9 = e[9], e10 = e[10];
|
|
38768
|
-
outMin.set((e0 > 0 ? e0 * minX : e0 * maxX) + (e4 > 0 ? e4 * minY : e4 * maxY) + (e8 > 0 ? e8 * minZ : e8 * maxZ), (e1 > 0 ? e1 * minX : e1 * maxX) + (e5 > 0 ? e5 * minY : e5 * maxY) + (e9 > 0 ? e9 * minZ : e9 * maxZ), (e2 > 0 ? e2 * minX : e2 * maxX) + (e6 > 0 ? e6 * minY : e6 * maxY) + (e10 > 0 ? e10 * minZ : e10 * maxZ));
|
|
38769
|
-
outMax.set((e0 > 0 ? e0 * maxX : e0 * minX) + (e4 > 0 ? e4 * maxY : e4 * minY) + (e8 > 0 ? e8 * maxZ : e8 * minZ), (e1 > 0 ? e1 * maxX : e1 * minX) + (e5 > 0 ? e5 * maxY : e5 * minY) + (e9 > 0 ? e9 * maxZ : e9 * minZ), (e2 > 0 ? e2 * maxX : e2 * minX) + (e6 > 0 ? e6 * maxY : e6 * minY) + (e10 > 0 ? e10 * maxZ : e10 * minZ));
|
|
38770
|
-
};
|
|
38771
38392
|
_create_class(BaseShape, [
|
|
38772
38393
|
{
|
|
38773
38394
|
key: "enabled",
|
|
@@ -38796,78 +38417,13 @@ __decorate([
|
|
|
38796
38417
|
this._updateManager.dispatch();
|
|
38797
38418
|
}
|
|
38798
38419
|
}
|
|
38799
|
-
},
|
|
38800
|
-
{
|
|
38801
|
-
key: "position",
|
|
38802
|
-
get: /**
|
|
38803
|
-
* Apply a local position offset to the shape.
|
|
38804
|
-
*/ function get() {
|
|
38805
|
-
return this._position;
|
|
38806
|
-
},
|
|
38807
|
-
set: function set(value) {
|
|
38808
|
-
if (value !== this._position) {
|
|
38809
|
-
this._position.copyFrom(value);
|
|
38810
|
-
}
|
|
38811
|
-
}
|
|
38812
|
-
},
|
|
38813
|
-
{
|
|
38814
|
-
key: "rotation",
|
|
38815
|
-
get: /**
|
|
38816
|
-
* Apply a local rotation to the shape, specified as euler angles in degrees.
|
|
38817
|
-
*/ function get() {
|
|
38818
|
-
return this._rotation;
|
|
38819
|
-
},
|
|
38820
|
-
set: function set(value) {
|
|
38821
|
-
if (value !== this._rotation) {
|
|
38822
|
-
this._rotation.copyFrom(value);
|
|
38823
|
-
}
|
|
38824
|
-
}
|
|
38825
|
-
},
|
|
38826
|
-
{
|
|
38827
|
-
key: "scale",
|
|
38828
|
-
get: /**
|
|
38829
|
-
* Apply a local scale to the shape.
|
|
38830
|
-
*/ function get() {
|
|
38831
|
-
return this._scale;
|
|
38832
|
-
},
|
|
38833
|
-
set: function set(value) {
|
|
38834
|
-
if (value !== this._scale) {
|
|
38835
|
-
this._scale.copyFrom(value);
|
|
38836
|
-
}
|
|
38837
|
-
}
|
|
38838
38420
|
}
|
|
38839
38421
|
]);
|
|
38840
38422
|
return BaseShape;
|
|
38841
38423
|
}();
|
|
38842
|
-
/** @internal */ BaseShape._tempVector20 = new engineMath.Vector2();
|
|
38843
|
-
/** @internal */ BaseShape._tempVector21 = new engineMath.Vector2();
|
|
38844
|
-
/** @internal */ BaseShape._tempVector30 = new engineMath.Vector3();
|
|
38845
|
-
/** @internal */ BaseShape._tempVector31 = new engineMath.Vector3();
|
|
38846
|
-
BaseShape._tempQuaternion = new engineMath.Quaternion();
|
|
38847
38424
|
__decorate([
|
|
38848
38425
|
ignoreClone
|
|
38849
38426
|
], BaseShape.prototype, "_updateManager", void 0);
|
|
38850
|
-
__decorate([
|
|
38851
|
-
deepClone
|
|
38852
|
-
], BaseShape.prototype, "_position", void 0);
|
|
38853
|
-
__decorate([
|
|
38854
|
-
deepClone
|
|
38855
|
-
], BaseShape.prototype, "_rotation", void 0);
|
|
38856
|
-
__decorate([
|
|
38857
|
-
deepClone
|
|
38858
|
-
], BaseShape.prototype, "_scale", void 0);
|
|
38859
|
-
__decorate([
|
|
38860
|
-
ignoreClone
|
|
38861
|
-
], BaseShape.prototype, "_matrix", void 0);
|
|
38862
|
-
__decorate([
|
|
38863
|
-
ignoreClone
|
|
38864
|
-
], BaseShape.prototype, "_transformDirty", void 0);
|
|
38865
|
-
__decorate([
|
|
38866
|
-
ignoreClone
|
|
38867
|
-
], BaseShape.prototype, "_hasShapeTransform", void 0);
|
|
38868
|
-
__decorate([
|
|
38869
|
-
ignoreClone
|
|
38870
|
-
], BaseShape.prototype, "_onTransformChanged", void 0);
|
|
38871
38427
|
|
|
38872
38428
|
/**
|
|
38873
38429
|
* @internal
|
|
@@ -38933,11 +38489,11 @@ __decorate([
|
|
|
38933
38489
|
|
|
38934
38490
|
/**
|
|
38935
38491
|
* Particle shape that emits particles from a box.
|
|
38936
|
-
*/ var BoxShape = /*#__PURE__*/ function(
|
|
38937
|
-
_inherits(BoxShape,
|
|
38492
|
+
*/ var BoxShape = /*#__PURE__*/ function(BaseShape) {
|
|
38493
|
+
_inherits(BoxShape, BaseShape);
|
|
38938
38494
|
function BoxShape() {
|
|
38939
38495
|
var _this;
|
|
38940
|
-
_this =
|
|
38496
|
+
_this = BaseShape.call(this) || this, _this.shapeType = ParticleShapeType.Box, _this._size = new engineMath.Vector3(1, 1, 1);
|
|
38941
38497
|
// @ts-ignore
|
|
38942
38498
|
_this._size._onValueChanged = _this._updateManager.dispatch.bind(_this._updateManager);
|
|
38943
38499
|
return _this;
|
|
@@ -38945,17 +38501,17 @@ __decorate([
|
|
|
38945
38501
|
var _proto = BoxShape.prototype;
|
|
38946
38502
|
/**
|
|
38947
38503
|
* @internal
|
|
38948
|
-
*/ _proto.
|
|
38504
|
+
*/ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
|
|
38949
38505
|
ShapeUtils._randomPointInsideHalfUnitBox(position, rand);
|
|
38950
38506
|
position.multiply(this.size);
|
|
38951
|
-
var defaultDirection =
|
|
38507
|
+
var defaultDirection = BoxShape._tempVector30;
|
|
38952
38508
|
defaultDirection.set(0.0, 0.0, -1.0);
|
|
38953
38509
|
ShapeUtils._randomPointUnitSphere(direction, rand);
|
|
38954
38510
|
engineMath.Vector3.lerp(defaultDirection, direction, this.randomDirectionAmount, direction);
|
|
38955
38511
|
};
|
|
38956
38512
|
/**
|
|
38957
38513
|
* @internal
|
|
38958
|
-
*/ _proto.
|
|
38514
|
+
*/ _proto._getDirectionRange = function _getDirectionRange(outMin, outMax) {
|
|
38959
38515
|
var radian = Math.PI * this.randomDirectionAmount;
|
|
38960
38516
|
if (this.randomDirectionAmount < 0.5) {
|
|
38961
38517
|
var dirSin = Math.sin(radian);
|
|
@@ -38969,7 +38525,7 @@ __decorate([
|
|
|
38969
38525
|
};
|
|
38970
38526
|
/**
|
|
38971
38527
|
* @internal
|
|
38972
|
-
*/ _proto.
|
|
38528
|
+
*/ _proto._getPositionRange = function _getPositionRange(outMin, outMax) {
|
|
38973
38529
|
var _this__size = this._size, x = _this__size.x, y = _this__size.y, z = _this__size.z;
|
|
38974
38530
|
outMin.set(-x * 0.5, -y * 0.5, -z * 0.5);
|
|
38975
38531
|
outMax.set(x * 0.5, y * 0.5, z * 0.5);
|
|
@@ -38991,6 +38547,7 @@ __decorate([
|
|
|
38991
38547
|
]);
|
|
38992
38548
|
return BoxShape;
|
|
38993
38549
|
}(BaseShape);
|
|
38550
|
+
BoxShape._tempVector30 = new engineMath.Vector3();
|
|
38994
38551
|
__decorate([
|
|
38995
38552
|
deepClone
|
|
38996
38553
|
], BoxShape.prototype, "_size", void 0);
|
|
@@ -39005,18 +38562,18 @@ __decorate([
|
|
|
39005
38562
|
|
|
39006
38563
|
/**
|
|
39007
38564
|
* Particle shape that emits particles from a circle.
|
|
39008
|
-
*/ var CircleShape = /*#__PURE__*/ function(
|
|
39009
|
-
_inherits(CircleShape,
|
|
38565
|
+
*/ var CircleShape = /*#__PURE__*/ function(BaseShape) {
|
|
38566
|
+
_inherits(CircleShape, BaseShape);
|
|
39010
38567
|
function CircleShape() {
|
|
39011
38568
|
var _this;
|
|
39012
|
-
_this =
|
|
38569
|
+
_this = BaseShape.apply(this, arguments) || this, _this.shapeType = ParticleShapeType.Circle, _this._radius = 1.0, _this._arc = 360.0, _this._arcMode = ParticleShapeArcMode.Random, _this._arcSpeed = 1.0;
|
|
39013
38570
|
return _this;
|
|
39014
38571
|
}
|
|
39015
38572
|
var _proto = CircleShape.prototype;
|
|
39016
38573
|
/**
|
|
39017
38574
|
* @internal
|
|
39018
|
-
*/ _proto.
|
|
39019
|
-
var positionPoint =
|
|
38575
|
+
*/ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
|
|
38576
|
+
var positionPoint = CircleShape._tempPositionPoint;
|
|
39020
38577
|
switch(this.arcMode){
|
|
39021
38578
|
case ParticleShapeArcMode.Loop:
|
|
39022
38579
|
var normalizedEmitTime = emitTime * this.arcSpeed * (360 / this.arc) % 1;
|
|
@@ -39035,7 +38592,7 @@ __decorate([
|
|
|
39035
38592
|
};
|
|
39036
38593
|
/**
|
|
39037
38594
|
* @internal
|
|
39038
|
-
*/ _proto.
|
|
38595
|
+
*/ _proto._getDirectionRange = function _getDirectionRange(outMin, outMax) {
|
|
39039
38596
|
var randomDirZ = this.randomDirectionAmount > 0.5 ? 1 : Math.sin(this.randomDirectionAmount * Math.PI);
|
|
39040
38597
|
var randomDegreeOnXY = 0.5 * (360 - this._arc) * this.randomDirectionAmount;
|
|
39041
38598
|
var randomDirY = randomDegreeOnXY > 90 ? -1 : -Math.sin(randomDegreeOnXY);
|
|
@@ -39043,7 +38600,7 @@ __decorate([
|
|
|
39043
38600
|
};
|
|
39044
38601
|
/**
|
|
39045
38602
|
* @internal
|
|
39046
|
-
*/ _proto.
|
|
38603
|
+
*/ _proto._getPositionRange = function _getPositionRange(outMin, outMax) {
|
|
39047
38604
|
this._getUnitArcRange(this._arc, outMin, outMax, 0, 0);
|
|
39048
38605
|
outMin.scale(this._radius);
|
|
39049
38606
|
outMax.scale(this._radius);
|
|
@@ -39126,21 +38683,22 @@ __decorate([
|
|
|
39126
38683
|
]);
|
|
39127
38684
|
return CircleShape;
|
|
39128
38685
|
}(BaseShape);
|
|
38686
|
+
CircleShape._tempPositionPoint = new engineMath.Vector2();
|
|
39129
38687
|
|
|
39130
38688
|
/**
|
|
39131
38689
|
* Cone shape.
|
|
39132
|
-
*/ var ConeShape = /*#__PURE__*/ function(
|
|
39133
|
-
_inherits(ConeShape,
|
|
38690
|
+
*/ var ConeShape = /*#__PURE__*/ function(BaseShape) {
|
|
38691
|
+
_inherits(ConeShape, BaseShape);
|
|
39134
38692
|
function ConeShape() {
|
|
39135
38693
|
var _this;
|
|
39136
|
-
_this =
|
|
38694
|
+
_this = BaseShape.apply(this, arguments) || this, _this.shapeType = ParticleShapeType.Cone, _this._angle = 25.0, _this._radius = 1.0, _this._length = 5.0, _this._emitType = 0;
|
|
39137
38695
|
return _this;
|
|
39138
38696
|
}
|
|
39139
38697
|
var _proto = ConeShape.prototype;
|
|
39140
38698
|
/**
|
|
39141
38699
|
* @internal
|
|
39142
|
-
*/ _proto.
|
|
39143
|
-
var unitPosition =
|
|
38700
|
+
*/ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
|
|
38701
|
+
var unitPosition = ConeShape._tempVector20;
|
|
39144
38702
|
var radian = engineMath.MathUtil.degreeToRadian(this.angle);
|
|
39145
38703
|
var dirSinA = Math.sin(radian);
|
|
39146
38704
|
var dirCosA = Math.cos(radian);
|
|
@@ -39148,7 +38706,7 @@ __decorate([
|
|
|
39148
38706
|
case 0:
|
|
39149
38707
|
ShapeUtils.randomPointInsideUnitCircle(unitPosition, rand);
|
|
39150
38708
|
position.set(unitPosition.x * this.radius, unitPosition.y * this.radius, 0);
|
|
39151
|
-
var unitDirection =
|
|
38709
|
+
var unitDirection = ConeShape._tempVector21;
|
|
39152
38710
|
ShapeUtils.randomPointInsideUnitCircle(unitDirection, rand);
|
|
39153
38711
|
engineMath.Vector2.lerp(unitPosition, unitDirection, this.randomDirectionAmount, unitDirection);
|
|
39154
38712
|
direction.set(unitDirection.x * dirSinA, unitDirection.y * dirSinA, -dirCosA);
|
|
@@ -39158,10 +38716,10 @@ __decorate([
|
|
|
39158
38716
|
position.set(unitPosition.x * this.radius, unitPosition.y * this.radius, 0);
|
|
39159
38717
|
direction.set(unitPosition.x * dirSinA, unitPosition.y * dirSinA, -dirCosA);
|
|
39160
38718
|
direction.normalize();
|
|
39161
|
-
var distance =
|
|
38719
|
+
var distance = ConeShape._tempVector30;
|
|
39162
38720
|
engineMath.Vector3.scale(direction, this.length * rand.random(), distance);
|
|
39163
38721
|
position.add(distance);
|
|
39164
|
-
var randomDirection =
|
|
38722
|
+
var randomDirection = ConeShape._tempVector31;
|
|
39165
38723
|
ShapeUtils._randomPointUnitSphere(randomDirection, rand);
|
|
39166
38724
|
engineMath.Vector3.lerp(direction, randomDirection, this.randomDirectionAmount, direction);
|
|
39167
38725
|
break;
|
|
@@ -39169,7 +38727,7 @@ __decorate([
|
|
|
39169
38727
|
};
|
|
39170
38728
|
/**
|
|
39171
38729
|
* @internal
|
|
39172
|
-
*/ _proto.
|
|
38730
|
+
*/ _proto._getDirectionRange = function _getDirectionRange(outMin, outMax) {
|
|
39173
38731
|
var radian = 0;
|
|
39174
38732
|
switch(this.emitType){
|
|
39175
38733
|
case 0:
|
|
@@ -39186,7 +38744,7 @@ __decorate([
|
|
|
39186
38744
|
};
|
|
39187
38745
|
/**
|
|
39188
38746
|
* @internal
|
|
39189
|
-
*/ _proto.
|
|
38747
|
+
*/ _proto._getPositionRange = function _getPositionRange(outMin, outMax) {
|
|
39190
38748
|
var radius = this.radius;
|
|
39191
38749
|
switch(this.emitType){
|
|
39192
38750
|
case 0:
|
|
@@ -39261,6 +38819,10 @@ __decorate([
|
|
|
39261
38819
|
]);
|
|
39262
38820
|
return ConeShape;
|
|
39263
38821
|
}(BaseShape);
|
|
38822
|
+
ConeShape._tempVector20 = new engineMath.Vector2();
|
|
38823
|
+
ConeShape._tempVector21 = new engineMath.Vector2();
|
|
38824
|
+
ConeShape._tempVector30 = new engineMath.Vector3();
|
|
38825
|
+
ConeShape._tempVector31 = new engineMath.Vector3();
|
|
39264
38826
|
/**
|
|
39265
38827
|
* Cone emitter type.
|
|
39266
38828
|
*/ var ConeEmitType = /*#__PURE__*/ function(ConeEmitType) {
|
|
@@ -39281,7 +38843,7 @@ __decorate([
|
|
|
39281
38843
|
var _proto = HemisphereShape.prototype;
|
|
39282
38844
|
/**
|
|
39283
38845
|
* @internal
|
|
39284
|
-
*/ _proto.
|
|
38846
|
+
*/ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
|
|
39285
38847
|
ShapeUtils._randomPointInsideUnitSphere(position, rand);
|
|
39286
38848
|
position.scale(this.radius);
|
|
39287
38849
|
var z = position.z;
|
|
@@ -39291,14 +38853,14 @@ __decorate([
|
|
|
39291
38853
|
};
|
|
39292
38854
|
/**
|
|
39293
38855
|
* @internal
|
|
39294
|
-
*/ _proto.
|
|
38856
|
+
*/ _proto._getDirectionRange = function _getDirectionRange(outMin, outMax) {
|
|
39295
38857
|
var randomDir = Math.sin(0.5 * this.randomDirectionAmount * Math.PI);
|
|
39296
38858
|
outMin.set(-1, -1, -1);
|
|
39297
38859
|
outMax.set(1, 1, randomDir);
|
|
39298
38860
|
};
|
|
39299
38861
|
/**
|
|
39300
38862
|
* @internal
|
|
39301
|
-
*/ _proto.
|
|
38863
|
+
*/ _proto._getPositionRange = function _getPositionRange(outMin, outMax) {
|
|
39302
38864
|
var radius = this._radius;
|
|
39303
38865
|
outMin.set(-radius, -radius, -radius);
|
|
39304
38866
|
outMax.set(radius, radius, 0);
|
|
@@ -39336,7 +38898,7 @@ __decorate([
|
|
|
39336
38898
|
var _proto = MeshShape.prototype;
|
|
39337
38899
|
/**
|
|
39338
38900
|
* @internal
|
|
39339
|
-
*/ _proto.
|
|
38901
|
+
*/ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
|
|
39340
38902
|
var _this = this, positions = _this._positionBuffer, positionInfo = _this._positionElementInfo, normals = _this._normalBuffer, normalInfo = _this._normalElementInfo;
|
|
39341
38903
|
var randomIndex = Math.floor(rand.random() * this._mesh.vertexCount);
|
|
39342
38904
|
// index = randomIndex * stride + offset
|
|
@@ -39349,14 +38911,14 @@ __decorate([
|
|
|
39349
38911
|
};
|
|
39350
38912
|
/**
|
|
39351
38913
|
* @internal
|
|
39352
|
-
*/ _proto.
|
|
38914
|
+
*/ _proto._getPositionRange = function _getPositionRange(outMin, outMax) {
|
|
39353
38915
|
var bounds = this._mesh.bounds;
|
|
39354
38916
|
bounds.min.copyTo(outMin);
|
|
39355
38917
|
bounds.max.copyTo(outMax);
|
|
39356
38918
|
};
|
|
39357
38919
|
/**
|
|
39358
38920
|
* @internal
|
|
39359
|
-
*/ _proto.
|
|
38921
|
+
*/ _proto._getDirectionRange = function _getDirectionRange(outMin, outMax) {
|
|
39360
38922
|
// @todo: Should use min and max of normal, use bounds is worst, but we can't get the min and max of normal by fast way.
|
|
39361
38923
|
var bounds = this._mesh.bounds;
|
|
39362
38924
|
bounds.min.copyTo(outMin);
|
|
@@ -39471,7 +39033,7 @@ __decorate([
|
|
|
39471
39033
|
var _proto = SphereShape.prototype;
|
|
39472
39034
|
/**
|
|
39473
39035
|
* @internal
|
|
39474
|
-
*/ _proto.
|
|
39036
|
+
*/ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
|
|
39475
39037
|
ShapeUtils._randomPointInsideUnitSphere(position, rand);
|
|
39476
39038
|
position.scale(this.radius);
|
|
39477
39039
|
ShapeUtils._randomPointUnitSphere(direction, rand);
|
|
@@ -39479,13 +39041,13 @@ __decorate([
|
|
|
39479
39041
|
};
|
|
39480
39042
|
/**
|
|
39481
39043
|
* @internal
|
|
39482
|
-
*/ _proto.
|
|
39044
|
+
*/ _proto._getDirectionRange = function _getDirectionRange(outMin, outMax) {
|
|
39483
39045
|
outMin.set(-1, -1, -1);
|
|
39484
39046
|
outMax.set(1, 1, 1);
|
|
39485
39047
|
};
|
|
39486
39048
|
/**
|
|
39487
39049
|
* @internal
|
|
39488
|
-
*/ _proto.
|
|
39050
|
+
*/ _proto._getPositionRange = function _getPositionRange(outMin, outMax) {
|
|
39489
39051
|
var radius = this._radius;
|
|
39490
39052
|
outMin.set(-radius, -radius, -radius);
|
|
39491
39053
|
outMax.set(radius, radius, radius);
|
|
@@ -40248,27 +39810,37 @@ var cacheDir = new engineMath.Vector3();
|
|
|
40248
39810
|
* Suspend the audio context.
|
|
40249
39811
|
* @returns A promise that resolves when the audio context is suspended
|
|
40250
39812
|
*/ AudioManager.suspend = function suspend() {
|
|
40251
|
-
|
|
39813
|
+
var _AudioManager__context;
|
|
39814
|
+
var _AudioManager__context_suspend;
|
|
39815
|
+
return (_AudioManager__context_suspend = (_AudioManager__context = AudioManager._context) == null ? void 0 : _AudioManager__context.suspend()) != null ? _AudioManager__context_suspend : Promise.resolve();
|
|
40252
39816
|
};
|
|
40253
39817
|
/**
|
|
40254
39818
|
* Resume the audio context.
|
|
40255
39819
|
* @remarks On iOS Safari, calling this within a user gesture (e.g., click/touch event handler) can pre-unlock audio and reduce playback delay.
|
|
40256
39820
|
* @returns A promise that resolves when the audio context is resumed
|
|
40257
39821
|
*/ AudioManager.resume = function resume() {
|
|
40258
|
-
var
|
|
40259
|
-
|
|
40260
|
-
|
|
39822
|
+
var context = AudioManager._context;
|
|
39823
|
+
if (!context || context.state === "running") {
|
|
39824
|
+
return Promise.resolve();
|
|
39825
|
+
}
|
|
39826
|
+
return context.resume().then(function() {
|
|
40261
39827
|
AudioManager._needsUserGestureResume = false;
|
|
40262
|
-
|
|
40263
|
-
AudioManager._resumePromise = null;
|
|
39828
|
+
AudioManager._resumePendingSources();
|
|
40264
39829
|
});
|
|
40265
39830
|
};
|
|
39831
|
+
/** @internal */ AudioManager._registerPendingSource = function _registerPendingSource(source) {
|
|
39832
|
+
AudioManager._pendingSources.add(source);
|
|
39833
|
+
};
|
|
39834
|
+
/** @internal */ AudioManager._unregisterPendingSource = function _unregisterPendingSource(source) {
|
|
39835
|
+
AudioManager._pendingSources.delete(source);
|
|
39836
|
+
};
|
|
40266
39837
|
/**
|
|
40267
39838
|
* @internal
|
|
40268
39839
|
*/ AudioManager.getContext = function getContext() {
|
|
40269
39840
|
var context = AudioManager._context;
|
|
40270
39841
|
if (!context) {
|
|
40271
39842
|
AudioManager._context = context = new window.AudioContext();
|
|
39843
|
+
context.onstatechange = AudioManager._onContextStateChange;
|
|
40272
39844
|
document.addEventListener("visibilitychange", AudioManager._onVisibilityChange);
|
|
40273
39845
|
// iOS Safari requires user gesture to resume AudioContext
|
|
40274
39846
|
document.addEventListener("touchstart", AudioManager._resumeAfterInterruption, {
|
|
@@ -40297,28 +39869,58 @@ var cacheDir = new engineMath.Vector3();
|
|
|
40297
39869
|
*/ AudioManager.isAudioContextRunning = function isAudioContextRunning() {
|
|
40298
39870
|
return AudioManager.getContext().state === "running";
|
|
40299
39871
|
};
|
|
39872
|
+
AudioManager._onContextStateChange = function _onContextStateChange() {
|
|
39873
|
+
var _AudioManager__context;
|
|
39874
|
+
if (((_AudioManager__context = AudioManager._context) == null ? void 0 : _AudioManager__context.state) === "running") {
|
|
39875
|
+
AudioManager._needsUserGestureResume = false;
|
|
39876
|
+
AudioManager._resumePendingSources();
|
|
39877
|
+
}
|
|
39878
|
+
};
|
|
39879
|
+
AudioManager._resumePendingSources = function _resumePendingSources() {
|
|
39880
|
+
if (!AudioManager._pendingSources.size || !AudioManager.isAudioContextRunning()) {
|
|
39881
|
+
return;
|
|
39882
|
+
}
|
|
39883
|
+
var pendingSources = Array.from(AudioManager._pendingSources);
|
|
39884
|
+
AudioManager._pendingSources.clear();
|
|
39885
|
+
for(var i = 0, n = pendingSources.length; i < n; i++){
|
|
39886
|
+
pendingSources[i]._resumePendingPlayback();
|
|
39887
|
+
}
|
|
39888
|
+
};
|
|
40300
39889
|
AudioManager._onVisibilityChange = function _onVisibilityChange() {
|
|
40301
|
-
|
|
40302
|
-
|
|
40303
|
-
|
|
40304
|
-
// Calling suspend() first forces a clean internal state reset before user gesture triggers resume.
|
|
40305
|
-
// Related: https://bugs.webkit.org/show_bug.cgi?id=263627
|
|
40306
|
-
AudioManager.suspend();
|
|
40307
|
-
AudioManager._needsUserGestureResume = true;
|
|
39890
|
+
var context = AudioManager._context;
|
|
39891
|
+
if (document.hidden || !context || AudioManager._playingCount === 0 && AudioManager._pendingSources.size === 0 || context.state === "running") {
|
|
39892
|
+
return;
|
|
40308
39893
|
}
|
|
39894
|
+
AudioManager.resume().then(function() {
|
|
39895
|
+
var _AudioManager__context;
|
|
39896
|
+
if (((_AudioManager__context = AudioManager._context) == null ? void 0 : _AudioManager__context.state) !== "running") {
|
|
39897
|
+
return AudioManager._prepareGestureResume();
|
|
39898
|
+
}
|
|
39899
|
+
}).catch(function() {
|
|
39900
|
+
return AudioManager._prepareGestureResume();
|
|
39901
|
+
});
|
|
40309
39902
|
};
|
|
40310
39903
|
AudioManager._resumeAfterInterruption = function _resumeAfterInterruption() {
|
|
40311
|
-
if (AudioManager._needsUserGestureResume) {
|
|
39904
|
+
if (AudioManager._needsUserGestureResume || AudioManager._pendingSources.size > 0) {
|
|
40312
39905
|
AudioManager.resume().catch(function(e) {
|
|
40313
39906
|
console.warn("Failed to resume AudioContext:", e);
|
|
40314
39907
|
});
|
|
40315
39908
|
}
|
|
40316
39909
|
};
|
|
39910
|
+
AudioManager._prepareGestureResume = function _prepareGestureResume() {
|
|
39911
|
+
// iOS WKWebView WebKit bug(Triggered in LingGuang App): AudioContext may be in a "zombie" state where
|
|
39912
|
+
// state reports "suspended" but resume() alone won't restart audio rendering.
|
|
39913
|
+
// Calling suspend() first forces a clean internal state reset before user gesture triggers resume.
|
|
39914
|
+
// Related: https://bugs.webkit.org/show_bug.cgi?id=263627
|
|
39915
|
+
return AudioManager.suspend().catch(function() {}).then(function() {
|
|
39916
|
+
AudioManager._needsUserGestureResume = true;
|
|
39917
|
+
});
|
|
39918
|
+
};
|
|
40317
39919
|
return AudioManager;
|
|
40318
39920
|
}();
|
|
40319
39921
|
/** @internal */ AudioManager._playingCount = 0;
|
|
40320
|
-
AudioManager._resumePromise = null;
|
|
40321
39922
|
AudioManager._needsUserGestureResume = false;
|
|
39923
|
+
AudioManager._pendingSources = new Set();
|
|
40322
39924
|
|
|
40323
39925
|
/**
|
|
40324
39926
|
* Audio Source Component.
|
|
@@ -40336,7 +39938,6 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40336
39938
|
/**
|
|
40337
39939
|
* Play the clip.
|
|
40338
39940
|
*/ _proto.play = function play() {
|
|
40339
|
-
var _this = this;
|
|
40340
39941
|
var _this__clip;
|
|
40341
39942
|
if (!((_this__clip = this._clip) == null ? void 0 : _this__clip._getAudioSource()) || this._isPlaying || this._pendingPlay) {
|
|
40342
39943
|
return;
|
|
@@ -40344,22 +39945,9 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40344
39945
|
if (AudioManager.isAudioContextRunning()) {
|
|
40345
39946
|
this._startPlayback();
|
|
40346
39947
|
} else {
|
|
40347
|
-
// iOS Safari requires resume() to be called within the same user gesture callback that triggers playback.
|
|
40348
|
-
// Document-level events won't work - must call resume() directly here in play().
|
|
40349
39948
|
this._pendingPlay = true;
|
|
40350
|
-
AudioManager.
|
|
40351
|
-
|
|
40352
|
-
if (!_this._pendingPlay) {
|
|
40353
|
-
return;
|
|
40354
|
-
}
|
|
40355
|
-
_this._pendingPlay = false;
|
|
40356
|
-
// Check if still valid to play after async resume
|
|
40357
|
-
if (_this._destroyed || !_this.enabled || !_this._clip) {
|
|
40358
|
-
return;
|
|
40359
|
-
}
|
|
40360
|
-
_this._startPlayback();
|
|
40361
|
-
}, function(e) {
|
|
40362
|
-
_this._pendingPlay = false;
|
|
39949
|
+
AudioManager._registerPendingSource(this);
|
|
39950
|
+
AudioManager.resume().catch(function(e) {
|
|
40363
39951
|
console.warn("Failed to resume AudioContext:", e);
|
|
40364
39952
|
});
|
|
40365
39953
|
}
|
|
@@ -40367,7 +39955,7 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40367
39955
|
/**
|
|
40368
39956
|
* Stops playing the clip.
|
|
40369
39957
|
*/ _proto.stop = function stop() {
|
|
40370
|
-
this.
|
|
39958
|
+
this._cancelPendingPlayback();
|
|
40371
39959
|
if (this._isPlaying) {
|
|
40372
39960
|
this._clearSourceNode();
|
|
40373
39961
|
this._isPlaying = false;
|
|
@@ -40379,7 +39967,7 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40379
39967
|
/**
|
|
40380
39968
|
* Pauses playing the clip.
|
|
40381
39969
|
*/ _proto.pause = function pause() {
|
|
40382
|
-
this.
|
|
39970
|
+
this._cancelPendingPlayback();
|
|
40383
39971
|
if (this._isPlaying) {
|
|
40384
39972
|
this._clearSourceNode();
|
|
40385
39973
|
this._pausedTime = AudioManager.getContext().currentTime;
|
|
@@ -40414,6 +40002,17 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40414
40002
|
_proto._onPlayEnd = function _onPlayEnd() {
|
|
40415
40003
|
this.stop();
|
|
40416
40004
|
};
|
|
40005
|
+
/** @internal */ _proto._resumePendingPlayback = function _resumePendingPlayback() {
|
|
40006
|
+
var _this__clip;
|
|
40007
|
+
if (!this._pendingPlay) {
|
|
40008
|
+
return;
|
|
40009
|
+
}
|
|
40010
|
+
this._pendingPlay = false;
|
|
40011
|
+
if (this._destroyed || !this.enabled || !((_this__clip = this._clip) == null ? void 0 : _this__clip._getAudioSource())) {
|
|
40012
|
+
return;
|
|
40013
|
+
}
|
|
40014
|
+
this._startPlayback();
|
|
40015
|
+
};
|
|
40417
40016
|
_proto._startPlayback = function _startPlayback() {
|
|
40418
40017
|
var startTime = this._pausedTime > 0 ? this._pausedTime - this._playTime : 0;
|
|
40419
40018
|
this._initSourceNode(startTime);
|
|
@@ -40439,6 +40038,13 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40439
40038
|
this._sourceNode.onended = null;
|
|
40440
40039
|
this._sourceNode = null;
|
|
40441
40040
|
};
|
|
40041
|
+
_proto._cancelPendingPlayback = function _cancelPendingPlayback() {
|
|
40042
|
+
if (!this._pendingPlay) {
|
|
40043
|
+
return;
|
|
40044
|
+
}
|
|
40045
|
+
this._pendingPlay = false;
|
|
40046
|
+
AudioManager._unregisterPendingSource(this);
|
|
40047
|
+
};
|
|
40442
40048
|
_create_class(AudioSource, [
|
|
40443
40049
|
{
|
|
40444
40050
|
key: "clip",
|
|
@@ -40842,7 +40448,6 @@ exports.MeshRenderer = MeshRenderer;
|
|
|
40842
40448
|
exports.MeshShape = MeshShape;
|
|
40843
40449
|
exports.MeshTopology = MeshTopology;
|
|
40844
40450
|
exports.ModelMesh = ModelMesh;
|
|
40845
|
-
exports.NoiseModule = NoiseModule;
|
|
40846
40451
|
exports.OverflowMode = OverflowMode;
|
|
40847
40452
|
exports.PBRMaterial = PBRMaterial;
|
|
40848
40453
|
exports.ParticleCompositeCurve = ParticleCompositeCurve;
|