ifcjs / hello-world Goto Github PK
View Code? Open in Web Editor NEWMinimal examples of open BIM application using IFC.js.
License: MIT License
Minimal examples of open BIM application using IFC.js.
License: MIT License
Hello-world tutorial for ifc-web is returning [ ] (array named spaces) for every .ifc file available for the same tutorial. I've checked and
let lines = ifcapi.GetLineIDsWithType(modelID, IFSPACE);
returns an empty array.
Is it possible to check what might be the problem? I'm copying the repo url:
Make a tutorial on multi-format converter/loader
Adjust relative localisation
Add a button to adjust the position of each model relatively one to others:
Process: select a model in viewer, define a base point on it, then define a target point on one of other loaded models
Expected result: Model moves to the target point
demonstrate clipping plans
Add a button to add clipping plan by selecting a model face
Add a switch button to switch visibility of clipping vector and plans
demonstrate 2D projections and exports (PDF/DXF)
Add a button to project 2D line drawing by selecting a face or a clipping plan
Add a button+shortcut to export PDF of 2D edge projection
Add a button+shortcut to export DXF of 2D edge projection
Inspiration links :
A list of requirements for this bounty to be considered successful :
If someone completes a part of the bounty, a part of the money is given and a new bounty is created.
Links, documentation and references that you think will help to complete the task.
β CHALLENGE:
We need a 3D navigation cube to easily control the camera in 3D. We need an example using that cube and web-ifc-three in the following repository:
π©ββοΈ REQUIREMENTS:
The cube should be similar to this: https://i.stack.imgur.com/uYSbQ.jpg
The cube should allow any user to control the camera around smoothly.
β CHALLENGE:
We need a 3D navigation cube to easily control the camera in 3D. We need an example using that cube and web-ifc-three in the following repository:
π©ββοΈ REQUIREMENTS:
The cube should be similar to this: https://i.stack.imgur.com/uYSbQ.jpg
The cube should allow any user to control the camera around smoothly.
To enable more dynamic workflows in IFC and future versions of IFC we are exploring a "By Element" approach to IFC data. This means storing individual IFC files per element. To utilize this data it necessary to be able to load many files at once vs one at a time. This request is to enable the selection of one or more IFC files and have them load via a single threaded or if possible a multi-threaded process.
The sample data can be found here.
-https://github.com/magnetar-io/ByElementIFC_Data/tree/main/Basic%20Sample%20Architecture%202
Sample Files; -https://github.com/magnetar-io/ByElementIFC_Data/tree/main/Basic%20Sample%20Architecture%202
I have tried to upload IFC4 file in the hello world example in the IFC documentation web site. But the IFC file is not rendered properly. But the same model is loaded properly with the BIMvision software.
Isn't IFC4 files are compatiple with IFC.js ?
hello world result
https://ibb.co/g6zX0dW
BIMvision software result
https://ibb.co/hBhkQz7
Three.js
.Autodesk Forge has a very nice ambient occlusion that gives it a cool look. You can check it out here:
As far as we know, Forge is built Three.js (around version 70), so we are convinced that it is possible to achieve that effect, especially considering all the advances Three.js has made since then.
Similar look to Forge viewer.
Decent performance (don't go below 30 fps with medium-size IFC models in a laptop).
You can use the hello world repository, which has a simple example of IFC.js that you can use as starting point:
Here you have some IFC files to test:
In addition to that, there are multiple types of ambient occlusion examples published in official Three.js resources:
Hey agviegas thankyou for creating such a great tutorial for the IFC.js-three.js beginners.
Yesterday I attempted using the hello-world tutorial to build my first ifc viewer and did so by using the hello-world html and app.js. I then downloaded the web-ifc.wasm file and bundled the projekt using webpack. After opening the site the 3d scene appears, but the scene is unable to add the ifc model. I recompiled multiple times and switched between local and external ifc files and when the ifc files are attempted to be loaded (by app.js) I always receive the error:
TypeError: Cannot read property 'rawConstructor' of undefined
at pe (bundle_3d_viewer.js:2)
at web-ifc.wasm:0x45b2d
at X (web-ifc.wasm:0x301c2)
at r.___wasm_call_ctors (bundle_3d_viewer.js:2)
at func (bundle_3d_viewer.js:2)
at _t (bundle_3d_viewer.js:2)
at pt (bundle_3d_viewer.js:2)
at s (bundle_3d_viewer.js:2)
at Ui (bundle_3d_viewer.js:2)
at t (bundle_3d_viewer.js:2)
(anonymous) @ bundle_3d_viewer.js:2
async function (async)
(anonymous) @ bundle_3d_viewer.js:2
(anonymous) @ bundle_3d_viewer.js:2
load (async)
load @ bundle_3d_viewer.js:2
load @ bundle_3d_viewer.js:2
(anonymous) @ bundle_3d_viewer.js:2
my app.js that I used for bundling and the corresponding webpack.config.js is also added below to give more context.
app.js
import {
AmbientLight,
AxesHelper,
Color,
DirectionalLight,
GridHelper,
PerspectiveCamera,
Scene,
Vector3,
WebGLRenderer,
} from "three";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
import { IFCLoader } from "three/examples/jsm/loaders/IFCLoader";
//Creates the Three.js scene
const scene = new Scene();
//Object to store the size of the viewport
const size = {
width: window.innerWidth,
height: window.innerHeight,
};
//Creates the camera (point of view of the user)
const camera = new PerspectiveCamera(75, size.width / size.height);
camera.position.z = 15;
camera.position.y = 13;
camera.position.x = 8;
//Creates the lights of the scene
const lightColor = 0xffffff;
const ambientLight = new AmbientLight(lightColor, 0.5);
scene.add(ambientLight);
const directionalLight = new DirectionalLight(lightColor, 1);
directionalLight.position.set(0, 10, 0);
directionalLight.target.position.set(-5, 0, 0);
scene.add(directionalLight);
scene.add(directionalLight.target);
//Sets up the renderer, fetching the canvas of the HTML
const threeCanvas = document.getElementById("three-canvas");
const renderer = new WebGLRenderer({ canvas: threeCanvas, alpha: true });
renderer.setSize(size.width, size.height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
//Creates grids and axes in the scene
const grid = new GridHelper(50, 30);
scene.add(grid);
const axes = new AxesHelper();
axes.material.depthTest = false;
axes.renderOrder = 1;
scene.add(axes);
//Creates the orbit controls (to navigate the scene)
const controls = new OrbitControls(camera, threeCanvas);
controls.enableDamping = true;
controls.target.set(-2, 0, 0);
//Animation loop
const animate = () => {
controls.update();
renderer.render(scene, camera);
requestAnimationFrame(animate);
};
animate();
//Adjust the viewport to the size of the browser
window.addEventListener("resize", () => {
(size.width = window.innerWidth), (size.height = window.innerHeight);
camera.aspect = size.width / size.height;
camera.updateProjectionMatrix();
renderer.setSize(size.width, size.height);
});
//Sets up the IFC loading
function loadIFC(){}
const ifcLoader = new IFCLoader();
ifcLoader.setWasmPath("../");
const url = "https://raw.githubusercontent.com/IFCjs/test-ifc-files/main/Revit/TESTED_Simple_project_01.ifc";
window.addEventListener('DOMContentLoaded', (event) => {
ifcLoader.load(url, (geometry) => scene.add(geometry));
});
webpack.config.js
const path = require('path');
module.exports = {
entry: "./src/public/js/app.js",
output: {
filename: 'bundle_3d_viewer.js',
path: path.join(__dirname,"/src/public/dist")
},
devServer: {
contentBase: path.join(__dirname,'/src/public'),
port:9000
}
};
Here is the viewer.html, which is essentially the same as the tutorial, but with different paths.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../css/platform.css" />
<title>Document</title>
</head>
<body>
<input type="file" name="load" id="file-input" />
<canvas id="three-canvas"></canvas>
<script src="../dist/bundle_3d_viewer.js"></script>
</body>
</html>
I suspect it is an issue with the wasm file, but it could also be the app.js itself or my bundelling technique.
Do you have an idea how I could fix it?
hi all,
im new to ifcjs. been working on it for few weeks now. anyway ive an issue still unable to solve.
i took the example at "https://github.com/IFCjs/hello-world/blob/main/examples/web-ifc-viewer/spatial-tree/". it tends to crashed with larger models with "RangeError: Maximum call stack size exceeded".
i need to create a tree for the model. any fix or other approach to this? thanks in advance.
β CHALLENGE:
We need a 3D navigation cube to easily control the camera in 3D. We need an example using that cube and web-ifc-three in the following repository:
π©ββοΈ REQUIREMENTS:
The cube should be similar to this: https://i.stack.imgur.com/uYSbQ.jpg
The cube should allow any user to control the camera around smoothly.
Three.js
.One of the most powerful use cases for BIM is building energy analysis. Luckily, there are brilliant people who are already implementing this problem; we are referring to the people at Ladybug Tools.
One of their free libraries for energy analysis is Honeybee, which uses their own open HBJSON format. The goal of this task is to extract all the necessary data from an IFC and create an HBJSON file that HoneyBee can read correctly.
We are aware that many IFCs do not have the necessary information for their energy analysis, and the aim of this task is not to generate that information. We are going to provide an IFC that does have that data, so you can concentrate on simply extracting it to generate the JSON.
Quoting Mostapha Sadeghipour (Ladybug tools):
The way a simulation model should be prepared depends on the type of the simulation. A model can be built face-by-face or it can be built room-by-room. The first one is great for daylight simulation. The second one is what is needed for energy simulation. In the IFC world IFCSpaces are supposed to those rooms that should be used for energy simulation but it is not as easy. Here you have a related discussion in OSArch:
Regarding HBJSON, and quoting Mostapha again: The schema is open source and documented here: https://www.ladybug.tools/honeybee-schema/model.html#tag/model_model - Model is the object that describes the whole building.: You can think about it as a mini-IFC fo
We use OpenAPI toolkit to generate different SDKs. We use Python and C# actively. We have never used the JS one but this project might be the right place to use it. Once we generate a valid HBJSON file the rest of the process is taken care of with our translators. Most of our translators are written in Python but since we use the HBJSON file in the middle as the transition layer it doesn't really matter what language you want to use to generate the HBJSON file.
You can use the hello world repository, which has a simple example of IFC.js that you can use as starting point:
Here you have an IFC files with the necesary information to make energy analysis:
Here you have the HBJSON specification:
Finally, here you have some HBJSON examples:
Hi,
I would like to be able to allow people to view my IFC files in VR -- with Oculus goggles for example.
Please have a look at the course at Udemy https://www.udemy.com/course/intro-webxr/
and some information for developers at:
https://developer.oculus.com/manage/organizations/create/
All I expect is:
Please let me know if you can include some AR capabilities in the project.
Kind regards, Marcos
A follow-up to the conversation in the Discord Channel (user name: Arie);
At the start of a project, we define the requirements for the IFC models which parties have to create. During the project, it's very time consuming checking these models manually to see if the IFC models fits the requirements. It would be nice if this process can be more automated by automatically checking the properties of the objects in the IFC model.
For example:
Also, we need to set custom requirements. For example;
Setting the requirements beforehand isn't the hardest part for me. But getting the right structure out of IFCjs to do the check, is the part I need help with.
Looking at the size of the IFC models (200-300mb) I think, as you suggested in the Discord Channel, JSON in combination with a NoSQL database (MongoDB) suits the best. Preprocessing the IFC models in the beginning so the querying (check the properties) is faster, fits the best for my situation I think.
For testing purposes, I have installed the local version of MongoDB.
Thanks for your help and your great product!
I tried updating and running this example. First problem is it points to an old test IFC file, IFC/7/Tungasletta10_R01.ifc, which is no longer there. I changed main.js to use the 01.ifc that is there but then get the following error:
pablo@top:~/ifcjs/hello-world/examples/web-ifc/ifc-to-json/node> node main.js
web-ifc: 0.0.34 threading: 0
TypeError: Cannot convert "undefined" to unsigned int
at Object.toWireType (/Users/pablo/ifcjs/hello-world/node_modules/web-ifc/web-ifc-api-node.js:10184:21)
at Object.GetLine (eval at new_ (/Users/pablo/ifcjs/hello-world/node_modules/web-ifc/web-ifc-api-node.js:9880:31), <anonymous>:8:26)
at IfcAPI2.GetRawLineData (/Users/pablo/ifcjs/hello-world/node_modules/web-ifc/web-ifc-api-node.js:54841:28)
at IfcAPI2.GetLine (/Users/pablo/ifcjs/hello-world/node_modules/web-ifc/web-ifc-api-node.js:54790:28)
at saveProperties (/Users/pablo/ifcjs/hello-world/examples/web-ifc/ifc-to-json/node/main.js:42:26)
at getAllItemsFromLines (/Users/pablo/ifcjs/hello-world/examples/web-ifc/ifc-to-json/node/main.js:33:13)
at GetAllItems (/Users/pablo/ifcjs/hello-world/examples/web-ifc/ifc-to-json/node/main.js:26:5)
at LoadFile (/Users/pablo/ifcjs/hello-world/examples/web-ifc/ifc-to-json/node/main.js:12:22)
Last commit to the repo:
> git log
commit 5d8f9fb7d613c13c912d288c9006b798bba7959a (HEAD -> main, origin/main, origin/HEAD)
Author: Antonio GonzΓ‘lez Viegas <[email protected]>
Date: Wed Jun 22 00:39:02 2022 +0200
Add psets to gltf import example
When I add more than one model to the web-ifc-three/picking-properties example and when I try to select any element that doesn't belong to the first model it throws this error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'type')
at IfcAPI2.GetLine (bundle.js:75440:48)
at WebIfcPropertyManager.getItemProperties (bundle.js:76763:27)
at PropertyManager.getItemProperties (bundle.js:77775:30)
at IFCManager.getItemProperties (bundle.js:79061:28)
at pick (bundle.js:83427:33)
When doing the same with web-ifc-viewer/picking, it throws this error when the mouse is over any element:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'mesh')
at ItemsMap.getGeometry (bundle.js:89496:49)
at ItemsMap.generateGeometryIndexMap (bundle.js:89474:27)
at SubsetCreator.createSubset (bundle.js:89606:18)
at SubsetManager.createSubset (bundle.js:89751:31)
at IFCManager.createSubset (bundle.js:92428:25)
at IfcSelection.newSelection (bundle.js:92583:49)
at IfcSelection.pick (bundle.js:92566:35)
at async IfcSelector.prePickIfcItem (bundle.js:92667:9)
How should I fix these?
Three.js
.The goal is to take an arbitrary 3d object in Three.js and generate the 2d projection of their occluded edges.
To understand what we want, take a look at the tables/chairs in the following image. Just focus on the chair + table, ignore the rest:
We want this to generate floor plans, so if you do it so that it projects the edges in an horizontal plane, it's more than enough.
Generate an array of coplanar edges that represent the object from above.
The process shouldn't be slow. A small object (like the one provided below) should be processed in less than 1/2 seconds.
You can start with a standard three.js scene. Here you have the same chairs/tables of the images shown above:
And here you have some interesting resources that might serve you as a starting point:
If you have any questions, let us know!
β CHALLENGE:
We need a 3D navigation cube to easily control the camera in 3D. We need an example using that cube and web-ifc-three in the following repository:
π©ββοΈ REQUIREMENTS:
The cube should be similar to this: https://i.stack.imgur.com/uYSbQ.jpg
The cube should allow any user to control the camera around smoothly.
Hi, i would love to try testing the examples that results in compiling the project using 'npm build'. I know this comes from my unknowledge regarding Node.js but shouldn't this output an HTML where I could test this packages? Thanks in advance.
Three.js
.Autodesk Forge has a very nice edges that gives it a cool look. You can check it out here:
As far as we know, Forge is built Three.js (around version 70), so we are convinced that it is possible to achieve that effect, especially considering all the advances Three.js has made since then.
We have tried THREE.EdgesGeometry (https://threejs.org/docs/#api/en/geometries/EdgesGeometry), but it's not very performant in bigger models. A postproduction or shader approach is what we are looking for.
Similar look to Forge viewer.
Decent performance (don't go below 30 fps with medium-size IFC models in a laptop).
You can use the hello world repository, which has a simple example of IFC.js that you can use as starting point:
Here you have some IFC files to test:
In addition to that, there are multiple related discussions in the three.js forum. For instance:
The objective is to extract data from an IFC file that can be used to create an adjacency graph, in which the vertices represent voxels. The voxels have a property clashes:[]
that contains an array of the expressID
s of the building elements they intersect (clash) with.
There are two major steps in the process:
The output contains, for each storey in a building, an array of voxels and the elements it clashes with. NOTE: we expect that many of the voxels clash with multiple elements.
The input to the process is defined as follows
{
// Where to get the file
url: 'file:///IFCSchependomlaan.ifc',
// Size of voxels in 3 dimensions, in mm
voxelSize: [500,500,500],
// Which types to include in the clash detection
// If not present, include all
// Prevails over excludes
includes: [
'IFCWALL',
'IFCWINDOW',
'IFCSTAIRS',
'IFCDOOR'
],
// Which types to exclude in the clash detection
// If not present, do not exclude anything
excludes: [
'IFCRAILING',
'IFCFURNISHINGELEMENT'
]
}
The output that will allow the creation of the adjacency graph is the following
{
// meta contains the original input, and the processing time in ms
meta: {
input: {},
duration: 450
},
// the storeys array contains , for each storey, an array of voxels
// with a clashes property that contains the expressIDs of the items
// it clashes with., and a coords:[] property in indicating the position in the voxel matrix.
// Voxels that do not clash with anything do not need to be returned.
storeys: [
{
level: -1,
name: 'basement',
expressID: 120,
voxels: [,
{
coords: [5,40,2],
clashes: [
42552,
3662,
267282,
467383
]
},
{
coords: [5,40,3],
clashes: [
42552,
267282
]
},
......
]
},
.....
]
}
Testfiles :
IFCSchependomlaan.ifc (multi storey)
Three.js
.A very interesting use case for BIM is collision detection. There are many companies that sell solutions whose only purpose is this.
IFC.js is already able to create a simple example where it detects collision between objects of the user's choice using subsets. This should be easy thanks to Garrett Johnson's work with three-mesh-bvh:
Create a simple clash detector that detects whether two subsets are colliding or not.
Get the IDs of the items that collide.
Filter clashes by intersection distance.
You can use the hello world repository, which has a simple example of IFC.js that you can use as starting point:
Here you have some IFC files to test:
Here you have some examples Garrett Johnson regarding collision in his three-mesh-bvh repository:
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/shapecast.html
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/edgeIntersect.html
In addition to that, here you have the IFC.js subset tutorial to understand how they work:
When i try to open any example it gives me this error: Uncaught (in promise) TypeError: this.wasmModule.OpenModel is not a function
.
How can i fix this or what did i do wrong? (ran all the npm scripts)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.