Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 38 additions & 34 deletions Sources/IO/Geometry/IFCImporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ function vtkIFCImporter(publicAPI, model) {
const pointValues = new Float32Array(vertices.length / 2);
const normalsArray = new Float32Array(vertices.length / 2);

for (let i = 0; i < vertices.length; i += 6) {
pointValues[i / 2] = vertices[i];
pointValues[i / 2 + 1] = vertices[i + 1];
pointValues[i / 2 + 2] = vertices[i + 2];

normalsArray[i / 2] = vertices[i + 3];
normalsArray[i / 2 + 1] = vertices[i + 4];
normalsArray[i / 2 + 2] = vertices[i + 5];
for (let i = 0, p = 0; i < vertices.length; i += 6, p += 3) {
pointValues[p] = vertices[i];
pointValues[p + 1] = vertices[i + 1];
pointValues[p + 2] = vertices[i + 2];

normalsArray[p] = vertices[i + 3];
normalsArray[p + 1] = vertices[i + 4];
normalsArray[p + 2] = vertices[i + 5];
}

const nCells = indices.length;
Expand Down Expand Up @@ -99,40 +99,44 @@ function vtkIFCImporter(publicAPI, model) {
.buildFromRadian()
.multiply3x3(mat3.fromMat4(mat3.create(), userMatrix));

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]];
const point = [0, 0, 0];
const normal = [0, 0, 0];
for (let i = 0, p = 0; i < vertices.length; i += 6, p += 3) {
point[0] = vertices[i];
point[1] = vertices[i + 1];
point[2] = vertices[i + 2];
normal[0] = vertices[i + 3];
normal[1] = vertices[i + 4];
normal[2] = vertices[i + 5];

transformMatrix.apply(point);
normalMatrix.apply(normal);

pointValues[i / 2] = point[0];
pointValues[i / 2 + 1] = point[1];
pointValues[i / 2 + 2] = point[2];
pointValues[p] = point[0];
pointValues[p + 1] = point[1];
pointValues[p + 2] = point[2];

normalsArray[i / 2] = normal[0];
normalsArray[i / 2 + 1] = normal[1];
normalsArray[i / 2 + 2] = normal[2];
normalsArray[p] = normal[0];
normalsArray[p + 1] = normal[1];
normalsArray[p + 2] = normal[2];

const colorIndex = i / 2;
colorArray[colorIndex] = color.x;
colorArray[colorIndex + 1] = color.y;
colorArray[colorIndex + 2] = color.z;
colorArray[p] = color.x;
colorArray[p + 1] = color.y;
colorArray[p + 2] = color.z;
}
} else {
for (let i = 0; i < vertices.length; i += 6) {
pointValues[i / 2] = vertices[i];
pointValues[i / 2 + 1] = vertices[i + 1];
pointValues[i / 2 + 2] = vertices[i + 2];

normalsArray[i / 2] = vertices[i + 3];
normalsArray[i / 2 + 1] = vertices[i + 4];
normalsArray[i / 2 + 2] = vertices[i + 5];

const colorIndex = i / 2;
colorArray[colorIndex] = color.x;
colorArray[colorIndex + 1] = color.y;
colorArray[colorIndex + 2] = color.z;
for (let i = 0, p = 0; i < vertices.length; i += 6, p += 3) {
pointValues[p] = vertices[i];
pointValues[p + 1] = vertices[i + 1];
pointValues[p + 2] = vertices[i + 2];

normalsArray[p] = vertices[i + 3];
normalsArray[p + 1] = vertices[i + 4];
normalsArray[p + 2] = vertices[i + 5];

colorArray[p] = color.x;
colorArray[p + 1] = color.y;
colorArray[p + 2] = color.z;
}
}

Expand Down