Clamp a 3D position to stay within arena boundaries.
Only clamps X and Z axes (horizontal plane). Y axis (height) is unchanged. Arena is centered at origin with bounds extending ±width/2 and ±depth/2.
Korean: 위치를 경기장 경계로 제한 (Clamp Position To Bounds)
3D position in meters (THREE.Vector3 or Position3D)
Arena bounds with min/max values
Clamped position as new THREE.Vector3
const position = new THREE.Vector3(6, 0, 4); // Outside boundsconst bounds = calculateArenaBounds(config);const clamped = clampPositionToBounds(position, bounds);// Result: Vector3(4.7, 0, 3.45) - clamped to edges Copy
const position = new THREE.Vector3(6, 0, 4); // Outside boundsconst bounds = calculateArenaBounds(config);const clamped = clampPositionToBounds(position, bounds);// Result: Vector3(4.7, 0, 3.45) - clamped to edges
Clamp a 3D position to stay within arena boundaries.
Only clamps X and Z axes (horizontal plane). Y axis (height) is unchanged. Arena is centered at origin with bounds extending ±width/2 and ±depth/2.
Korean: 위치를 경기장 경계로 제한 (Clamp Position To Bounds)