forked from kdanielyu/CODE2270-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (67 loc) · 2.46 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CODE2270 - 2022 BIM Interface</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1223.0.js"></script>
<script src="/loadS3.js"></script>
<script>listFiles();</script>
<script src="/js/three.js"></script>
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/[email protected]/build/three.module.js"
}
}
</script>
<div class="titleBlock">
<h1>UNSW CODE2270 BIM PLAN</h1><br>
<h2>Daniel Yu</h2>
</div>
<div class="canvas">
<div id="frame"></div>
<script type="module">
import * as THREE from 'three';
import { GLTFLoader } from 'https://unpkg.com/[email protected]/examples/jsm/loaders/GLTFLoader.js';
import { OrbitControls } from 'https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js';
// Getting dimensions of div ID "frame"
let box = document.querySelector('.canvas');
let width = box.offsetWidth;
let height = box.offsetHeight;
const container = document.getElementById('frame');
// Scene setup
const scene = new THREE.Scene();
// const camera = new THREE.PerspectiveCamera( 60, width / height, 1, 10000 );
const camera = new THREE.OrthographicCamera( width / - 70, width / 70, height / 70, height / - 80, -200, 200 );
// Renderer setup and appending to 'frame'
const renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio ( window.devicePixelRatio );
renderer.setSize( width, height );
container.appendChild( renderer.domElement )
// Geometry
const loader = new GLTFLoader();
loader.load('model/scene.gltf', function (gltf) {
scene.add(gltf.scene);
}, undefined, function ( error ) {
console.error( error );
});
//Scene
scene.background = new THREE.Color(255, 255, 255)
camera.position.set( 1, 1, 3 );
//Control
const controls = new OrbitControls(camera, renderer.domElement);
controls.update();
function animate() {
requestAnimationFrame( animate );
controls.update();
renderer.render( scene, camera );
}
animate();
</script>
</div>
</body>
</html>