-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.html
59 lines (49 loc) · 2.1 KB
/
testing.html
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
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Shapes testing three.js app</title>
<style>
body { margin: 0; }
</style>
</head>
<body>
<script type="module">
import * as THREE from 'https://unpkg.com/three/build/three.module.js';
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const geometry = new THREE.BoxGeometry(10, 10, 10);
const material = new THREE.MeshBasicMaterial();
material.wireframe = true;
const cube = new THREE.Mesh( geometry, material);
const sphere = new THREE.Mesh( new THREE.SphereGeometry(5, 15, 6), material);
sphere.position.y = 20;
const dodecahedron = new THREE.Mesh( new THREE.DodecahedronGeometry(8,0), material);
dodecahedron.position.y = -20;
const torusKnot = new THREE.Mesh( new THREE.TorusKnotGeometry(8, 3, 80, 12), material);
torusKnot.position.set(35, 20, 0);
const capsule = new THREE.Mesh(new THREE.CapsuleGeometry(4, 4, 6, 20), material)
capsule.position.set(35, 0, 0);
scene.add(cube, sphere, dodecahedron, torusKnot, capsule);
camera.position.z = 50;
function animate() {
requestAnimationFrame(animate);
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
sphere.rotation.x += .01;
sphere.rotation.y += .01;
dodecahedron.rotation.x +=0.01;
dodecahedron.rotation.y +=.01;
torusKnot.rotation.x += .01
torusKnot.rotation.y += .01
capsule.rotation.x += .01
capsule.rotation.y += .01
renderer.render( scene, camera);
}
animate();
</script>
</body>
</html>