forked from QuarkGluonPlasma/threejs-exercize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
54 lines (47 loc) · 1.29 KB
/
index.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 lang="en">
<head>
<meta charset="UTF-8">
<title>全景图</title>
<style>
body {
margin: 0;
overflow: hidden;
}
</style>
<script src="./js/three.js"></script>
<script src="./js/OrbitControls.js"></script>
</head>
<body>
<script>
const width = window.innerWidth;
const height = window.innerHeight;
const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 1000);
const scene = new THREE.Scene();
const renderer = new THREE.WebGLRenderer();
camera.position.set(0,0, 100);
camera.lookAt(scene.position);
renderer.setSize(width, height);
document.body.appendChild(renderer.domElement)
function create() {
let urls = [
'./img/home.left.jpg',
'./img/home.right.jpg',
'./img/home.top.jpg',
'./img/home.bottom.jpg',
'./img/home.front.jpg',
'./img/home.back.jpg'
];
let cubeTexture = new THREE.CubeTextureLoader().load(urls);
scene.background = cubeTexture;
}
function render() {
renderer.render(scene, camera);
requestAnimationFrame(render);
}
create();
render();
const controls = new THREE.OrbitControls(camera);
</script>
</body>
</html>