1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| import * as Three from "three"; import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
const scene = new Three.Scene();
const camera = new Three.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); camera.position.set(0, 0, 10); scene.add(camera);
const cubeGeometry = new Three.BoxGeometry(); const cubeMaterial = new Three.LineBasicMaterial({ color: 0xffffff, }); const cube = new Three.Mesh(cubeGeometry, cubeMaterial); scene.add(cube);
const renderer = new Three.WebGLRenderer({ antialias: true, }); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement);
const controls = new OrbitControls(camera, renderer.domElement);
function render() { renderer.render(scene, camera); requestAnimationFrame(render); } render();
|