-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrbitControls.html
53 lines (49 loc) · 1.68 KB
/
OrbitControls.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
<!DOCTYPE html>
<html>
<head>
<title>webgl demo</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<script type="text/javascript" src="./js/three.min.js"></script>
<script src="./js/OrbitControls.js"></script>
<style>
*{margin:0;padding: 0;}
html,body{
height: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<script type="text/javascript">
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 100000);
var renderer = new THREE.WebGLRenderer();
renderer.setClearColor(0x333333);
renderer.setSize(window.innerWidth, window.innerHeight);
camera.position.set(10,10,10);
camera.lookAt(scene.position);
var geometry = new THREE.BoxGeometry(3,3,3);
var material = new THREE.MeshLambertMaterial({
color: 0xff0000
});
var mesh = new THREE.Mesh(geometry,material);
mesh.position.set(0,0,0);
scene.add(mesh);
var light=new THREE.PointLight(0xffffff);
light.position.set(300,400,200);
scene.add(light);
scene.add(new THREE.AmbientLight(0x333333));
function render() {
renderer.clear();
renderer.render(scene,camera);
}
render();
var controls = new THREE.OrbitControls(camera,renderer.domElement );
controls.addEventListener('change', render);
// controls.enableDamping = true;
// controls.dampingFactor = 0.25;
// controls.enableZoom = false;
document.body.appendChild(renderer.domElement);
</script>
</body>
</html>