Skip to content

Commit

Permalink
Merge pull request #6 from IFCjs/feat/restructure-clay
Browse files Browse the repository at this point in the history
Refactoring the code and creating the SimpleWall family
  • Loading branch information
rrdls authored Feb 12, 2024
2 parents 8ccb2bc + c692ade commit f2b82ca
Show file tree
Hide file tree
Showing 45 changed files with 169,817 additions and 28,812 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
ignorePatterns: ["**/dist/*", "**/node_modules/*", "**/*.json", "**/*.js"],
rules: {
"prettier/prettier": [
"error",
"off",
{
endOfLine: "auto",
},
Expand Down
150 changes: 150 additions & 0 deletions examples/simple-wall.html
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>
44 changes: 23 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,31 @@
"publish-repo-alpha": "cpy package.json dist && cd dist && npm publish --tag alpha"
},
"devDependencies": {
"@rollup/plugin-commonjs": "25.0.0",
"@rollup/plugin-node-resolve": "15.1.0",
"@types/earcut": "^2.1.1",
"@types/jest": "27.0.0",
"@types/node": "^14.14.31",
"@types/three": "0.152.1",
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"cpy-cli": "^3.1.1",
"eslint": "^7.28.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"jest": "27.0.4",
"prettier": "^2.3.1",
"rollup": "3.2.3",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",
"typescript": "^4.3.2"
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/earcut": "^2.1.4",
"@types/jest": "^29.5.11",
"@types/node": "^20.11.6",
"@types/three": "^0.160.0",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"cpy-cli": "^5.0.0",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"prettier": "^3.2.4",
"rollup": "^4.9.6",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"dependencies": {
"earcut": "^2.2.4",
"three": "0.152.2"
"openbim-components": "^1.3.2",
"three": "^0.160.1",
"web-ifc": "^0.0.50"
}
}
Loading

0 comments on commit f2b82ca

Please sign in to comment.