# Hybrid 3D Gaussian Splatting (3DGS) Diorama & Proxy-Mesh Shadow Compositing in Three.js (WebGL 2)

> Render anisotropic 3D Gaussian Splat backdrops and dioramas in Three.js r183 WebGL 2 via instanced quads, EWA perspective covariance projection, and zero-allocation bucket depth sorting, composited cleanly with opaque PBR gameplay actors and a ShadowMaterial shadow-catcher proxy floor.

- **Canonical page:** https://gamecrew.ai/techniques/three/hybrid-gaussian-splatting-diorama
- **Techniques hub:** https://gamecrew.ai/techniques
- **Engine:** Three.js
- **Category:** rendering
- **Tags:** `gaussian-splatting`, `3dgs`, `splat`, `diorama`, `proxy-mesh`, `shadow-catcher`, `covariance`, `depth-sort`, `rendering`, `webgl2`
- **Verification:** Compile-verified pattern
- **Revision:** 1 (2026-11-30)
- **Demo:** No demo

## When to Use (and When Not To)

3D Gaussian Splatting (3DGS) lets small teams render organic dioramas, photogrammetry/world-model backdrops, and painterly foliage volumes that would otherwise cost hundreds of thousands of triangles. The main engineering trap in games is **hybrid compositing**: raw splats have no triangle depth for shadows, get drawn in broken order on camera turns, or allocate garbage every frame during sorting.

- **Use this technique** when combining a 3DGS environment or hero diorama with interactive PBR characters, pickups, collision proxy floors, and real cast shadows in WebGL 2.
- **Skip this technique** for tightly articulated skinned characters or sharp mechanical props that need crisp specular normal maps and dynamic self-shadowing — keep those as standard PBR meshes composited *inside* the splat world.

## Mathematical & Algorithmic Core

1. **Anisotropic 3D Covariance Projection (EWA Splatting)**:
   - Each Gaussian stores center $\boldsymbol{\mu} \in \mathbb{R}^3$, scale $\mathbf{s} \in \mathbb{R}^3$, unit quaternion $\mathbf{q}$, and linear color + opacity.
   - Its 3D covariance $\boldsymbol{\Sigma}_{3\text{D}} = \mathbf{R}\mathbf{S}\mathbf{S}^\top\mathbf{R}^\top$ is projected into 2D screen pixels via the perspective Jacobian $\mathbf{J}$ and view rotation $\mathbf{W}$:
     $$\boldsymbol{\Sigma}_{2\text{D}} = \mathbf{J}\mathbf{W}\boldsymbol{\Sigma}_{3\text{D}}\mathbf{W}^\top\mathbf{J}^\top + 0.3\mathbf{I}$$
   - Closed-form $2\times 2$ symmetric eigendecomposition extracts the two principal ellipse radii and eigenvectors directly in the vertex shader, expanding one instanced quad to $\pm 2.5\sigma$ while clamping maximum pixel radius so close-up splats cannot stall mobile fill-rate.
2. **Zero-Allocation $O(N + B)$ Back-to-Front Depth Sort**:
   - Pre-allocate `2048` integer depth buckets plus scratch typed arrays once at load. Project splat centers along the camera forward axis, quantize to `[0..2047]` farthest-first, run a single counting-sort pass, and repack the `DynamicDrawUsage` instanced buffers.
   - Gate re-sorting behind a camera-pose hysteresis check (`distanceSq > 0.015` or `dot(dir, prevDir) < 0.9994`) so static frames incur **0 ms** sort cost while camera cuts resort immediately.
3. **Depth-Tested Hybrid Compositing & Shadow Catching**:
   - Opaque PBR meshes render first into the depth buffer. Splats render afterward with `depthTest: true`, `depthWrite: false`, `THREE.NormalBlending` (`renderOrder: 4`), so PBR actors properly occlude splats behind them while foreground splats blend cleanly in front.
   - A `THREE.ShadowMaterial` proxy plane (`renderOrder: 6`, `receiveShadow: true`, `depthWrite: false`) sits at the splat ground height so real gameplay actors cast grounded shadows directly onto the splat diorama.

