index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>three.js</title>
<script type="importmap">
{
"imports": {
"three": "./three.module.js"
}
}
</script>
</head>
<body>
<div id="webgl"></div>
<script src="./index.js" type="module"></script>
</body>
</html>
index.js
import * as THREE from 'three';
console.log(THREE.Scene);
let width = 800, height = 500
const scene = new THREE.Scene()
const geometry = new THREE.BoxGeometry(100, 100, 100);
const material = new THREE.MeshBasicMaterial({color: 0xff0000})
const mesh = new THREE.Mesh(geometry, material)
mesh.position.set(0, 10, 0)
scene.add(mesh)
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.1, 1000 );
camera.position.set(200, 200, 200)
camera.lookAt(mesh.position)
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
renderer.render( scene, camera );
document.getElementById("webgl").appendChild(renderer.domElement)