@thatopen/components 2.4.2 → 2.4.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/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import * as THREE$1 from "three";
8
- import { BufferAttribute, Vector3, Plane, Line3, Vector2, Triangle, Sphere, Matrix4, Box3, BackSide, DoubleSide, FrontSide, Ray, Mesh, Object3D, MeshBasicMaterial, LineBasicMaterial, CylinderGeometry, BoxGeometry, BufferGeometry, Float32BufferAttribute, OctahedronGeometry, Line, TorusGeometry, SphereGeometry, Quaternion, Euler, PlaneGeometry, Raycaster } from "three";
8
+ import { BufferAttribute, Vector3, Vector2, Plane, Line3, Triangle, Sphere, Matrix4, Box3, BackSide, DoubleSide, FrontSide, Mesh, Ray, Raycaster, Quaternion, Object3D, Euler, MeshBasicMaterial, LineBasicMaterial, CylinderGeometry, BoxGeometry, BufferGeometry, Float32BufferAttribute, OctahedronGeometry, Line, SphereGeometry, TorusGeometry, PlaneGeometry } from "three";
9
9
  import * as FRAGS from "@thatopen/fragments";
10
10
  import { FragmentsGroup, Serializer } from "@thatopen/fragments";
11
11
  import * as WEBIFC from "web-ifc";
@@ -2022,27 +2022,27 @@ function iterateOverTriangles_indirect(offset, count, bvh, intersectsTriangleFun
2022
2022
  return false;
2023
2023
  }
2024
2024
  const _boxIntersection$3 = /* @__PURE__ */ new Vector3();