## Engine Implementation (`Assets/Game/gaussianSplatDiorama.ts`)

```ts
import * as THREE from 'three';

export interface SplatRecord {
  position: [number, number, number];
  scale: [number, number, number];
  rotation: [number, number, number, number];
  color: [number, number, number];
  opacity: number;
}

export interface SplatCloudData {
  count: number;
  positions: Float32Array;
  scales: Float32Array;
  rotations: Float32Array;
  colors: Float32Array;
}

export interface GaussianSplatRenderer {
  mesh: THREE.Mesh;
  count: number;
  uniforms: {
    uViewport: { value: THREE.Vector2 };
    uSplatScale: { value: number };
    uMaxPixelRadius: { value: number };
  };
  /** Re-sorts back-to-front using an O(N + B) zero-allocation bucket sort when camera moves past threshold. */
  syncCamera: (camera: THREE.Camera, viewportWidth: number, viewportHeight: number, force?: boolean) => boolean;
  setSplatScale: (scale: number) => void;
  getSortCount: () => number;
  getLastOrder: () => Uint32Array;
  dispose: () => void;
}

/** Packs an array of SplatRecord entries into contiguous typed arrays suitable for instanced WebGL 2 rendering. */
export function packSplatRecords(records: readonly SplatRecord[]): SplatCloudData {
  const count = records.length;
  const positions = new Float32Array(count * 3);
  const scales = new Float32Array(count * 3);
  const rotations = new Float32Array(count * 4);
  const colors = new Float32Array(count * 4);

  for (let i = 0; i < count; i++) {
    const r = records[i];
    const i3 = i * 3;
    const i4 = i * 4;
    positions[i3] = r.position[0];
    positions[i3 + 1] = r.position[1];
    positions[i3 + 2] = r.position[2];

    scales[i3] = Math.max(0.005, r.scale[0]);
    scales[i3 + 1] = Math.max(0.005, r.scale[1]);
    scales[i3 + 2] = Math.max(0.005, r.scale[2]);

    const qLen = Math.hypot(r.rotation[0], r.rotation[1], r.rotation[2], r.rotation[3]) || 1;
    rotations[i4] = r.rotation[0] / qLen;
    rotations[i4 + 1] = r.rotation[1] / qLen;
    rotations[i4 + 2] = r.rotation[2] / qLen;
    rotations[i4 + 3] = r.rotation[3] / qLen;

    colors[i4] = Math.min(1, Math.max(0, r.color[0]));
    colors[i4 + 1] = Math.min(1, Math.max(0, r.color[1]));
    colors[i4 + 2] = Math.min(1, Math.max(0, r.color[2]));
    colors[i4 + 3] = Math.min(1, Math.max(0, r.opacity));
  }
  return { count, positions, scales, rotations, colors };
}

/**
 * Deterministic procedural 3D Gaussian Splat sanctuary builder (mossy stone terrace, twin weathered pillars + arch,
 * sunlit blossom trees, and warm glowing lantern flora) — zero external downloads needed for demos and tests.
 */
export function buildSanctuarySplatCloud(seed = 202609): SplatCloudData {
  let state = seed >>> 0;
  const rnd = () => {
    state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
    return state / 4294967296;
  };
  const records: SplatRecord[] = [];
  const tmpQuat = new THREE.Quaternion();
  const tmpEuler = new THREE.Euler();

  const pushSplat = (
    px: number, py: number, pz: number,
    sx: number, sy: number, sz: number,
    rx: number, ry: number, rz: number,
    cr: number, cg: number, cb: number, opacity: number
  ) => {
    tmpEuler.set(rx, ry, rz);
    tmpQuat.setFromEuler(tmpEuler);
    records.push({
      position: [px, py, pz],
      scale: [sx, sy, sz],
      rotation: [tmpQuat.x, tmpQuat.y, tmpQuat.z, tmpQuat.w],
      color: [cr, cg, cb],
      opacity,
    });
  };

  // 1. Mossy stone garden terrace disc (flat anisotropic splats hugging y ~= -0.06)
  for (let i = 0; i < 1100; i++) {
    const r = Math.sqrt(rnd()) * 6.4;
    const a = rnd() * Math.PI * 2;
    const x = Math.cos(a) * r;
    const z = Math.sin(a) * r;
    const isPath = Math.abs(x) < 1.35 && z < 2.2;
    const edgeFade = r > 5.3 ? 0.65 : 0.92;
    const j = (rnd() - 0.5) * 0.08;
    const col: [number, number, number] = isPath
      ? [0.68 + j, 0.65 + j, 0.58 + j]
      : [0.24 + j * 0.8, 0.46 + j, 0.23 + j * 0.6];
    pushSplat(
      x, -0.06 - (r > 5.6 ? (r - 5.6) * 0.25 : 0) + (rnd() - 0.5) * 0.05, z,
      0.24 + rnd() * 0.22, 0.06 + rnd() * 0.04, 0.24 + rnd() * 0.22,
      (rnd() - 0.5) * 0.14, rnd() * Math.PI, (rnd() - 0.5) * 0.14,
      col[0], col[1], col[2], edgeFade
    );
  }

  // 2. Twin weathered sanctuary columns + curved lintel arch behind the hero plinth (z = 2.6)
  for (const side of [-2.4, 2.4]) {
    for (let i = 0; i < 240; i++) {
      const h = rnd() * 3.8;
      const a = rnd() * Math.PI * 2;
      const rad = 0.42 + (rnd() - 0.5) * 0.12;
      const moss = h < 1.1 ? 0.45 * (1 - h / 1.1) : 0;
      const j = (rnd() - 0.5) * 0.07;
      pushSplat(
        side + Math.cos(a) * rad, h + 0.1, 2.6 + Math.sin(a) * rad,
        0.16 + rnd() * 0.1, 0.22 + rnd() * 0.12, 0.16 + rnd() * 0.1,
        (rnd() - 0.5) * 0.2, a, (rnd() - 0.5) * 0.2,
        0.74 * (1 - moss) + 0.25 * moss + j,
        0.71 * (1 - moss) + 0.48 * moss + j,
        0.65 * (1 - moss) + 0.24 * moss + j,
        0.92
      );
    }
  }
  for (let i = 0; i < 260; i++) {
    const t = rnd();
    const ang = t * Math.PI;
    const x = -Math.cos(ang) * 2.45 + (rnd() - 0.5) * 0.22;
    const y = 3.7 + Math.sin(ang) * 1.45 + (rnd() - 0.5) * 0.2;
    const z = 2.6 + (rnd() - 0.5) * 0.55;
    const j = (rnd() - 0.5) * 0.08;
    pushSplat(
      x, y, z,
      0.24 + rnd() * 0.14, 0.18 + rnd() * 0.1, 0.2 + rnd() * 0.12,
      (rnd() - 0.5) * 0.3, (rnd() - 0.5) * 0.5, ang - Math.PI * 0.5,
      0.77 + j, 0.72 + j, 0.64 + j, 0.94
    );
  }

  // 3. Two stylized blossom & cypress foliage canopies flanking the arch
  const trees: { cx: number; cy: number; cz: number; rad: number; palette: [number, number, number][] }[] = [
    {
      cx: -3.7, cy: 3.1, cz: 1.5, rad: 1.65,
      palette: [[0.96, 0.62, 0.74], [0.99, 0.78, 0.85], [0.85, 0.44, 0.58]],
    },
    {
      cx: 3.8, cy: 2.9, cz: 1.4, rad: 1.55,
      palette: [[0.20, 0.58, 0.46], [0.34, 0.74, 0.54], [0.16, 0.44, 0.36]],
    },
  ];
  for (const tree of trees) {
    // Trunk splats
    for (let i = 0; i < 90; i++) {
      const h = rnd() * (tree.cy - 0.3);
      const a = rnd() * Math.PI * 2;
      const rr = 0.22 * (1 - h / (tree.cy * 1.4));
      pushSplat(
        tree.cx + Math.cos(a) * rr, h + 0.1, tree.cz + Math.sin(a) * rr,
        0.13, 0.24, 0.13, 0, a, 0,
        0.38, 0.26, 0.19, 0.94
      );
    }
    // Canopy leaf-cloud splats
    for (let i = 0; i < 420; i++) {
      const u = rnd() * 2 - 1;
      const phi = rnd() * Math.PI * 2;
      const s = Math.sqrt(1 - u * u);
      const r = Math.cbrt(rnd()) * tree.rad;
      const px = tree.cx + s * Math.cos(phi) * r * 1.15;
      const py = tree.cy + u * r * 0.82;
      const pz = tree.cz + s * Math.sin(phi) * r;
      const base = tree.palette[i % tree.palette.length];
      const sunBoost = 0.85 + 0.25 * (u * 0.5 + 0.5);
      pushSplat(
        px, py, pz,
        0.26 + rnd() * 0.18, 0.18 + rnd() * 0.12, 0.24 + rnd() * 0.16,
        rnd() * Math.PI, rnd() * Math.PI, rnd() * Math.PI,
        Math.min(1, base[0] * sunBoost), Math.min(1, base[1] * sunBoost), Math.min(1, base[2] * sunBoost),
        0.84
      );
    }
  }

  // 4. Warm amber glowing shrine wisps hovering under the arch
  for (let i = 0; i < 90; i++) {
    const a = rnd() * Math.PI * 2;
    const r = 0.8 + rnd() * 3.8;
    pushSplat(
      Math.cos(a) * r, 0.65 + rnd() * 3.4, 0.6 + Math.sin(a) * r * 0.7,
      0.08 + rnd() * 0.06, 0.08 + rnd() * 0.06, 0.08 + rnd() * 0.06,
      0, 0, 0,
      1.0, 0.82, 0.36, 0.72
    );
  }

  return packSplatRecords(records);
}

const SPLAT_VERTEX_SHADER = /* glsl */ `
  precision highp float;
  attribute vec3 aCenter;
  attribute vec3 aScale;
  attribute vec4 aQuat;
  attribute vec4 aColorOpacity;

  uniform vec2 uViewport;
  uniform float uSplatScale;
  uniform float uMaxPixelRadius;

  varying vec2 vLocal;
  varying vec4 vColorOpacity;

  mat3 quatToMat3(vec4 q) {
    float x = q.x, y = q.y, z = q.z, w = q.w;
    float x2 = x + x, y2 = y + y, z2 = z + z;
    float xx = x * x2, xy = x * y2, xz = x * z2;
    float yy = y * y2, yz = y * z2, zz = z * z2;
    float wx = w * x2, wy = w * y2, wz = w * z2;
    return mat3(
      1.0 - (yy + zz), xy + wz, xz - wy,
      xy - wz, 1.0 - (xx + zz), yz + wx,
      xz + wy, yz - wx, 1.0 - (xx + yy)
    );
  }

  void main() {
    vec4 worldCenter = modelMatrix * vec4(aCenter, 1.0);
    vec4 viewCenter = viewMatrix * worldCenter;
    if (viewCenter.z > -0.15) {
      gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
      vLocal = vec2(10.0);
      vColorOpacity = vec4(0.0);
      return;
    }

    vec4 clipCenter = projectionMatrix * viewCenter;
    vec3 ndcCenter = clipCenter.xyz / clipCenter.w;

    // 3D world covariance Sigma = R * S * S^T * R^T projected into view space
    mat3 R = quatToMat3(aQuat);
    vec3 s = aScale * uSplatScale;
    mat3 M = mat3(R[0] * s.x, R[1] * s.y, R[2] * s.z);
    mat3 sigma3D = M * transpose(M);

    mat3 W = mat3(viewMatrix) * mat3(modelMatrix);
    float fx = projectionMatrix[0][0] * uViewport.x * 0.5;
    float fy = projectionMatrix[1][1] * uViewport.y * 0.5;
    float invZ = 1.0 / (-viewCenter.z);
    float limX = 1.35 * (uViewport.x * 0.5 / max(1.0, fx));
    float limY = 1.35 * (uViewport.y * 0.5 / max(1.0, fy));
    float tx = clamp(viewCenter.x * invZ, -limX, limX) * (-viewCenter.z);
    float ty = clamp(viewCenter.y * invZ, -limY, limY) * (-viewCenter.z);

    // EWA perspective projection Jacobian (column-major in GLSL)
    mat3 J = mat3(
      fx * invZ, 0.0, 0.0,
      0.0, fy * invZ, 0.0,
      -fx * tx * invZ * invZ, -fy * ty * invZ * invZ, 0.0
    );
    mat3 T = J * W;
    mat3 cov = T * sigma3D * transpose(T);

    float covA = cov[0][0] + 0.3;
    float covB = cov[0][1];
    float covC = cov[1][1] + 0.3;

    float det = covA * covC - covB * covB;
    float mid = 0.5 * (covA + covC);
    float disc = sqrt(max(0.05, mid * mid - det));
    float lambda1 = max(0.1, mid + disc);
    float lambda2 = max(0.1, mid - disc);

    vec2 eig1 = normalize(vec2(covB, lambda1 - covA) + vec2(1e-6, 0.0));
    vec2 eig2 = vec2(eig1.y, -eig1.x);

    float r1 = min(uMaxPixelRadius, sqrt(lambda1));
    float r2 = min(uMaxPixelRadius, sqrt(lambda2));
    vec2 quad = position.xy * 2.5;
    vec2 pixelOffset = eig1 * (r1 * quad.x) + eig2 * (r2 * quad.y);
    vec2 ndcOffset = (pixelOffset * 2.0) / max(vec2(1.0), uViewport);

    gl_Position = vec4(ndcCenter.xy + ndcOffset, ndcCenter.z, 1.0);
    vLocal = quad;
    vColorOpacity = aColorOpacity;
  }
