-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo10.html
56 lines (51 loc) · 1.39 KB
/
demo10.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>My first three.js app</title>
<style>
body { margin: 0; }
#info {
position: absolute;
top: 10px;
width: 100%;
text-align: center;
z-index: 100;
display:block;
}
</style>
</head>
<body>
<canvas id="mainCanvas" width="400px" height="300px"></canvas>
</body>
<script src="https://cdn.bootcss.com/three.js/91/three.js"></script>
<script>
function init(){
var renderer = new THREE.WebGLRenderer({
canvas: document.getElementById('mainCanvas')
});
renderer.setClearColor(0x000000);
var scene = new THREE.Scene();
// camera
var camera = new THREE.OrthographicCamera(-5, 5, 3.75, -3.75, 0.1, 100);
camera.position.set(25, 25, 25);
camera.lookAt(new THREE.Vector3(0, 0, 0));
scene.add(camera);
// light
var light = new THREE.PointLight(0xffffff, 1, 200);
light.position.set(10, 15, 25);
scene.add(light);
var material = new THREE.MeshPhongMaterial({
color: 0xffffff,
specular: 0xffff00,
shininess: 1000
});
var sphere = new THREE.Mesh(new THREE.SphereGeometry(3, 20, 8), material);
scene.add(sphere);
renderer.render(scene, camera);
}
init();
</script>
</html>