-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
158 lines (130 loc) · 5.15 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html lang="en">
<head>
<title>Camera Animation (Tween) By Clicking link</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!-- <link rel="icon" type="png" href="images/worthington_icon.png"> -->
<link href='https://fonts.googleapis.com/css?family=Raleway:400,300,500,600,200,100' rel='stylesheet' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/threejs/r84/three.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<script src = "https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="src/Tween.js"></script>
<style>
body {
/* set margin to 0 and overflow to hidden, to go fullscreen */
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<!-- Div which will hold the Output -->
<div id="WebGL-output">
<a href="#" id="safety_text" onclick="CameraMoveToOtherLocation()"> OBJECT 1 -- </a>
<a href="#" id="safety_text" onclick="CameraMoveToOtherLocation1()"> OBJECT 2 -- </a>
<a href="#" id="safety_text" onclick="CameraMoveToOtherLocation2()"> DEFAULT POSITION -- </a>
<a href="#" id="safety_text" onclick="TraceValues()"> TRACE POSITION </a>
</div>
<!-- Javascript code that runs our Three.js examples -->
<script type="text/javascript">
window.onload = init;
// once everything is loaded, we run our Three.js stuff.
var camera ;
var orbit;
function CameraMoveToOtherLocation()
{
new TWEEN.Tween( camera.position ).to( {
x:-0.5,
y: 3.5,
z: 2.6 }, 2000 )
.start();
//camera.position.set(-0.5, 3.5, 2.6);
//camera.rotation.set(-0.5, 0.4, 0.4);
orbit.update();
}
function CameraMoveToOtherLocation1()
{
new TWEEN.Tween( camera.position ).to( {
x:3.64,
y: 1.47,
z: -2.37 }, 2000 )
.start();
/*new TWEEN.Tween( camera.rotation ).to( {
x:-0.38,
y: 0.74,
z: 0.26 }, 2000 )
.start();*/
//camera.position.set(-3.3, 2.3, 2.0);
//camera.rotation.set(-0.8, -0.8, -0.7);
orbit.update();
}
function CameraMoveToOtherLocation2()
{
new TWEEN.Tween( camera.position ).to( {
x: 5,
y: 2,
z: 5 }, 2000 )
.start();
//camera.position.set(5, 2, 5);
orbit.update();
}
function TraceValues()
{
console.log(camera.position);
console.log(camera.rotation);
}
function init()
{
var scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
camera.position.x = 5;
camera.position.y = 2;
camera.position.z = 5;
camera.lookAt(scene.position);
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor(0xdddddd);
document.body.appendChild( renderer.domElement );
var axis = new THREE.AxisHelper(10);
scene.add(axis);
// Orbit Control Function
orbit = new THREE.OrbitControls(camera);
orbit.damping = 0.2;
orbit.minDistance = 0.1;
orbit.maxDistance = 50;
orbit.enableDamping = true;
orbit.dampingFactor = 0.25;
orbit.maxPolarAngle = 0.9 * Math.PI / 2;
// Loading 3D Model (.json)
var loader = new THREE.ObjectLoader();
loader.load("SimpleScene/scene.json",function ( obj ) {
obj.traverse( function ( child ) {
});
scene.add( obj );
});
// HTML5 DIV Loader...
document.getElementById("WebGL-output").appendChild(renderer.domElement);
// 3D World responsive function
function onWindowResize()
{
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
render();
// WebGL Renderer...
function render()
{
TWEEN.update();
// render using requestAnimationFrame
requestAnimationFrame(render);
renderer.render(scene, camera);
orbit.update();
window.addEventListener( 'resize', onWindowResize, false );
}
}
</script>
</body>
</html>