@ifc-lite/geometry 1.16.5 → 1.16.6
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 +43 -12
- package/dist/geometry-coordinate.d.ts +29 -0
- package/dist/geometry-coordinate.d.ts.map +1 -0
- package/dist/geometry-coordinate.js +83 -0
- package/dist/geometry-coordinate.js.map +1 -0
- package/dist/geometry-native.d.ts +51 -0
- package/dist/geometry-native.d.ts.map +1 -0
- package/dist/geometry-native.js +154 -0
- package/dist/geometry-native.js.map +1 -0
- package/dist/geometry-parallel.d.ts +23 -0
- package/dist/geometry-parallel.d.ts.map +1 -0
- package/dist/geometry-parallel.js +193 -0
- package/dist/geometry-parallel.js.map +1 -0
- package/dist/ifc-lite-mesh-collector.d.ts +1 -0
- package/dist/ifc-lite-mesh-collector.d.ts.map +1 -1
- package/dist/ifc-lite-mesh-collector.js +1 -0
- package/dist/ifc-lite-mesh-collector.js.map +1 -1
- package/dist/index.d.ts +18 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -382
- package/dist/index.js.map +1 -1
- package/dist/native-bridge-conversion.d.ts +71 -0
- package/dist/native-bridge-conversion.d.ts.map +1 -0
- package/dist/native-bridge-conversion.js +55 -0
- package/dist/native-bridge-conversion.js.map +1 -0
- package/dist/native-bridge.d.ts.map +1 -1
- package/dist/native-bridge.js +2 -139
- package/dist/native-bridge.js.map +1 -1
- package/dist/packed-geometry-decoder.d.ts +25 -0
- package/dist/packed-geometry-decoder.d.ts.map +1 -0
- package/dist/packed-geometry-decoder.js +106 -0
- package/dist/packed-geometry-decoder.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
* Convert an unknown payload (ArrayBuffer, Uint8Array, or number[]) into an
|
|
6
|
+
* ArrayBuffer suitable for DataView / TypedArray construction.
|
|
7
|
+
*/
|
|
8
|
+
export function toArrayBuffer(payload) {
|
|
9
|
+
if (payload instanceof ArrayBuffer) {
|
|
10
|
+
return payload;
|
|
11
|
+
}
|
|
12
|
+
if (payload instanceof Uint8Array) {
|
|
13
|
+
if (payload.byteOffset === 0
|
|
14
|
+
&& payload.byteLength === payload.buffer.byteLength
|
|
15
|
+
&& payload.buffer instanceof ArrayBuffer) {
|
|
16
|
+
return payload.buffer;
|
|
17
|
+
}
|
|
18
|
+
return payload.slice().buffer;
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(payload)) {
|
|
21
|
+
return Uint8Array.from(payload).buffer;
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Unsupported packed geometry shard payload: ${typeof payload}`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Decode a packed geometry cache shard from its binary representation into a
|
|
27
|
+
* GeometryBatch.
|
|
28
|
+
*
|
|
29
|
+
* Binary layout (all little-endian uint32 unless noted):
|
|
30
|
+
* Header (8 words): magic, version, meshCount, positionsLen, normalsLen,
|
|
31
|
+
* indicesLen, processed, total
|
|
32
|
+
* Mesh table (meshCount * 11 words each): expressId, posOff, posLen, nrmOff,
|
|
33
|
+
* nrmLen, idxOff, idxLen, color(r,g,b,a as float32)
|
|
34
|
+
* Data: positions (Float32), normals (Float32), indices (Uint32)
|
|
35
|
+
*/
|
|
36
|
+
export function decodePackedGeometryCacheShard(payload, jsReceivedTimeMs, batchSequence) {
|
|
37
|
+
const buffer = toArrayBuffer(payload);
|
|
38
|
+
const header = new Uint32Array(buffer, 0, 8);
|
|
39
|
+
const [magic, version, meshCount, positionsLen, normalsLen, indicesLen, processed, total] = header;
|
|
40
|
+
if (magic !== 0x49464342) {
|
|
41
|
+
throw new Error('Invalid packed geometry cache shard magic');
|
|
42
|
+
}
|
|
43
|
+
if (version !== 1) {
|
|
44
|
+
throw new Error(`Unsupported packed geometry cache shard version: ${version}`);
|
|
45
|
+
}
|
|
46
|
+
const meshRecordWordLength = 11;
|
|
47
|
+
const meshWordOffset = 8;
|
|
48
|
+
const meshTableWords = meshCount * meshRecordWordLength;
|
|
49
|
+
const dataByteOffset = (meshWordOffset + meshTableWords) * Uint32Array.BYTES_PER_ELEMENT;
|
|
50
|
+
const positionsByteLength = positionsLen * Float32Array.BYTES_PER_ELEMENT;
|
|
51
|
+
const normalsByteLength = normalsLen * Float32Array.BYTES_PER_ELEMENT;
|
|
52
|
+
const indicesByteLength = indicesLen * Uint32Array.BYTES_PER_ELEMENT;
|
|
53
|
+
const positionsOffset = dataByteOffset;
|
|
54
|
+
const normalsOffset = positionsOffset + positionsByteLength;
|
|
55
|
+
const indicesOffset = normalsOffset + normalsByteLength;
|
|
56
|
+
const positions = new Float32Array(buffer, positionsOffset, positionsLen);
|
|
57
|
+
const normals = new Float32Array(buffer, normalsOffset, normalsLen);
|
|
58
|
+
const indices = new Uint32Array(buffer, indicesOffset, indicesLen);
|
|
59
|
+
const meshView = new DataView(buffer, meshWordOffset * Uint32Array.BYTES_PER_ELEMENT, meshTableWords * Uint32Array.BYTES_PER_ELEMENT);
|
|
60
|
+
const meshes = [];
|
|
61
|
+
for (let meshIndex = 0; meshIndex < meshCount; meshIndex += 1) {
|
|
62
|
+
const base = meshIndex * meshRecordWordLength * Uint32Array.BYTES_PER_ELEMENT;
|
|
63
|
+
const expressId = meshView.getUint32(base, true);
|
|
64
|
+
const positionsOffsetWords = meshView.getUint32(base + 4, true);
|
|
65
|
+
const positionsLengthWords = meshView.getUint32(base + 8, true);
|
|
66
|
+
const normalsOffsetWords = meshView.getUint32(base + 12, true);
|
|
67
|
+
const normalsLengthWords = meshView.getUint32(base + 16, true);
|
|
68
|
+
const indicesOffsetWords = meshView.getUint32(base + 20, true);
|
|
69
|
+
const indicesLengthWords = meshView.getUint32(base + 24, true);
|
|
70
|
+
const color = [
|
|
71
|
+
meshView.getFloat32(base + 28, true),
|
|
72
|
+
meshView.getFloat32(base + 32, true),
|
|
73
|
+
meshView.getFloat32(base + 36, true),
|
|
74
|
+
meshView.getFloat32(base + 40, true),
|
|
75
|
+
];
|
|
76
|
+
meshes.push({
|
|
77
|
+
expressId,
|
|
78
|
+
positions: positions.subarray(positionsOffsetWords, positionsOffsetWords + positionsLengthWords),
|
|
79
|
+
normals: normals.subarray(normalsOffsetWords, normalsOffsetWords + normalsLengthWords),
|
|
80
|
+
indices: indices.subarray(indicesOffsetWords, indicesOffsetWords + indicesLengthWords),
|
|
81
|
+
color,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
meshes,
|
|
86
|
+
progress: {
|
|
87
|
+
processed,
|
|
88
|
+
total,
|
|
89
|
+
currentType: 'cached',
|
|
90
|
+
},
|
|
91
|
+
nativeTelemetry: {
|
|
92
|
+
batchSequence,
|
|
93
|
+
payloadKind: 'packed-cache-shard',
|
|
94
|
+
meshCount,
|
|
95
|
+
positionsLen,
|
|
96
|
+
normalsLen,
|
|
97
|
+
indicesLen,
|
|
98
|
+
chunkReadyTimeMs: 0,
|
|
99
|
+
packTimeMs: 0,
|
|
100
|
+
emitTimeMs: 0,
|
|
101
|
+
emittedTimeMs: 0,
|
|
102
|
+
jsReceivedTimeMs,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=packed-geometry-decoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packed-geometry-decoder.js","sourceRoot":"","sources":["../src/packed-geometry-decoder.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAY/D;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,IAAI,OAAO,YAAY,WAAW,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,OAAO,YAAY,UAAU,EAAE,CAAC;QAClC,IACE,OAAO,CAAC,UAAU,K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ACnB,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,CAAC;YAChB,gBAAgB;SACjB;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ifc-lite/geometry",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.6",
|
|
4
4
|
"description": "Geometry processing bridge for IFC-Lite - 1.9x faster than web-ifc",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@ifc-lite/data": "^1.15.2",
|
|
16
|
-
"@ifc-lite/wasm": "^1.16.
|
|
16
|
+
"@ifc-lite/wasm": "^1.16.7"
|
|
17
17
|
},
|
|
18
18
|
"optionalDependencies": {
|
|
19
19
|
"@tauri-apps/api": "^2.0.0"
|