-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
102 lines (81 loc) · 3.4 KB
/
index.html
File metadata and controls
102 lines (81 loc) · 3.4 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Loading 3D Objects from .json files - Orbit Controls</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>
<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">
</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.
function init()
{
var scene = new THREE.Scene();
var 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
var orbit = new THREE.OrbitControls(camera);
orbit.damping = 0.2;
orbit.minDistance = 10;
orbit.maxDistance = 50;
// Limit the control function
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()
{
// render using requestAnimationFrame
requestAnimationFrame(render);
renderer.render(scene, camera);
orbit.update();
window.addEventListener( 'resize', onWindowResize, false );
}
}
</script>
</body>
</html>