-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: define boolean operations at the element level
- Loading branch information
Showing
16 changed files
with
473 additions
and
429 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,70 @@ | ||
import * as THREE from "three"; | ||
import { ClayObject } from "../../base"; | ||
import { v4 as uuidv4 } from "uuid"; | ||
import { IFC4X3 as IFC } from "web-ifc"; | ||
import { ClayObject, Model } from "../../base"; | ||
import { Opening } from "../Opening"; | ||
import { IfcUtils } from "../../utils/ifc-utils"; | ||
|
||
export abstract class Family extends ClayObject { | ||
abstract ifcData: IFC.IfcElement; | ||
abstract geometries: { [name: string]: ClayObject }; | ||
|
||
abstract get mesh(): THREE.InstancedMesh; | ||
mesh: THREE.InstancedMesh; | ||
|
||
position = new THREE.Vector3(); | ||
|
||
rotation = new THREE.Euler(); | ||
|
||
openings = new Map<number, IFC.IfcRelVoidsElement>(); | ||
|
||
constructor(model: Model) { | ||
super(model); | ||
this.mesh = this.newThreeMesh(); | ||
} | ||
|
||
addOpening(opening: Opening) { | ||
const voids = new IFC.IfcRelVoidsElement( | ||
new IFC.IfcGloballyUniqueId(uuidv4()), | ||
null, | ||
null, | ||
null, | ||
this.ifcData, | ||
opening.ifcData | ||
); | ||
|
||
this.model.set(voids); | ||
|
||
const id = opening.ifcData.expressID; | ||
this.openings.set(id, voids); | ||
|
||
this.model.update(); | ||
} | ||
|
||
removeOpening(opening: Opening) { | ||
const id = opening.ifcData.expressID; | ||
const found = this.openings.get(id); | ||
if (!found) return; | ||
this.model.delete(found); | ||
this.model.update(); | ||
} | ||
|
||
updateElement() { | ||
const placement = this.model.get( | ||
this.ifcData.ObjectPlacement | ||
) as IFC.IfcLocalPlacement; | ||
|
||
const relPlacement = this.model.get( | ||
placement.RelativePlacement | ||
) as IFC.IfcAxis2Placement3D; | ||
|
||
IfcUtils.setAxis2Placement( | ||
this.model, | ||
relPlacement, | ||
this.position, | ||
this.rotation | ||
); | ||
|
||
this.model.set(this.ifcData); | ||
this.setMesh(this.ifcData.expressID, this.mesh); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.