Skip to content
Make the player visible with a procedural 3D humanoid132be7c
JavaScript60 lines3.0 KB
// Stage geometry as plain data (units: meters, y up, fighters on z=0).export const stage = {  floor: { center: [0, -0.1, 0], size: [24, 0.2, 10], color: [0.18, 0.16, 0.2] },  backWall: { center: [0, 4, -5], size: [24, 8, 0.4], color: [0.1, 0.09, 0.14] },  pillars: [-9, -4.5, 4.5, 9].map((x) => ({ center: [x, 3.5, -4.2], size: [1, 7, 1], color: [0.22, 0.2, 0.26] })),  lights: [    { type: "directional", direction: [-0.4, -1, -0.6], color: [1, 0.95, 0.85], intensity: 1 },    { type: "point", position: [-6, 5, -3], color: [1, 0.3, 0.3], intensity: 0.6 },    { type: "point", position: [6, 5, -3], color: [0.3, 0.4, 1], intensity: 0.6 },  ],}; // --- Modern stage layers (plain data consumed by renderers) --------------------------------- /** Parallax background layers, drawn back to front. `depth` 0 = infinitely far (no parallax), 1 = fighter plane. */export const parallaxLayers = [  { name: "sky", depth: 0, z: -40, height: 30, colors: [[0.03, 0.03, 0.08], [0.16, 0.08, 0.18]] },  { name: "skyline", depth: 0.2, z: -24, height: 12, colors: [[0.07, 0.06, 0.12], [0.12, 0.1, 0.18]] },  { name: "temple", depth: 0.45, z: -12, height: 9, colors: [[0.1, 0.09, 0.15], [0.18, 0.15, 0.22]] },  { name: "wall", depth: 0.75, z: -5, height: 8, colors: [[0.1, 0.09, 0.14], [0.2, 0.17, 0.24]] },  { name: "foreground", depth: 1.15, z: 2.5, height: 1.2, colors: [[0.02, 0.02, 0.04], [0.05, 0.04, 0.08]] },]; /** Vertical lighting gradients (top -> bottom colour) for background and floor. */export const lightingGradients = {  sky: { top: [0.02, 0.02, 0.06], bottom: [0.22, 0.1, 0.2] },  wall: { top: [0.05, 0.04, 0.08], bottom: [0.2, 0.17, 0.26] },  floor: { near: [0.2, 0.18, 0.24], far: [0.08, 0.07, 0.11] },  rim: { color: [1, 0.55, 0.45], intensity: 0.8 },}; /** Ground reflection parameters for the glossy floor. */export const groundReflection = { strength: 0.35, blur: 0.6, fade: 2.5, tint: [0.9, 0.85, 1] }; /** Soft fighter shadow (blob) parameters. */export const fighterShadow = { radius: 0.7, softness: 0.5, opacity: 0.55, color: [0, 0, 0], maxHeightFade: 3 }; /** Horizontal parallax offset (world units) for a layer given the camera x position. */export function parallaxOffset(layer, cameraX) {  return cameraX * (1 - layer.depth);} /** Linear blend between two RGB colours of a gradient, t in [0,1]. */export function gradientAt(gradient, t) {  const k = Math.min(1, Math.max(0, t));  const a = gradient.top || gradient.near, b = gradient.bottom || gradient.far;  if (k <= 0) return a.slice();  if (k >= 1) return b.slice();  return a.map((v, i) => v + (b[i] - v) * k);} /** Shadow radius/opacity for a fighter at height y: the higher the jump, the larger and fainter the shadow. */export function shadowAt(y) {  const t = Math.min(1, Math.max(0, y / fighterShadow.maxHeightFade));  return { radius: fighterShadow.radius * (1 + t * 0.6), opacity: fighterShadow.opacity * (1 - t) };} /** All layer data in one object for renderers that want a single import. */export const stageLayers = { parallaxLayers, lightingGradients, groundReflection, fighterShadow };