Spaces:
Running
Running
File size: 2,893 Bytes
1390db3 bf6239d 874a51f 1390db3 fd12cd0 1390db3 bf6239d 1390db3 5cf582c a646668 5cf582c 1390db3 a646668 fd12cd0 874a51f 1390db3 5cf582c 1390db3 fe3647a fd12cd0 1390db3 fd12cd0 a297171 1f43352 1390db3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
import * as THREE from 'three';
// Centralized mutable game state shared across modules
export const G = {
renderer: null,
scene: null,
camera: null,
controls: null,
clock: null,
state: 'menu',
ground: null,
flashlight: null,
sunLight: null,
moonLight: null,
sunSprite: null,
moonSprite: null,
ambientLight: null,
// Lightweight sky clouds
clouds: [],
// Foliage chunk refs for LOD/culling
foliage: { grass: [], flowers: [] },
mountains: null,
input: {
w: false,
a: false,
s: false,
d: false,
shoot: false,
sprint: false,
crouch: false,
jump: false,
grenade: false
},
player: null, // initialized in main
enemies: [],
treeColliders: [],
treeMeshes: [],
// Subset of meshes used for bullet blocking (trunks only)
treeTrunks: [],
// Spatial index for trees to accelerate queries
treeGrid: null,
// Static blockers array for raycasting (ground + trees)
blockers: [],
shootCooldown: 0,
raycaster: new THREE.Raycaster(),
tmpV1: new THREE.Vector3(),
tmpV2: new THREE.Vector3(),
tmpV3: new THREE.Vector3(),
weapon: {
group: null,
muzzle: null,
basePos: new THREE.Vector3(),
baseRot: new THREE.Euler(0, 0, 0),
recoil: 0,
swayT: 0,
ammo: 0,
reserve: Infinity,
reloading: false,
reloadTimer: 0,
anchor: { depth: 0.80, right: 0.417, bottom: 0.365 },
// Dynamic aim spread (NDC units) and helpers
spread: 0,
targetSpread: 0,
// View recoil offsets applied to camera (radians)
viewPitch: 0,
viewYaw: 0,
appliedPitch: 0,
appliedYaw: 0,
// Dynamic fire-rate buff
rofMult: 1,
rofBuffTimer: 0,
rofBuffTotal: 0,
// Infinite ammo buff
infiniteAmmoTimer: 0,
infiniteAmmoTotal: 0,
ammoBeforeInf: null,
reserveBeforeInf: null,
materials: [],
glowT: 0
},
// Temporary movement speed buff (used by accelerator)
movementMult: 1,
movementBuffTimer: 0,
fx: { tracers: [], impacts: [], flashes: [], dusts: [], portals: [] },
// Player grenades and preview helpers
grenades: [],
heldGrenade: null,
grenadeCount: 0,
grenadePreview: null,
// Explosion VFX
explosions: [],
enemyProjectiles: [],
// Health orbs and other pickups
orbs: [],
// Ephemeral wave pickups (e.g., ROF accelerators)
powerups: [],
// Ejected shell casings
casings: [],
// Detached props (helmets) with simple physics
helmets: [],
damageFlash: 0,
healFlash: 0,
hitFlash: 0,
// Deferred GPU resource disposal queue to avoid frame spikes
disposeQueue: [],
waves: {
current: 1,
aliveCount: 0,
spawnQueue: 0,
nextSpawnTimer: 0,
breakTimer: 0,
inBreak: false,
spawnAnchor: null,
shamansToSpawn: 0,
wolvesToSpawn: 0,
golemsToSpawn: 0
},
random: null,
// Day/night cycle
timeOfDay: 0.25 // 0..1, where ~0.5 is noon
};
|