MCPcopy Create free account
hub / github.com/ThatOpen/engine_clay / IfcUtils

Class IfcUtils

packages/clay/src/utils/ifc-utils.ts:6–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import { MathUtils } from "./math-utils";
5
6export 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);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected