|
@@ -15,74 +15,76 @@
|
|
<div id="info">
|
|
<div id="info">
|
|
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a>
|
|
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a>
|
|
-
|
|
-
|
|
- <a href="https://www.buildingsmart.org/standards/bsi-standards/industry-foundation-classes/" target="_blank" rel="noopener"
|
|
|
|
- >IFC</a
|
|
|
|
- >
|
|
|
|
|
|
+ <a href="https://www.buildingsmart.org/standards/bsi-standards/industry-foundation-classes/" target="_blank" rel="noopener">IFC</a>
|
|
loader
|
|
loader
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script type="module">
|
|
<script type="module">
|
|
- import * as THREE from "../build/three.module.js";
|
|
|
|
- import { OrbitControls } from "./jsm/controls/OrbitControls.js";
|
|
|
|
|
|
|
|
- import { IFCLoader } from "./jsm/loaders/ifc/IFCLoader.js";
|
|
|
|
|
|
+ import * as THREE from '../build/three.module.js';
|
|
|
|
+ import { OrbitControls } from './jsm/controls/OrbitControls.js';
|
|
|
|
+
|
|
|
|
+ import { IFCLoader } from './jsm/loaders/IFCLoader.js';
|
|
|
|
|
|
//Scene
|
|
//Scene
|
|
const scene = new THREE.Scene();
|
|
const scene = new THREE.Scene();
|
|
- scene.background = new THREE.Color(0x8cc7de);
|
|
|
|
|
|
+ scene.background = new THREE.Color( 0x8cc7de );
|
|
|
|
|
|
//Renderer
|
|
//Renderer
|
|
const container = document.querySelector( '#container' );
|
|
const container = document.querySelector( '#container' );
|
|
- const renderer = new THREE.WebGLRenderer({ antialias: true });
|
|
|
|
- renderer.setSize(window.innerWidth, window.innerHeight);
|
|
|
|
- renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
|
|
|
|
+ const renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
|
|
+ renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
+ renderer.setPixelRatio( Math.min( window.devicePixelRatio, 2 ) );
|
|
|
|
+ renderer.setAnimationLoop( animation );
|
|
container.appendChild( renderer.domElement );
|
|
container.appendChild( renderer.domElement );
|
|
|
|
|
|
//Camera
|
|
//Camera
|
|
- const camera = new THREE.PerspectiveCamera(45,window.innerWidth / window.innerHeight,0.1,1000);
|
|
|
|
- camera.position.z = -70;
|
|
|
|
|
|
+ const camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 1000 );
|
|
|
|
+ camera.position.z = - 70;
|
|
camera.position.y = 25;
|
|
camera.position.y = 25;
|
|
camera.position.x = 90;
|
|
camera.position.x = 90;
|
|
- camera.lookAt(0,0,0);
|
|
|
|
- let controls = new OrbitControls(camera, renderer.domElement);
|
|
|
|
|
|
+ camera.lookAt( 0, 0, 0 );
|
|
|
|
+ const controls = new OrbitControls( camera, renderer.domElement );
|
|
|
|
|
|
//Initial cube
|
|
//Initial cube
|
|
const geometry = new THREE.BoxGeometry();
|
|
const geometry = new THREE.BoxGeometry();
|
|
- const material = new THREE.MeshPhongMaterial({ color: 0xffffff });
|
|
|
|
- const cube = new THREE.Mesh(geometry, material);
|
|
|
|
- scene.add(cube);
|
|
|
|
|
|
+ const material = new THREE.MeshPhongMaterial( { color: 0xffffff } );
|
|
|
|
+ const cube = new THREE.Mesh( geometry, material );
|
|
|
|
+ scene.add( cube );
|
|
|
|
|
|
//Lights
|
|
//Lights
|
|
- const directionalLight1 = new THREE.DirectionalLight(0xffeeff, 0.8);
|
|
|
|
- directionalLight1.position.set(1, 1, 1);
|
|
|
|
- scene.add(directionalLight1);
|
|
|
|
- const directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.8);
|
|
|
|
- directionalLight2.position.set(-1, 0.5, -1);
|
|
|
|
- scene.add(directionalLight2);
|
|
|
|
- const ambientLight = new THREE.AmbientLight(0xffffee, 0.25);
|
|
|
|
- scene.add(ambientLight);
|
|
|
|
|
|
+ const directionalLight1 = new THREE.DirectionalLight( 0xffeeff, 0.8 );
|
|
|
|
+ directionalLight1.position.set( 1, 1, 1 );
|
|
|
|
+ scene.add( directionalLight1 );
|
|
|
|
+ const directionalLight2 = new THREE.DirectionalLight( 0xffffff, 0.8 );
|
|
|
|
+ directionalLight2.position.set( - 1, 0.5, - 1 );
|
|
|
|
+ scene.add( directionalLight2 );
|
|
|
|
+ const ambientLight = new THREE.AmbientLight( 0xffffee, 0.25 );
|
|
|
|
+ scene.add( ambientLight );
|
|
|
|
|
|
//Window resize support
|
|
//Window resize support
|
|
- window.addEventListener("resize", () => {
|
|
|
|
|
|
+ window.addEventListener( 'resize', () => {
|
|
|
|
+
|
|
camera.aspect = window.innerWidth / window.innerHeight;
|
|
camera.aspect = window.innerWidth / window.innerHeight;
|
|
camera.updateProjectionMatrix();
|
|
camera.updateProjectionMatrix();
|
|
- renderer.setSize(window.innerWidth, window.innerHeight);
|
|
|
|
- });
|
|
|
|
|
|
+ renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
+
|
|
|
|
+ } );
|
|
|
|
|
|
//Setup IFC Loader
|
|
//Setup IFC Loader
|
|
const ifcLoader = new IFCLoader();
|
|
const ifcLoader = new IFCLoader();
|
|
|
|
|
|
//Load IFC file
|
|
//Load IFC file
|
|
- ifcLoader.load('models/ifc/rac_advanced_sample_project.ifc', (geometry) => scene.add(geometry));
|
|
|
|
|
|
+ ifcLoader.load( 'models/ifc/rac_advanced_sample_project.ifc', ( geometry ) => scene.add( geometry ) );
|
|
|
|
|
|
//Animation
|
|
//Animation
|
|
- function AnimationLoop() {
|
|
|
|
- requestAnimationFrame(AnimationLoop);
|
|
|
|
|
|
+ function animation() {
|
|
|
|
+
|
|
controls.update();
|
|
controls.update();
|
|
- renderer.render(scene, camera);
|
|
|
|
|
|
+ renderer.render( scene, camera );
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- AnimationLoop();
|
|
|
|
</script>
|
|
</script>
|
|
</body>
|
|
</body>
|
|
</html>
|
|
</html>
|