opengeometry 2.0.1 → 2.0.2
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/index.js +145 -333
- package/index.js.map +1 -1
- package/opengeometry/pkg/opengeometry.d.ts +199 -201
- package/opengeometry/pkg/opengeometry.js +18 -45
- package/opengeometry/pkg/opengeometry_bg.wasm +0 -0
- package/opengeometry/pkg/opengeometry_bg.wasm.d.ts +199 -200
- package/opengeometry_bg.wasm +0 -0
- package/opengeometry_bg.wasm.d.ts +199 -200
- package/package.json +1 -1
- package/src/examples/booleans.d.ts +2 -1
- package/src/shapes/index.d.ts +0 -1
- package/src/shapes/polygon.d.ts +1 -4
- 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,16 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
178
178
|
function isLikeNone(x) {
|
|
179
179
|
return x === undefined || x === null;
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*
|
|
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);
|
|
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)));
|
|
206
187
|
}
|
|
188
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
189
|
+
return result;
|
|
207
190
|
}
|
|
208
|
-
|
|
209
191
|
/**
|
|
210
192
|
* Wasm entry point for union.
|
|
211
193
|
* @param {string} lhs_brep_serialized
|
|
@@ -268,16 +250,6 @@ function booleanSubtraction$1(lhs_brep_serialized, rhs_brep_serialized, options_
|
|
|
268
250
|
}
|
|
269
251
|
return OGBooleanResult.__wrap(ret[0]);
|
|
270
252
|
}
|
|
271
|
-
function getArrayJsValueFromWasm0(ptr, len) {
|
|
272
|
-
ptr = ptr >>> 0;
|
|
273
|
-
const mem = getDataViewMemory0();
|
|
274
|
-
const result = [];
|
|
275
|
-
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
276
|
-
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
277
|
-
}
|
|
278
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
279
|
-
return result;
|
|
280
|
-
}
|
|
281
253
|
const Matrix3Finalization = typeof FinalizationRegistry === 'undefined' ? {
|
|
282
254
|
register: () => {},
|
|
283
255
|
unregister: () => {}
|
|
@@ -2605,7 +2577,7 @@ class OGLine {
|
|
|
2605
2577
|
* @returns {Vector3}
|
|
2606
2578
|
*/
|
|
2607
2579
|
get_anchor() {
|
|
2608
|
-
const ret = wasm.
|
|
2580
|
+
const ret = wasm.ogline_get_anchor(this.__wbg_ptr);
|
|
2609
2581
|
return Vector3.__wrap(ret);
|
|
2610
2582
|
}
|
|
2611
2583
|
/**
|
|
@@ -3231,7 +3203,7 @@ class OGPolyline {
|
|
|
3231
3203
|
* @returns {Vector3}
|
|
3232
3204
|
*/
|
|
3233
3205
|
get_anchor() {
|
|
3234
|
-
const ret = wasm.
|
|
3206
|
+
const ret = wasm.ogline_get_anchor(this.__wbg_ptr);
|
|
3235
3207
|
return Vector3.__wrap(ret);
|
|
3236
3208
|
}
|
|
3237
3209
|
/**
|
|
@@ -5222,7 +5194,7 @@ class OGWedge {
|
|
|
5222
5194
|
* @returns {Vector3}
|
|
5223
5195
|
*/
|
|
5224
5196
|
get_anchor() {
|
|
5225
|
-
const ret = wasm.
|
|
5197
|
+
const ret = wasm.ogline_get_anchor(this.__wbg_ptr);
|
|
5226
5198
|
return Vector3.__wrap(ret);
|
|
5227
5199
|
}
|
|
5228
5200
|
}
|
|
@@ -5655,7 +5627,6 @@ var OGKernel = /*#__PURE__*/Object.freeze({
|
|
|
5655
5627
|
booleanSubtraction: booleanSubtraction$1,
|
|
5656
5628
|
booleanUnion: booleanUnion$1,
|
|
5657
5629
|
default: __wbg_init,
|
|
5658
|
-
extrudeBrepFace: extrudeBrepFace,
|
|
5659
5630
|
initSync: initSync
|
|
5660
5631
|
});
|
|
5661
5632
|
|
|
@@ -5737,7 +5708,7 @@ function getUUID() {
|
|
|
5737
5708
|
return uuid;
|
|
5738
5709
|
}
|
|
5739
5710
|
|
|
5740
|
-
function cloneVector$
|
|
5711
|
+
function cloneVector$1(vector, fallback) {
|
|
5741
5712
|
var _a;
|
|
5742
5713
|
return (_a = vector === null || vector === void 0 ? void 0 : vector.clone()) !== null && _a !== void 0 ? _a : new Vector3(...fallback);
|
|
5743
5714
|
}
|
|
@@ -5751,31 +5722,31 @@ function createParametricEditCapabilities(entityType, editFamily) {
|
|
|
5751
5722
|
canConvertToFreeform: true,
|
|
5752
5723
|
};
|
|
5753
5724
|
}
|
|
5754
|
-
function clonePlacement
|
|
5725
|
+
function clonePlacement(placement) {
|
|
5755
5726
|
return {
|
|
5756
|
-
translation: cloneVector$
|
|
5757
|
-
rotation: cloneVector$
|
|
5758
|
-
scale: cloneVector$
|
|
5727
|
+
translation: cloneVector$1(placement.translation, [0, 0, 0]),
|
|
5728
|
+
rotation: cloneVector$1(placement.rotation, [0, 0, 0]),
|
|
5729
|
+
scale: cloneVector$1(placement.scale, [1, 1, 1]),
|
|
5759
5730
|
};
|
|
5760
5731
|
}
|
|
5761
5732
|
function toObjectTransformation$1(placement) {
|
|
5762
5733
|
if ("anchor" in placement) {
|
|
5763
5734
|
return {
|
|
5764
|
-
anchor: cloneVector$
|
|
5765
|
-
translation: cloneVector$
|
|
5766
|
-
rotation: cloneVector$
|
|
5767
|
-
scale: cloneVector$
|
|
5735
|
+
anchor: cloneVector$1(placement.anchor, [0, 0, 0]),
|
|
5736
|
+
translation: cloneVector$1(placement.translation, [0, 0, 0]),
|
|
5737
|
+
rotation: cloneVector$1(placement.rotation, [0, 0, 0]),
|
|
5738
|
+
scale: cloneVector$1(placement.scale, [1, 1, 1]),
|
|
5768
5739
|
};
|
|
5769
5740
|
}
|
|
5770
5741
|
return {
|
|
5771
5742
|
anchor: new Vector3(0, 0, 0),
|
|
5772
|
-
translation: cloneVector$
|
|
5773
|
-
rotation: cloneVector$
|
|
5774
|
-
scale: cloneVector$
|
|
5743
|
+
translation: cloneVector$1(placement.translation, [0, 0, 0]),
|
|
5744
|
+
rotation: cloneVector$1(placement.rotation, [0, 0, 0]),
|
|
5745
|
+
scale: cloneVector$1(placement.scale, [1, 1, 1]),
|
|
5775
5746
|
};
|
|
5776
5747
|
}
|
|
5777
5748
|
|
|
5778
|
-
function parseJson$
|
|
5749
|
+
function parseJson$1(payload) {
|
|
5779
5750
|
return JSON.parse(payload);
|
|
5780
5751
|
}
|
|
5781
5752
|
function toVector3$1(value) {
|
|
@@ -5850,7 +5821,7 @@ function normalizeFreeformCapabilities(raw) {
|
|
|
5850
5821
|
};
|
|
5851
5822
|
}
|
|
5852
5823
|
function parseEditResult(payload) {
|
|
5853
|
-
const result = parseJson$
|
|
5824
|
+
const result = parseJson$1(payload);
|
|
5854
5825
|
return Object.assign(Object.assign({}, result), { placement: normalizePlacement$1(result.placement) });
|
|
5855
5826
|
}
|
|
5856
5827
|
function serializeOptions(options) {
|
|
@@ -5872,28 +5843,28 @@ class FreeformEditor {
|
|
|
5872
5843
|
return this.geometry;
|
|
5873
5844
|
}
|
|
5874
5845
|
getTopologyRenderData() {
|
|
5875
|
-
return normalizeTopologyRenderData(parseJson$
|
|
5846
|
+
return normalizeTopologyRenderData(parseJson$1(this.editor.getTopologyRenderData(this.geometry.getKernelGeometry())));
|
|
5876
5847
|
}
|
|
5877
5848
|
getFaceInfo(faceId) {
|
|
5878
|
-
return normalizeFaceInfo(parseJson$
|
|
5849
|
+
return normalizeFaceInfo(parseJson$1(this.editor.getFaceInfo(this.geometry.getKernelGeometry(), faceId)));
|
|
5879
5850
|
}
|
|
5880
5851
|
getEdgeInfo(edgeId) {
|
|
5881
|
-
return normalizeEdgeInfo(parseJson$
|
|
5852
|
+
return normalizeEdgeInfo(parseJson$1(this.editor.getEdgeInfo(this.geometry.getKernelGeometry(), edgeId)));
|
|
5882
5853
|
}
|
|
5883
5854
|
getVertexInfo(vertexId) {
|
|
5884
|
-
return normalizeVertexInfo(parseJson$
|
|
5855
|
+
return normalizeVertexInfo(parseJson$1(this.editor.getVertexInfo(this.geometry.getKernelGeometry(), vertexId)));
|
|
5885
5856
|
}
|
|
5886
5857
|
getEditCapabilities() {
|
|
5887
|
-
return normalizeFreeformCapabilities(parseJson$
|
|
5858
|
+
return normalizeFreeformCapabilities(parseJson$1(this.editor.getEditCapabilities(this.geometry.getKernelGeometry())));
|
|
5888
5859
|
}
|
|
5889
5860
|
getFaceEditCapabilities(faceId) {
|
|
5890
|
-
return normalizeFeatureCapabilities(parseJson$
|
|
5861
|
+
return normalizeFeatureCapabilities(parseJson$1(this.editor.getFaceEditCapabilities(this.geometry.getKernelGeometry(), faceId)));
|
|
5891
5862
|
}
|
|
5892
5863
|
getEdgeEditCapabilities(edgeId) {
|
|
5893
|
-
return normalizeFeatureCapabilities(parseJson$
|
|
5864
|
+
return normalizeFeatureCapabilities(parseJson$1(this.editor.getEdgeEditCapabilities(this.geometry.getKernelGeometry(), edgeId)));
|
|
5894
5865
|
}
|
|
5895
5866
|
getVertexEditCapabilities(vertexId) {
|
|
5896
|
-
return normalizeFeatureCapabilities(parseJson$
|
|
5867
|
+
return normalizeFeatureCapabilities(parseJson$1(this.editor.getVertexEditCapabilities(this.geometry.getKernelGeometry(), vertexId)));
|
|
5897
5868
|
}
|
|
5898
5869
|
pushPullFace(faceId, distance, options) {
|
|
5899
5870
|
return parseEditResult(this.editor.pushPullFace(this.geometry.getKernelGeometry(), faceId, distance, serializeOptions(options)));
|
|
@@ -5930,7 +5901,7 @@ function createFreeformEditor(geometry) {
|
|
|
5930
5901
|
return new FreeformEditor(geometry);
|
|
5931
5902
|
}
|
|
5932
5903
|
|
|
5933
|
-
function parseJson
|
|
5904
|
+
function parseJson(payload) {
|
|
5934
5905
|
return JSON.parse(payload);
|
|
5935
5906
|
}
|
|
5936
5907
|
function toVector3(value) {
|
|
@@ -5943,7 +5914,7 @@ function toPlainVector3(value) {
|
|
|
5943
5914
|
z: value.z,
|
|
5944
5915
|
};
|
|
5945
5916
|
}
|
|
5946
|
-
function cloneVector
|
|
5917
|
+
function cloneVector(vector, fallback) {
|
|
5947
5918
|
var _a;
|
|
5948
5919
|
return (_a = vector === null || vector === void 0 ? void 0 : vector.clone()) !== null && _a !== void 0 ? _a : new Vector3(...fallback);
|
|
5949
5920
|
}
|
|
@@ -5957,10 +5928,10 @@ function normalizePlacement(placement) {
|
|
|
5957
5928
|
}
|
|
5958
5929
|
function toObjectTransformation(placement) {
|
|
5959
5930
|
return {
|
|
5960
|
-
anchor: cloneVector
|
|
5961
|
-
translation: cloneVector
|
|
5962
|
-
rotation: cloneVector
|
|
5963
|
-
scale: cloneVector
|
|
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]),
|
|
5964
5935
|
};
|
|
5965
5936
|
}
|
|
5966
5937
|
function toPlainObjectTransformation(transform) {
|
|
@@ -6015,7 +5986,7 @@ class FreeformGeometry {
|
|
|
6015
5986
|
return this.geometry.getOutlineGeometrySerialized();
|
|
6016
5987
|
}
|
|
6017
5988
|
getPlacement() {
|
|
6018
|
-
return normalizePlacement(parseJson
|
|
5989
|
+
return normalizePlacement(parseJson(this.geometry.getPlacementSerialized()));
|
|
6019
5990
|
}
|
|
6020
5991
|
setPlacement(transform) {
|
|
6021
5992
|
this.geometry.setPlacementSerialized(JSON.stringify(toPlainObjectTransformation(transform)));
|
|
@@ -6158,7 +6129,7 @@ class Line extends THREE.Line {
|
|
|
6158
6129
|
this.setPlacement({ scale });
|
|
6159
6130
|
}
|
|
6160
6131
|
getPlacement() {
|
|
6161
|
-
return clonePlacement
|
|
6132
|
+
return clonePlacement({
|
|
6162
6133
|
translation: this.options.translation,
|
|
6163
6134
|
rotation: this.options.rotation,
|
|
6164
6135
|
scale: this.options.scale,
|
|
@@ -6378,7 +6349,7 @@ class Polyline extends THREE.Line {
|
|
|
6378
6349
|
this.setPlacement({ scale });
|
|
6379
6350
|
}
|
|
6380
6351
|
getPlacement() {
|
|
6381
|
-
return clonePlacement
|
|
6352
|
+
return clonePlacement({
|
|
6382
6353
|
translation: this.options.translation,
|
|
6383
6354
|
rotation: this.options.rotation,
|
|
6384
6355
|
scale: this.options.scale,
|
|
@@ -6607,7 +6578,7 @@ class Arc extends THREE.Line {
|
|
|
6607
6578
|
return this.options;
|
|
6608
6579
|
}
|
|
6609
6580
|
getPlacement() {
|
|
6610
|
-
return clonePlacement
|
|
6581
|
+
return clonePlacement({
|
|
6611
6582
|
translation: this.options.translation,
|
|
6612
6583
|
rotation: this.options.rotation,
|
|
6613
6584
|
scale: this.options.scale,
|
|
@@ -6828,7 +6799,7 @@ class Rectangle extends THREE.Line {
|
|
|
6828
6799
|
return this.options;
|
|
6829
6800
|
}
|
|
6830
6801
|
getPlacement() {
|
|
6831
|
-
return clonePlacement
|
|
6802
|
+
return clonePlacement({
|
|
6832
6803
|
translation: this.options.translation,
|
|
6833
6804
|
rotation: this.options.rotation,
|
|
6834
6805
|
scale: this.options.scale,
|
|
@@ -7029,7 +7000,7 @@ class Curve extends THREE.Line {
|
|
|
7029
7000
|
this.setPlacement({ scale });
|
|
7030
7001
|
}
|
|
7031
7002
|
getPlacement() {
|
|
7032
|
-
return clonePlacement
|
|
7003
|
+
return clonePlacement({
|
|
7033
7004
|
translation: this.options.translation,
|
|
7034
7005
|
rotation: this.options.rotation,
|
|
7035
7006
|
scale: this.options.scale,
|
|
@@ -7398,228 +7369,6 @@ function getRenderableOutlinePositions(geometry, fallbackSerialized) {
|
|
|
7398
7369
|
return JSON.parse(fallbackSerialized);
|
|
7399
7370
|
}
|
|
7400
7371
|
|
|
7401
|
-
var _ExtrudedShape_outlineMesh;
|
|
7402
|
-
function parseJson(payload) {
|
|
7403
|
-
return JSON.parse(payload);
|
|
7404
|
-
}
|
|
7405
|
-
function cloneVector(vector, fallback) {
|
|
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
|
-
};
|
|
7416
|
-
}
|
|
7417
|
-
class ExtrudedShape extends THREE.Mesh {
|
|
7418
|
-
constructor(localBrepSerialized, options) {
|
|
7419
|
-
var _a, _b, _c, _d, _e;
|
|
7420
|
-
super();
|
|
7421
|
-
_ExtrudedShape_outlineMesh.set(this, null);
|
|
7422
|
-
this._outlineEnabled = false;
|
|
7423
|
-
this._fatOutlines = false;
|
|
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
|
-
}
|
|
7441
|
-
set color(color) {
|
|
7442
|
-
this._color = color;
|
|
7443
|
-
if (this.material instanceof THREE.MeshStandardMaterial) {
|
|
7444
|
-
this.material.color.set(color);
|
|
7445
|
-
}
|
|
7446
|
-
}
|
|
7447
|
-
get color() {
|
|
7448
|
-
return this._color;
|
|
7449
|
-
}
|
|
7450
|
-
getBrepSerialized() {
|
|
7451
|
-
return this.freeform.getBrepSerialized();
|
|
7452
|
-
}
|
|
7453
|
-
getPlacement() {
|
|
7454
|
-
return this.freeform.getPlacement();
|
|
7455
|
-
}
|
|
7456
|
-
setPlacement(placement) {
|
|
7457
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7458
|
-
const current = this.freeform.getPlacement();
|
|
7459
|
-
this.freeform.setPlacement({
|
|
7460
|
-
anchor: (_b = (_a = placement.anchor) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : current.anchor.clone(),
|
|
7461
|
-
translation: (_d = (_c = placement.translation) === null || _c === void 0 ? void 0 : _c.clone()) !== null && _d !== void 0 ? _d : current.translation.clone(),
|
|
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
|
-
});
|
|
7465
|
-
this.generateGeometry();
|
|
7466
|
-
}
|
|
7467
|
-
setTransform(translation, rotation, scale) {
|
|
7468
|
-
this.freeform.setTransform(translation.clone(), rotation.clone(), scale.clone());
|
|
7469
|
-
this.generateGeometry();
|
|
7470
|
-
}
|
|
7471
|
-
setTranslation(translation) {
|
|
7472
|
-
this.freeform.setTranslation(translation.clone());
|
|
7473
|
-
this.generateGeometry();
|
|
7474
|
-
}
|
|
7475
|
-
setRotation(rotation) {
|
|
7476
|
-
this.freeform.setRotation(rotation.clone());
|
|
7477
|
-
this.generateGeometry();
|
|
7478
|
-
}
|
|
7479
|
-
setScale(scale) {
|
|
7480
|
-
this.freeform.setScale(scale.clone());
|
|
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);
|
|
7488
|
-
}
|
|
7489
|
-
subtract(operand, options) {
|
|
7490
|
-
return booleanSubtraction(this, operand, options);
|
|
7491
|
-
}
|
|
7492
|
-
set outlineColor(color) {
|
|
7493
|
-
this._outlineColor = color;
|
|
7494
|
-
setShapeOutlineColor(__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f"), color);
|
|
7495
|
-
}
|
|
7496
|
-
get outlineColor() {
|
|
7497
|
-
return getShapeOutlineColor(__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f"), this._outlineColor);
|
|
7498
|
-
}
|
|
7499
|
-
set outline(enable) {
|
|
7500
|
-
this._outlineEnabled = enable;
|
|
7501
|
-
this.clearOutlineMesh();
|
|
7502
|
-
if (!enable) {
|
|
7503
|
-
return;
|
|
7504
|
-
}
|
|
7505
|
-
const outlinePositions = parseJson(this.freeform.getOutlineGeometrySerialized());
|
|
7506
|
-
__classPrivateFieldSet(this, _ExtrudedShape_outlineMesh, createShapeOutlineMesh({
|
|
7507
|
-
positions: outlinePositions,
|
|
7508
|
-
color: this._outlineColor,
|
|
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;
|
|
7516
|
-
}
|
|
7517
|
-
set fatOutlines(value) {
|
|
7518
|
-
this._fatOutlines = value;
|
|
7519
|
-
if (this._outlineEnabled) {
|
|
7520
|
-
this.outline = true;
|
|
7521
|
-
}
|
|
7522
|
-
}
|
|
7523
|
-
get fatOutlines() {
|
|
7524
|
-
return this._fatOutlines;
|
|
7525
|
-
}
|
|
7526
|
-
set outlineWidth(value) {
|
|
7527
|
-
this._outlineWidth = sanitizeOutlineWidth(value);
|
|
7528
|
-
if (this._outlineEnabled) {
|
|
7529
|
-
this.outline = true;
|
|
7530
|
-
}
|
|
7531
|
-
}
|
|
7532
|
-
get outlineWidth() {
|
|
7533
|
-
return this._outlineWidth;
|
|
7534
|
-
}
|
|
7535
|
-
dispose() {
|
|
7536
|
-
this.clearOutlineMesh();
|
|
7537
|
-
this.geometry.dispose();
|
|
7538
|
-
if (Array.isArray(this.material)) {
|
|
7539
|
-
this.material.forEach((material) => material.dispose());
|
|
7540
|
-
return;
|
|
7541
|
-
}
|
|
7542
|
-
this.material.dispose();
|
|
7543
|
-
}
|
|
7544
|
-
generateGeometry() {
|
|
7545
|
-
var _a;
|
|
7546
|
-
const positions = parseJson(this.freeform.getGeometrySerialized());
|
|
7547
|
-
this.writePositionsToGeometry(this.geometry, positions);
|
|
7548
|
-
if (this.material instanceof THREE.MeshStandardMaterial) {
|
|
7549
|
-
this.material.color.set(this._color);
|
|
7550
|
-
this.material.transparent = true;
|
|
7551
|
-
this.material.opacity = 0.82;
|
|
7552
|
-
this.material.side = THREE.FrontSide;
|
|
7553
|
-
}
|
|
7554
|
-
else {
|
|
7555
|
-
if (Array.isArray(this.material)) {
|
|
7556
|
-
this.material.forEach((material) => material.dispose());
|
|
7557
|
-
}
|
|
7558
|
-
else {
|
|
7559
|
-
this.material.dispose();
|
|
7560
|
-
}
|
|
7561
|
-
this.material = new THREE.MeshStandardMaterial({
|
|
7562
|
-
color: this._color,
|
|
7563
|
-
transparent: true,
|
|
7564
|
-
opacity: 0.82,
|
|
7565
|
-
side: THREE.FrontSide,
|
|
7566
|
-
polygonOffset: true,
|
|
7567
|
-
polygonOffsetFactor: 1,
|
|
7568
|
-
polygonOffsetUnits: 1,
|
|
7569
|
-
});
|
|
7570
|
-
}
|
|
7571
|
-
if (positions.length > 0) {
|
|
7572
|
-
this.geometry.computeVertexNormals();
|
|
7573
|
-
this.geometry.computeBoundingBox();
|
|
7574
|
-
this.geometry.computeBoundingSphere();
|
|
7575
|
-
}
|
|
7576
|
-
else {
|
|
7577
|
-
this.geometry.deleteAttribute("normal");
|
|
7578
|
-
this.geometry.boundingBox = null;
|
|
7579
|
-
this.geometry.boundingSphere = null;
|
|
7580
|
-
}
|
|
7581
|
-
if (!this._outlineEnabled) {
|
|
7582
|
-
return;
|
|
7583
|
-
}
|
|
7584
|
-
const outlinePositions = parseJson(this.freeform.getOutlineGeometrySerialized());
|
|
7585
|
-
if (!__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f")) {
|
|
7586
|
-
this.outline = true;
|
|
7587
|
-
return;
|
|
7588
|
-
}
|
|
7589
|
-
if (__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f") instanceof THREE.LineSegments) {
|
|
7590
|
-
this.writePositionsToGeometry(__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f").geometry, outlinePositions);
|
|
7591
|
-
__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f").geometry.computeBoundingBox();
|
|
7592
|
-
__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f").geometry.computeBoundingSphere();
|
|
7593
|
-
return;
|
|
7594
|
-
}
|
|
7595
|
-
const fatGeometry = __classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f").geometry;
|
|
7596
|
-
fatGeometry.setPositions(outlinePositions);
|
|
7597
|
-
const fatOutline = __classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f");
|
|
7598
|
-
(_a = fatOutline.computeLineDistances) === null || _a === void 0 ? void 0 : _a.call(fatOutline);
|
|
7599
|
-
}
|
|
7600
|
-
clearOutlineMesh() {
|
|
7601
|
-
if (!__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f")) {
|
|
7602
|
-
return;
|
|
7603
|
-
}
|
|
7604
|
-
this.remove(__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f"));
|
|
7605
|
-
disposeShapeOutlineMesh(__classPrivateFieldGet(this, _ExtrudedShape_outlineMesh, "f"));
|
|
7606
|
-
__classPrivateFieldSet(this, _ExtrudedShape_outlineMesh, null, "f");
|
|
7607
|
-
}
|
|
7608
|
-
writePositionsToGeometry(geometry, positions) {
|
|
7609
|
-
const existing = geometry.getAttribute("position");
|
|
7610
|
-
if (!(existing instanceof THREE.BufferAttribute) ||
|
|
7611
|
-
existing.itemSize !== 3 ||
|
|
7612
|
-
existing.count !== positions.length / 3) {
|
|
7613
|
-
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
|
|
7614
|
-
return;
|
|
7615
|
-
}
|
|
7616
|
-
const array = existing.array;
|
|
7617
|
-
array.set(positions);
|
|
7618
|
-
existing.needsUpdate = true;
|
|
7619
|
-
}
|
|
7620
|
-
}
|
|
7621
|
-
_ExtrudedShape_outlineMesh = new WeakMap();
|
|
7622
|
-
|
|
7623
7372
|
/**
|
|
7624
7373
|
* Executes a kernel-backed subtraction for a shape wrapper against another boolean operand.
|
|
7625
7374
|
*/
|
|
@@ -7768,7 +7517,7 @@ class Polygon extends THREE.Mesh {
|
|
|
7768
7517
|
this.setPlacement({ scale });
|
|
7769
7518
|
}
|
|
7770
7519
|
getPlacement() {
|
|
7771
|
-
return clonePlacement
|
|
7520
|
+
return clonePlacement({
|
|
7772
7521
|
translation: this.options.translation,
|
|
7773
7522
|
rotation: this.options.rotation,
|
|
7774
7523
|
scale: this.options.scale,
|
|
@@ -7985,28 +7734,29 @@ class Polygon extends THREE.Mesh {
|
|
|
7985
7734
|
holes: ((_b = this.options.holes) !== null && _b !== void 0 ? _b : []).map((hole) => hole.map((vertex) => vertex.clone())),
|
|
7986
7735
|
});
|
|
7987
7736
|
}
|
|
7988
|
-
extrude(height
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
7737
|
+
// extrude(height: number) {
|
|
7738
|
+
// if (!this.polygon) return;
|
|
7739
|
+
// const extruded_buff = this.polygon.extrude_by_height(height);
|
|
7740
|
+
// console.log(extruded_buff);
|
|
7741
|
+
// this.generateExtrudedGeometry(extruded_buff);
|
|
7742
|
+
// }
|
|
7743
|
+
// generateExtrudedGeometry(extruded_buff: string) {
|
|
7744
|
+
// // THIS WORKS
|
|
7745
|
+
// const flushBuffer = JSON.parse(extruded_buff);
|
|
7746
|
+
// console.log(flushBuffer);
|
|
7747
|
+
// const geometry = new THREE.BufferGeometry();
|
|
7748
|
+
// geometry.setAttribute("position", new THREE.BufferAttribute(new Float32Array(flushBuffer), 3));
|
|
7749
|
+
// geometry.computeVertexNormals();
|
|
7750
|
+
// this.geometry = geometry;
|
|
7751
|
+
// const material = new THREE.MeshStandardMaterial({
|
|
7752
|
+
// color: 0x00ff00,
|
|
7753
|
+
// side: THREE.FrontSide,
|
|
7754
|
+
// transparent: true,
|
|
7755
|
+
// opacity: 0.5,
|
|
7756
|
+
// // wireframe: true
|
|
7757
|
+
// });
|
|
7758
|
+
// this.material = material;
|
|
7759
|
+
// }
|
|
8010
7760
|
getBrepData() {
|
|
8011
7761
|
if (!this.polygon)
|
|
8012
7762
|
return null;
|
|
@@ -8238,7 +7988,7 @@ class Cylinder extends THREE.Mesh {
|
|
|
8238
7988
|
this.setPlacement({ scale });
|
|
8239
7989
|
}
|
|
8240
7990
|
getPlacement() {
|
|
8241
|
-
return clonePlacement
|
|
7991
|
+
return clonePlacement({
|
|
8242
7992
|
translation: this.options.translation,
|
|
8243
7993
|
rotation: this.options.rotation,
|
|
8244
7994
|
scale: this.options.scale,
|
|
@@ -8443,7 +8193,7 @@ class Cuboid extends THREE.Mesh {
|
|
|
8443
8193
|
return this.options;
|
|
8444
8194
|
}
|
|
8445
8195
|
getPlacement() {
|
|
8446
|
-
return clonePlacement
|
|
8196
|
+
return clonePlacement({
|
|
8447
8197
|
translation: this.options.translation,
|
|
8448
8198
|
rotation: this.options.rotation,
|
|
8449
8199
|
scale: this.options.scale,
|
|
@@ -8766,7 +8516,7 @@ class Opening extends THREE.Mesh {
|
|
|
8766
8516
|
this.setPlacement({ scale });
|
|
8767
8517
|
}
|
|
8768
8518
|
getPlacement() {
|
|
8769
|
-
return clonePlacement
|
|
8519
|
+
return clonePlacement({
|
|
8770
8520
|
translation: this.options.translation,
|
|
8771
8521
|
rotation: this.options.rotation,
|
|
8772
8522
|
scale: this.options.scale,
|
|
@@ -9050,7 +8800,7 @@ class Sphere extends THREE.Mesh {
|
|
|
9050
8800
|
this.setPlacement({ scale });
|
|
9051
8801
|
}
|
|
9052
8802
|
getPlacement() {
|
|
9053
|
-
return clonePlacement
|
|
8803
|
+
return clonePlacement({
|
|
9054
8804
|
translation: this.options.translation,
|
|
9055
8805
|
rotation: this.options.rotation,
|
|
9056
8806
|
scale: this.options.scale,
|
|
@@ -9315,7 +9065,7 @@ class Wedge extends THREE.Mesh {
|
|
|
9315
9065
|
this.setPlacement({ scale });
|
|
9316
9066
|
}
|
|
9317
9067
|
getPlacement() {
|
|
9318
|
-
return clonePlacement
|
|
9068
|
+
return clonePlacement({
|
|
9319
9069
|
translation: this.options.translation,
|
|
9320
9070
|
rotation: this.options.rotation,
|
|
9321
9071
|
scale: this.options.scale,
|
|
@@ -9611,7 +9361,7 @@ class Sweep extends THREE.Mesh {
|
|
|
9611
9361
|
this.setPlacement({ scale });
|
|
9612
9362
|
}
|
|
9613
9363
|
getPlacement() {
|
|
9614
|
-
return clonePlacement
|
|
9364
|
+
return clonePlacement({
|
|
9615
9365
|
translation: this.options.translation,
|
|
9616
9366
|
rotation: this.options.rotation,
|
|
9617
9367
|
scale: this.options.scale,
|
|
@@ -10119,7 +9869,9 @@ function createWallFromOffsetsExample(scene) {
|
|
|
10119
9869
|
function createBooleanExample(operation, options) {
|
|
10120
9870
|
const preset = options.mode === "solid"
|
|
10121
9871
|
? createSolidPreset(operation, options)
|
|
10122
|
-
:
|
|
9872
|
+
: options.mode === "polygon"
|
|
9873
|
+
? createPolygonPreset(operation, options)
|
|
9874
|
+
: createExtrudedPreset(operation, options);
|
|
10123
9875
|
const execute = getBooleanExecutor(operation);
|
|
10124
9876
|
const result = execute(preset.lhsOperand, preset.rhsOperand, options);
|
|
10125
9877
|
const group = new THREE.Group();
|
|
@@ -10219,6 +9971,66 @@ function createPolygonPreset(operation, options) {
|
|
|
10219
9971
|
rhsVisual: rhs,
|
|
10220
9972
|
};
|
|
10221
9973
|
}
|
|
9974
|
+
/**
|
|
9975
|
+
* Builds the straight-sweep solid preset used to demonstrate extruded booleans.
|
|
9976
|
+
*/
|
|
9977
|
+
function createExtrudedPreset(operation, options) {
|
|
9978
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9979
|
+
const outlineWidth = (_a = options.outlineWidth) !== null && _a !== void 0 ? _a : 3;
|
|
9980
|
+
const extrudedOffset = (_b = options.extrudedOffset) !== null && _b !== void 0 ? _b : new Vector3(0.0, 0.0, 0.0);
|
|
9981
|
+
const path = [
|
|
9982
|
+
new Vector3(0.0, 0.0, 0.0),
|
|
9983
|
+
new Vector3(0.0, 1.6, 0.0),
|
|
9984
|
+
];
|
|
9985
|
+
const lhsProfile = [
|
|
9986
|
+
new Vector3(-2, 0.0, -0.65),
|
|
9987
|
+
new Vector3(2.1, 0.0, -0.65),
|
|
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,
|
|
10007
|
+
color: 0x60a5fa,
|
|
10008
|
+
capStart: true,
|
|
10009
|
+
capEnd: true,
|
|
10010
|
+
fatOutlines: (_c = options.fatOutlines) !== null && _c !== void 0 ? _c : true,
|
|
10011
|
+
outlineWidth,
|
|
10012
|
+
});
|
|
10013
|
+
const rhs = new Sweep({
|
|
10014
|
+
path: path.map((point) => point.clone()),
|
|
10015
|
+
profile: rhsProfile,
|
|
10016
|
+
color: 0xf97316,
|
|
10017
|
+
capStart: true,
|
|
10018
|
+
capEnd: true,
|
|
10019
|
+
translation: extrudedOffset.clone(),
|
|
10020
|
+
fatOutlines: (_d = options.fatOutlines) !== null && _d !== void 0 ? _d : true,
|
|
10021
|
+
outlineWidth,
|
|
10022
|
+
});
|
|
10023
|
+
lhs.outline = (_e = options.outline) !== null && _e !== void 0 ? _e : true;
|
|
10024
|
+
rhs.outline = (_f = options.outline) !== null && _f !== void 0 ? _f : true;
|
|
10025
|
+
return {
|
|
10026
|
+
title: `${capitalize(operation)} Extruded Solids`,
|
|
10027
|
+
description: "Two capped straight sweeps demonstrate boolean operations on extruded solid profiles.",
|
|
10028
|
+
lhsOperand: lhs,
|
|
10029
|
+
rhsOperand: rhs,
|
|
10030
|
+
lhsVisual: lhs,
|
|
10031
|
+
rhsVisual: rhs,
|
|
10032
|
+
};
|
|
10033
|
+
}
|
|
10222
10034
|
/**
|
|
10223
10035
|
* Selects the exported boolean helper that matches the current example mode.
|
|
10224
10036
|
*/
|
|
@@ -10422,5 +10234,5 @@ class OpenGeometry {
|
|
|
10422
10234
|
OpenGeometry.version = OPEN_GEOMETRY_THREE_VERSION;
|
|
10423
10235
|
OpenGeometry.instance = null;
|
|
10424
10236
|
|
|
10425
|
-
export { Arc, BooleanResult, Cuboid, Curve, Cylinder,
|
|
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 };
|
|
10426
10238
|
//# sourceMappingURL=index.js.map
|