`;

const SPLAT_FRAGMENT_SHADER = /* glsl */ `
  precision highp float;
  varying vec2 vLocal;
  varying vec4 vColorOpacity;

  void main() {
    float r2 = dot(vLocal, vLocal);
    if (r2 > 6.25) discard;
    float weight = exp(-0.5 * r2);
    float alpha = min(0.99, vColorOpacity.a * weight);
    if (alpha < 0.02) discard;
    gl_FragColor = vec4(vColorOpacity.rgb, alpha);
  }
`;

/**
 * Creates a WebGL 2 instanced 3D Gaussian Splat mesh with zero-allocation O(N + B) bucket depth sorting
 * and depth-tested compositing against opaque PBR gameplay meshes.
 */
export function createGaussianSplatRenderer(data: SplatCloudData, maxPixelRadius = 96): GaussianSplatRenderer {
  const count = data.count;
  const quad = new THREE.PlaneGeometry(2, 2);
  const geo = new THREE.InstancedBufferGeometry();
  geo.index = quad.index;
  geo.attributes.position = quad.attributes.position;
  geo.instanceCount = count;

  // Sorted working buffers bound to WebGL 2 instanced attributes
  const sortedPos = new Float32Array(data.positions);
  const sortedScale = new Float32Array(data.scales);
  const sortedRot = new Float32Array(data.rotations);
  const sortedCol = new Float32Array(data.colors);

  const posAttr = new THREE.InstancedBufferAttribute(sortedPos, 3);
  const scaleAttr = new THREE.InstancedBufferAttribute(sortedScale, 3);
  const rotAttr = new THREE.InstancedBufferAttribute(sortedRot, 4);
  const colAttr = new THREE.InstancedBufferAttribute(sortedCol, 4);
  posAttr.setUsage(THREE.DynamicDrawUsage);
  scaleAttr.setUsage(THREE.DynamicDrawUsage);
  rotAttr.setUsage(THREE.DynamicDrawUsage);
  colAttr.setUsage(THREE.DynamicDrawUsage);

  geo.setAttribute('aCenter', posAttr);
  geo.setAttribute('aScale', scaleAttr);
  geo.setAttribute('aQuat', rotAttr);
  geo.setAttribute('aColorOpacity', colAttr);

  const uniforms = {
    uViewport: { value: new THREE.Vector2(960, 540) },
    uSplatScale: { value: 1.0 },
    uMaxPixelRadius: { value: maxPixelRadius },
  };
  const mat = new THREE.ShaderMaterial({
    uniforms,
    vertexShader: SPLAT_VERTEX_SHADER,
    fragmentShader: SPLAT_FRAGMENT_SHADER,
    transparent: true,
    depthTest: true,
    depthWrite: false,
    blending: THREE.NormalBlending,
    side: THREE.DoubleSide,
  });

  const mesh = new THREE.Mesh(geo, mat);
  mesh.name = 'GaussianSplatCloud';
  mesh.frustumCulled = false;
  mesh.renderOrder = 4;

  // Pre-allocated O(N + B) back-to-front counting-sort scratchpad (zero GC per frame)
  const BUCKETS = 2048;
  const counts = new Uint32Array(BUCKETS);
  const depths = new Float32Array(count);
  const keys = new Uint16Array(count);
  const order = new Uint32Array(count);
  for (let i = 0; i < count; i++) order[i] = i;

  const lastCamPos = new THREE.Vector3(Infinity, Infinity, Infinity);
  const lastCamDir = new THREE.Vector3(0, 0, -1);
  const curPos = new THREE.Vector3();
  const curDir = new THREE.Vector3();
  let sortCount = 0;

  const sortNow = (camPos: THREE.Vector3, camDir: THREE.Vector3) => {
    let minD = Infinity;
    let maxD = -Infinity;
    const fx = camDir.x;
    const fy = camDir.y;
    const fz = camDir.z;
    const cx = camPos.x;
    const cy = camPos.y;
    const cz = camPos.z;

    for (let i = 0; i < count; i++) {
      const i3 = i * 3;
      const d = (data.positions[i3] - cx) * fx + (data.positions[i3 + 1] - cy) * fy + (data.positions[i3 + 2] - cz) * fz;
      depths[i] = d;
      if (d < minD) minD = d;
      if (d > maxD) maxD = d;
    }

    counts.fill(0);
    const invRange = (BUCKETS - 1) / Math.max(1e-4, maxD - minD);
    for (let i = 0; i < count; i++) {
      // Farther depth gets smaller bucket index -> back-to-front draw order
      const b = Math.min(BUCKETS - 1, Math.max(0, Math.round((maxD - depths[i]) * invRange)));
      keys[i] = b;
      counts[b]++;
    }

    let acc = 0;
    for (let b = 0; b < BUCKETS; b++) {
      const c = counts[b];
      counts[b] = acc;
      acc += c;
    }

    for (let i = 0; i < count; i++) {
      const dst = counts[keys[i]]++;
      order[dst] = i;
    }

    for (let dst = 0; dst < count; dst++) {
      const src = order[dst];
      const s3 = src * 3;
      const d3 = dst * 3;
      sortedPos[d3] = data.positions[s3];
      sortedPos[d3 + 1] = data.positions[s3 + 1];
      sortedPos[d3 + 2] = data.positions[s3 + 2];
      sortedScale[d3] = data.scales[s3];
      sortedScale[d3 + 1] = data.scales[s3 + 1];
      sortedScale[d3 + 2] = data.scales[s3 + 2];

      const s4 = src * 4;
      const d4 = dst * 4;
      sortedRot[d4] = data.rotations[s4];
      sortedRot[d4 + 1] = data.rotations[s4 + 1];
      sortedRot[d4 + 2] = data.rotations[s4 + 2];
      sortedRot[d4 + 3] = data.rotations[s4 + 3];
      sortedCol[d4] = data.colors[s4];
      sortedCol[d4 + 1] = data.colors[s4 + 1];
      sortedCol[d4 + 2] = data.colors[s4 + 2];
      sortedCol[d4 + 3] = data.colors[s4 + 3];
    }

    posAttr.needsUpdate = true;
    scaleAttr.needsUpdate = true;
    rotAttr.needsUpdate = true;
    colAttr.needsUpdate = true;
    sortCount++;
  };

  return {
    mesh,
    count,
    uniforms,
    syncCamera(camera: THREE.Camera, viewportWidth: number, viewportHeight: number, force = false): boolean {
      uniforms.uViewport.value.set(Math.max(1, viewportWidth), Math.max(1, viewportHeight));
      camera.getWorldPosition(curPos);
      camera.getWorldDirection(curDir);
      const moved = curPos.distanceToSquared(lastCamPos) > 0.015 || curDir.dot(lastCamDir) < 0.9994;
      if (!force && !moved) return false;
      lastCamPos.copy(curPos);
      lastCamDir.copy(curDir);
      sortNow(curPos, curDir);
      return true;
    },
    setSplatScale(scale: number) {
      uniforms.uSplatScale.value = Math.min(2.0, Math.max(0.15, scale));
    },
    getSortCount: () => sortCount,
    getLastOrder: () => order,
    dispose() {
      quad.dispose();
      geo.dispose();
      mat.dispose();
    },
  };
}

/**
 * Builds a transparent shadow-catcher proxy mesh aligned to a Gaussian Splat diorama floor so real PBR actors
 * cast crisp shadows onto the splat environment without writing flat proxy albedo over the splats.
 */
export function createSplatShadowCatcher(radius = 6.2, y = 0.02, opacity = 0.42): THREE.Mesh {
  const geo = new THREE.CircleGeometry(radius, 36);
  geo.rotateX(-Math.PI / 2);
  const mat = new THREE.ShadowMaterial({
    opacity,
    depthWrite: false,
    polygonOffset: true,
    polygonOffsetFactor: -1,
  });
  const catcher = new THREE.Mesh(geo, mat);
  catcher.position.y = y;
  catcher.receiveShadow = true;
  catcher.renderOrder = 6;
  return catcher;
}
```

