diff --git a/Sources/IO/Geometry/IFCImporter/example/controller.html b/Sources/IO/Geometry/IFCImporter/example/controller.html
new file mode 100644
index 00000000000..d77bd53ba33
--- /dev/null
+++ b/Sources/IO/Geometry/IFCImporter/example/controller.html
@@ -0,0 +1,15 @@
+
diff --git a/Sources/IO/Geometry/IFCImporter/example/index.js b/Sources/IO/Geometry/IFCImporter/example/index.js
index 847ad237368..418e12418cf 100644
--- a/Sources/IO/Geometry/IFCImporter/example/index.js
+++ b/Sources/IO/Geometry/IFCImporter/example/index.js
@@ -6,18 +6,33 @@ import '@kitware/vtk.js/Rendering/Profiles/Geometry';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkResourceLoader from '@kitware/vtk.js/IO/Core/ResourceLoader';
import vtkIFCImporter from '@kitware/vtk.js/IO/Geometry/IFCImporter';
+import vtkURLExtract from '@kitware/vtk.js/Common/Core/URLExtract';
+
+import controlPanel from './controller.html';
// ----------------------------------------------------------------------------
// Example code
// ----------------------------------------------------------------------------
+const userParams = vtkURLExtract.extractURLParameters();
+const url =
+ userParams.fileURL ||
+ 'https://raw.githubusercontent.com/ThatOpen/engine_web-ifc/refs/heads/main/tests/ifcfiles/public/duplex.ifc';
+const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
+fullScreenRenderer.addController(controlPanel);
+
+if (userParams.mergeGeometries === undefined) {
+ userParams.mergeGeometries = true;
+}
+const mergeGeometriesCheckbox = document.querySelector('#mergeGeometries');
+mergeGeometriesCheckbox.checked = Boolean(userParams.mergeGeometries);
+
const importer = vtkIFCImporter.newInstance({
- mergeGeometries: true,
+ mergeGeometries: mergeGeometriesCheckbox.checked,
});
// ----------------------------------------------------------------------------
function update() {
- const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
@@ -41,9 +56,9 @@ vtkResourceLoader
vtkIFCImporter.setIFCAPI(window.WebIFC);
// Trigger data download
- importer
- .setUrl(
- 'https://raw.githubusercontent.com/ThatOpen/engine_web-ifc/refs/heads/main/tests/ifcfiles/public/duplex.ifc'
- )
- .then(update);
+ importer.setUrl(url).then(update);
});
+
+mergeGeometriesCheckbox.addEventListener('change', (evt) => {
+ window.location = `?mergeGeometries=${evt.target.checked}`;
+});
diff --git a/Sources/IO/Geometry/IFCImporter/index.js b/Sources/IO/Geometry/IFCImporter/index.js
index b4969c198f0..7bbdfacfe54 100644
--- a/Sources/IO/Geometry/IFCImporter/index.js
+++ b/Sources/IO/Geometry/IFCImporter/index.js
@@ -94,11 +94,34 @@ function vtkIFCImporter(publicAPI, model) {
.buildFromRadian()
.setMatrix(userMatrix);
+ const rotMatrix = [
+ userMatrix[0],
+ userMatrix[1],
+ userMatrix[2],
+ 0,
+ userMatrix[4],
+ userMatrix[5],
+ userMatrix[6],
+ 0,
+ userMatrix[8],
+ userMatrix[9],
+ userMatrix[10],
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ ];
+ const rotationMatrix = vtkMatrixBuilder
+ .buildFromRadian()
+ .setMatrix(rotMatrix);
+
for (let i = 0; i < vertices.length; i += 6) {
const point = [vertices[i], vertices[i + 1], vertices[i + 2]];
const normal = [vertices[i + 3], vertices[i + 4], vertices[i + 5]];
- transformMatrix.apply(point).apply(normal);
+ transformMatrix.apply(point);
+ rotationMatrix.apply(normal);
pointValues[i / 2] = point[0];
pointValues[i / 2 + 1] = point[1];
@@ -244,32 +267,32 @@ function vtkIFCImporter(publicAPI, model) {
publicAPI.importActors = (renderer) => {
if (model.mergeGeometries) {
const opaqueMeshes = meshes.filter((mesh) => mesh.color.w === 1);
- let apd = vtkAppendPolyData.newInstance();
+ const oapd = vtkAppendPolyData.newInstance();
opaqueMeshes.forEach((mesh) => {
const pd = createColoredPolyDataFromIFCMesh(mesh);
- apd.addInputData(pd);
+ oapd.addInputData(pd);
});
let mapper = vtkMapper.newInstance();
mapper.setColorModeToDirectScalars();
- mapper.setInputConnection(apd.getOutputPort());
+ mapper.setInputConnection(oapd.getOutputPort());
let actor = vtkActor.newInstance();
actor.setMapper(mapper);
renderer.addActor(actor);
const transparentMeshes = meshes.filter((mesh) => mesh.color.w < 1);
- apd = vtkAppendPolyData.newInstance();
+ const tapd = vtkAppendPolyData.newInstance();
transparentMeshes.forEach((mesh) => {
const pd = createColoredPolyDataFromIFCMesh(mesh);
- apd.addInputData(pd);
+ tapd.addInputData(pd);
});
mapper = vtkMapper.newInstance();
mapper.setColorModeToDirectScalars();
- mapper.setInputConnection(apd.getOutputPort());
+ mapper.setInputConnection(tapd.getOutputPort());
actor = vtkActor.newInstance();
actor.setMapper(mapper);