-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from IFCjs/feat/restructure-clay
Refactoring the code and creating the SimpleWall family
- Loading branch information
Showing
45 changed files
with
169,817 additions
and
28,812 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" | ||
/> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
<link rel="stylesheet" href="../../../resources/styles.css" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://fonts.googleapis.com/icon?family=Material+Icons" | ||
/> | ||
<link | ||
rel="icon" | ||
type="image/x-icon" | ||
href="../../../resources/favicon.ico" | ||
/> | ||
<title>Tools Component</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.full-screen { | ||
width: 100vw; | ||
height: 100vh; | ||
position: relative; | ||
overflow: hidden; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="full-screen" id="container"></div> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"three": "https://unpkg.com/[email protected]/build/three.module.js", | ||
"openbim-components": "../resources/openbim-components.js", | ||
"openbim-clay": "../resources/openbim-clay.js", | ||
"stats.js/src/Stats.js": "https://unpkg.com/[email protected]/src/Stats.js", | ||
"three/examples/jsm/libs/lil-gui.module.min": "https://unpkg.com/[email protected]/examples/jsm/libs/lil-gui.module.min.js", | ||
"three/examples/jsm/controls/TransformControls": "https://unpkg.com/[email protected]/examples/jsm/controls/TransformControls.js", | ||
"web-ifc": "../node_modules/web-ifc/web-ifc-api.js" | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
<script type="module"> | ||
import * as THREE from "three"; | ||
import * as OBC from "openbim-components"; | ||
import { Wall } from "openbim-clay"; | ||
import * as WEBIFC from "web-ifc"; | ||
import Stats from "stats.js/src/Stats.js"; | ||
import * as dat from "three/examples/jsm/libs/lil-gui.module.min"; | ||
import { TransformControls } from "three/examples/jsm/controls/TransformControls"; | ||
|
||
const container = document.getElementById("container"); | ||
|
||
const components = new OBC.Components(); | ||
|
||
components.scene = new OBC.SimpleScene(components); | ||
components.renderer = new OBC.PostproductionRenderer(components, container); | ||
components.camera = new OBC.SimpleCamera(components); | ||
components.raycaster = new OBC.SimpleRaycaster(components); | ||
|
||
components.init(); | ||
|
||
components.renderer.postproduction.enabled = true; | ||
|
||
const scene = components.scene.get(); | ||
|
||
components.camera.controls.setLookAt(12, 6, 8, 0, 0, -10); | ||
|
||
components.scene.setup(); | ||
|
||
const grid = new OBC.SimpleGrid(components, new THREE.Color(0x666666)); | ||
|
||
const customEffects = components.renderer.postproduction.customEffects; | ||
customEffects.excludedMeshes.push(grid.get()); | ||
|
||
// // IFC API | ||
|
||
const ifcAPI = new WEBIFC.IfcAPI(); | ||
|
||
ifcAPI.SetWasmPath("../../node_modules/web-ifc/", false); | ||
await ifcAPI.Init(); | ||
|
||
const model = ifcAPI.CreateModel({ schema: WEBIFC.Schemas.IFC4X3 }); | ||
|
||
const wall = new Wall(ifcAPI, model); | ||
|
||
scene.add(wall.mesh); | ||
|
||
// // Set up GUI | ||
|
||
const settings = { | ||
transformMode: "translate", | ||
}; | ||
|
||
// const helper = new THREE.Object3D(); | ||
const camera = components.camera.get(); | ||
|
||
// const controls = new TransformControls(camera, container); | ||
// controls.attach(wall.mesh); | ||
// scene.add(controls); | ||
|
||
// controls.addEventListener( | ||
// "dragging-changed", | ||
// (event) => (components.camera.enabled = !event.value) | ||
// ); | ||
|
||
// let transform = new THREE.Matrix4(); | ||
// controls.addEventListener("change", () => { | ||
// const mesh = wall.mesh; | ||
// mesh.updateMatrix(); | ||
// }); | ||
|
||
const gui = new dat.GUI(); | ||
gui.add(wall, "width").min(1).max(30).step(1); | ||
gui.add(wall, "height").min(1).max(30).step(1); | ||
gui.add(wall, "thickness").min(0.1).max(1).step(0.1); | ||
// gui.add(walls, "xPosition").min(-2).max(2).step(0.1); | ||
// gui.add(walls, "yPosition").min(-0.2).max(0.2).step(0.01); | ||
// gui.add(walls, "zPosition").min(-2).max(2).step(0.1); | ||
|
||
// gui | ||
// .add(settings, "transformMode", { | ||
// translate: "translate", | ||
// rotate: "rotate", | ||
// scale: "scale", | ||
// }) | ||
// .name("Transform mode") | ||
// .onChange((result) => { | ||
// controls.setMode(result); | ||
// }); | ||
|
||
// // Set up stats | ||
|
||
const stats = new Stats(); | ||
stats.showPanel(2); | ||
document.body.append(stats.dom); | ||
stats.dom.style.left = "0px"; | ||
const renderer = components.renderer; | ||
renderer.onBeforeUpdate.add(() => stats.begin()); | ||
renderer.onAfterUpdate.add(() => stats.end()); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.