opengeometry 2.0.1 → 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 +627 -415
- package/index.js.map +1 -1
- package/opengeometry/pkg/opengeometry.d.ts +131 -123
- package/opengeometry/pkg/opengeometry.js +68 -33
- package/opengeometry/pkg/opengeometry_bg.wasm +0 -0
- package/opengeometry/pkg/opengeometry_bg.wasm.d.ts +126 -122
- package/opengeometry_bg.wasm +0 -0
- package/opengeometry_bg.wasm.d.ts +126 -122
- 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/examples/booleans.d.ts +2 -1
- 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 -1
- package/src/shapes/opening.d.ts +15 -0
- package/src/shapes/outline-utils.d.ts +21 -0
- package/src/shapes/polygon.d.ts +31 -7
- 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/src/shapes/extruded-shape.d.ts +0 -49
package/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import * as THREE from 'three';
|
|
|
3
3
|
import { Line2 } from 'three/examples/jsm/lines/Line2.js';
|
|
4
4
|
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial.js';
|
|
5
5
|
import { LineGeometry } from 'three/examples/jsm/lines/LineGeometry.js';
|
|
6
|
-
import { toCreasedNormals } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
7
6
|
import { LineSegments2 } from 'three/examples/jsm/lines/LineSegments2.js';
|
|
8
7
|
import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry.js';
|
|
8
|
+
import { toCreasedNormals } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
9
9
|
|
|
10
10
|
/******************************************************************************
|
|
11
11
|
Copyright (c) Microsoft Corporation.
|
|
@@ -138,16 +138,16 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
138
138
|
WASM_VECTOR_LEN = offset;
|
|
139
139
|
return ptr;
|
|
140
140
|
}
|
|
141
|
-
function takeFromExternrefTable0(idx) {
|
|
142
|
-
const value = wasm.__wbindgen_export_2.get(idx);
|
|
143
|
-
wasm.__externref_table_dealloc(idx);
|
|
144
|
-
return value;
|
|
145
|
-
}
|
|
146
141
|
function _assertClass(instance, klass) {
|
|
147
142
|
if (!(instance instanceof klass)) {
|
|
148
143
|
throw new Error(`expected instance of ${klass.name}`);
|
|
149
144
|
}
|
|
150
145
|
}
|
|
146
|
+
function takeFromExternrefTable0(idx) {
|
|
147
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
148
|
+
wasm.__externref_table_dealloc(idx);
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
151
|
let cachedFloat64ArrayMemory0 = null;
|
|
152
152
|
function getFloat64ArrayMemory0() {
|
|
153
153
|
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
@@ -178,34 +178,6 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
178
178
|
function isLikeNone(x) {
|
|
179
179
|
return x === undefined || x === null;
|
|
180
180
|
}
|
|
181
|
-
/**
|
|
182
|
-
* @param {string} local_brep_serialized
|
|
183
|
-
* @param {number} face_id
|
|
184
|
-
* @param {number} distance
|
|
185
|
-
* @returns {string}
|
|
186
|
-
*/
|
|
187
|
-
function extrudeBrepFace(local_brep_serialized, face_id, distance) {
|
|
188
|
-
let deferred3_0;
|
|
189
|
-
let deferred3_1;
|
|
190
|
-
try {
|
|
191
|
-
const ptr0 = passStringToWasm0(local_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
-
const len0 = WASM_VECTOR_LEN;
|
|
193
|
-
const ret = wasm.extrudeBrepFace(ptr0, len0, face_id, distance);
|
|
194
|
-
var ptr2 = ret[0];
|
|
195
|
-
var len2 = ret[1];
|
|
196
|
-
if (ret[3]) {
|
|
197
|
-
ptr2 = 0;
|
|
198
|
-
len2 = 0;
|
|
199
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
200
|
-
}
|
|
201
|
-
deferred3_0 = ptr2;
|
|
202
|
-
deferred3_1 = len2;
|
|
203
|
-
return getStringFromWasm0(ptr2, len2);
|
|
204
|
-
} finally {
|
|
205
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
181
|
/**
|
|
210
182
|
* Wasm entry point for union.
|
|
211
183
|
* @param {string} lhs_brep_serialized
|
|
@@ -268,6 +240,33 @@ function booleanSubtraction$1(lhs_brep_serialized, rhs_brep_serialized, options_
|
|
|
268
240
|
}
|
|
269
241
|
return OGBooleanResult.__wrap(ret[0]);
|
|
270
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
|
+
}
|
|
271
270
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
272
271
|
ptr = ptr >>> 0;
|
|
273
272
|
const mem = getDataViewMemory0();
|
|
@@ -2257,6 +2256,24 @@ class OGFreeformGeometry {
|
|
|
2257
2256
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2258
2257
|
}
|
|
2259
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
|
+
}
|
|
2260
2277
|
/**
|
|
2261
2278
|
* @returns {string}
|
|
2262
2279
|
*/
|
|
@@ -2272,6 +2289,24 @@ class OGFreeformGeometry {
|
|
|
2272
2289
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2273
2290
|
}
|
|
2274
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
|
+
}
|
|
2275
2310
|
/**
|
|
2276
2311
|
* @returns {string}
|
|
2277
2312
|
*/
|
|
@@ -5655,7 +5690,7 @@ var OGKernel = /*#__PURE__*/Object.freeze({
|
|
|
5655
5690
|
booleanSubtraction: booleanSubtraction$1,
|
|
5656
5691
|
booleanUnion: booleanUnion$1,
|
|
5657
5692
|
default: __wbg_init,
|
|
5658
|
-
extrudeBrepFace: extrudeBrepFace,
|
|
5693
|
+
extrudeBrepFace: extrudeBrepFace$1,
|
|
5659
5694
|
initSync: initSync
|
|
5660
5695
|
});
|
|
5661
5696
|
|
|
@@ -5677,7 +5712,10 @@ class SpotLabel extends CSS2DObject {
|
|
|
5677
5712
|
}
|
|
5678
5713
|
}
|
|
5679
5714
|
|
|
5680
|
-
|
|
5715
|
+
/**
|
|
5716
|
+
* Version string exposed by the Three.js adapter at runtime.
|
|
5717
|
+
*/
|
|
5718
|
+
const OPEN_GEOMETRY_THREE_VERSION = "2.0.3";
|
|
5681
5719
|
|
|
5682
5720
|
/**
|
|
5683
5721
|
* Convert array of 16 byte values to UUID string format of the form:
|
|
@@ -5741,6 +5779,9 @@ function cloneVector$2(vector, fallback) {
|
|
|
5741
5779
|
var _a;
|
|
5742
5780
|
return (_a = vector === null || vector === void 0 ? void 0 : vector.clone()) !== null && _a !== void 0 ? _a : new Vector3(...fallback);
|
|
5743
5781
|
}
|
|
5782
|
+
/**
|
|
5783
|
+
* Returns the canonical capability payload exposed by parametric wrappers.
|
|
5784
|
+
*/
|
|
5744
5785
|
function createParametricEditCapabilities(entityType, editFamily) {
|
|
5745
5786
|
return {
|
|
5746
5787
|
editingMode: "parametric",
|
|
@@ -5751,13 +5792,20 @@ function createParametricEditCapabilities(entityType, editFamily) {
|
|
|
5751
5792
|
canConvertToFreeform: true,
|
|
5752
5793
|
};
|
|
5753
5794
|
}
|
|
5754
|
-
|
|
5795
|
+
/**
|
|
5796
|
+
* Normalizes optional placement fields into concrete vectors.
|
|
5797
|
+
*/
|
|
5798
|
+
function clonePlacement(placement) {
|
|
5755
5799
|
return {
|
|
5756
5800
|
translation: cloneVector$2(placement.translation, [0, 0, 0]),
|
|
5757
5801
|
rotation: cloneVector$2(placement.rotation, [0, 0, 0]),
|
|
5758
5802
|
scale: cloneVector$2(placement.scale, [1, 1, 1]),
|
|
5759
5803
|
};
|
|
5760
5804
|
}
|
|
5805
|
+
/**
|
|
5806
|
+
* Converts a parametric placement payload into the freeform/object transform
|
|
5807
|
+
* structure expected by BRep-backed helpers.
|
|
5808
|
+
*/
|
|
5761
5809
|
function toObjectTransformation$1(placement) {
|
|
5762
5810
|
if ("anchor" in placement) {
|
|
5763
5811
|
return {
|
|
@@ -5775,7 +5823,7 @@ function toObjectTransformation$1(placement) {
|
|
|
5775
5823
|
};
|
|
5776
5824
|
}
|
|
5777
5825
|
|
|
5778
|
-
function parseJson$
|
|
5826
|
+
function parseJson$1(payload) {
|
|
5779
5827
|
return JSON.parse(payload);
|
|
5780
5828
|
}
|
|
5781
5829
|
function toVector3$1(value) {
|
|
@@ -5850,7 +5898,7 @@ function normalizeFreeformCapabilities(raw) {
|
|
|
5850
5898
|
};
|
|
5851
5899
|
}
|
|
5852
5900
|
function parseEditResult(payload) {
|
|
5853
|
-
const result = parseJson$
|
|
5901
|
+
const result = parseJson$1(payload);
|
|
5854
5902
|
return Object.assign(Object.assign({}, result), { placement: normalizePlacement$1(result.placement) });
|
|
5855
5903
|
}
|
|
5856
5904
|
function serializeOptions(options) {
|
|
@@ -5863,74 +5911,137 @@ function serializeOptions(options) {
|
|
|
5863
5911
|
? toPlainVector3$1(options.constraintPlaneNormal)
|
|
5864
5912
|
: undefined }));
|
|
5865
5913
|
}
|
|
5914
|
+
/**
|
|
5915
|
+
* High-level editor facade over the kernel freeform editing API.
|
|
5916
|
+
*/
|
|
5866
5917
|
class FreeformEditor {
|
|
5867
5918
|
constructor(geometry, editor = new OGFreeformEditor()) {
|
|
5868
5919
|
this.geometry = geometry;
|
|
5869
5920
|
this.editor = editor;
|
|
5870
5921
|
}
|
|
5922
|
+
/**
|
|
5923
|
+
* Returns the freeform geometry currently managed by this editor.
|
|
5924
|
+
*/
|
|
5871
5925
|
getFreeformGeometry() {
|
|
5872
5926
|
return this.geometry;
|
|
5873
5927
|
}
|
|
5928
|
+
/**
|
|
5929
|
+
* Returns renderable topology buffers for faces, edges, and vertices.
|
|
5930
|
+
*/
|
|
5874
5931
|
getTopologyRenderData() {
|
|
5875
|
-
return normalizeTopologyRenderData(parseJson$
|
|
5932
|
+
return normalizeTopologyRenderData(parseJson$1(this.editor.getTopologyRenderData(this.geometry.getKernelGeometry())));
|
|
5876
5933
|
}
|
|
5934
|
+
/**
|
|
5935
|
+
* Returns semantic and topological information for a face id.
|
|
5936
|
+
*/
|
|
5877
5937
|
getFaceInfo(faceId) {
|
|
5878
|
-
return normalizeFaceInfo(parseJson$
|
|
5938
|
+
return normalizeFaceInfo(parseJson$1(this.editor.getFaceInfo(this.geometry.getKernelGeometry(), faceId)));
|
|
5879
5939
|
}
|
|
5940
|
+
/**
|
|
5941
|
+
* Returns semantic and topological information for an edge id.
|
|
5942
|
+
*/
|
|
5880
5943
|
getEdgeInfo(edgeId) {
|
|
5881
|
-
return normalizeEdgeInfo(parseJson$
|
|
5944
|
+
return normalizeEdgeInfo(parseJson$1(this.editor.getEdgeInfo(this.geometry.getKernelGeometry(), edgeId)));
|
|
5882
5945
|
}
|
|
5946
|
+
/**
|
|
5947
|
+
* Returns semantic and topological information for a vertex id.
|
|
5948
|
+
*/
|
|
5883
5949
|
getVertexInfo(vertexId) {
|
|
5884
|
-
return normalizeVertexInfo(parseJson$
|
|
5950
|
+
return normalizeVertexInfo(parseJson$1(this.editor.getVertexInfo(this.geometry.getKernelGeometry(), vertexId)));
|
|
5885
5951
|
}
|
|
5952
|
+
/**
|
|
5953
|
+
* Returns global edit capabilities for the current freeform model.
|
|
5954
|
+
*/
|
|
5886
5955
|
getEditCapabilities() {
|
|
5887
|
-
return normalizeFreeformCapabilities(parseJson$
|
|
5956
|
+
return normalizeFreeformCapabilities(parseJson$1(this.editor.getEditCapabilities(this.geometry.getKernelGeometry())));
|
|
5888
5957
|
}
|
|
5958
|
+
/**
|
|
5959
|
+
* Returns edit capabilities scoped to a single face.
|
|
5960
|
+
*/
|
|
5889
5961
|
getFaceEditCapabilities(faceId) {
|
|
5890
|
-
return normalizeFeatureCapabilities(parseJson$
|
|
5962
|
+
return normalizeFeatureCapabilities(parseJson$1(this.editor.getFaceEditCapabilities(this.geometry.getKernelGeometry(), faceId)));
|
|
5891
5963
|
}
|
|
5964
|
+
/**
|
|
5965
|
+
* Returns edit capabilities scoped to a single edge.
|
|
5966
|
+
*/
|
|
5892
5967
|
getEdgeEditCapabilities(edgeId) {
|
|
5893
|
-
return normalizeFeatureCapabilities(parseJson$
|
|
5968
|
+
return normalizeFeatureCapabilities(parseJson$1(this.editor.getEdgeEditCapabilities(this.geometry.getKernelGeometry(), edgeId)));
|
|
5894
5969
|
}
|
|
5970
|
+
/**
|
|
5971
|
+
* Returns edit capabilities scoped to a single vertex.
|
|
5972
|
+
*/
|
|
5895
5973
|
getVertexEditCapabilities(vertexId) {
|
|
5896
|
-
return normalizeFeatureCapabilities(parseJson$
|
|
5974
|
+
return normalizeFeatureCapabilities(parseJson$1(this.editor.getVertexEditCapabilities(this.geometry.getKernelGeometry(), vertexId)));
|
|
5897
5975
|
}
|
|
5976
|
+
/**
|
|
5977
|
+
* Offset a face along its editable normal direction.
|
|
5978
|
+
*/
|
|
5898
5979
|
pushPullFace(faceId, distance, options) {
|
|
5899
5980
|
return parseEditResult(this.editor.pushPullFace(this.geometry.getKernelGeometry(), faceId, distance, serializeOptions(options)));
|
|
5900
5981
|
}
|
|
5982
|
+
/**
|
|
5983
|
+
* Creates new side faces by extruding a face region.
|
|
5984
|
+
*/
|
|
5901
5985
|
extrudeFace(faceId, distance, options) {
|
|
5902
5986
|
return parseEditResult(this.editor.extrudeFace(this.geometry.getKernelGeometry(), faceId, distance, serializeOptions(options)));
|
|
5903
5987
|
}
|
|
5988
|
+
/**
|
|
5989
|
+
* Splits a face by connecting two points sampled on its boundary edges.
|
|
5990
|
+
*/
|
|
5904
5991
|
cutFace(faceId, startEdgeId, startT, endEdgeId, endT, options) {
|
|
5905
5992
|
return parseEditResult(this.editor.cutFace(this.geometry.getKernelGeometry(), faceId, startEdgeId, startT, endEdgeId, endT, serializeOptions(options)));
|
|
5906
5993
|
}
|
|
5994
|
+
/**
|
|
5995
|
+
* Moves a face by a translation vector, subject to kernel constraints.
|
|
5996
|
+
*/
|
|
5907
5997
|
moveFace(faceId, translation, options) {
|
|
5908
5998
|
return parseEditResult(this.editor.moveFace(this.geometry.getKernelGeometry(), faceId, translation, serializeOptions(options)));
|
|
5909
5999
|
}
|
|
6000
|
+
/**
|
|
6001
|
+
* Moves an edge by a translation vector, subject to kernel constraints.
|
|
6002
|
+
*/
|
|
5910
6003
|
moveEdge(edgeId, translation, options) {
|
|
5911
6004
|
return parseEditResult(this.editor.moveEdge(this.geometry.getKernelGeometry(), edgeId, translation, serializeOptions(options)));
|
|
5912
6005
|
}
|
|
6006
|
+
/**
|
|
6007
|
+
* Moves a vertex by a translation vector, subject to kernel constraints.
|
|
6008
|
+
*/
|
|
5913
6009
|
moveVertex(vertexId, translation, options) {
|
|
5914
6010
|
return parseEditResult(this.editor.moveVertex(this.geometry.getKernelGeometry(), vertexId, translation, serializeOptions(options)));
|
|
5915
6011
|
}
|
|
6012
|
+
/**
|
|
6013
|
+
* Inserts a vertex at parametric position `t` along an edge.
|
|
6014
|
+
*/
|
|
5916
6015
|
insertVertexOnEdge(edgeId, t, options) {
|
|
5917
6016
|
return parseEditResult(this.editor.insertVertexOnEdge(this.geometry.getKernelGeometry(), edgeId, t, serializeOptions(options)));
|
|
5918
6017
|
}
|
|
6018
|
+
/**
|
|
6019
|
+
* Splits an edge at parametric position `t`.
|
|
6020
|
+
*/
|
|
5919
6021
|
splitEdge(edgeId, t, options) {
|
|
5920
6022
|
return parseEditResult(this.editor.splitEdge(this.geometry.getKernelGeometry(), edgeId, t, serializeOptions(options)));
|
|
5921
6023
|
}
|
|
6024
|
+
/**
|
|
6025
|
+
* Creates a loop cut that propagates from the selected edge when possible.
|
|
6026
|
+
*/
|
|
5922
6027
|
loopCut(edgeId, t, options) {
|
|
5923
6028
|
return parseEditResult(this.editor.loopCut(this.geometry.getKernelGeometry(), edgeId, t, serializeOptions(options)));
|
|
5924
6029
|
}
|
|
6030
|
+
/**
|
|
6031
|
+
* Removes a vertex when the current topology allows the edit.
|
|
6032
|
+
*/
|
|
5925
6033
|
removeVertex(vertexId, options) {
|
|
5926
6034
|
return parseEditResult(this.editor.removeVertex(this.geometry.getKernelGeometry(), vertexId, serializeOptions(options)));
|
|
5927
6035
|
}
|
|
5928
6036
|
}
|
|
6037
|
+
/**
|
|
6038
|
+
* Convenience factory for creating a freeform editor around a geometry wrapper.
|
|
6039
|
+
*/
|
|
5929
6040
|
function createFreeformEditor(geometry) {
|
|
5930
6041
|
return new FreeformEditor(geometry);
|
|
5931
6042
|
}
|
|
5932
6043
|
|
|
5933
|
-
function parseJson
|
|
6044
|
+
function parseJson(payload) {
|
|
5934
6045
|
return JSON.parse(payload);
|
|
5935
6046
|
}
|
|
5936
6047
|
function toVector3(value) {
|
|
@@ -5971,7 +6082,7 @@ function toPlainObjectTransformation(transform) {
|
|
|
5971
6082
|
scale: toPlainVector3(transform.scale),
|
|
5972
6083
|
};
|
|
5973
6084
|
}
|
|
5974
|
-
function serializeBrepLike$
|
|
6085
|
+
function serializeBrepLike$2(value) {
|
|
5975
6086
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
5976
6087
|
}
|
|
5977
6088
|
function normalizeFreeformSerialized(source) {
|
|
@@ -5982,56 +6093,119 @@ function normalizeFreeformSerialized(source) {
|
|
|
5982
6093
|
return source.getLocalBrepSerialized();
|
|
5983
6094
|
}
|
|
5984
6095
|
if (typeof source.getLocalBrepData === "function") {
|
|
5985
|
-
return serializeBrepLike$
|
|
6096
|
+
return serializeBrepLike$2(source.getLocalBrepData());
|
|
5986
6097
|
}
|
|
5987
6098
|
if (typeof source.getBrepSerialized === "function") {
|
|
5988
6099
|
return source.getBrepSerialized();
|
|
5989
6100
|
}
|
|
5990
6101
|
if (typeof source.getBrepData === "function") {
|
|
5991
|
-
return serializeBrepLike$
|
|
6102
|
+
return serializeBrepLike$2(source.getBrepData());
|
|
5992
6103
|
}
|
|
5993
6104
|
if (typeof source.getBrep === "function") {
|
|
5994
|
-
return serializeBrepLike$
|
|
6105
|
+
return serializeBrepLike$2(source.getBrep());
|
|
5995
6106
|
}
|
|
5996
6107
|
return JSON.stringify(source);
|
|
5997
6108
|
}
|
|
6109
|
+
/**
|
|
6110
|
+
* Thin client-side wrapper around the kernel `OGFreeformGeometry` object.
|
|
6111
|
+
*/
|
|
5998
6112
|
class FreeformGeometry {
|
|
5999
6113
|
constructor(geometry) {
|
|
6000
6114
|
this.geometry = geometry;
|
|
6001
6115
|
}
|
|
6116
|
+
/**
|
|
6117
|
+
* Returns the stable kernel-side id for this freeform geometry object.
|
|
6118
|
+
*/
|
|
6002
6119
|
getId() {
|
|
6003
6120
|
return this.geometry.id;
|
|
6004
6121
|
}
|
|
6122
|
+
/**
|
|
6123
|
+
* Returns the world-space serialized BRep payload.
|
|
6124
|
+
*/
|
|
6005
6125
|
getBrepSerialized() {
|
|
6006
6126
|
return this.geometry.getBrepSerialized();
|
|
6007
6127
|
}
|
|
6128
|
+
/**
|
|
6129
|
+
* Returns the local-space serialized BRep payload.
|
|
6130
|
+
*/
|
|
6008
6131
|
getLocalBrepSerialized() {
|
|
6009
6132
|
return this.geometry.getLocalBrepSerialized();
|
|
6010
6133
|
}
|
|
6134
|
+
/**
|
|
6135
|
+
* Returns the serialized triangle position buffer emitted by the kernel.
|
|
6136
|
+
*/
|
|
6011
6137
|
getGeometrySerialized() {
|
|
6012
6138
|
return this.geometry.getGeometrySerialized();
|
|
6013
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
|
+
*/
|
|
6014
6155
|
getOutlineGeometrySerialized() {
|
|
6015
6156
|
return this.geometry.getOutlineGeometrySerialized();
|
|
6016
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
|
+
*/
|
|
6017
6173
|
getPlacement() {
|
|
6018
|
-
return normalizePlacement(parseJson
|
|
6174
|
+
return normalizePlacement(parseJson(this.geometry.getPlacementSerialized()));
|
|
6019
6175
|
}
|
|
6176
|
+
/**
|
|
6177
|
+
* Replaces the full placement transform in one call.
|
|
6178
|
+
*/
|
|
6020
6179
|
setPlacement(transform) {
|
|
6021
6180
|
this.geometry.setPlacementSerialized(JSON.stringify(toPlainObjectTransformation(transform)));
|
|
6022
6181
|
}
|
|
6182
|
+
/**
|
|
6183
|
+
* Sets translation, rotation, and scale without changing the current anchor.
|
|
6184
|
+
*/
|
|
6023
6185
|
setTransform(translation, rotation, scale) {
|
|
6024
6186
|
this.geometry.setTransform(translation, rotation, scale);
|
|
6025
6187
|
}
|
|
6188
|
+
/**
|
|
6189
|
+
* Updates only the translation component of the placement.
|
|
6190
|
+
*/
|
|
6026
6191
|
setTranslation(translation) {
|
|
6027
6192
|
this.geometry.setTranslation(translation);
|
|
6028
6193
|
}
|
|
6194
|
+
/**
|
|
6195
|
+
* Updates only the rotation component of the placement.
|
|
6196
|
+
*/
|
|
6029
6197
|
setRotation(rotation) {
|
|
6030
6198
|
this.geometry.setRotation(rotation);
|
|
6031
6199
|
}
|
|
6200
|
+
/**
|
|
6201
|
+
* Updates only the scale component of the placement.
|
|
6202
|
+
*/
|
|
6032
6203
|
setScale(scale) {
|
|
6033
6204
|
this.geometry.setScale(scale);
|
|
6034
6205
|
}
|
|
6206
|
+
/**
|
|
6207
|
+
* Updates the explicit modeling anchor used by downstream transforms.
|
|
6208
|
+
*/
|
|
6035
6209
|
setAnchor(anchor) {
|
|
6036
6210
|
this.geometry.setAnchor(anchor);
|
|
6037
6211
|
}
|
|
@@ -6040,6 +6214,10 @@ class FreeformGeometry {
|
|
|
6040
6214
|
return this.geometry;
|
|
6041
6215
|
}
|
|
6042
6216
|
}
|
|
6217
|
+
/**
|
|
6218
|
+
* Creates a `FreeformGeometry` wrapper from serialized BRep JSON, a parsed
|
|
6219
|
+
* BRep object, or another wrapper exposing BRep accessors.
|
|
6220
|
+
*/
|
|
6043
6221
|
function createFreeformGeometry(source, options) {
|
|
6044
6222
|
var _a;
|
|
6045
6223
|
const id = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : `freeform-${Date.now()}`;
|
|
@@ -6158,7 +6336,7 @@ class Line extends THREE.Line {
|
|
|
6158
6336
|
this.setPlacement({ scale });
|
|
6159
6337
|
}
|
|
6160
6338
|
getPlacement() {
|
|
6161
|
-
return clonePlacement
|
|
6339
|
+
return clonePlacement({
|
|
6162
6340
|
translation: this.options.translation,
|
|
6163
6341
|
rotation: this.options.rotation,
|
|
6164
6342
|
scale: this.options.scale,
|
|
@@ -6275,6 +6453,9 @@ class Line extends THREE.Line {
|
|
|
6275
6453
|
}
|
|
6276
6454
|
|
|
6277
6455
|
/* eslint-enable no-unused-vars */
|
|
6456
|
+
/**
|
|
6457
|
+
* Polyline wrapper backed by the kernel OGPolyline primitive.
|
|
6458
|
+
*/
|
|
6278
6459
|
class Polyline extends THREE.Line {
|
|
6279
6460
|
set color(color) {
|
|
6280
6461
|
this.options.color = color;
|
|
@@ -6378,7 +6559,7 @@ class Polyline extends THREE.Line {
|
|
|
6378
6559
|
this.setPlacement({ scale });
|
|
6379
6560
|
}
|
|
6380
6561
|
getPlacement() {
|
|
6381
|
-
return clonePlacement
|
|
6562
|
+
return clonePlacement({
|
|
6382
6563
|
translation: this.options.translation,
|
|
6383
6564
|
rotation: this.options.rotation,
|
|
6384
6565
|
scale: this.options.scale,
|
|
@@ -6502,6 +6683,9 @@ class Polyline extends THREE.Line {
|
|
|
6502
6683
|
}
|
|
6503
6684
|
}
|
|
6504
6685
|
|
|
6686
|
+
/**
|
|
6687
|
+
* Arc wrapper backed by the kernel OGArc primitive.
|
|
6688
|
+
*/
|
|
6505
6689
|
class Arc extends THREE.Line {
|
|
6506
6690
|
set color(color) {
|
|
6507
6691
|
this.options.color = color;
|
|
@@ -6607,7 +6791,7 @@ class Arc extends THREE.Line {
|
|
|
6607
6791
|
return this.options;
|
|
6608
6792
|
}
|
|
6609
6793
|
getPlacement() {
|
|
6610
|
-
return clonePlacement
|
|
6794
|
+
return clonePlacement({
|
|
6611
6795
|
translation: this.options.translation,
|
|
6612
6796
|
rotation: this.options.rotation,
|
|
6613
6797
|
scale: this.options.scale,
|
|
@@ -6709,6 +6893,9 @@ class Arc extends THREE.Line {
|
|
|
6709
6893
|
}
|
|
6710
6894
|
|
|
6711
6895
|
/* eslint-enable no-unused-vars */
|
|
6896
|
+
/**
|
|
6897
|
+
* Rectangle wrapper backed by the kernel OGRectangle primitive.
|
|
6898
|
+
*/
|
|
6712
6899
|
class Rectangle extends THREE.Line {
|
|
6713
6900
|
// set width(width: number) {
|
|
6714
6901
|
// this.options.width = width;
|
|
@@ -6828,7 +7015,7 @@ class Rectangle extends THREE.Line {
|
|
|
6828
7015
|
return this.options;
|
|
6829
7016
|
}
|
|
6830
7017
|
getPlacement() {
|
|
6831
|
-
return clonePlacement
|
|
7018
|
+
return clonePlacement({
|
|
6832
7019
|
translation: this.options.translation,
|
|
6833
7020
|
rotation: this.options.rotation,
|
|
6834
7021
|
scale: this.options.scale,
|
|
@@ -6944,6 +7131,9 @@ class Rectangle extends THREE.Line {
|
|
|
6944
7131
|
}
|
|
6945
7132
|
|
|
6946
7133
|
/* eslint-enable no-unused-vars */
|
|
7134
|
+
/**
|
|
7135
|
+
* Curve wrapper backed by the kernel OGCurve primitive.
|
|
7136
|
+
*/
|
|
6947
7137
|
class Curve extends THREE.Line {
|
|
6948
7138
|
set color(color) {
|
|
6949
7139
|
this.options.color = color;
|
|
@@ -7029,7 +7219,7 @@ class Curve extends THREE.Line {
|
|
|
7029
7219
|
this.setPlacement({ scale });
|
|
7030
7220
|
}
|
|
7031
7221
|
getPlacement() {
|
|
7032
|
-
return clonePlacement
|
|
7222
|
+
return clonePlacement({
|
|
7033
7223
|
translation: this.options.translation,
|
|
7034
7224
|
rotation: this.options.rotation,
|
|
7035
7225
|
scale: this.options.scale,
|
|
@@ -7104,12 +7294,18 @@ function getOutlineResolution() {
|
|
|
7104
7294
|
}
|
|
7105
7295
|
return new THREE.Vector2(window.innerWidth, window.innerHeight);
|
|
7106
7296
|
}
|
|
7297
|
+
/**
|
|
7298
|
+
* Clamps outline width inputs to the supported positive finite range.
|
|
7299
|
+
*/
|
|
7107
7300
|
function sanitizeOutlineWidth(width) {
|
|
7108
7301
|
if (!Number.isFinite(width) || typeof width !== "number" || width <= 0) {
|
|
7109
7302
|
return DEFAULT_OUTLINE_WIDTH;
|
|
7110
7303
|
}
|
|
7111
7304
|
return width;
|
|
7112
7305
|
}
|
|
7306
|
+
/**
|
|
7307
|
+
* Creates either a thin or fat outline mesh from line segment positions.
|
|
7308
|
+
*/
|
|
7113
7309
|
function createShapeOutlineMesh({ positions, color = DEFAULT_OUTLINE_COLOR, fatOutlines = false, outlineWidth = DEFAULT_OUTLINE_WIDTH, }) {
|
|
7114
7310
|
if (fatOutlines) {
|
|
7115
7311
|
const fatGeometry = new LineSegmentsGeometry();
|
|
@@ -7128,6 +7324,9 @@ function createShapeOutlineMesh({ positions, color = DEFAULT_OUTLINE_COLOR, fatO
|
|
|
7128
7324
|
const outlineMaterial = new THREE.LineBasicMaterial({ color });
|
|
7129
7325
|
return new THREE.LineSegments(outlineGeometry, outlineMaterial);
|
|
7130
7326
|
}
|
|
7327
|
+
/**
|
|
7328
|
+
* Disposes the geometry and material owned by an outline mesh.
|
|
7329
|
+
*/
|
|
7131
7330
|
function disposeShapeOutlineMesh(mesh) {
|
|
7132
7331
|
if (!mesh) {
|
|
7133
7332
|
return;
|
|
@@ -7139,6 +7338,9 @@ function disposeShapeOutlineMesh(mesh) {
|
|
|
7139
7338
|
}
|
|
7140
7339
|
mesh.material.dispose();
|
|
7141
7340
|
}
|
|
7341
|
+
/**
|
|
7342
|
+
* Updates the color of an existing outline mesh in place.
|
|
7343
|
+
*/
|
|
7142
7344
|
function setShapeOutlineColor(mesh, color) {
|
|
7143
7345
|
if (!mesh) {
|
|
7144
7346
|
return;
|
|
@@ -7151,6 +7353,9 @@ function setShapeOutlineColor(mesh, color) {
|
|
|
7151
7353
|
mesh.material.color.set(color);
|
|
7152
7354
|
}
|
|
7153
7355
|
}
|
|
7356
|
+
/**
|
|
7357
|
+
* Reads the current outline color, falling back when no outline exists.
|
|
7358
|
+
*/
|
|
7154
7359
|
function getShapeOutlineColor(mesh, fallback = DEFAULT_OUTLINE_COLOR) {
|
|
7155
7360
|
if (!mesh) {
|
|
7156
7361
|
return fallback;
|
|
@@ -7164,6 +7369,42 @@ function getShapeOutlineColor(mesh, fallback = DEFAULT_OUTLINE_COLOR) {
|
|
|
7164
7369
|
return fallback;
|
|
7165
7370
|
}
|
|
7166
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
|
+
|
|
7167
7408
|
var _BooleanResult_outlineMesh;
|
|
7168
7409
|
/* eslint-enable no-unused-vars */
|
|
7169
7410
|
const BOOLEAN_CREASE_ANGLE = Math.PI / 5;
|
|
@@ -7398,158 +7639,162 @@ function getRenderableOutlinePositions(geometry, fallbackSerialized) {
|
|
|
7398
7639
|
return JSON.parse(fallbackSerialized);
|
|
7399
7640
|
}
|
|
7400
7641
|
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
var _a;
|
|
7407
|
-
return (_a = vector === null || vector === void 0 ? void 0 : vector.clone()) !== null && _a !== void 0 ? _a : new Vector3(...fallback);
|
|
7408
|
-
}
|
|
7409
|
-
function clonePlacement(placement) {
|
|
7410
|
-
return {
|
|
7411
|
-
anchor: cloneVector(placement === null || placement === void 0 ? void 0 : placement.anchor, [0, 0, 0]),
|
|
7412
|
-
translation: cloneVector(placement === null || placement === void 0 ? void 0 : placement.translation, [0, 0, 0]),
|
|
7413
|
-
rotation: cloneVector(placement === null || placement === void 0 ? void 0 : placement.rotation, [0, 0, 0]),
|
|
7414
|
-
scale: cloneVector(placement === null || placement === void 0 ? void 0 : placement.scale, [1, 1, 1]),
|
|
7415
|
-
};
|
|
7642
|
+
/**
|
|
7643
|
+
* Executes a kernel-backed subtraction for a shape wrapper against another boolean operand.
|
|
7644
|
+
*/
|
|
7645
|
+
function subtractShapeOperand(host, operand, options) {
|
|
7646
|
+
return booleanSubtraction(host, operand, options);
|
|
7416
7647
|
}
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
this._outlineWidth = 1;
|
|
7425
|
-
this._outlineColor = 0x000000;
|
|
7426
|
-
this._color = 0x2563eb;
|
|
7427
|
-
this.ogid = (_a = options === null || options === void 0 ? void 0 : options.ogid) !== null && _a !== void 0 ? _a : getUUID();
|
|
7428
|
-
this._color = (_b = options === null || options === void 0 ? void 0 : options.color) !== null && _b !== void 0 ? _b : this._color;
|
|
7429
|
-
this._fatOutlines = (_c = options === null || options === void 0 ? void 0 : options.fatOutlines) !== null && _c !== void 0 ? _c : false;
|
|
7430
|
-
this._outlineWidth = sanitizeOutlineWidth(options === null || options === void 0 ? void 0 : options.outlineWidth);
|
|
7431
|
-
this._outlineColor = (_d = options === null || options === void 0 ? void 0 : options.outlineColor) !== null && _d !== void 0 ? _d : this._outlineColor;
|
|
7432
|
-
this.freeform = createFreeformGeometry(localBrepSerialized, {
|
|
7433
|
-
id: this.ogid,
|
|
7434
|
-
placement: clonePlacement(options === null || options === void 0 ? void 0 : options.placement),
|
|
7435
|
-
});
|
|
7436
|
-
this.generateGeometry();
|
|
7437
|
-
if ((_e = options === null || options === void 0 ? void 0 : options.outline) !== null && _e !== void 0 ? _e : false) {
|
|
7438
|
-
this.outline = true;
|
|
7439
|
-
}
|
|
7440
|
-
}
|
|
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 {
|
|
7441
7655
|
set color(color) {
|
|
7442
|
-
this.
|
|
7656
|
+
this.options.color = color;
|
|
7443
7657
|
if (this.material instanceof THREE.MeshStandardMaterial) {
|
|
7444
7658
|
this.material.color.set(color);
|
|
7445
7659
|
}
|
|
7446
7660
|
}
|
|
7447
7661
|
get color() {
|
|
7448
|
-
return this.
|
|
7662
|
+
return this.options.color;
|
|
7449
7663
|
}
|
|
7450
|
-
|
|
7451
|
-
|
|
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();
|
|
7452
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
|
+
*/
|
|
7453
7703
|
getPlacement() {
|
|
7454
|
-
return this.
|
|
7704
|
+
return clonePlacement(this.getPlacementTransform());
|
|
7455
7705
|
}
|
|
7706
|
+
/**
|
|
7707
|
+
* Applies translation, rotation, and scale updates to the wrapped BRep.
|
|
7708
|
+
*/
|
|
7456
7709
|
setPlacement(placement) {
|
|
7457
|
-
var _a, _b, _c
|
|
7458
|
-
|
|
7459
|
-
this.
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
rotation: (_f = (_e = placement.rotation) === null || _e === void 0 ? void 0 : _e.clone()) !== null && _f !== void 0 ? _f : current.rotation.clone(),
|
|
7463
|
-
scale: (_h = (_g = placement.scale) === null || _g === void 0 ? void 0 : _g.clone()) !== null && _h !== void 0 ? _h : current.scale.clone(),
|
|
7464
|
-
});
|
|
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());
|
|
7465
7715
|
this.generateGeometry();
|
|
7466
7716
|
}
|
|
7467
7717
|
setTransform(translation, rotation, scale) {
|
|
7468
|
-
this.
|
|
7469
|
-
|
|
7718
|
+
this.setPlacement({
|
|
7719
|
+
translation,
|
|
7720
|
+
rotation,
|
|
7721
|
+
scale,
|
|
7722
|
+
});
|
|
7470
7723
|
}
|
|
7471
7724
|
setTranslation(translation) {
|
|
7472
|
-
this.
|
|
7473
|
-
this.generateGeometry();
|
|
7725
|
+
this.setPlacement({ translation });
|
|
7474
7726
|
}
|
|
7475
7727
|
setRotation(rotation) {
|
|
7476
|
-
this.
|
|
7477
|
-
this.generateGeometry();
|
|
7728
|
+
this.setPlacement({ rotation });
|
|
7478
7729
|
}
|
|
7479
7730
|
setScale(scale) {
|
|
7480
|
-
this.
|
|
7481
|
-
this.generateGeometry();
|
|
7482
|
-
}
|
|
7483
|
-
union(operand, options) {
|
|
7484
|
-
return booleanUnion(this, operand, options);
|
|
7485
|
-
}
|
|
7486
|
-
intersection(operand, options) {
|
|
7487
|
-
return booleanIntersection(this, operand, options);
|
|
7731
|
+
this.setPlacement({ scale });
|
|
7488
7732
|
}
|
|
7489
|
-
|
|
7490
|
-
return
|
|
7733
|
+
getAnchor() {
|
|
7734
|
+
return this.getPlacementTransform().anchor.clone();
|
|
7491
7735
|
}
|
|
7492
|
-
|
|
7493
|
-
this.
|
|
7494
|
-
|
|
7736
|
+
setAnchor(anchor) {
|
|
7737
|
+
this.options.anchor = anchor.clone();
|
|
7738
|
+
this.solid.setPlacement(this.getPlacementTransform());
|
|
7739
|
+
this.generateGeometry();
|
|
7495
7740
|
}
|
|
7496
|
-
|
|
7497
|
-
|
|
7741
|
+
/**
|
|
7742
|
+
* Solid is always convertible back to the freeform editing wrapper.
|
|
7743
|
+
*/
|
|
7744
|
+
canConvertToFreeform() {
|
|
7745
|
+
return true;
|
|
7498
7746
|
}
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
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.");
|
|
7504
7753
|
}
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
fatOutlines: this._fatOutlines,
|
|
7510
|
-
outlineWidth: this._outlineWidth,
|
|
7511
|
-
}), "f");
|
|
7512
|
-
this.add(__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f"));
|
|
7513
|
-
}
|
|
7514
|
-
get outline() {
|
|
7515
|
-
return this._outlineEnabled;
|
|
7754
|
+
return createFreeformGeometry(this.getLocalBrepSerialized(), {
|
|
7755
|
+
id,
|
|
7756
|
+
placement: this.getPlacementTransform(),
|
|
7757
|
+
});
|
|
7516
7758
|
}
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7759
|
+
/**
|
|
7760
|
+
* Returns the world-space serialized BRep payload for this solid.
|
|
7761
|
+
*/
|
|
7762
|
+
getBrepSerialized() {
|
|
7763
|
+
return this.solid.getBrepSerialized();
|
|
7522
7764
|
}
|
|
7523
|
-
|
|
7524
|
-
|
|
7765
|
+
/**
|
|
7766
|
+
* Returns the local-space serialized BRep payload for this solid.
|
|
7767
|
+
*/
|
|
7768
|
+
getLocalBrepSerialized() {
|
|
7769
|
+
return this.solid.getLocalBrepSerialized();
|
|
7525
7770
|
}
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
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.");
|
|
7530
7778
|
}
|
|
7779
|
+
return JSON.parse(brepSerialized);
|
|
7531
7780
|
}
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
this
|
|
7537
|
-
this.geometry.dispose();
|
|
7538
|
-
if (Array.isArray(this.material)) {
|
|
7539
|
-
this.material.forEach((material) => material.dispose());
|
|
7540
|
-
return;
|
|
7541
|
-
}
|
|
7542
|
-
this.material.dispose();
|
|
7781
|
+
/**
|
|
7782
|
+
* Subtracts another boolean operand from this solid.
|
|
7783
|
+
*/
|
|
7784
|
+
subtract(operand, options) {
|
|
7785
|
+
return subtractShapeOperand(this, operand, options);
|
|
7543
7786
|
}
|
|
7787
|
+
/**
|
|
7788
|
+
* Rebuilds the visible mesh and outline from the current freeform geometry.
|
|
7789
|
+
*/
|
|
7544
7790
|
generateGeometry() {
|
|
7545
7791
|
var _a;
|
|
7546
|
-
const
|
|
7547
|
-
this.writePositionsToGeometry(this.geometry,
|
|
7792
|
+
const bufferData = this.solid.getGeometryBuffer();
|
|
7793
|
+
this.writePositionsToGeometry(this.geometry, bufferData);
|
|
7548
7794
|
if (this.material instanceof THREE.MeshStandardMaterial) {
|
|
7549
|
-
this.material.color.set(this.
|
|
7795
|
+
this.material.color.set(this.options.color);
|
|
7550
7796
|
this.material.transparent = true;
|
|
7551
|
-
this.material.opacity = 0.
|
|
7552
|
-
this.material.side = THREE.FrontSide;
|
|
7797
|
+
this.material.opacity = 0.6;
|
|
7553
7798
|
}
|
|
7554
7799
|
else {
|
|
7555
7800
|
if (Array.isArray(this.material)) {
|
|
@@ -7559,16 +7804,12 @@ class ExtrudedShape extends THREE.Mesh {
|
|
|
7559
7804
|
this.material.dispose();
|
|
7560
7805
|
}
|
|
7561
7806
|
this.material = new THREE.MeshStandardMaterial({
|
|
7562
|
-
color: this.
|
|
7807
|
+
color: this.options.color,
|
|
7563
7808
|
transparent: true,
|
|
7564
|
-
opacity: 0.
|
|
7565
|
-
side: THREE.FrontSide,
|
|
7566
|
-
polygonOffset: true,
|
|
7567
|
-
polygonOffsetFactor: 1,
|
|
7568
|
-
polygonOffsetUnits: 1,
|
|
7809
|
+
opacity: 0.6,
|
|
7569
7810
|
});
|
|
7570
7811
|
}
|
|
7571
|
-
if (
|
|
7812
|
+
if (bufferData.length > 0) {
|
|
7572
7813
|
this.geometry.computeVertexNormals();
|
|
7573
7814
|
this.geometry.computeBoundingBox();
|
|
7574
7815
|
this.geometry.computeBoundingSphere();
|
|
@@ -7581,53 +7822,103 @@ class ExtrudedShape extends THREE.Mesh {
|
|
|
7581
7822
|
if (!this._outlineEnabled) {
|
|
7582
7823
|
return;
|
|
7583
7824
|
}
|
|
7584
|
-
const
|
|
7585
|
-
if (!__classPrivateFieldGet(this,
|
|
7825
|
+
const outlineData = this.solid.getOutlineGeometryBuffer();
|
|
7826
|
+
if (!__classPrivateFieldGet(this, _Solid_outlineMesh, "f")) {
|
|
7586
7827
|
this.outline = true;
|
|
7587
7828
|
return;
|
|
7588
7829
|
}
|
|
7589
|
-
if (__classPrivateFieldGet(this,
|
|
7590
|
-
this.writePositionsToGeometry(__classPrivateFieldGet(this,
|
|
7591
|
-
__classPrivateFieldGet(this,
|
|
7592
|
-
__classPrivateFieldGet(this,
|
|
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();
|
|
7593
7834
|
return;
|
|
7594
7835
|
}
|
|
7595
|
-
const fatGeometry = __classPrivateFieldGet(this,
|
|
7596
|
-
fatGeometry.setPositions(
|
|
7597
|
-
const fatOutline = __classPrivateFieldGet(this,
|
|
7836
|
+
const fatGeometry = __classPrivateFieldGet(this, _Solid_outlineMesh, "f").geometry;
|
|
7837
|
+
fatGeometry.setPositions(outlineData);
|
|
7838
|
+
const fatOutline = __classPrivateFieldGet(this, _Solid_outlineMesh, "f");
|
|
7598
7839
|
(_a = fatOutline.computeLineDistances) === null || _a === void 0 ? void 0 : _a.call(fatOutline);
|
|
7599
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
|
+
}
|
|
7600
7884
|
clearOutlineMesh() {
|
|
7601
|
-
if (!__classPrivateFieldGet(this,
|
|
7885
|
+
if (!__classPrivateFieldGet(this, _Solid_outlineMesh, "f")) {
|
|
7602
7886
|
return;
|
|
7603
7887
|
}
|
|
7604
|
-
this.remove(__classPrivateFieldGet(this,
|
|
7605
|
-
disposeShapeOutlineMesh(__classPrivateFieldGet(this,
|
|
7606
|
-
__classPrivateFieldSet(this,
|
|
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
|
+
});
|
|
7607
7899
|
}
|
|
7608
7900
|
writePositionsToGeometry(geometry, positions) {
|
|
7609
|
-
const
|
|
7610
|
-
if (!(
|
|
7611
|
-
|
|
7612
|
-
|
|
7901
|
+
const attribute = geometry.getAttribute("position");
|
|
7902
|
+
if (!(attribute instanceof THREE.BufferAttribute) ||
|
|
7903
|
+
attribute.itemSize !== 3 ||
|
|
7904
|
+
attribute.count !== positions.length / 3) {
|
|
7613
7905
|
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
|
|
7614
7906
|
return;
|
|
7615
7907
|
}
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
existing.needsUpdate = true;
|
|
7908
|
+
attribute.array.set(positions);
|
|
7909
|
+
attribute.needsUpdate = true;
|
|
7619
7910
|
}
|
|
7620
7911
|
}
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
*/
|
|
7626
|
-
function subtractShapeOperand(host, operand, options) {
|
|
7627
|
-
return booleanSubtraction(host, operand, options);
|
|
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);
|
|
7628
7916
|
}
|
|
7629
7917
|
|
|
7630
7918
|
var _Polygon_outlineMesh;
|
|
7919
|
+
/**
|
|
7920
|
+
* Planar polygon mesh with support for holes, booleans, and extrusion to `Solid`.
|
|
7921
|
+
*/
|
|
7631
7922
|
class Polygon extends THREE.Mesh {
|
|
7632
7923
|
set color(color) {
|
|
7633
7924
|
this.options.color = color;
|
|
@@ -7638,8 +7929,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7638
7929
|
get color() {
|
|
7639
7930
|
return this.options.color;
|
|
7640
7931
|
}
|
|
7641
|
-
// TODO: Make Options Optional
|
|
7642
|
-
// constructor(vertices?: Vector3[]) // If no vertices are provided, it will be an empty polygon
|
|
7643
7932
|
constructor(options) {
|
|
7644
7933
|
var _a, _b, _c, _d, _e;
|
|
7645
7934
|
super();
|
|
@@ -7658,12 +7947,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7658
7947
|
this._fatOutlines = false;
|
|
7659
7948
|
this._outlineWidth = 1;
|
|
7660
7949
|
this._outlineColor = 0x000000;
|
|
7661
|
-
this.transformationMatrix = new THREE.Matrix4();
|
|
7662
|
-
// private _placement: THREE.Vector3 = new THREE.Vector3(0, 0, 0);
|
|
7663
|
-
// private _yaw: number = 0;
|
|
7664
|
-
// Store local center offset to align outlines
|
|
7665
|
-
// TODO: Can this be moved to Engine? It can increase performance | Needs to be used in other shapes too
|
|
7666
|
-
this._geometryCenterOffset = new THREE.Vector3();
|
|
7667
7950
|
this.ogid = (_a = options === null || options === void 0 ? void 0 : options.ogid) !== null && _a !== void 0 ? _a : getUUID();
|
|
7668
7951
|
this.polygon = new OGPolygon(this.ogid);
|
|
7669
7952
|
this.options = Object.assign(Object.assign({}, this.options), options);
|
|
@@ -7680,19 +7963,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7680
7963
|
rotation: (_d = this.options.rotation) === null || _d === void 0 ? void 0 : _d.clone(),
|
|
7681
7964
|
scale: (_e = this.options.scale) === null || _e === void 0 ? void 0 : _e.clone(),
|
|
7682
7965
|
});
|
|
7683
|
-
// TODO: THIS MIGHT HELP WITH SHARING THE POSITION with KERNEL when something is changed
|
|
7684
|
-
// const originalSet = this.position.set.bind(this.position);
|
|
7685
|
-
// this.position.set = (x: number, y: number, z: number) => {
|
|
7686
|
-
// console.log(`Position set to (${x}, ${y}, ${z})`);
|
|
7687
|
-
// // your custom logic here (e.g., notify OpenGeometry)
|
|
7688
|
-
// return originalSet(x, y, z);
|
|
7689
|
-
// };
|
|
7690
|
-
// // Optional: Override copy if you're using .copy() too
|
|
7691
|
-
// const originalCopy = this.position.copy.bind(this.position);
|
|
7692
|
-
// this.position.copy = (v: THREE.Vector3) => {
|
|
7693
|
-
// console.log(`Position copied from ${v.x}, ${v.y}, ${v.z}`);
|
|
7694
|
-
// return originalCopy(v);
|
|
7695
|
-
// };
|
|
7696
7966
|
}
|
|
7697
7967
|
validateOptions() {
|
|
7698
7968
|
if (!this.options) {
|
|
@@ -7768,18 +8038,27 @@ class Polygon extends THREE.Mesh {
|
|
|
7768
8038
|
this.setPlacement({ scale });
|
|
7769
8039
|
}
|
|
7770
8040
|
getPlacement() {
|
|
7771
|
-
return clonePlacement
|
|
8041
|
+
return clonePlacement({
|
|
7772
8042
|
translation: this.options.translation,
|
|
7773
8043
|
rotation: this.options.rotation,
|
|
7774
8044
|
scale: this.options.scale,
|
|
7775
8045
|
});
|
|
7776
8046
|
}
|
|
8047
|
+
/**
|
|
8048
|
+
* Returns the editing capability payload advertised by parametric wrappers.
|
|
8049
|
+
*/
|
|
7777
8050
|
getEditCapabilities() {
|
|
7778
8051
|
return createParametricEditCapabilities("polygon", "profile");
|
|
7779
8052
|
}
|
|
8053
|
+
/**
|
|
8054
|
+
* Polygon always supports conversion into the freeform editing wrapper.
|
|
8055
|
+
*/
|
|
7780
8056
|
canConvertToFreeform() {
|
|
7781
8057
|
return true;
|
|
7782
8058
|
}
|
|
8059
|
+
/**
|
|
8060
|
+
* Returns a freeform wrapper for direct BRep editing of this polygon.
|
|
8061
|
+
*/
|
|
7783
8062
|
toFreeform(id = this.ogid) {
|
|
7784
8063
|
if (!this.canConvertToFreeform()) {
|
|
7785
8064
|
throw new Error("This entity cannot be converted to freeform.");
|
|
@@ -7789,62 +8068,8 @@ class Polygon extends THREE.Mesh {
|
|
|
7789
8068
|
placement: this.getPlacement(),
|
|
7790
8069
|
});
|
|
7791
8070
|
}
|
|
7792
|
-
// /**
|
|
7793
|
-
// * Sets the placement of the polygon in 3D space.
|
|
7794
|
-
// * @param x X-coordinate
|
|
7795
|
-
// * @param y Y-coordinate
|
|
7796
|
-
// * @param z Z-coordinate
|
|
7797
|
-
// */
|
|
7798
|
-
// placement(x: number, y: number, z: number) {
|
|
7799
|
-
// this._placement.set(x, y, z);
|
|
7800
|
-
// // Do the recalculation of position based on the placement
|
|
7801
|
-
// const clonedObject = this.clone();
|
|
7802
|
-
// clonedObject.rotation.set(0, 0, 0);
|
|
7803
|
-
// clonedObject.geometry.computeBoundingBox();
|
|
7804
|
-
// if (!clonedObject.geometry.boundingBox) return;
|
|
7805
|
-
// const center = new THREE.Vector3();
|
|
7806
|
-
// clonedObject.geometry.boundingBox.getCenter(center);
|
|
7807
|
-
// const min = clonedObject.geometry.boundingBox.min;
|
|
7808
|
-
// this.position.set(
|
|
7809
|
-
// center.x + this._placement.x - min.x,
|
|
7810
|
-
// // this._placement.y,
|
|
7811
|
-
// 0.01, // Set Y to a small value to avoid z-fighting
|
|
7812
|
-
// center.z + this._placement.z - min.z
|
|
7813
|
-
// );
|
|
7814
|
-
// }
|
|
7815
|
-
// positionToPlacement() {
|
|
7816
|
-
// const clonedObject = this.clone();
|
|
7817
|
-
// clonedObject.rotation.set(0, 0, 0);
|
|
7818
|
-
// clonedObject.geometry.computeBoundingBox();
|
|
7819
|
-
// if (!clonedObject.geometry.boundingBox) return;
|
|
7820
|
-
// const min = clonedObject.geometry.boundingBox.min;
|
|
7821
|
-
// this._placement.set(
|
|
7822
|
-
// this.position.x + min.x,
|
|
7823
|
-
// this.position.y + min.y,
|
|
7824
|
-
// this.position.z + min.z
|
|
7825
|
-
// );
|
|
7826
|
-
// // console.log("Placement set to:", this._placement.x, this._placement.y, this._placement.z);
|
|
7827
|
-
// }
|
|
7828
|
-
// /**
|
|
7829
|
-
// * Rotates the polygon around the Y-axis.
|
|
7830
|
-
// * @param angle Rotation angle in Degrees
|
|
7831
|
-
// */
|
|
7832
|
-
// set yaw(angle: number) {
|
|
7833
|
-
// this._yaw = angle;
|
|
7834
|
-
// this.rotation.set(0, 0, 0);
|
|
7835
|
-
// this.rotation.y = THREE.MathUtils.degToRad(this._yaw);
|
|
7836
|
-
// }
|
|
7837
|
-
// get yaw() {
|
|
7838
|
-
// return this._yaw;
|
|
7839
|
-
// }
|
|
7840
8071
|
cleanGeometry() {
|
|
7841
|
-
this.
|
|
7842
|
-
if (Array.isArray(this.material)) {
|
|
7843
|
-
this.material.forEach(mat => mat.dispose());
|
|
7844
|
-
}
|
|
7845
|
-
else {
|
|
7846
|
-
this.material.dispose();
|
|
7847
|
-
}
|
|
8072
|
+
this.disposeResources();
|
|
7848
8073
|
}
|
|
7849
8074
|
generateGeometry() {
|
|
7850
8075
|
var _a;
|
|
@@ -7894,24 +8119,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7894
8119
|
fatGeometry.setPositions(outlineData);
|
|
7895
8120
|
const fatOutline = __classPrivateFieldGet(this, _Polygon_outlineMesh, "f");
|
|
7896
8121
|
(_a = fatOutline.computeLineDistances) === null || _a === void 0 ? void 0 : _a.call(fatOutline);
|
|
7897
|
-
// this.geometry.computeBoundingBox();
|
|
7898
|
-
// const originalCenter = new THREE.Vector3();
|
|
7899
|
-
// this.geometry.boundingBox?.getCenter(originalCenter);
|
|
7900
|
-
// console.log("Original Center:", originalCenter.x, originalCenter.y, originalCenter.z);
|
|
7901
|
-
// this.geometry.center();
|
|
7902
|
-
// this.geometry.computeBoundingBox();
|
|
7903
|
-
// const newCenter = new THREE.Vector3();
|
|
7904
|
-
// this.geometry.boundingBox?.getCenter(newCenter);
|
|
7905
|
-
// console.log("New Center after centering:", newCenter.x, newCenter.y, newCenter.z);
|
|
7906
|
-
// if (!this.geometry.boundingBox) return;
|
|
7907
|
-
// const min = this.geometry.boundingBox.min;
|
|
7908
|
-
// // console.log("Position before centering:", this.position.x, this.position.y, this.position.z);
|
|
7909
|
-
// console.log("Bounding Box Min:", min.x, min.y, min.z);
|
|
7910
|
-
// this.position.set(-min.x, 0, -min.z);
|
|
7911
|
-
// if (this._placement) {
|
|
7912
|
-
// this.placement(this._placement.x, this._placement.y, this._placement.z);
|
|
7913
|
-
// }
|
|
7914
|
-
// console.log("New Position after centering:", this.position.x, this.position.y, this.position.z);
|
|
7915
8122
|
}
|
|
7916
8123
|
addVertices(vertices) {
|
|
7917
8124
|
if (!this.polygon)
|
|
@@ -7920,59 +8127,6 @@ class Polygon extends THREE.Mesh {
|
|
|
7920
8127
|
vertices: vertices.map((vertex) => vertex.clone()),
|
|
7921
8128
|
});
|
|
7922
8129
|
}
|
|
7923
|
-
saveTransformationToBREP() {
|
|
7924
|
-
if (!this.polygon)
|
|
7925
|
-
return;
|
|
7926
|
-
}
|
|
7927
|
-
// /**
|
|
7928
|
-
// * Rotates the object around the Y-axis.
|
|
7929
|
-
// * @param angle Rotation angle in Degrees
|
|
7930
|
-
// * @returns
|
|
7931
|
-
// * @summary If rotation methods from threejs is used, it will rotate around the first vertex which might not be desired.
|
|
7932
|
-
// */
|
|
7933
|
-
// rotateOnYAxis(angle: number) {
|
|
7934
|
-
// if (!this.polygon) return;
|
|
7935
|
-
// }
|
|
7936
|
-
// resetVertices() {
|
|
7937
|
-
// if (!this.polygon) return;
|
|
7938
|
-
// this.layerVertices = [];
|
|
7939
|
-
// this.geometry.dispose();
|
|
7940
|
-
// this.polygon?.clear_vertices();
|
|
7941
|
-
// this.isTriangulated = false;
|
|
7942
|
-
// }
|
|
7943
|
-
// addVertex(threeVertex: Vector3) {
|
|
7944
|
-
// if (this.isTriangulated) {
|
|
7945
|
-
// this.layerVertices = [];
|
|
7946
|
-
// this.geometry.dispose();
|
|
7947
|
-
// this.polygon?.clear_vertices();
|
|
7948
|
-
// this.isTriangulated = false;
|
|
7949
|
-
// for (const vertex of this.layerBackVertices) {
|
|
7950
|
-
// this.layerVertices.push(vertex.clone());
|
|
7951
|
-
// }
|
|
7952
|
-
// };
|
|
7953
|
-
// const backupVertex = new Vector3(
|
|
7954
|
-
// parseFloat(threeVertex.x.toFixed(2)),
|
|
7955
|
-
// 0,
|
|
7956
|
-
// parseFloat(threeVertex.z.toFixed(2))
|
|
7957
|
-
// );
|
|
7958
|
-
// this.layerBackVertices.push(backupVertex);
|
|
7959
|
-
// const vertex = new Vector3(
|
|
7960
|
-
// parseFloat(threeVertex.x.toFixed(2)),
|
|
7961
|
-
// // when doing the parse operation getting -0 instead of 0
|
|
7962
|
-
// 0,
|
|
7963
|
-
// parseFloat(threeVertex.z.toFixed(2))
|
|
7964
|
-
// );
|
|
7965
|
-
// this.layerVertices.push(vertex);
|
|
7966
|
-
// if (this.layerVertices.length > 3) {
|
|
7967
|
-
// this.polygon?.add_vertices(this.layerVertices);
|
|
7968
|
-
// const bufFlush = this.polygon?.triangulate();
|
|
7969
|
-
// if (!bufFlush) {
|
|
7970
|
-
// return;
|
|
7971
|
-
// }
|
|
7972
|
-
// this.addFlushBufferToScene(bufFlush);
|
|
7973
|
-
// this.isTriangulated = true;
|
|
7974
|
-
// }
|
|
7975
|
-
// }
|
|
7976
8130
|
addHole(holeVertices) {
|
|
7977
8131
|
var _a, _b;
|
|
7978
8132
|
if (!this.polygon)
|
|
@@ -7985,28 +8139,29 @@ class Polygon extends THREE.Mesh {
|
|
|
7985
8139
|
holes: ((_b = this.options.holes) !== null && _b !== void 0 ? _b : []).map((hole) => hole.map((vertex) => vertex.clone())),
|
|
7986
8140
|
});
|
|
7987
8141
|
}
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
const localBrepSerialized = this.polygon.get_local_brep_serialized();
|
|
7994
|
-
const extrudedLocalBrep = extrudeFaceExport(localBrepSerialized, faceId, height);
|
|
8142
|
+
/**
|
|
8143
|
+
* Builds a kernel-backed `Solid` by extruding this polygon face by `height`.
|
|
8144
|
+
*/
|
|
8145
|
+
extrude(height) {
|
|
8146
|
+
const config = this.getConfig();
|
|
7995
8147
|
const placement = this.getPlacement();
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
fatOutlines:
|
|
8000
|
-
outlineWidth:
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
rotation: placement.rotation,
|
|
8006
|
-
scale: placement.scale,
|
|
8007
|
-
},
|
|
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(),
|
|
8008
8157
|
});
|
|
8158
|
+
solid.outline = this.outline;
|
|
8159
|
+
solid.outlineColor = this.outlineColor;
|
|
8160
|
+
return solid;
|
|
8009
8161
|
}
|
|
8162
|
+
/**
|
|
8163
|
+
* Returns the serialized BRep payload for this polygon.
|
|
8164
|
+
*/
|
|
8010
8165
|
getBrepData() {
|
|
8011
8166
|
if (!this.polygon)
|
|
8012
8167
|
return null;
|
|
@@ -8026,7 +8181,6 @@ class Polygon extends THREE.Mesh {
|
|
|
8026
8181
|
get outlineColor() {
|
|
8027
8182
|
return getShapeOutlineColor(__classPrivateFieldGet(this, _Polygon_outlineMesh, "f"), this._outlineColor);
|
|
8028
8183
|
}
|
|
8029
|
-
// TODO: Do we need a separate method for Hole Outlines?
|
|
8030
8184
|
set outline(enable) {
|
|
8031
8185
|
this._outlineEnabled = enable;
|
|
8032
8186
|
this.clearOutlineMesh();
|
|
@@ -8038,8 +8192,6 @@ class Polygon extends THREE.Mesh {
|
|
|
8038
8192
|
fatOutlines: this._fatOutlines,
|
|
8039
8193
|
outlineWidth: this._outlineWidth,
|
|
8040
8194
|
}), "f");
|
|
8041
|
-
// this.#outlineMesh.geometry.center();
|
|
8042
|
-
// this.#outlineMesh.applyMatrix4(this.transformationMatrix);
|
|
8043
8195
|
this.add(__classPrivateFieldGet(this, _Polygon_outlineMesh, "f"));
|
|
8044
8196
|
}
|
|
8045
8197
|
}
|
|
@@ -8066,20 +8218,8 @@ class Polygon extends THREE.Mesh {
|
|
|
8066
8218
|
get outlineWidth() {
|
|
8067
8219
|
return this._outlineWidth;
|
|
8068
8220
|
}
|
|
8069
|
-
// bTree() {
|
|
8070
|
-
// if (!this.polygon) return;
|
|
8071
|
-
// const bTree = this.polygon.binary_tree();
|
|
8072
|
-
// const parsedData = JSON.parse(bTree);
|
|
8073
|
-
// console.log(parsedData);
|
|
8074
|
-
// }
|
|
8075
8221
|
disposeGeometryMaterial() {
|
|
8076
|
-
|
|
8077
|
-
this.geometry.dispose();
|
|
8078
|
-
}
|
|
8079
|
-
if (this.material instanceof THREE.Material) {
|
|
8080
|
-
this.material.dispose();
|
|
8081
|
-
}
|
|
8082
|
-
this.clearOutlineMesh();
|
|
8222
|
+
this.disposeResources();
|
|
8083
8223
|
}
|
|
8084
8224
|
clearOutlineMesh() {
|
|
8085
8225
|
if (!__classPrivateFieldGet(this, _Polygon_outlineMesh, "f")) {
|
|
@@ -8090,20 +8230,7 @@ class Polygon extends THREE.Mesh {
|
|
|
8090
8230
|
__classPrivateFieldSet(this, _Polygon_outlineMesh, null, "f");
|
|
8091
8231
|
}
|
|
8092
8232
|
dispose() {
|
|
8093
|
-
|
|
8094
|
-
// this.geometry.dispose();
|
|
8095
|
-
// if (this.material instanceof THREE.Material) {
|
|
8096
|
-
// this.material.dispose();
|
|
8097
|
-
// }
|
|
8098
|
-
// if (this.#outlineMesh) {
|
|
8099
|
-
// this.#outlineMesh.geometry.dispose();
|
|
8100
|
-
// if (this.#outlineMesh.material instanceof THREE.Material) {
|
|
8101
|
-
// this.#outlineMesh.material.dispose();
|
|
8102
|
-
// }
|
|
8103
|
-
// }
|
|
8104
|
-
// this.polygon = null;
|
|
8105
|
-
// this.layerVertices = [];
|
|
8106
|
-
// this.layerBackVertices = [];
|
|
8233
|
+
this.disposeResources();
|
|
8107
8234
|
}
|
|
8108
8235
|
writePositionsToGeometry(geometry, positions) {
|
|
8109
8236
|
const existing = geometry.getAttribute("position");
|
|
@@ -8117,10 +8244,25 @@ class Polygon extends THREE.Mesh {
|
|
|
8117
8244
|
array.set(positions);
|
|
8118
8245
|
existing.needsUpdate = true;
|
|
8119
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
|
+
}
|
|
8120
8259
|
}
|
|
8121
8260
|
_Polygon_outlineMesh = new WeakMap();
|
|
8122
8261
|
|
|
8123
8262
|
var _Cylinder_outlineMesh;
|
|
8263
|
+
/**
|
|
8264
|
+
* Cylinder wrapper backed by the kernel cylindrical primitive.
|
|
8265
|
+
*/
|
|
8124
8266
|
class Cylinder extends THREE.Mesh {
|
|
8125
8267
|
set radius(value) {
|
|
8126
8268
|
this.setConfig({ radius: value });
|
|
@@ -8238,7 +8380,7 @@ class Cylinder extends THREE.Mesh {
|
|
|
8238
8380
|
this.setPlacement({ scale });
|
|
8239
8381
|
}
|
|
8240
8382
|
getPlacement() {
|
|
8241
|
-
return clonePlacement
|
|
8383
|
+
return clonePlacement({
|
|
8242
8384
|
translation: this.options.translation,
|
|
8243
8385
|
rotation: this.options.rotation,
|
|
8244
8386
|
scale: this.options.scale,
|
|
@@ -8391,6 +8533,9 @@ class Cylinder extends THREE.Mesh {
|
|
|
8391
8533
|
_Cylinder_outlineMesh = new WeakMap();
|
|
8392
8534
|
|
|
8393
8535
|
var _Cuboid_outlineMesh;
|
|
8536
|
+
/**
|
|
8537
|
+
* Box-shaped solid wrapper backed by the kernel cuboid primitive.
|
|
8538
|
+
*/
|
|
8394
8539
|
class Cuboid extends THREE.Mesh {
|
|
8395
8540
|
set width(value) {
|
|
8396
8541
|
this.setConfig({ width: value });
|
|
@@ -8443,7 +8588,7 @@ class Cuboid extends THREE.Mesh {
|
|
|
8443
8588
|
return this.options;
|
|
8444
8589
|
}
|
|
8445
8590
|
getPlacement() {
|
|
8446
|
-
return clonePlacement
|
|
8591
|
+
return clonePlacement({
|
|
8447
8592
|
translation: this.options.translation,
|
|
8448
8593
|
rotation: this.options.rotation,
|
|
8449
8594
|
scale: this.options.scale,
|
|
@@ -8645,6 +8790,9 @@ class Cuboid extends THREE.Mesh {
|
|
|
8645
8790
|
_Cuboid_outlineMesh = new WeakMap();
|
|
8646
8791
|
|
|
8647
8792
|
var _Opening_outlineMesh;
|
|
8793
|
+
/**
|
|
8794
|
+
* Opening wrapper used as a subtractive solid in architectural workflows.
|
|
8795
|
+
*/
|
|
8648
8796
|
class Opening extends THREE.Mesh {
|
|
8649
8797
|
set width(value) {
|
|
8650
8798
|
this.setConfig({ width: value });
|
|
@@ -8766,7 +8914,7 @@ class Opening extends THREE.Mesh {
|
|
|
8766
8914
|
this.setPlacement({ scale });
|
|
8767
8915
|
}
|
|
8768
8916
|
getPlacement() {
|
|
8769
|
-
return clonePlacement
|
|
8917
|
+
return clonePlacement({
|
|
8770
8918
|
translation: this.options.translation,
|
|
8771
8919
|
rotation: this.options.rotation,
|
|
8772
8920
|
scale: this.options.scale,
|
|
@@ -8931,6 +9079,9 @@ _Opening_outlineMesh = new WeakMap();
|
|
|
8931
9079
|
|
|
8932
9080
|
var _Sphere_outlineMesh;
|
|
8933
9081
|
/* eslint-enable no-unused-vars */
|
|
9082
|
+
/**
|
|
9083
|
+
* Sphere wrapper backed by the kernel sphere primitive.
|
|
9084
|
+
*/
|
|
8934
9085
|
class Sphere extends THREE.Mesh {
|
|
8935
9086
|
set radius(value) {
|
|
8936
9087
|
this.setConfig({ radius: value });
|
|
@@ -9050,7 +9201,7 @@ class Sphere extends THREE.Mesh {
|
|
|
9050
9201
|
this.setPlacement({ scale });
|
|
9051
9202
|
}
|
|
9052
9203
|
getPlacement() {
|
|
9053
|
-
return clonePlacement
|
|
9204
|
+
return clonePlacement({
|
|
9054
9205
|
translation: this.options.translation,
|
|
9055
9206
|
rotation: this.options.rotation,
|
|
9056
9207
|
scale: this.options.scale,
|
|
@@ -9204,6 +9355,9 @@ class Sphere extends THREE.Mesh {
|
|
|
9204
9355
|
_Sphere_outlineMesh = new WeakMap();
|
|
9205
9356
|
|
|
9206
9357
|
var _Wedge_outlineMesh;
|
|
9358
|
+
/**
|
|
9359
|
+
* Wedge wrapper backed by the kernel wedge primitive.
|
|
9360
|
+
*/
|
|
9207
9361
|
class Wedge extends THREE.Mesh {
|
|
9208
9362
|
set color(color) {
|
|
9209
9363
|
this.options.color = color;
|
|
@@ -9315,7 +9469,7 @@ class Wedge extends THREE.Mesh {
|
|
|
9315
9469
|
this.setPlacement({ scale });
|
|
9316
9470
|
}
|
|
9317
9471
|
getPlacement() {
|
|
9318
|
-
return clonePlacement
|
|
9472
|
+
return clonePlacement({
|
|
9319
9473
|
translation: this.options.translation,
|
|
9320
9474
|
rotation: this.options.rotation,
|
|
9321
9475
|
scale: this.options.scale,
|
|
@@ -9470,6 +9624,9 @@ _Wedge_outlineMesh = new WeakMap();
|
|
|
9470
9624
|
|
|
9471
9625
|
var _Sweep_outlineMesh;
|
|
9472
9626
|
/* eslint-enable no-unused-vars */
|
|
9627
|
+
/**
|
|
9628
|
+
* Sweep wrapper backed by the kernel sweep primitive.
|
|
9629
|
+
*/
|
|
9473
9630
|
class Sweep extends THREE.Mesh {
|
|
9474
9631
|
set color(color) {
|
|
9475
9632
|
this.options.color = color;
|
|
@@ -9611,7 +9768,7 @@ class Sweep extends THREE.Mesh {
|
|
|
9611
9768
|
this.setPlacement({ scale });
|
|
9612
9769
|
}
|
|
9613
9770
|
getPlacement() {
|
|
9614
|
-
return clonePlacement
|
|
9771
|
+
return clonePlacement({
|
|
9615
9772
|
translation: this.options.translation,
|
|
9616
9773
|
rotation: this.options.rotation,
|
|
9617
9774
|
scale: this.options.scale,
|
|
@@ -10117,9 +10274,7 @@ function createWallFromOffsetsExample(scene) {
|
|
|
10117
10274
|
* Builds a complete operand/result scene group for a boolean example page.
|
|
10118
10275
|
*/
|
|
10119
10276
|
function createBooleanExample(operation, options) {
|
|
10120
|
-
const preset = options
|
|
10121
|
-
? createSolidPreset(operation, options)
|
|
10122
|
-
: createPolygonPreset(operation, options);
|
|
10277
|
+
const preset = createPreset(operation, options);
|
|
10123
10278
|
const execute = getBooleanExecutor(operation);
|
|
10124
10279
|
const result = execute(preset.lhsOperand, preset.rhsOperand, options);
|
|
10125
10280
|
const group = new THREE.Group();
|
|
@@ -10135,6 +10290,16 @@ function createBooleanExample(operation, options) {
|
|
|
10135
10290
|
description: preset.description,
|
|
10136
10291
|
};
|
|
10137
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
|
+
}
|
|
10138
10303
|
/**
|
|
10139
10304
|
* Builds the solid-operand preset used by the example pages.
|
|
10140
10305
|
*/
|
|
@@ -10219,6 +10384,50 @@ function createPolygonPreset(operation, options) {
|
|
|
10219
10384
|
rhsVisual: rhs,
|
|
10220
10385
|
};
|
|
10221
10386
|
}
|
|
10387
|
+
/**
|
|
10388
|
+
* Builds an extrusion-first preset that exercises polygon.extrude(height) and
|
|
10389
|
+
* reuses the standard solid boolean pipeline.
|
|
10390
|
+
*/
|
|
10391
|
+
function createExtrudedPreset(operation, options) {
|
|
10392
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10393
|
+
const outlineWidth = (_a = options.outlineWidth) !== null && _a !== void 0 ? _a : 3;
|
|
10394
|
+
const extrudedOffset = (_b = options.extrudedOffset) !== null && _b !== void 0 ? _b : new Vector3(0.0, 0.0, 0.0);
|
|
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
|
+
],
|
|
10402
|
+
color: 0x60a5fa,
|
|
10403
|
+
fatOutlines: (_c = options.fatOutlines) !== null && _c !== void 0 ? _c : true,
|
|
10404
|
+
outlineWidth,
|
|
10405
|
+
});
|
|
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
|
+
],
|
|
10413
|
+
color: 0xf97316,
|
|
10414
|
+
fatOutlines: (_d = options.fatOutlines) !== null && _d !== void 0 ? _d : true,
|
|
10415
|
+
outlineWidth,
|
|
10416
|
+
});
|
|
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;
|
|
10422
|
+
return {
|
|
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,
|
|
10429
|
+
};
|
|
10430
|
+
}
|
|
10222
10431
|
/**
|
|
10223
10432
|
* Selects the exported boolean helper that matches the current example mode.
|
|
10224
10433
|
*/
|
|
@@ -10356,6 +10565,9 @@ function createEditorModesExample(scene) {
|
|
|
10356
10565
|
};
|
|
10357
10566
|
}
|
|
10358
10567
|
|
|
10568
|
+
/**
|
|
10569
|
+
* Shared runtime entrypoint used to initialize the OpenGeometry wasm module.
|
|
10570
|
+
*/
|
|
10359
10571
|
class OpenGeometry {
|
|
10360
10572
|
get enableDebug() {
|
|
10361
10573
|
return this._enableDebug;
|
|
@@ -10422,5 +10634,5 @@ class OpenGeometry {
|
|
|
10422
10634
|
OpenGeometry.version = OPEN_GEOMETRY_THREE_VERSION;
|
|
10423
10635
|
OpenGeometry.instance = null;
|
|
10424
10636
|
|
|
10425
|
-
export { Arc, BooleanResult, Cuboid, Curve, Cylinder,
|
|
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 };
|
|
10426
10638
|
//# sourceMappingURL=index.js.map
|