Scene·three·v1.0.0·MIT
Orbit Scene
A starter Three.js scene with a perspective camera, orbit controls, ambient + directional light, ground grid, and a render loop. Drop your geometry into `scene` and go.
#three#scene#orbit#starter
Install
npx gamecn add orbit-sceneUsage
ts
import { OrbitScene } from '@/scenes/OrbitScene';
const orbit = new OrbitScene({ canvas: document.querySelector('canvas')! });
orbit.scene.add(myMesh);
orbit.start();Source preview
Compatibility
| Engines | three >=0.160.0 |
| Frameworks | vanilla |
| Languages | typescript |
| Bundlers | vite |
Files installed
- {scenes}/OrbitScene.ts
- docs/gamecn/orbit-scene.md(docs)
Dependencies
npm
three@>=0.160.0
Notes
Usage
<canvas id="game" style="width: 100vw; height: 100vh;"></canvas>import * as THREE from "three";
import { OrbitScene } from "@/scenes/OrbitScene";
const orbit = new OrbitScene({
canvas: document.getElementById("game") as HTMLCanvasElement,
backgroundColor: 0x1a1a2e,
cameraPosition: [5, 5, 5],
shadows: true,
});
// Add your geometry
const cube = new THREE.Mesh(
new THREE.BoxGeometry(),
new THREE.MeshStandardMaterial({ color: 0xff6b6b }),
);
orbit.scene.add(cube);
// Per-frame logic
orbit.onUpdate((dt) => {
cube.rotation.y += dt;
});
orbit.start();
// Later:
// orbit.stop();
// orbit.dispose();What you get
WebGLRendererwith antialias, devicePixelRatio scaling, optional shadowsPerspectiveCamerawith reasonable defaults (50° FOV, 0.1–1000 near/far)OrbitControlswith dampingAmbientLight+DirectionalLight- Optional
GridHelper requestAnimationFrameloop with delta-time updaters- Resize handling on
window
Related
- 3D Asset TestTemplate
3D Asset Test — a Three.js starter mirrored from OpusGameLabs/game-creator.
- Castle SiegeTemplate
Castle Siege — a Three.js starter mirrored from OpusGameLabs/game-creator.
- Crowd DashTemplate
Crowd Dash — a Three.js starter mirrored from OpusGameLabs/game-creator.
- Flappy Bird 3DTemplate
Flappy Bird 3D — a Three.js starter mirrored from OpusGameLabs/game-creator.