opengeometry 2.0.7 → 2.0.9

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.
@@ -29,13 +29,69 @@ function handleError(f, args) {
29
29
  }
30
30
  }
31
31
 
32
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
33
-
34
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
35
-
36
- function getStringFromWasm0(ptr, len) {
37
- ptr = ptr >>> 0;
38
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
32
+ function debugString(val) {
33
+ // primitive types
34
+ const type = typeof val;
35
+ if (type == 'number' || type == 'boolean' || val == null) {
36
+ return `${val}`;
37
+ }
38
+ if (type == 'string') {
39
+ return `"${val}"`;
40
+ }
41
+ if (type == 'symbol') {
42
+ const description = val.description;
43
+ if (description == null) {
44
+ return 'Symbol';
45
+ } else {
46
+ return `Symbol(${description})`;
47
+ }
48
+ }
49
+ if (type == 'function') {
50
+ const name = val.name;
51
+ if (typeof name == 'string' && name.length > 0) {
52
+ return `Function(${name})`;
53
+ } else {
54
+ return 'Function';
55
+ }
56
+ }
57
+ // objects
58
+ if (Array.isArray(val)) {
59
+ const length = val.length;
60
+ let debug = '[';
61
+ if (length > 0) {
62
+ debug += debugString(val[0]);
63
+ }
64
+ for(let i = 1; i < length; i++) {
65
+ debug += ', ' + debugString(val[i]);
66
+ }
67
+ debug += ']';
68
+ return debug;
69
+ }
70
+ // Test for built-in
71
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
72
+ let className;
73
+ if (builtInMatches && builtInMatches.length > 1) {
74
+ className = builtInMatches[1];
75
+ } else {
76
+ // Failed to match the standard '[object ClassName]'
77
+ return toString.call(val);
78
+ }
79
+ if (className == 'Object') {
80
+ // we're a user defined class or Object
81
+ // JSON.stringify avoids problems with cycles, and is generally much
82
+ // easier than looping through ownProperties of `val`.
83
+ try {
84
+ return 'Object(' + JSON.stringify(val) + ')';
85
+ } catch (_) {
86
+ return 'Object';
87
+ }
88
+ }
89
+ // errors
90
+ if (val instanceof Error) {
91
+ return `${val.name}: ${val.message}\n${val.stack}`;
92
+ }
93
+ // TODO we could test for more things here, like `Set`s and `Map`s.
94
+ return className;
39
95
  }
40
96
 
41
97
  let WASM_VECTOR_LEN = 0;
@@ -94,6 +150,24 @@ function passStringToWasm0(arg, malloc, realloc) {
94
150
  return ptr;
95
151
  }
96
152
 
153
+ let cachedDataViewMemory0 = null;
154
+
155
+ function getDataViewMemory0() {
156
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
157
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
158
+ }
159
+ return cachedDataViewMemory0;
160
+ }
161
+
162
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
163
+
164
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
165
+
166
+ function getStringFromWasm0(ptr, len) {
167
+ ptr = ptr >>> 0;
168
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
169
+ }
170
+
97
171
  function _assertClass(instance, klass) {
98
172
  if (!(instance instanceof klass)) {
99
173
  throw new Error(`expected instance of ${klass.name}`);
@@ -119,40 +193,6 @@ function getArrayF64FromWasm0(ptr, len) {
119
193
  ptr = ptr >>> 0;
120
194
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
121
195
  }
122
- /**
123
- * @param {string} local_brep_serialized
124
- * @param {number} height
125
- * @returns {string}
126
- */
127
- export function extrudeBrepFace(local_brep_serialized, height) {
128
- let deferred3_0;
129
- let deferred3_1;
130
- try {
131
- const ptr0 = passStringToWasm0(local_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132
- const len0 = WASM_VECTOR_LEN;
133
- const ret = wasm.extrudeBrepFace(ptr0, len0, height);
134
- var ptr2 = ret[0];
135
- var len2 = ret[1];
136
- if (ret[3]) {
137
- ptr2 = 0; len2 = 0;
138
- throw takeFromExternrefTable0(ret[2]);
139
- }
140
- deferred3_0 = ptr2;
141
- deferred3_1 = len2;
142
- return getStringFromWasm0(ptr2, len2);
143
- } finally {
144
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
145
- }
146
- }
147
-
148
- let cachedDataViewMemory0 = null;
149
-
150
- function getDataViewMemory0() {
151
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
152
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
153
- }
154
- return cachedDataViewMemory0;
155
- }
156
196
 
157
197
  function passArrayJsValueToWasm0(array, malloc) {
158
198
  const ptr = malloc(array.length * 4, 4) >>> 0;
@@ -251,6 +291,32 @@ export function booleanSubtractionMany(lhs_brep_serialized, cutters_brep_seriali
251
291
  return OGBooleanResult.__wrap(ret[0]);
252
292
  }
253
293
 
294
+ /**
295
+ * @param {string} local_brep_serialized
296
+ * @param {number} height
297
+ * @returns {string}
298
+ */
299
+ export function extrudeBrepFace(local_brep_serialized, height) {
300
+ let deferred3_0;
301
+ let deferred3_1;
302
+ try {
303
+ const ptr0 = passStringToWasm0(local_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
304
+ const len0 = WASM_VECTOR_LEN;
305
+ const ret = wasm.extrudeBrepFace(ptr0, len0, height);
306
+ var ptr2 = ret[0];
307
+ var len2 = ret[1];
308
+ if (ret[3]) {
309
+ ptr2 = 0; len2 = 0;
310
+ throw takeFromExternrefTable0(ret[2]);
311
+ }
312
+ deferred3_0 = ptr2;
313
+ deferred3_1 = len2;
314
+ return getStringFromWasm0(ptr2, len2);
315
+ } finally {
316
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
317
+ }
318
+ }
319
+
254
320
  function getArrayJsValueFromWasm0(ptr, len) {
255
321
  ptr = ptr >>> 0;
256
322
  const mem = getDataViewMemory0();
@@ -1653,6 +1719,100 @@ export class OGCylinder {
1653
1719
  }
1654
1720
  }
1655
1721
 
1722
+ const OGEntityRegistryFinalization = (typeof FinalizationRegistry === 'undefined')
1723
+ ? { register: () => {}, unregister: () => {} }
1724
+ : new FinalizationRegistry(ptr => wasm.__wbg_ogentityregistry_free(ptr >>> 0, 1));
1725
+ /**
1726
+ * Flat entity registry with a batched multi-view projection API.
1727
+ * Replaces the scene-centric OGSceneManager pattern for export use cases.
1728
+ */
1729
+ export class OGEntityRegistry {
1730
+
1731
+ __destroy_into_raw() {
1732
+ const ptr = this.__wbg_ptr;
1733
+ this.__wbg_ptr = 0;
1734
+ OGEntityRegistryFinalization.unregister(this);
1735
+ return ptr;
1736
+ }
1737
+
1738
+ free() {
1739
+ const ptr = this.__destroy_into_raw();
1740
+ wasm.__wbg_ogentityregistry_free(ptr, 0);
1741
+ }
1742
+ constructor() {
1743
+ const ret = wasm.ogentityregistry_new();
1744
+ this.__wbg_ptr = ret >>> 0;
1745
+ OGEntityRegistryFinalization.register(this, this.__wbg_ptr, this);
1746
+ return this;
1747
+ }
1748
+ /**
1749
+ * Register (or replace) an entity. `kind` must be an OGEntityKind string.
1750
+ * @param {string} id
1751
+ * @param {string} kind
1752
+ * @param {string} brep_json
1753
+ */
1754
+ registerEntity(id, kind, brep_json) {
1755
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1756
+ const len0 = WASM_VECTOR_LEN;
1757
+ const ptr1 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1758
+ const len1 = WASM_VECTOR_LEN;
1759
+ const ptr2 = passStringToWasm0(brep_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1760
+ const len2 = WASM_VECTOR_LEN;
1761
+ const ret = wasm.ogentityregistry_registerEntity(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
1762
+ if (ret[1]) {
1763
+ throw takeFromExternrefTable0(ret[0]);
1764
+ }
1765
+ }
1766
+ /**
1767
+ * Remove a previously registered entity.
1768
+ * @param {string} id
1769
+ * @returns {boolean}
1770
+ */
1771
+ unregisterEntity(id) {
1772
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1773
+ const len0 = WASM_VECTOR_LEN;
1774
+ const ret = wasm.ogentityregistry_unregisterEntity(this.__wbg_ptr, ptr0, len0);
1775
+ return ret !== 0;
1776
+ }
1777
+ /**
1778
+ * Remove all registered entities.
1779
+ */
1780
+ clearEntities() {
1781
+ wasm.ogentityregistry_clearEntities(this.__wbg_ptr);
1782
+ }
1783
+ /**
1784
+ * Batched multi-view projection.
1785
+ *
1786
+ * Input: JSON array of `{ id, camera, hlr?, section_plane? }` (ViewRequest).
1787
+ * Output: JSON map of `{ viewportId: Scene2D }`.
1788
+ *
1789
+ * All viewports are projected in a single WASM call, amortising
1790
+ * serialisation overhead and keeping BRep data in WASM memory.
1791
+ * @param {string} views_json
1792
+ * @returns {string}
1793
+ */
1794
+ projectCurrentToViews(views_json) {
1795
+ let deferred3_0;
1796
+ let deferred3_1;
1797
+ try {
1798
+ const ptr0 = passStringToWasm0(views_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1799
+ const len0 = WASM_VECTOR_LEN;
1800
+ const ret = wasm.ogentityregistry_projectCurrentToViews(this.__wbg_ptr, ptr0, len0);
1801
+ var ptr2 = ret[0];
1802
+ var len2 = ret[1];
1803
+ if (ret[3]) {
1804
+ ptr2 = 0; len2 = 0;
1805
+ throw takeFromExternrefTable0(ret[2]);
1806
+ }
1807
+ deferred3_0 = ptr2;
1808
+ deferred3_1 = len2;
1809
+ return getStringFromWasm0(ptr2, len2);
1810
+ } finally {
1811
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1812
+ }
1813
+ }
1814
+ }
1815
+
1656
1816
  const OGFreeformEditorFinalization = (typeof FinalizationRegistry === 'undefined')
1657
1817
  ? { register: () => {}, unregister: () => {} }
1658
1818
  : new FinalizationRegistry(ptr => wasm.__wbg_ogfreeformeditor_free(ptr >>> 0, 1));
@@ -4996,7 +5156,7 @@ export class OGSweep {
4996
5156
  * @returns {Vector3}
4997
5157
  */
4998
5158
  get_anchor() {
4999
- const ret = wasm.ogarc_get_anchor(this.__wbg_ptr);
5159
+ const ret = wasm.ogsweep_get_anchor(this.__wbg_ptr);
5000
5160
  return Vector3.__wrap(ret);
5001
5161
  }
5002
5162
  /**
@@ -5624,6 +5784,13 @@ function __wbg_get_imports() {
5624
5784
  const ret = Vector3.__unwrap(arg0);
5625
5785
  return ret;
5626
5786
  };
5787
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
5788
+ const ret = debugString(arg1);
5789
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5790
+ const len1 = WASM_VECTOR_LEN;
5791
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
5792
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
5793
+ };
5627
5794
  imports.wbg.__wbindgen_init_externref_table = function() {
5628
5795
  const table = wasm.__wbindgen_export_2;
5629
5796
  const offset = table.grow(4);