2025
- function raycast(bvh, root, side, ray2, intersects) {
2025
+ function raycast(bvh, root, side, ray2, intersects2) {
2026
2026
  BufferStack.setBuffer(bvh._roots[root]);
2027
- _raycast$1(0, bvh, side, ray2, intersects);
2027
+ _raycast$1(0, bvh, side, ray2, intersects2);
2028
2028
  BufferStack.clearBuffer();
2029
2029
  }
2030
- function _raycast$1(nodeIndex32, bvh, side, ray2, intersects) {
2030
+ function _raycast$1(nodeIndex32, bvh, side, ray2, intersects2) {
2031
2031
  const { float32Array, uint16Array, uint32Array } = BufferStack;
2032
2032
  const nodeIndex16 = nodeIndex32 * 2;
2033
2033
  const isLeaf = IS_LEAF(nodeIndex16, uint16Array);
2034
2034
  if (isLeaf) {
2035
2035
  const offset = OFFSET(nodeIndex32, uint32Array);
2036
2036
  const count = COUNT(nodeIndex16, uint16Array);
2037
- intersectTris(bvh, side, ray2, offset, count, intersects);
2037
+ intersectTris(bvh, side, ray2, offset, count, intersects2);
2038
2038
  } else {
2039
2039
  const leftIndex = LEFT_NODE(nodeIndex32);
2040
2040
  if (intersectRay(leftIndex, float32Array, ray2, _boxIntersection$3)) {
2041
- _raycast$1(leftIndex, bvh, side, ray2, intersects);
2041
+ _raycast$1(leftIndex, bvh, side, ray2, intersects2);
2042
2042
  }
2043
2043
  const rightIndex = RIGHT_NODE(nodeIndex32, uint32Array);
2044
2044
  if (intersectRay(rightIndex, float32Array, ray2, _boxIntersection$3)) {
2045
- _raycast$1(rightIndex, bvh, side, ray2, intersects);
2045
+ _raycast$1(rightIndex, bvh, side, ray2, intersects2);
2046
2046
  }
2047
2047
  }
2048
2048
  }
@@ -2428,27 +2428,27 @@ function refit_indirect(bvh, nodeIndices = null) {
2428
2428
  }
2429
2429
  }
2430
2430
  const _boxIntersection$1 = /* @__PURE__ */ new Vector3();
2431
- function raycast_indirect(bvh, root, side, ray2, intersects) {
2431
+ function raycast_indirect(bvh, root, side, ray2, intersects2) {
2432
2432
  BufferStack.setBuffer(bvh._roots[root]);
2433
- _raycast(0, bvh, side, ray2, intersects);
2433
+ _raycast(0, bvh, side, ray2, intersects2);
2434
2434
  BufferStack.clearBuffer();
2435
2435
  }
2436
- function _raycast(nodeIndex32, bvh, side, ray2, intersects) {
2436
+ function _raycast(nodeIndex32, bvh, side, ray2, intersects2) {
2437
2437
  const { float32Array, uint16Array, uint32Array } = BufferStack;
2438
2438
  const nodeIndex16 = nodeIndex32 * 2;
2439
2439
  const isLeaf = IS_LEAF(nodeIndex16, uint16Array);
2440
2440
  if (isLeaf) {
2441
2441
  const offset = OFFSET(nodeIndex32, uint32Array);
2442
2442
  const count = COUNT(nodeIndex16, uint16Array);
2443
- intersectTris_indirect(bvh, side, ray2, offset, count, intersects);
2443
+ intersectTris_indirect(bvh, side, ray2, offset, count, intersects2);
2444
2444
  } else {
2445
2445
  const leftIndex = LEFT_NODE(nodeIndex32);
2446
2446
  if (intersectRay(leftIndex, float32Array, ray2, _boxIntersection$1)) {
2447
- _raycast(leftIndex, bvh, side, ray2, intersects);
2447
+ _raycast(leftIndex, bvh, side, ray2, intersects2);
2448
2448
  }
2449
2449
  const rightIndex = RIGHT_NODE(nodeIndex32, uint32Array);
2450
2450
  if (intersectRay(rightIndex, float32Array, ray2, _boxIntersection$1)) {
2451
- _raycast(rightIndex, bvh, side, ray2, intersects);
2451
+ _raycast(rightIndex, bvh, side, ray2, intersects2);
2452
2452
  }
2453
2453
  }
2454
2454
  }
@@ -3120,7 +3120,7 @@ class MeshBVH {
3120
3120
  raycast(ray2, materialOrSide = FrontSide) {
3121
3121
  const roots = this._roots;
3122
3122
  const geometry = this.geometry;
3123
- const intersects = [];
3123
+ const intersects2 = [];
3124
3124
  const isMaterial = materialOrSide.isMaterial;
3125
3125
  const isArrayMaterial = Array.isArray(materialOrSide);
3126
3126
  const groups = geometry.groups;
@@ -3128,16 +3128,16 @@ class MeshBVH {
3128
3128
  const raycastFunc = this.indirect ? raycast_indirect : raycast;
3129
3129
  for (let i = 0, l = roots.length; i < l; i++) {
3130
3130
  const materialSide = isArrayMaterial ? materialOrSide[groups[i].materialIndex].side : side;
3131
- const startCount = intersects.length;
3132
- raycastFunc(this, i, materialSide, ray2, intersects);
3131
+ const startCount = intersects2.length;
3132
+ raycastFunc(this, i, materialSide, ray2, intersects2);
3133
3133
  if (isArrayMaterial) {
3134
3134
  const materialIndex = groups[i].materialIndex;
3135
- for (let j = startCount, jl = intersects.length; j < jl; j++) {
3136
- intersects[j].face.materialIndex = materialIndex;
3135
+ for (let j = startCount, jl = intersects2.length; j < jl; j++) {
3136
+ intersects2[j].face.materialIndex = materialIndex;
3137
3137
  }
3138
3138
  }
3139
3139
  }
3140
- return intersects;
3140
+ return intersects2;
3141
3141
  }
3142
3142
  raycastFirst(ray2, materialOrSide = FrontSide) {
3143
3143
  const roots = this._roots;
@@ -3335,7 +3335,7 @@ function convertRaycastIntersect(hit, object, raycaster) {
3335
3335
  const ray = /* @__PURE__ */ new Ray();
3336
3336
  const tmpInverseMatrix = /* @__PURE__ */ new Matrix4();
3337
3337
  const origMeshRaycastFunc = Mesh.prototype.raycast;
3338
- function acceleratedRaycast(raycaster, intersects) {
3338
+ function acceleratedRaycast(raycaster, intersects2) {
3339
3339
  if (this.geometry.boundsTree) {
3340
3340
  if (this.material === void 0)
3341
3341
  return;
@@ -3345,19 +3345,19 @@ function acceleratedRaycast(raycaster, intersects) {
3345
3345
  if (raycaster.firstHitOnly === true) {
3346
3346
  const hit = convertRaycastIntersect(bvh.raycastFirst(ray, this.material), this, raycaster);
3347
3347
  if (hit) {
3348
- intersects.push(hit);
3348
+ intersects2.push(hit);
3349
3349
  }
3350
3350
  } else {
3351
3351
  const hits = bvh.raycast(ray, this.material);
3352
3352
  for (let i = 0, l = hits.length; i < l; i++) {
3353
3353
  const hit = convertRaycastIntersect(hits[i], this, raycaster);
3354
3354
  if (hit) {
3355
- intersects.push(hit);
3355
+ intersects2.push(hit);
3356
3356
  }
3357
3357
  }
3358
3358
  }
3359
3359
  } else {
3360
- origMeshRaycastFunc.call(this, raycaster, intersects);
3360
+ origMeshRaycastFunc.call(this, raycaster, intersects2);
3361
3361
  }
3362
3362
  }
3363
3363
  function computeBoundsTree(options) {
@@ -4732,15 +4732,15 @@ function obbFromPoints(vertices) {
4732
4732
  mean.add(p).add(q).add(r).divideScalar(3);
4733
4733
  qp.subVectors(q, p);
4734
4734
  rp.subVectors(r, p);
4735
- const area = v.crossVectors(qp, rp).length() / 2;
4736
- weightedMean.add(v.copy(mean).multiplyScalar(area));
4737
- areaSum += area;
4738
- cxx += (9 * mean.x * mean.x + p.x * p.x + q.x * q.x + r.x * r.x) * (area / 12);
4739
- cxy += (9 * mean.x * mean.y + p.x * p.y + q.x * q.y + r.x * r.y) * (area / 12);
4740
- cxz += (9 * mean.x * mean.z + p.x * p.z + q.x * q.z + r.x * r.z) * (area / 12);
4741
- cyy += (9 * mean.y * mean.y + p.y * p.y + q.y * q.y + r.y * r.y) * (area / 12);
4742
- cyz += (9 * mean.y * mean.z + p.y * p.z + q.y * q.z + r.y * r.z) * (area / 12);
4743
- czz += (9 * mean.z * mean.z + p.z * p.z + q.z * q.z + r.z * r.z) * (area / 12);
4735
+ const area2 = v.crossVectors(qp, rp).length() / 2;
4736
+ weightedMean.add(v.copy(mean).multiplyScalar(area2));
4737
+ areaSum += area2;
4738
+ cxx += (9 * mean.x * mean.x + p.x * p.x + q.x * q.x + r.x * r.x) * (area2 / 12);
4739
+ cxy += (9 * mean.x * mean.y + p.x * p.y + q.x * q.y + r.x * r.y) * (area2 / 12);
4740
+ cxz += (9 * mean.x * mean.z + p.x * p.z + q.x * q.z + r.x * r.z) * (area2 / 12);
4741
+ cyy += (9 * mean.y * mean.y + p.y * p.y + q.y * q.y + r.y * r.y) * (area2 / 12);
4742
+ cyz += (9 * mean.y * mean.z + p.y * p.z + q.y * q.z + r.y * r.z) * (area2 / 12);
4743
+ czz += (9 * mean.z * mean.z + p.z * p.z + q.z * q.z + r.z * r.z) * (area2 / 12);
4744
4744
  }
4745
4745
  weightedMean.divideScalar(areaSum);
4746
4746
  cxx /= areaSum;
@@ -5232,15 +5232,15 @@ class VertexPicker extends Component {
5232
5232
  return this._pickedPoint;
5233
5233
  const casters = this.components.get(Raycasters);
5234
5234
  const caster = casters.get(world);
5235
- const intersects = caster.castRay();
5236
- if (!intersects) {
5235
+ const intersects2 = caster.castRay();
5236
+ if (!intersects2) {
5237
5237
  if (this._pickedPoint !== null) {
5238
5238
  this.onVertexLost.trigger();
5239
5239
  this._pickedPoint = null;
5240
5240
  }
5241
5241
  return this._pickedPoint;
5242
5242
  }
5243
- const point = this.getClosestVertex(intersects);
5243
+ const point = this.getClosestVertex(intersects2);
5244
5244
  if (!point) {
5245
5245
  if (this._pickedPoint !== null) {
5246
5246
  this.onVertexLost.trigger();
@@ -5259,11 +5259,11 @@ class VertexPicker extends Component {
5259
5259
  }
5260
5260
  return this._pickedPoint;
5261
5261
  }
5262
- getClosestVertex(intersects) {
5262
+ getClosestVertex(intersects2) {
5263
5263
  let closestVertex = new THREE$1.Vector3();
5264
5264
  let vertexFound = false;
5265
5265
  let closestDistance = Number.MAX_SAFE_INTEGER;
5266
- const vertices = this.getVertices(intersects);
5266
+ const vertices = this.getVertices(intersects2);
5267
5267
  if (vertices === null) {
5268
5268
  return null;
5269
5269
  }
@@ -5271,35 +5271,35 @@ class VertexPicker extends Component {
5271
5271
  if (!vertex) {
5272
5272
  continue;
5273
5273
  }
5274
- const distance = intersects.point.distanceTo(vertex);
5274
+ const distance = intersects2.point.distanceTo(vertex);
5275
5275
  if (distance > closestDistance || distance > this._config.snapDistance) {
5276
5276
  continue;
5277
5277
  }
5278
5278
  vertexFound = true;
5279
5279
  closestVertex = vertex;
5280
- closestDistance = intersects.point.distanceTo(vertex);
5280
+ closestDistance = intersects2.point.distanceTo(vertex);
5281
5281
  }
5282
5282
  if (vertexFound) {
5283
5283
  return closestVertex;
5284
5284
  }
5285
- return this.config.showOnlyVertex ? null : intersects.point;
5285
+ return this.config.showOnlyVertex ? null : intersects2.point;
5286
5286
  }
5287
- getVertices(intersects) {
5288
- const mesh = intersects.object;
5289
- if (!intersects.face || !mesh)
5287
+ getVertices(intersects2) {
5288
+ const mesh = intersects2.object;
5289
+ if (!intersects2.face || !mesh)
5290
5290
  return null;
5291
5291
  const geom = mesh.geometry;
5292
5292
  const instanceTransform = new THREE$1.Matrix4();
5293
- const { instanceId } = intersects;
5293
+ const { instanceId } = intersects2;
5294
5294
  const instanceFound = instanceId !== void 0;
5295
5295
  const isInstance = mesh instanceof THREE$1.InstancedMesh;
5296
5296
  if (isInstance && instanceFound) {
5297
5297
  mesh.getMatrixAt(instanceId, instanceTransform);
5298
5298
  }
5299
5299
  return [
5300
- this.getVertex(intersects.face.a, geom),
5301
- this.getVertex(intersects.face.b, geom),
5302
- this.getVertex(intersects.face.c, geom)
5300
+ this.getVertex(intersects2.face.a, geom),
5301
+ this.getVertex(intersects2.face.b, geom),
5302
+ this.getVertex(intersects2.face.c, geom)
5303
5303
  ].map((vertex) => {
5304
5304
  if (vertex) {
5305
5305
  if (isInstance && instanceFound) {
@@ -5321,6 +5321,840 @@ class VertexPicker extends Component {
5321
5321
  );
5322
5322
  }
5323
5323
  }
5324
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
5325
+ function getDefaultExportFromCjs(x) {
5326
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
5327
+ }
5328
+ var earcut$2 = { exports: {} };
5329
+ earcut$2.exports = earcut;
5330
+ earcut$2.exports.default = earcut;
5331
+ function earcut(data, holeIndices, dim) {
5332
+ dim = dim || 2;
5333
+ var hasHoles = holeIndices && holeIndices.length, outerLen = hasHoles ? holeIndices[0] * dim : data.length, outerNode = linkedList(data, 0, outerLen, dim, true), triangles = [];
5334
+ if (!outerNode || outerNode.next === outerNode.prev)
5335
+ return triangles;
5336
+ var minX, minY, maxX, maxY, x, y, invSize;
5337
+ if (hasHoles)
5338
+ outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
5339
+ if (data.length > 80 * dim) {
5340
+ minX = maxX = data[0];
5341
+ minY = maxY = data[1];
5342
+ for (var i = dim; i < outerLen; i += dim) {
5343
+ x = data[i];
5344
+ y = data[i + 1];
5345
+ if (x < minX)
5346
+ minX = x;
5347
+ if (y < minY)
5348
+ minY = y;
5349
+ if (x > maxX)
5350
+ maxX = x;
5351
+ if (y > maxY)
5352
+ maxY = y;
5353
+ }
5354
+ invSize = Math.max(maxX - minX, maxY - minY);
5355
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
5356
+ }
5357
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
5358
+ return triangles;
5359
+ }
5360
+ function linkedList(data, start, end, dim, clockwise) {
5361
+ var i, last;
5362
+ if (clockwise === signedArea(data, start, end, dim) > 0) {
5363
+ for (i = start; i < end; i += dim)
5364
+ last = insertNode(i, data[i], data[i + 1], last);
5365
+ } else {
5366
+ for (i = end - dim; i >= start; i -= dim)
5367
+ last = insertNode(i, data[i], data[i + 1], last);
5368
+ }
5369
+ if (last && equals(last, last.next)) {
5370
+ removeNode(last);
5371
+ last = last.next;
5372
+ }
5373
+ return last;
5374
+ }
5375
+ function filterPoints(start, end) {
5376
+ if (!start)
5377
+ return start;
5378
+ if (!end)
5379
+ end = start;
5380
+ var p = start, again;
5381
+ do {
5382
+ again = false;
5383
+ if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
5384
+ removeNode(p);
5385
+ p = end = p.prev;
5386
+ if (p === p.next)
5387
+ break;
5388
+ again = true;
5389
+ } else {
5390
+ p = p.next;
5391
+ }
5392
+ } while (again || p !== end);
5393
+ return end;
5394
+ }
5395
+ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
5396
+ if (!ear)
5397
+ return;
5398
+ if (!pass && invSize)
5399
+ indexCurve(ear, minX, minY, invSize);
5400
+ var stop = ear, prev, next;
5401
+ while (ear.prev !== ear.next) {
5402
+ prev = ear.prev;
5403
+ next = ear.next;
5404
+ if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
5405
+ triangles.push(prev.i / dim | 0);
5406
+ triangles.push(ear.i / dim | 0);
5407
+ triangles.push(next.i / dim | 0);
5408
+ removeNode(ear);
5409
+ ear = next.next;
5410
+ stop = next.next;
5411
+ continue;
5412
+ }
5413
+ ear = next;
5414
+ if (ear === stop) {
5415
+ if (!pass) {
5416
+ earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
5417
+ } else if (pass === 1) {
5418
+ ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
5419
+ earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
5420
+ } else if (pass === 2) {
5421
+ splitEarcut(ear, triangles, dim, minX, minY, invSize);
5422
+ }
5423
+ break;
5424
+ }
5425
+ }
5426
+ }
5427
+ function isEar(ear) {
5428
+ var a = ear.prev, b = ear, c = ear.next;
5429
+ if (area(a, b, c) >= 0)
5430
+ return false;
5431
+ var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
5432
+ var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx, y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy, x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx, y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
5433
+ var p = c.next;
5434
+ while (p !== a) {
5435
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
5436
+ return false;
5437
+ p = p.next;
5438
+ }
5439
+ return true;
5440
+ }
5441
+ function isEarHashed(ear, minX, minY, invSize) {
5442
+ var a = ear.prev, b = ear, c = ear.next;
5443
+ if (area(a, b, c) >= 0)
5444
+ return false;
5445
+ var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
5446
+ var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx, y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy, x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx, y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
5447
+ var minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
5448
+ var p = ear.prevZ, n = ear.nextZ;
5449
+ while (p && p.z >= minZ && n && n.z <= maxZ) {
5450
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
5451
+ return false;
5452
+ p = p.prevZ;
5453
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
5454
+ return false;
5455
+ n = n.nextZ;
5456
+ }
5457
+ while (p && p.z >= minZ) {
5458
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
5459
+ return false;
5460
+ p = p.prevZ;
5461
+ }
5462
+ while (n && n.z <= maxZ) {
5463
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
5464
+ return false;
5465
+ n = n.nextZ;
5466
+ }
5467
+ return true;
5468
+ }
5469
+ function cureLocalIntersections(start, triangles, dim) {
5470
+ var p = start;
5471
+ do {
5472
+ var a = p.prev, b = p.next.next;
5473
+ if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
5474
+ triangles.push(a.i / dim | 0);
5475
+ triangles.push(p.i / dim | 0);
5476
+ triangles.push(b.i / dim | 0);
5477
+ removeNode(p);
5478
+ removeNode(p.next);
5479
+ p = start = b;
5480
+ }
5481
+ p = p.next;
5482
+ } while (p !== start);
5483
+ return filterPoints(p);
5484
+ }
5485
+ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
5486
+ var a = start;
5487
+ do {
5488
+ var b = a.next.next;
5489
+ while (b !== a.prev) {
5490
+ if (a.i !== b.i && isValidDiagonal(a, b)) {
5491
+ var c = splitPolygon(a, b);
5492
+ a = filterPoints(a, a.next);
5493
+ c = filterPoints(c, c.next);
5494
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
5495
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
5496
+ return;
5497
+ }
5498
+ b = b.next;
5499
+ }
5500
+ a = a.next;
5501
+ } while (a !== start);
5502
+ }
5503
+ function eliminateHoles(data, holeIndices, outerNode, dim) {
5504
+ var queue = [], i, len, start, end, list;
5505
+ for (i = 0, len = holeIndices.length; i < len; i++) {
5506
+ start = holeIndices[i] * dim;
5507
+ end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
5508
+ list = linkedList(data, start, end, dim, false);
5509
+ if (list === list.next)
5510
+ list.steiner = true;
5511
+ queue.push(getLeftmost(list));
5512
+ }
5513
+ queue.sort(compareX);
5514
+ for (i = 0; i < queue.length; i++) {
5515
+ outerNode = eliminateHole(queue[i], outerNode);
5516
+ }
5517
+ return outerNode;
5518
+ }
5519
+ function compareX(a, b) {
5520
+ return a.x - b.x;
5521
+ }
5522
+ function eliminateHole(hole, outerNode) {
5523
+ var bridge = findHoleBridge(hole, outerNode);
5524
+ if (!bridge) {
5525
+ return outerNode;
5526
+ }
5527
+ var bridgeReverse = splitPolygon(bridge, hole);
5528
+ filterPoints(bridgeReverse, bridgeReverse.next);
5529
+ return filterPoints(bridge, bridge.next);
5530
+ }
5531
+ function findHoleBridge(hole, outerNode) {
5532
+ var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m;
5533
+ do {
5534
+ if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
5535
+ var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
5536
+ if (x <= hx && x > qx) {
5537
+ qx = x;
5538
+ m = p.x < p.next.x ? p : p.next;
5539
+ if (x === hx)
5540
+ return m;
5541
+ }
5542
+ }
5543
+ p = p.next;
5544
+ } while (p !== outerNode);
5545
+ if (!m)
5546
+ return null;
5547
+ var stop = m, mx = m.x, my = m.y, tanMin = Infinity, tan;
5548
+ p = m;
5549
+ do {
5550
+ if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
5551
+ tan = Math.abs(hy - p.y) / (hx - p.x);
5552
+ if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
5553
+ m = p;
5554
+ tanMin = tan;
5555
+ }
5556
+ }
5557
+ p = p.next;
5558
+ } while (p !== stop);
5559
+ return m;
5560
+ }
5561
+ function sectorContainsSector(m, p) {
5562
+ return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
5563
+ }
5564
+ function indexCurve(start, minX, minY, invSize) {
5565
+ var p = start;
5566
+ do {
5567
+ if (p.z === 0)
5568
+ p.z = zOrder(p.x, p.y, minX, minY, invSize);
5569
+ p.prevZ = p.prev;
5570
+ p.nextZ = p.next;
5571
+ p = p.next;
5572
+ } while (p !== start);
5573
+ p.prevZ.nextZ = null;
5574
+ p.prevZ = null;
5575
+ sortLinked(p);
5576
+ }
5577
+ function sortLinked(list) {
5578
+ var i, p, q, e, tail, numMerges, pSize, qSize, inSize = 1;
5579
+ do {
5580
+ p = list;
5581
+ list = null;
5582
+ tail = null;
5583
+ numMerges = 0;
5584
+ while (p) {
5585
+ numMerges++;
5586
+ q = p;
5587
+ pSize = 0;
5588
+ for (i = 0; i < inSize; i++) {
5589
+ pSize++;
5590
+ q = q.nextZ;
5591
+ if (!q)
5592
+ break;
5593
+ }
5594
+ qSize = inSize;
5595
+ while (pSize > 0 || qSize > 0 && q) {
5596
+ if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
5597
+ e = p;
5598
+ p = p.nextZ;
5599
+ pSize--;
5600
+ } else {
5601
+ e = q;
5602
+ q = q.nextZ;
5603
+ qSize--;
5604
+ }
5605
+ if (tail)
5606
+ tail.nextZ = e;
5607
+ else
5608
+ list = e;
5609
+ e.prevZ = tail;
5610
+ tail = e;
5611
+ }
5612
+ p = q;
5613
+ }
5614
+ tail.nextZ = null;
5615
+ inSize *= 2;
5616
+ } while (numMerges > 1);
5617
+ return list;
5618
+ }
5619
+ function zOrder(x, y, minX, minY, invSize) {
5620
+ x = (x - minX) * invSize | 0;
5621
+ y = (y - minY) * invSize | 0;
5622
+ x = (x | x << 8) & 16711935;
5623
+ x = (x | x << 4) & 252645135;
5624
+ x = (x | x << 2) & 858993459;
5625
+ x = (x | x << 1) & 1431655765;
5626
+ y = (y | y << 8) & 16711935;
5627
+ y = (y | y << 4) & 252645135;
5628
+ y = (y | y << 2) & 858993459;
5629
+ y = (y | y << 1) & 1431655765;
5630
+ return x | y << 1;
5631
+ }
5632
+ function getLeftmost(start) {
5633
+ var p = start, leftmost = start;
5634
+ do {
5635
+ if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
5636
+ leftmost = p;
5637
+ p = p.next;
5638
+ } while (p !== start);
5639
+ return leftmost;
5640
+ }
5641
+ function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
5642
+ return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
5643
+ }
5644
+ function isValidDiagonal(a, b) {
5645
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
5646
+ (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
5647
+ (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
5648
+ equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
5649
+ }
5650
+ function area(p, q, r) {
5651
+ return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
5652
+ }
5653
+ function equals(p1, p2) {
5654
+ return p1.x === p2.x && p1.y === p2.y;
5655
+ }
5656
+ function intersects(p1, q1, p2, q2) {
5657
+ var o1 = sign(area(p1, q1, p2));
5658
+ var o2 = sign(area(p1, q1, q2));
5659
+ var o3 = sign(area(p2, q2, p1));
5660
+ var o4 = sign(area(p2, q2, q1));
5661
+ if (o1 !== o2 && o3 !== o4)
5662
+ return true;
5663
+ if (o1 === 0 && onSegment(p1, p2, q1))
5664
+ return true;
5665
+ if (o2 === 0 && onSegment(p1, q2, q1))
5666
+ return true;
5667
+ if (o3 === 0 && onSegment(p2, p1, q2))
5668
+ return true;
5669
+ if (o4 === 0 && onSegment(p2, q1, q2))
5670
+ return true;
5671
+ return false;
5672
+ }
5673
+ function onSegment(p, q, r) {
5674
+ return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
5675
+ }
5676
+ function sign(num) {
5677
+ return num > 0 ? 1 : num < 0 ? -1 : 0;
5678
+ }
5679
+ function intersectsPolygon(a, b) {
5680
+ var p = a;
5681
+ do {
5682
+ if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b))
5683
+ return true;
5684
+ p = p.next;
5685
+ } while (p !== a);
5686
+ return false;
5687
+ }
5688
+ function locallyInside(a, b) {
5689
+ return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
5690
+ }
5691
+ function middleInside(a, b) {
5692
+ var p = a, inside = false, px = (a.x + b.x) / 2, py = (a.y + b.y) / 2;
5693
+ do {
5694
+ if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)
5695
+ inside = !inside;
5696
+ p = p.next;
5697
+ } while (p !== a);
5698
+ return inside;
5699
+ }
5700
+ function splitPolygon(a, b) {
5701
+ var a2 = new Node(a.i, a.x, a.y), b2 = new Node(b.i, b.x, b.y), an = a.next, bp = b.prev;
5702
+ a.next = b;
5703
+ b.prev = a;
5704
+ a2.next = an;
5705
+ an.prev = a2;
5706
+ b2.next = a2;
5707
+ a2.prev = b2;
5708
+ bp.next = b2;
5709
+ b2.prev = bp;
5710
+ return b2;
5711
+ }
5712
+ function insertNode(i, x, y, last) {
5713
+ var p = new Node(i, x, y);
5714
+ if (!last) {
5715
+ p.prev = p;
5716
+ p.next = p;
5717
+ } else {
5718
+ p.next = last.next;
5719
+ p.prev = last;
5720
+ last.next.prev = p;
5721
+ last.next = p;
5722
+ }
5723
+ return p;
5724
+ }
5725
+ function removeNode(p) {
5726
+ p.next.prev = p.prev;
5727
+ p.prev.next = p.next;
5728
+ if (p.prevZ)
5729
+ p.prevZ.nextZ = p.nextZ;
5730
+ if (p.nextZ)
5731
+ p.nextZ.prevZ = p.prevZ;
5732
+ }
5733
+ function Node(i, x, y) {
5734
+ this.i = i;
5735
+ this.x = x;
5736
+ this.y = y;
5737
+ this.prev = null;
5738
+ this.next = null;
5739
+ this.z = 0;
5740
+ this.prevZ = null;
5741
+ this.nextZ = null;
5742
+ this.steiner = false;
5743
+ }
5744
+ earcut.deviation = function(data, holeIndices, dim, triangles) {
5745
+ var hasHoles = holeIndices && holeIndices.length;
5746
+ var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
5747
+ var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
5748
+ if (hasHoles) {
5749
+ for (var i = 0, len = holeIndices.length; i < len; i++) {
5750
+ var start = holeIndices[i] * dim;
5751
+ var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
5752
+ polygonArea -= Math.abs(signedArea(data, start, end, dim));
5753
+ }
5754
+ }
5755
+ var trianglesArea = 0;
5756
+ for (i = 0; i < triangles.length; i += 3) {
5757
+ var a = triangles[i] * dim;
5758
+ var b = triangles[i + 1] * dim;
5759
+ var c = triangles[i + 2] * dim;
5760
+ trianglesArea += Math.abs(
5761
+ (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - (data[a] - data[b]) * (data[c + 1] - data[a + 1])
5762
+ );
5763
+ }
5764
+ return polygonArea === 0 && trianglesArea === 0 ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea);
5765
+ };
5766
+ function signedArea(data, start, end, dim) {
5767
+ var sum = 0;
5768
+ for (var i = start, j = end - dim; i < end; i += dim) {
5769
+ sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
5770
+ j = i;
5771
+ }
5772
+ return sum;
5773
+ }
5774
+ earcut.flatten = function(data) {
5775
+ var dim = data[0][0].length, result = { vertices: [], holes: [], dimensions: dim }, holeIndex = 0;
5776
+ for (var i = 0; i < data.length; i++) {
5777
+ for (var j = 0; j < data[i].length; j++) {
5778
+ for (var d = 0; d < dim; d++)
5779
+ result.vertices.push(data[i][j][d]);
5780
+ }
5781
+ if (i > 0) {
5782
+ holeIndex += data[i - 1].length;
5783
+ result.holes.push(holeIndex);
5784
+ }
5785
+ }
5786
+ return result;
5787
+ };
5788
+ var earcutExports = earcut$2.exports;
5789
+ const earcut$1 = /* @__PURE__ */ getDefaultExportFromCjs(earcutExports);
5790
+ class SectionGenerator extends Component {
5791
+ constructor() {
5792
+ super(...arguments);
5793
+ __publicField(this, "enabled", true);
5794
+ __publicField(this, "_inverseMatrix", new THREE$1.Matrix4());
5795
+ __publicField(this, "_localPlane", new THREE$1.Plane());
5796
+ __publicField(this, "_tempLine", new THREE$1.Line3());
5797
+ __publicField(this, "_tempVector", new THREE$1.Vector3());
5798
+ __publicField(this, "_plane");
5799
+ __publicField(this, "_plane2DCoordinateSystem", new THREE$1.Matrix4());
5800
+ __publicField(this, "_precission", 1e4);
5801
+ // Used if the plane is orthogonal to the cartesian planes
5802
+ __publicField(this, "_planeAxis");
5803
+ }
5804
+ get plane() {
5805
+ if (!this._plane) {
5806
+ throw new Error("Plane not set");
5807
+ }
5808
+ return this._plane;
5809
+ }
5810
+ set plane(plane) {
5811
+ this._plane = plane;
5812
+ }
5813
+ // This assumes that the mesh that contains the posAttr is aligned with the current plane
5814
+ createEdges(data) {
5815
+ const { meshes, posAttr } = data;
5816
+ let index = 0;
5817
+ posAttr.array.fill(0);
5818
+ const indexes = [];
5819
+ let lastIndex = 0;
5820
+ const tempMesh = new THREE$1.Mesh();
5821
+ for (const mesh of meshes) {
5822
+ if (!mesh.geometry) {
5823
+ continue;
5824
+ }
5825
+ if (!mesh.geometry.boundsTree) {
5826
+ mesh.geometry.computeBoundsTree();
5827
+ }
5828
+ if (!mesh.geometry.boundsTree) {
5829
+ throw new Error("Bounds tree not found for edges generation.");
5830
+ }
5831
+ if (mesh instanceof THREE$1.InstancedMesh) {
5832
+ if (mesh.count === 0) {
5833
+ continue;
5834
+ }
5835
+ const instanced = mesh;
5836
+ for (let i = 0; i < instanced.count; i++) {
5837
+ tempMesh.geometry = mesh.geometry;
5838
+ tempMesh.matrix.copy(mesh.matrix);
5839
+ const tempMatrix2 = new THREE$1.Matrix4();
5840
+ instanced.getMatrixAt(i, tempMatrix2);
5841
+ tempMesh.applyMatrix4(tempMatrix2);
5842
+ tempMesh.applyMatrix4(mesh.matrixWorld);
5843
+ tempMesh.updateMatrix();
5844
+ tempMesh.updateMatrixWorld();
5845
+ this._inverseMatrix.copy(tempMesh.matrixWorld).invert();
5846
+ this._localPlane.copy(this.plane).applyMatrix4(this._inverseMatrix);
5847
+ index = this.shapecast(tempMesh, posAttr, index);
5848
+ if (index !== lastIndex) {
5849
+ indexes.push(index);
5850
+ lastIndex = index;
5851
+ }
5852
+ }
5853
+ } else {
5854
+ this._inverseMatrix.copy(mesh.matrixWorld).invert();
5855
+ this._localPlane.copy(this.plane).applyMatrix4(this._inverseMatrix);
5856
+ index = this.shapecast(mesh, posAttr, index);
5857
+ if (index !== lastIndex) {
5858
+ indexes.push(index);
5859
+ lastIndex = index;
5860
+ }
5861
+ }
5862
+ }
5863
+ return { indexes, index };
5864
+ }
5865
+ createFills(buffer, trianglesIndices) {
5866
+ this.updatePlane2DCoordinateSystem();
5867
+ const allIndices = [];
5868
+ let currentTriangle = 0;
5869
+ for (let i = 0; i < trianglesIndices.length; i++) {
5870
+ const nextTriangle = trianglesIndices[i];
5871
+ const vertices = [];
5872
+ for (let j = currentTriangle; j < nextTriangle; j += 2) {
5873
+ vertices.push(j * 3);
5874
+ }
5875
+ const indices = this.computeFill(vertices, buffer);
5876
+ for (const index of indices) {
5877
+ allIndices.push(index);
5878
+ }
5879
+ currentTriangle = nextTriangle;
5880
+ }
5881
+ return allIndices;
5882
+ }
5883
+ computeFill(vertices, buffer) {
5884
+ const indices = /* @__PURE__ */ new Map();
5885
+ const all2DVertices = {};
5886
+ const shapes = /* @__PURE__ */ new Map();
5887
+ let nextShapeID = 0;
5888
+ const shapesEnds = /* @__PURE__ */ new Map();
5889
+ const shapesStarts = /* @__PURE__ */ new Map();
5890
+ const openShapes = /* @__PURE__ */ new Set();
5891
+ const p = this._precission;
5892
+ for (let i = 0; i < vertices.length; i++) {
5893
+ const startVertexIndex = vertices[i];
5894
+ let x1 = 0;
5895
+ let y1 = 0;
5896
+ let x2 = 0;
5897
+ let y2 = 0;
5898
+ const globalX1 = buffer[startVertexIndex];
5899
+ const globalY1 = buffer[startVertexIndex + 1];
5900
+ const globalZ1 = buffer[startVertexIndex + 2];
5901
+ const globalX2 = buffer[startVertexIndex + 3];
5902
+ const globalY2 = buffer[startVertexIndex + 4];
5903
+ const globalZ2 = buffer[startVertexIndex + 5];
5904
+ this._tempVector.set(globalX1, globalY1, globalZ1);
5905
+ this._tempVector.applyMatrix4(this._plane2DCoordinateSystem);
5906
+ x1 = Math.trunc(this._tempVector.x * p) / p;
5907
+ y1 = Math.trunc(this._tempVector.y * p) / p;
5908
+ this._tempVector.set(globalX2, globalY2, globalZ2);
5909
+ this._tempVector.applyMatrix4(this._plane2DCoordinateSystem);
5910
+ x2 = Math.trunc(this._tempVector.x * p) / p;
5911
+ y2 = Math.trunc(this._tempVector.y * p) / p;
5912
+ if (x1 === x2 && y1 === y2) {
5913
+ continue;
5914
+ }
5915
+ const startCode = `${x1}|${y1}`;
5916
+ const endCode = `${x2}|${y2}`;
5917
+ if (!indices.has(startCode)) {
5918
+ indices.set(startCode, startVertexIndex / 3);
5919
+ }
5920
+ if (!indices.has(endCode)) {
5921
+ indices.set(endCode, startVertexIndex / 3 + 1);
5922
+ }
5923
+ const start = indices.get(startCode);
5924
+ const end = indices.get(endCode);
5925
+ all2DVertices[start] = [x1, y1];
5926
+ all2DVertices[end] = [x2, y2];
5927
+ const startMatchesStart = shapesStarts.has(start);
5928
+ const startMatchesEnd = shapesEnds.has(start);
5929
+ const endMatchesStart = shapesStarts.has(end);
5930
+ const endMatchesEnd = shapesEnds.has(end);
5931
+ const noMatches = !startMatchesStart && !startMatchesEnd && !endMatchesStart && !endMatchesEnd;
5932
+ if (noMatches) {
5933
+ shapesStarts.set(start, nextShapeID);
5934
+ shapesEnds.set(end, nextShapeID);
5935
+ openShapes.add(nextShapeID);
5936
+ shapes.set(nextShapeID, [start, end]);
5937
+ nextShapeID++;
5938
+ } else if (startMatchesStart && endMatchesEnd) {
5939
+ const startIndex = shapesStarts.get(start);
5940
+ const endIndex = shapesEnds.get(end);
5941
+ const isShapeMerge = startIndex !== endIndex;
5942
+ if (isShapeMerge) {
5943
+ const endShape = shapes.get(endIndex);
5944
+ const startShape = shapes.get(startIndex);
5945
+ if (!endShape || !startShape) {
5946
+ continue;
5947
+ }
5948
+ shapes.delete(startIndex);
5949
+ openShapes.delete(startIndex);
5950
+ shapesEnds.set(startShape[startShape.length - 1], endIndex);
5951
+ shapesEnds.delete(endShape[endShape.length - 1]);
5952
+ for (const index of startShape) {
5953
+ endShape.push(index);
5954
+ }
5955
+ } else {
5956
+ openShapes.delete(endIndex);
5957
+ }
5958
+ shapesStarts.delete(start);
5959
+ shapesEnds.delete(end);
5960
+ } else if (startMatchesEnd && endMatchesStart) {
5961
+ const startIndex = shapesStarts.get(end);
5962
+ const endIndex = shapesEnds.get(start);
5963
+ const isShapeMerge = startIndex !== endIndex;
5964
+ if (isShapeMerge) {
5965
+ const endShape = shapes.get(endIndex);
5966
+ const startShape = shapes.get(startIndex);
5967
+ if (!endShape || !startShape) {
5968
+ continue;
5969
+ }
5970
+ shapes.delete(startIndex);
5971
+ openShapes.delete(startIndex);
5972
+ shapesEnds.set(startShape[startShape.length - 1], endIndex);
5973
+ shapesEnds.delete(endShape[endShape.length - 1]);
5974
+ for (const index of startShape) {
5975
+ endShape.push(index);
5976
+ }
5977
+ } else {
5978
+ openShapes.delete(endIndex);
5979
+ }
5980
+ shapesStarts.delete(end);
5981
+ shapesEnds.delete(start);
5982
+ } else if (startMatchesStart && endMatchesStart) {
5983
+ const startIndex1 = shapesStarts.get(end);
5984
+ const startIndex2 = shapesStarts.get(start);
5985
+ const startShape2 = shapes.get(startIndex2);
5986
+ const startShape1 = shapes.get(startIndex1);
5987
+ if (!startShape2 || !startShape1) {
5988
+ continue;
5989
+ }
5990
+ shapes.delete(startIndex1);
5991
+ openShapes.delete(startIndex1);
5992
+ shapesStarts.delete(startShape2[0]);
5993
+ shapesStarts.delete(startShape1[0]);
5994
+ shapesEnds.delete(startShape1[startShape1.length - 1]);
5995
+ shapesStarts.set(startShape1[startShape1.length - 1], startIndex2);
5996
+ startShape1.reverse();
5997
+ startShape2.splice(0, 0, ...startShape1);
5998
+ } else if (startMatchesEnd && endMatchesEnd) {
5999
+ const endIndex1 = shapesEnds.get(end);
6000
+ const endIndex2 = shapesEnds.get(start);
6001
+ const endShape2 = shapes.get(endIndex2);
6002
+ const endShape1 = shapes.get(endIndex1);
6003
+ if (!endShape2 || !endShape1) {
6004
+ continue;
6005
+ }
6006
+ shapes.delete(endIndex1);
6007
+ openShapes.delete(endIndex1);
6008
+ shapesEnds.delete(endShape2[endShape2.length - 1]);
6009
+ shapesEnds.delete(endShape1[endShape1.length - 1]);
6010
+ shapesStarts.delete(endShape1[0]);
6011
+ shapesEnds.set(endShape1[0], endIndex2);
6012
+ endShape1.reverse();
6013
+ endShape2.push(...endShape1);
6014
+ } else if (startMatchesStart) {
6015
+ const shapeIndex = shapesStarts.get(start);
6016
+ const shape = shapes.get(shapeIndex);
6017
+ if (!shape) {
6018
+ continue;
6019
+ }
6020
+ shape.unshift(end);
6021
+ shapesStarts.delete(start);
6022
+ shapesStarts.set(end, shapeIndex);
6023
+ } else if (startMatchesEnd) {
6024
+ const shapeIndex = shapesEnds.get(start);
6025
+ const shape = shapes.get(shapeIndex);
6026
+ if (!shape) {
6027
+ continue;
6028
+ }
6029
+ shape.push(end);
6030
+ shapesEnds.delete(start);
6031
+ shapesEnds.set(end, shapeIndex);
6032
+ } else if (endMatchesStart) {
6033
+ const shapeIndex = shapesStarts.get(end);
6034
+ const shape = shapes.get(shapeIndex);
6035
+ if (!shape) {
6036
+ continue;
6037
+ }
6038
+ shape.unshift(start);
6039
+ shapesStarts.delete(end);
6040
+ shapesStarts.set(start, shapeIndex);
6041
+ } else if (endMatchesEnd) {
6042
+ const shapeIndex = shapesEnds.get(end);
6043
+ const shape = shapes.get(shapeIndex);
6044
+ if (!shape) {
6045
+ continue;
6046
+ }
6047
+ shape.push(start);
6048
+ shapesEnds.delete(end);
6049
+ shapesEnds.set(start, shapeIndex);
6050
+ }
6051
+ }
6052
+ const trueIndices = [];
6053
+ for (const [id, shape] of shapes) {
6054
+ if (openShapes.has(id)) {
6055
+ continue;
6056
+ }
6057
+ const vertices2 = [];
6058
+ const indexMap = /* @__PURE__ */ new Map();
6059
+ let counter = 0;
6060
+ for (const index of shape) {
6061
+ const vertex = all2DVertices[index];
6062
+ vertices2.push(vertex[0], vertex[1]);
6063
+ indexMap.set(counter++, index);
6064
+ }
6065
+ const result = earcut$1(vertices2);
6066
+ for (const index of result) {
6067
+ const trueIndex = indexMap.get(index);
6068
+ if (trueIndex === void 0) {
6069
+ throw new Error("Map error!");
6070
+ }
6071
+ trueIndices.push(trueIndex);
6072
+ }
6073
+ }
6074
+ return trueIndices;
6075
+ }
6076
+ updatePlane2DCoordinateSystem() {
6077
+ this._plane2DCoordinateSystem = new THREE$1.Matrix4();
6078
+ const xAxis = new THREE$1.Vector3(1, 0, 0);
6079
+ const yAxis = new THREE$1.Vector3(0, 1, 0);
6080
+ const zAxis = this.plane.normal;
6081
+ const pos = new THREE$1.Vector3();
6082
+ this.plane.coplanarPoint(pos);
6083
+ if (this._planeAxis === "x") {
6084
+ xAxis.crossVectors(yAxis, zAxis);
6085
+ } else if (this._planeAxis === "y") {
6086
+ yAxis.crossVectors(zAxis, xAxis);
6087
+ } else if (this._planeAxis === "z")
6088
+ ;
6089
+ else {
6090
+ xAxis.crossVectors(yAxis, zAxis).normalize();
6091
+ yAxis.crossVectors(zAxis, xAxis);
6092
+ }
6093
+ this._plane2DCoordinateSystem.fromArray([
6094
+ xAxis.x,
6095
+ xAxis.y,
6096
+ xAxis.z,
6097
+ 0,
6098
+ yAxis.x,
6099
+ yAxis.y,
6100
+ yAxis.z,
6101
+ 0,
6102
+ zAxis.x,
6103
+ zAxis.y,
6104
+ zAxis.z,
6105
+ 0,
6106
+ pos.x,
6107
+ pos.y,
6108
+ pos.z,
6109
+ 1
6110
+ ]);
6111
+ this._plane2DCoordinateSystem.invert();
6112
+ }
6113
+ shapecast(mesh, posAttr, index) {
6114
+ mesh.geometry.boundsTree.shapecast({
6115
+ intersectsBounds: (box) => {
6116
+ return this._localPlane.intersectsBox(box);
6117
+ },
6118
+ // @ts-ignore
6119
+ intersectsTriangle: (tri) => {
6120
+ let count = 0;
6121
+ this._tempLine.start.copy(tri.a);
6122
+ this._tempLine.end.copy(tri.b);
6123
+ if (this._localPlane.intersectLine(this._tempLine, this._tempVector)) {
6124
+ const result = this._tempVector.applyMatrix4(mesh.matrixWorld);
6125
+ posAttr.setXYZ(index, result.x, result.y, result.z);
6126
+ count++;
6127
+ index++;
6128
+ }
6129
+ this._tempLine.start.copy(tri.b);
6130
+ this._tempLine.end.copy(tri.c);
6131
+ if (this._localPlane.intersectLine(this._tempLine, this._tempVector)) {
6132
+ const result = this._tempVector.applyMatrix4(mesh.matrixWorld);
6133
+ posAttr.setXYZ(index, result.x, result.y, result.z);
6134
+ count++;
6135
+ index++;
6136
+ }
6137
+ this._tempLine.start.copy(tri.c);
6138
+ this._tempLine.end.copy(tri.a);
6139
+ if (this._localPlane.intersectLine(this._tempLine, this._tempVector)) {
6140
+ const result = this._tempVector.applyMatrix4(mesh.matrixWorld);
6141
+ posAttr.setXYZ(index, result.x, result.y, result.z);
6142
+ count++;
6143
+ index++;
6144
+ }
6145
+ if (count !== 2) {
6146
+ index -= count;
6147
+ }
6148
+ }
6149
+ });
6150
+ return index;
6151
+ }
6152
+ }
6153
+ /**
6154
+ * A unique identifier for the component.
6155
+ * This UUID is used to register the component within the Components system.
6156
+ */
6157
+ __publicField(SectionGenerator, "uuid", "1a193b87-6376-46c8-9e65-62a1576fdb64");
5324
6158
  const _Components = class _Components {
5325
6159
  constructor() {
5326
6160
  /** {@link Disposable.onDisposed} */
@@ -5459,7 +6293,7 @@ const _Components = class _Components {
5459
6293
  /**
5460
6294
  * The version of the @thatopen/components library.
5461
6295
  */
5462
- __publicField(_Components, "release", "2.4.2");
6296
+ __publicField(_Components, "release", "2.4.4");
5463
6297
  let Components = _Components;
5464
6298
  class SimpleWorld extends Base {
5465
6299
  constructor() {
@@ -8122,9 +8956,9 @@ class CameraControls extends EventDispatcher {
8122
8956
  const origin = _v3C.addVectors(this._target, nearPlaneCorner);
8123
8957
  _raycaster$1.set(origin, rayDirection);
8124
8958
  _raycaster$1.far = this._spherical.radius + 1;
8125
- const intersects = _raycaster$1.intersectObjects(this.colliderMeshes);
8126
- if (intersects.length !== 0 && intersects[0].distance < distance) {
8127
- distance = intersects[0].distance;
8959
+ const intersects2 = _raycaster$1.intersectObjects(this.colliderMeshes);
8960
+ if (intersects2.length !== 0 && intersects2[0].distance < distance) {
8961
+ distance = intersects2[0].distance;
8128
8962
  }
8129
8963
  }
8130
8964
  return distance;
@@ -11548,9 +12382,9 @@ const _Clipper = class _Clipper extends Component {
11548
12382
  create(world) {
11549
12383
  const casters = this.components.get(Raycasters);
11550
12384
  const caster = casters.get(world);
11551
- const intersects = caster.castRay();
11552
- if (intersects) {
11553
- return this.createPlaneFromIntersection(world, intersects);
12385
+ const intersects2 = caster.castRay();
12386
+ if (intersects2) {
12387
+ return this.createPlaneFromIntersection(world, intersects2);
11554
12388
  }
11555
12389
  return null;
11556
12390
  }
@@ -11627,9 +12461,9 @@ const _Clipper = class _Clipper extends Component {
11627
12461
  const casters = this.components.get(Raycasters);
11628
12462
  const caster = casters.get(world);
11629
12463
  const meshes = this.getAllPlaneMeshes();
11630
- const intersects = caster.castRay(meshes);
11631
- if (intersects) {
11632
- const found = intersects.object;
12464
+ const intersects2 = caster.castRay(meshes);
12465
+ if (intersects2) {
12466
+ const found = intersects2.object;
11633
12467
  return this.list.find((p) => p.meshes.includes(found));
11634
12468
  }
11635
12469
  return void 0;
@@ -17143,10 +17977,6 @@ const _FragmentsManager = class _FragmentsManager extends Component {
17143
17977
  */
17144
17978
  __publicField(_FragmentsManager, "uuid", "fef46874-46a3-461b-8c44-2922ab77c806");
17145
17979
  let FragmentsManager = _FragmentsManager;
17146
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
17147
- function getDefaultExportFromCjs(x) {
17148
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
17149
- }
17150
17980
  function commonjsRequire(path) {
17151
17981
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
17152
17982
  }
@@ -20257,10 +21087,8 @@ function readDocType$1(xmlData, i) {
20257
21087
  i += 8;
20258
21088
  else if (hasBody && isNotation(xmlData, i))
20259
21089
  i += 9;
20260
- else if (isComment)
20261
- comment = true;
20262
21090
  else
20263
- throw new Error("Invalid DOCTYPE");
21091
+ comment = true;
20264
21092
  angleBracketsCount++;
20265
21093
  exp = "";
20266
21094
  } else if (xmlData[i] === ">") {
@@ -20304,11 +21132,6 @@ function readEntityExp(xmlData, i) {
20304
21132
  }
20305
21133
  return [entityName2, val2, i];
20306
21134
  }
20307
- function isComment(xmlData, i) {
20308
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
20309
- return true;
20310
- return false;
20311
- }
20312
21135
  function isEntity(xmlData, i) {
20313
21136
  if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y")
20314
21137
  return true;
@@ -20363,13 +21186,13 @@ function toNumber$1(str, options = {}) {
20363
21186
  } else {
20364
21187
  const match = numRegex.exec(trimmedStr);
20365
21188
  if (match) {
20366
- const sign = match[1];
21189
+ const sign2 = match[1];
20367
21190
  const leadingZeros = match[2];
20368
21191
  let numTrimmedByZeros = trimZeros(match[3]);
20369
21192
  const eNotation = match[4] || match[6];
20370
- if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".")
21193
+ if (!options.leadingZeros && leadingZeros.length > 0 && sign2 && trimmedStr[2] !== ".")
20371
21194
  return str;
20372
- else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".")
21195
+ else if (!options.leadingZeros && leadingZeros.length > 0 && !sign2 && trimmedStr[1] !== ".")
20373
21196
  return str;
20374
21197
  else {
20375
21198
  const num = Number(trimmedStr);
@@ -20389,7 +21212,7 @@ function toNumber$1(str, options = {}) {
20389
21212
  return num;
20390
21213
  else if (numStr === numTrimmedByZeros)
20391
21214
  return num;
20392
- else if (sign && numStr === "-" + numTrimmedByZeros)
21215
+ else if (sign2 && numStr === "-" + numTrimmedByZeros)
20393
21216
  return num;
20394
21217
  else
20395
21218
  return str;
@@ -20397,14 +21220,14 @@ function toNumber$1(str, options = {}) {
20397
21220
  if (leadingZeros) {
20398
21221
  if (numTrimmedByZeros === numStr)
20399
21222
  return num;
20400
- else if (sign + numTrimmedByZeros === numStr)
21223
+ else if (sign2 + numTrimmedByZeros === numStr)
20401
21224
  return num;
20402
21225
  else
20403
21226
  return str;
20404
21227
  }
20405
21228
  if (trimmedStr === numStr)
20406
21229
  return num;
20407
- else if (trimmedStr === sign + numStr)
21230
+ else if (trimmedStr === sign2 + numStr)
20408
21231
  return num;
20409
21232
  return str;
20410
21233
  }
@@ -22349,7 +23172,7 @@ ${users}
22349
23172
  Comment: CommentText,
22350
23173
  Viewpoint: Viewpoint2
22351
23174
  } = markupComment;
22352
- if (!(Guid && CommentDate && Author && (Comment || Viewpoint2)))
23175
+ if (!(Guid && CommentDate && Author && Comment))
22353
23176
  return null;
22354
23177
  const viewpoints = this.components.get(Viewpoints);
22355
23178
  const comment = new Comment(this.components, CommentText ?? "");
@@ -26399,10 +27222,10 @@ class IDSFacet {
26399
27222
  let minPass = true;
26400
27223
  let maxPass = true;
26401
27224
  if (min !== void 0) {
26402
- minPass = minInclusive ? value <= min : value < min;
27225
+ minPass = minInclusive ? value >= min : value > min;
26403
27226
  }
26404
27227
  if (max !== void 0) {
26405
- maxPass = maxInclusive ? value >= max : value > max;
27228
+ maxPass = maxInclusive ? value <= max : value < max;
26406
27229
  }
26407
27230
  pass = minPass && maxPass;
26408
27231
  }
@@ -27127,16 +27950,15 @@ class IDSProperty extends IDSFacet {
27127
27950
  this.testResult.push(result2);
27128
27951
  const sets = await this.getPsets(model, expressID);
27129
27952
  const matchingSets = sets.filter((set) => {
27130
- var _a2;
27131
27953
  const result3 = this.evalRequirement(
27132
- ((_a2 = set.Name) == null ? void 0 : _a2.value) ?? null,
27954
+ set.Name ?? null,
27133
27955
  this.propertySet,
27134
27956
  "PropertySet"
27135
27957
  );
27136
27958
  if (!result3)
27137
27959
  return false;
27138
27960
  checks.push({
27139
- currentValue: set.Name.value,
27961
+ currentValue: set.Name,
27140
27962
  parameter: "PropertySet",
27141
27963
  pass: true,
27142
27964
  requiredValue: this.propertySet.parameter
@@ -27153,8 +27975,7 @@ class IDSProperty extends IDSFacet {
27153
27975
  continue;
27154
27976
  }
27155
27977
  for (const set of matchingSets) {
27156
- const itemsAttrName = this.getItemsAttrName(set.type);
27157
- if (!itemsAttrName) {
27978
+ if (!("Properties" in set)) {
27158
27979
  checks.push({
27159
27980
  currentValue: null,
27160
27981
  parameter: "BaseName",
@@ -27163,7 +27984,7 @@ class IDSProperty extends IDSFacet {
27163
27984
  });
27164
27985
  continue;
27165
27986
  }
27166
- const items = set[itemsAttrName];
27987
+ const items = set.Properties;
27167
27988
  const matchingItems = items.filter((item) => {
27168
27989
  var _a2;
27169
27990
  if (this._unsupportedTypes.includes(item.type)) {
@@ -27218,18 +28039,22 @@ class IDSProperty extends IDSFacet {
27218
28039
  (name) => name.endsWith("Value") || name.endsWith("Values")
27219
28040
  );
27220
28041
  }
27221
- async getPsetProps(model, attrs, propsListName) {
27222
- const attrsClone = structuredClone(attrs);
28042
+ async simplifyPset(model, attrs, propsListName) {
28043
+ var _a;
27223
28044
  const props = [];
27224
- const list = attrsClone[propsListName];
28045
+ const list = attrs[propsListName];
27225
28046
  if (!list)
27226
- return props;
28047
+ return attrs;
27227
28048
  for (const { value } of list) {
27228
28049
  const propAttrs = await model.getProperties(value);
27229
28050
  if (propAttrs)
27230
28051
  props.push(propAttrs);
27231
28052
  }
27232
- attrsClone[propsListName] = props;
28053
+ const attrsClone = {
28054
+ Name: (_a = attrs.Name) == null ? void 0 : _a.value,
28055
+ Properties: props,
28056
+ type: attrs.type
28057
+ };
27233
28058
  return attrsClone;
27234
28059
  }
27235
28060
  async getTypePsets(model, expressID) {
@@ -27247,13 +28072,14 @@ class IDSProperty extends IDSFacet {
27247
28072
  if (!(psetAttrs && "HasProperties" in psetAttrs && Array.isArray(psetAttrs.HasProperties))) {
27248
28073
  continue;
27249
28074
  }
27250
- const pset = await this.getPsetProps(model, psetAttrs, "HasProperties");
28075
+ const pset = await this.simplifyPset(model, psetAttrs, "HasProperties");
27251
28076
  sets.push(pset);
27252
28077
  }
27253
28078
  return sets;
27254
28079
  }
27255
28080
  async getPsets(model, expressID) {
27256
- const sets = await this.getTypePsets(model, expressID);
28081
+ var _a;
28082
+ const typePsets = await this.getTypePsets(model, expressID);
27257
28083
  const indexer = this.components.get(IfcRelationsIndexer);
27258
28084
  const definitions = indexer.getEntityRelations(
27259
28085
  model,
@@ -27261,7 +28087,8 @@ class IDSProperty extends IDSFacet {
27261
28087
  "IsDefinedBy"
27262
28088
  );
27263
28089
  if (!definitions)
27264
- return sets;
28090
+ return typePsets;
28091
+ const sets = [];
27265
28092
  for (const definitionID of definitions) {
27266
28093
  const attrs = await model.getProperties(definitionID);
27267
28094
  if (!attrs)
@@ -27269,8 +28096,25 @@ class IDSProperty extends IDSFacet {
27269
28096
  const propsListName = this.getItemsAttrName(attrs.type);
27270
28097
  if (!propsListName)
27271
28098
  continue;
27272
- const pset = await this.getPsetProps(model, attrs, propsListName);
27273
- sets.push(pset);
28099
+ const occurencePset = await this.simplifyPset(
28100
+ model,
28101
+ attrs,
28102
+ propsListName
28103
+ );
28104
+ const typePset = typePsets.find(
28105
+ ({ Name }) => Name === occurencePset.Name
28106
+ );
28107
+ if (typePset) {
28108
+ for (const prop of typePset.Properties) {
28109
+ const name = (_a = prop.Name) == null ? void 0 : _a.value;
28110
+ const existingProp = occurencePset.Properties.find(
28111
+ ({ Name }) => Name.value === name
28112
+ );
28113
+ if (!existingProp)
28114
+ occurencePset.Properties.push(prop);
28115
+ }
28116
+ }
28117
+ sets.push(occurencePset);
27274
28118
  }
27275
28119
  return sets;
27276
28120
  }
@@ -27802,6 +28646,7 @@ export {
27802
28646
  ProjectionManager,
27803
28647
  PropertiesStreamingSettings,
27804
28648
  Raycasters,
28649
+ SectionGenerator,
27805
28650
  ShadowedScene,
27806
28651
  SimpleCamera,
27807
28652
  SimpleGrid,