Skip to content

Commit

Permalink
fix(core): correct geometry splits tiling bug
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 20, 2024
1 parent a5cbe8d commit ac32b51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components",
"description": "Collection of core functionalities to author BIM apps.",
"version": "2.4.0-alpha.7",
"version": "2.4.0-alpha.8",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down
15 changes: 9 additions & 6 deletions packages/core/src/fragments/IfcGeometryTiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export class IfcGeometryTiler extends Component implements Disposable {
this.webIfc.SetLogLevel(logLevel);
}
this.webIfc.OpenModelFromCallback(loadCallback, this.settings.webIfc);
this._nextAvailableID = this.webIfc.GetMaxExpressID(0);
}

private async streamAllGeometries() {
Expand Down Expand Up @@ -337,7 +338,7 @@ export class IfcGeometryTiler extends Component implements Disposable {

if (!this._visitedGeometries.has(transpGeometryID)) {
// This is the first time we see this geometry
this.getGeometry(webIfc, geometryID, transpGeometryID);
this.getGeometry(webIfc, geometryID, isOpaque);
}

this.registerGeometryData(
Expand All @@ -361,11 +362,7 @@ export class IfcGeometryTiler extends Component implements Disposable {
this._assets.push(asset);
}

private getGeometry(
webIfc: WEBIFC.IfcAPI,
id: number,
transpGeometryID: number,
) {
private getGeometry(webIfc: WEBIFC.IfcAPI, id: number, isOpaque: boolean) {
const geometry = webIfc.GetGeometry(0, id);

// Get the full index, position and normal data
Expand Down Expand Up @@ -393,6 +390,9 @@ export class IfcGeometryTiler extends Component implements Disposable {
normal[i / 2 + 2] = vertexData[i + 5];
}

// Take transparency into account
const factor = isOpaque ? 1 : -1;

// Empty geometry
if (index.length === 0) {
// prettier-ignore
Expand All @@ -413,6 +413,8 @@ export class IfcGeometryTiler extends Component implements Disposable {

const geomIndex = this._visitedGeometries.size;
const uuid = THREE.MathUtils.generateUUID();

const transpGeometryID = id * factor;
this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
this._geometryCount++;
geometry.delete();
Expand Down Expand Up @@ -484,6 +486,7 @@ export class IfcGeometryTiler extends Component implements Disposable {

const geomIndex = this._visitedGeometries.size;
const uuid = THREE.MathUtils.generateUUID();
const transpGeometryID = geometryID * factor;
this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
this._geometryCount++;
firstSplit = false;
Expand Down

0 comments on commit ac32b51

Please sign in to comment.