-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathquickstart.html
More file actions
52 lines (45 loc) · 1.38 KB
/
quickstart.html
File metadata and controls
52 lines (45 loc) · 1.38 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.182.0/build/three.webgpu.js",
"three/webgpu": "https://cdn.jsdelivr.net/npm/three@0.182.0/build/three.webgpu.js"
}
}
</script>
<script type="module">
import * as THREE from "three/webgpu";
const width = 960;
const height = 540;
const canvas = document.querySelector("#myCanvas");
// レンダラーを作成
const renderer = new THREE.WebGPURenderer({
canvas,
});
renderer.setSize(width, height);
renderer.setPixelRatio(devicePixelRatio);
renderer.setAnimationLoop(tick);
// シーンを作成
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x000000);
// カメラを作成
const camera = new THREE.PerspectiveCamera(45, width / height);
camera.position.set(0, 0, +1000);
// 箱を作成
const geometry = new THREE.BoxGeometry(400, 400, 400);
const material = new THREE.MeshNormalMaterial();
const box = new THREE.Mesh(geometry, material);
scene.add(box);
function tick() {
box.rotation.y += 0.01;
renderer.render(scene, camera);
}
</script>
</head>
<body>
<canvas id="myCanvas"></canvas>
</body>
</html>