Skip to content

Commit

Permalink
Merge pull request #1637 from paireks/develop/dotbim_unsorted_meshes
Browse files Browse the repository at this point in the history
[FIX] Support unsorted set of meshes for face colors
  • Loading branch information
xeolabs committed Aug 22, 2024
2 parents ac73a01 + 8f05c1f commit 32ff91b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ export class DotBIMLoaderPlugin extends Plugin {
const fileData = ctx.fileData;
const sceneModel = ctx.sceneModel;

const dbMeshIndices = {};
const dbMeshLoaded = {};

const ifcProjectId = math.createUUID();
Expand Down Expand Up @@ -385,17 +384,14 @@ export class DotBIMLoaderPlugin extends Plugin {
propertySets: []
};

for (let i = 0, len = fileData.meshes.length; i < len; i++) {
const dbMesh = fileData.meshes[i];
dbMeshIndices[dbMesh.mesh_id] = i;
}

const parseDBMesh = (dbMeshId) => {
const parseDBMesh = (dbMeshId, element) => {
if (dbMeshLoaded[dbMeshId]) {
return;
}
const dbMeshIndex = dbMeshIndices[dbMeshId];
const dbMesh = fileData.meshes[dbMeshIndex];

const dbMesh = fileData.meshes.find(obj => {
return obj.mesh_id === element.mesh_id;
});
sceneModel.createGeometry({
id: dbMeshId,
primitive: "triangles",
Expand Down Expand Up @@ -434,7 +430,7 @@ export class DotBIMLoaderPlugin extends Plugin {

if (element.face_colors === undefined) {

parseDBMesh(dbMeshId);
parseDBMesh(dbMeshId, element);

const meshId = `${objectId}-mesh`;

Expand Down Expand Up @@ -477,7 +473,9 @@ export class DotBIMLoaderPlugin extends Plugin {
let faceColors = element.face_colors;
let coloredTrianglesDictionary = {};
let currentTriangleIndicesCount = 0;
let dbMesh = fileData.meshes[element.mesh_id];
let dbMesh = fileData.meshes.find(obj => {
return obj.mesh_id === element.mesh_id;
});
for (let i = 0, len = faceColors.length; i < len; i+=4) {
let faceColor = [faceColors[i], faceColors[i+1], faceColors[i+2], faceColors[i+3]];
if (coloredTrianglesDictionary[faceColor] === undefined) {
Expand Down

0 comments on commit 32ff91b

Please sign in to comment.