## Performance, Browser & Software-Renderer Budgets

- **Splat budget for WebGL 2 & mobile**: `2,500–12,000` splats sort in `< 0.5 ms` on the main thread using `2048`-bucket counting sort with zero GC allocations; clamp `maxPixelRadius` (`64–96 px`) to prevent overdraw spikes when a camera approaches close splats.
- **Keep `syncCamera` in `onAlways` as well as `onLateUpdate`**: Multi-view screenshot capture tools jump the camera directly between frames; calling `syncCamera` inside `onAlways` ensures every captured angle is strictly depth-sorted.
- **Shadow-catcher ordering**: Render opaque gameplay meshes (`renderOrder: 0`), then splats (`renderOrder: 4`, `depthTest: true`, `depthWrite: false`), then the `ShadowMaterial` proxy floor (`renderOrder: 6`, `polygonOffset`) so actor shadows darken the splat ground cleanly without z-fighting.

## Integration & Verification Checklist

1. Call `splats.syncCamera(game.camera, width, height, true)` once at startup and on every camera update/capture tick.
2. Unit-test `packSplatRecords` + `syncCamera` to verify strict farthest-first draw ordering and zero redundant sorts on a stationary camera.
3. Capture wide and close views to verify smooth anisotropic splat blending, crisp PBR actor occlusion in front of the arch, and grounded shadows on the proxy floor.

## Official references

- Bernhard Kerbl et al. (SIGGRAPH 2023 — 3D Gaussian Splatting for Real-Time Radiance Field Rendering)
- Matthias Zwicker et al. (IEEE VIS 2001 — EWA Splatting)
- Khronos KHR_gaussian_splatting glTF Extension Proposal (2026)
- Three.js r183 InstancedBufferGeometry & ShadowMaterial Reference
