Complete 3D rendering system using Three.js for meshes, materials, lighting, and cameras
The 3D Graphics API provides a complete Three.js-powered 3D rendering system with mesh management, primitive shapes, material system, lighting, and GLB model loading.
Creates a cube mesh with the specified properties.
const cubeId = createCube(2, 0xff0000, [0, 1, 0], { metalness: 0.5 });
Creates a sphere mesh.
const ballId = createSphere(1.5, 0x00ff00, [5, 2, 0], 16);
Creates a flat plane mesh (ground, walls, etc.).
const groundId = createPlane(100, 100, 0x808080, [0, -1, 0]);
Retrieves a mesh object by its ID for direct manipulation.
const mesh = getMesh(cubeId);
mesh.rotation.y += 0.01;
Removes a mesh and frees its resources.
destroyMesh(cubeId); // Clean up
Loads a GLB/GLTF 3D model asynchronously.
const modelId = await loadModel("/models/character.glb", [0, 0, 0], 2);
Adds a directional light (like the sun).
addDirectionalLight(0xffffff, 1.0, [10, 20, 5]);
Adds ambient light (overall scene brightness).
addAmbientLight(0x404040, 0.5);