| 4 | import { MathUtils } from "./math-utils"; |
| 5 | |
| 6 | export class IfcUtils { |
| 7 | static direction(vector: THREE.Vector3) { |
| 8 | return new IFC.IfcDirection([ |
| 9 | new IFC.IfcReal(vector.x), |
| 10 | new IFC.IfcReal(vector.y), |
| 11 | new IFC.IfcReal(vector.z), |
| 12 | ]); |
| 13 | } |
| 14 | |
| 15 | static point(vector: THREE.Vector3) { |
| 16 | return new IFC.IfcCartesianPoint([ |
| 17 | new IFC.IfcLengthMeasure(vector.x), |
| 18 | new IFC.IfcLengthMeasure(vector.y), |
| 19 | new IFC.IfcLengthMeasure(vector.z), |
| 20 | ]); |
| 21 | } |
| 22 | |
| 23 | static localPlacement( |
| 24 | location = new THREE.Vector3(0, 0, 0), |
| 25 | zDirection = new THREE.Vector3(0, 0, 1), |
| 26 | xDirection = new THREE.Vector3(1, 0, 0), |
| 27 | ) { |
| 28 | return new IFC.IfcLocalPlacement( |
| 29 | null, |
| 30 | new IFC.IfcAxis2Placement3D( |
| 31 | IfcUtils.point(location), |
| 32 | IfcUtils.direction(zDirection), |
| 33 | IfcUtils.direction(xDirection), |
| 34 | ), |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | static productDefinitionShape( |
| 39 | model: Model, |
| 40 | items: IFC.IfcRepresentationItem[], |
| 41 | ) { |
| 42 | const representation = this.shape(model, items); |
| 43 | return new IFC.IfcProductDefinitionShape(null, null, [representation]); |
| 44 | } |
| 45 | |
| 46 | static shape(model: Model, items: IFC.IfcRepresentationItem[]) { |
| 47 | return new IFC.IfcShapeRepresentation(model.context, null, null, items); |
| 48 | } |
| 49 | |
| 50 | static setAxis2Placement( |
| 51 | model: Model, |
| 52 | placement: IFC.IfcAxis2Placement3D | IFC.IfcAxis2Placement2D, |
| 53 | object: THREE.Object3D, |
| 54 | ) { |
| 55 | const location = model.get(placement.Location) as IFC.IfcCartesianPoint; |
| 56 | |
| 57 | const position = MathUtils.toIfcCoords(object.position); |
| 58 | const rotation = MathUtils.toIfcRot(object.rotation) as THREE.Euler; |
| 59 | |
| 60 | location.Coordinates[0].value = position.x; |
| 61 | location.Coordinates[1].value = position.y; |
| 62 | location.Coordinates[2].value = position.z; |
| 63 | model.set(location); |
nothing calls this directly
no outgoing calls
no test coverage detected