Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Aug 2, 2024
1 parent 6de2e64 commit 16d03d5
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 89 deletions.
147 changes: 112 additions & 35 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -118175,7 +118175,7 @@ const parseNodesWithNames = (function () {

const objectIdStack = [];
const meshIdsStack = [];
let meshIds = null;
let meshIds = [];

return function (ctx, node, depth, matrix) {
matrix = parseNodeMatrix(node, matrix);
Expand Down Expand Up @@ -127080,7 +127080,7 @@ class TreeViewPlugin extends Plugin {
this._nodeNodes[buildingNode.nodeId] = buildingNode;
} else if (metaObjectType === "IfcBuildingStorey") {
if (!buildingNode) {
this.error("Failed to build storeys hierarchy for model '" + this.metaModel.id + "' - model does not have an IfcBuilding object, or is not an IFC model");
this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");
return;
}
storeyNode = {
Expand Down Expand Up @@ -139267,49 +139267,126 @@ class DotBIMLoaderPlugin extends Plugin {

const dbMeshId = element.mesh_id;

parseDBMesh(dbMeshId);

const meshId = `${objectId}-mesh`;
const vector = element.vector;
const rotation = element.rotation;
const props = objectDefaults ? objectDefaults[elementType] || objectDefaults["DEFAULT"] : null;

let visible = true;
let pickable = true;
let color = element.color ? [element.color.r / 255, element.color.g / 255, element.color.b / 255] : [1, 1, 1];
let opacity = element.color ? element.color.a / 255 : 1.0;

if (props) {
if (props.visible === false) {
visible = false;
}
if (props.pickable === false) {
pickable = false;
}
if (props.colorize) {
color = props.colorize;
}
if (props.opacity !== undefined && props.opacity !== null) {
opacity = props.opacity;
if (element.face_colors === undefined) {

parseDBMesh(dbMeshId);

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

let color = element.color ? [element.color.r / 255.0, element.color.g / 255.0, element.color.b / 255.0] : [1, 1, 1];
let opacity = element.color ? element.color.a / 255.0 : 1.0;

if (props) {
if (props.visible === false) {
visible = false;
}
if (props.pickable === false) {
pickable = false;
}
if (props.colorize) {
color = props.colorize;
}
if (props.opacity !== undefined && props.opacity !== null) {
opacity = props.opacity;
}
}

sceneModel.createMesh({
id: meshId,
geometryId: dbMeshId,
color: color,
opacity: opacity,
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
position: vector ? [vector.x, vector.y, vector.z] : undefined
});

sceneModel.createEntity({
id: objectId,
meshIds: [meshId],
visible: visible,
pickable: pickable,
isObject: true
});
}
else {
let faceColors = element.face_colors;
let coloredTrianglesDictionary = {};
let currentTriangleIndicesCount = 0;
let dbMesh = fileData.meshes[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) {
coloredTrianglesDictionary[faceColor] = [];
}
let indexForPoint0 = dbMesh.indices[currentTriangleIndicesCount];
let x0 = dbMesh.coordinates[indexForPoint0*3];
let y0 = dbMesh.coordinates[indexForPoint0*3+1];
let z0 = dbMesh.coordinates[indexForPoint0*3+2];
let indexForPoint1 = dbMesh.indices[currentTriangleIndicesCount+1];
let x1 = dbMesh.coordinates[indexForPoint1*3];
let y1 = dbMesh.coordinates[indexForPoint1*3+1];
let z1 = dbMesh.coordinates[indexForPoint1*3+2];
let indexForPoint2 = dbMesh.indices[currentTriangleIndicesCount+2];
let x2 = dbMesh.coordinates[indexForPoint2*3];
let y2 = dbMesh.coordinates[indexForPoint2*3+1];
let z2 = dbMesh.coordinates[indexForPoint2*3+2];
coloredTrianglesDictionary[faceColor].push(x0, y0, z0, x1, y1, z1, x2, y2, z2);

currentTriangleIndicesCount += 3;
}
let meshIds = [];
for (const [faceColor, trianglesCoordinates] of Object.entries(coloredTrianglesDictionary)) {
sceneModel.createGeometry({
id: `${dbMeshId}-${faceColor}`,
primitive: "triangles",
positions: trianglesCoordinates,
indices: [...Array(trianglesCoordinates.length).keys()]
});
const meshId = `${objectId}-mesh-${faceColor}`;
const faceColorArray = faceColor.split(',').map(Number);

sceneModel.createMesh({
id: meshId,
geometryId: dbMeshId,
color,
opacity,
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
position: vector ? [vector.x, vector.y, vector.z] : undefined
});
let color = [faceColorArray[0] / 255.0, faceColorArray[1] / 255.0, faceColorArray[2] / 255.0];
let opacity = faceColorArray[3] / 255.0;

sceneModel.createEntity({
id: objectId,
meshIds: [meshId],
visible,
pickable,
isObject: true
});
if (props) {
if (props.visible === false) {
visible = false;
}
if (props.pickable === false) {
pickable = false;
}
if (props.colorize) {
color = props.colorize;
}
if (props.opacity !== undefined && props.opacity !== null) {
opacity = props.opacity;
}
}

sceneModel.createMesh({
id: meshId,
geometryId: `${dbMeshId}-${faceColor}`,
color: color,
opacity: opacity,
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
position: vector ? [vector.x, vector.y, vector.z] : undefined
});
meshIds.push(meshId);
}
sceneModel.createEntity({
id: objectId,
meshIds: meshIds,
visible: visible,
pickable: pickable,
isObject: true
});
}

for (let infoKey in info) {
let properties;
Expand Down
147 changes: 112 additions & 35 deletions dist/xeokit-sdk.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -118171,7 +118171,7 @@ const parseNodesWithNames = (function () {

const objectIdStack = [];
const meshIdsStack = [];
let meshIds = null;
let meshIds = [];

return function (ctx, node, depth, matrix) {
matrix = parseNodeMatrix(node, matrix);
Expand Down Expand Up @@ -127076,7 +127076,7 @@ class TreeViewPlugin extends Plugin {
this._nodeNodes[buildingNode.nodeId] = buildingNode;
} else if (metaObjectType === "IfcBuildingStorey") {
if (!buildingNode) {
this.error("Failed to build storeys hierarchy for model '" + this.metaModel.id + "' - model does not have an IfcBuilding object, or is not an IFC model");
this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");
return;
}
storeyNode = {
Expand Down Expand Up @@ -139263,49 +139263,126 @@ class DotBIMLoaderPlugin extends Plugin {

const dbMeshId = element.mesh_id;

parseDBMesh(dbMeshId);

const meshId = `${objectId}-mesh`;
const vector = element.vector;
const rotation = element.rotation;
const props = objectDefaults ? objectDefaults[elementType] || objectDefaults["DEFAULT"] : null;

let visible = true;
let pickable = true;
let color = element.color ? [element.color.r / 255, element.color.g / 255, element.color.b / 255] : [1, 1, 1];
let opacity = element.color ? element.color.a / 255 : 1.0;

if (props) {
if (props.visible === false) {
visible = false;
}
if (props.pickable === false) {
pickable = false;
}
if (props.colorize) {
color = props.colorize;
}
if (props.opacity !== undefined && props.opacity !== null) {
opacity = props.opacity;
if (element.face_colors === undefined) {

parseDBMesh(dbMeshId);

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

let color = element.color ? [element.color.r / 255.0, element.color.g / 255.0, element.color.b / 255.0] : [1, 1, 1];
let opacity = element.color ? element.color.a / 255.0 : 1.0;

if (props) {
if (props.visible === false) {
visible = false;
}
if (props.pickable === false) {
pickable = false;
}
if (props.colorize) {
color = props.colorize;
}
if (props.opacity !== undefined && props.opacity !== null) {
opacity = props.opacity;
}
}

sceneModel.createMesh({
id: meshId,
geometryId: dbMeshId,
color: color,
opacity: opacity,
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
position: vector ? [vector.x, vector.y, vector.z] : undefined
});

sceneModel.createEntity({
id: objectId,
meshIds: [meshId],
visible: visible,
pickable: pickable,
isObject: true
});
}
else {
let faceColors = element.face_colors;
let coloredTrianglesDictionary = {};
let currentTriangleIndicesCount = 0;
let dbMesh = fileData.meshes[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) {
coloredTrianglesDictionary[faceColor] = [];
}
let indexForPoint0 = dbMesh.indices[currentTriangleIndicesCount];
let x0 = dbMesh.coordinates[indexForPoint0*3];
let y0 = dbMesh.coordinates[indexForPoint0*3+1];
let z0 = dbMesh.coordinates[indexForPoint0*3+2];
let indexForPoint1 = dbMesh.indices[currentTriangleIndicesCount+1];
let x1 = dbMesh.coordinates[indexForPoint1*3];
let y1 = dbMesh.coordinates[indexForPoint1*3+1];
let z1 = dbMesh.coordinates[indexForPoint1*3+2];
let indexForPoint2 = dbMesh.indices[currentTriangleIndicesCount+2];
let x2 = dbMesh.coordinates[indexForPoint2*3];
let y2 = dbMesh.coordinates[indexForPoint2*3+1];
let z2 = dbMesh.coordinates[indexForPoint2*3+2];
coloredTrianglesDictionary[faceColor].push(x0, y0, z0, x1, y1, z1, x2, y2, z2);

currentTriangleIndicesCount += 3;
}
let meshIds = [];
for (const [faceColor, trianglesCoordinates] of Object.entries(coloredTrianglesDictionary)) {
sceneModel.createGeometry({
id: `${dbMeshId}-${faceColor}`,
primitive: "triangles",
positions: trianglesCoordinates,
indices: [...Array(trianglesCoordinates.length).keys()]
});
const meshId = `${objectId}-mesh-${faceColor}`;
const faceColorArray = faceColor.split(',').map(Number);

sceneModel.createMesh({
id: meshId,
geometryId: dbMeshId,
color,
opacity,
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
position: vector ? [vector.x, vector.y, vector.z] : undefined
});
let color = [faceColorArray[0] / 255.0, faceColorArray[1] / 255.0, faceColorArray[2] / 255.0];
let opacity = faceColorArray[3] / 255.0;

sceneModel.createEntity({
id: objectId,
meshIds: [meshId],
visible,
pickable,
isObject: true
});
if (props) {
if (props.visible === false) {
visible = false;
}
if (props.pickable === false) {
pickable = false;
}
if (props.colorize) {
color = props.colorize;
}
if (props.opacity !== undefined && props.opacity !== null) {
opacity = props.opacity;
}
}

sceneModel.createMesh({
id: meshId,
geometryId: `${dbMeshId}-${faceColor}`,
color: color,
opacity: opacity,
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
position: vector ? [vector.x, vector.y, vector.z] : undefined
});
meshIds.push(meshId);
}
sceneModel.createEntity({
id: objectId,
meshIds: meshIds,
visible: visible,
pickable: pickable,
isObject: true
});
}

for (let infoKey in info) {
let properties;
Expand Down
22 changes: 11 additions & 11 deletions dist/xeokit-sdk.es5.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/xeokit-sdk.min.cjs.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/xeokit-sdk.min.es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/xeokit-sdk.min.es5.js

Large diffs are not rendered by default.

0 comments on commit 16d03d5

Please sign in to comment.