@ifc-lite/parser 2.4.2 → 3.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/README.md +5 -3
- package/dist/columnar-parser-indexes.d.ts +1 -7
- package/dist/columnar-parser-indexes.d.ts.map +1 -1
- package/dist/columnar-parser-indexes.js.map +1 -1
- package/dist/columnar-parser.d.ts +39 -12
- package/dist/columnar-parser.d.ts.map +1 -1
- package/dist/columnar-parser.js +113 -26
- package/dist/columnar-parser.js.map +1 -1
- package/dist/data-store-accessors.d.ts +24 -0
- package/dist/data-store-accessors.d.ts.map +1 -0
- package/dist/data-store-accessors.js +43 -0
- package/dist/data-store-accessors.js.map +1 -0
- package/dist/data-store-transport.d.ts +1 -0
- package/dist/data-store-transport.d.ts.map +1 -1
- package/dist/data-store-transport.js +16 -9
- package/dist/data-store-transport.js.map +1 -1
- package/dist/entity-extractor.d.ts.map +1 -1
- package/dist/entity-extractor.js +20 -1
- package/dist/entity-extractor.js.map +1 -1
- package/dist/entity-index.d.ts +3 -0
- package/dist/entity-index.d.ts.map +1 -1
- package/dist/entity-index.js.map +1 -1
- package/dist/entity-scanner.d.ts +30 -0
- package/dist/entity-scanner.d.ts.map +1 -0
- package/dist/entity-scanner.js +132 -0
- package/dist/entity-scanner.js.map +1 -0
- package/dist/entity-source.d.ts +17 -0
- package/dist/entity-source.d.ts.map +1 -0
- package/dist/entity-source.js +29 -0
- package/dist/entity-source.js.map +1 -0
- package/dist/ifc-schema.d.ts +10 -2
- package/dist/ifc-schema.d.ts.map +1 -1
- package/dist/ifc-schema.js +65 -2
- package/dist/ifc-schema.js.map +1 -1
- package/dist/index.d.ts +15 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -289
- package/dist/index.js.map +1 -1
- package/dist/material-resolver.d.ts +54 -0
- package/dist/material-resolver.d.ts.map +1 -1
- package/dist/material-resolver.js +265 -0
- package/dist/material-resolver.js.map +1 -1
- package/dist/on-demand-extractors.d.ts +34 -0
- package/dist/on-demand-extractors.d.ts.map +1 -1
- package/dist/on-demand-extractors.js +153 -0
- package/dist/on-demand-extractors.js.map +1 -1
- package/dist/parser.worker.d.ts.map +1 -1
- package/dist/parser.worker.js.map +1 -1
- package/dist/property-extractor.d.ts +3 -0
- package/dist/property-extractor.d.ts.map +1 -1
- package/dist/property-extractor.js.map +1 -1
- package/dist/quantity-extractor.d.ts +3 -0
- package/dist/quantity-extractor.d.ts.map +1 -1
- package/dist/quantity-extractor.js.map +1 -1
- package/dist/relationship-extractor.d.ts +3 -0
- package/dist/relationship-extractor.d.ts.map +1 -1
- package/dist/relationship-extractor.js.map +1 -1
- package/dist/spatial-hierarchy-builder.d.ts.map +1 -1
- package/dist/spatial-hierarchy-builder.js +26 -4
- package/dist/spatial-hierarchy-builder.js.map +1 -1
- package/dist/tokenizer.d.ts.map +1 -1
- package/dist/tokenizer.js +21 -4
- package/dist/tokenizer.js.map +1 -1
- package/dist/types.d.ts +2 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/opfs-source-buffer.d.ts +0 -70
- package/dist/opfs-source-buffer.d.ts.map +0 -1
- package/dist/opfs-source-buffer.js +0 -166
- package/dist/opfs-source-buffer.js.map +0 -1
- package/dist/style-extractor.d.ts +0 -84
- package/dist/style-extractor.d.ts.map +0 -1
- package/dist/style-extractor.js +0 -345
- package/dist/style-extractor.js.map +0 -1
|
@@ -1,166 +0,0 @@
|
|
|
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
|
-
/**
|
|
5
|
-
* A source buffer that can be backed by either in-memory Uint8Array or OPFS.
|
|
6
|
-
* Provides sync and async read interfaces.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* ```ts
|
|
10
|
-
* const source = await OpfsSourceBuffer.create(uint8Buffer);
|
|
11
|
-
* // On-demand entity extraction:
|
|
12
|
-
* const bytes = await source.readRange(byteOffset, byteLength);
|
|
13
|
-
* // Or use the sync subarray for backwards compatibility:
|
|
14
|
-
* const view = source.subarray(byteOffset, byteOffset + byteLength);
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export class OpfsSourceBuffer {
|
|
18
|
-
/** In-memory buffer (null when offloaded to OPFS) */
|
|
19
|
-
memoryBuffer;
|
|
20
|
-
/** OPFS sync access handle for range reads (null when in-memory) */
|
|
21
|
-
fileHandle = null;
|
|
22
|
-
/** Async file handle wrapper */
|
|
23
|
-
asyncFileHandle = null;
|
|
24
|
-
/** Total file size in bytes */
|
|
25
|
-
byteLength;
|
|
26
|
-
/** Whether the source is backed by OPFS */
|
|
27
|
-
isOpfsBacked;
|
|
28
|
-
/** OPFS file name (for cleanup) */
|
|
29
|
-
opfsFileName = null;
|
|
30
|
-
constructor(memoryBuffer, byteLength, isOpfsBacked) {
|
|
31
|
-
this.memoryBuffer = memoryBuffer;
|
|
32
|
-
this.byteLength = byteLength;
|
|
33
|
-
this.isOpfsBacked = isOpfsBacked;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Create an OpfsSourceBuffer, offloading to OPFS when available.
|
|
37
|
-
*
|
|
38
|
-
* @param buffer - The source IFC file bytes
|
|
39
|
-
* @param forceMemory - If true, skip OPFS and keep in memory
|
|
40
|
-
* @returns A new OpfsSourceBuffer instance
|
|
41
|
-
*/
|
|
42
|
-
static async create(buffer, forceMemory = false) {
|
|
43
|
-
if (forceMemory || !OpfsSourceBuffer.isOpfsAvailable()) {
|
|
44
|
-
return new OpfsSourceBuffer(buffer, buffer.byteLength, false);
|
|
45
|
-
}
|
|
46
|
-
let fileName = null;
|
|
47
|
-
let syncHandle = null;
|
|
48
|
-
try {
|
|
49
|
-
fileName = `ifc-source-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
50
|
-
const root = await navigator.storage.getDirectory();
|
|
51
|
-
const fileHandle = await root.getFileHandle(fileName, { create: true });
|
|
52
|
-
// Write buffer to OPFS using sync access handle (fastest path)
|
|
53
|
-
syncHandle = await fileHandle.createSyncAccessHandle();
|
|
54
|
-
const bytesWritten = syncHandle.write(buffer, { at: 0 });
|
|
55
|
-
if (bytesWritten !== buffer.byteLength) {
|
|
56
|
-
syncHandle.close();
|
|
57
|
-
const root = await navigator.storage.getDirectory();
|
|
58
|
-
await root.removeEntry(fileName);
|
|
59
|
-
throw new Error(`OPFS short write: wrote ${bytesWritten}/${buffer.byteLength} bytes`);
|
|
60
|
-
}
|
|
61
|
-
syncHandle.flush();
|
|
62
|
-
const instance = new OpfsSourceBuffer(null, buffer.byteLength, true);
|
|
63
|
-
instance.fileHandle = syncHandle;
|
|
64
|
-
instance.asyncFileHandle = fileHandle;
|
|
65
|
-
instance.opfsFileName = fileName;
|
|
66
|
-
return instance;
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
// OPFS failed — clean up partial resources and fall back to in-memory
|
|
70
|
-
if (syncHandle) {
|
|
71
|
-
try {
|
|
72
|
-
syncHandle.close();
|
|
73
|
-
}
|
|
74
|
-
catch { /* ignore */ }
|
|
75
|
-
}
|
|
76
|
-
if (fileName) {
|
|
77
|
-
try {
|
|
78
|
-
const root = await navigator.storage.getDirectory();
|
|
79
|
-
await root.removeEntry(fileName);
|
|
80
|
-
}
|
|
81
|
-
catch { /* ignore */ }
|
|
82
|
-
}
|
|
83
|
-
return new OpfsSourceBuffer(buffer, buffer.byteLength, false);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Check if OPFS is available in the current context.
|
|
88
|
-
*/
|
|
89
|
-
static isOpfsAvailable() {
|
|
90
|
-
return (typeof globalThis !== 'undefined' &&
|
|
91
|
-
typeof globalThis.navigator?.storage?.getDirectory === 'function');
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Read a byte range from the source buffer.
|
|
95
|
-
* Works for both in-memory and OPFS-backed buffers.
|
|
96
|
-
*/
|
|
97
|
-
readRange(byteOffset, byteLength) {
|
|
98
|
-
if (byteOffset < 0 || byteLength < 0 || byteOffset + byteLength > this.byteLength) {
|
|
99
|
-
throw new RangeError(`OpfsSourceBuffer.readRange: offset=${byteOffset} length=${byteLength} exceeds buffer size=${this.byteLength}`);
|
|
100
|
-
}
|
|
101
|
-
if (this.memoryBuffer) {
|
|
102
|
-
// In-memory: zero-copy subarray view
|
|
103
|
-
return this.memoryBuffer.subarray(byteOffset, byteOffset + byteLength);
|
|
104
|
-
}
|
|
105
|
-
if (this.fileHandle) {
|
|
106
|
-
// OPFS sync access: read into a new buffer
|
|
107
|
-
const dest = new Uint8Array(byteLength);
|
|
108
|
-
const bytesRead = this.fileHandle.read(dest, { at: byteOffset });
|
|
109
|
-
if (bytesRead < byteLength) {
|
|
110
|
-
throw new Error(`OpfsSourceBuffer.readRange: short read (${bytesRead}/${byteLength} bytes at offset ${byteOffset})`);
|
|
111
|
-
}
|
|
112
|
-
return dest;
|
|
113
|
-
}
|
|
114
|
-
throw new Error('OpfsSourceBuffer: no backing store available');
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Synchronous subarray — for backward compatibility with code that
|
|
118
|
-
* expects `source.subarray(start, end)`.
|
|
119
|
-
*
|
|
120
|
-
* When OPFS-backed, this allocates a new Uint8Array and reads from disk.
|
|
121
|
-
* When in-memory, this returns a zero-copy view.
|
|
122
|
-
*/
|
|
123
|
-
subarray(start, end) {
|
|
124
|
-
return this.readRange(start, end - start);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Get the full in-memory buffer (only available when not OPFS-backed).
|
|
128
|
-
* Used as a migration aid — callers should prefer readRange().
|
|
129
|
-
*
|
|
130
|
-
* @throws Error if the buffer has been offloaded to OPFS
|
|
131
|
-
*/
|
|
132
|
-
getMemoryBuffer() {
|
|
133
|
-
if (this.memoryBuffer)
|
|
134
|
-
return this.memoryBuffer;
|
|
135
|
-
throw new Error('OpfsSourceBuffer: source has been offloaded to OPFS. Use readRange() instead.');
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Check if the in-memory buffer is still available.
|
|
139
|
-
*/
|
|
140
|
-
hasMemoryBuffer() {
|
|
141
|
-
return this.memoryBuffer !== null;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Release OPFS resources and clean up the temporary file.
|
|
145
|
-
* Call this when the model is unloaded.
|
|
146
|
-
*/
|
|
147
|
-
async dispose() {
|
|
148
|
-
if (this.fileHandle) {
|
|
149
|
-
this.fileHandle.close();
|
|
150
|
-
this.fileHandle = null;
|
|
151
|
-
}
|
|
152
|
-
if (this.opfsFileName) {
|
|
153
|
-
try {
|
|
154
|
-
const root = await navigator.storage.getDirectory();
|
|
155
|
-
await root.removeEntry(this.opfsFileName);
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// Ignore cleanup errors
|
|
159
|
-
}
|
|
160
|
-
this.opfsFileName = null;
|
|
161
|
-
}
|
|
162
|
-
this.asyncFileHandle = null;
|
|
163
|
-
this.memoryBuffer = null;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
//# sourceMappingURL=opfs-source-buffer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"opfs-source-buffer.js","sourceRoot":"","sources":["../src/opfs-source-buffer.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AA0B/D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,gBAAgB;IAC3B,qDAAqD;IAC7C,YAAY,CAAoB;IACxC,oEAAoE;IAC5D,UAAU,GAAgC,IAAI,CAAC;IACvD,gCAAgC;IACxB,eAAe,GAA0B,IAAI,CAAC;IACtD,+BAA+B;IACtB,UAAU,CAAS;IAC5B,2CAA2C;IAClC,YAAY,CAAU;IAC/B,mCAAmC;IAC3B,YAAY,GAAkB,IAAI,CAAC;IAE3C,YACE,YAA+B,EAC/B,UAAkB,EAClB,YAAq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AAE,CAAC;YACpB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;gBACpD,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC5C,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;YACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Style extractor - extracts IfcSurfaceStyle and related appearance entities
|
|
3
|
-
*/
|
|
4
|
-
import type { IfcEntity, EntityIndex } from './types.js';
|
|
5
|
-
export interface IFCMaterial {
|
|
6
|
-
baseColor: [number, number, number, number];
|
|
7
|
-
metallic: number;
|
|
8
|
-
roughness: number;
|
|
9
|
-
transparency: number;
|
|
10
|
-
reflectanceMethod?: 'BLINN' | 'PHONG' | 'METAL' | 'GLASS' | 'MATT' | 'PLASTIC' | 'STRAUSS' | 'MIRROR';
|
|
11
|
-
specularColor?: [number, number, number];
|
|
12
|
-
specularHighlight?: number;
|
|
13
|
-
doubleSided: boolean;
|
|
14
|
-
alphaMode: 'opaque' | 'mask' | 'blend';
|
|
15
|
-
}
|
|
16
|
-
export interface StyleMapping {
|
|
17
|
-
geometryExpressId: number;
|
|
18
|
-
material: IFCMaterial;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Extract IFC surface styles and create material mappings
|
|
22
|
-
*/
|
|
23
|
-
export declare class StyleExtractor {
|
|
24
|
-
private entities;
|
|
25
|
-
constructor(entities: Map<number, IfcEntity>, _entityIndex: EntityIndex);
|
|
26
|
-
/**
|
|
27
|
-
* Extract all style mappings from IFC entities
|
|
28
|
-
*/
|
|
29
|
-
extractStyles(): Map<number, IFCMaterial>;
|
|
30
|
-
/**
|
|
31
|
-
* Extract material from IfcStyledItem
|
|
32
|
-
*/
|
|
33
|
-
private extractMaterialFromStyledItem;
|
|
34
|
-
/**
|
|
35
|
-
* Extract material from IfcPresentationStyleAssignment
|
|
36
|
-
*/
|
|
37
|
-
private extractMaterialFromStyleAssignment;
|
|
38
|
-
/**
|
|
39
|
-
* Extract material from IfcSurfaceStyle
|
|
40
|
-
*/
|
|
41
|
-
private extractMaterialFromSurfaceStyle;
|
|
42
|
-
/**
|
|
43
|
-
* Extract material from IfcSurfaceStyleRendering
|
|
44
|
-
*/
|
|
45
|
-
private extractMaterialFromRendering;
|
|
46
|
-
/**
|
|
47
|
-
* Extract material from IfcSurfaceStyleShading (simpler fallback)
|
|
48
|
-
*/
|
|
49
|
-
private extractMaterialFromShading;
|
|
50
|
-
/**
|
|
51
|
-
* Extract RGB color from IfcColourRgb
|
|
52
|
-
*/
|
|
53
|
-
private extractColorRgb;
|
|
54
|
-
/**
|
|
55
|
-
* Extract transparency value
|
|
56
|
-
*/
|
|
57
|
-
private extractTransparency;
|
|
58
|
-
/**
|
|
59
|
-
* Extract specular highlight value
|
|
60
|
-
*/
|
|
61
|
-
private extractSpecularHighlight;
|
|
62
|
-
/**
|
|
63
|
-
* Extract reflectance method enum
|
|
64
|
-
*/
|
|
65
|
-
private extractReflectanceMethod;
|
|
66
|
-
/**
|
|
67
|
-
* Map IFC reflectance method to PBR metallic/roughness
|
|
68
|
-
*/
|
|
69
|
-
private mapReflectanceToPBR;
|
|
70
|
-
/**
|
|
71
|
-
* Find entities by type name (case-insensitive)
|
|
72
|
-
*/
|
|
73
|
-
private findEntitiesByType;
|
|
74
|
-
/**
|
|
75
|
-
* Get attribute value from entity
|
|
76
|
-
*/
|
|
77
|
-
private getAttributeValue;
|
|
78
|
-
/**
|
|
79
|
-
* Get numeric value from entity attribute
|
|
80
|
-
* Also handles TypedValue wrappers like [typeName, numericValue]
|
|
81
|
-
*/
|
|
82
|
-
private getNumericValue;
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=style-extractor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style-extractor.d.ts","sourceRoot":"","sources":["../src/style-extractor.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,WAAW,WAAW;IAExB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAG5C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAGrB,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACtG,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAG3B,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;CAC1C;AAED,MAAM,WAAW,YAAY;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAyB;gBAE7B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,YAAY,EAAE,WAAW;IAMvE;;OAEG;IACH,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAyBzC;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAyBrC;;OAEG;IACH,OAAO,CAAC,kCAAkC;IAsB1C;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAgCvC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAwCpC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAqBlC;;OAEG;IACH,OAAO,CAAC,eAAe;IAuBvB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgB3B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAahC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAyD3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;;OAGG;IACH,OAAO,CAAC,eAAe;CA4B1B"}
|
package/dist/style-extractor.js
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
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
|
-
/**
|
|
5
|
-
* Extract IFC surface styles and create material mappings
|
|
6
|
-
*/
|
|
7
|
-
export class StyleExtractor {
|
|
8
|
-
entities;
|
|
9
|
-
constructor(entities, _entityIndex) {
|
|
10
|
-
this.entities = entities;
|
|
11
|
-
// entityIndex reserved for future type-specific style lookups
|
|
12
|
-
void _entityIndex;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Extract all style mappings from IFC entities
|
|
16
|
-
*/
|
|
17
|
-
extractStyles() {
|
|
18
|
-
const styleMap = new Map();
|
|
19
|
-
// Find all IfcStyledItem entities
|
|
20
|
-
const styledItems = this.findEntitiesByType('IFCSTYLEDITEM');
|
|
21
|
-
for (const styledItem of styledItems) {
|
|
22
|
-
try {
|
|
23
|
-
const material = this.extractMaterialFromStyledItem(styledItem);
|
|
24
|
-
if (material) {
|
|
25
|
-
// IfcStyledItem.Item references the geometry
|
|
26
|
-
const itemRef = this.getAttributeValue(styledItem, 0);
|
|
27
|
-
if (typeof itemRef === 'number') {
|
|
28
|
-
styleMap.set(itemRef, material);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
// Skip invalid styled items
|
|
34
|
-
console.warn(`[StyleExtractor] Failed to extract style from #${styledItem.expressId}:`, e);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return styleMap;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Extract material from IfcStyledItem
|
|
41
|
-
*/
|
|
42
|
-
extractMaterialFromStyledItem(styledItem) {
|
|
43
|
-
// IfcStyledItem structure:
|
|
44
|
-
// Item (0) - reference to geometry
|
|
45
|
-
// Styles (1) - SET OF IfcPresentationStyleAssignment
|
|
46
|
-
// Name (2) - optional
|
|
47
|
-
const stylesRef = this.getAttributeValue(styledItem, 1);
|
|
48
|
-
if (!stylesRef)
|
|
49
|
-
return null;
|
|
50
|
-
// Handle SET OF (array)
|
|
51
|
-
const styleAssignments = Array.isArray(stylesRef) ? stylesRef : [stylesRef];
|
|
52
|
-
for (const styleAssignmentRef of styleAssignments) {
|
|
53
|
-
if (typeof styleAssignmentRef !== 'number')
|
|
54
|
-
continue;
|
|
55
|
-
const styleAssignment = this.entities.get(styleAssignmentRef);
|
|
56
|
-
if (!styleAssignment)
|
|
57
|
-
continue;
|
|
58
|
-
const material = this.extractMaterialFromStyleAssignment(styleAssignment);
|
|
59
|
-
if (material)
|
|
60
|
-
return material;
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Extract material from IfcPresentationStyleAssignment
|
|
66
|
-
*/
|
|
67
|
-
extractMaterialFromStyleAssignment(styleAssignment) {
|
|
68
|
-
// IfcPresentationStyleAssignment structure:
|
|
69
|
-
// Styles (0) - SET OF IfcSurfaceStyle
|
|
70
|
-
const stylesRef = this.getAttributeValue(styleAssignment, 0);
|
|
71
|
-
if (!stylesRef)
|
|
72
|
-
return null;
|
|
73
|
-
const styles = Array.isArray(stylesRef) ? stylesRef : [stylesRef];
|
|
74
|
-
for (const styleRef of styles) {
|
|
75
|
-
if (typeof styleRef !== 'number')
|
|
76
|
-
continue;
|
|
77
|
-
const style = this.entities.get(styleRef);
|
|
78
|
-
if (!style)
|
|
79
|
-
continue;
|
|
80
|
-
const material = this.extractMaterialFromSurfaceStyle(style);
|
|
81
|
-
if (material)
|
|
82
|
-
return material;
|
|
83
|
-
}
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Extract material from IfcSurfaceStyle
|
|
88
|
-
*/
|
|
89
|
-
extractMaterialFromSurfaceStyle(surfaceStyle) {
|
|
90
|
-
// IfcSurfaceStyle structure:
|
|
91
|
-
// Name (0) - optional
|
|
92
|
-
// Side (1) - .POSITIVE., .NEGATIVE., .BOTH.
|
|
93
|
-
// Styles (2) - SET OF IfcSurfaceStyleElement
|
|
94
|
-
const sideAttr = this.getAttributeValue(surfaceStyle, 1);
|
|
95
|
-
const doubleSided = sideAttr === '.BOTH.' || sideAttr === 'BOTH';
|
|
96
|
-
const stylesRef = this.getAttributeValue(surfaceStyle, 2);
|
|
97
|
-
if (!stylesRef)
|
|
98
|
-
return null;
|
|
99
|
-
const styles = Array.isArray(stylesRef) ? stylesRef : [stylesRef];
|
|
100
|
-
// Look for IfcSurfaceStyleRendering (most common)
|
|
101
|
-
for (const styleRef of styles) {
|
|
102
|
-
if (typeof styleRef !== 'number')
|
|
103
|
-
continue;
|
|
104
|
-
const styleElement = this.entities.get(styleRef);
|
|
105
|
-
if (!styleElement)
|
|
106
|
-
continue;
|
|
107
|
-
const typeUpper = styleElement.type.toUpperCase();
|
|
108
|
-
if (typeUpper === 'IFCSURFACESTYLERENDERING') {
|
|
109
|
-
return this.extractMaterialFromRendering(styleElement, doubleSided);
|
|
110
|
-
}
|
|
111
|
-
else if (typeUpper === 'IFCSURFACESTYLESHADING') {
|
|
112
|
-
return this.extractMaterialFromShading(styleElement, doubleSided);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Extract material from IfcSurfaceStyleRendering
|
|
119
|
-
*/
|
|
120
|
-
extractMaterialFromRendering(rendering, doubleSided) {
|
|
121
|
-
// IfcSurfaceStyleRendering structure:
|
|
122
|
-
// SurfaceColour (0) - IfcColourRgb
|
|
123
|
-
// Transparency (1) - OPTIONAL IfcNormalisedRatioMeasure
|
|
124
|
-
// DiffuseColour (2) - OPTIONAL IfcColourOrFactor
|
|
125
|
-
// TransmissionColour (3) - OPTIONAL
|
|
126
|
-
// DiffuseTransmissionColour (4) - OPTIONAL
|
|
127
|
-
// ReflectionColour (5) - OPTIONAL
|
|
128
|
-
// SpecularColour (6) - OPTIONAL
|
|
129
|
-
// SpecularHighlight (7) - OPTIONAL IfcSpecularHighlightSelect
|
|
130
|
-
// ReflectanceMethod (8) - IfcReflectanceMethodEnum
|
|
131
|
-
const surfaceColor = this.extractColorRgb(this.getAttributeValue(rendering, 0));
|
|
132
|
-
const transparency = this.extractTransparency(this.getAttributeValue(rendering, 1));
|
|
133
|
-
const specularHighlight = this.extractSpecularHighlight(this.getAttributeValue(rendering, 7));
|
|
134
|
-
const reflectanceMethod = this.extractReflectanceMethod(this.getAttributeValue(rendering, 8));
|
|
135
|
-
// Extract specular color if available
|
|
136
|
-
const specularColorRef = this.getAttributeValue(rendering, 6);
|
|
137
|
-
const specularColor = specularColorRef ? this.extractColorRgb(specularColorRef) : undefined;
|
|
138
|
-
// Map reflectance method to PBR properties
|
|
139
|
-
const { metallic, roughness } = this.mapReflectanceToPBR(reflectanceMethod, specularHighlight);
|
|
140
|
-
return {
|
|
141
|
-
baseColor: [...surfaceColor, 1.0 - transparency],
|
|
142
|
-
metallic,
|
|
143
|
-
roughness,
|
|
144
|
-
transparency,
|
|
145
|
-
reflectanceMethod,
|
|
146
|
-
specularColor,
|
|
147
|
-
specularHighlight,
|
|
148
|
-
doubleSided,
|
|
149
|
-
alphaMode: transparency > 0.01 ? 'blend' : 'opaque',
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Extract material from IfcSurfaceStyleShading (simpler fallback)
|
|
154
|
-
*/
|
|
155
|
-
extractMaterialFromShading(shading, doubleSided) {
|
|
156
|
-
// IfcSurfaceStyleShading structure:
|
|
157
|
-
// SurfaceColour (0) - IfcColourRgb
|
|
158
|
-
// Transparency (1) - OPTIONAL
|
|
159
|
-
const surfaceColor = this.extractColorRgb(this.getAttributeValue(shading, 0));
|
|
160
|
-
const transparency = this.extractTransparency(this.getAttributeValue(shading, 1));
|
|
161
|
-
return {
|
|
162
|
-
baseColor: [...surfaceColor, 1.0 - transparency],
|
|
163
|
-
metallic: 0.0,
|
|
164
|
-
roughness: 0.6,
|
|
165
|
-
transparency,
|
|
166
|
-
doubleSided,
|
|
167
|
-
alphaMode: transparency > 0.01 ? 'blend' : 'opaque',
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Extract RGB color from IfcColourRgb
|
|
172
|
-
*/
|
|
173
|
-
extractColorRgb(colorRef) {
|
|
174
|
-
if (!colorRef)
|
|
175
|
-
return [0.8, 0.8, 0.8];
|
|
176
|
-
// If it's a reference, resolve it
|
|
177
|
-
if (typeof colorRef === 'number') {
|
|
178
|
-
const colorEntity = this.entities.get(colorRef);
|
|
179
|
-
if (colorEntity) {
|
|
180
|
-
// IfcColourRgb structure: Name (0), Red (1), Green (2), Blue (3)
|
|
181
|
-
const r = this.getNumericValue(colorEntity, 1) ?? 0.8;
|
|
182
|
-
const g = this.getNumericValue(colorEntity, 2) ?? 0.8;
|
|
183
|
-
const b = this.getNumericValue(colorEntity, 3) ?? 0.8;
|
|
184
|
-
return [r, g, b];
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// If it's already an array or object
|
|
188
|
-
if (Array.isArray(colorRef) && colorRef.length >= 3) {
|
|
189
|
-
return [colorRef[0], colorRef[1], colorRef[2]];
|
|
190
|
-
}
|
|
191
|
-
return [0.8, 0.8, 0.8];
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Extract transparency value
|
|
195
|
-
*/
|
|
196
|
-
extractTransparency(transparencyRef) {
|
|
197
|
-
if (transparencyRef === null || transparencyRef === undefined)
|
|
198
|
-
return 0.0;
|
|
199
|
-
// If it's wrapped in IFCNORMALISEDRATIOMEASURE, extract the value
|
|
200
|
-
if (typeof transparencyRef === 'number') {
|
|
201
|
-
return Math.max(0.0, Math.min(1.0, transparencyRef));
|
|
202
|
-
}
|
|
203
|
-
// If it's an object with a value property
|
|
204
|
-
if (typeof transparencyRef === 'object' && 'value' in transparencyRef) {
|
|
205
|
-
return Math.max(0.0, Math.min(1.0, Number(transparencyRef.value) || 0.0));
|
|
206
|
-
}
|
|
207
|
-
return 0.0;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Extract specular highlight value
|
|
211
|
-
*/
|
|
212
|
-
extractSpecularHighlight(highlightRef) {
|
|
213
|
-
if (highlightRef === null || highlightRef === undefined)
|
|
214
|
-
return undefined;
|
|
215
|
-
// If it's wrapped in IFCSPECULAREXPONENT, extract the value
|
|
216
|
-
if (typeof highlightRef === 'number') {
|
|
217
|
-
return highlightRef;
|
|
218
|
-
}
|
|
219
|
-
// If it's an object with a value property
|
|
220
|
-
if (typeof highlightRef === 'object' && 'value' in highlightRef) {
|
|
221
|
-
return Number(highlightRef.value) || undefined;
|
|
222
|
-
}
|
|
223
|
-
return undefined;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Extract reflectance method enum
|
|
227
|
-
*/
|
|
228
|
-
extractReflectanceMethod(methodRef) {
|
|
229
|
-
if (!methodRef)
|
|
230
|
-
return undefined;
|
|
231
|
-
const methodStr = String(methodRef).toUpperCase().replace(/^\./, '').replace(/\.$/, '');
|
|
232
|
-
const validMethods = ['BLINN', 'PHONG', 'METAL', 'GLASS', 'MATT', 'PLASTIC', 'STRAUSS', 'MIRROR'];
|
|
233
|
-
if (validMethods.includes(methodStr)) {
|
|
234
|
-
return methodStr;
|
|
235
|
-
}
|
|
236
|
-
return undefined;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Map IFC reflectance method to PBR metallic/roughness
|
|
240
|
-
*/
|
|
241
|
-
mapReflectanceToPBR(method, specularHighlight) {
|
|
242
|
-
// Default values
|
|
243
|
-
let metallic = 0.0;
|
|
244
|
-
let roughness = 0.6;
|
|
245
|
-
if (!method) {
|
|
246
|
-
// Use specular highlight to estimate roughness if available
|
|
247
|
-
if (specularHighlight !== undefined) {
|
|
248
|
-
// Higher specular exponent = smoother surface = lower roughness
|
|
249
|
-
roughness = Math.max(0.1, Math.min(1.0, 1.0 - (specularHighlight / 128.0)));
|
|
250
|
-
}
|
|
251
|
-
return { metallic, roughness };
|
|
252
|
-
}
|
|
253
|
-
const methodUpper = method.toUpperCase();
|
|
254
|
-
switch (methodUpper) {
|
|
255
|
-
case 'MATT':
|
|
256
|
-
metallic = 0.0;
|
|
257
|
-
roughness = 0.9;
|
|
258
|
-
break;
|
|
259
|
-
case 'PLASTIC':
|
|
260
|
-
metallic = 0.0;
|
|
261
|
-
roughness = 0.5;
|
|
262
|
-
break;
|
|
263
|
-
case 'PHONG':
|
|
264
|
-
case 'BLINN':
|
|
265
|
-
metallic = 0.0;
|
|
266
|
-
roughness = specularHighlight ? Math.max(0.1, Math.min(0.8, 1.0 - (specularHighlight / 128.0))) : 0.4;
|
|
267
|
-
break;
|
|
268
|
-
case 'METAL':
|
|
269
|
-
metallic = 0.9;
|
|
270
|
-
roughness = 0.4;
|
|
271
|
-
break;
|
|
272
|
-
case 'MIRROR':
|
|
273
|
-
metallic = 1.0;
|
|
274
|
-
roughness = 0.1;
|
|
275
|
-
break;
|
|
276
|
-
case 'GLASS':
|
|
277
|
-
metallic = 0.0;
|
|
278
|
-
roughness = 0.05;
|
|
279
|
-
break;
|
|
280
|
-
case 'STRAUSS':
|
|
281
|
-
metallic = 0.5;
|
|
282
|
-
roughness = 0.5;
|
|
283
|
-
break;
|
|
284
|
-
default:
|
|
285
|
-
metallic = 0.0;
|
|
286
|
-
roughness = 0.6;
|
|
287
|
-
}
|
|
288
|
-
return { metallic, roughness };
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Find entities by type name (case-insensitive)
|
|
292
|
-
*/
|
|
293
|
-
findEntitiesByType(typeName) {
|
|
294
|
-
const result = [];
|
|
295
|
-
const typeUpper = typeName.toUpperCase();
|
|
296
|
-
for (const entity of this.entities.values()) {
|
|
297
|
-
if (entity.type.toUpperCase() === typeUpper) {
|
|
298
|
-
result.push(entity);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return result;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Get attribute value from entity
|
|
305
|
-
*/
|
|
306
|
-
getAttributeValue(entity, index) {
|
|
307
|
-
if (index < 0 || index >= entity.attributes.length) {
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
return entity.attributes[index];
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Get numeric value from entity attribute
|
|
314
|
-
* Also handles TypedValue wrappers like [typeName, numericValue]
|
|
315
|
-
*/
|
|
316
|
-
getNumericValue(entity, index) {
|
|
317
|
-
const value = this.getAttributeValue(entity, index);
|
|
318
|
-
if (typeof value === 'number') {
|
|
319
|
-
return value;
|
|
320
|
-
}
|
|
321
|
-
if (typeof value === 'string') {
|
|
322
|
-
const parsed = parseFloat(value);
|
|
323
|
-
return isNaN(parsed) ? null : parsed;
|
|
324
|
-
}
|
|
325
|
-
// Handle TypedValue wrappers: [typeName, numericValue]
|
|
326
|
-
// e.g., ["IFCNORMALISEDRATIOMEASURE", 0.5]
|
|
327
|
-
if (Array.isArray(value) && value.length >= 2) {
|
|
328
|
-
if (typeof value[0] === 'string' && typeof value[1] === 'number') {
|
|
329
|
-
return value[1];
|
|
330
|
-
}
|
|
331
|
-
// Nested case: recursively try to extract numeric from second element
|
|
332
|
-
if (typeof value[0] === 'string') {
|
|
333
|
-
if (typeof value[1] === 'number') {
|
|
334
|
-
return value[1];
|
|
335
|
-
}
|
|
336
|
-
if (typeof value[1] === 'string') {
|
|
337
|
-
const parsed = parseFloat(value[1]);
|
|
338
|
-
return isNaN(parsed) ? null : parsed;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
//# sourceMappingURL=style-extractor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style-extractor.js","sourceRoot":"","sources":["../src/style-extractor.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAgC/D;;GAEG;AACH,MAAM,OAAO,cAAc;IACf,QAAQ,CAAyB;IAEzC,YAAY,QAAgC,EAAE,YAAyB;QACnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,8DAA8D;QAC9D,KAAK,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,aAAa;QACT,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;QAEhD,kCAAkC;QAClC,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAE7D,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACnC,IAAI,CAAC;gBACD,MAAM,QAAQ,GAAG,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,CAAC;gBAChE,IAAI,QAAQ,EAAE,CAAC;oBACX,6CAA6C;oBAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;oBACtD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,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