import*asTHREEfrom'three';import{FullscreenQuad,FULLSCREEN_VERT}from'../engine/fullscreen.js';import{U,COMMON_GLSL,NOISE_GLSL,WORLD_GLSL,ARENA_GLSL,LIGHTS_GLSL,FORCES_GLSL,GROUND_GLSL,FX_BLENDING,FX_VERT_HEAD,FX_FRAG_HEAD,FX_OUT_GLSL,LINES_BLENDING,ARENA,}from'./common.js';import{Q}from
g
p g
i i p i
x pi y pi z pi
n x y z x
pi x n y n z n
g
g
g
g
tail
tail
merged g tail
merged
merged
g
p g
i i p i pi pi
g
g
out
name
aname bname
arr
arr arr
outname arr
out
k c k k k
renderer
ground
n
name name
id
lit def def def
k name id lit def
k
name id
id
name
k id id id
k patch
k
id kind kind kind
id slots a b threshold rate lifeScale sizeScale up
d k o k
ca cb d d d
style d
paint d d
morph d d d d
flags d d d
d d d d
d d d d
d d d d d
d d d d d d d
ca d
cb d d
style d style paint morph flags
d d d d
d d d d
d d d d
d
o
k k
debrisRows
rest debrisRows
glowRows rest mediaRows rest glowRows
rows glowRows glowRows mediaRows glowRows mediaRows debrisRows
s
r0 nr rowss
s r0 nr
fi
fd
st fd
count fd st
o fi
st st count fd fd fd fd fd fd fd fd o
st count
fi
fi
rtOpts
rtOpts rtOpts
stateU
stateU
stateU
quad
quad
quad
s s
s
gq quad
gq
stateU
mq quad
mq
stateU
debrisU
src variant variant
g
n srcn gn srcn
g
mat stateU debrisU vi variant
mat debrisU
m g mat
m
m
m
paintScene
s
g
g s
g
g
m g
stateU s
m
m s
m
m
r
rt rrt r r
r
s s
id kind kind kind
id
p
id opts opts
opts opts
opts opts opts
p count
perSecond dt
n
n n p n
name
st e
ring st st
n prescaled count count
n n ring
n
def e life def e
mk def def def
def mkdef touch
reach e life e e
e e reach life
start st
n
take n ring start
o
o st st start o take o e o e
o e o e o e o e
o e o e o e o e
o e o e o e o
o e o e o e o e
h st
sth start sth take sth life
st
st st st
start start take ring
n take
st start
s
s s s
time
u
sc
s s
r r r
o r st o
st st o
s
st s
st
ringStart st st ring st st
a st b ringStart st
b a sca b
sca ringStart ring scringStart b ringStart ringStart ring b
u sc
u
u dt
s
st s ring st st st
st st st time st
j st j st j j
live st st
st live st st
st live st st ring ring ring
s st st st
meshes s s
m meshes
m n
m m base
m n
p p s
p base
p n
p n
s
st s
on s s st st st
mat name name
mat
sh stateU styleU variant
sh sh
sh sh
mat
// instance -> texel: field blocks first, then the live window of the ring
const
INDEX_GLSL
=
/* glsl */
`
uniform int uStyleStart;
uniform int uStyleCount;
uniform int uFieldCount;
uniform int uRingBase;
int particleIndex(int id) {
int ring = uStyleCount - uFieldCount;
int local = id < uFieldCount ? id : uFieldCount + (uRingBase + id - uFieldCount) % max(ring, 1);
return uStyleStart + local;
}
`
;
// colour / alpha / size over life, shared by every style
`
precision highp float;
precision highp int;
precision highp sampler2D;
${COMMON_GLSL}${NOISE_GLSL}${ARENA_GLSL}${FORCES_GLSL}${GROUND_GLSL}${STATE_GLSL(W)}
uniform highp sampler2D uEmitTex;
uniform int uEmitCount;
uniform vec2 uSpan[6];
uniform int uSpanCount;
uniform highp sampler2D uFieldTex;
uniform int uFieldCount;
uniform float uSimDt;
layout(location = 0) out vec4 o0;
layout(location = 1) out vec4 o1;
layout(location = 2) out vec4 o2;
void spawn(int kind, vec3 pos, vec3 vel, float lifeScale, float sizeScale, float seed) {
vec4 k2 = kindTexel(kind, 2);
float life = mix(k2.x, k2.y, hash11(seed * 7.13)) * lifeScale;
o0 = vec4(pos, 0.0);
o1 = vec4(vel, max(life, 1e-3));
o2 = vec4(float(kind) + clamp(sizeScale, 0.0, 9.99) * 0.1, seed, -1e4, 0.0);
}
bool tryEmit(int idx) {
bool inSpan = false;
for (int s = 0; s < 6; s++) {
if (s >= uSpanCount) break;
if (float(idx) >= uSpan[s].x && float(idx) < uSpan[s].y) { inSpan = true; break; }
}
if (!inSpan) return false;
for (int r = 0; r < ${MAX_REC}; r++) {
if (r >= uEmitCount) break;
vec4 e0 = texelFetch(uEmitTex, ivec2(0, r), 0);
int j = idx - int(e0.x);
if (j < 0 || j >= int(e0.y)) continue;
vec4 e1 = texelFetch(uEmitTex, ivec2(1, r), 0), e2 = texelFetch(uEmitTex, ivec2(2, r), 0);
vec4 e3 = texelFetch(uEmitTex, ivec2(3, r), 0), e4 = texelFetch(uEmitTex, ivec2(4, r), 0);
float seed = fract(e3.w + float(j) * 0.618034) * 1000.0 + float(j) * 0.001;
vec4 h = hash41(seed);
vec3 h2 = hash31(seed + 17.0);
int shape = int(e0.w);
vec3 pos = e1.xyz, radial = vec3(0.0);
if (shape == 0) { vec3 d = randomInSphere(h.xyz); pos += d * e1.w; radial = normalize(d + 1e-5); }
else if (shape == 1) { vec3 d = randomOnSphere(h.xy); pos += d * e1.w; radial = d; }
else if (shape == 2 || shape == 3) {
float a = h.x * 2.0 * PI, r = shape == 2 ? sqrt(h.y) : 1.0;
radial = vec3(cos(a), 0.0, sin(a));
pos += radial * r * e1.w;
}
else if (shape == 4) {
vec3 d = randomInSphere(h2);
pos = mix(e1.xyz, e3.xyz, h.x) + d * e1.w;
radial = normalize(d + 1e-5);
}
else { // cone around e3.xyz, half-angle e4.w
pos += randomInSphere(h2) * e1.w;
vec3 ax = normalize(e3.xyz + 1e-6);
float ct = mix(1.0, cos(e4.w), h.x), st = sqrt(1.0 - ct * ct), ph = h.y * 2.0 * PI;
radial = basisFrom(ax) * vec3(st * cos(ph), st * sin(ph), ct);
}
vec3 vel = e2.xyz + randomInSphere(hash31(seed + 31.0)) * e2.w + radial * e4.x * mix(0.6, 1.0, h.w);
spawn(int(e0.z), pos, vel, e4.z, e4.y, seed);
return true;
}
return false;
}
// field emitters: dead texels in a block respawn on the floor where the ground field qualifies
bool tryField(int idx) {
for (int f = 0; f < ${MAX_FIELD}; f++) {
if (f >= uFieldCount) break;
vec4 f0 = texelFetch(uFieldTex, ivec2(0, f), 0);
int j = idx - int(f0.x);
if (j < 0 || j >= int(f0.y)) continue;
vec4 wa = texelFetch(uFieldTex, ivec2(1, f), 0), wb = texelFetch(uFieldTex, ivec2(2, f), 0);
vec4 f3 = texelFetch(uFieldTex, ivec2(3, f), 0);
float seed = hash12(vec2(float(idx), mod(uFrame, 4096.0))) * 1000.0;
vec4 h = hash41(seed);
float a = h.x * 2.0 * PI, r = sqrt(h.y) * ${(ARENA.radius-0.4).toFixed(2)};
vec2 xz = vec2(cos(a), sin(a)) * r;
float s = dot(groundA(xz), wa) + dot(groundB(xz), wb) - f0.w;
if (h.z > s * f3.x * uSimDt) return true; // stays dead this frame
vec3 pos = vec3(xz.x, 0.04, xz.y);
vec2 pq = abs(xz - vec2(${ARENA.pool.center.x.toFixed(3)}, ${ARENA.pool.center.y.toFixed(3)}));
if (pq.x < ${ARENA.pool.half.x.toFixed(3)} && pq.y < ${ARENA.pool.half.y.toFixed(3)}) pos.y += ${ARENA.pool.water.toFixed(3)};
vec3 vel = vec3(0.0, f3.w, 0.0) + randomInSphere(hash31(seed + 5.0)) * 0.3;
spawn(int(f0.z), pos, vel, f3.y, f3.z * clamp(s * 2.0, 0.5, 1.5), seed);
return true;
}
return false;
}
void main() {
ivec2 px = ivec2(gl_FragCoord.xy);
int idx = px.y * PW + px.x;
vec4 s0 = texelFetch(uS0, px, 0);
vec4 s1 = texelFetch(uS1, px, 0);
bool dead = s0.w >= s1.w;
if (dead) {
o0 = vec4(0.0, -1000.0, 0.0, 1e9); o1 = vec4(0.0, 0.0, 0.0, 1.0); o2 = vec4(0.0, 0.0, -1e4, 0.0);
if (!tryEmit(idx)) tryField(idx);
return;
}
// a texel re-allocated by the ring this frame restarts even if still alive (pool full: oldest die)
if (tryEmit(idx)) return;
vec4 s2 = texelFetch(uS2, px, 0);
int kind = int(s2.x);
float sizeScale = fract(s2.x) * 10.0;
vec4 k0 = kindTexel(kind, 0), k1 = kindTexel(kind, 1), k2 = kindTexel(kind, 2), k6 = kindTexel(kind, 6);
vec4 k8 = kindTexel(kind, 8);
float dt = uSimDt;
vec3 pos = s0.xyz, vel = s1.xyz;
float age = s0.w + dt, life = s1.w, t = age / life;
float kill = 0.0;
vec3 acc = vec3(0.0, k0.z * (1.0 - 0.6 * t) - k0.y, 0.0);
if (k0.w != 0.0) acc += curl3(pos * k1.x + vec3(0.0, uTime * 0.05, 0.0) + s2.y * 0.01) * k0.w;
if (k1.y != 0.0) acc += forceAccel(pos, vel, kill) * k1.y;
vel += acc * dt;
vel *= exp(-k0.x * dt);
vec3 np = pos + vel * dt;
// collision with the arena (floor, rim, pillars, dummies, dynamic capsules)
float custom = s2.w, collide = s2.z;
if (k1.z >= 0.0) {
float rad = max(mix(k2.z, k2.w, t) * sizeScale * 0.5, 0.01);
float d = arenaSDF(np);
if (d < rad) {
vec3 n = arenaNormal(np);
np += n * (rad - d);
float vn = dot(vel, n);
if (vn < 0.0) {
vec3 vt = vel - n * vn;
vel = vt * (1.0 - k1.w) - n * vn * k1.z;
}
collide = uTime;
int flags = int(k6.w);
if ((flags & 2) != 0) kill = 1.0;
if (k6.z > 0.5) { // morph into another kind, keeping position and the bounce
int m = int(k6.z) - 1;
vec4 m2 = kindTexel(m, 2);
kind = m; age = 0.0;
life = mix(m2.x, m2.y, hash11(s2.y * 3.7));
}
// debris: remember when it came to rest (its spin freezes there)
if (custom <= 0.0 && dot(vel, vel) < 0.04 && k6.x > 2.5) custom = age;
}
}
// orbit hook: keep a Kepler-ish disk tidy (accretion), uses force 'orbit' for speed
if (kill > 0.5) age = life;
o0 = vec4(np, age);
o1 = vec4(vel, life);
o2 = vec4(float(kind) + sizeScale * 0.1, s2.y, collide, custom);
}`
;
// --- glow: velocity-stretched additive quads, full res ---------------------------------
const
GLOW_VERT
=
(
W
)
=>
/* glsl */
`
precision highp float;
precision highp int;
${COMMON_GLSL}${NOISE_GLSL}${STATE_GLSL(W)}${INDEX_GLSL}${LOOK_GLSL}
out vec2 vUv;
out vec3 vColor;
out float vSoft;
void main() {
int idx = particleIndex(gl_InstanceID);
ivec2 px = texelOf(idx);
vec4 s0 = texelFetch(uS0, px, 0), s1 = texelFetch(uS1, px, 0);
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
vColor = vec3(0.0);
if (s0.w >= s1.w) return;
vec4 s2 = texelFetch(uS2, px, 0);
int kind = int(s2.x);
float t = s0.w / s1.w;
Look l = particleLook(kind, t, fract(s2.x) * 10.0);
vec4 k3 = kindTexel(kind, 3);
vec3 headV = (viewMatrix * vec4(s0.xyz, 1.0)).xyz;
vec3 tailV = (viewMatrix * vec4(s0.xyz - s1.xyz * k3.x, 1.0)).xyz;
float viewZ = max(-headV.z, 0.05);
float pxWorld = 2.0 * viewZ / (projectionMatrix[1][1] * uResolution.y);
float size = l.size, w = max(size, 1.5 * pxWorld);
float aa = size / w; // Humus phone-wire AA: keep energy when clamped to 1.5 px
vec2 axis = tailV.xy - headV.xy;
float len = length(axis);
vec2 dir = len > 1e-4 ? axis / len : vec2(1.0, 0.0);
vec2 perp = vec2(-dir.y, dir.x);
// quad: x in [-1, 1] spans head (-1) .. tail (+1) plus caps, y across
vec2 off = dir * (position.x < 0.0 ? -w : len + w) + perp * position.y * w;
vec3 pv = headV + vec3(off, 0.0);
gl_Position = projectionMatrix * vec4(pv, 1.0);
vUv = vec2(position.x < 0.0 ? -1.0 : 1.0, position.y);
vSoft = len / (len + 2.0 * w); // how much of the quad is the stretched body
float nearFade = smoothstep(0.3, 1.2, viewZ);
// stretching spreads the same energy over a longer streak (motion-blur conservation)
float fk = kindTexel(kind, 10).x, ph = s2.y * 97.0 + s0.w * mix(9.0, 23.0, fract(s2.y * 13.7));
vColor = l.color * l.emissive * l.alpha * aa * nearFade * (2.0 * w / (len + 2.0 * w)) * (1.0 - fk * (0.5 + 0.5 * sin(ph) * sin(ph * 0.37 + 1.3)));
}`
;
const
GLOW_FRAG
=
/* glsl */
`
precision highp float;
in vec2 vUv;
in vec3 vColor;
in float vSoft;
out vec4 fragColor;
void main() {
// capsule falloff: distance from the centre segment in quad units
float x = vUv.x * 0.5 + 0.5; // 0 head .. 1 tail
float ends = 1.0 - vSoft;
float dx = x < ends * 0.5 ? (ends * 0.5 - x) / max(ends * 0.5, 1e-3) : x > 1.0 - ends * 0.5 ? (x - 1.0 + ends * 0.5) / max(ends * 0.5, 1e-3) : 0.0;
float d2 = dx * dx + vUv.y * vUv.y;
float core = exp(-d2 * 4.0);
float tailFade = mix(1.0, 0.35, x); // brighter at the head
fragColor = vec4(vColor * core * tailFade, 0.0);
}`
;
// --- media: spherical billboards into the half-res WBOIT pass ---------------------------
const
MEDIA_VERT
=
(
W
)
=>
FX_VERT_HEAD
+
/* glsl */
`${COMMON_GLSL}${NOISE_GLSL}${ARENA_GLSL}${LIGHTS_GLSL}${STATE_GLSL(W)}${INDEX_GLSL}${LOOK_GLSL}
uniform vec3 uSunDir;
uniform vec3 uSunColor;
uniform vec3 uAmbient;
out vec2 vUv;
out vec3 vSun;
out vec3 vAmb;
out vec3 vSunL;
out vec3 vUpL;
out vec3 vEmit;
out float vAlpha;
out float vViewZ;
out float vRadius;
out float vDensity;
out float vErode;
out float vDistort;
out vec3 vNoise;
void main() {
int idx = particleIndex(gl_InstanceID);
ivec2 px = texelOf(idx);
vec4 s0 = texelFetch(uS0, px, 0), s1 = texelFetch(uS1, px, 0);
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
vAlpha = 0.0;
if (s0.w >= s1.w) return;
vec4 s2 = texelFetch(uS2, px, 0);
int kind = int(s2.x);
float t = s0.w / s1.w;
Look l = particleLook(kind, t, fract(s2.x) * 10.0);
vec4 k6 = kindTexel(kind, 6), k7 = kindTexel(kind, 7), k9 = kindTexel(kind, 9);
vec3 cv = (viewMatrix * vec4(s0.xyz, 1.0)).xyz;
float viewZ = -cv.z;
if (viewZ < 0.05) return;
// overdraw guard: never wider than 12% of the screen height
float maxR = 0.12 * viewZ / projectionMatrix[1][1];
float r = min(l.size * 0.5, maxR);
float spin = s2.y + s0.w * kindTexel(kind, 8).z;
vec2 c = vec2(cos(spin), sin(spin));
vec2 q = mat2(c.x, -c.y, c.y, c.x) * position.xy;
gl_Position = projectionMatrix * vec4(cv + vec3(q * r, 0.0), 1.0);
vUv = position.xy;
vViewZ = viewZ;
vRadius = r;
vDensity = k7.z;
vErode = kindTexel(kind, 9).z * t; // erosion grows with age
vDistort = k7.w * l.alpha;
vNoise = s0.xyz * 0.35 + s2.y;
bool absorbing = (int(k6.w) & 1) != 0;
float smoke = absorbing ? 1.0 : l.smoke;
// lighting for the scattering part: sun with forward scattering, sky, spell lights
gLightNoShadow = true;
vec3 v = normalize(cameraPosition - s0.xyz);
float g = 0.35;
// flames glow; what scatters light is their soot, never their own blackbody colour
vec3 albedo = l.emissive > 0.0 ? vec3(k7.y) : mix(l.color, vec3(k7.y), smoke);
if (absorbing) albedo = l.color;
vSun = albedo * uSunColor * hgPhase(dot(uSunDir, -v), g) * 4.0 * PI * 0.6;
vAmb = albedo * (uAmbient * 1.4 + spellLightScatter(s0.xyz, v, g) * k9.x);
// sun and up in the sprite's own frame (view space turned back by the spin), so the fragment
// can shade the billboard as the sphere it stands for
vec3 sv = mat3(viewMatrix) * uSunDir, up = mat3(viewMatrix) * vec3(0.0, 1.0, 0.0);
mat2 unspin = mat2(c.x, c.y, -c.y, c.x);
vSunL = vec3(unspin * sv.xy, sv.z);
vUpL = vec3(unspin * up.xy, up.z);
// emission fades as fire turns to smoke
vEmit = (l.emissive > 0.0 && !absorbing) ? l.color * l.emissive * (1.0 - smoke) : vec3(0.0);
vAlpha = l.alpha;
// pure emitters (flames before they smoke) are mostly glow, little occlusion
vAlpha *= mix(0.25 + 0.75 * smoke, 1.0, step(l.emissive, 0.0));
vAlpha *= smoothstep(0.2, 1.0, viewZ);
}`
;
const
MEDIA_FRAG
=
(
W
)
=>
FX_FRAG_HEAD
+
/* glsl */
`${COMMON_GLSL}${NOISE_GLSL}${FX_OUT_GLSL}
in vec2 vUv;
in vec3 vSun;
in vec3 vAmb;
in vec3 vSunL;
in vec3 vUpL;
in vec3 vEmit;
in float vAlpha;
in float vViewZ;
in float vRadius;
in float vDensity;
in float vErode;
in float vDistort;
in vec3 vNoise;
void main() {
if (vAlpha <= 0.001) discard;
float r2 = dot(vUv, vUv);
if (r2 >= 1.0) discard;
// spherical billboard (Umenhoffer et al. 2006): visible thickness of a sphere, cut by the scene
float h = sqrt(1.0 - r2) * vRadius;
float sceneZ = sceneViewZ();
float thick = clamp(min(vViewZ + h, sceneZ) - max(vViewZ - h, uNearFar.x), 0.0, 2.0 * h);
// eroded by world-space noise so a sprite reads as a lumpy volume; a finer octave rags the edges
float n = noise3(vNoise + vec3(vUv * 0.42, 0.0)) * 0.72 + noise3(vNoise * 2.7 + vec3(vUv * 1.1, 0.0)) * 0.28;
float er = smoothstep(vErode, vErode + 0.35, n * (1.15 - r2 * 0.6));
// billows and gaps from the first frame of a puff's life, not only once it erodes
float b = smoothstep(0.22, 0.62, n);
float a = (1.0 - exp(-vDensity * thick * (0.35 + 0.65 * b))) * er * vAlpha;
// shading: a dense puff is a lit sphere with a dark side, a dark core against the sun and billows
// that shadow each other (noise denser towards the sun = in shadow, one extra tap); thin wisps
// scatter evenly. Normalised so a front-lit puff keeps about its old mean brightness.
vec3 N = vec3(vUv, sqrt(1.0 - r2));
float dense = 1.0 - exp(-vDensity * vRadius * 2.0);
float ns = noise3(vNoise + vec3((vUv + vSunL.xy * 0.3) * 0.42, 0.0));
float self = clamp(0.5 + (n - ns) * 4.5, 0.0, 1.0);
float lam = clamp((dot(N, vSunL) + 0.35) / 1.35, 0.0, 1.0);
float through = exp(-vDensity * thick);
float sunShade = mix(through, lam, clamp(vSunL.z * 0.5 + 0.5, 0.0, 1.0)) * mix(1.0, self, 0.85) * 2.2;
float ambShade = (0.65 + 0.35 * dot(N, vUpL)) * (0.5 + 0.5 * sqrt(r2)) * 1.7;
vec3 vLit = vSun * mix(1.0, sunShade, dense) + vAmb * mix(1.0, ambShade, dense);
vec2 dist = vDistort * (vec2(noise3(vNoise * 1.7 + uTime * 0.6), noise3(vNoise.zxy * 1.7 - uTime * 0.6)) - 0.5) * 0.02 * (1.0 - r2);
// fire is hottest deep in a billow: thin edges and gaps run redder and much dimmer
float core = b * (1.0 - r2);
vec3 emit = vEmit * mix(vec3(0.5, 0.2, 0.08), vec3(1.5, 1.35, 1.2), core * core);
fxOut(vLit, a, emit * a * 2.0, dist, vViewZ);
}`
;
// --- painting the ground field where paint kinds collided this frame --------------------
const
PAINT_VERT
=
(
W
)
=>
/* glsl */
`
precision highp float;
precision highp int;
uniform float uTime;
uniform vec4 uGroundRect;
${STATE_GLSL(W)}${INDEX_GLSL}
out vec4 vA;
out vec4 vB;
void main() {
int idx = particleIndex(gl_VertexID);
ivec2 px = texelOf(idx);
vec4 s0 = texelFetch(uS0, px, 0), s2 = texelFetch(uS2, px, 0);
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
gl_PointSize = 1.0;
vA = vB = vec4(0.0);
if (s2.z != uTime) return; // collided this frame (the sim wrote exactly this uniform)
int kind = int(s2.x);
vec4 k6 = kindTexel(kind, 6), k9 = kindTexel(kind, 9);
int ch = int(k6.y) - 1;
if (ch < 0) return;
vec2 uv = (s0.xz - uGroundRect.xy) * uGroundRect.w;
gl_Position = vec4(uv * 2.0 - 1.0, 0.0, 1.0);
gl_PointSize = 3.0;
float amt = kindTexel(kind, 9).w;
if (ch < 4) vA[ch] = amt; else vB[ch - 4] = amt;
}`
;
const
PAINT_FRAG
=
/* glsl */
`
precision highp float;
in vec4 vA;
in vec4 vB;
layout(location = 0) out vec4 gA;
layout(location = 1) out vec4 gB;
void main() {
float f = 1.0 - length(gl_PointCoord * 2.0 - 1.0);
if (f <= 0.0) discard;
gA = vA * f; gB = vB * f;
}`
;
// --- geometry for debris variants -----------------------------------------------------
function
rockGeometry
(
)
{
const
=
new
THREE.IcosahedronGeometry
(
0.5
,
1
)
;
const
=
.
attributes
.
position
;
for
(
let
=
0
;
<
.
count
;
++
)
{
const
=
.
getX
(
)
,
=
.
getY
(
)
,
=
.
getZ
(
)
;
const
=
0.75
+
0.35
*
Math
.
abs
(
Math
.
sin
(
*
9.1
+
*
4.3
)
*
Math
.
cos
(
*
7.7
-
*
2.1
)
)
;
.
setXYZ
(
,
*
,
*
*
0.8
,
*
)
;
}
.
computeVertexNormals
(
)
;
return
;
// polyhedra are already non-indexed, so the normals are faceted
}
function
shardGeometry
(
)
{
// hexagonal ice shard: prism with a pointed tip, flat facets