-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo03.html
63 lines (50 loc) · 1.42 KB
/
demo03.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
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>画线</title>
<style>
body {
margin: 0;
}
canvas {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="info">Description</div>
<script src="js/three.js"></script>
<script type="module">
// 1.场景
const scene = new THREE.Scene()
// 2.相机
const camera = new THREE.PerspectiveCamera(30, window.innerWidth / window.innerHeight, 0.1, 1000)
// 3 渲染器
const renderer = new THREE.WebGLRenderer()
renderer.setSize(window.innerWidth, window.innerHeight)
renderer.setClearColor(0xb9d3ff, 1); //设置背景颜色
document.body.appendChild(renderer.domElement)
const geometry = new THREE.BoxGeometry(20, 20, 20)
const material = new THREE.MeshNormalMaterial()
const cube = new THREE.Mesh(geometry, material)
scene.add(cube)
// update cube vertices
// update cube vertices
// rotate cube
cube.rotation.x = 0.45
cube.rotation.y = -0.25
camera.position.z = 100
var light = new THREE.PointLight(0xffff00)
light.position.set(10, 0, 25)
scene.add(light)
var render = function () {
requestAnimationFrame(render)
renderer.render(scene, camera)
icosahedron.rotation.x += 0.05;
}
render()
</script>
</body>
</html>