@margoengine/ifc 0.0.0-stage → 0.1.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.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/NOTICE.md +16 -0
- package/README.md +366 -3
- package/dist/bcf-wKfMzfyy.js +871 -0
- package/dist/bcf.d.ts +274 -0
- package/dist/bcf.js +1 -0
- package/dist/data-CuTaQPFm.js +534 -0
- package/dist/data.d.ts +205 -0
- package/dist/data.js +1 -0
- package/dist/ids.d.ts +199 -0
- package/dist/ids.js +759 -0
- package/dist/ifc-stream.worker.d.ts +1 -0
- package/dist/ifc.worker.d.ts +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +116 -0
- package/dist/meshes.d.ts +75 -0
- package/dist/open-D1NQyRTk.js +181 -0
- package/dist/open.d.ts +39 -0
- package/dist/predefined-enums.d.ts +2 -0
- package/dist/query.d.ts +62 -0
- package/dist/query.js +92 -0
- package/dist/raw.d.ts +7 -0
- package/dist/scene.d.ts +187 -0
- package/dist/scene.js +642 -0
- package/dist/schema-B_VBQpdF.js +51 -0
- package/dist/schema-tree.d.ts +2 -0
- package/dist/schema.d.ts +16 -0
- package/dist/section.d.ts +95 -0
- package/dist/section.js +380 -0
- package/dist/step.d.ts +1 -0
- package/dist/tolerance-CAOnp3Mo.js +7 -0
- package/dist/tolerance.d.ts +2 -0
- package/dist/units-B32iYdmV.js +134 -0
- package/dist/units.d.ts +33 -0
- package/dist/worker.d.ts +38 -0
- package/dist/worker.js +108 -0
- package/dist/workers/ifc-stream.js +1 -0
- package/dist/workers/ifc.js +1 -0
- package/dist/write.d.ts +113 -0
- package/dist/write.js +546 -0
- package/package.json +102 -6
package/dist/scene.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
3
|
+
import type { EngineKernel } from '@margoengine/core';
|
|
4
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
5
|
+
import { Material } from '@margoengine/materials';
|
|
6
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
7
|
+
import type { MaterialMesh } from '@margoengine/materials';
|
|
8
|
+
import type { BCFView, BCFViewInput } from './bcf.js';
|
|
9
|
+
import type { IFCData } from './data.js';
|
|
10
|
+
import type { IFCMeshes, IFCMeshGeometry } from './meshes.js';
|
|
11
|
+
export { readIFCMeshes, streamIFCMeshes, type IFCMeshChunk, type IFCMeshGeometry, type IFCMeshes, type IFCMeshOptions, type IFCPlacement, type IFCStreamOptions, } from './meshes.js';
|
|
12
|
+
/** Options of createIFCScene. Colours are sRGB components 0..1. */
|
|
13
|
+
export interface IFCSceneOptions {
|
|
14
|
+
/** A geometry placed this many times or more (opaque placements) draws as one instanced mesh. 0 batches all. Default 2. */
|
|
15
|
+
instancing?: number;
|
|
16
|
+
/** Vertices per batch, 3 to 1,000,000; a larger geometry draws as its own mesh. Default 1,000,000. */
|
|
17
|
+
batchVertices?: number;
|
|
18
|
+
/** Draw both faces of every triangle (IFC tessellations often mix windings). Default true. */
|
|
19
|
+
doubleSided?: boolean;
|
|
20
|
+
/** Colour of ghosted elements. Default [0.62, 0.72, 0.86]. */
|
|
21
|
+
ghostColor?: readonly number[];
|
|
22
|
+
/** Opacity of ghosted elements, 0 to 1. Default 0.15. */
|
|
23
|
+
ghostOpacity?: number;
|
|
24
|
+
/** Colour of selected elements. Default [0.1, 0.55, 1]. */
|
|
25
|
+
selectionColor?: readonly number[];
|
|
26
|
+
/** The model's readIFCData result: storeyPlan needs its storeys. */
|
|
27
|
+
data?: IFCData;
|
|
28
|
+
}
|
|
29
|
+
/** One element's display state. */
|
|
30
|
+
export interface IFCElementState {
|
|
31
|
+
hidden: boolean;
|
|
32
|
+
ghosted: boolean;
|
|
33
|
+
selected: boolean;
|
|
34
|
+
/** Override colour (sRGB), or undefined for the file's colours. */
|
|
35
|
+
color?: [number, number, number];
|
|
36
|
+
/** Override opacity below 1, or undefined. */
|
|
37
|
+
opacity?: number;
|
|
38
|
+
}
|
|
39
|
+
/** What storeyPlan returns: the cut and a top-down orthographic camera over the storey. */
|
|
40
|
+
export interface IFCStoreyPlan {
|
|
41
|
+
/** The storey's elevation and the cut height above it, engine Y in meters. */
|
|
42
|
+
elevation: number;
|
|
43
|
+
cut: number;
|
|
44
|
+
clippingPlanes: number[][];
|
|
45
|
+
camera: {
|
|
46
|
+
type: 'orthogonal';
|
|
47
|
+
position: [number, number, number];
|
|
48
|
+
target: [number, number, number];
|
|
49
|
+
up: [number, number, number];
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* An IFC model drawn through @margoengine/materials: instanced meshes for repeated geometry, BatchedMesh draws for the
|
|
55
|
+
* rest, and per-element visibility, ghosting, colour, opacity, selection, picking and clipping. Create it with
|
|
56
|
+
* createIFCScene; dispose it to free every mesh, batch and material.
|
|
57
|
+
*/
|
|
58
|
+
export declare class IFCScene {
|
|
59
|
+
private readonly engine;
|
|
60
|
+
/** The opaque, translucent and ghost materials: set their shared options here (clipping goes through clippingPlanes). */
|
|
61
|
+
readonly materials: {
|
|
62
|
+
opaque: Material;
|
|
63
|
+
translucent: Material;
|
|
64
|
+
};
|
|
65
|
+
/** The model's origin (readIFCMeshes' `origin`). */
|
|
66
|
+
readonly origin: [number, number, number];
|
|
67
|
+
private readonly slots;
|
|
68
|
+
private readonly order;
|
|
69
|
+
private readonly opaque;
|
|
70
|
+
private readonly translucent;
|
|
71
|
+
private readonly groups;
|
|
72
|
+
/** Every geometry added so far by key, so a later chunk can place one an earlier chunk sent. */
|
|
73
|
+
private readonly known;
|
|
74
|
+
/** Per geometry key; a different geometry under a known key (another model) starts afresh. */
|
|
75
|
+
private readonly uses;
|
|
76
|
+
private readonly instancing;
|
|
77
|
+
private readonly ghost;
|
|
78
|
+
private readonly ghostOpacity;
|
|
79
|
+
private readonly selection;
|
|
80
|
+
private readonly data?;
|
|
81
|
+
private planes;
|
|
82
|
+
private disposed;
|
|
83
|
+
/** @internal Use createIFCScene. */
|
|
84
|
+
constructor(engine: EngineKernel, origin: readonly number[], options?: IFCSceneOptions);
|
|
85
|
+
/** Draws readIFCMeshes' output on `engine`: the same as createIFCScene. Dispose the scene to free it. */
|
|
86
|
+
static attach(engine: EngineKernel, meshes: IFCMeshes, options?: IFCSceneOptions): IFCScene;
|
|
87
|
+
/** Every element with geometry, by expressID, in the order they were added. */
|
|
88
|
+
get elements(): number[];
|
|
89
|
+
/** The meshes the scene draws (for shadows.add, clustered.add, ssao.add or picking filters). */
|
|
90
|
+
get meshes(): readonly MaterialMesh[];
|
|
91
|
+
/**
|
|
92
|
+
* Adds readIFCMeshes' output or a streamIFCMeshes chunk. Placements join the scene's existing instance groups and
|
|
93
|
+
* batches: a geometry placed `instancing` times over all adds draws instanced (its earlier batched parts move into
|
|
94
|
+
* the group), and batches grow before new ones open, so a streamed model ends with the draws of a whole load. A
|
|
95
|
+
* chunk may name geometries an earlier add sent. Growing replaces meshes: read `meshes` again after the last add.
|
|
96
|
+
*/
|
|
97
|
+
add(meshes: Pick<IFCMeshes, 'geometries' | 'placements'>): this;
|
|
98
|
+
/** The state of an element, or undefined when it has no geometry here. */
|
|
99
|
+
stateOf(id: number): IFCElementState | undefined;
|
|
100
|
+
/** Shows or hides elements. IDs without geometry are skipped. */
|
|
101
|
+
setVisible(ids: Iterable<number>, visible: boolean): this;
|
|
102
|
+
hide(ids: Iterable<number>): this;
|
|
103
|
+
show(ids: Iterable<number>): this;
|
|
104
|
+
/** Shows only `ids`: every other element is hidden, or with `{ghost: true}` ghosted, as an x-ray isolate. */
|
|
105
|
+
isolate(ids: Iterable<number>, options?: {
|
|
106
|
+
ghost?: boolean;
|
|
107
|
+
}): this;
|
|
108
|
+
/** Shows every element and clears ghosting (colours, opacity and selection stay). */
|
|
109
|
+
showAll(): this;
|
|
110
|
+
/** Draws elements as translucent ghosts (or back as themselves). */
|
|
111
|
+
setGhosted(ids: Iterable<number>, ghosted: boolean): this;
|
|
112
|
+
/** Overrides elements' colour (sRGB components 0..1), or with null restores the file's colours. */
|
|
113
|
+
setColor(ids: Iterable<number>, color: readonly number[] | null): this;
|
|
114
|
+
/** Overrides elements' opacity (0 to 1; 1 or null restores the file's). */
|
|
115
|
+
setOpacity(ids: Iterable<number>, opacity: number | null): this;
|
|
116
|
+
/** Selects exactly `ids`, drawn in the selection colour. */
|
|
117
|
+
select(ids: Iterable<number>): this;
|
|
118
|
+
/** The selected elements, in the order they were added. */
|
|
119
|
+
get selected(): number[];
|
|
120
|
+
/** The hidden elements, in the order they were added. */
|
|
121
|
+
get hidden(): number[];
|
|
122
|
+
/**
|
|
123
|
+
* The element a pick hit: an instanced mesh by its `instanceId`, a batch by the element slot in UV0 (pick with
|
|
124
|
+
* `@margoengine/selection/hit-details`, whose hits carry `uv`). Undefined for a hit on anything else.
|
|
125
|
+
*/
|
|
126
|
+
elementAt(hit: {
|
|
127
|
+
model?: unknown;
|
|
128
|
+
mesh?: unknown;
|
|
129
|
+
instanceId?: number;
|
|
130
|
+
uv?: readonly number[];
|
|
131
|
+
} | null | undefined): number | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Section planes `[a, b, c, d]` (what has `a x + b y + c z + d < 0` is cut away), at most 16, on every material.
|
|
134
|
+
* `@margoengine/ifc/section` adds caps and cut edges.
|
|
135
|
+
*/
|
|
136
|
+
get clippingPlanes(): number[][];
|
|
137
|
+
set clippingPlanes(planes: readonly (readonly number[])[]);
|
|
138
|
+
/** Cuts away everything outside the box from `min` to `max` (engine axes, meters) and returns its six planes. */
|
|
139
|
+
sectionBox(min: readonly number[], max: readonly number[]): number[][];
|
|
140
|
+
/**
|
|
141
|
+
* The placed geometries of element `id` (none for an unknown id): its triangles, its placement in the scene's
|
|
142
|
+
* coordinates (rebased by `origin`) and its file colour (linear RGB and alpha). Read-only views of the scene's data.
|
|
143
|
+
*/
|
|
144
|
+
placementsOf(id: number): readonly {
|
|
145
|
+
geometry: IFCMeshGeometry;
|
|
146
|
+
matrix: Float32Array;
|
|
147
|
+
color: readonly [number, number, number, number];
|
|
148
|
+
}[];
|
|
149
|
+
/** The world box [minX, minY, minZ, maxX, maxY, maxZ] of `ids` (default every shown element); empty is all Infinity. */
|
|
150
|
+
bounds(ids?: Iterable<number>): Float64Array;
|
|
151
|
+
/**
|
|
152
|
+
* A storey plan: shows only the storey's elements, cuts everything `cutHeight` meters (default 1.2) above the
|
|
153
|
+
* storey's elevation (IfcBuildingStorey.Elevation in SI, rebased by `origin`, or `elevation`) and returns a
|
|
154
|
+
* top-down orthographic camera over it. Needs the `data` option.
|
|
155
|
+
*/
|
|
156
|
+
storeyPlan(storey: number, options?: {
|
|
157
|
+
cutHeight?: number;
|
|
158
|
+
elevation?: number;
|
|
159
|
+
}): IFCStoreyPlan;
|
|
160
|
+
/**
|
|
161
|
+
* Applies a viewFromBCF result: visibility, colours (alpha below 1 as opacity), selection and section planes, each
|
|
162
|
+
* replacing the scene's. Returns the view's camera for the app to set (undefined when the viewpoint has none).
|
|
163
|
+
*/
|
|
164
|
+
applyBCFView(view: BCFView): BCFView['camera'];
|
|
165
|
+
/** The scene's state for bcfFromView: hidden, selected, colours (with opacity as alpha) and section planes. */
|
|
166
|
+
bcfView(): Required<Pick<BCFViewInput, 'hidden' | 'selected' | 'colors' | 'clippingPlanes'>>;
|
|
167
|
+
dispose(): void;
|
|
168
|
+
[Symbol.dispose](): void;
|
|
169
|
+
private live;
|
|
170
|
+
/** Places `part` as the next instance of `group`. */
|
|
171
|
+
private instance;
|
|
172
|
+
/** Rebuilds a full group's mesh with room for `count` instances (at least twice as many), its rows kept. */
|
|
173
|
+
private reserve;
|
|
174
|
+
private slot;
|
|
175
|
+
private fileColor;
|
|
176
|
+
/** A batch copy of `g`: white vertex colours with `alpha`, and the element's slot in UV0 for picking. */
|
|
177
|
+
private copy;
|
|
178
|
+
private each;
|
|
179
|
+
/** Draws one part as the element's state says: shown, tinted, or hidden behind a translucent overlay. */
|
|
180
|
+
private draw;
|
|
181
|
+
private overlay;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Draws readIFCMeshes' output with @margoengine/materials: instanced meshes for geometry placed `instancing` times or
|
|
185
|
+
* more, BatchedMesh draws for the rest, ready for per-element visibility, ghosting, colour, picking and clipping.
|
|
186
|
+
*/
|
|
187
|
+
export declare function createIFCScene(engine: EngineKernel, meshes: IFCMeshes, options?: IFCSceneOptions): IFCScene;
|