Virtual Sandbox
CubeThis code mixes geometry, particle physics, and interface elements that behave more like living organisms than obedient tools. Here's a catalog of logic and functionality extracted from the depths of this code: Architecture and Space
- Scene Origin — Initialization of an infinite space with a dynamic background changing color every 100 seconds.
- Optic Engine — Perspective Camera setup with adaptive lighting (Ambient, Directional, and a specific Ultramarine Light) tied to the observer's movement.
- Orbit Pivot — Orbit control via OrbitControls with soft damping to simulate inertia. Forma Module (Cube Structures)
- Voxel Genesis — Generation of hollow cubes consisting of individual faces, with adjacency checking to eliminate duplicate planes.
- Tunnel Boring — Deletes a face on click, simultaneously generating a new cube in the normal direction, creating the effect of an infinite corridor.
- Phantom Shell — Toggles face transparency (0.5 opacity) with a long press.
- Wire Skeleton — Globally switches between solid and wireframe display. Polarity Module (Physics Objects)
- Object Spawning — Creates various geometric primitives (Box, Tetra, Icosa, Octa, Dodeca) with random physical properties.
- Static/Polar Toggle — Separates objects into stationary (Static) and active (Polar), each with mass, velocity vector, and polarity.
- Kinetic Interaction — Repulsion and attraction logic: objects with the same polarity fly apart, while objects with different polarities converge. * Static Friction — Interaction between active polar objects and stationary ones, where the "statics" shift slightly as the "polars" approach.
- Atmospheric Drag — Gradual deceleration of all moving objects to prevent them from flying away indefinitely. Controls and Navigation
- Auto Pilot — Free camera flight forward with smooth acceleration and deceleration.
- Bypass Drift — Automatic camera wandering with random changes in focus and movement vector.
- Lunge Strike — A sharp jerk of the camera forward (Lunge), causing all objects within the radius to physically fly away.
- Proximity Repulsion — Automatically repels objects from the camera when approaching too closely.
- Dynamic Scaling — Resizing an object in real time by holding down the left (zoom in) or right (zoom out) mouse button. Interaction and Interface
- Scatter Burst — An object scatters when clicked, accompanied by a random release of text "secrets."
- Secret Rain — The appearance of drifting text labels from a list of keywords that smoothly move across the screen and disappear.
- Mode Selector — A drop-down menu for switching interaction modes: Fix, Polar, Delete, View.
- Cleanup Protocol — A mode for selectively removing objects (both cubic faces and physical bodies) from the scene.