three.js dev template - module

HTML

<script type="importmap">
	{
		"imports": {
			"three": "https://unpkg.com/three/build/three.webgpu.js",
      "three/addons/": "https://unpkg.com/three/examples/jsm/"
		}
	}
</script>

CSS

body {
	margin: 0px;
}

JavaScript

import * as THREE from "three";
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';


// Scene
const scene = new THREE.Scene();

/**
 * Base + Box
 */
const sphere = new THREE.SphereGeometry(1.5, 15, 15, 0, Math.PI * 2, Math.PI * 0.5, Math.PI * 0.5);
//make sure we dont have normal or UV
delete sphere.attributes.normal;
delete sphere.attributes.uv;

const cubeMat = new THREE.MeshStandardMaterial({
  color: new THREE.Color("yellow"),
  flatShading: true,
  side: THREE.DoubleSide,
});

const cubeMesh = new THREE.Mesh(sphere, cubeMat);

scene.add(cubeMesh);

/**
 * lights
 */

const light1 = new THREE.PointLight(0xddddff, 30);
light1.position.set(0, 1, 4);
scene.add(light1);

const light2 = new THREE.AmbientLight(0xffffee, 1);
light2.position.set(0, 3, 4);

scene.add(light2);

/**
 * Camera
 */
const camera = new THREE.PerspectiveCamera(75,window.innerWidth / window.innerHeight);
camera.position.z = 4;
camera.position.y = 1;
scene.add(camera);
scene.background = new THREE.Color("black");

const renderer = new THREE.WebGPURenderer({
  antialias: true
});
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setAnimationLoop(animate);
document.body.appendChild(renderer.domElement);

const controls = new OrbitControls( camera, renderer.domElement );


function animate() {
  renderer.render(scene, camera);
}