What Three.js Does
- Scene graph — nested objects with transforms
- Geometries — box, sphere, plane, custom, glTF/OBJ/FBX loaders
- Materials & shaders — PBR, custom GLSL
- Lighting — directional, point, spot, IBL
- Post-processing — bloom, SSAO, DOF
- Animation — keyframes, skeletal, morph targets
- Physics — via Rapier, Cannon, Ammo integrations
- VR/AR — WebXR module
- WebGPU — experimental next-gen backend
Architecture
Single scene graph with a renderer that walks the tree each frame. Each Object3D has position/rotation/scale matrices. Materials map to shaders; geometries hold vertex data in GPU buffers. renderer.render(scene, camera) does the GL calls.
Self-Hosting
Client library — ships with your app.
Key Features
- WebGL + experimental WebGPU renderer
- 40+ geometries & materials
- glTF/OBJ/FBX/STL/PLY/DRACO loaders
- Skeletal animation
- Post-processing pipeline
- WebXR (VR/AR)
- Shadow mapping
- Ray casting for picking
- Cameras: Perspective, Orthographic, Cube
Comparison
| Library | Focus | Bundle | React Wrapper |
|---|---|---|---|
| Three.js | General 3D | ~600KB | React Three Fiber |
| Babylon.js | Games/Enterprise | ~1MB | None |
| Pixi.js | 2D WebGL | ~200KB | @pixi/react |
| PlayCanvas | Editor-based games | ~400KB | None |
常见问题 FAQ
Q: 和 React 怎么集成? A: 用 React Three Fiber(R3F)——声明式 JSX 写 Three.js 场景。生态还有 drei(工具库)、rapier(物理)。
Q: WebGL vs WebGPU? A: WebGL 是 OpenGL ES 的 Web 移植,已稳定。WebGPU 是新一代 API(接近 Metal/Vulkan),Chrome/Safari 已支持,Three.js 有实验渲染器。
Q: 性能优化? A: 减少 draw calls(InstancedMesh)、合并几何体、使用 KTX2/Draco 压缩、禁用阴影。
来源与致谢 Sources
- Docs: https://threejs.org/docs
- GitHub: https://github.com/mrdoob/three.js
- License: MIT