opengeometry 2.0.2 → 2.0.3
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 +1 -1
- package/index.d.ts +12 -0
- package/index.js +683 -283
- package/index.js.map +1 -1
- package/opengeometry/pkg/opengeometry.d.ts +207 -197
- package/opengeometry/pkg/opengeometry.js +76 -14
- package/opengeometry/pkg/opengeometry_bg.wasm +0 -0
- package/opengeometry/pkg/opengeometry_bg.wasm.d.ts +202 -197
- package/opengeometry_bg.wasm +0 -0
- package/opengeometry_bg.wasm.d.ts +202 -197
- package/package.json +1 -1
- package/src/base-types.d.ts +7 -1
- package/src/editor/freeform.d.ts +63 -0
- package/src/editor/index.d.ts +3 -0
- package/src/editor/parametric.d.ts +10 -0
- package/src/editor/types.d.ts +72 -0
- package/src/freeform/geometry.d.ts +59 -0
- package/src/freeform/index.d.ts +3 -0
- package/src/freeform/types.d.ts +12 -0
- package/src/operations/boolean.d.ts +15 -0
- package/src/operations/extrude.d.ts +9 -0
- package/src/operations/index.d.ts +1 -0
- package/src/primitives/arc.d.ts +15 -0
- package/src/primitives/curve.d.ts +18 -0
- package/src/primitives/line.d.ts +15 -0
- package/src/primitives/polyline.d.ts +18 -0
- package/src/primitives/rectangle.d.ts +18 -0
- package/src/shapes/boolean-subtract.d.ts +9 -0
- package/src/shapes/cuboid.d.ts +15 -0
- package/src/shapes/cylinder.d.ts +15 -0
- package/src/shapes/extrusion.d.ts +64 -0
- package/src/shapes/index.d.ts +1 -0
- package/src/shapes/opening.d.ts +15 -0
- package/src/shapes/outline-utils.d.ts +21 -0
- package/src/shapes/polygon.d.ts +30 -3
- package/src/shapes/solid.d.ts +111 -0
- package/src/shapes/sphere.d.ts +15 -0
- package/src/shapes/sweep.d.ts +15 -0
- package/src/shapes/wedge.d.ts +15 -0
package/index.js
CHANGED
|
@@ -178,16 +178,6 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
178
178
|
function isLikeNone(x) {
|
|
179
179
|
return x === undefined || x === null;
|
|
180
180
|
}
|
|
181
|
-
function getArrayJsValueFromWasm0(ptr, len) {
|
|
182
|
-
ptr = ptr >>> 0;
|
|
183
|
-
const mem = getDataViewMemory0();
|
|
184
|
-
const result = [];
|
|
185
|
-
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
186
|
-
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
187
|
-
}
|
|
188
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
189
|
-
return result;
|
|
190
|
-
}
|
|
191
181
|
/**
|
|
192
182
|
* Wasm entry point for union.
|
|
193
183
|
* @param {string} lhs_brep_serialized
|
|
@@ -250,6 +240,43 @@ function booleanSubtraction$1(lhs_brep_serialized, rhs_brep_serialized, options_
|
|
|
250
240
|
}
|
|
251
241
|
return OGBooleanResult.__wrap(ret[0]);
|
|
252
242
|
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @param {string} local_brep_serialized
|
|
246
|
+
* @param {number} height
|
|
247
|
+
* @returns {string}
|
|
248
|
+
*/
|
|
249
|
+
function extrudeBrepFace$1(local_brep_serialized, height) {
|
|
250
|
+
let deferred3_0;
|
|
251
|
+
let deferred3_1;
|
|
252
|
+
try {
|
|
253
|
+
const ptr0 = passStringToWasm0(local_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
254
|
+
const len0 = WASM_VECTOR_LEN;
|
|
255
|
+
const ret = wasm.extrudeBrepFace(ptr0, len0, height);
|
|
256
|
+
var ptr2 = ret[0];
|
|
257
|
+
var len2 = ret[1];
|
|
258
|
+
if (ret[3]) {
|
|
259
|
+
ptr2 = 0;
|
|
260
|
+
len2 = 0;
|
|
261
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
262
|
+
}
|
|
263
|
+
deferred3_0 = ptr2;
|
|
264
|
+
deferred3_1 = len2;
|
|
265
|
+
return getStringFromWasm0(ptr2, len2);
|
|
266
|
+
} finally {
|
|
267
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
271
|
+
ptr = ptr >>> 0;
|
|
272
|
+
const mem = getDataViewMemory0();
|
|
273
|
+
const result = [];
|
|
274
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
275
|
+
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
276
|
+
}
|
|
277
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
253
280
|
const Matrix3Finalization = typeof FinalizationRegistry === 'undefined' ? {
|
|
254
281
|
register: () => {},
|
|
255
282
|
unregister: () => {}
|
|
@@ -2229,6 +2256,24 @@ class OGFreeformGeometry {
|
|
|
2229
2256
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2230
2257
|
}
|
|
2231
2258
|
}
|
|
2259
|
+
/**
|
|
2260
|
+
* @returns {Float64Array}
|
|
2261
|
+
*/
|
|
2262
|
+
getGeometryBuffer() {
|
|
2263
|
+
const ret = wasm.ogfreeformgeometry_getGeometryBuffer(this.__wbg_ptr);
|
|
2264
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2265
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2266
|
+
return v1;
|
|
2267
|
+
}
|
|
2268
|
+
/**
|
|
2269
|
+
* @returns {Float64Array}
|
|
2270
|
+
*/
|
|
2271
|
+
getLocalGeometryBuffer() {
|
|
2272
|
+
const ret = wasm.ogfreeformgeometry_getLocalGeometryBuffer(this.__wbg_ptr);
|
|
2273
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2274
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2275
|
+
return v1;
|
|
2276
|
+
}
|
|
2232
2277
|
/**
|
|
2233
2278
|
* @returns {string}
|
|
2234
2279
|
*/
|
|
@@ -2244,6 +2289,24 @@ class OGFreeformGeometry {
|
|
|
2244
2289
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2245
2290
|
}
|
|
2246
2291
|
}
|
|
2292
|
+
/**
|
|
2293
|
+
* @returns {Float64Array}
|
|
2294
|
+
*/
|
|
2295
|
+
getOutlineGeometryBuffer() {
|
|
2296
|
+
const ret = wasm.ogfreeformgeometry_getOutlineGeometryBuffer(this.__wbg_ptr);
|
|
2297
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2298
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2299
|
+
return v1;
|
|
2300
|
+
}
|
|
2301
|
+
/**
|
|
2302
|
+
* @returns {Float64Array}
|
|
2303
|
+
*/
|
|
2304
|
+
getLocalOutlineGeometryBuffer() {
|
|
2305
|
+
const ret = wasm.ogfreeformgeometry_getLocalOutlineGeometryBuffer(this.__wbg_ptr);
|
|
2306
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2307
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2308
|
+
return v1;
|
|
2309
|
+
}
|
|
2247
2310
|
/**
|
|
2248
2311
|
* @returns {string}
|
|
2249
2312
|
*/
|
|
@@ -2577,7 +2640,7 @@ class OGLine {
|
|
|
2577
2640
|
* @returns {Vector3}
|
|
2578
2641
|
*/
|
|
2579
2642
|
get_anchor() {
|
|
2580
|
-
const ret = wasm.
|
|
2643
|
+
const ret = wasm.ogcurve_get_anchor(this.__wbg_ptr);
|
|
2581
2644
|
return Vector3.__wrap(ret);
|
|
2582
2645
|
}
|
|
2583
2646
|
/**
|
|
@@ -3203,7 +3266,7 @@ class OGPolyline {
|
|
|
3203
3266
|
* @returns {Vector3}
|
|
3204
3267
|
*/
|
|
3205
3268
|
get_anchor() {
|
|
3206
|
-
const ret = wasm.
|
|
3269
|
+
const ret = wasm.ogcurve_get_anchor(this.__wbg_ptr);
|
|
3207
3270
|
return Vector3.__wrap(ret);
|
|
3208
3271
|
}
|
|
3209
3272
|
/**
|
|
@@ -5194,7 +5257,7 @@ class OGWedge {
|
|
|
5194
5257
|
* @returns {Vector3}
|
|
5195
5258
|
*/
|
|
5196
5259
|
get_anchor() {
|
|
5197
|
-
const ret = wasm.
|
|
5260
|
+
const ret = wasm.ogwedge_get_anchor(this.__wbg_ptr);
|
|
5198
5261
|
return Vector3.__wrap(ret);
|
|
5199
5262
|
}
|
|
5200
5263
|
}
|
|
@@ -5627,6 +5690,7 @@ var OGKernel = /*#__PURE__*/Object.freeze({
|
|
|
5627
5690
|
booleanSubtraction: booleanSubtraction$1,
|
|
5628
5691
|
booleanUnion: booleanUnion$1,
|
|
5629
5692
|
default: __wbg_init,
|
|
5693
|
+
extrudeBrepFace: extrudeBrepFace$1,
|
|
5630
5694
|
initSync: initSync
|
|
5631
5695
|
});
|
|
5632
5696
|
|
|
@@ -5648,7 +5712,10 @@ class SpotLabel extends CSS2DObject {
|
|
|
5648
5712
|
}
|
|
5649
5713
|
}
|
|
5650
5714
|
|
|
5651
|
-
|
|
5715
|
+
/**
|
|
5716
|
+
* Version string exposed by the Three.js adapter at runtime.
|
|
5717
|
+
*/
|
|
5718
|
+
const OPEN_GEOMETRY_THREE_VERSION = "2.0.3";
|
|
5652
5719
|
|
|
5653
5720
|
/**
|
|
5654
5721
|
* Convert array of 16 byte values to UUID string format of the form:
|
|
@@ -5708,10 +5775,13 @@ function getUUID() {
|
|
|
5708
5775
|
return uuid;
|
|
5709
5776
|
}
|
|
5710
5777
|
|
|
5711
|
-
function cloneVector$
|
|
5778
|
+
function cloneVector$2(vector, fallback) {
|
|
5712
5779
|
var _a;
|
|
5713
5780
|
return (_a = vector === null || vector === void 0 ? void 0 : vector.clone()) !== null && _a !== void 0 ? _a : new Vector3(...fallback);
|
|
5714
5781
|
}
|
|
5782
|
+
/**
|
|
5783
|
+
* Returns the canonical capability payload exposed by parametric wrappers.
|
|
5784
|
+
*/
|
|
5715
5785
|
function createParametricEditCapabilities(entityType, editFamily) {
|
|
5716
5786
|
return {
|
|
5717
5787
|
editingMode: "parametric",
|
|
@@ -5722,27 +5792,34 @@ function createParametricEditCapabilities(entityType, editFamily) {
|
|
|
5722
5792
|
canConvertToFreeform: true,
|
|
5723
5793
|
};
|
|
5724
5794
|
}
|
|
5795
|
+
/**
|
|
5796
|
+
* Normalizes optional placement fields into concrete vectors.
|
|
5797
|
+
*/
|
|
5725
5798
|
function clonePlacement(placement) {
|
|
5726
5799
|
return {
|
|
5727
|
-
translation: cloneVector$
|
|
5728
|
-
rotation: cloneVector$
|
|
5729
|
-
scale: cloneVector$
|
|
5800
|
+
translation: cloneVector$2(placement.translation, [0, 0, 0]),
|
|
5801
|
+
rotation: cloneVector$2(placement.rotation, [0, 0, 0]),
|
|
5802
|
+
scale: cloneVector$2(placement.scale, [1, 1, 1]),
|
|
5730
5803
|
};
|
|
5731
5804
|
}
|
|
5805
|
+
/**
|
|
5806
|
+
* Converts a parametric placement payload into the freeform/object transform
|
|
5807
|
+
* structure expected by BRep-backed helpers.
|
|
5808
|
+
*/
|
|
5732
5809
|
function toObjectTransformation$1(placement) {
|
|
5733
5810
|
if ("anchor" in placement) {
|
|
5734
5811
|
return {
|
|
5735
|
-
anchor: cloneVector$
|
|
5736
|
-
translation: cloneVector$
|
|
5737
|
-
rotation: cloneVector$
|
|
5738
|
-
scale: cloneVector$
|
|
5812
|
+
anchor: cloneVector$2(placement.anchor, [0, 0, 0]),
|
|
5813
|
+
translation: cloneVector$2(placement.translation, [0, 0, 0]),
|
|
5814
|
+
rotation: cloneVector$2(placement.rotation, [0, 0, 0]),
|
|
5815
|
+
scale: cloneVector$2(placement.scale, [1, 1, 1]),
|
|
5739
5816
|
};
|
|
5740
5817
|
}
|
|
5741
5818
|
return {
|
|
5742
5819
|
anchor: new Vector3(0, 0, 0),
|
|
5743
|
-
translation: cloneVector$
|
|
5744
|
-
rotation: cloneVector$
|
|
5745
|
-
scale: cloneVector$
|
|
5820
|
+
translation: cloneVector$2(placement.translation, [0, 0, 0]),
|
|
5821
|
+
rotation: cloneVector$2(placement.rotation, [0, 0, 0]),
|
|
5822
|
+
scale: cloneVector$2(placement.scale, [1, 1, 1]),
|
|
5746
5823
|
};
|
|
5747
5824
|
}
|
|
5748
5825
|
|
|
@@ -5834,69 +5911,132 @@ function serializeOptions(options) {
|
|
|
5834
5911
|
? toPlainVector3$1(options.constraintPlaneNormal)
|
|
5835
5912
|
: undefined }));
|
|
5836
5913
|
}
|
|
5914
|
+
/**
|
|
5915
|
+
* High-level editor facade over the kernel freeform editing API.
|
|
5916
|
+
*/
|
|
5837
5917
|
class FreeformEditor {
|
|
5838
5918
|
constructor(geometry, editor = new OGFreeformEditor()) {
|
|
5839
5919
|
this.geometry = geometry;
|
|
5840
5920
|
this.editor = editor;
|
|
5841
5921
|
}
|
|
5922
|
+
/**
|
|
5923
|
+
* Returns the freeform geometry currently managed by this editor.
|
|
5924
|
+
*/
|
|
5842
5925
|
getFreeformGeometry() {
|
|
5843
5926
|
return this.geometry;
|
|
5844
5927
|
}
|
|
5928
|
+
/**
|
|
5929
|
+
* Returns renderable topology buffers for faces, edges, and vertices.
|
|
5930
|
+
*/
|
|
5845
5931
|
getTopologyRenderData() {
|
|
5846
5932
|
return normalizeTopologyRenderData(parseJson$1(this.editor.getTopologyRenderData(this.geometry.getKernelGeometry())));
|
|
5847
5933
|
}
|
|
5934
|
+
/**
|
|
5935
|
+
* Returns semantic and topological information for a face id.
|
|
5936
|
+
*/
|
|
5848
5937
|
getFaceInfo(faceId) {
|
|
5849
5938
|
return normalizeFaceInfo(parseJson$1(this.editor.getFaceInfo(this.geometry.getKernelGeometry(), faceId)));
|
|
5850
5939
|
}
|
|
5940
|
+
/**
|
|
5941
|
+
* Returns semantic and topological information for an edge id.
|
|
5942
|
+
*/
|
|
5851
5943
|
getEdgeInfo(edgeId) {
|
|
5852
5944
|
return normalizeEdgeInfo(parseJson$1(this.editor.getEdgeInfo(this.geometry.getKernelGeometry(), edgeId)));
|
|
5853
5945
|
}
|
|
5946
|
+
/**
|
|
5947
|
+
* Returns semantic and topological information for a vertex id.
|
|
5948
|
+
*/
|
|
5854
5949
|
getVertexInfo(vertexId) {
|
|
5855
5950
|
return normalizeVertexInfo(parseJson$1(this.editor.getVertexInfo(this.geometry.getKernelGeometry(), vertexId)));
|
|
5856
5951
|
}
|
|
5952
|
+
/**
|
|
5953
|
+
* Returns global edit capabilities for the current freeform model.
|
|
5954
|
+
*/
|
|
5857
5955
|
getEditCapabilities() {
|
|
5858
5956
|
return normalizeFreeformCapabilities(parseJson$1(this.editor.getEditCapabilities(this.geometry.getKernelGeometry())));
|
|
5859
5957
|
}
|
|
5958
|
+
/**
|
|
5959
|
+
* Returns edit capabilities scoped to a single face.
|
|
5960
|
+
*/
|
|
5860
5961
|
getFaceEditCapabilities(faceId) {
|
|
5861
5962
|
return normalizeFeatureCapabilities(parseJson$1(this.editor.getFaceEditCapabilities(this.geometry.getKernelGeometry(), faceId)));
|
|
5862
5963
|
}
|
|
5964
|
+
/**
|
|
5965
|
+
* Returns edit capabilities scoped to a single edge.
|
|
5966
|
+
*/
|
|
5863
5967
|
getEdgeEditCapabilities(edgeId) {
|
|
5864
5968
|
return normalizeFeatureCapabilities(parseJson$1(this.editor.getEdgeEditCapabilities(this.geometry.getKernelGeometry(), edgeId)));
|
|
5865
5969
|
}
|
|
5970
|
+
/**
|
|
5971
|
+
* Returns edit capabilities scoped to a single vertex.
|
|
5972
|
+
*/
|
|
5866
5973
|
getVertexEditCapabilities(vertexId) {
|
|
5867
5974
|
return normalizeFeatureCapabilities(parseJson$1(this.editor.getVertexEditCapabilities(this.geometry.getKernelGeometry(), vertexId)));
|
|
5868
5975
|
}
|
|
5976
|
+
/**
|
|
5977
|
+
* Offset a face along its editable normal direction.
|
|
5978
|
+
*/
|
|
5869
5979
|
pushPullFace(faceId, distance, options) {
|
|
5870
5980
|
return parseEditResult(this.editor.pushPullFace(this.geometry.getKernelGeometry(), faceId, distance, serializeOptions(options)));
|
|
5871
5981
|
}
|
|
5982
|
+
/**
|
|
5983
|
+
* Creates new side faces by extruding a face region.
|
|
5984
|
+
*/
|
|
5872
5985
|
extrudeFace(faceId, distance, options) {
|
|
5873
5986
|
return parseEditResult(this.editor.extrudeFace(this.geometry.getKernelGeometry(), faceId, distance, serializeOptions(options)));
|
|
5874
5987
|
}
|
|
5988
|
+
/**
|
|
5989
|
+
* Splits a face by connecting two points sampled on its boundary edges.
|
|
5990
|
+
*/
|
|
5875
5991
|
cutFace(faceId, startEdgeId, startT, endEdgeId, endT, options) {
|
|
5876
5992
|
return parseEditResult(this.editor.cutFace(this.geometry.getKernelGeometry(), faceId, startEdgeId, startT, endEdgeId, endT, serializeOptions(options)));
|
|
5877
5993
|
}
|
|
5994
|
+
/**
|
|
5995
|
+
* Moves a face by a translation vector, subject to kernel constraints.
|
|
5996
|
+
*/
|
|
5878
5997
|
moveFace(faceId, translation, options) {
|
|
5879
5998
|
return parseEditResult(this.editor.moveFace(this.geometry.getKernelGeometry(), faceId, translation, serializeOptions(options)));
|
|
5880
5999
|
}
|
|
6000
|
+
/**
|
|
6001
|
+
* Moves an edge by a translation vector, subject to kernel constraints.
|
|
6002
|
+
*/
|
|
5881
6003
|
moveEdge(edgeId, translation, options) {
|
|
5882
6004
|
return parseEditResult(this.editor.moveEdge(this.geometry.getKernelGeometry(), edgeId, translation, serializeOptions(options)));
|
|
5883
6005
|
}
|
|
6006
|
+
/**
|
|
6007
|
+
* Moves a vertex by a translation vector, subject to kernel constraints.
|
|
6008
|
+
*/
|
|
5884
6009
|
moveVertex(vertexId, translation, options) {
|
|
5885
6010
|
return parseEditResult(this.editor.moveVertex(this.geometry.getKernelGeometry(), vertexId, translation, serializeOptions(options)));
|
|
5886
6011
|
}
|
|
6012
|
+
/**
|
|
6013
|
+
* Inserts a vertex at parametric position `t` along an edge.
|
|
6014
|
+
*/
|
|
5887
6015
|
insertVertexOnEdge(edgeId, t, options) {
|
|
5888
6016
|
return parseEditResult(this.editor.insertVertexOnEdge(this.geometry.getKernelGeometry(), edgeId, t, serializeOptions(options)));
|
|
5889
6017
|
}
|
|
6018
|
+
/**
|
|
6019
|
+
* Splits an edge at parametric position `t`.
|
|
6020
|
+
*/
|
|
5890
6021
|
splitEdge(edgeId, t, options) {
|
|
5891
6022
|
return parseEditResult(this.editor.splitEdge(this.geometry.getKernelGeometry(), edgeId, t, serializeOptions(options)));
|
|
5892
6023
|
}
|
|
6024
|
+
/**
|
|
6025
|
+
* Creates a loop cut that propagates from the selected edge when possible.
|
|
6026
|
+
*/
|
|
5893
6027
|
loopCut(edgeId, t, options) {
|
|
5894
6028
|
return parseEditResult(this.editor.loopCut(this.geometry.getKernelGeometry(), edgeId, t, serializeOptions(options)));
|
|
5895
6029
|
}
|
|
6030
|
+
/**
|
|
6031
|
+
* Removes a vertex when the current topology allows the edit.
|
|
6032
|
+
*/
|
|
5896
6033
|
removeVertex(vertexId, options) {
|
|
5897
6034
|
return parseEditResult(this.editor.removeVertex(this.geometry.getKernelGeometry(), vertexId, serializeOptions(options)));
|
|
5898
6035
|
}
|
|
5899
6036
|
}
|
|
6037
|
+
/**
|
|
6038
|
+
* Convenience factory for creating a freeform editor around a geometry wrapper.
|
|
6039
|
+
*/
|
|
5900
6040
|
function createFreeformEditor(geometry) {
|
|
5901
6041
|
return new FreeformEditor(geometry);
|
|
5902
6042
|
}
|
|
@@ -5914,7 +6054,7 @@ function toPlainVector3(value) {
|
|
|
5914
6054
|
z: value.z,
|
|
5915
6055
|
};
|
|
5916
6056
|
}
|
|
5917
|
-
function cloneVector(vector, fallback) {
|
|
6057
|
+
function cloneVector$1(vector, fallback) {
|
|
5918
6058
|
var _a;
|
|
5919
6059
|
return (_a = vector === null || vector === void 0 ? void 0 : vector.clone()) !== null && _a !== void 0 ? _a : new Vector3(...fallback);
|
|
5920
6060
|
}
|
|
@@ -5928,10 +6068,10 @@ function normalizePlacement(placement) {
|
|
|
5928
6068
|
}
|
|
5929
6069
|
function toObjectTransformation(placement) {
|
|
5930
6070
|
return {
|
|
5931
|
-
anchor: cloneVector(placement.anchor, [0, 0, 0]),
|
|
5932
|
-
translation: cloneVector(placement.translation, [0, 0, 0]),
|
|
5933
|
-
rotation: cloneVector(placement.rotation, [0, 0, 0]),
|
|
5934
|
-
scale: cloneVector(placement.scale, [1, 1, 1]),
|
|
6071
|
+
anchor: cloneVector$1(placement.anchor, [0, 0, 0]),
|
|
6072
|
+
translation: cloneVector$1(placement.translation, [0, 0, 0]),
|
|
6073
|
+
rotation: cloneVector$1(placement.rotation, [0, 0, 0]),
|
|
6074
|
+
scale: cloneVector$1(placement.scale, [1, 1, 1]),
|
|
5935
6075
|
};
|
|
5936
6076
|
}
|
|
5937
6077
|
function toPlainObjectTransformation(transform) {
|
|
@@ -5942,7 +6082,7 @@ function toPlainObjectTransformation(transform) {
|
|
|
5942
6082
|
scale: toPlainVector3(transform.scale),
|
|
5943
6083
|
};
|
|
5944
6084
|
}
|
|
5945
|
-
function serializeBrepLike$
|
|
6085
|
+
function serializeBrepLike$2(value) {
|
|
5946
6086
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
5947
6087
|
}
|
|
5948
6088
|
function normalizeFreeformSerialized(source) {
|
|
@@ -5953,56 +6093,119 @@ function normalizeFreeformSerialized(source) {
|
|
|
5953
6093
|
return source.getLocalBrepSerialized();
|
|
5954
6094
|
}
|
|
5955
6095
|
if (typeof source.getLocalBrepData === "function") {
|
|
5956
|
-
return serializeBrepLike$
|
|
6096
|
+
return serializeBrepLike$2(source.getLocalBrepData());
|
|
5957
6097
|
}
|
|
5958
6098
|
if (typeof source.getBrepSerialized === "function") {
|
|
5959
6099
|
return source.getBrepSerialized();
|
|
5960
6100
|
}
|
|
5961
6101
|
if (typeof source.getBrepData === "function") {
|
|
5962
|
-
return serializeBrepLike$
|
|
6102
|
+
return serializeBrepLike$2(source.getBrepData());
|
|
5963
6103
|
}
|
|
5964
6104
|
if (typeof source.getBrep === "function") {
|
|
5965
|
-
return serializeBrepLike$
|
|
6105
|
+
return serializeBrepLike$2(source.getBrep());
|
|
5966
6106
|
}
|
|
5967
6107
|
return JSON.stringify(source);
|
|
5968
6108
|
}
|
|
6109
|
+
/**
|
|
6110
|
+
* Thin client-side wrapper around the kernel `OGFreeformGeometry` object.
|
|
6111
|
+
*/
|
|
5969
6112
|
class FreeformGeometry {
|
|
5970
6113
|
constructor(geometry) {
|
|
5971
6114
|
this.geometry = geometry;
|
|
5972
6115
|
}
|
|
6116
|
+
/**
|
|
6117
|
+
* Returns the stable kernel-side id for this freeform geometry object.
|
|
6118
|
+
*/
|
|
5973
6119
|
getId() {
|
|
5974
6120
|
return this.geometry.id;
|
|
5975
6121
|
}
|
|
6122
|
+
/**
|
|
6123
|
+
* Returns the world-space serialized BRep payload.
|
|
6124
|
+
*/
|
|
5976
6125
|
getBrepSerialized() {
|
|
5977
6126
|
return this.geometry.getBrepSerialized();
|
|
5978
6127
|
}
|
|
6128
|
+
/**
|
|
6129
|
+
* Returns the local-space serialized BRep payload.
|
|
6130
|
+
*/
|
|
5979
6131
|
getLocalBrepSerialized() {
|
|
5980
6132
|
return this.geometry.getLocalBrepSerialized();
|
|
5981
6133
|
}
|
|
6134
|
+
/**
|
|
6135
|
+
* Returns the serialized triangle position buffer emitted by the kernel.
|
|
6136
|
+
*/
|
|
5982
6137
|
getGeometrySerialized() {
|
|
5983
6138
|
return this.geometry.getGeometrySerialized();
|
|
5984
6139
|
}
|
|
6140
|
+
/**
|
|
6141
|
+
* Returns world-space triangle positions as a plain number array.
|
|
6142
|
+
*/
|
|
6143
|
+
getGeometryBuffer() {
|
|
6144
|
+
return Array.from(this.geometry.getGeometryBuffer());
|
|
6145
|
+
}
|
|
6146
|
+
/**
|
|
6147
|
+
* Returns local-space triangle positions as a plain number array.
|
|
6148
|
+
*/
|
|
6149
|
+
getLocalGeometryBuffer() {
|
|
6150
|
+
return Array.from(this.geometry.getLocalGeometryBuffer());
|
|
6151
|
+
}
|
|
6152
|
+
/**
|
|
6153
|
+
* Returns the serialized outline buffer emitted by the kernel.
|
|
6154
|
+
*/
|
|
5985
6155
|
getOutlineGeometrySerialized() {
|
|
5986
6156
|
return this.geometry.getOutlineGeometrySerialized();
|
|
5987
6157
|
}
|
|
6158
|
+
/**
|
|
6159
|
+
* Returns world-space outline segment positions as a plain number array.
|
|
6160
|
+
*/
|
|
6161
|
+
getOutlineGeometryBuffer() {
|
|
6162
|
+
return Array.from(this.geometry.getOutlineGeometryBuffer());
|
|
6163
|
+
}
|
|
6164
|
+
/**
|
|
6165
|
+
* Returns local-space outline segment positions as a plain number array.
|
|
6166
|
+
*/
|
|
6167
|
+
getLocalOutlineGeometryBuffer() {
|
|
6168
|
+
return Array.from(this.geometry.getLocalOutlineGeometryBuffer());
|
|
6169
|
+
}
|
|
6170
|
+
/**
|
|
6171
|
+
* Returns the current normalized placement for this freeform geometry.
|
|
6172
|
+
*/
|
|
5988
6173
|
getPlacement() {
|
|
5989
6174
|
return normalizePlacement(parseJson(this.geometry.getPlacementSerialized()));
|
|
5990
6175
|
}
|
|
6176
|
+
/**
|
|
6177
|
+
* Replaces the full placement transform in one call.
|
|
6178
|
+
*/
|
|
5991
6179
|
setPlacement(transform) {
|
|
5992
6180
|
this.geometry.setPlacementSerialized(JSON.stringify(toPlainObjectTransformation(transform)));
|
|
5993
6181
|
}
|
|
6182
|
+
/**
|
|
6183
|
+
* Sets translation, rotation, and scale without changing the current anchor.
|
|
6184
|
+
*/
|
|
5994
6185
|
setTransform(translation, rotation, scale) {
|
|
5995
6186
|
this.geometry.setTransform(translation, rotation, scale);
|
|
5996
6187
|
}
|
|
6188
|
+
/**
|
|
6189
|
+
* Updates only the translation component of the placement.
|
|
6190
|
+
*/
|
|
5997
6191
|
setTranslation(translation) {
|
|
5998
6192
|
this.geometry.setTranslation(translation);
|
|
5999
6193
|
}
|
|
6194
|
+
/**
|
|
6195
|
+
* Updates only the rotation component of the placement.
|
|
6196
|
+
*/
|
|
6000
6197
|
setRotation(rotation) {
|
|
6001
6198
|
this.geometry.setRotation(rotation);
|
|
6002
6199
|
}
|
|
6200
|
+
/**
|
|
6201
|
+
* Updates only the scale component of the placement.
|
|
6202
|
+
*/
|
|
6003
6203
|
setScale(scale) {
|
|
6004
6204
|
this.geometry.setScale(scale);
|
|
6005
6205
|
}
|
|
6206
|
+
/**
|
|
6207
|
+
* Updates the explicit modeling anchor used by downstream transforms.
|
|
6208
|
+
*/
|
|
6006
6209
|
setAnchor(anchor) {
|
|
6007
6210
|
this.geometry.setAnchor(anchor);
|
|
6008
6211
|
}
|
|
@@ -6011,6 +6214,10 @@ class FreeformGeometry {
|
|
|
6011
6214
|
return this.geometry;
|
|
6012
6215
|
}
|
|
6013
6216
|
}
|
|
6217
|
+
/**
|
|
6218
|
+
* Creates a `FreeformGeometry` wrapper from serialized BRep JSON, a parsed
|
|
6219
|
+
* BRep object, or another wrapper exposing BRep accessors.
|
|
6220
|
+
*/
|
|
6014
6221
|
function createFreeformGeometry(source, options) {
|
|
6015
6222
|
var _a;
|
|
6016
6223
|
const id = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : `freeform-${Date.now()}`;
|
|
@@ -6246,6 +6453,9 @@ class Line extends THREE.Line {
|
|
|
6246
6453
|
}
|
|
6247
6454
|
|
|
6248
6455
|
/* eslint-enable no-unused-vars */
|
|
6456
|
+
/**
|
|
6457
|
+
* Polyline wrapper backed by the kernel OGPolyline primitive.
|
|
6458
|
+
*/
|
|
6249
6459
|
class Polyline extends THREE.Line {
|
|
6250
6460
|
set color(color) {
|
|
6251
6461
|
this.options.color = color;
|
|
@@ -6473,6 +6683,9 @@ class Polyline extends THREE.Line {
|
|
|
6473
6683
|
}
|
|
6474
6684
|
}
|
|
6475
6685
|
|
|
6686
|
+
/**
|
|
6687
|
+
* Arc wrapper backed by the kernel OGArc primitive.
|
|
6688
|
+
*/
|
|
6476
6689
|
class Arc extends THREE.Line {
|
|
6477
6690
|
set color(color) {
|
|
6478
6691
|
this.options.color = color;
|
|
@@ -6680,6 +6893,9 @@ class Arc extends THREE.Line {
|
|
|
6680
6893
|
}
|
|
6681
6894
|
|
|
6682
6895
|
/* eslint-enable no-unused-vars */
|
|
6896
|
+
/**
|
|
6897
|
+
* Rectangle wrapper backed by the kernel OGRectangle primitive.
|
|
6898
|
+
*/
|
|
6683
6899
|
class Rectangle extends THREE.Line {
|
|
6684
6900
|
// set width(width: number) {
|
|
6685
6901
|
// this.options.width = width;
|
|
@@ -6915,6 +7131,9 @@ class Rectangle extends THREE.Line {
|
|
|
6915
7131
|
}
|
|
6916
7132
|
|
|
6917
7133
|
/* eslint-enable no-unused-vars */
|
|
7134
|
+
/**
|
|
7135
|
+
* Curve wrapper backed by the kernel OGCurve primitive.
|
|
7136
|
+
*/
|
|
6918
7137
|
class Curve extends THREE.Line {
|
|
6919
7138
|
set color(color) {
|
|
6920
7139
|
this.options.color = color;
|
|
@@ -7075,12 +7294,18 @@ function getOutlineResolution() {
|
|
|
7075
7294
|
}
|
|
7076
7295
|
return new THREE.Vector2(window.innerWidth, window.innerHeight);
|
|
7077
7296
|
}
|
|
7297
|
+
/**
|
|
7298
|
+
* Clamps outline width inputs to the supported positive finite range.
|
|
7299
|
+
*/
|
|
7078
7300
|
function sanitizeOutlineWidth(width) {
|
|
7079
7301
|
if (!Number.isFinite(width) || typeof width !== "number" || width <= 0) {
|
|
7080
7302
|
return DEFAULT_OUTLINE_WIDTH;
|
|
7081
7303
|
}
|
|
7082
7304
|
return width;
|
|
7083
7305
|
}
|
|
7306
|
+
/**
|
|
7307
|
+
* Creates either a thin or fat outline mesh from line segment positions.
|
|
7308
|
+
*/
|
|
7084
7309
|
function createShapeOutlineMesh({ positions, color = DEFAULT_OUTLINE_COLOR, fatOutlines = false, outlineWidth = DEFAULT_OUTLINE_WIDTH, }) {
|
|
7085
7310
|
if (fatOutlines) {
|
|
7086
7311
|
const fatGeometry = new LineSegmentsGeometry();
|
|
@@ -7099,6 +7324,9 @@ function createShapeOutlineMesh({ positions, color = DEFAULT_OUTLINE_COLOR, fatO
|
|
|
7099
7324
|
const outlineMaterial = new THREE.LineBasicMaterial({ color });
|
|
7100
7325
|
return new THREE.LineSegments(outlineGeometry, outlineMaterial);
|
|
7101
7326
|
}
|
|
7327
|
+
/**
|
|
7328
|
+
* Disposes the geometry and material owned by an outline mesh.
|
|
7329
|
+
*/
|
|
7102
7330
|
function disposeShapeOutlineMesh(mesh) {
|
|
7103
7331
|
if (!mesh) {
|
|
7104
7332
|
return;
|
|
@@ -7110,6 +7338,9 @@ function disposeShapeOutlineMesh(mesh) {
|
|
|
7110
7338
|
}
|
|
7111
7339
|
mesh.material.dispose();
|
|
7112
7340
|
}
|
|
7341
|
+
/**
|
|
7342
|
+
* Updates the color of an existing outline mesh in place.
|
|
7343
|
+
*/
|
|
7113
7344
|
function setShapeOutlineColor(mesh, color) {
|
|
7114
7345
|
if (!mesh) {
|
|
7115
7346
|
return;
|
|
@@ -7122,6 +7353,9 @@ function setShapeOutlineColor(mesh, color) {
|
|
|
7122
7353
|
mesh.material.color.set(color);
|
|
7123
7354
|
}
|
|
7124
7355
|
}
|
|
7356
|
+
/**
|
|
7357
|
+
* Reads the current outline color, falling back when no outline exists.
|
|
7358
|
+
*/
|
|
7125
7359
|
function getShapeOutlineColor(mesh, fallback = DEFAULT_OUTLINE_COLOR) {
|
|
7126
7360
|
if (!mesh) {
|
|
7127
7361
|
return fallback;
|
|
@@ -7135,6 +7369,42 @@ function getShapeOutlineColor(mesh, fallback = DEFAULT_OUTLINE_COLOR) {
|
|
|
7135
7369
|
return fallback;
|
|
7136
7370
|
}
|
|
7137
7371
|
|
|
7372
|
+
/**
|
|
7373
|
+
* Extrudes the first face or wire in a local BRep payload into a closed solid BRep.
|
|
7374
|
+
*/
|
|
7375
|
+
function extrudeBrepFace(source, height) {
|
|
7376
|
+
const extrudeExport = extrudeBrepFace$1;
|
|
7377
|
+
if (typeof extrudeExport !== "function") {
|
|
7378
|
+
throw new Error("extrudeBrepFace is not available in the loaded wasm package. Rebuild opengeometry wasm bindings.");
|
|
7379
|
+
}
|
|
7380
|
+
const kernelFunction = extrudeExport;
|
|
7381
|
+
return kernelFunction(resolveLocalBrepSerialized(source), height);
|
|
7382
|
+
}
|
|
7383
|
+
function resolveLocalBrepSerialized(source) {
|
|
7384
|
+
if (typeof source === "string") {
|
|
7385
|
+
return source;
|
|
7386
|
+
}
|
|
7387
|
+
if (typeof source.getLocalBrepSerialized === "function") {
|
|
7388
|
+
return source.getLocalBrepSerialized();
|
|
7389
|
+
}
|
|
7390
|
+
if (typeof source.getLocalBrepData === "function") {
|
|
7391
|
+
return serializeBrepLike$1(source.getLocalBrepData());
|
|
7392
|
+
}
|
|
7393
|
+
if (typeof source.getBrepSerialized === "function") {
|
|
7394
|
+
return source.getBrepSerialized();
|
|
7395
|
+
}
|
|
7396
|
+
if (typeof source.getBrepData === "function") {
|
|
7397
|
+
return serializeBrepLike$1(source.getBrepData());
|
|
7398
|
+
}
|
|
7399
|
+
if (typeof source.getBrep === "function") {
|
|
7400
|
+
return serializeBrepLike$1(source.getBrep());
|
|
7401
|
+
}
|
|
7402
|
+
return JSON.stringify(source);
|
|
7403
|
+
}
|
|
7404
|
+
function serializeBrepLike$1(value) {
|
|
7405
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
7406
|
+
}
|
|
7407
|
+
|
|
7138
7408
|
var _BooleanResult_outlineMesh;
|
|
7139
7409
|
/* eslint-enable no-unused-vars */
|
|
7140
7410
|
const BOOLEAN_CREASE_ANGLE = Math.PI / 5;
|
|
@@ -7376,7 +7646,279 @@ function subtractShapeOperand(host, operand, options) {
|
|
|
7376
7646
|
return booleanSubtraction(host, operand, options);
|
|
7377
7647
|
}
|
|
7378
7648
|
|
|
7649
|
+
var _Solid_outlineMesh;
|
|
7650
|
+
/**
|
|
7651
|
+
* Generic renderable BRep-backed solid used for extrusion outputs and other
|
|
7652
|
+
* kernel results that are not dedicated parametric shapes.
|
|
7653
|
+
*/
|
|
7654
|
+
class Solid extends THREE.Mesh {
|
|
7655
|
+
set color(color) {
|
|
7656
|
+
this.options.color = color;
|
|
7657
|
+
if (this.material instanceof THREE.MeshStandardMaterial) {
|
|
7658
|
+
this.material.color.set(color);
|
|
7659
|
+
}
|
|
7660
|
+
}
|
|
7661
|
+
get color() {
|
|
7662
|
+
return this.options.color;
|
|
7663
|
+
}
|
|
7664
|
+
constructor(options) {
|
|
7665
|
+
var _a, _b;
|
|
7666
|
+
super();
|
|
7667
|
+
this.options = {
|
|
7668
|
+
brep: "{}",
|
|
7669
|
+
color: 0x00ff00,
|
|
7670
|
+
fatOutlines: false,
|
|
7671
|
+
outlineWidth: 1,
|
|
7672
|
+
anchor: new Vector3(0, 0, 0),
|
|
7673
|
+
translation: new Vector3(0, 0, 0),
|
|
7674
|
+
rotation: new Vector3(0, 0, 0),
|
|
7675
|
+
scale: new Vector3(1, 1, 1),
|
|
7676
|
+
};
|
|
7677
|
+
_Solid_outlineMesh.set(this, null);
|
|
7678
|
+
this._outlineEnabled = false;
|
|
7679
|
+
this._fatOutlines = false;
|
|
7680
|
+
this._outlineWidth = 1;
|
|
7681
|
+
this._outlineColor = 0x000000;
|
|
7682
|
+
this.ogid = (_a = options.ogid) !== null && _a !== void 0 ? _a : getUUID();
|
|
7683
|
+
this.options = Object.assign(Object.assign(Object.assign({}, this.options), options), { ogid: this.ogid, anchor: cloneVector(options.anchor, [0, 0, 0]), translation: cloneVector(options.translation, [0, 0, 0]), rotation: cloneVector(options.rotation, [0, 0, 0]), scale: cloneVector(options.scale, [1, 1, 1]) });
|
|
7684
|
+
this._fatOutlines = (_b = this.options.fatOutlines) !== null && _b !== void 0 ? _b : false;
|
|
7685
|
+
this._outlineWidth = sanitizeOutlineWidth(this.options.outlineWidth);
|
|
7686
|
+
this.options.fatOutlines = this._fatOutlines;
|
|
7687
|
+
this.options.outlineWidth = this._outlineWidth;
|
|
7688
|
+
this.solid = createFreeformGeometry(this.options.brep, {
|
|
7689
|
+
id: this.ogid,
|
|
7690
|
+
placement: this.getPlacementTransform(),
|
|
7691
|
+
});
|
|
7692
|
+
this.generateGeometry();
|
|
7693
|
+
}
|
|
7694
|
+
/**
|
|
7695
|
+
* Extrudes a face-like BRep source and wraps the result as a renderable solid.
|
|
7696
|
+
*/
|
|
7697
|
+
static extrude(source, height, options) {
|
|
7698
|
+
return new Solid(Object.assign(Object.assign({}, options), { brep: extrudeBrepFace(source, height) }));
|
|
7699
|
+
}
|
|
7700
|
+
/**
|
|
7701
|
+
* Returns the current placement values as cloned vectors.
|
|
7702
|
+
*/
|
|
7703
|
+
getPlacement() {
|
|
7704
|
+
return clonePlacement(this.getPlacementTransform());
|
|
7705
|
+
}
|
|
7706
|
+
/**
|
|
7707
|
+
* Applies translation, rotation, and scale updates to the wrapped BRep.
|
|
7708
|
+
*/
|
|
7709
|
+
setPlacement(placement) {
|
|
7710
|
+
var _a, _b, _c;
|
|
7711
|
+
this.options.translation = cloneVector((_a = placement.translation) !== null && _a !== void 0 ? _a : this.options.translation, [0, 0, 0]);
|
|
7712
|
+
this.options.rotation = cloneVector((_b = placement.rotation) !== null && _b !== void 0 ? _b : this.options.rotation, [0, 0, 0]);
|
|
7713
|
+
this.options.scale = cloneVector((_c = placement.scale) !== null && _c !== void 0 ? _c : this.options.scale, [1, 1, 1]);
|
|
7714
|
+
this.solid.setPlacement(this.getPlacementTransform());
|
|
7715
|
+
this.generateGeometry();
|
|
7716
|
+
}
|
|
7717
|
+
setTransform(translation, rotation, scale) {
|
|
7718
|
+
this.setPlacement({
|
|
7719
|
+
translation,
|
|
7720
|
+
rotation,
|
|
7721
|
+
scale,
|
|
7722
|
+
});
|
|
7723
|
+
}
|
|
7724
|
+
setTranslation(translation) {
|
|
7725
|
+
this.setPlacement({ translation });
|
|
7726
|
+
}
|
|
7727
|
+
setRotation(rotation) {
|
|
7728
|
+
this.setPlacement({ rotation });
|
|
7729
|
+
}
|
|
7730
|
+
setScale(scale) {
|
|
7731
|
+
this.setPlacement({ scale });
|
|
7732
|
+
}
|
|
7733
|
+
getAnchor() {
|
|
7734
|
+
return this.getPlacementTransform().anchor.clone();
|
|
7735
|
+
}
|
|
7736
|
+
setAnchor(anchor) {
|
|
7737
|
+
this.options.anchor = anchor.clone();
|
|
7738
|
+
this.solid.setPlacement(this.getPlacementTransform());
|
|
7739
|
+
this.generateGeometry();
|
|
7740
|
+
}
|
|
7741
|
+
/**
|
|
7742
|
+
* Solid is always convertible back to the freeform editing wrapper.
|
|
7743
|
+
*/
|
|
7744
|
+
canConvertToFreeform() {
|
|
7745
|
+
return true;
|
|
7746
|
+
}
|
|
7747
|
+
/**
|
|
7748
|
+
* Returns a freeform wrapper for direct editing of this solid's BRep.
|
|
7749
|
+
*/
|
|
7750
|
+
toFreeform(id = this.ogid) {
|
|
7751
|
+
if (!this.canConvertToFreeform()) {
|
|
7752
|
+
throw new Error("This entity cannot be converted to freeform.");
|
|
7753
|
+
}
|
|
7754
|
+
return createFreeformGeometry(this.getLocalBrepSerialized(), {
|
|
7755
|
+
id,
|
|
7756
|
+
placement: this.getPlacementTransform(),
|
|
7757
|
+
});
|
|
7758
|
+
}
|
|
7759
|
+
/**
|
|
7760
|
+
* Returns the world-space serialized BRep payload for this solid.
|
|
7761
|
+
*/
|
|
7762
|
+
getBrepSerialized() {
|
|
7763
|
+
return this.solid.getBrepSerialized();
|
|
7764
|
+
}
|
|
7765
|
+
/**
|
|
7766
|
+
* Returns the local-space serialized BRep payload for this solid.
|
|
7767
|
+
*/
|
|
7768
|
+
getLocalBrepSerialized() {
|
|
7769
|
+
return this.solid.getLocalBrepSerialized();
|
|
7770
|
+
}
|
|
7771
|
+
/**
|
|
7772
|
+
* Returns the parsed world-space BRep object for this solid.
|
|
7773
|
+
*/
|
|
7774
|
+
getBrepData() {
|
|
7775
|
+
const brepSerialized = this.getBrepSerialized();
|
|
7776
|
+
if (!brepSerialized) {
|
|
7777
|
+
throw new Error("Brep data is not available for this solid.");
|
|
7778
|
+
}
|
|
7779
|
+
return JSON.parse(brepSerialized);
|
|
7780
|
+
}
|
|
7781
|
+
/**
|
|
7782
|
+
* Subtracts another boolean operand from this solid.
|
|
7783
|
+
*/
|
|
7784
|
+
subtract(operand, options) {
|
|
7785
|
+
return subtractShapeOperand(this, operand, options);
|
|
7786
|
+
}
|
|
7787
|
+
/**
|
|
7788
|
+
* Rebuilds the visible mesh and outline from the current freeform geometry.
|
|
7789
|
+
*/
|
|
7790
|
+
generateGeometry() {
|
|
7791
|
+
var _a;
|
|
7792
|
+
const bufferData = this.solid.getGeometryBuffer();
|
|
7793
|
+
this.writePositionsToGeometry(this.geometry, bufferData);
|
|
7794
|
+
if (this.material instanceof THREE.MeshStandardMaterial) {
|
|
7795
|
+
this.material.color.set(this.options.color);
|
|
7796
|
+
this.material.transparent = true;
|
|
7797
|
+
this.material.opacity = 0.6;
|
|
7798
|
+
}
|
|
7799
|
+
else {
|
|
7800
|
+
if (Array.isArray(this.material)) {
|
|
7801
|
+
this.material.forEach((material) => material.dispose());
|
|
7802
|
+
}
|
|
7803
|
+
else {
|
|
7804
|
+
this.material.dispose();
|
|
7805
|
+
}
|
|
7806
|
+
this.material = new THREE.MeshStandardMaterial({
|
|
7807
|
+
color: this.options.color,
|
|
7808
|
+
transparent: true,
|
|
7809
|
+
opacity: 0.6,
|
|
7810
|
+
});
|
|
7811
|
+
}
|
|
7812
|
+
if (bufferData.length > 0) {
|
|
7813
|
+
this.geometry.computeVertexNormals();
|
|
7814
|
+
this.geometry.computeBoundingBox();
|
|
7815
|
+
this.geometry.computeBoundingSphere();
|
|
7816
|
+
}
|
|
7817
|
+
else {
|
|
7818
|
+
this.geometry.deleteAttribute("normal");
|
|
7819
|
+
this.geometry.boundingBox = null;
|
|
7820
|
+
this.geometry.boundingSphere = null;
|
|
7821
|
+
}
|
|
7822
|
+
if (!this._outlineEnabled) {
|
|
7823
|
+
return;
|
|
7824
|
+
}
|
|
7825
|
+
const outlineData = this.solid.getOutlineGeometryBuffer();
|
|
7826
|
+
if (!__classPrivateFieldGet(this, _Solid_outlineMesh, "f")) {
|
|
7827
|
+
this.outline = true;
|
|
7828
|
+
return;
|
|
7829
|
+
}
|
|
7830
|
+
if (__classPrivateFieldGet(this, _Solid_outlineMesh, "f") instanceof THREE.LineSegments) {
|
|
7831
|
+
this.writePositionsToGeometry(__classPrivateFieldGet(this, _Solid_outlineMesh, "f").geometry, outlineData);
|
|
7832
|
+
__classPrivateFieldGet(this, _Solid_outlineMesh, "f").geometry.computeBoundingBox();
|
|
7833
|
+
__classPrivateFieldGet(this, _Solid_outlineMesh, "f").geometry.computeBoundingSphere();
|
|
7834
|
+
return;
|
|
7835
|
+
}
|
|
7836
|
+
const fatGeometry = __classPrivateFieldGet(this, _Solid_outlineMesh, "f").geometry;
|
|
7837
|
+
fatGeometry.setPositions(outlineData);
|
|
7838
|
+
const fatOutline = __classPrivateFieldGet(this, _Solid_outlineMesh, "f");
|
|
7839
|
+
(_a = fatOutline.computeLineDistances) === null || _a === void 0 ? void 0 : _a.call(fatOutline);
|
|
7840
|
+
}
|
|
7841
|
+
set outlineColor(color) {
|
|
7842
|
+
this._outlineColor = color;
|
|
7843
|
+
setShapeOutlineColor(__classPrivateFieldGet(this, _Solid_outlineMesh, "f"), color);
|
|
7844
|
+
}
|
|
7845
|
+
get outlineColor() {
|
|
7846
|
+
return getShapeOutlineColor(__classPrivateFieldGet(this, _Solid_outlineMesh, "f"), this._outlineColor);
|
|
7847
|
+
}
|
|
7848
|
+
set outline(enable) {
|
|
7849
|
+
this._outlineEnabled = enable;
|
|
7850
|
+
this.clearOutlineMesh();
|
|
7851
|
+
if (enable) {
|
|
7852
|
+
__classPrivateFieldSet(this, _Solid_outlineMesh, createShapeOutlineMesh({
|
|
7853
|
+
positions: this.solid.getOutlineGeometryBuffer(),
|
|
7854
|
+
color: this._outlineColor,
|
|
7855
|
+
fatOutlines: this._fatOutlines,
|
|
7856
|
+
outlineWidth: this._outlineWidth,
|
|
7857
|
+
}), "f");
|
|
7858
|
+
this.add(__classPrivateFieldGet(this, _Solid_outlineMesh, "f"));
|
|
7859
|
+
}
|
|
7860
|
+
}
|
|
7861
|
+
get outline() {
|
|
7862
|
+
return this._outlineEnabled;
|
|
7863
|
+
}
|
|
7864
|
+
set fatOutlines(value) {
|
|
7865
|
+
this._fatOutlines = value;
|
|
7866
|
+
this.options.fatOutlines = value;
|
|
7867
|
+
if (this._outlineEnabled) {
|
|
7868
|
+
this.outline = true;
|
|
7869
|
+
}
|
|
7870
|
+
}
|
|
7871
|
+
get fatOutlines() {
|
|
7872
|
+
return this._fatOutlines;
|
|
7873
|
+
}
|
|
7874
|
+
set outlineWidth(value) {
|
|
7875
|
+
this._outlineWidth = sanitizeOutlineWidth(value);
|
|
7876
|
+
this.options.outlineWidth = this._outlineWidth;
|
|
7877
|
+
if (this._outlineEnabled) {
|
|
7878
|
+
this.outline = true;
|
|
7879
|
+
}
|
|
7880
|
+
}
|
|
7881
|
+
get outlineWidth() {
|
|
7882
|
+
return this._outlineWidth;
|
|
7883
|
+
}
|
|
7884
|
+
clearOutlineMesh() {
|
|
7885
|
+
if (!__classPrivateFieldGet(this, _Solid_outlineMesh, "f")) {
|
|
7886
|
+
return;
|
|
7887
|
+
}
|
|
7888
|
+
this.remove(__classPrivateFieldGet(this, _Solid_outlineMesh, "f"));
|
|
7889
|
+
disposeShapeOutlineMesh(__classPrivateFieldGet(this, _Solid_outlineMesh, "f"));
|
|
7890
|
+
__classPrivateFieldSet(this, _Solid_outlineMesh, null, "f");
|
|
7891
|
+
}
|
|
7892
|
+
getPlacementTransform() {
|
|
7893
|
+
return toObjectTransformation$1({
|
|
7894
|
+
anchor: cloneVector(this.options.anchor, [0, 0, 0]),
|
|
7895
|
+
translation: cloneVector(this.options.translation, [0, 0, 0]),
|
|
7896
|
+
rotation: cloneVector(this.options.rotation, [0, 0, 0]),
|
|
7897
|
+
scale: cloneVector(this.options.scale, [1, 1, 1]),
|
|
7898
|
+
});
|
|
7899
|
+
}
|
|
7900
|
+
writePositionsToGeometry(geometry, positions) {
|
|
7901
|
+
const attribute = geometry.getAttribute("position");
|
|
7902
|
+
if (!(attribute instanceof THREE.BufferAttribute) ||
|
|
7903
|
+
attribute.itemSize !== 3 ||
|
|
7904
|
+
attribute.count !== positions.length / 3) {
|
|
7905
|
+
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
|
|
7906
|
+
return;
|
|
7907
|
+
}
|
|
7908
|
+
attribute.array.set(positions);
|
|
7909
|
+
attribute.needsUpdate = true;
|
|
7910
|
+
}
|
|
7911
|
+
}
|
|
7912
|
+
_Solid_outlineMesh = new WeakMap();
|
|
7913
|
+
function cloneVector(vector, fallback) {
|
|
7914
|
+
var _a;
|
|
7915
|
+
return (_a = vector === null || vector === void 0 ? void 0 : vector.clone()) !== null && _a !== void 0 ? _a : new Vector3(...fallback);
|
|
7916
|
+
}
|
|
7917
|
+
|
|
7379
7918
|
var _Polygon_outlineMesh;
|
|
7919
|
+
/**
|
|
7920
|
+
* Planar polygon mesh with support for holes, booleans, and extrusion to `Solid`.
|
|
7921
|
+
*/
|
|
7380
7922
|
class Polygon extends THREE.Mesh {
|
|
7381
7923
|
set color(color) {
|
|
7382
7924
|
this.options.color = color;
|
|
@@ -7387,8 +7929,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7387
7929
|
get color() {
|
|
7388
7930
|
return this.options.color;
|
|
7389
7931
|
}
|
|
7390
|
-
// TODO: Make Options Optional
|
|
7391
|
-
// constructor(vertices?: Vector3[]) // If no vertices are provided, it will be an empty polygon
|
|
7392
7932
|
constructor(options) {
|
|
7393
7933
|
var _a, _b, _c, _d, _e;
|
|
7394
7934
|
super();
|
|
@@ -7407,12 +7947,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7407
7947
|
this._fatOutlines = false;
|
|
7408
7948
|
this._outlineWidth = 1;
|
|
7409
7949
|
this._outlineColor = 0x000000;
|
|
7410
|
-
this.transformationMatrix = new THREE.Matrix4();
|
|
7411
|
-
// private _placement: THREE.Vector3 = new THREE.Vector3(0, 0, 0);
|
|
7412
|
-
// private _yaw: number = 0;
|
|
7413
|
-
// Store local center offset to align outlines
|
|
7414
|
-
// TODO: Can this be moved to Engine? It can increase performance | Needs to be used in other shapes too
|
|
7415
|
-
this._geometryCenterOffset = new THREE.Vector3();
|
|
7416
7950
|
this.ogid = (_a = options === null || options === void 0 ? void 0 : options.ogid) !== null && _a !== void 0 ? _a : getUUID();
|
|
7417
7951
|
this.polygon = new OGPolygon(this.ogid);
|
|
7418
7952
|
this.options = Object.assign(Object.assign({}, this.options), options);
|
|
@@ -7429,19 +7963,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7429
7963
|
rotation: (_d = this.options.rotation) === null || _d === void 0 ? void 0 : _d.clone(),
|
|
7430
7964
|
scale: (_e = this.options.scale) === null || _e === void 0 ? void 0 : _e.clone(),
|
|
7431
7965
|
});
|
|
7432
|
-
// TODO: THIS MIGHT HELP WITH SHARING THE POSITION with KERNEL when something is changed
|
|
7433
|
-
// const originalSet = this.position.set.bind(this.position);
|
|
7434
|
-
// this.position.set = (x: number, y: number, z: number) => {
|
|
7435
|
-
// console.log(`Position set to (${x}, ${y}, ${z})`);
|
|
7436
|
-
// // your custom logic here (e.g., notify OpenGeometry)
|
|
7437
|
-
// return originalSet(x, y, z);
|
|
7438
|
-
// };
|
|
7439
|
-
// // Optional: Override copy if you're using .copy() too
|
|
7440
|
-
// const originalCopy = this.position.copy.bind(this.position);
|
|
7441
|
-
// this.position.copy = (v: THREE.Vector3) => {
|
|
7442
|
-
// console.log(`Position copied from ${v.x}, ${v.y}, ${v.z}`);
|
|
7443
|
-
// return originalCopy(v);
|
|
7444
|
-
// };
|
|
7445
7966
|
}
|
|
7446
7967
|
validateOptions() {
|
|
7447
7968
|
if (!this.options) {
|
|
@@ -7523,12 +8044,21 @@ class Polygon extends THREE.Mesh {
|
|
|
7523
8044
|
scale: this.options.scale,
|
|
7524
8045
|
});
|
|
7525
8046
|
}
|
|
8047
|
+
/**
|
|
8048
|
+
* Returns the editing capability payload advertised by parametric wrappers.
|
|
8049
|
+
*/
|
|
7526
8050
|
getEditCapabilities() {
|
|
7527
8051
|
return createParametricEditCapabilities("polygon", "profile");
|
|
7528
8052
|
}
|
|
8053
|
+
/**
|
|
8054
|
+
* Polygon always supports conversion into the freeform editing wrapper.
|
|
8055
|
+
*/
|
|
7529
8056
|
canConvertToFreeform() {
|
|
7530
8057
|
return true;
|
|
7531
8058
|
}
|
|
8059
|
+
/**
|
|
8060
|
+
* Returns a freeform wrapper for direct BRep editing of this polygon.
|
|
8061
|
+
*/
|
|
7532
8062
|
toFreeform(id = this.ogid) {
|
|
7533
8063
|
if (!this.canConvertToFreeform()) {
|
|
7534
8064
|
throw new Error("This entity cannot be converted to freeform.");
|
|
@@ -7538,62 +8068,8 @@ class Polygon extends THREE.Mesh {
|
|
|
7538
8068
|
placement: this.getPlacement(),
|
|
7539
8069
|
});
|
|
7540
8070
|
}
|
|
7541
|
-
// /**
|
|
7542
|
-
// * Sets the placement of the polygon in 3D space.
|
|
7543
|
-
// * @param x X-coordinate
|
|
7544
|
-
// * @param y Y-coordinate
|
|
7545
|
-
// * @param z Z-coordinate
|
|
7546
|
-
// */
|
|
7547
|
-
// placement(x: number, y: number, z: number) {
|
|
7548
|
-
// this._placement.set(x, y, z);
|
|
7549
|
-
// // Do the recalculation of position based on the placement
|
|
7550
|
-
// const clonedObject = this.clone();
|
|
7551
|
-
// clonedObject.rotation.set(0, 0, 0);
|
|
7552
|
-
// clonedObject.geometry.computeBoundingBox();
|
|
7553
|
-
// if (!clonedObject.geometry.boundingBox) return;
|
|
7554
|
-
// const center = new THREE.Vector3();
|
|
7555
|
-
// clonedObject.geometry.boundingBox.getCenter(center);
|
|
7556
|
-
// const min = clonedObject.geometry.boundingBox.min;
|
|
7557
|
-
// this.position.set(
|
|
7558
|
-
// center.x + this._placement.x - min.x,
|
|
7559
|
-
// // this._placement.y,
|
|
7560
|
-
// 0.01, // Set Y to a small value to avoid z-fighting
|
|
7561
|
-
// center.z + this._placement.z - min.z
|
|
7562
|
-
// );
|
|
7563
|
-
// }
|
|
7564
|
-
// positionToPlacement() {
|
|
7565
|
-
// const clonedObject = this.clone();
|
|
7566
|
-
// clonedObject.rotation.set(0, 0, 0);
|
|
7567
|
-
// clonedObject.geometry.computeBoundingBox();
|
|
7568
|
-
// if (!clonedObject.geometry.boundingBox) return;
|
|
7569
|
-
// const min = clonedObject.geometry.boundingBox.min;
|
|
7570
|
-
// this._placement.set(
|
|
7571
|
-
// this.position.x + min.x,
|
|
7572
|
-
// this.position.y + min.y,
|
|
7573
|
-
// this.position.z + min.z
|
|
7574
|
-
// );
|
|
7575
|
-
// // console.log("Placement set to:", this._placement.x, this._placement.y, this._placement.z);
|
|
7576
|
-
// }
|
|
7577
|
-
// /**
|
|
7578
|
-
// * Rotates the polygon around the Y-axis.
|
|
7579
|
-
// * @param angle Rotation angle in Degrees
|
|
7580
|
-
// */
|
|
7581
|
-
// set yaw(angle: number) {
|
|
7582
|
-
// this._yaw = angle;
|
|
7583
|
-
// this.rotation.set(0, 0, 0);
|
|
7584
|
-
// this.rotation.y = THREE.MathUtils.degToRad(this._yaw);
|
|
7585
|
-
// }
|
|
7586
|
-
// get yaw() {
|
|
7587
|
-
// return this._yaw;
|
|
7588
|
-
// }
|
|
7589
8071
|
cleanGeometry() {
|
|
7590
|
-
this.
|
|
7591
|
-
if (Array.isArray(this.material)) {
|
|
7592
|
-
this.material.forEach(mat => mat.dispose());
|
|
7593
|
-
}
|
|
7594
|
-
else {
|
|
7595
|
-
this.material.dispose();
|
|
7596
|
-
}
|
|
8072
|
+
this.disposeResources();
|
|
7597
8073
|
}
|
|
7598
8074
|
generateGeometry() {
|
|
7599
8075
|
var _a;
|
|
@@ -7643,24 +8119,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7643
8119
|
fatGeometry.setPositions(outlineData);
|
|
7644
8120
|
const fatOutline = __classPrivateFieldGet(this, _Polygon_outlineMesh, "f");
|
|
7645
8121
|
(_a = fatOutline.computeLineDistances) === null || _a === void 0 ? void 0 : _a.call(fatOutline);
|
|
7646
|
-
// this.geometry.computeBoundingBox();
|
|
7647
|
-
// const originalCenter = new THREE.Vector3();
|
|
7648
|
-
// this.geometry.boundingBox?.getCenter(originalCenter);
|
|
7649
|
-
// console.log("Original Center:", originalCenter.x, originalCenter.y, originalCenter.z);
|
|
7650
|
-
// this.geometry.center();
|
|
7651
|
-
// this.geometry.computeBoundingBox();
|
|
7652
|
-
// const newCenter = new THREE.Vector3();
|
|
7653
|
-
// this.geometry.boundingBox?.getCenter(newCenter);
|
|
7654
|
-
// console.log("New Center after centering:", newCenter.x, newCenter.y, newCenter.z);
|
|
7655
|
-
// if (!this.geometry.boundingBox) return;
|
|
7656
|
-
// const min = this.geometry.boundingBox.min;
|
|
7657
|
-
// // console.log("Position before centering:", this.position.x, this.position.y, this.position.z);
|
|
7658
|
-
// console.log("Bounding Box Min:", min.x, min.y, min.z);
|
|
7659
|
-
// this.position.set(-min.x, 0, -min.z);
|
|
7660
|
-
// if (this._placement) {
|
|
7661
|
-
// this.placement(this._placement.x, this._placement.y, this._placement.z);
|
|
7662
|
-
// }
|
|
7663
|
-
// console.log("New Position after centering:", this.position.x, this.position.y, this.position.z);
|
|
7664
8122
|
}
|
|
7665
8123
|
addVertices(vertices) {
|
|
7666
8124
|
if (!this.polygon)
|
|
@@ -7669,59 +8127,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7669
8127
|
vertices: vertices.map((vertex) => vertex.clone()),
|
|
7670
8128
|
});
|
|
7671
8129
|
}
|
|
7672
|
-
saveTransformationToBREP() {
|
|
7673
|
-
if (!this.polygon)
|
|
7674
|
-
return;
|
|
7675
|
-
}
|
|
7676
|
-
// /**
|
|
7677
|
-
// * Rotates the object around the Y-axis.
|
|
7678
|
-
// * @param angle Rotation angle in Degrees
|
|
7679
|
-
// * @returns
|
|
7680
|
-
// * @summary If rotation methods from threejs is used, it will rotate around the first vertex which might not be desired.
|
|
7681
|
-
// */
|
|
7682
|
-
// rotateOnYAxis(angle: number) {
|
|
7683
|
-
// if (!this.polygon) return;
|
|
7684
|
-
// }
|
|
7685
|
-
// resetVertices() {
|
|
7686
|
-
// if (!this.polygon) return;
|
|
7687
|
-
// this.layerVertices = [];
|
|
7688
|
-
// this.geometry.dispose();
|
|
7689
|
-
// this.polygon?.clear_vertices();
|
|
7690
|
-
// this.isTriangulated = false;
|
|
7691
|
-
// }
|
|
7692
|
-
// addVertex(threeVertex: Vector3) {
|
|
7693
|
-
// if (this.isTriangulated) {
|
|
7694
|
-
// this.layerVertices = [];
|
|
7695
|
-
// this.geometry.dispose();
|
|
7696
|
-
// this.polygon?.clear_vertices();
|
|
7697
|
-
// this.isTriangulated = false;
|
|
7698
|
-
// for (const vertex of this.layerBackVertices) {
|
|
7699
|
-
// this.layerVertices.push(vertex.clone());
|
|
7700
|
-
// }
|
|
7701
|
-
// };
|
|
7702
|
-
// const backupVertex = new Vector3(
|
|
7703
|
-
// parseFloat(threeVertex.x.toFixed(2)),
|
|
7704
|
-
// 0,
|
|
7705
|
-
// parseFloat(threeVertex.z.toFixed(2))
|
|
7706
|
-
// );
|
|
7707
|
-
// this.layerBackVertices.push(backupVertex);
|
|
7708
|
-
// const vertex = new Vector3(
|
|
7709
|
-
// parseFloat(threeVertex.x.toFixed(2)),
|
|
7710
|
-
// // when doing the parse operation getting -0 instead of 0
|
|
7711
|
-
// 0,
|
|
7712
|
-
// parseFloat(threeVertex.z.toFixed(2))
|
|
7713
|
-
// );
|
|
7714
|
-
// this.layerVertices.push(vertex);
|
|
7715
|
-
// if (this.layerVertices.length > 3) {
|
|
7716
|
-
// this.polygon?.add_vertices(this.layerVertices);
|
|
7717
|
-
// const bufFlush = this.polygon?.triangulate();
|
|
7718
|
-
// if (!bufFlush) {
|
|
7719
|
-
// return;
|
|
7720
|
-
// }
|
|
7721
|
-
// this.addFlushBufferToScene(bufFlush);
|
|
7722
|
-
// this.isTriangulated = true;
|
|
7723
|
-
// }
|
|
7724
|
-
// }
|
|
7725
8130
|
addHole(holeVertices) {
|
|
7726
8131
|
var _a, _b;
|
|
7727
8132
|
if (!this.polygon)
|
|
@@ -7734,29 +8139,29 @@ class Polygon extends THREE.Mesh {
|
|
|
7734
8139
|
holes: ((_b = this.options.holes) !== null && _b !== void 0 ? _b : []).map((hole) => hole.map((vertex) => vertex.clone())),
|
|
7735
8140
|
});
|
|
7736
8141
|
}
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
8142
|
+
/**
|
|
8143
|
+
* Builds a kernel-backed `Solid` by extruding this polygon face by `height`.
|
|
8144
|
+
*/
|
|
8145
|
+
extrude(height) {
|
|
8146
|
+
const config = this.getConfig();
|
|
8147
|
+
const placement = this.getPlacement();
|
|
8148
|
+
const solid = new Solid({
|
|
8149
|
+
brep: extrudeBrepFace(this.polygon.get_local_brep_serialized(), height),
|
|
8150
|
+
color: config.color,
|
|
8151
|
+
fatOutlines: config.fatOutlines,
|
|
8152
|
+
outlineWidth: config.outlineWidth,
|
|
8153
|
+
anchor: this.getAnchor(),
|
|
8154
|
+
translation: placement.translation.clone(),
|
|
8155
|
+
rotation: placement.rotation.clone(),
|
|
8156
|
+
scale: placement.scale.clone(),
|
|
8157
|
+
});
|
|
8158
|
+
solid.outline = this.outline;
|
|
8159
|
+
solid.outlineColor = this.outlineColor;
|
|
8160
|
+
return solid;
|
|
8161
|
+
}
|
|
8162
|
+
/**
|
|
8163
|
+
* Returns the serialized BRep payload for this polygon.
|
|
8164
|
+
*/
|
|
7760
8165
|
getBrepData() {
|
|
7761
8166
|
if (!this.polygon)
|
|
7762
8167
|
return null;
|
|
@@ -7776,7 +8181,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7776
8181
|
get outlineColor() {
|
|
7777
8182
|
return getShapeOutlineColor(__classPrivateFieldGet(this, _Polygon_outlineMesh, "f"), this._outlineColor);
|
|
7778
8183
|
}
|
|
7779
|
-
// TODO: Do we need a separate method for Hole Outlines?
|
|
7780
8184
|
set outline(enable) {
|
|
7781
8185
|
this._outlineEnabled = enable;
|
|
7782
8186
|
this.clearOutlineMesh();
|
|
@@ -7788,8 +8192,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7788
8192
|
fatOutlines: this._fatOutlines,
|
|
7789
8193
|
outlineWidth: this._outlineWidth,
|
|
7790
8194
|
}), "f");
|
|
7791
|
-
// this.#outlineMesh.geometry.center();
|
|
7792
|
-
// this.#outlineMesh.applyMatrix4(this.transformationMatrix);
|
|
7793
8195
|
this.add(__classPrivateFieldGet(this, _Polygon_outlineMesh, "f"));
|
|
7794
8196
|
}
|
|
7795
8197
|
}
|
|
@@ -7816,20 +8218,8 @@ class Polygon extends THREE.Mesh {
|
|
|
7816
8218
|
get outlineWidth() {
|
|
7817
8219
|
return this._outlineWidth;
|
|
7818
8220
|
}
|
|
7819
|
-
// bTree() {
|
|
7820
|
-
// if (!this.polygon) return;
|
|
7821
|
-
// const bTree = this.polygon.binary_tree();
|
|
7822
|
-
// const parsedData = JSON.parse(bTree);
|
|
7823
|
-
// console.log(parsedData);
|
|
7824
|
-
// }
|
|
7825
8221
|
disposeGeometryMaterial() {
|
|
7826
|
-
|
|
7827
|
-
this.geometry.dispose();
|
|
7828
|
-
}
|
|
7829
|
-
if (this.material instanceof THREE.Material) {
|
|
7830
|
-
this.material.dispose();
|
|
7831
|
-
}
|
|
7832
|
-
this.clearOutlineMesh();
|
|
8222
|
+
this.disposeResources();
|
|
7833
8223
|
}
|
|
7834
8224
|
clearOutlineMesh() {
|
|
7835
8225
|
if (!__classPrivateFieldGet(this, _Polygon_outlineMesh, "f")) {
|
|
@@ -7840,20 +8230,7 @@ class Polygon extends THREE.Mesh {
|
|
|
7840
8230
|
__classPrivateFieldSet(this, _Polygon_outlineMesh, null, "f");
|
|
7841
8231
|
}
|
|
7842
8232
|
dispose() {
|
|
7843
|
-
|
|
7844
|
-
// this.geometry.dispose();
|
|
7845
|
-
// if (this.material instanceof THREE.Material) {
|
|
7846
|
-
// this.material.dispose();
|
|
7847
|
-
// }
|
|
7848
|
-
// if (this.#outlineMesh) {
|
|
7849
|
-
// this.#outlineMesh.geometry.dispose();
|
|
7850
|
-
// if (this.#outlineMesh.material instanceof THREE.Material) {
|
|
7851
|
-
// this.#outlineMesh.material.dispose();
|
|
7852
|
-
// }
|
|
7853
|
-
// }
|
|
7854
|
-
// this.polygon = null;
|
|
7855
|
-
// this.layerVertices = [];
|
|
7856
|
-
// this.layerBackVertices = [];
|
|
8233
|
+
this.disposeResources();
|
|
7857
8234
|
}
|
|
7858
8235
|
writePositionsToGeometry(geometry, positions) {
|
|
7859
8236
|
const existing = geometry.getAttribute("position");
|
|
@@ -7867,10 +8244,25 @@ class Polygon extends THREE.Mesh {
|
|
|
7867
8244
|
array.set(positions);
|
|
7868
8245
|
existing.needsUpdate = true;
|
|
7869
8246
|
}
|
|
8247
|
+
disposeResources() {
|
|
8248
|
+
if (this.geometry) {
|
|
8249
|
+
this.geometry.dispose();
|
|
8250
|
+
}
|
|
8251
|
+
if (Array.isArray(this.material)) {
|
|
8252
|
+
this.material.forEach((material) => material.dispose());
|
|
8253
|
+
}
|
|
8254
|
+
else if (this.material instanceof THREE.Material) {
|
|
8255
|
+
this.material.dispose();
|
|
8256
|
+
}
|
|
8257
|
+
this.clearOutlineMesh();
|
|
8258
|
+
}
|
|
7870
8259
|
}
|
|
7871
8260
|
_Polygon_outlineMesh = new WeakMap();
|
|
7872
8261
|
|
|
7873
8262
|
var _Cylinder_outlineMesh;
|
|
8263
|
+
/**
|
|
8264
|
+
* Cylinder wrapper backed by the kernel cylindrical primitive.
|
|
8265
|
+
*/
|
|
7874
8266
|
class Cylinder extends THREE.Mesh {
|
|
7875
8267
|
set radius(value) {
|
|
7876
8268
|
this.setConfig({ radius: value });
|
|
@@ -8141,6 +8533,9 @@ class Cylinder extends THREE.Mesh {
|
|
|
8141
8533
|
_Cylinder_outlineMesh = new WeakMap();
|
|
8142
8534
|
|
|
8143
8535
|
var _Cuboid_outlineMesh;
|
|
8536
|
+
/**
|
|
8537
|
+
* Box-shaped solid wrapper backed by the kernel cuboid primitive.
|
|
8538
|
+
*/
|
|
8144
8539
|
class Cuboid extends THREE.Mesh {
|
|
8145
8540
|
set width(value) {
|
|
8146
8541
|
this.setConfig({ width: value });
|
|
@@ -8395,6 +8790,9 @@ class Cuboid extends THREE.Mesh {
|
|
|
8395
8790
|
_Cuboid_outlineMesh = new WeakMap();
|
|
8396
8791
|
|
|
8397
8792
|
var _Opening_outlineMesh;
|
|
8793
|
+
/**
|
|
8794
|
+
* Opening wrapper used as a subtractive solid in architectural workflows.
|
|
8795
|
+
*/
|
|
8398
8796
|
class Opening extends THREE.Mesh {
|
|
8399
8797
|
set width(value) {
|
|
8400
8798
|
this.setConfig({ width: value });
|
|
@@ -8681,6 +9079,9 @@ _Opening_outlineMesh = new WeakMap();
|
|
|
8681
9079
|
|
|
8682
9080
|
var _Sphere_outlineMesh;
|
|
8683
9081
|
/* eslint-enable no-unused-vars */
|
|
9082
|
+
/**
|
|
9083
|
+
* Sphere wrapper backed by the kernel sphere primitive.
|
|
9084
|
+
*/
|
|
8684
9085
|
class Sphere extends THREE.Mesh {
|
|
8685
9086
|
set radius(value) {
|
|
8686
9087
|
this.setConfig({ radius: value });
|
|
@@ -8954,6 +9355,9 @@ class Sphere extends THREE.Mesh {
|
|
|
8954
9355
|
_Sphere_outlineMesh = new WeakMap();
|
|
8955
9356
|
|
|
8956
9357
|
var _Wedge_outlineMesh;
|
|
9358
|
+
/**
|
|
9359
|
+
* Wedge wrapper backed by the kernel wedge primitive.
|
|
9360
|
+
*/
|
|
8957
9361
|
class Wedge extends THREE.Mesh {
|
|
8958
9362
|
set color(color) {
|
|
8959
9363
|
this.options.color = color;
|
|
@@ -9220,6 +9624,9 @@ _Wedge_outlineMesh = new WeakMap();
|
|
|
9220
9624
|
|
|
9221
9625
|
var _Sweep_outlineMesh;
|
|
9222
9626
|
/* eslint-enable no-unused-vars */
|
|
9627
|
+
/**
|
|
9628
|
+
* Sweep wrapper backed by the kernel sweep primitive.
|
|
9629
|
+
*/
|
|
9223
9630
|
class Sweep extends THREE.Mesh {
|
|
9224
9631
|
set color(color) {
|
|
9225
9632
|
this.options.color = color;
|
|
@@ -9867,11 +10274,7 @@ function createWallFromOffsetsExample(scene) {
|
|
|
9867
10274
|
* Builds a complete operand/result scene group for a boolean example page.
|
|
9868
10275
|
*/
|
|
9869
10276
|
function createBooleanExample(operation, options) {
|
|
9870
|
-
const preset = options
|
|
9871
|
-
? createSolidPreset(operation, options)
|
|
9872
|
-
: options.mode === "polygon"
|
|
9873
|
-
? createPolygonPreset(operation, options)
|
|
9874
|
-
: createExtrudedPreset(operation, options);
|
|
10277
|
+
const preset = createPreset(operation, options);
|
|
9875
10278
|
const execute = getBooleanExecutor(operation);
|
|
9876
10279
|
const result = execute(preset.lhsOperand, preset.rhsOperand, options);
|
|
9877
10280
|
const group = new THREE.Group();
|
|
@@ -9887,6 +10290,16 @@ function createBooleanExample(operation, options) {
|
|
|
9887
10290
|
description: preset.description,
|
|
9888
10291
|
};
|
|
9889
10292
|
}
|
|
10293
|
+
function createPreset(operation, options) {
|
|
10294
|
+
switch (options.mode) {
|
|
10295
|
+
case "solid":
|
|
10296
|
+
return createSolidPreset(operation, options);
|
|
10297
|
+
case "polygon":
|
|
10298
|
+
return createPolygonPreset(operation, options);
|
|
10299
|
+
case "extruded":
|
|
10300
|
+
return createExtrudedPreset(operation, options);
|
|
10301
|
+
}
|
|
10302
|
+
}
|
|
9890
10303
|
/**
|
|
9891
10304
|
* Builds the solid-operand preset used by the example pages.
|
|
9892
10305
|
*/
|
|
@@ -9972,63 +10385,47 @@ function createPolygonPreset(operation, options) {
|
|
|
9972
10385
|
};
|
|
9973
10386
|
}
|
|
9974
10387
|
/**
|
|
9975
|
-
* Builds
|
|
10388
|
+
* Builds an extrusion-first preset that exercises polygon.extrude(height) and
|
|
10389
|
+
* reuses the standard solid boolean pipeline.
|
|
9976
10390
|
*/
|
|
9977
10391
|
function createExtrudedPreset(operation, options) {
|
|
9978
10392
|
var _a, _b, _c, _d, _e, _f;
|
|
9979
10393
|
const outlineWidth = (_a = options.outlineWidth) !== null && _a !== void 0 ? _a : 3;
|
|
9980
10394
|
const extrudedOffset = (_b = options.extrudedOffset) !== null && _b !== void 0 ? _b : new Vector3(0.0, 0.0, 0.0);
|
|
9981
|
-
const
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
new Vector3(1.75, 0.0, 0.7),
|
|
9989
|
-
new Vector3(-1.55, 0.0, 0.7),
|
|
9990
|
-
];
|
|
9991
|
-
const rhsProfile = operation === "subtraction"
|
|
9992
|
-
? [
|
|
9993
|
-
new Vector3(-0.42, 0.0, -0.24),
|
|
9994
|
-
new Vector3(0.42, 0.0, -0.24),
|
|
9995
|
-
new Vector3(0.42, 0.0, 0.24),
|
|
9996
|
-
new Vector3(-0.42, 0.0, 0.24),
|
|
9997
|
-
]
|
|
9998
|
-
: [
|
|
9999
|
-
new Vector3(-0.8, 0.0, -0.42),
|
|
10000
|
-
new Vector3(0.72, 0.0, -0.42),
|
|
10001
|
-
new Vector3(0.72, 0.0, 0.42),
|
|
10002
|
-
new Vector3(-0.8, 0.0, 0.42),
|
|
10003
|
-
];
|
|
10004
|
-
const lhs = new Sweep({
|
|
10005
|
-
path,
|
|
10006
|
-
profile: lhsProfile,
|
|
10395
|
+
const wallProfile = new Polygon({
|
|
10396
|
+
vertices: [
|
|
10397
|
+
new Vector3(-2.2, 0.0, -0.18),
|
|
10398
|
+
new Vector3(2.2, 0.0, -0.18),
|
|
10399
|
+
new Vector3(2.2, 0.0, 0.18),
|
|
10400
|
+
new Vector3(-2.2, 0.0, 0.18),
|
|
10401
|
+
],
|
|
10007
10402
|
color: 0x60a5fa,
|
|
10008
|
-
capStart: true,
|
|
10009
|
-
capEnd: true,
|
|
10010
10403
|
fatOutlines: (_c = options.fatOutlines) !== null && _c !== void 0 ? _c : true,
|
|
10011
10404
|
outlineWidth,
|
|
10012
10405
|
});
|
|
10013
|
-
const
|
|
10014
|
-
|
|
10015
|
-
|
|
10406
|
+
const openingProfile = new Polygon({
|
|
10407
|
+
vertices: [
|
|
10408
|
+
new Vector3(-0.7, 0.0, -0.34),
|
|
10409
|
+
new Vector3(0.9, 0.0, -0.34),
|
|
10410
|
+
new Vector3(0.9, 0.0, 0.34),
|
|
10411
|
+
new Vector3(-0.7, 0.0, 0.34),
|
|
10412
|
+
],
|
|
10016
10413
|
color: 0xf97316,
|
|
10017
|
-
capStart: true,
|
|
10018
|
-
capEnd: true,
|
|
10019
|
-
translation: extrudedOffset.clone(),
|
|
10020
10414
|
fatOutlines: (_d = options.fatOutlines) !== null && _d !== void 0 ? _d : true,
|
|
10021
10415
|
outlineWidth,
|
|
10022
10416
|
});
|
|
10023
|
-
|
|
10024
|
-
|
|
10417
|
+
const wall = wallProfile.extrude(2.8);
|
|
10418
|
+
const opening = openingProfile.extrude(operation === "intersection" ? 1.45 : 1.35);
|
|
10419
|
+
opening.setTranslation(new Vector3(extrudedOffset.x, 0.85, extrudedOffset.z));
|
|
10420
|
+
wall.outline = (_e = options.outline) !== null && _e !== void 0 ? _e : true;
|
|
10421
|
+
opening.outline = (_f = options.outline) !== null && _f !== void 0 ? _f : true;
|
|
10025
10422
|
return {
|
|
10026
|
-
title: `${capitalize(operation)} Extruded
|
|
10027
|
-
description: "Two
|
|
10028
|
-
lhsOperand:
|
|
10029
|
-
rhsOperand:
|
|
10030
|
-
lhsVisual:
|
|
10031
|
-
rhsVisual:
|
|
10423
|
+
title: `${capitalize(operation)} Extruded Solid`,
|
|
10424
|
+
description: "Two polygon.extrude(height) solids overlap to demonstrate renderable BRep booleans.",
|
|
10425
|
+
lhsOperand: wall,
|
|
10426
|
+
rhsOperand: opening,
|
|
10427
|
+
lhsVisual: wall,
|
|
10428
|
+
rhsVisual: opening,
|
|
10032
10429
|
};
|
|
10033
10430
|
}
|
|
10034
10431
|
/**
|
|
@@ -10168,6 +10565,9 @@ function createEditorModesExample(scene) {
|
|
|
10168
10565
|
};
|
|
10169
10566
|
}
|
|
10170
10567
|
|
|
10568
|
+
/**
|
|
10569
|
+
* Shared runtime entrypoint used to initialize the OpenGeometry wasm module.
|
|
10570
|
+
*/
|
|
10171
10571
|
class OpenGeometry {
|
|
10172
10572
|
get enableDebug() {
|
|
10173
10573
|
return this._enableDebug;
|
|
@@ -10234,5 +10634,5 @@ class OpenGeometry {
|
|
|
10234
10634
|
OpenGeometry.version = OPEN_GEOMETRY_THREE_VERSION;
|
|
10235
10635
|
OpenGeometry.instance = null;
|
|
10236
10636
|
|
|
10237
|
-
export { Arc, BooleanResult, Cuboid, Curve, Cylinder, FreeformEditor, FreeformGeometry, Line, OGSceneManager, OpenGeometry, Opening, Polygon, Polyline, Rectangle, Sphere, SpotLabel, Sweep, Vector3, Wedge, booleanIntersection, booleanSubtraction, booleanUnion, clonePlacement, createBooleanExample, createEditorModesExample, createFreeformEditor, createFreeformGeometry, createOffsetExample, createParametricEditCapabilities, createPrimitivesExample, createShapesExample, createSweepExample, createWallFromOffsetsExample, toObjectTransformation$1 as toObjectTransformation };
|
|
10637
|
+
export { Arc, BooleanResult, Cuboid, Curve, Cylinder, FreeformEditor, FreeformGeometry, Line, OGSceneManager, OpenGeometry, Opening, Polygon, Polyline, Rectangle, Solid, Sphere, SpotLabel, Sweep, Vector3, Wedge, booleanIntersection, booleanSubtraction, booleanUnion, clonePlacement, createBooleanExample, createEditorModesExample, createFreeformEditor, createFreeformGeometry, createOffsetExample, createParametricEditCapabilities, createPrimitivesExample, createShapesExample, createSweepExample, createWallFromOffsetsExample, extrudeBrepFace, toObjectTransformation$1 as toObjectTransformation };
|
|
10238
10638
|
//# sourceMappingURL=index.js.map
|