opengeometry 0.0.2 → 0.0.4

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 CHANGED
@@ -76,6 +76,19 @@ function addHeapObject(obj) {
76
76
  heap[idx] = obj;
77
77
  return idx;
78
78
  }
79
+ function getObject(idx) {
80
+ return heap[idx];
81
+ }
82
+ function dropObject(idx) {
83
+ if (idx < 132) return;
84
+ heap[idx] = heap_next;
85
+ heap_next = idx;
86
+ }
87
+ function takeObject(idx) {
88
+ const ret = getObject(idx);
89
+ dropObject(idx);
90
+ return ret;
91
+ }
79
92
  function _assertClass(instance, klass) {
80
93
  if (!(instance instanceof klass)) {
81
94
  throw new Error(`expected instance of ${klass.name}`);
@@ -144,19 +157,6 @@ function passArrayJsValueToWasm0(array, malloc) {
144
157
  WASM_VECTOR_LEN = array.length;
145
158
  return ptr;
146
159
  }
147
- function getObject(idx) {
148
- return heap[idx];
149
- }
150
- function dropObject(idx) {
151
- if (idx < 132) return;
152
- heap[idx] = heap_next;
153
- heap_next = idx;
154
- }
155
- function takeObject(idx) {
156
- const ret = getObject(idx);
157
- dropObject(idx);
158
- return ret;
159
- }
160
160
  function getArrayJsValueFromWasm0(ptr, len) {
161
161
  ptr = ptr >>> 0;
162
162
  const mem = getDataViewMemory0();
@@ -783,12 +783,615 @@ class CircleArc {
783
783
  /**
784
784
  * @returns {string}
785
785
  */
786
- get_points() {
786
+ get_points() {
787
+ let deferred1_0;
788
+ let deferred1_1;
789
+ try {
790
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
791
+ wasm.circlearc_get_points(retptr, this.__wbg_ptr);
792
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
793
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
794
+ deferred1_0 = r0;
795
+ deferred1_1 = r1;
796
+ return getStringFromWasm0(r0, r1);
797
+ } finally {
798
+ wasm.__wbindgen_add_to_stack_pointer(16);
799
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
800
+ }
801
+ }
802
+ /**
803
+ * @returns {(Vector3D)[]}
804
+ */
805
+ get_raw_points() {
806
+ try {
807
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
808
+ wasm.circlearc_get_raw_points(retptr, this.__wbg_ptr);
809
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
810
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
811
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
812
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
813
+ return v1;
814
+ } finally {
815
+ wasm.__wbindgen_add_to_stack_pointer(16);
816
+ }
817
+ }
818
+ }
819
+ typeof FinalizationRegistry === 'undefined' ? {
820
+ } : new FinalizationRegistry(ptr => wasm.__wbg_color_free(ptr >>> 0, 1));
821
+ typeof FinalizationRegistry === 'undefined' ? {
822
+ } : new FinalizationRegistry(ptr => wasm.__wbg_colorrgb_free(ptr >>> 0, 1));
823
+ typeof FinalizationRegistry === 'undefined' ? {
824
+ } : new FinalizationRegistry(ptr => wasm.__wbg_matrix3d_free(ptr >>> 0, 1));
825
+ const OGCylinderFinalization = typeof FinalizationRegistry === 'undefined' ? {
826
+ register: () => {},
827
+ unregister: () => {}
828
+ } : new FinalizationRegistry(ptr => wasm.__wbg_ogcylinder_free(ptr >>> 0, 1));
829
+ /**
830
+ */
831
+ class OGCylinder {
832
+ __destroy_into_raw() {
833
+ const ptr = this.__wbg_ptr;
834
+ this.__wbg_ptr = 0;
835
+ OGCylinderFinalization.unregister(this);
836
+ return ptr;
837
+ }
838
+ free() {
839
+ const ptr = this.__destroy_into_raw();
840
+ wasm.__wbg_ogcylinder_free(ptr, 0);
841
+ }
842
+ /**
843
+ * @param {string} id
844
+ */
845
+ set id(id) {
846
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
847
+ const len0 = WASM_VECTOR_LEN;
848
+ wasm.ogcylinder_set_id(this.__wbg_ptr, ptr0, len0);
849
+ }
850
+ /**
851
+ * @returns {string}
852
+ */
853
+ get id() {
854
+ let deferred1_0;
855
+ let deferred1_1;
856
+ try {
857
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
858
+ wasm.ogcylinder_id(retptr, this.__wbg_ptr);
859
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
860
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
861
+ deferred1_0 = r0;
862
+ deferred1_1 = r1;
863
+ return getStringFromWasm0(r0, r1);
864
+ } finally {
865
+ wasm.__wbindgen_add_to_stack_pointer(16);
866
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
867
+ }
868
+ }
869
+ /**
870
+ * @param {string} id
871
+ */
872
+ constructor(id) {
873
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
874
+ const len0 = WASM_VECTOR_LEN;
875
+ const ret = wasm.ogcylinder_new(ptr0, len0);
876
+ this.__wbg_ptr = ret >>> 0;
877
+ OGCylinderFinalization.register(this, this.__wbg_ptr, this);
878
+ return this;
879
+ }
880
+ /**
881
+ * @param {Vector3D} center
882
+ * @param {number} radius
883
+ * @param {number} height
884
+ * @param {number} angle
885
+ * @param {number} segments
886
+ */
887
+ set_config(center, radius, height, angle, segments) {
888
+ _assertClass(center, Vector3D);
889
+ var ptr0 = center.__destroy_into_raw();
890
+ wasm.ogcylinder_set_config(this.__wbg_ptr, ptr0, radius, height, angle, segments);
891
+ }
892
+ /**
893
+ */
894
+ generate_geometry() {
895
+ wasm.ogcylinder_generate_geometry(this.__wbg_ptr);
896
+ }
897
+ /**
898
+ * @returns {string}
899
+ */
900
+ get_geometry() {
901
+ let deferred1_0;
902
+ let deferred1_1;
903
+ try {
904
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
905
+ wasm.ogcylinder_get_geometry(retptr, this.__wbg_ptr);
906
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
907
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
908
+ deferred1_0 = r0;
909
+ deferred1_1 = r1;
910
+ return getStringFromWasm0(r0, r1);
911
+ } finally {
912
+ wasm.__wbindgen_add_to_stack_pointer(16);
913
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
914
+ }
915
+ }
916
+ /**
917
+ */
918
+ discard_geometry() {
919
+ wasm.ogcylinder_discard_geometry(this.__wbg_ptr);
920
+ }
921
+ /**
922
+ * @returns {string}
923
+ */
924
+ outline_edges() {
925
+ let deferred1_0;
926
+ let deferred1_1;
927
+ try {
928
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
929
+ wasm.ogcylinder_outline_edges(retptr, this.__wbg_ptr);
930
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
931
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
932
+ deferred1_0 = r0;
933
+ deferred1_1 = r1;
934
+ return getStringFromWasm0(r0, r1);
935
+ } finally {
936
+ wasm.__wbindgen_add_to_stack_pointer(16);
937
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
938
+ }
939
+ }
940
+ /**
941
+ * @returns {string}
942
+ */
943
+ get_brep_dump() {
944
+ let deferred1_0;
945
+ let deferred1_1;
946
+ try {
947
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
948
+ wasm.ogcylinder_get_brep_dump(retptr, this.__wbg_ptr);
949
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
950
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
951
+ deferred1_0 = r0;
952
+ deferred1_1 = r1;
953
+ return getStringFromWasm0(r0, r1);
954
+ } finally {
955
+ wasm.__wbindgen_add_to_stack_pointer(16);
956
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
957
+ }
958
+ }
959
+ }
960
+ const OGPolyLineFinalization = typeof FinalizationRegistry === 'undefined' ? {
961
+ register: () => {},
962
+ unregister: () => {}
963
+ } : new FinalizationRegistry(ptr => wasm.__wbg_ogpolyline_free(ptr >>> 0, 1));
964
+ /**
965
+ */
966
+ class OGPolyLine {
967
+ static __wrap(ptr) {
968
+ ptr = ptr >>> 0;
969
+ const obj = Object.create(OGPolyLine.prototype);
970
+ obj.__wbg_ptr = ptr;
971
+ OGPolyLineFinalization.register(obj, obj.__wbg_ptr, obj);
972
+ return obj;
973
+ }
974
+ __destroy_into_raw() {
975
+ const ptr = this.__wbg_ptr;
976
+ this.__wbg_ptr = 0;
977
+ OGPolyLineFinalization.unregister(this);
978
+ return ptr;
979
+ }
980
+ free() {
981
+ const ptr = this.__destroy_into_raw();
982
+ wasm.__wbg_ogpolyline_free(ptr, 0);
983
+ }
984
+ /**
985
+ * @param {string} id
986
+ */
987
+ set id(id) {
988
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
989
+ const len0 = WASM_VECTOR_LEN;
990
+ wasm.ogpolyline_set_id(this.__wbg_ptr, ptr0, len0);
991
+ }
992
+ /**
993
+ * @returns {string}
994
+ */
995
+ get id() {
996
+ let deferred1_0;
997
+ let deferred1_1;
998
+ try {
999
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1000
+ wasm.ogpolyline_id(retptr, this.__wbg_ptr);
1001
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1002
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1003
+ deferred1_0 = r0;
1004
+ deferred1_1 = r1;
1005
+ return getStringFromWasm0(r0, r1);
1006
+ } finally {
1007
+ wasm.__wbindgen_add_to_stack_pointer(16);
1008
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1009
+ }
1010
+ }
1011
+ /**
1012
+ * @param {string} id
1013
+ */
1014
+ constructor(id) {
1015
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1016
+ const len0 = WASM_VECTOR_LEN;
1017
+ const ret = wasm.ogpolyline_new(ptr0, len0);
1018
+ this.__wbg_ptr = ret >>> 0;
1019
+ OGPolyLineFinalization.register(this, this.__wbg_ptr, this);
1020
+ return this;
1021
+ }
1022
+ /**
1023
+ * @returns {OGPolyLine}
1024
+ */
1025
+ clone() {
1026
+ const ret = wasm.ogpolyline_clone(this.__wbg_ptr);
1027
+ return OGPolyLine.__wrap(ret);
1028
+ }
1029
+ /**
1030
+ * @param {Vector3D} translation
1031
+ */
1032
+ translate(translation) {
1033
+ _assertClass(translation, Vector3D);
1034
+ var ptr0 = translation.__destroy_into_raw();
1035
+ wasm.ogpolyline_translate(this.__wbg_ptr, ptr0);
1036
+ }
1037
+ /**
1038
+ * @param {Vector3D} position
1039
+ */
1040
+ set_position(position) {
1041
+ _assertClass(position, Vector3D);
1042
+ var ptr0 = position.__destroy_into_raw();
1043
+ wasm.ogpolyline_set_position(this.__wbg_ptr, ptr0);
1044
+ }
1045
+ /**
1046
+ * @param {(Vector3D)[]} points
1047
+ */
1048
+ add_multiple_points(points) {
1049
+ const ptr0 = passArrayJsValueToWasm0(points, wasm.__wbindgen_malloc);
1050
+ const len0 = WASM_VECTOR_LEN;
1051
+ wasm.ogpolyline_add_multiple_points(this.__wbg_ptr, ptr0, len0);
1052
+ }
1053
+ /**
1054
+ * @param {Vector3D} point
1055
+ */
1056
+ add_point(point) {
1057
+ _assertClass(point, Vector3D);
1058
+ var ptr0 = point.__destroy_into_raw();
1059
+ wasm.ogpolyline_add_point(this.__wbg_ptr, ptr0);
1060
+ }
1061
+ /**
1062
+ * @returns {string}
1063
+ */
1064
+ get_points() {
1065
+ let deferred1_0;
1066
+ let deferred1_1;
1067
+ try {
1068
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1069
+ wasm.ogpolyline_get_points(retptr, this.__wbg_ptr);
1070
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1071
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1072
+ deferred1_0 = r0;
1073
+ deferred1_1 = r1;
1074
+ return getStringFromWasm0(r0, r1);
1075
+ } finally {
1076
+ wasm.__wbindgen_add_to_stack_pointer(16);
1077
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1078
+ }
1079
+ }
1080
+ /**
1081
+ * @returns {(Vector3D)[]}
1082
+ */
1083
+ get_raw_points() {
1084
+ try {
1085
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1086
+ wasm.ogpolyline_get_raw_points(retptr, this.__wbg_ptr);
1087
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1088
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1089
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
1090
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
1091
+ return v1;
1092
+ } finally {
1093
+ wasm.__wbindgen_add_to_stack_pointer(16);
1094
+ }
1095
+ }
1096
+ /**
1097
+ * @returns {boolean}
1098
+ */
1099
+ is_closed() {
1100
+ const ret = wasm.ogpolyline_is_closed(this.__wbg_ptr);
1101
+ return ret !== 0;
1102
+ }
1103
+ /**
1104
+ */
1105
+ check_closed_test() {
1106
+ wasm.ogpolyline_check_closed_test(this.__wbg_ptr);
1107
+ }
1108
+ /**
1109
+ */
1110
+ generate_brep() {
1111
+ wasm.ogpolyline_generate_brep(this.__wbg_ptr);
1112
+ }
1113
+ /**
1114
+ * @returns {string}
1115
+ */
1116
+ get_brep_data() {
1117
+ let deferred1_0;
1118
+ let deferred1_1;
1119
+ try {
1120
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1121
+ wasm.ogpolyline_get_brep_data(retptr, this.__wbg_ptr);
1122
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1123
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1124
+ deferred1_0 = r0;
1125
+ deferred1_1 = r1;
1126
+ return getStringFromWasm0(r0, r1);
1127
+ } finally {
1128
+ wasm.__wbindgen_add_to_stack_pointer(16);
1129
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1130
+ }
1131
+ }
1132
+ /**
1133
+ * @param {number} distance
1134
+ * @returns {string}
1135
+ */
1136
+ get_offset(distance) {
1137
+ let deferred1_0;
1138
+ let deferred1_1;
1139
+ try {
1140
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1141
+ wasm.ogpolyline_get_offset(retptr, this.__wbg_ptr, distance);
1142
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1143
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1144
+ deferred1_0 = r0;
1145
+ deferred1_1 = r1;
1146
+ return getStringFromWasm0(r0, r1);
1147
+ } finally {
1148
+ wasm.__wbindgen_add_to_stack_pointer(16);
1149
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1150
+ }
1151
+ }
1152
+ /**
1153
+ * @param {Vector3D} point_a
1154
+ * @param {Vector3D} point_b
1155
+ * @param {Vector3D} point_c
1156
+ * @param {Vector3D} point_d
1157
+ * @returns {Vector3D | undefined}
1158
+ */
1159
+ static calculate_2D_interesection(point_a, point_b, point_c, point_d) {
1160
+ _assertClass(point_a, Vector3D);
1161
+ _assertClass(point_b, Vector3D);
1162
+ _assertClass(point_c, Vector3D);
1163
+ _assertClass(point_d, Vector3D);
1164
+ const ret = wasm.ogpolyline_calculate_2D_interesection(point_a.__wbg_ptr, point_b.__wbg_ptr, point_c.__wbg_ptr, point_d.__wbg_ptr);
1165
+ return ret === 0 ? undefined : Vector3D.__wrap(ret);
1166
+ }
1167
+ }
1168
+ const OGPolygonFinalization = typeof FinalizationRegistry === 'undefined' ? {
1169
+ register: () => {},
1170
+ unregister: () => {}
1171
+ } : new FinalizationRegistry(ptr => wasm.__wbg_ogpolygon_free(ptr >>> 0, 1));
1172
+ /**
1173
+ */
1174
+ class OGPolygon {
1175
+ static __wrap(ptr) {
1176
+ ptr = ptr >>> 0;
1177
+ const obj = Object.create(OGPolygon.prototype);
1178
+ obj.__wbg_ptr = ptr;
1179
+ OGPolygonFinalization.register(obj, obj.__wbg_ptr, obj);
1180
+ return obj;
1181
+ }
1182
+ __destroy_into_raw() {
1183
+ const ptr = this.__wbg_ptr;
1184
+ this.__wbg_ptr = 0;
1185
+ OGPolygonFinalization.unregister(this);
1186
+ return ptr;
1187
+ }
1188
+ free() {
1189
+ const ptr = this.__destroy_into_raw();
1190
+ wasm.__wbg_ogpolygon_free(ptr, 0);
1191
+ }
1192
+ /**
1193
+ * @returns {boolean}
1194
+ */
1195
+ get extruded() {
1196
+ const ret = wasm.__wbg_get_ogpolygon_extruded(this.__wbg_ptr);
1197
+ return ret !== 0;
1198
+ }
1199
+ /**
1200
+ * @param {boolean} arg0
1201
+ */
1202
+ set extruded(arg0) {
1203
+ wasm.__wbg_set_ogpolygon_extruded(this.__wbg_ptr, arg0);
1204
+ }
1205
+ /**
1206
+ * @returns {number}
1207
+ */
1208
+ get extruded_height() {
1209
+ const ret = wasm.__wbg_get_ogpolygon_extruded_height(this.__wbg_ptr);
1210
+ return ret;
1211
+ }
1212
+ /**
1213
+ * @param {number} arg0
1214
+ */
1215
+ set extruded_height(arg0) {
1216
+ wasm.__wbg_set_ogpolygon_extruded_height(this.__wbg_ptr, arg0);
1217
+ }
1218
+ /**
1219
+ * @returns {boolean}
1220
+ */
1221
+ get is_polygon() {
1222
+ const ret = wasm.__wbg_get_ogpolygon_is_polygon(this.__wbg_ptr);
1223
+ return ret !== 0;
1224
+ }
1225
+ /**
1226
+ * @param {boolean} arg0
1227
+ */
1228
+ set is_polygon(arg0) {
1229
+ wasm.__wbg_set_ogpolygon_is_polygon(this.__wbg_ptr, arg0);
1230
+ }
1231
+ /**
1232
+ * @returns {Vector3D}
1233
+ */
1234
+ get position() {
1235
+ const ret = wasm.__wbg_get_ogpolygon_position(this.__wbg_ptr);
1236
+ return Vector3D.__wrap(ret);
1237
+ }
1238
+ /**
1239
+ * @param {Vector3D} arg0
1240
+ */
1241
+ set position(arg0) {
1242
+ _assertClass(arg0, Vector3D);
1243
+ var ptr0 = arg0.__destroy_into_raw();
1244
+ wasm.__wbg_set_ogpolygon_position(this.__wbg_ptr, ptr0);
1245
+ }
1246
+ /**
1247
+ * @returns {Vector3D}
1248
+ */
1249
+ get rotation() {
1250
+ const ret = wasm.__wbg_get_ogpolygon_rotation(this.__wbg_ptr);
1251
+ return Vector3D.__wrap(ret);
1252
+ }
1253
+ /**
1254
+ * @param {Vector3D} arg0
1255
+ */
1256
+ set rotation(arg0) {
1257
+ _assertClass(arg0, Vector3D);
1258
+ var ptr0 = arg0.__destroy_into_raw();
1259
+ wasm.__wbg_set_ogpolygon_rotation(this.__wbg_ptr, ptr0);
1260
+ }
1261
+ /**
1262
+ * @returns {Vector3D}
1263
+ */
1264
+ get scale() {
1265
+ const ret = wasm.__wbg_get_ogpolygon_scale(this.__wbg_ptr);
1266
+ return Vector3D.__wrap(ret);
1267
+ }
1268
+ /**
1269
+ * @param {Vector3D} arg0
1270
+ */
1271
+ set scale(arg0) {
1272
+ _assertClass(arg0, Vector3D);
1273
+ var ptr0 = arg0.__destroy_into_raw();
1274
+ wasm.__wbg_set_ogpolygon_scale(this.__wbg_ptr, ptr0);
1275
+ }
1276
+ /**
1277
+ * @param {string} id
1278
+ */
1279
+ set id(id) {
1280
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1281
+ const len0 = WASM_VECTOR_LEN;
1282
+ wasm.ogpolygon_set_id(this.__wbg_ptr, ptr0, len0);
1283
+ }
1284
+ /**
1285
+ * @returns {string}
1286
+ */
1287
+ get id() {
1288
+ let deferred1_0;
1289
+ let deferred1_1;
1290
+ try {
1291
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1292
+ wasm.ogpolygon_id(retptr, this.__wbg_ptr);
1293
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1294
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1295
+ deferred1_0 = r0;
1296
+ deferred1_1 = r1;
1297
+ return getStringFromWasm0(r0, r1);
1298
+ } finally {
1299
+ wasm.__wbindgen_add_to_stack_pointer(16);
1300
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1301
+ }
1302
+ }
1303
+ /**
1304
+ * @param {string} id
1305
+ */
1306
+ constructor(id) {
1307
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1308
+ const len0 = WASM_VECTOR_LEN;
1309
+ const ret = wasm.ogpolygon_new(ptr0, len0);
1310
+ this.__wbg_ptr = ret >>> 0;
1311
+ OGPolygonFinalization.register(this, this.__wbg_ptr, this);
1312
+ return this;
1313
+ }
1314
+ /**
1315
+ * @param {Vector3D} translation
1316
+ */
1317
+ translate(translation) {
1318
+ _assertClass(translation, Vector3D);
1319
+ var ptr0 = translation.__destroy_into_raw();
1320
+ wasm.ogpolygon_translate(this.__wbg_ptr, ptr0);
1321
+ }
1322
+ /**
1323
+ * @param {CircleArc} circle_arc
1324
+ * @returns {OGPolygon}
1325
+ */
1326
+ static new_with_circle(circle_arc) {
1327
+ _assertClass(circle_arc, CircleArc);
1328
+ var ptr0 = circle_arc.__destroy_into_raw();
1329
+ const ret = wasm.ogpolygon_new_with_circle(ptr0);
1330
+ return OGPolygon.__wrap(ret);
1331
+ }
1332
+ /**
1333
+ * @param {OGRectangle} rectangle
1334
+ * @returns {OGPolygon}
1335
+ */
1336
+ static new_with_rectangle(rectangle) {
1337
+ _assertClass(rectangle, OGRectangle);
1338
+ var ptr0 = rectangle.__destroy_into_raw();
1339
+ const ret = wasm.ogpolygon_new_with_rectangle(ptr0);
1340
+ return OGPolygon.__wrap(ret);
1341
+ }
1342
+ /**
1343
+ * @param {(Vector3D)[]} vertices
1344
+ */
1345
+ add_vertices(vertices) {
1346
+ const ptr0 = passArrayJsValueToWasm0(vertices, wasm.__wbindgen_malloc);
1347
+ const len0 = WASM_VECTOR_LEN;
1348
+ wasm.ogpolygon_add_vertices(this.__wbg_ptr, ptr0, len0);
1349
+ }
1350
+ /**
1351
+ * @param {Vector3D} vertex
1352
+ */
1353
+ add_vertex(vertex) {
1354
+ _assertClass(vertex, Vector3D);
1355
+ var ptr0 = vertex.__destroy_into_raw();
1356
+ wasm.ogpolygon_add_vertex(this.__wbg_ptr, ptr0);
1357
+ }
1358
+ /**
1359
+ * @param {(Vector3D)[]} holes
1360
+ */
1361
+ add_holes(holes) {
1362
+ const ptr0 = passArrayJsValueToWasm0(holes, wasm.__wbindgen_malloc);
1363
+ const len0 = WASM_VECTOR_LEN;
1364
+ wasm.ogpolygon_add_holes(this.__wbg_ptr, ptr0, len0);
1365
+ }
1366
+ /**
1367
+ * @returns {string}
1368
+ */
1369
+ triangulate() {
1370
+ let deferred1_0;
1371
+ let deferred1_1;
1372
+ try {
1373
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1374
+ wasm.ogpolygon_triangulate(retptr, this.__wbg_ptr);
1375
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1376
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1377
+ deferred1_0 = r0;
1378
+ deferred1_1 = r1;
1379
+ return getStringFromWasm0(r0, r1);
1380
+ } finally {
1381
+ wasm.__wbindgen_add_to_stack_pointer(16);
1382
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1383
+ }
1384
+ }
1385
+ /**
1386
+ * @param {boolean} is_ccw
1387
+ * @returns {string}
1388
+ */
1389
+ triangulate_with_holes_variable_geometry(is_ccw) {
787
1390
  let deferred1_0;
788
1391
  let deferred1_1;
789
1392
  try {
790
1393
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
791
- wasm.circlearc_get_points(retptr, this.__wbg_ptr);
1394
+ wasm.ogpolygon_triangulate_with_holes_variable_geometry(retptr, this.__wbg_ptr, is_ccw);
792
1395
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
793
1396
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
794
1397
  deferred1_0 = r0;
@@ -800,69 +1403,33 @@ class CircleArc {
800
1403
  }
801
1404
  }
802
1405
  /**
803
- * @returns {(Vector3D)[]}
1406
+ * @returns {string}
804
1407
  */
805
- get_raw_points() {
1408
+ triangulate_with_holes() {
1409
+ let deferred1_0;
1410
+ let deferred1_1;
806
1411
  try {
807
1412
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
808
- wasm.circlearc_get_raw_points(retptr, this.__wbg_ptr);
1413
+ wasm.ogpolygon_triangulate_with_holes(retptr, this.__wbg_ptr);
809
1414
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
810
1415
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
811
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
812
- wasm.__wbindgen_free(r0, r1 * 4, 4);
813
- return v1;
1416
+ deferred1_0 = r0;
1417
+ deferred1_1 = r1;
1418
+ return getStringFromWasm0(r0, r1);
814
1419
  } finally {
815
1420
  wasm.__wbindgen_add_to_stack_pointer(16);
1421
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
816
1422
  }
817
1423
  }
818
- }
819
- typeof FinalizationRegistry === 'undefined' ? {
820
- } : new FinalizationRegistry(ptr => wasm.__wbg_color_free(ptr >>> 0, 1));
821
- typeof FinalizationRegistry === 'undefined' ? {
822
- } : new FinalizationRegistry(ptr => wasm.__wbg_colorrgb_free(ptr >>> 0, 1));
823
- typeof FinalizationRegistry === 'undefined' ? {
824
- } : new FinalizationRegistry(ptr => wasm.__wbg_matrix3d_free(ptr >>> 0, 1));
825
- const OGPolyLineFinalization = typeof FinalizationRegistry === 'undefined' ? {
826
- register: () => {},
827
- unregister: () => {}
828
- } : new FinalizationRegistry(ptr => wasm.__wbg_ogpolyline_free(ptr >>> 0, 1));
829
- /**
830
- */
831
- class OGPolyLine {
832
- static __wrap(ptr) {
833
- ptr = ptr >>> 0;
834
- const obj = Object.create(OGPolyLine.prototype);
835
- obj.__wbg_ptr = ptr;
836
- OGPolyLineFinalization.register(obj, obj.__wbg_ptr, obj);
837
- return obj;
838
- }
839
- __destroy_into_raw() {
840
- const ptr = this.__wbg_ptr;
841
- this.__wbg_ptr = 0;
842
- OGPolyLineFinalization.unregister(this);
843
- return ptr;
844
- }
845
- free() {
846
- const ptr = this.__destroy_into_raw();
847
- wasm.__wbg_ogpolyline_free(ptr, 0);
848
- }
849
- /**
850
- * @param {string} id
851
- */
852
- set id(id) {
853
- const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
854
- const len0 = WASM_VECTOR_LEN;
855
- wasm.ogpolyline_set_id(this.__wbg_ptr, ptr0, len0);
856
- }
857
1424
  /**
858
1425
  * @returns {string}
859
1426
  */
860
- get id() {
1427
+ get_buffer_flush() {
861
1428
  let deferred1_0;
862
1429
  let deferred1_1;
863
1430
  try {
864
1431
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
865
- wasm.ogpolyline_id(retptr, this.__wbg_ptr);
1432
+ wasm.ogpolygon_get_buffer_flush(retptr, this.__wbg_ptr);
866
1433
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
867
1434
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
868
1435
  deferred1_0 = r0;
@@ -874,58 +1441,88 @@ class OGPolyLine {
874
1441
  }
875
1442
  }
876
1443
  /**
877
- * @param {string} id
878
1444
  */
879
- constructor(id) {
880
- const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
881
- const len0 = WASM_VECTOR_LEN;
882
- const ret = wasm.ogpolyline_new(ptr0, len0);
883
- this.__wbg_ptr = ret >>> 0;
884
- OGPolyLineFinalization.register(this, this.__wbg_ptr, this);
885
- return this;
1445
+ clear_buffer() {
1446
+ wasm.ogpolygon_clear_buffer(this.__wbg_ptr);
886
1447
  }
887
1448
  /**
888
- * @returns {OGPolyLine}
889
1449
  */
890
- clone() {
891
- const ret = wasm.ogpolyline_clone(this.__wbg_ptr);
892
- return OGPolyLine.__wrap(ret);
1450
+ clear_vertices() {
1451
+ wasm.ogpolygon_clear_vertices(this.__wbg_ptr);
893
1452
  }
894
1453
  /**
895
- * @param {(Vector3D)[]} points
896
1454
  */
897
- set_config(points) {
898
- const ptr0 = passArrayJsValueToWasm0(points, wasm.__wbindgen_malloc);
899
- const len0 = WASM_VECTOR_LEN;
900
- wasm.ogpolyline_set_config(this.__wbg_ptr, ptr0, len0);
1455
+ reset_polygon() {
1456
+ wasm.ogpolygon_reset_polygon(this.__wbg_ptr);
901
1457
  }
902
1458
  /**
903
- * @param {Vector3D} point
1459
+ * @param {number} height
1460
+ * @returns {string}
904
1461
  */
905
- add_point(point) {
906
- _assertClass(point, Vector3D);
907
- var ptr0 = point.__destroy_into_raw();
908
- wasm.ogpolyline_add_point(this.__wbg_ptr, ptr0);
1462
+ extrude_by_height_with_holes(height) {
1463
+ let deferred1_0;
1464
+ let deferred1_1;
1465
+ try {
1466
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1467
+ wasm.ogpolygon_extrude_by_height_with_holes(retptr, this.__wbg_ptr, height);
1468
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1469
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1470
+ deferred1_0 = r0;
1471
+ deferred1_1 = r1;
1472
+ return getStringFromWasm0(r0, r1);
1473
+ } finally {
1474
+ wasm.__wbindgen_add_to_stack_pointer(16);
1475
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1476
+ }
909
1477
  }
910
1478
  /**
1479
+ * @param {number} height
1480
+ * @returns {string}
911
1481
  */
912
- dispose_points() {
913
- wasm.ogpolyline_destroy(this.__wbg_ptr);
1482
+ extrude_by_height(height) {
1483
+ let deferred1_0;
1484
+ let deferred1_1;
1485
+ try {
1486
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1487
+ wasm.ogpolygon_extrude_by_height(retptr, this.__wbg_ptr, height);
1488
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1489
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1490
+ deferred1_0 = r0;
1491
+ deferred1_1 = r1;
1492
+ return getStringFromWasm0(r0, r1);
1493
+ } finally {
1494
+ wasm.__wbindgen_add_to_stack_pointer(16);
1495
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1496
+ }
914
1497
  }
915
1498
  /**
1499
+ * @returns {string}
916
1500
  */
917
- destroy() {
918
- wasm.ogpolyline_destroy(this.__wbg_ptr);
1501
+ get_outlines() {
1502
+ let deferred1_0;
1503
+ let deferred1_1;
1504
+ try {
1505
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1506
+ wasm.ogpolygon_get_outlines(retptr, this.__wbg_ptr);
1507
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1508
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1509
+ deferred1_0 = r0;
1510
+ deferred1_1 = r1;
1511
+ return getStringFromWasm0(r0, r1);
1512
+ } finally {
1513
+ wasm.__wbindgen_add_to_stack_pointer(16);
1514
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1515
+ }
919
1516
  }
920
1517
  /**
921
1518
  * @returns {string}
922
1519
  */
923
- get_points() {
1520
+ get_geometry() {
924
1521
  let deferred1_0;
925
1522
  let deferred1_1;
926
1523
  try {
927
1524
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
928
- wasm.ogpolyline_get_points(retptr, this.__wbg_ptr);
1525
+ wasm.ogpolygon_get_geometry(retptr, this.__wbg_ptr);
929
1526
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
930
1527
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
931
1528
  deferred1_0 = r0;
@@ -937,32 +1534,61 @@ class OGPolyLine {
937
1534
  }
938
1535
  }
939
1536
  /**
940
- * @returns {(Vector3D)[]}
1537
+ * @returns {string}
941
1538
  */
942
- get_raw_points() {
1539
+ get_brep_data() {
1540
+ let deferred1_0;
1541
+ let deferred1_1;
943
1542
  try {
944
1543
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
945
- wasm.ogpolyline_get_raw_points(retptr, this.__wbg_ptr);
1544
+ wasm.ogpolygon_get_brep_data(retptr, this.__wbg_ptr);
946
1545
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
947
1546
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
948
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
949
- wasm.__wbindgen_free(r0, r1 * 4, 4);
950
- return v1;
1547
+ deferred1_0 = r0;
1548
+ deferred1_1 = r1;
1549
+ return getStringFromWasm0(r0, r1);
951
1550
  } finally {
952
1551
  wasm.__wbindgen_add_to_stack_pointer(16);
1552
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
953
1553
  }
954
1554
  }
955
1555
  /**
956
- * @returns {boolean}
1556
+ * @returns {string}
957
1557
  */
958
- is_closed() {
959
- const ret = wasm.ogpolyline_is_closed(this.__wbg_ptr);
960
- return ret !== 0;
1558
+ outline_edges() {
1559
+ let deferred1_0;
1560
+ let deferred1_1;
1561
+ try {
1562
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1563
+ wasm.ogpolygon_outline_edges(retptr, this.__wbg_ptr);
1564
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1565
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1566
+ deferred1_0 = r0;
1567
+ deferred1_1 = r1;
1568
+ return getStringFromWasm0(r0, r1);
1569
+ } finally {
1570
+ wasm.__wbindgen_add_to_stack_pointer(16);
1571
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1572
+ }
961
1573
  }
962
1574
  /**
1575
+ * @returns {string}
963
1576
  */
964
- check_closed_test() {
965
- wasm.ogpolyline_check_closed_test(this.__wbg_ptr);
1577
+ binary_tree() {
1578
+ let deferred1_0;
1579
+ let deferred1_1;
1580
+ try {
1581
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1582
+ wasm.ogpolygon_binary_tree(retptr, this.__wbg_ptr);
1583
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1584
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1585
+ deferred1_0 = r0;
1586
+ deferred1_1 = r1;
1587
+ return getStringFromWasm0(r0, r1);
1588
+ } finally {
1589
+ wasm.__wbindgen_add_to_stack_pointer(16);
1590
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1591
+ }
966
1592
  }
967
1593
  }
968
1594
  const OGRectangleFinalization = typeof FinalizationRegistry === 'undefined' ? {
@@ -1198,12 +1824,12 @@ class OGSimpleLine {
1198
1824
  /**
1199
1825
  */
1200
1826
  dispose_points() {
1201
- wasm.ogpolyline_destroy(this.__wbg_ptr);
1827
+ wasm.ogsimpleline_destroy(this.__wbg_ptr);
1202
1828
  }
1203
1829
  /**
1204
1830
  */
1205
1831
  destroy() {
1206
- wasm.ogpolyline_destroy(this.__wbg_ptr);
1832
+ wasm.ogsimpleline_destroy(this.__wbg_ptr);
1207
1833
  }
1208
1834
  /**
1209
1835
  * @returns {string}
@@ -1399,6 +2025,44 @@ class Vector3D {
1399
2025
  const ret = wasm.vector3d_clone(this.__wbg_ptr);
1400
2026
  return Vector3D.__wrap(ret);
1401
2027
  }
2028
+ /**
2029
+ * @returns {number}
2030
+ */
2031
+ length_squared() {
2032
+ const ret = wasm.vector3d_length_squared(this.__wbg_ptr);
2033
+ return ret;
2034
+ }
2035
+ /**
2036
+ * @returns {number}
2037
+ */
2038
+ magnitude() {
2039
+ const ret = wasm.vector3d_magnitude(this.__wbg_ptr);
2040
+ return ret;
2041
+ }
2042
+ /**
2043
+ * @returns {Vector3D}
2044
+ */
2045
+ normalize() {
2046
+ const ret = wasm.vector3d_normalize(this.__wbg_ptr);
2047
+ return Vector3D.__wrap(ret);
2048
+ }
2049
+ /**
2050
+ * @param {number} scalar
2051
+ * @returns {Vector3D}
2052
+ */
2053
+ multiply(scalar) {
2054
+ const ret = wasm.vector3d_multiply(this.__wbg_ptr, scalar);
2055
+ return Vector3D.__wrap(ret);
2056
+ }
2057
+ /**
2058
+ * @param {Vector3D} other
2059
+ * @returns {number}
2060
+ */
2061
+ distance_to(other) {
2062
+ _assertClass(other, Vector3D);
2063
+ const ret = wasm.vector3d_distance_to(this.__wbg_ptr, other.__wbg_ptr);
2064
+ return ret;
2065
+ }
1402
2066
  }
1403
2067
  async function __wbg_load(module, imports) {
1404
2068
  if (typeof Response === 'function' && module instanceof Response) {
@@ -1430,6 +2094,13 @@ async function __wbg_load(module, imports) {
1430
2094
  function __wbg_get_imports() {
1431
2095
  const imports = {};
1432
2096
  imports.wbg = {};
2097
+ imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
2098
+ const ret = getStringFromWasm0(arg0, arg1);
2099
+ return addHeapObject(ret);
2100
+ };
2101
+ imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
2102
+ takeObject(arg0);
2103
+ };
1433
2104
  imports.wbg.__wbg_vector3d_new = function (arg0) {
1434
2105
  const ret = Vector3D.__wrap(arg0);
1435
2106
  return addHeapObject(ret);
@@ -1438,9 +2109,8 @@ function __wbg_get_imports() {
1438
2109
  const ret = Vector3D.__unwrap(takeObject(arg0));
1439
2110
  return ret;
1440
2111
  };
1441
- imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
1442
- const ret = getStringFromWasm0(arg0, arg1);
1443
- return addHeapObject(ret);
2112
+ imports.wbg.__wbg_log_b103404cc5920657 = function (arg0) {
2113
+ console.log(getObject(arg0));
1444
2114
  };
1445
2115
  imports.wbg.__wbindgen_throw = function (arg0, arg1) {
1446
2116
  throw new Error(getStringFromWasm0(arg0, arg1));
@@ -12066,7 +12736,57 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
12066
12736
  faceIndex: null,
12067
12737
  object: object
12068
12738
 
12069
- };
12739
+ };
12740
+
12741
+ }
12742
+
12743
+ const _start = /*@__PURE__*/ new Vector3();
12744
+ const _end = /*@__PURE__*/ new Vector3();
12745
+
12746
+ class LineSegments extends Line {
12747
+
12748
+ constructor( geometry, material ) {
12749
+
12750
+ super( geometry, material );
12751
+
12752
+ this.isLineSegments = true;
12753
+
12754
+ this.type = 'LineSegments';
12755
+
12756
+ }
12757
+
12758
+ computeLineDistances() {
12759
+
12760
+ const geometry = this.geometry;
12761
+
12762
+ // we assume non-indexed geometry
12763
+
12764
+ if ( geometry.index === null ) {
12765
+
12766
+ const positionAttribute = geometry.attributes.position;
12767
+ const lineDistances = [];
12768
+
12769
+ for ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {
12770
+
12771
+ _start.fromBufferAttribute( positionAttribute, i );
12772
+ _end.fromBufferAttribute( positionAttribute, i + 1 );
12773
+
12774
+ lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];
12775
+ lineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );
12776
+
12777
+ }
12778
+
12779
+ geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
12780
+
12781
+ } else {
12782
+
12783
+ console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
12784
+
12785
+ }
12786
+
12787
+ return this;
12788
+
12789
+ }
12070
12790
 
12071
12791
  }
12072
12792
 
@@ -12803,12 +13523,14 @@ class Pencil {
12803
13523
  // Raycaster
12804
13524
  this.raycaster.params.Line.threshold = 0.1;
12805
13525
  // A Dummy Ground Plane
12806
- const geometry = new PlaneGeometry(100, 100);
13526
+ const geometry = new PlaneGeometry(1000, 1000);
13527
+ // const material = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.DoubleSide, wireframe: true });
12807
13528
  const material = new MeshBasicMaterial({ color: 0xffff00, side: DoubleSide, transparent: true, opacity: 0 });
12808
13529
  const plane = new Mesh(geometry, material);
12809
13530
  plane.name = "pencil-ground";
12810
13531
  plane.rotation.x = Math.PI / 2;
12811
13532
  this.scene.add(plane);
13533
+ // plane.visible = true;
12812
13534
  plane.visible = false;
12813
13535
  this.dummyPlane = plane;
12814
13536
  }
@@ -12881,6 +13603,17 @@ class Pencil {
12881
13603
  }
12882
13604
  });
12883
13605
  }
13606
+ fireCursor(mouse) {
13607
+ const rect = this.container.getBoundingClientRect();
13608
+ const x = ((mouse.clientX - rect.left) / rect.width) * 2 - 1;
13609
+ const y = -((mouse.clientY - rect.top) / rect.height) * 2 + 1;
13610
+ this.raycaster.setFromCamera(new Vector2(x, y), this.camera);
13611
+ const intersects = this.raycaster.intersectObjects([this.dummyPlane]);
13612
+ if (intersects.length > 0) {
13613
+ const point = intersects[0].point;
13614
+ this.onCursorDown.trigger(point);
13615
+ }
13616
+ }
12884
13617
  }
12885
13618
 
12886
13619
  function spotLabelElement() {
@@ -12950,23 +13683,40 @@ class PolyLine extends Line {
12950
13683
  this.material.color.set(color);
12951
13684
  }
12952
13685
  }
12953
- constructor(points = []) {
13686
+ constructor(points) {
12954
13687
  super();
12955
13688
  this.points = [];
12956
13689
  this.isClosed = false;
13690
+ this.polyline = null;
12957
13691
  this.ogid = getUUID();
12958
- this.points = points;
12959
13692
  this.polyline = new OGPolyLine(this.ogid);
12960
- this.setConfig(points);
13693
+ if (points) {
13694
+ this.addMultiplePoints(points);
13695
+ }
13696
+ }
13697
+ addMultiplePoints(points) {
13698
+ this.points = points;
13699
+ if (!this.polyline)
13700
+ return;
13701
+ this.polyline.add_multiple_points(points);
12961
13702
  this.generateGeometry();
12962
13703
  }
12963
- setConfig(points) {
12964
- if (this.points.length < 2)
13704
+ // TODO: This needs to be improved
13705
+ translate(translation) {
13706
+ if (!this.polyline)
13707
+ return;
13708
+ this.polyline.translate(translation);
13709
+ this.generateGeometry();
13710
+ }
13711
+ set_position(position) {
13712
+ if (!this.polyline)
12965
13713
  return;
12966
- this.polyline.set_config(points);
13714
+ this.polyline.set_position(position);
12967
13715
  }
12968
13716
  addPoint(point) {
12969
13717
  this.points.push(point);
13718
+ if (!this.polyline)
13719
+ return;
12970
13720
  this.polyline.add_point(point);
12971
13721
  if (this.points.length < 2)
12972
13722
  return;
@@ -12977,6 +13727,8 @@ class PolyLine extends Line {
12977
13727
  }
12978
13728
  generateGeometry() {
12979
13729
  this.clearGeometry();
13730
+ if (!this.polyline)
13731
+ return;
12980
13732
  const buf = this.polyline.get_points();
12981
13733
  const bufFlush = JSON.parse(buf);
12982
13734
  const line = new BufferGeometry().setFromPoints(bufFlush);
@@ -12985,8 +13737,32 @@ class PolyLine extends Line {
12985
13737
  this.material = material;
12986
13738
  this.isClosed = this.polyline.is_closed();
12987
13739
  }
13740
+ getBrepData() {
13741
+ if (!this.polyline)
13742
+ return null;
13743
+ return this.polyline.get_brep_data();
13744
+ }
13745
+ // TODO: Add proper return type
13746
+ createOffset(offset) {
13747
+ if (!this.polyline)
13748
+ return null;
13749
+ const offsetData = this.polyline.get_offset(offset);
13750
+ if (!offsetData)
13751
+ return null;
13752
+ const data = JSON.parse(offsetData);
13753
+ if (!data.treated || data.treated.length === 0) {
13754
+ return null;
13755
+ }
13756
+ return data;
13757
+ }
13758
+ dispose() {
13759
+ console.log("Disposing OG - Polyline");
13760
+ this.clearGeometry();
13761
+ this.polyline = null;
13762
+ }
12988
13763
  }
12989
13764
 
13765
+ // TODO: What if user wants infintely smooth circle
12990
13766
  class BaseCircle extends Line {
12991
13767
  set color(color) {
12992
13768
  if (this.material instanceof LineBasicMaterial) {
@@ -13029,11 +13805,13 @@ class BaseCircle extends Line {
13029
13805
  }
13030
13806
  }
13031
13807
 
13032
- var _Rectangle_color;
13808
+ class BasePrimitive extends Line {
13809
+ }
13810
+
13033
13811
  /**
13034
13812
  * Rectangle
13035
13813
  */
13036
- class Rectangle extends Line {
13814
+ class Rectangle extends BasePrimitive {
13037
13815
  set width(width) {
13038
13816
  this.options.width = width;
13039
13817
  this.polyLineRectangle.update_width(width);
@@ -13044,33 +13822,47 @@ class Rectangle extends Line {
13044
13822
  this.polyLineRectangle.update_breadth(breadth);
13045
13823
  this.generateGeometry();
13046
13824
  }
13825
+ set center(center) {
13826
+ this.options.center = center;
13827
+ this.polyLineRectangle.update_center(center);
13828
+ this.generateGeometry();
13829
+ }
13047
13830
  set color(color) {
13048
13831
  if (this.material instanceof LineBasicMaterial) {
13049
13832
  this.material.color.set(color);
13050
- __classPrivateFieldSet(this, _Rectangle_color, color, "f");
13833
+ this.options.color = color;
13051
13834
  }
13052
13835
  }
13053
13836
  constructor(options) {
13837
+ var _a;
13054
13838
  super();
13055
- // nodeChild: RectanglePoly | null = null;
13056
- this.nodeOperation = "none";
13057
- _Rectangle_color.set(this, 0x000000);
13058
- this.ogid = getUUID();
13059
- this.options = options;
13060
- this.polyLineRectangle = new OGRectangle(this.ogid);
13061
- this.setConfig();
13839
+ this.options = {
13840
+ width: 1,
13841
+ breadth: 1,
13842
+ center: new Vector3D(0, 0, 0),
13843
+ color: 0x000000,
13844
+ };
13845
+ const ogid = (_a = options === null || options === void 0 ? void 0 : options.ogid) !== null && _a !== void 0 ? _a : getUUID();
13846
+ this.polyLineRectangle = new OGRectangle(ogid);
13847
+ const mergedOptions = Object.assign(Object.assign(Object.assign({}, this.options), options), { ogid });
13848
+ this.setConfig(mergedOptions);
13062
13849
  this.generateGeometry();
13063
13850
  }
13064
- setConfig() {
13851
+ setConfig(options) {
13852
+ this.options = options;
13853
+ console.log("Rectangle options set:", this.options);
13065
13854
  const { breadth, width, center } = this.options;
13066
13855
  this.polyLineRectangle.set_config(center, width, breadth);
13067
13856
  }
13857
+ getConfig() {
13858
+ return this.options;
13859
+ }
13068
13860
  generateGeometry() {
13069
13861
  this.polyLineRectangle.generate_points();
13070
13862
  const bufRaw = this.polyLineRectangle.get_points();
13071
13863
  const bufFlush = JSON.parse(bufRaw);
13072
13864
  const line = new BufferGeometry().setFromPoints(bufFlush);
13073
- const material = new LineBasicMaterial({ color: __classPrivateFieldGet(this, _Rectangle_color, "f") });
13865
+ const material = new LineBasicMaterial({ color: this.options.color });
13074
13866
  this.geometry = line;
13075
13867
  this.material = material;
13076
13868
  }
@@ -13078,22 +13870,359 @@ class Rectangle extends Line {
13078
13870
  this.geometry.dispose();
13079
13871
  }
13080
13872
  }
13081
- _Rectangle_color = new WeakMap();
13873
+
13874
+ var _Cylinder_outlineMesh;
13875
+ class Cylinder extends Mesh {
13876
+ constructor(options) {
13877
+ super();
13878
+ _Cylinder_outlineMesh.set(this, null);
13879
+ // Store local center offset to align outlines
13880
+ // TODO: Can this be moved to Engine? It can increase performance | Needs to be used in other shapes too
13881
+ this._geometryCenterOffset = new Vector3();
13882
+ this.ogid = getUUID();
13883
+ this.options = options;
13884
+ this.cylinder = new OGCylinder(this.ogid);
13885
+ this.setConfig();
13886
+ this.generateGeometry();
13887
+ }
13888
+ validateOptions() {
13889
+ if (!this.options) {
13890
+ throw new Error("Options are not defined for Cylinder");
13891
+ }
13892
+ }
13893
+ setConfig() {
13894
+ this.validateOptions();
13895
+ const { radius, height, segments, angle, center } = this.options;
13896
+ this.cylinder.set_config((center === null || center === void 0 ? void 0 : center.clone()) || new Vector3D(0, 0, 0), radius, height, angle, segments);
13897
+ }
13898
+ generateGeometry() {
13899
+ var _a, _b, _c;
13900
+ this.cylinder.generate_geometry();
13901
+ const geometryData = this.cylinder.get_geometry();
13902
+ const bufferData = JSON.parse(geometryData);
13903
+ console.log(bufferData);
13904
+ const geometry = new BufferGeometry();
13905
+ geometry.setAttribute("position", new Float32BufferAttribute(bufferData, 3));
13906
+ const material = new MeshStandardMaterial({
13907
+ color: 0x00ff00,
13908
+ transparent: true,
13909
+ opacity: 0.6,
13910
+ });
13911
+ geometry.computeVertexNormals();
13912
+ geometry.computeBoundingBox();
13913
+ const boundingBox = geometry.boundingBox;
13914
+ if (boundingBox) {
13915
+ boundingBox.getCenter(this._geometryCenterOffset);
13916
+ geometry.translate(-this._geometryCenterOffset.x, -this._geometryCenterOffset.y, -this._geometryCenterOffset.z);
13917
+ }
13918
+ this.geometry = geometry;
13919
+ this.material = material;
13920
+ this.position.set(((_a = this.options.center) === null || _a === void 0 ? void 0 : _a.x) || 0, ((_b = this.options.center) === null || _b === void 0 ? void 0 : _b.y) || 0, ((_c = this.options.center) === null || _c === void 0 ? void 0 : _c.z) || 0);
13921
+ }
13922
+ set outline(enable) {
13923
+ if (enable && !__classPrivateFieldGet(this, _Cylinder_outlineMesh, "f")) {
13924
+ const outline_buff = this.cylinder.outline_edges();
13925
+ const outline_buf = JSON.parse(outline_buff);
13926
+ const outlineGeometry = new BufferGeometry();
13927
+ outlineGeometry.setAttribute("position", new Float32BufferAttribute(outline_buf, 3));
13928
+ outlineGeometry.translate(-this._geometryCenterOffset.x, -this._geometryCenterOffset.y, -this._geometryCenterOffset.z);
13929
+ const outlineMaterial = new LineBasicMaterial({ color: 0x000000 });
13930
+ __classPrivateFieldSet(this, _Cylinder_outlineMesh, new LineSegments(outlineGeometry, outlineMaterial), "f");
13931
+ this.add(__classPrivateFieldGet(this, _Cylinder_outlineMesh, "f"));
13932
+ }
13933
+ if (!enable && __classPrivateFieldGet(this, _Cylinder_outlineMesh, "f")) {
13934
+ this.remove(__classPrivateFieldGet(this, _Cylinder_outlineMesh, "f"));
13935
+ __classPrivateFieldGet(this, _Cylinder_outlineMesh, "f").geometry.dispose();
13936
+ __classPrivateFieldSet(this, _Cylinder_outlineMesh, null, "f");
13937
+ }
13938
+ }
13939
+ getBrepData() {
13940
+ const brepData = this.cylinder.get_brep_dump();
13941
+ const brepDataParsed = JSON.parse(brepData);
13942
+ console.log(brepDataParsed);
13943
+ }
13944
+ }
13945
+ _Cylinder_outlineMesh = new WeakMap();
13946
+
13947
+ var _Polygon_outlineMesh;
13948
+ class Polygon extends Mesh {
13949
+ constructor(vertices) {
13950
+ var _a, _b;
13951
+ super();
13952
+ this.layerVertices = [];
13953
+ this.layerBackVertices = [];
13954
+ this.polygon = null;
13955
+ this.isTriangulated = false;
13956
+ _Polygon_outlineMesh.set(this, null);
13957
+ this._geometryCenterOffset = new Vector3();
13958
+ this.ogid = getUUID();
13959
+ this.polygon = new OGPolygon(this.ogid);
13960
+ if (vertices) {
13961
+ this.polygon.add_vertices(vertices);
13962
+ // Triangulate the polygon - WORKS
13963
+ (_a = this.polygon) === null || _a === void 0 ? void 0 : _a.triangulate();
13964
+ const bufFlush = (_b = this.polygon) === null || _b === void 0 ? void 0 : _b.get_buffer_flush();
13965
+ this.addFlushBufferToScene(bufFlush);
13966
+ // Testing New Triangulation - FAILING
13967
+ // const triResult = JSON.parse(this.polygon.new_triangulate());
13968
+ // console.log(triResult);
13969
+ }
13970
+ // THIS MIGHT HELP WITH SHARING THE POSITION with KERNEL when something is changed
13971
+ // const originalSet = this.position.set.bind(this.position);
13972
+ // this.position.set = (x: number, y: number, z: number) => {
13973
+ // console.log(`Position set to (${x}, ${y}, ${z})`);
13974
+ // // your custom logic here (e.g., notify OpenGeometry)
13975
+ // return originalSet(x, y, z);
13976
+ // };
13977
+ // // Optional: Override copy if you're using .copy() too
13978
+ // const originalCopy = this.position.copy.bind(this.position);
13979
+ // this.position.copy = (v: THREE.Vector3) => {
13980
+ // console.log(`Position copied from ${v.x}, ${v.y}, ${v.z}`);
13981
+ // return originalCopy(v);
13982
+ // };
13983
+ }
13984
+ translate(translation) {
13985
+ if (!this.polygon)
13986
+ return;
13987
+ console.log("Translating polygon by", translation.x, translation.y, translation.z);
13988
+ this.geometry.dispose();
13989
+ this.polygon.clear_buffer();
13990
+ this.polygon.translate(translation);
13991
+ this.polygon.triangulate();
13992
+ console.log("Polygon translated by", translation);
13993
+ const bufFlush = this.polygon.get_buffer_flush();
13994
+ console.log("Buffer flush after translation:", bufFlush);
13995
+ this.addFlushBufferToScene(bufFlush);
13996
+ }
13997
+ addVertices(vertices) {
13998
+ var _a, _b;
13999
+ if (!this.polygon)
14000
+ return;
14001
+ this.polygon.add_vertices(vertices);
14002
+ (_a = this.polygon) === null || _a === void 0 ? void 0 : _a.triangulate();
14003
+ const bufFlush = (_b = this.polygon) === null || _b === void 0 ? void 0 : _b.get_buffer_flush();
14004
+ this.addFlushBufferToScene(bufFlush);
14005
+ }
14006
+ resetVertices() {
14007
+ var _a;
14008
+ if (!this.polygon)
14009
+ return;
14010
+ this.layerVertices = [];
14011
+ this.geometry.dispose();
14012
+ (_a = this.polygon) === null || _a === void 0 ? void 0 : _a.clear_vertices();
14013
+ this.isTriangulated = false;
14014
+ }
14015
+ addVertex(threeVertex) {
14016
+ var _a, _b, _c;
14017
+ if (this.isTriangulated) {
14018
+ this.layerVertices = [];
14019
+ this.geometry.dispose();
14020
+ (_a = this.polygon) === null || _a === void 0 ? void 0 : _a.clear_vertices();
14021
+ this.isTriangulated = false;
14022
+ for (const vertex of this.layerBackVertices) {
14023
+ this.layerVertices.push(vertex.clone());
14024
+ }
14025
+ }
14026
+ const backupVertex = new Vector3D(parseFloat(threeVertex.x.toFixed(2)), 0, parseFloat(threeVertex.z.toFixed(2)));
14027
+ this.layerBackVertices.push(backupVertex);
14028
+ const vertex = new Vector3D(parseFloat(threeVertex.x.toFixed(2)),
14029
+ // when doing the parse operation getting -0 instead of 0
14030
+ 0, parseFloat(threeVertex.z.toFixed(2)));
14031
+ this.layerVertices.push(vertex);
14032
+ if (this.layerVertices.length > 3) {
14033
+ (_b = this.polygon) === null || _b === void 0 ? void 0 : _b.add_vertices(this.layerVertices);
14034
+ const bufFlush = (_c = this.polygon) === null || _c === void 0 ? void 0 : _c.triangulate();
14035
+ if (!bufFlush) {
14036
+ return;
14037
+ }
14038
+ this.addFlushBufferToScene(bufFlush);
14039
+ this.isTriangulated = true;
14040
+ }
14041
+ }
14042
+ addHole(holeVertices) {
14043
+ if (!this.polygon)
14044
+ return;
14045
+ this.polygon.add_holes(holeVertices);
14046
+ const triResult = JSON.parse(this.polygon.triangulate_with_holes());
14047
+ console.log(triResult);
14048
+ const newBufferFlush = triResult.new_buffer;
14049
+ const geometry = new BufferGeometry();
14050
+ geometry.setAttribute("position", new BufferAttribute(new Float32Array(newBufferFlush), 3));
14051
+ this.geometry = geometry;
14052
+ // const bufFlush = this.polygon.get_buffer_flush();
14053
+ // this.addFlushBufferToScene(bufFlush);
14054
+ }
14055
+ addFlushBufferToScene(flush) {
14056
+ const flushBuffer = JSON.parse(flush);
14057
+ const geometry = new BufferGeometry();
14058
+ geometry.setAttribute("position", new BufferAttribute(new Float32Array(flushBuffer), 3));
14059
+ geometry.computeVertexNormals();
14060
+ const material = new MeshStandardMaterial({
14061
+ color: 0x00ff00,
14062
+ side: DoubleSide,
14063
+ transparent: true,
14064
+ opacity: 0.5,
14065
+ // wireframe: true
14066
+ });
14067
+ this.geometry = geometry;
14068
+ this.material = material;
14069
+ }
14070
+ extrude(height) {
14071
+ if (!this.polygon)
14072
+ return;
14073
+ const extruded_buff = this.polygon.extrude_by_height(height);
14074
+ console.log(extruded_buff);
14075
+ this.generateExtrudedGeometry(extruded_buff);
14076
+ }
14077
+ generateExtrudedGeometry(extruded_buff) {
14078
+ // THIS WORKS
14079
+ const flushBuffer = JSON.parse(extruded_buff);
14080
+ console.log(flushBuffer);
14081
+ const geometry = new BufferGeometry();
14082
+ geometry.setAttribute("position", new BufferAttribute(new Float32Array(flushBuffer), 3));
14083
+ geometry.computeVertexNormals();
14084
+ this.geometry = geometry;
14085
+ const material = new MeshStandardMaterial({
14086
+ color: 0x00ff00,
14087
+ side: FrontSide,
14088
+ transparent: true,
14089
+ opacity: 0.5,
14090
+ // wireframe: true
14091
+ });
14092
+ this.material = material;
14093
+ }
14094
+ getBrepData() {
14095
+ if (!this.polygon)
14096
+ return null;
14097
+ const brepData = this.polygon.get_brep_data();
14098
+ return brepData;
14099
+ }
14100
+ set outlineColor(color) {
14101
+ if (__classPrivateFieldGet(this, _Polygon_outlineMesh, "f") && __classPrivateFieldGet(this, _Polygon_outlineMesh, "f").material instanceof LineBasicMaterial) {
14102
+ __classPrivateFieldGet(this, _Polygon_outlineMesh, "f").material.color.set(color);
14103
+ }
14104
+ }
14105
+ get outlineColor() {
14106
+ if (__classPrivateFieldGet(this, _Polygon_outlineMesh, "f") && __classPrivateFieldGet(this, _Polygon_outlineMesh, "f").material instanceof LineBasicMaterial) {
14107
+ return __classPrivateFieldGet(this, _Polygon_outlineMesh, "f").material.color.getHex();
14108
+ }
14109
+ return 0x000000; // Default color if outline mesh is not present
14110
+ }
14111
+ set outline(enable) {
14112
+ if (enable && !__classPrivateFieldGet(this, _Polygon_outlineMesh, "f") && this.polygon) {
14113
+ const outline_buff = this.polygon.outline_edges();
14114
+ const outline_buf = JSON.parse(outline_buff);
14115
+ const outlineGeometry = new BufferGeometry();
14116
+ outlineGeometry.setAttribute("position", new Float32BufferAttribute(outline_buf, 3));
14117
+ // TODO: Fix the outline position
14118
+ // outlineGeometry.translate(
14119
+ // -this._geometryCenterOffset.x,
14120
+ // -this._geometryCenterOffset.y,
14121
+ // -this._geometryCenterOffset.z
14122
+ // );
14123
+ const outlineMaterial = new LineBasicMaterial({ color: 0x000000 });
14124
+ __classPrivateFieldSet(this, _Polygon_outlineMesh, new LineSegments(outlineGeometry, outlineMaterial), "f");
14125
+ this.add(__classPrivateFieldGet(this, _Polygon_outlineMesh, "f"));
14126
+ }
14127
+ if (!enable && __classPrivateFieldGet(this, _Polygon_outlineMesh, "f")) {
14128
+ this.remove(__classPrivateFieldGet(this, _Polygon_outlineMesh, "f"));
14129
+ __classPrivateFieldGet(this, _Polygon_outlineMesh, "f").geometry.dispose();
14130
+ __classPrivateFieldSet(this, _Polygon_outlineMesh, null, "f");
14131
+ }
14132
+ }
14133
+ get outline() {
14134
+ if (__classPrivateFieldGet(this, _Polygon_outlineMesh, "f")) {
14135
+ return true;
14136
+ }
14137
+ return false;
14138
+ }
14139
+ bTree() {
14140
+ if (!this.polygon)
14141
+ return;
14142
+ const bTree = this.polygon.binary_tree();
14143
+ const parsedData = JSON.parse(bTree);
14144
+ console.log(parsedData);
14145
+ }
14146
+ dispose() {
14147
+ // console.log("Disposing OG - Polygon");
14148
+ this.geometry.dispose();
14149
+ if (this.material instanceof Material) {
14150
+ this.material.dispose();
14151
+ }
14152
+ if (__classPrivateFieldGet(this, _Polygon_outlineMesh, "f")) {
14153
+ __classPrivateFieldGet(this, _Polygon_outlineMesh, "f").geometry.dispose();
14154
+ if (__classPrivateFieldGet(this, _Polygon_outlineMesh, "f").material instanceof Material) {
14155
+ __classPrivateFieldGet(this, _Polygon_outlineMesh, "f").material.dispose();
14156
+ }
14157
+ }
14158
+ this.polygon = null;
14159
+ this.layerVertices = [];
14160
+ this.layerBackVertices = [];
14161
+ }
14162
+ }
14163
+ _Polygon_outlineMesh = new WeakMap();
13082
14164
 
13083
14165
  class OpenGeometry {
14166
+ set enablePencil(value) {
14167
+ if (value && !this._pencil) {
14168
+ if (!this.container || !this.scene) {
14169
+ throw new Error("Container or Scene is not defined");
14170
+ }
14171
+ this._pencil = new Pencil(this.container, this.scene, this.camera);
14172
+ }
14173
+ else if (!value && this._pencil) ;
14174
+ }
14175
+ get pencil() {
14176
+ return this._pencil;
14177
+ }
14178
+ get labelRenderer() {
14179
+ return this._labelRenderer;
14180
+ }
14181
+ get enableDebug() {
14182
+ return this._enableDebug;
14183
+ }
14184
+ /**
14185
+ * Enables or disables debug mode for OpenGeometry.
14186
+ * When enabled, it logs debug information to the console.
14187
+ * Addtionally,
14188
+ * 1. The geometry will be rendered with a semi-transparent material.
14189
+ * 2. The faces will be rendered with a random color.
14190
+ * 3. The normals will be rendered for better visualization.
14191
+ * @param value - A boolean indicating whether to enable or disable debug mode.
14192
+ */
14193
+ set enableDebug(value) {
14194
+ this._enableDebug = value;
14195
+ if (this._enableDebug) {
14196
+ console.log("OpenGeometry Debug Mode Enabled");
14197
+ }
14198
+ }
13084
14199
  constructor(container, threeScene, camera) {
13085
14200
  this.camera = camera;
14201
+ this._enableDebug = false;
13086
14202
  this.scene = threeScene;
13087
14203
  this.container = container;
13088
14204
  }
13089
- // Why Generic Types are used sometimes
13090
- // verifyOptions(options: OpenGeometryOptions) {
13091
- // for (const key in options) {
13092
- // if (options[key as keyof OpenGeometryOptions] === undefined) {
13093
- // throw new Error(`Missing required option: ${key}`);
13094
- // }
13095
- // }
13096
- // }
14205
+ /**
14206
+ * Asynchronously creates and initializes an instance of OpenGeometry.
14207
+ *
14208
+ * This factory method sets up the OpenGeometry engine by linking it with the
14209
+ * rendering context and the WebAssembly module. It ensures all required
14210
+ * options are provided and prepares the instance for 3D geometry operations.
14211
+ *
14212
+ * @param options - Configuration object for initializing OpenGeometry.
14213
+ * @returns A promise that resolves to a fully initialized OpenGeometry instance.
14214
+ * @throws If any of the required options (`container`, `scene`, or `camera`) are missing.
14215
+ *
14216
+ * @example
14217
+ * ```ts
14218
+ * const openGeometry = await OpenGeometry.create({
14219
+ * container: document.getElementById('myContainer')!,
14220
+ * scene: threeScene,
14221
+ * camera: threeCamera,
14222
+ * wasmURL: '/assets/opengeometry.wasm'
14223
+ * });
14224
+ * ```
14225
+ */
13097
14226
  static create(options) {
13098
14227
  return __awaiter(this, void 0, void 0, function* () {
13099
14228
  const { container, scene, camera } = options;
@@ -13109,18 +14238,9 @@ class OpenGeometry {
13109
14238
  return __awaiter(this, void 0, void 0, function* () {
13110
14239
  yield __wbg_init(wasmURL);
13111
14240
  this.setuplabelRenderer();
13112
- if (!this.container || !this.scene)
13113
- return;
13114
- this._pencil = new Pencil(this.container, this.scene, this.camera);
13115
14241
  this.setupEvent();
13116
14242
  });
13117
14243
  }
13118
- get pencil() {
13119
- return this._pencil;
13120
- }
13121
- get labelRenderer() {
13122
- return this._labelRenderer;
13123
- }
13124
14244
  setuplabelRenderer() {
13125
14245
  if (!this.container || !this.scene) {
13126
14246
  throw new Error("Container or Scene is not defined");
@@ -13133,6 +14253,8 @@ class OpenGeometry {
13133
14253
  this._labelRenderer = labelRenderer;
13134
14254
  }
13135
14255
  setupEvent() {
14256
+ // NOTE: The responsibility to resize normal rendererer lies with the user
14257
+ // but the label renderer should be resized automatically
13136
14258
  window.addEventListener("resize", () => {
13137
14259
  var _a, _b, _c;
13138
14260
  if (!this.container)
@@ -13140,6 +14262,13 @@ class OpenGeometry {
13140
14262
  (_a = this._labelRenderer) === null || _a === void 0 ? void 0 : _a.setSize((_b = this.container) === null || _b === void 0 ? void 0 : _b.clientWidth, (_c = this.container) === null || _c === void 0 ? void 0 : _c.clientHeight);
13141
14263
  });
13142
14264
  }
14265
+ // TODO: Can this be handled inside the OpenGeometry class itself?
14266
+ /**
14267
+ * Updates the label renderer to render the scene with the given camera.
14268
+ * This method should be called in the animation loop or render loop of your application.
14269
+ * @param scene - The Three.js scene containing the objects to be rendered.
14270
+ * @param camera - The Three.js camera used for rendering the scene.
14271
+ */
13143
14272
  update(scene, camera) {
13144
14273
  var _a;
13145
14274
  (_a = this._labelRenderer) === null || _a === void 0 ? void 0 : _a.render(scene, camera);
@@ -13225,8 +14354,14 @@ class BasePoly extends Mesh {
13225
14354
  const flushBuffer = JSON.parse(flush);
13226
14355
  const geometry = new BufferGeometry();
13227
14356
  geometry.setAttribute("position", new BufferAttribute(new Float32Array(flushBuffer), 3));
13228
- geometry.computeVertexNormals();
13229
- const material = new MeshStandardMaterial({ color: 0x3a86ff, side: DoubleSide });
14357
+ // geometry.computeVertexNormals();
14358
+ const material = new MeshStandardMaterial({
14359
+ color: 0x00ff00,
14360
+ // side: THREE.DoubleSide,
14361
+ transparent: true,
14362
+ opacity: 0.5,
14363
+ // wireframe: true
14364
+ });
13230
14365
  this.geometry = geometry;
13231
14366
  this.material = material;
13232
14367
  }
@@ -13239,15 +14374,16 @@ class BasePoly extends Mesh {
13239
14374
  generateExtrudedGeometry(extruded_buff) {
13240
14375
  // THIS WORKS
13241
14376
  const flushBuffer = JSON.parse(extruded_buff);
13242
- const geometry = new BufferGeometry();
13243
- geometry.setAttribute("position", new BufferAttribute(new Float32Array(flushBuffer), 3));
13244
- geometry.computeVertexNormals();
13245
- const material = new MeshPhongMaterial({
13246
- color: 0x3a86ff,
13247
- });
13248
- material.side = DoubleSide;
13249
- this.geometry = geometry;
13250
- this.material = material;
14377
+ console.log(flushBuffer);
14378
+ // const geometry = new THREE.BufferGeometry();
14379
+ // geometry.setAttribute("position", new THREE.BufferAttribute(new Float32Array(flushBuffer), 3));
14380
+ // // geometry.computeVertexNormals();
14381
+ // // const material = new THREE.MeshPhongMaterial({
14382
+ // // color: 0x3a86ff,
14383
+ // // });
14384
+ // // material.side = THREE.DoubleSide;
14385
+ // this.geometry = geometry;
14386
+ // this.material = material;
13251
14387
  }
13252
14388
  }
13253
14389
  class CirclePoly extends Mesh {
@@ -13276,7 +14412,7 @@ class CirclePoly extends Mesh {
13276
14412
  generateGeometry() {
13277
14413
  if (!this.baseCircle.circleArc)
13278
14414
  return;
13279
- this.polygon = BasePolygon.new_with_circle(this.baseCircle.circleArc.clone());
14415
+ this.polygon = OGPolygon.new_with_circle(this.baseCircle.circleArc.clone());
13280
14416
  }
13281
14417
  addFlushBufferToScene() {
13282
14418
  if (!this.polygon)
@@ -13304,10 +14440,11 @@ class CirclePoly extends Mesh {
13304
14440
  // }
13305
14441
  // geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
13306
14442
  const material = new MeshStandardMaterial({
13307
- color: 0x4460FF,
13308
- side: DoubleSide,
14443
+ color: 0x00ff00,
14444
+ // side: THREE.DoubleSide,
13309
14445
  transparent: true,
13310
- opacity: 0.8
14446
+ opacity: 0.5,
14447
+ // wireframe: true
13311
14448
  });
13312
14449
  this.geometry = geometry;
13313
14450
  this.material = material;
@@ -13319,9 +14456,17 @@ class CirclePoly extends Mesh {
13319
14456
  if (!this.polygon)
13320
14457
  return;
13321
14458
  const extruded_buff = this.polygon.extrude_by_height(height);
14459
+ console.log(JSON.parse(extruded_buff));
13322
14460
  this.isExtruded = true;
13323
14461
  this.generateExtrudedGeometry(extruded_buff);
13324
14462
  }
14463
+ getBrepData() {
14464
+ if (!this.polygon)
14465
+ return;
14466
+ const brepData = this.polygon.get_brep_data();
14467
+ const parsedData = JSON.parse(brepData);
14468
+ console.log(parsedData);
14469
+ }
13325
14470
  getOutline(type) {
13326
14471
  if (!this.polygon)
13327
14472
  return;
@@ -13406,7 +14551,6 @@ class CirclePoly extends Mesh {
13406
14551
  const flushBuffer = JSON.parse(extruded_buff);
13407
14552
  const geometry = new BufferGeometry();
13408
14553
  geometry.setAttribute("position", new BufferAttribute(new Float32Array(flushBuffer), 3));
13409
- geometry.computeVertexNormals();
13410
14554
  // To Test If Triangulation is working
13411
14555
  // const colors = new Float32Array(flushBuffer.length);
13412
14556
  // for (let i = 0; i < colors.length; i += 9) {
@@ -13431,12 +14575,21 @@ class CirclePoly extends Mesh {
13431
14575
  // shininess: 0,
13432
14576
  // side: THREE.DoubleSide
13433
14577
  // });
13434
- const material = new MeshPhongMaterial({
13435
- color: 0x3a86ff,
13436
- });
13437
- material.side = DoubleSide;
14578
+ // const material = new THREE.MeshPhongMaterial({
14579
+ // color: 0x3a86ff,
14580
+ // });
14581
+ // material.side = THREE.DoubleSide;
13438
14582
  this.geometry = geometry;
13439
- this.material = material;
14583
+ // this.material = material;
14584
+ }
14585
+ dispose() {
14586
+ var _a;
14587
+ if (!this.polygon)
14588
+ return;
14589
+ this.geometry.dispose();
14590
+ (_a = this.polygon) === null || _a === void 0 ? void 0 : _a.clear_vertices();
14591
+ this.polygon = null;
14592
+ this.isExtruded = false;
13440
14593
  }
13441
14594
  }
13442
14595
  class RectanglePoly extends Mesh {
@@ -13445,27 +14598,26 @@ class RectanglePoly extends Mesh {
13445
14598
  this.polygon = null;
13446
14599
  this.isExtruded = false;
13447
14600
  this.ogid = getUUID();
13448
- if (!baseRectangle.polyLineRectangle) {
13449
- throw new Error("BaseRectangle is not defined");
13450
- }
13451
- // baseRectangle.nodeChild = this;
13452
- baseRectangle.nodeOperation = "polygon";
14601
+ // if (!baseRectangle.polyLineRectangle) {
14602
+ // throw new Error("BaseRectangle is not defined");
14603
+ // }
14604
+ // // baseRectangle.nodeChild = this;
14605
+ // baseRectangle.nodeOperation = "polygon";
13453
14606
  this.baseRectangle = baseRectangle;
13454
14607
  this.generateGeometry();
13455
14608
  this.addFlushBufferToScene();
13456
14609
  }
13457
14610
  update() {
13458
- var _a, _b;
14611
+ var _a;
13459
14612
  this.geometry.dispose();
13460
14613
  (_a = this.polygon) === null || _a === void 0 ? void 0 : _a.clear_vertices();
13461
- (_b = this.polygon) === null || _b === void 0 ? void 0 : _b.add_vertices(this.baseRectangle.polyLineRectangle.get_raw_points());
14614
+ // this.polygon?.add_vertices(this.baseRectangle.polyLineRectangle.get_raw_points());
13462
14615
  this.generateGeometry();
13463
14616
  this.addFlushBufferToScene();
13464
14617
  }
13465
14618
  generateGeometry() {
13466
- if (!this.baseRectangle.polyLineRectangle)
13467
- return;
13468
- this.polygon = BasePolygon.new_with_rectangle(this.baseRectangle.polyLineRectangle.clone());
14619
+ // if (!this.baseRectangle.polyLineRectangle) return;
14620
+ // this.polygon = BasePolygon.new_with_rectangle(this.baseRectangle.polyLineRectangle.clone());
13469
14621
  }
13470
14622
  addFlushBufferToScene() {
13471
14623
  if (!this.polygon)
@@ -13622,5 +14774,5 @@ class FlatMesh extends Mesh {
13622
14774
  }
13623
14775
  }
13624
14776
 
13625
- export { BaseCircle, BasePoly, CirclePoly, FlatMesh, OpenGeometry, PolyLine, Rectangle, RectanglePoly, SimpleLine, SpotLabel, Vector3D };
14777
+ export { BaseCircle, BasePoly, CirclePoly, Cylinder, FlatMesh, OpenGeometry, PolyLine, Polygon, Rectangle, RectanglePoly, SimpleLine, SpotLabel, Vector3D };
13626
14778
  //# sourceMappingURL=index.js.map