-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo06材质.html
54 lines (47 loc) · 1.38 KB
/
demo06材质.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
<!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">
var scene = new THREE.Scene()
var camera = new THREE.PerspectiveCamera(30, window.innerWidth / window.innerHeight, 0.1, 1000)
var renderer = new THREE.WebGLRenderer()
renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)
// add icosahedron
var geometry = new THREE.OctahedronGeometry(20)
var color = new THREE.Color('#7833aa')
var material = new THREE.MeshLambertMaterial({ color: color.getHex() })
var mesh = new THREE.Mesh(geometry, material)
scene.add(mesh)
camera.position.z = 100;
var light = new THREE.PointLight(0xffff00, 1.5)
light.position.set(10, 0, 80)
scene.add(light)
var light2 = new THREE.PointLight(0xffff00, 1.5)
light2.position.set(25, 0, -80)
scene.add(light2)
var render = function () {
requestAnimationFrame(render)
mesh.rotation.x += 0.01
mesh.rotation.y += 0.01
renderer.render(scene, camera)
}
render()
</script>
</body>
</html>