@ifc-lite/geometry 7.1.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Render frame <-> IFC world coordinates: the one implementation (#4879).
3
+ *
4
+ * Meshes out of this package are NOT in the file's own coordinates. The wasm
5
+ * mesh pass subtracts an RTC offset (`CoordinateInfo.wasmRtcOffset`, IFC
6
+ * Z-up) and `CoordinateHandler` may subtract a further origin shift
7
+ * (`CoordinateInfo.originShift`, already in the Y-up mesh axes), both to keep
8
+ * f32 precision usable for georeferenced models. Everything read off those
9
+ * meshes (renderer camera, section plane, entity and clash bounds) is in that
10
+ * shifted, Y-up "render frame". Anything written for another tool (BCF
11
+ * viewpoints above all) has to be in IFC world coordinates, Z-up.
12
+ *
13
+ * The viewer, the CLI, the MCP playground and the SDK all need the same
14
+ * answer, so the axis swap and the offset sum live here, next to the
15
+ * `CoordinateInfo` they read, rather than once per consumer.
16
+ * `scripts/check-rtc-frame-copies.mjs` keeps it that way.
17
+ */
18
+ import type { CoordinateInfo, Vec3 } from './coordinate-types.js';
19
+ /** The two recorded offsets; either may be absent (a model near the origin). */
20
+ export type RenderFrameInfo = {
21
+ originShift?: Readonly<Vec3> | null;
22
+ wasmRtcOffset?: Readonly<Vec3> | null;
23
+ };
24
+ /**
25
+ * Convert an IFC Z-up coordinate to the render frame's Y-up axes. `0 - value`
26
+ * deliberately normalises either sign of zero only on the negated axis.
27
+ */
28
+ export declare function ifcToViewerAxes(point: Readonly<Vec3>): Vec3;
29
+ /** Convert render-frame Y-up to IFC Z-up with the same negated-axis zero rule. */
30
+ export declare function viewerToIfcAxes(point: Readonly<Vec3>): Vec3;
31
+ /**
32
+ * Total translation from the render frame to world coordinates, in Y-up
33
+ * axes. `originShift` is already Y-up; `wasmRtcOffset` is IFC Z-up.
34
+ */
35
+ export declare function totalYupOffset(info?: RenderFrameInfo | null): Vec3;
36
+ /**
37
+ * Render frame -> IFC world translation, in IFC Z-up metres: the axes BCF
38
+ * positions (and the IFC file) use. Add it to a render-frame point that has
39
+ * already been converted to Z-up. Exactly zero, with no `-0`, for a model
40
+ * that was not shifted.
41
+ */
42
+ export declare function renderFrameWorldOffset(info?: RenderFrameInfo | null): Vec3;
43
+ /** A loaded model as far as the federation frame rule is concerned. */
44
+ export interface FrameCandidate {
45
+ /** Load order; the earliest-loaded model owns the shared frame. */
46
+ loadedAt: number;
47
+ geometryResult?: {
48
+ coordinateInfo?: CoordinateInfo | null;
49
+ } | null;
50
+ }
51
+ /**
52
+ * The `CoordinateInfo` whose frame a set of loaded models is drawn in.
53
+ *
54
+ * A federation is aligned to the earliest-loaded model's RTC frame at load,
55
+ * so that model's offsets ARE the scene's offsets; reading a later model's
56
+ * would describe a frame nothing is drawn in. `fallback` covers a single
57
+ * model loaded without a federation entry. Null when nothing has geometry.
58
+ */
59
+ export declare function federationFrameInfo(models: Iterable<FrameCandidate>, fallback?: {
60
+ coordinateInfo?: CoordinateInfo | null;
61
+ } | null): CoordinateInfo | null;
62
+ //# sourceMappingURL=world-frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world-frame.d.ts","sourceRoot":"","sources":["../src/world-frame.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAIlE,gFAAgF;AAChF,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACpC,aAAa,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAE3D;AAED,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAE3D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAQlE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAG1E;AAED,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CACpE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,EAChC,QAAQ,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAC3D,cAAc,GAAG,IAAI,CAWvB"}
@@ -0,0 +1,59 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ const ZERO = { x: 0, y: 0, z: 0 };
5
+ /**
6
+ * Convert an IFC Z-up coordinate to the render frame's Y-up axes. `0 - value`
7
+ * deliberately normalises either sign of zero only on the negated axis.
8
+ */
9
+ export function ifcToViewerAxes(point) {
10
+ return { x: point.x, y: point.z, z: 0 - point.y };
11
+ }
12
+ /** Convert render-frame Y-up to IFC Z-up with the same negated-axis zero rule. */
13
+ export function viewerToIfcAxes(point) {
14
+ return { x: point.x, y: 0 - point.z, z: point.y };
15
+ }
16
+ /**
17
+ * Total translation from the render frame to world coordinates, in Y-up
18
+ * axes. `originShift` is already Y-up; `wasmRtcOffset` is IFC Z-up.
19
+ */
20
+ export function totalYupOffset(info) {
21
+ const shift = info?.originShift ?? ZERO;
22
+ const rtcYup = ifcToViewerAxes(info?.wasmRtcOffset ?? ZERO);
23
+ return {
24
+ x: shift.x + rtcYup.x,
25
+ y: shift.y + rtcYup.y,
26
+ z: shift.z + rtcYup.z,
27
+ };
28
+ }
29
+ /**
30
+ * Render frame -> IFC world translation, in IFC Z-up metres: the axes BCF
31
+ * positions (and the IFC file) use. Add it to a render-frame point that has
32
+ * already been converted to Z-up. Exactly zero, with no `-0`, for a model
33
+ * that was not shifted.
34
+ */
35
+ export function renderFrameWorldOffset(info) {
36
+ const offset = viewerToIfcAxes(totalYupOffset(info));
37
+ return { x: offset.x + 0, y: offset.y + 0, z: offset.z + 0 };
38
+ }
39
+ /**
40
+ * The `CoordinateInfo` whose frame a set of loaded models is drawn in.
41
+ *
42
+ * A federation is aligned to the earliest-loaded model's RTC frame at load,
43
+ * so that model's offsets ARE the scene's offsets; reading a later model's
44
+ * would describe a frame nothing is drawn in. `fallback` covers a single
45
+ * model loaded without a federation entry. Null when nothing has geometry.
46
+ */
47
+ export function federationFrameInfo(models, fallback) {
48
+ let earliest = Infinity;
49
+ let info = null;
50
+ for (const model of models) {
51
+ const candidate = model.geometryResult?.coordinateInfo;
52
+ if (candidate && model.loadedAt < earliest) {
53
+ earliest = model.loadedAt;
54
+ info = candidate;
55
+ }
56
+ }
57
+ return info ?? fallback?.coordinateInfo ?? null;
58
+ }
59
+ //# sourceMappingURL=world-frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world-frame.js","sourceRoot":"","sources":["../src/world-frame.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAsB/D,MAAM,IAAI,GAAS,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAQxC;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAqB;IACnD,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC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IAAI,SAAS,IAAI,KAAK,CAAC,QAAQ,GAAG,QAAQ,EAAE,CAAC;YAC3C,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YAC1B,IAAI,GAAG,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,IAAI,QAAQ,EAAE,cAAc,IAAI,IAAI,CAAC;AAClD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifc-lite/geometry",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "Geometry processing bridge for IFC-Lite - exact-arithmetic CSG, streamed across workers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,12 +15,17 @@
15
15
  "types": "./dist/geometry-class.d.ts",
16
16
  "import": "./dist/geometry-class.js",
17
17
  "default": "./dist/geometry-class.js"
18
+ },
19
+ "./world-frame": {
20
+ "types": "./dist/world-frame.d.ts",
21
+ "import": "./dist/world-frame.js",
22
+ "default": "./dist/world-frame.js"
18
23
  }
19
24
  },
20
25
  "dependencies": {
21
26
  "@ifc-lite/data": "^4.4.0",
22
- "@ifc-lite/wasm-lifecycle": "^0.2.0",
23
- "@ifc-lite/wasm": "^9.1.0"
27
+ "@ifc-lite/wasm": "^9.1.0",
28
+ "@ifc-lite/wasm-lifecycle": "^0.2.0"
24
29
  },
25
30
  "optionalDependencies": {
26
31
  "@tauri-apps/api": "^2.11.1"