@thatopen/components 2.4.8 → 2.4.10

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, 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";
8
+ import { BufferAttribute, Vector3, Vector2, Plane, Line3, Triangle, Sphere, Matrix4, Box3, BackSide, DoubleSide, FrontSide, Mesh, Ray, Raycaster, Quaternion, Controls, Euler, Object3D, 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";
@@ -4002,6 +4002,9 @@ const _plane = new Plane();
4002
4002
  const _closestPoint = new Vector3();
4003
4003
  const _triangle = new Triangle();
4004
4004
  class ConvexHull {
4005
+ /**
4006
+ * Constructs a new convex hull.
4007
+ */
4005
4008
  constructor() {
4006
4009
  this.tolerance = -1;
4007
4010
  this.faces = [];
@@ -4010,16 +4013,29 @@ class ConvexHull {
4010
4013
  this.unassigned = new VertexList();
4011
4014
  this.vertices = [];
4012
4015
  }
4016
+ /**
4017
+ * Computes to convex hull for the given array of points.
4018
+ *
4019
+ * @param {Array<Vector3>} points - The array of points in 3D space.
4020
+ * @return {ConvexHull} A reference to this convex hull.
4021
+ */
4013
4022
  setFromPoints(points) {
4014
4023
  if (points.length >= 4) {
4015
4024
  this.makeEmpty();
4016
4025
  for (let i = 0, l = points.length; i < l; i++) {
4017
4026
  this.vertices.push(new VertexNode(points[i]));
4018
4027
  }
4019
- this.compute();
4028
+ this._compute();
4020
4029
  }
4021
4030
  return this;
4022
4031
  }
4032
+ /**
4033
+ * Computes the convex hull of the given 3D object (including its descendants),
4034
+ * accounting for the world transforms of both the 3D object and its descendants.
4035
+ *
4036
+ * @param {Object3D} object - The 3D object to compute the convex hull for.
4037
+ * @return {ConvexHull} A reference to this convex hull.
4038
+ */
4023
4039
  setFromObject(object) {
4024
4040
  const points = [];
4025
4041
  object.updateMatrixWorld(true);
@@ -4038,6 +4054,12 @@ class ConvexHull {
4038
4054
  });
4039
4055
  return this.setFromPoints(points);
4040
4056
  }
4057
+ /**
4058
+ * Returns `true` if the given point lies in the convex hull.
4059
+ *
4060
+ * @param {Vector3} point - The point to test.
4061
+ * @return {boolean} Whether the given point lies in the convex hull or not.
4062
+ */
4041
4063
  containsPoint(point) {
4042
4064
  const faces = this.faces;
4043
4065
  for (let i = 0, l = faces.length; i < l; i++) {
@@ -4047,6 +4069,13 @@ class ConvexHull {
4047
4069
  }
4048
4070
  return true;
4049
4071
  }
4072
+ /**
4073
+ * Computes the intersections point of the given ray and this convex hull.
4074
+ *
4075
+ * @param {Ray} ray - The ray to test.
4076
+ * @param {Vector3} target - The target vector that is used to store the method's result.
4077
+ * @return {Vector3|null} The intersection point. Returns `null` if not intersection was detected.
4078
+ */
4050
4079
  intersectRay(ray2, target) {
4051
4080
  const faces = this.faces;
4052
4081
  let tNear = -Infinity;
@@ -4076,16 +4105,35 @@ class ConvexHull {
4076
4105
  }
4077
4106
  return target;
4078
4107
  }
4108
+ /**
4109
+ * Returns `true` if the given ray intersects with this convex hull.
4110
+ *
4111
+ * @param {Ray} ray - The ray to test.
4112
+ * @return {boolean} Whether the given ray intersects with this convex hull or not.
4113
+ */
4079
4114
  intersectsRay(ray2) {
4080
4115
  return this.intersectRay(ray2, _v1$1) !== null;
4081
4116
  }
4117
+ /**
4118
+ * Makes the convex hull empty.
4119
+ *
4120
+ * @return {ConvexHull} A reference to this convex hull.
4121
+ */
4082
4122
  makeEmpty() {
4083
4123
  this.faces = [];
4084
4124
  this.vertices = [];
4085
4125
  return this;
4086
4126
  }
4087
- // Adds a vertex to the 'assigned' list of vertices and assigns it to the given face
4088
- addVertexToFace(vertex, face) {
4127
+ // private
4128
+ /**
4129
+ * Adds a vertex to the 'assigned' list of vertices and assigns it to the given face.
4130
+ *
4131
+ * @private
4132
+ * @param {VertexNode} vertex - The vertex to add.
4133
+ * @param {Face} face - The target face.
4134
+ * @return {ConvexHull} A reference to this convex hull.
4135
+ */
4136
+ _addVertexToFace(vertex, face) {
4089
4137
  vertex.face = face;
4090
4138
  if (face.outside === null) {
4091
4139
  this.assigned.append(vertex);
@@ -4095,8 +4143,17 @@ class ConvexHull {
4095
4143
  face.outside = vertex;
4096
4144
  return this;
4097
4145
  }
4098
- // Removes a vertex from the 'assigned' list of vertices and from the given face
4099
- removeVertexFromFace(vertex, face) {
4146
+ /**
4147
+ * Removes a vertex from the 'assigned' list of vertices and from the given face.
4148
+ * It also makes sure that the link from 'face' to the first vertex it sees in 'assigned'
4149
+ * is linked correctly after the removal.
4150
+ *
4151
+ * @private
4152
+ * @param {VertexNode} vertex - The vertex to remove.
4153
+ * @param {Face} face - The target face.
4154
+ * @return {ConvexHull} A reference to this convex hull.
4155
+ */
4156
+ _removeVertexFromFace(vertex, face) {
4100
4157
  if (vertex === face.outside) {
4101
4158
  if (vertex.next !== null && vertex.next.face === face) {
4102
4159
  face.outside = vertex.next;
@@ -4107,8 +4164,15 @@ class ConvexHull {
4107
4164
  this.assigned.remove(vertex);
4108
4165
  return this;
4109
4166
  }
4110
- // Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertex list
4111
- removeAllVerticesFromFace(face) {
4167
+ /**
4168
+ * Removes all the visible vertices that a given face is able to see which are stored in
4169
+ * the 'assigned' vertex list.
4170
+ *
4171
+ * @private
4172
+ * @param {Face} face - The target face.
4173
+ * @return {VertexNode|undefined} A reference to this convex hull.
4174
+ */
4175
+ _removeAllVerticesFromFace(face) {
4112
4176
  if (face.outside !== null) {
4113
4177
  const start = face.outside;
4114
4178
  let end = face.outside;
@@ -4121,9 +4185,20 @@ class ConvexHull {
4121
4185
  return start;
4122
4186
  }
4123
4187
  }
4124
- // Removes all the visible vertices that 'face' is able to see
4125
- deleteFaceVertices(face, absorbingFace) {
4126
- const faceVertices = this.removeAllVerticesFromFace(face);
4188
+ /**
4189
+ * Removes all the visible vertices that `face` is able to see.
4190
+ *
4191
+ * - If `absorbingFace` doesn't exist, then all the removed vertices will be added to the 'unassigned' vertex list.
4192
+ * - If `absorbingFace` exists, then this method will assign all the vertices of 'face' that can see 'absorbingFace'.
4193
+ * - If a vertex cannot see `absorbingFace`, it's added to the 'unassigned' vertex list.
4194
+ *
4195
+ * @private
4196
+ * @param {Face} face - The given face.
4197
+ * @param {Face} [absorbingFace] - An optional face that tries to absorb the vertices of the first face.
4198
+ * @return {ConvexHull} A reference to this convex hull.
4199
+ */
4200
+ _deleteFaceVertices(face, absorbingFace) {
4201
+ const faceVertices = this._removeAllVerticesFromFace(face);
4127
4202
  if (faceVertices !== void 0) {
4128
4203
  if (absorbingFace === void 0) {
4129
4204
  this.unassigned.appendChain(faceVertices);
@@ -4133,7 +4208,7 @@ class ConvexHull {
4133
4208
  const nextVertex = vertex.next;
4134
4209
  const distance = absorbingFace.distanceToPoint(vertex.point);
4135
4210
  if (distance > this.tolerance) {
4136
- this.addVertexToFace(vertex, absorbingFace);
4211
+ this._addVertexToFace(vertex, absorbingFace);
4137
4212
  } else {
4138
4213
  this.unassigned.append(vertex);
4139
4214
  }
@@ -4143,8 +4218,14 @@ class ConvexHull {
4143
4218
  }
4144
4219
  return this;
4145
4220
  }
4146
- // Reassigns as many vertices as possible from the unassigned list to the new faces
4147
- resolveUnassignedPoints(newFaces) {
4221
+ /**
4222
+ * Reassigns as many vertices as possible from the unassigned list to the new faces.
4223
+ *
4224
+ * @private
4225
+ * @param {Array<Face>} newFaces - The new faces.
4226
+ * @return {ConvexHull} A reference to this convex hull.
4227
+ */
4228
+ _resolveUnassignedPoints(newFaces) {
4148
4229
  if (this.unassigned.isEmpty() === false) {
4149
4230
  let vertex = this.unassigned.first();
4150
4231
  do {
@@ -4164,15 +4245,21 @@ class ConvexHull {
4164
4245
  }
4165
4246
  }
4166
4247
  if (maxFace !== null) {
4167
- this.addVertexToFace(vertex, maxFace);
4248
+ this._addVertexToFace(vertex, maxFace);
4168
4249
  }
4169
4250
  vertex = nextVertex;
4170
4251
  } while (vertex !== null);
4171
4252
  }
4172
4253
  return this;
4173
4254
  }
4174
- // Computes the extremes of a simplex which will be the initial hull
4175
- computeExtremes() {
4255
+ /**
4256
+ * Computes the extremes values (min/max vectors) which will be used to
4257
+ * compute the initial hull.
4258
+ *
4259
+ * @private
4260
+ * @return {Object} The extremes.
4261
+ */
4262
+ _computeExtremes() {
4176
4263
  const min = new Vector3();
4177
4264
  const max = new Vector3();
4178
4265
  const minVertices = [];
@@ -4201,11 +4288,16 @@ class ConvexHull {
4201
4288
  this.tolerance = 3 * Number.EPSILON * (Math.max(Math.abs(min.x), Math.abs(max.x)) + Math.max(Math.abs(min.y), Math.abs(max.y)) + Math.max(Math.abs(min.z), Math.abs(max.z)));
4202
4289
  return { min: minVertices, max: maxVertices };
4203
4290
  }
4204
- // Computes the initial simplex assigning to its faces all the points
4205
- // that are candidates to form part of the hull
4206
- computeInitialHull() {
4291
+ /**
4292
+ * Computes the initial simplex assigning to its faces all the points that are
4293
+ * candidates to form part of the hull.
4294
+ *
4295
+ * @private
4296
+ * @return {ConvexHull} A reference to this convex hull.
4297
+ */
4298
+ _computeInitialHull() {
4207
4299
  const vertices = this.vertices;
4208
- const extremes = this.computeExtremes();
4300
+ const extremes = this._computeExtremes();
4209
4301
  const min = extremes.min;
4210
4302
  const max = extremes.max;
4211
4303
  let maxDistance = 0;
@@ -4288,14 +4380,19 @@ class ConvexHull {
4288
4380
  }
4289
4381
  }
4290
4382
  if (maxFace !== null) {
4291
- this.addVertexToFace(vertex, maxFace);
4383
+ this._addVertexToFace(vertex, maxFace);
4292
4384
  }
4293
4385
  }
4294
4386
  }
4295
4387
  return this;
4296
4388
  }
4297
- // Removes inactive faces
4298
- reindexFaces() {
4389
+ /**
4390
+ * Removes inactive (e.g. deleted) faces from the internal face list.
4391
+ *
4392
+ * @private
4393
+ * @return {ConvexHull} A reference to this convex hull.
4394
+ */
4395
+ _reindexFaces() {
4299
4396
  const activeFaces = [];
4300
4397
  for (let i = 0; i < this.faces.length; i++) {
4301
4398
  const face = this.faces[i];
@@ -4306,8 +4403,17 @@ class ConvexHull {
4306
4403
  this.faces = activeFaces;
4307
4404
  return this;
4308
4405
  }
4309
- // Finds the next vertex to create faces with the current hull
4310
- nextVertexToAdd() {
4406
+ /**
4407
+ * Finds the next vertex to create faces with the current hull.
4408
+ *
4409
+ * - Let the initial face be the first face existing in the 'assigned' vertex list.
4410
+ * - If a face doesn't exist then return since there're no vertices left.
4411
+ * - Otherwise for each vertex that face sees find the one furthest away from it.
4412
+ *
4413
+ * @private
4414
+ * @return {?VertexNode} The next vertex to add.
4415
+ */
4416
+ _nextVertexToAdd() {
4311
4417
  if (this.assigned.isEmpty() === false) {
4312
4418
  let eyeVertex, maxDistance = 0;
4313
4419
  const eyeFace = this.assigned.first().face;
@@ -4323,11 +4429,20 @@ class ConvexHull {
4323
4429
  return eyeVertex;
4324
4430
  }
4325
4431
  }
4326
- // Computes a chain of half edges in CCW order called the 'horizon'.
4327
- // For an edge to be part of the horizon it must join a face that can see
4328
- // 'eyePoint' and a face that cannot see 'eyePoint'.
4329
- computeHorizon(eyePoint, crossEdge, face, horizon) {
4330
- this.deleteFaceVertices(face);
4432
+ /**
4433
+ * Computes a chain of half edges in CCW order called the 'horizon'. For an edge
4434
+ * to be part of the horizon it must join a face that can see 'eyePoint' and a face
4435
+ * that cannot see 'eyePoint'.
4436
+ *
4437
+ * @private
4438
+ * @param {Vector3} eyePoint - The 3D-coordinates of a point.
4439
+ * @param {HalfEdge} crossEdge - The edge used to jump to the current face.
4440
+ * @param {Face} face - The current face being tested.
4441
+ * @param {Array<HalfEdge>} horizon - The edges that form part of the horizon in CCW order.
4442
+ * @return {ConvexHull} A reference to this convex hull.
4443
+ */
4444
+ _computeHorizon(eyePoint, crossEdge, face, horizon) {
4445
+ this._deleteFaceVertices(face);
4331
4446
  face.mark = Deleted;
4332
4447
  let edge;
4333
4448
  if (crossEdge === null) {
@@ -4340,7 +4455,7 @@ class ConvexHull {
4340
4455
  const oppositeFace = twinEdge.face;
4341
4456
  if (oppositeFace.mark === Visible) {
4342
4457
  if (oppositeFace.distanceToPoint(eyePoint) > this.tolerance) {
4343
- this.computeHorizon(eyePoint, twinEdge, oppositeFace, horizon);
4458
+ this._computeHorizon(eyePoint, twinEdge, oppositeFace, horizon);
4344
4459
  } else {
4345
4460
  horizon.push(edge);
4346
4461
  }
@@ -4349,22 +4464,38 @@ class ConvexHull {
4349
4464
  } while (edge !== crossEdge);
4350
4465
  return this;
4351
4466
  }
4352
- // Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order
4353
- addAdjoiningFace(eyeVertex, horizonEdge) {
4467
+ /**
4468
+ * Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head'
4469
+ * in CCW order. All the half edges are created in CCW order thus the face is always pointing
4470
+ * outside the hull.
4471
+ *
4472
+ * @private
4473
+ * @param {VertexNode} eyeVertex - The vertex that is added to the hull.
4474
+ * @param {HalfEdge} horizonEdge - A single edge of the horizon.
4475
+ * @return {HalfEdge} The half edge whose vertex is the eyeVertex.
4476
+ */
4477
+ _addAdjoiningFace(eyeVertex, horizonEdge) {
4354
4478
  const face = Face.create(eyeVertex, horizonEdge.tail(), horizonEdge.head());
4355
4479
  this.faces.push(face);
4356
4480
  face.getEdge(-1).setTwin(horizonEdge.twin);
4357
4481
  return face.getEdge(0);
4358
4482
  }
4359
- // Adds 'horizon.length' faces to the hull, each face will be linked with the
4360
- // horizon opposite face and the face on the left/right
4361
- addNewFaces(eyeVertex, horizon) {
4483
+ /**
4484
+ * Adds 'horizon.length' faces to the hull, each face will be linked with the horizon
4485
+ * opposite face and the face on the left/right.
4486
+ *
4487
+ * @private
4488
+ * @param {VertexNode} eyeVertex - The vertex that is added to the hull.
4489
+ * @param {Array<HalfEdge>} horizon - The horizon.
4490
+ * @return {ConvexHull} A reference to this convex hull.
4491
+ */
4492
+ _addNewFaces(eyeVertex, horizon) {
4362
4493
  this.newFaces = [];
4363
4494
  let firstSideEdge = null;
4364
4495
  let previousSideEdge = null;
4365
4496
  for (let i = 0; i < horizon.length; i++) {
4366
4497
  const horizonEdge = horizon[i];
4367
- const sideEdge = this.addAdjoiningFace(eyeVertex, horizonEdge);
4498
+ const sideEdge = this._addAdjoiningFace(eyeVertex, horizonEdge);
4368
4499
  if (firstSideEdge === null) {
4369
4500
  firstSideEdge = sideEdge;
4370
4501
  } else {
@@ -4376,34 +4507,62 @@ class ConvexHull {
4376
4507
  firstSideEdge.next.setTwin(previousSideEdge);
4377
4508
  return this;
4378
4509
  }
4379
- // Adds a vertex to the hull
4380
- addVertexToHull(eyeVertex) {
4510
+ /**
4511
+ * Adds a vertex to the hull with the following algorithm:
4512
+ *
4513
+ * - Compute the 'horizon' which is a chain of half edges. For an edge to belong to this group
4514
+ * it must be the edge connecting a face that can see 'eyeVertex' and a face which cannot see 'eyeVertex'.
4515
+ * - All the faces that can see 'eyeVertex' have its visible vertices removed from the assigned vertex list.
4516
+ * - A new set of faces is created with each edge of the 'horizon' and 'eyeVertex'. Each face is connected
4517
+ * with the opposite horizon face and the face on the left/right.
4518
+ * - The vertices removed from all the visible faces are assigned to the new faces if possible.
4519
+ *
4520
+ * @private
4521
+ * @param {VertexNode} eyeVertex - The vertex to add.
4522
+ * @return {ConvexHull} A reference to this convex hull.
4523
+ */
4524
+ _addVertexToHull(eyeVertex) {
4381
4525
  const horizon = [];
4382
4526
  this.unassigned.clear();
4383
- this.removeVertexFromFace(eyeVertex, eyeVertex.face);
4384
- this.computeHorizon(eyeVertex.point, null, eyeVertex.face, horizon);
4385
- this.addNewFaces(eyeVertex, horizon);
4386
- this.resolveUnassignedPoints(this.newFaces);
4527
+ this._removeVertexFromFace(eyeVertex, eyeVertex.face);
4528
+ this._computeHorizon(eyeVertex.point, null, eyeVertex.face, horizon);
4529
+ this._addNewFaces(eyeVertex, horizon);
4530
+ this._resolveUnassignedPoints(this.newFaces);
4387
4531
  return this;
4388
4532
  }
4389
- cleanup() {
4533
+ /**
4534
+ * Cleans up internal properties after computing the convex hull.
4535
+ *
4536
+ * @private
4537
+ * @return {ConvexHull} A reference to this convex hull.
4538
+ */
4539
+ _cleanup() {
4390
4540
  this.assigned.clear();
4391
4541
  this.unassigned.clear();
4392
4542
  this.newFaces = [];
4393
4543
  return this;
4394
4544
  }
4395
- compute() {
4545
+ /**
4546
+ * Starts the execution of the quick hull algorithm.
4547
+ *
4548
+ * @private
4549
+ * @return {ConvexHull} A reference to this convex hull.
4550
+ */
4551
+ _compute() {
4396
4552
  let vertex;
4397
- this.computeInitialHull();
4398
- while ((vertex = this.nextVertexToAdd()) !== void 0) {
4399
- this.addVertexToHull(vertex);
4553
+ this._computeInitialHull();
4554
+ while ((vertex = this._nextVertexToAdd()) !== void 0) {
4555
+ this._addVertexToHull(vertex);
4400
4556
  }
4401
- this.reindexFaces();
4402
- this.cleanup();
4557
+ this._reindexFaces();
4558
+ this._cleanup();
4403
4559
  return this;
4404
4560
  }
4405
4561
  }
4406
4562
  class Face {
4563
+ /**
4564
+ * Constructs a new face.
4565
+ */
4407
4566
  constructor() {
4408
4567
  this.normal = new Vector3();
4409
4568
  this.midpoint = new Vector3();
@@ -4413,6 +4572,15 @@ class Face {
4413
4572
  this.mark = Visible;
4414
4573
  this.edge = null;
4415
4574
  }
4575
+ /**
4576
+ * Creates a face from the given vertex nodes.
4577
+ *
4578
+ * @private
4579
+ * @param {VertexNode} a - The first vertex node.
4580
+ * @param {VertexNode} b - The second vertex node.
4581
+ * @param {VertexNode} c - The third vertex node.
4582
+ * @return {Face} The created face.
4583
+ */
4416
4584
  static create(a, b, c) {
4417
4585
  const face = new Face();
4418
4586
  const e0 = new HalfEdge(a, face);
@@ -4424,6 +4592,13 @@ class Face {
4424
4592
  face.edge = e0;
4425
4593
  return face.compute();
4426
4594
  }
4595
+ /**
4596
+ * Returns an edge by the given index.
4597
+ *
4598
+ * @private
4599
+ * @param {number} i - The edge index.
4600
+ * @return {HalfEdge} The edge.
4601
+ */
4427
4602
  getEdge(i) {
4428
4603
  let edge = this.edge;
4429
4604
  while (i > 0) {
@@ -4436,6 +4611,12 @@ class Face {
4436
4611
  }
4437
4612
  return edge;
4438
4613
  }
4614
+ /**
4615
+ * Computes all properties of the face.
4616
+ *
4617
+ * @private
4618
+ * @return {Face} A reference to this face.
4619
+ */
4439
4620
  compute() {
4440
4621
  const a = this.edge.tail();
4441
4622
  const b = this.edge.head();
@@ -4447,11 +4628,24 @@ class Face {
4447
4628
  this.constant = this.normal.dot(this.midpoint);
4448
4629
  return this;
4449
4630
  }
4631
+ /**
4632
+ * Returns the signed distance from a given point to the plane representation of this face.
4633
+ *
4634
+ * @private
4635
+ * @param {Vector3} point - The point to compute the distance to.
4636
+ * @return {number} The distance.
4637
+ */
4450
4638
  distanceToPoint(point) {
4451
4639
  return this.normal.dot(point) - this.constant;
4452
4640
  }
4453
4641
  }
4454
4642
  class HalfEdge {
4643
+ /**
4644
+ * Constructs a new half edge.
4645
+ *
4646
+ * @param {VertexNode} vertex - A reference to its destination vertex.
4647
+ * @param {Face} face - A reference to its face.
4648
+ */
4455
4649
  constructor(vertex, face) {
4456
4650
  this.vertex = vertex;
4457
4651
  this.prev = null;
@@ -4459,12 +4653,30 @@ class HalfEdge {
4459
4653
  this.twin = null;
4460
4654
  this.face = face;
4461
4655
  }
4656
+ /**
4657
+ * Returns the destination vertex.
4658
+ *
4659
+ * @private
4660
+ * @return {VertexNode} The destination vertex.
4661
+ */
4462
4662
  head() {
4463
4663
  return this.vertex;
4464
4664
  }
4665
+ /**
4666
+ * Returns the origin vertex.
4667
+ *
4668
+ * @private
4669
+ * @return {VertexNode} The destination vertex.
4670
+ */
4465
4671
  tail() {
4466
4672
  return this.prev ? this.prev.vertex : null;
4467
4673
  }
4674
+ /**
4675
+ * Returns the Euclidean length (straight-line length) of the edge.
4676
+ *
4677
+ * @private
4678
+ * @return {number} The edge's length.
4679
+ */
4468
4680
  length() {
4469
4681
  const head = this.head();
4470
4682
  const tail = this.tail();
@@ -4473,6 +4685,12 @@ class HalfEdge {
4473
4685
  }
4474
4686
  return -1;
4475
4687
  }
4688
+ /**
4689
+ * Returns the square of the Euclidean length (straight-line length) of the edge.
4690
+ *
4691
+ * @private
4692
+ * @return {number} The square of the edge's length.
4693
+ */
4476
4694
  lengthSquared() {
4477
4695
  const head = this.head();
4478
4696
  const tail = this.tail();
@@ -4481,6 +4699,14 @@ class HalfEdge {
4481
4699
  }
4482
4700
  return -1;
4483
4701
  }
4702
+ /**
4703
+ * Sets the twin edge of this half-edge. It also ensures that the twin reference
4704
+ * of the given half-edge is correctly set.
4705
+ *
4706
+ * @private
4707
+ * @param {HalfEdge} edge - The twin edge to set.
4708
+ * @return {HalfEdge} A reference to this edge.
4709
+ */
4484
4710
  setTwin(edge) {
4485
4711
  this.twin = edge;
4486
4712
  edge.twin = this;
@@ -4488,6 +4714,11 @@ class HalfEdge {
4488
4714
  }
4489
4715
  }
4490
4716
  class VertexNode {
4717
+ /**
4718
+ * Constructs a new vertex node.
4719
+ *
4720
+ * @param {Vector3} point - A point in 3D space.
4721
+ */
4491
4722
  constructor(point) {
4492
4723
  this.point = point;
4493
4724
  this.prev = null;
@@ -4496,21 +4727,49 @@ class VertexNode {
4496
4727
  }
4497
4728
  }
4498
4729
  class VertexList {
4730
+ /**
4731
+ * Constructs a new vertex list.
4732
+ */
4499
4733
  constructor() {
4500
4734
  this.head = null;
4501
4735
  this.tail = null;
4502
4736
  }
4737
+ /**
4738
+ * Returns the head reference.
4739
+ *
4740
+ * @private
4741
+ * @return {VertexNode} The head reference.
4742
+ */
4503
4743
  first() {
4504
4744
  return this.head;
4505
4745
  }
4746
+ /**
4747
+ * Returns the tail reference.
4748
+ *
4749
+ * @private
4750
+ * @return {VertexNode} The tail reference.
4751
+ */
4506
4752
  last() {
4507
4753
  return this.tail;
4508
4754
  }
4755
+ /**
4756
+ * Clears the linked list.
4757
+ *
4758
+ * @private
4759
+ * @return {VertexList} A reference to this vertex list.
4760
+ */
4509
4761
  clear() {
4510
4762
  this.head = this.tail = null;
4511
4763
  return this;
4512
4764
  }
4513
- // Inserts a vertex before the target vertex
4765
+ /**
4766
+ * Inserts a vertex before a target vertex.
4767
+ *
4768
+ * @private
4769
+ * @param {VertexNode} target - The target.
4770
+ * @param {VertexNode} vertex - The vertex to insert.
4771
+ * @return {VertexList} A reference to this vertex list.
4772
+ */
4514
4773
  insertBefore(target, vertex) {
4515
4774
  vertex.prev = target.prev;
4516
4775
  vertex.next = target;
@@ -4522,7 +4781,14 @@ class VertexList {
4522
4781
  target.prev = vertex;
4523
4782
  return this;
4524
4783
  }
4525
- // Inserts a vertex after the target vertex
4784
+ /**
4785
+ * Inserts a vertex after a target vertex.
4786
+ *
4787
+ * @private
4788
+ * @param {VertexNode} target - The target.
4789
+ * @param {VertexNode} vertex - The vertex to insert.
4790
+ * @return {VertexList} A reference to this vertex list.
4791
+ */
4526
4792
  insertAfter(target, vertex) {
4527
4793
  vertex.prev = target;
4528
4794
  vertex.next = target.next;
@@ -4534,7 +4800,13 @@ class VertexList {
4534
4800
  target.next = vertex;
4535
4801
  return this;
4536
4802
  }
4537
- // Appends a vertex to the end of the linked list
4803
+ /**
4804
+ * Appends a vertex to this vertex list.
4805
+ *
4806
+ * @private
4807
+ * @param {VertexNode} vertex - The vertex to append.
4808
+ * @return {VertexList} A reference to this vertex list.
4809
+ */
4538
4810
  append(vertex) {
4539
4811
  if (this.head === null) {
4540
4812
  this.head = vertex;
@@ -4546,7 +4818,13 @@ class VertexList {
4546
4818
  this.tail = vertex;
4547
4819
  return this;
4548
4820
  }
4549
- // Appends a chain of vertices where 'vertex' is the head.
4821
+ /**
4822
+ * Appends a chain of vertices where the given vertex is the head.
4823
+ *
4824
+ * @private
4825
+ * @param {VertexNode} vertex - The head vertex of a chain of vertices.
4826
+ * @return {VertexList} A reference to this vertex list.
4827
+ */
4550
4828
  appendChain(vertex) {
4551
4829
  if (this.head === null) {
4552
4830
  this.head = vertex;
@@ -4560,7 +4838,13 @@ class VertexList {
4560
4838
  this.tail = vertex;
4561
4839
  return this;
4562
4840
  }
4563
- // Removes a vertex from the linked list
4841
+ /**
4842
+ * Removes a vertex from the linked list.
4843
+ *
4844
+ * @private
4845
+ * @param {VertexNode} vertex - The vertex to remove.
4846
+ * @return {VertexList} A reference to this vertex list.
4847
+ */
4564
4848
  remove(vertex) {
4565
4849
  if (vertex.prev === null) {
4566
4850
  this.head = vertex.next;
@@ -4574,7 +4858,14 @@ class VertexList {
4574
4858
  }
4575
4859
  return this;
4576
4860
  }
4577
- // Removes a list of vertices whose 'head' is 'a' and whose 'tail' is b
4861
+ /**
4862
+ * Removes a sublist of vertices from the linked list.
4863
+ *
4864
+ * @private
4865
+ * @param {VertexNode} a - The head of the sublist.
4866
+ * @param {VertexNode} b - The tail of the sublist.
4867
+ * @return {VertexList} A reference to this vertex list.
4868
+ */
4578
4869
  removeSubList(a, b) {
4579
4870
  if (a.prev === null) {
4580
4871
  this.head = b.next;
@@ -4588,6 +4879,12 @@ class VertexList {
4588
4879
  }
4589
4880
  return this;
4590
4881
  }
4882
+ /**
4883
+ * Returns `true` if the linked list is empty.
4884
+ *
4885
+ * @private
4886
+ * @return {boolean} Whether the linked list is empty or not.
4887
+ */
4591
4888
  isEmpty() {
4592
4889
  return this.head === null;
4593
4890
  }
@@ -6293,7 +6590,7 @@ const _Components = class _Components {
6293
6590
  /**
6294
6591
  * The version of the @thatopen/components library.
6295
6592
  */
6296
- __publicField(_Components, "release", "2.4.8");
6593
+ __publicField(_Components, "release", "2.4.10");
6297
6594
  let Components = _Components;
6298
6595
  class SimpleWorld extends Base {
6299
6596
  constructor() {
@@ -6863,20 +7160,24 @@ const ACTION = Object.freeze({
6863
7160
  NONE: 0,
6864
7161
  ROTATE: 1,
6865
7162
  TRUCK: 2,
6866
- OFFSET: 4,
6867
- DOLLY: 8,
6868
- ZOOM: 16,
6869
- TOUCH_ROTATE: 32,
6870
- TOUCH_TRUCK: 64,
6871
- TOUCH_OFFSET: 128,
6872
- TOUCH_DOLLY: 256,
6873
- TOUCH_ZOOM: 512,
6874
- TOUCH_DOLLY_TRUCK: 1024,
6875
- TOUCH_DOLLY_OFFSET: 2048,
6876
- TOUCH_DOLLY_ROTATE: 4096,
6877
- TOUCH_ZOOM_TRUCK: 8192,
6878
- TOUCH_ZOOM_OFFSET: 16384,
6879
- TOUCH_ZOOM_ROTATE: 32768
7163
+ SCREEN_PAN: 4,
7164
+ OFFSET: 8,
7165
+ DOLLY: 16,
7166
+ ZOOM: 32,
7167
+ TOUCH_ROTATE: 64,
7168
+ TOUCH_TRUCK: 128,
7169
+ TOUCH_SCREEN_PAN: 256,
7170
+ TOUCH_OFFSET: 512,
7171
+ TOUCH_DOLLY: 1024,
7172
+ TOUCH_ZOOM: 2048,
7173
+ TOUCH_DOLLY_TRUCK: 4096,
7174
+ TOUCH_DOLLY_SCREEN_PAN: 8192,
7175
+ TOUCH_DOLLY_OFFSET: 16384,
7176
+ TOUCH_DOLLY_ROTATE: 32768,
7177
+ TOUCH_ZOOM_TRUCK: 65536,
7178
+ TOUCH_ZOOM_OFFSET: 131072,
7179
+ TOUCH_ZOOM_SCREEN_PAN: 262144,
7180
+ TOUCH_ZOOM_ROTATE: 524288
6880
7181
  });
6881
7182
  const DOLLY_DIRECTION = {
6882
7183
  NONE: 0,
@@ -7075,11 +7376,10 @@ class EventDispatcher {
7075
7376
  }
7076
7377
  }
7077
7378
  }
7078
- const VERSION = "2.7.3";
7379
+ var _a;
7380
+ const VERSION = "2.10.1";
7079
7381
  const TOUCH_DOLLY_FACTOR = 1 / 8;
7080
- const isBrowser = typeof window !== "undefined";
7081
- const isMac = isBrowser && /Mac/.test(navigator.platform);
7082
- const isPointerEventsNotSupported = !(isBrowser && "PointerEvent" in window);
7382
+ const isMac = /Mac/.test((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.platform);
7083
7383
  let THREE;
7084
7384
  let _ORIGIN;
7085
7385
  let _AXIS_Y;
@@ -7176,6 +7476,12 @@ class CameraControls extends EventDispatcher {
7176
7476
  static get ACTION() {
7177
7477
  return ACTION;
7178
7478
  }
7479
+ /**
7480
+ * @deprecated Use `cameraControls.mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.
7481
+ */
7482
+ set verticalDragToForward(_) {
7483
+ console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.");
7484
+ }
7179
7485
  /**
7180
7486
  * Creates a `CameraControls` instance.
7181
7487
  *
@@ -7214,7 +7520,6 @@ class CameraControls extends EventDispatcher {
7214
7520
  this.truckSpeed = 2;
7215
7521
  this.dollyToCursor = false;
7216
7522
  this.dragToOffset = false;
7217
- this.verticalDragToForward = false;
7218
7523
  this.boundaryFriction = 0;
7219
7524
  this.restThreshold = 0.01;
7220
7525
  this.colliderMeshes = [];
@@ -7247,7 +7552,7 @@ class CameraControls extends EventDispatcher {
7247
7552
  this._targetVelocity = new THREE.Vector3();
7248
7553
  this._focalOffsetVelocity = new THREE.Vector3();
7249
7554
  this._zoomVelocity = { value: 0 };
7250
- this._truckInternal = (deltaX, deltaY, dragToOffset) => {
7555
+ this._truckInternal = (deltaX, deltaY, dragToOffset, screenSpacePanning) => {
7251
7556
  let truckX;
7252
7557
  let pedestalY;
7253
7558
  if (isPerspectiveCamera(this._camera)) {
@@ -7258,12 +7563,12 @@ class CameraControls extends EventDispatcher {
7258
7563
  pedestalY = this.truckSpeed * deltaY * targetDistance / this._elementRect.height;
7259
7564
  } else if (isOrthographicCamera(this._camera)) {
7260
7565
  const camera2 = this._camera;
7261
- truckX = deltaX * (camera2.right - camera2.left) / camera2.zoom / this._elementRect.width;
7262
- pedestalY = deltaY * (camera2.top - camera2.bottom) / camera2.zoom / this._elementRect.height;
7566
+ truckX = this.truckSpeed * deltaX * (camera2.right - camera2.left) / camera2.zoom / this._elementRect.width;
7567
+ pedestalY = this.truckSpeed * deltaY * (camera2.top - camera2.bottom) / camera2.zoom / this._elementRect.height;
7263
7568
  } else {
7264
7569
  return;
7265
7570
  }
7266
- if (this.verticalDragToForward) {
7571
+ if (screenSpacePanning) {
7267
7572
  dragToOffset ? this.setFocalOffset(this._focalOffsetEnd.x + truckX, this._focalOffsetEnd.y, this._focalOffsetEnd.z, true) : this.truck(truckX, 0, true);
7268
7573
  this.forward(-pedestalY, true);
7269
7574
  } else {
@@ -7383,37 +7688,6 @@ class CameraControls extends EventDispatcher {
7383
7688
  this._isDragging = true;
7384
7689
  startDragging(event);
7385
7690
  };
7386
- const onMouseDown = (event) => {
7387
- if (!this._enabled || !this._domElement || this._lockedPointer)
7388
- return;
7389
- if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
7390
- const elRect = this._domElement.getBoundingClientRect();
7391
- const left = event.clientX / elRect.width;
7392
- const top = event.clientY / elRect.height;
7393
- if (left < this._interactiveArea.left || left > this._interactiveArea.right || top < this._interactiveArea.top || top > this._interactiveArea.bottom)
7394
- return;
7395
- }
7396
- const mouseButton = (event.buttons & MOUSE_BUTTON.LEFT) === MOUSE_BUTTON.LEFT ? MOUSE_BUTTON.LEFT : (event.buttons & MOUSE_BUTTON.MIDDLE) === MOUSE_BUTTON.MIDDLE ? MOUSE_BUTTON.MIDDLE : (event.buttons & MOUSE_BUTTON.RIGHT) === MOUSE_BUTTON.RIGHT ? MOUSE_BUTTON.RIGHT : null;
7397
- if (mouseButton !== null) {
7398
- const zombiePointer = this._findPointerByMouseButton(mouseButton);
7399
- zombiePointer && this._disposePointer(zombiePointer);
7400
- }
7401
- const pointer = {
7402
- pointerId: 1,
7403
- clientX: event.clientX,
7404
- clientY: event.clientY,
7405
- deltaX: 0,
7406
- deltaY: 0,
7407
- mouseButton: (event.buttons & MOUSE_BUTTON.LEFT) === MOUSE_BUTTON.LEFT ? MOUSE_BUTTON.LEFT : (event.buttons & MOUSE_BUTTON.MIDDLE) === MOUSE_BUTTON.LEFT ? MOUSE_BUTTON.MIDDLE : (event.buttons & MOUSE_BUTTON.RIGHT) === MOUSE_BUTTON.LEFT ? MOUSE_BUTTON.RIGHT : null
7408
- };
7409
- this._activePointers.push(pointer);
7410
- this._domElement.ownerDocument.removeEventListener("mousemove", onMouseMove);
7411
- this._domElement.ownerDocument.removeEventListener("mouseup", onMouseUp);
7412
- this._domElement.ownerDocument.addEventListener("mousemove", onMouseMove);
7413
- this._domElement.ownerDocument.addEventListener("mouseup", onMouseUp);
7414
- this._isDragging = true;
7415
- startDragging(event);
7416
- };
7417
7691
  const onPointerMove2 = (event) => {
7418
7692
  if (event.cancelable)
7419
7693
  event.preventDefault();
@@ -7451,26 +7725,6 @@ class CameraControls extends EventDispatcher {
7451
7725
  }
7452
7726
  dragging();
7453
7727
  };
7454
- const onMouseMove = (event) => {
7455
- const pointer = this._lockedPointer || this._findPointerById(1);
7456
- if (!pointer)
7457
- return;
7458
- pointer.clientX = event.clientX;
7459
- pointer.clientY = event.clientY;
7460
- pointer.deltaX = event.movementX;
7461
- pointer.deltaY = event.movementY;
7462
- this._state = 0;
7463
- if (this._lockedPointer || (event.buttons & MOUSE_BUTTON.LEFT) === MOUSE_BUTTON.LEFT) {
7464
- this._state = this._state | this.mouseButtons.left;
7465
- }
7466
- if ((event.buttons & MOUSE_BUTTON.MIDDLE) === MOUSE_BUTTON.MIDDLE) {
7467
- this._state = this._state | this.mouseButtons.middle;
7468
- }
7469
- if ((event.buttons & MOUSE_BUTTON.RIGHT) === MOUSE_BUTTON.RIGHT) {
7470
- this._state = this._state | this.mouseButtons.right;
7471
- }
7472
- dragging();
7473
- };
7474
7728
  const onPointerUp2 = (event) => {
7475
7729
  const pointer = this._findPointerById(event.pointerId);
7476
7730
  if (pointer && pointer === this._lockedPointer)
@@ -7496,14 +7750,6 @@ class CameraControls extends EventDispatcher {
7496
7750
  }
7497
7751
  endDragging();
7498
7752
  };
7499
- const onMouseUp = () => {
7500
- const pointer = this._findPointerById(1);
7501
- if (pointer && pointer === this._lockedPointer)
7502
- return;
7503
- pointer && this._disposePointer(pointer);
7504
- this._state = ACTION.NONE;
7505
- endDragging();
7506
- };
7507
7753
  let lastScrollTimeStamp = -1;
7508
7754
  const onMouseWheel = (event) => {
7509
7755
  if (!this._domElement)
@@ -7525,7 +7771,7 @@ class CameraControls extends EventDispatcher {
7525
7771
  lastScrollTimeStamp = now;
7526
7772
  }
7527
7773
  const deltaYFactor = isMac ? -1 : -3;
7528
- const delta = event.deltaMode === 1 ? event.deltaY / deltaYFactor : event.deltaY / (deltaYFactor * 10);
7774
+ const delta = event.deltaMode === 1 || event.ctrlKey ? event.deltaY / deltaYFactor : event.deltaY / (deltaYFactor * 10);
7529
7775
  const x = this.dollyToCursor ? (event.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0;
7530
7776
  const y = this.dollyToCursor ? (event.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
7531
7777
  switch (this.mouseButtons.wheel) {
@@ -7535,12 +7781,17 @@ class CameraControls extends EventDispatcher {
7535
7781
  break;
7536
7782
  }
7537
7783
  case ACTION.TRUCK: {
7538
- this._truckInternal(event.deltaX, event.deltaY, false);
7784
+ this._truckInternal(event.deltaX, event.deltaY, false, false);
7785
+ this._isUserControllingTruck = true;
7786
+ break;
7787
+ }
7788
+ case ACTION.SCREEN_PAN: {
7789
+ this._truckInternal(event.deltaX, event.deltaY, false, true);
7539
7790
  this._isUserControllingTruck = true;
7540
7791
  break;
7541
7792
  }
7542
7793
  case ACTION.OFFSET: {
7543
- this._truckInternal(event.deltaX, event.deltaY, true);
7794
+ this._truckInternal(event.deltaX, event.deltaY, true, false);
7544
7795
  this._isUserControllingOffset = true;
7545
7796
  break;
7546
7797
  }
@@ -7561,13 +7812,11 @@ class CameraControls extends EventDispatcher {
7561
7812
  if (!this._domElement || !this._enabled)
7562
7813
  return;
7563
7814
  if (this.mouseButtons.right === CameraControls.ACTION.NONE) {
7564
- const pointerId = event instanceof PointerEvent ? event.pointerId : event instanceof MouseEvent ? 0 : 0;
7815
+ const pointerId = event instanceof PointerEvent ? event.pointerId : 0;
7565
7816
  const pointer = this._findPointerById(pointerId);
7566
7817
  pointer && this._disposePointer(pointer);
7567
7818
  this._domElement.ownerDocument.removeEventListener("pointermove", onPointerMove2, { passive: false });
7568
7819
  this._domElement.ownerDocument.removeEventListener("pointerup", onPointerUp2);
7569
- this._domElement.ownerDocument.removeEventListener("mousemove", onMouseMove);
7570
- this._domElement.ownerDocument.removeEventListener("mouseup", onMouseUp);
7571
7820
  return;
7572
7821
  }
7573
7822
  event.preventDefault();
@@ -7622,15 +7871,15 @@ class CameraControls extends EventDispatcher {
7622
7871
  this._thetaVelocity.value = 0;
7623
7872
  this._phiVelocity.value = 0;
7624
7873
  }
7625
- if ((this._state & ACTION.TRUCK) === ACTION.TRUCK || (this._state & ACTION.TOUCH_TRUCK) === ACTION.TOUCH_TRUCK || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK) {
7874
+ if ((this._state & ACTION.TRUCK) === ACTION.TRUCK || (this._state & ACTION.SCREEN_PAN) === ACTION.SCREEN_PAN || (this._state & ACTION.TOUCH_TRUCK) === ACTION.TOUCH_TRUCK || (this._state & ACTION.TOUCH_SCREEN_PAN) === ACTION.TOUCH_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_ZOOM_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN) {
7626
7875
  this._targetEnd.copy(this._target);
7627
7876
  this._targetVelocity.set(0, 0, 0);
7628
7877
  }
7629
- if ((this._state & ACTION.DOLLY) === ACTION.DOLLY || (this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE) {
7878
+ if ((this._state & ACTION.DOLLY) === ACTION.DOLLY || (this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE) {
7630
7879
  this._sphericalEnd.radius = this._spherical.radius;
7631
7880
  this._radiusVelocity.value = 0;
7632
7881
  }
7633
- if ((this._state & ACTION.ZOOM) === ACTION.ZOOM || (this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET || (this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE) {
7882
+ if ((this._state & ACTION.ZOOM) === ACTION.ZOOM || (this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_ZOOM_SCREEN_PAN) === ACTION.TOUCH_ZOOM_SCREEN_PAN || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET || (this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE) {
7634
7883
  this._zoomEnd = this._zoom;
7635
7884
  this._zoomVelocity.value = 0;
7636
7885
  }
@@ -7645,7 +7894,7 @@ class CameraControls extends EventDispatcher {
7645
7894
  return;
7646
7895
  this._dragNeedsUpdate = false;
7647
7896
  extractClientCoordFromEvent(this._activePointers, _v2$1);
7648
- const isPointerLockActive = this._domElement && document.pointerLockElement === this._domElement;
7897
+ const isPointerLockActive = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement;
7649
7898
  const lockedPointer = isPointerLockActive ? this._lockedPointer || this._activePointers[0] : null;
7650
7899
  const deltaX = lockedPointer ? -lockedPointer.deltaX : lastDragPosition.x - _v2$1.x;
7651
7900
  const deltaY = lockedPointer ? -lockedPointer.deltaY : lastDragPosition.y - _v2$1.y;
@@ -7666,7 +7915,7 @@ class CameraControls extends EventDispatcher {
7666
7915
  this._isUserControllingZoom = true;
7667
7916
  }
7668
7917
  }
7669
- if ((this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE || (this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE) {
7918
+ if ((this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_ZOOM_SCREEN_PAN) === ACTION.TOUCH_ZOOM_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE || (this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE) {
7670
7919
  const dx = _v2$1.x - this._activePointers[1].clientX;
7671
7920
  const dy = _v2$1.y - this._activePointers[1].clientY;
7672
7921
  const distance = Math.sqrt(dx * dx + dy * dy);
@@ -7674,7 +7923,7 @@ class CameraControls extends EventDispatcher {
7674
7923
  dollyStart.set(0, distance);
7675
7924
  const dollyX = this.dollyToCursor ? (lastDragPosition.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0;
7676
7925
  const dollyY = this.dollyToCursor ? (lastDragPosition.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
7677
- if ((this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET) {
7926
+ if ((this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET) {
7678
7927
  this._dollyInternal(dollyDelta * TOUCH_DOLLY_FACTOR, dollyX, dollyY);
7679
7928
  this._isUserControllingDolly = true;
7680
7929
  } else {
@@ -7683,11 +7932,15 @@ class CameraControls extends EventDispatcher {
7683
7932
  }
7684
7933
  }
7685
7934
  if ((this._state & ACTION.TRUCK) === ACTION.TRUCK || (this._state & ACTION.TOUCH_TRUCK) === ACTION.TOUCH_TRUCK || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK) {
7686
- this._truckInternal(deltaX, deltaY, false);
7935
+ this._truckInternal(deltaX, deltaY, false, false);
7936
+ this._isUserControllingTruck = true;
7937
+ }
7938
+ if ((this._state & ACTION.SCREEN_PAN) === ACTION.SCREEN_PAN || (this._state & ACTION.TOUCH_SCREEN_PAN) === ACTION.TOUCH_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_ZOOM_SCREEN_PAN) === ACTION.TOUCH_ZOOM_SCREEN_PAN) {
7939
+ this._truckInternal(deltaX, deltaY, false, true);
7687
7940
  this._isUserControllingTruck = true;
7688
7941
  }
7689
7942
  if ((this._state & ACTION.OFFSET) === ACTION.OFFSET || (this._state & ACTION.TOUCH_OFFSET) === ACTION.TOUCH_OFFSET || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET) {
7690
- this._truckInternal(deltaX, deltaY, true);
7943
+ this._truckInternal(deltaX, deltaY, true, false);
7691
7944
  this._isUserControllingOffset = true;
7692
7945
  }
7693
7946
  this.dispatchEvent({ type: "control" });
@@ -7701,9 +7954,7 @@ class CameraControls extends EventDispatcher {
7701
7954
  }
7702
7955
  if (this._activePointers.length === 0 && this._domElement) {
7703
7956
  this._domElement.ownerDocument.removeEventListener("pointermove", onPointerMove2, { passive: false });
7704
- this._domElement.ownerDocument.removeEventListener("mousemove", onMouseMove);
7705
7957
  this._domElement.ownerDocument.removeEventListener("pointerup", onPointerUp2);
7706
- this._domElement.ownerDocument.removeEventListener("mouseup", onMouseUp);
7707
7958
  this.dispatchEvent({ type: "controlend" });
7708
7959
  }
7709
7960
  };
@@ -7730,16 +7981,15 @@ class CameraControls extends EventDispatcher {
7730
7981
  startDragging();
7731
7982
  };
7732
7983
  this.unlockPointer = () => {
7984
+ var _a2, _b, _c;
7733
7985
  if (this._lockedPointer !== null) {
7734
7986
  this._disposePointer(this._lockedPointer);
7735
7987
  this._lockedPointer = null;
7736
7988
  }
7737
- document.exitPointerLock();
7989
+ (_a2 = this._domElement) === null || _a2 === void 0 ? void 0 : _a2.ownerDocument.exitPointerLock();
7990
+ (_b = this._domElement) === null || _b === void 0 ? void 0 : _b.ownerDocument.removeEventListener("pointerlockchange", onPointerLockChange);
7991
+ (_c = this._domElement) === null || _c === void 0 ? void 0 : _c.ownerDocument.removeEventListener("pointerlockerror", onPointerLockError);
7738
7992
  this.cancel();
7739
- if (!this._domElement)
7740
- return;
7741
- this._domElement.ownerDocument.removeEventListener("pointerlockchange", onPointerLockChange);
7742
- this._domElement.ownerDocument.removeEventListener("pointerlockerror", onPointerLockError);
7743
7993
  };
7744
7994
  const onPointerLockChange = () => {
7745
7995
  const isPointerLockActive = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement;
@@ -7755,7 +8005,6 @@ class CameraControls extends EventDispatcher {
7755
8005
  this._domElement.style.userSelect = "none";
7756
8006
  this._domElement.style.webkitUserSelect = "none";
7757
8007
  this._domElement.addEventListener("pointerdown", onPointerDown2);
7758
- isPointerEventsNotSupported && this._domElement.addEventListener("mousedown", onMouseDown);
7759
8008
  this._domElement.addEventListener("pointercancel", onPointerUp2);
7760
8009
  this._domElement.addEventListener("wheel", onMouseWheel, { passive: false });
7761
8010
  this._domElement.addEventListener("contextmenu", onContextMenu);
@@ -7767,14 +8016,11 @@ class CameraControls extends EventDispatcher {
7767
8016
  this._domElement.style.userSelect = "";
7768
8017
  this._domElement.style.webkitUserSelect = "";
7769
8018
  this._domElement.removeEventListener("pointerdown", onPointerDown2);
7770
- this._domElement.removeEventListener("mousedown", onMouseDown);
7771
8019
  this._domElement.removeEventListener("pointercancel", onPointerUp2);
7772
8020
  this._domElement.removeEventListener("wheel", onMouseWheel, { passive: false });
7773
8021
  this._domElement.removeEventListener("contextmenu", onContextMenu);
7774
8022
  this._domElement.ownerDocument.removeEventListener("pointermove", onPointerMove2, { passive: false });
7775
- this._domElement.ownerDocument.removeEventListener("mousemove", onMouseMove);
7776
8023
  this._domElement.ownerDocument.removeEventListener("pointerup", onPointerUp2);
7777
- this._domElement.ownerDocument.removeEventListener("mouseup", onMouseUp);
7778
8024
  this._domElement.ownerDocument.removeEventListener("pointerlockchange", onPointerLockChange);
7779
8025
  this._domElement.ownerDocument.removeEventListener("pointerlockerror", onPointerLockError);
7780
8026
  };
@@ -8206,7 +8452,7 @@ class CameraControls extends EventDispatcher {
8206
8452
  lookInDirectionOf(x, y, z, enableTransition = false) {
8207
8453
  const point = _v3A.set(x, y, z);
8208
8454
  const direction = point.sub(this._targetEnd).normalize();
8209
- const position = direction.multiplyScalar(-this._sphericalEnd.radius);
8455
+ const position = direction.multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);
8210
8456
  return this.setPosition(position.x, position.y, position.z, enableTransition);
8211
8457
  }
8212
8458
  /**
@@ -8291,8 +8537,8 @@ class CameraControls extends EventDispatcher {
8291
8537
  */
8292
8538
  fitToSphere(sphereOrMesh, enableTransition) {
8293
8539
  const promises = [];
8294
- const isSphere = sphereOrMesh instanceof THREE.Sphere;
8295
- const boundingSphere = isSphere ? _sphere.copy(sphereOrMesh) : CameraControls.createBoundingSphere(sphereOrMesh, _sphere);
8540
+ const isObject3D = "isObject3D" in sphereOrMesh;
8541
+ const boundingSphere = isObject3D ? CameraControls.createBoundingSphere(sphereOrMesh, _sphere) : _sphere.copy(sphereOrMesh);
8296
8542
  promises.push(this.moveTo(boundingSphere.center.x, boundingSphere.center.y, boundingSphere.center.z, enableTransition));
8297
8543
  if (isPerspectiveCamera(this._camera)) {
8298
8544
  const distanceToFit = this.getDistanceToFitSphere(boundingSphere.radius);
@@ -8545,7 +8791,7 @@ class CameraControls extends EventDispatcher {
8545
8791
  * @category Methods
8546
8792
  */
8547
8793
  getSpherical(out, receiveEndValue = true) {
8548
- const _out = !!out && out instanceof THREE.Spherical ? out : new THREE.Spherical();
8794
+ const _out = out || new THREE.Spherical();
8549
8795
  return _out.copy(receiveEndValue ? this._sphericalEnd : this._spherical);
8550
8796
  }
8551
8797
  /**
@@ -8568,6 +8814,15 @@ class CameraControls extends EventDispatcher {
8568
8814
  this._sphericalEnd.theta += PI_2;
8569
8815
  this._spherical.theta += PI_2 * Math.round((this._sphericalEnd.theta - this._spherical.theta) / PI_2);
8570
8816
  }
8817
+ /**
8818
+ * stop all transitions.
8819
+ */
8820
+ stop() {
8821
+ this._focalOffset.copy(this._focalOffsetEnd);
8822
+ this._target.copy(this._targetEnd);
8823
+ this._spherical.copy(this._sphericalEnd);
8824
+ this._zoom = this._zoomEnd;
8825
+ }
8571
8826
  /**
8572
8827
  * Reset all rotation and position to defaults.
8573
8828
  * @param enableTransition
@@ -8748,7 +9003,6 @@ class CameraControls extends EventDispatcher {
8748
9003
  this._camera.lookAt(this._target);
8749
9004
  const affectOffset = !approxZero(this._focalOffset.x) || !approxZero(this._focalOffset.y) || !approxZero(this._focalOffset.z);
8750
9005
  if (affectOffset) {
8751
- this._camera.updateMatrixWorld();
8752
9006
  _xColumn.setFromMatrixColumn(this._camera.matrix, 0);
8753
9007
  _yColumn.setFromMatrixColumn(this._camera.matrix, 1);
8754
9008
  _zColumn.setFromMatrixColumn(this._camera.matrix, 2);
@@ -8757,6 +9011,7 @@ class CameraControls extends EventDispatcher {
8757
9011
  _zColumn.multiplyScalar(this._focalOffset.z);
8758
9012
  _v3A.copy(_xColumn).add(_yColumn).add(_zColumn);
8759
9013
  this._camera.position.add(_v3A);
9014
+ this._camera.updateMatrixWorld();
8760
9015
  }
8761
9016
  if (this._boundaryEnclosesCamera) {
8762
9017
  this._encloseToBoundary(this._camera.position.copy(this._target), _v3A.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse), 1);
@@ -8801,7 +9056,6 @@ class CameraControls extends EventDispatcher {
8801
9056
  dollySpeed: this.dollySpeed,
8802
9057
  truckSpeed: this.truckSpeed,
8803
9058
  dollyToCursor: this.dollyToCursor,
8804
- verticalDragToForward: this.verticalDragToForward,
8805
9059
  target: this._targetEnd.toArray(),
8806
9060
  position: _v3A.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),
8807
9061
  zoom: this._zoomEnd,
@@ -8834,7 +9088,6 @@ class CameraControls extends EventDispatcher {
8834
9088
  this.dollySpeed = obj.dollySpeed;
8835
9089
  this.truckSpeed = obj.truckSpeed;
8836
9090
  this.dollyToCursor = obj.dollyToCursor;
8837
- this.verticalDragToForward = obj.verticalDragToForward;
8838
9091
  this._target0.fromArray(obj.target0);
8839
9092
  this._position0.fromArray(obj.position0);
8840
9093
  this._zoom0 = obj.zoom0;
@@ -9050,6 +9303,8 @@ class CameraControls extends EventDispatcher {
9050
9303
  if (!object.isMesh)
9051
9304
  return;
9052
9305
  const mesh = object;
9306
+ if (!mesh.geometry)
9307
+ return;
9053
9308
  const geometry = mesh.geometry.clone();
9054
9309
  geometry.applyMatrix4(mesh.matrixWorld);
9055
9310
  const bufferGeometry = geometry;
@@ -9088,14 +9343,14 @@ class SimpleCamera extends BaseCamera {
9088
9343
  * {@link Components.renderer}.
9089
9344
  */
9090
9345
  __publicField(this, "updateAspect", () => {
9091
- var _a;
9346
+ var _a2;
9092
9347
  if (!this.currentWorld || !this.currentWorld.renderer)
9093
9348
  return;
9094
9349
  if (this.three instanceof THREE$1.OrthographicCamera) {
9095
9350
  this.onAspectUpdated.trigger();
9096
9351
  return;
9097
9352
  }
9098
- if ((_a = this.currentWorld.renderer) == null ? void 0 : _a.isResizeable()) {
9353
+ if ((_a2 = this.currentWorld.renderer) == null ? void 0 : _a2.isResizeable()) {
9099
9354
  const size = this.currentWorld.renderer.getSize();
9100
9355
  this.three.aspect = size.width / size.height;
9101
9356
  this.three.updateProjectionMatrix();
@@ -10789,7 +11044,7 @@ class SimpleGrid {
10789
11044
 
10790
11045
  `,
10791
11046
  extensions: {
10792
- derivatives: true
11047
+ // derivatives: true,
10793
11048
  }
10794
11049
  });
10795
11050
  this.three = new THREE$1.Mesh(geometry, material);
@@ -10943,26 +11198,26 @@ const _unit = {
10943
11198
  Z: new Vector3(0, 0, 1)
10944
11199
  };
10945
11200
  const _changeEvent = { type: "change" };
10946
- const _mouseDownEvent = { type: "mouseDown" };
11201
+ const _mouseDownEvent = { type: "mouseDown", mode: null };
10947
11202
  const _mouseUpEvent = { type: "mouseUp", mode: null };
10948
11203
  const _objectChangeEvent = { type: "objectChange" };
10949
- class TransformControls extends Object3D {
10950
- constructor(camera, domElement) {
10951
- super();
10952
- if (domElement === void 0) {
10953
- console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.');
10954
- domElement = document;
10955
- }
10956
- this.isTransformControls = true;
10957
- this.visible = false;
10958
- this.domElement = domElement;
10959
- this.domElement.style.touchAction = "none";
10960
- const _gizmo = new TransformControlsGizmo();
10961
- this._gizmo = _gizmo;
10962
- this.add(_gizmo);
10963
- const _plane2 = new TransformControlsPlane();
10964
- this._plane = _plane2;
10965
- this.add(_plane2);
11204
+ class TransformControls extends Controls {
11205
+ /**
11206
+ * Constructs a new controls instance.
11207
+ *
11208
+ * @param {Camera} camera - The camera of the rendered scene.
11209
+ * @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
11210
+ */
11211
+ constructor(camera, domElement = null) {
11212
+ super(void 0, domElement);
11213
+ const root = new TransformControlsRoot(this);
11214
+ this._root = root;
11215
+ const gizmo = new TransformControlsGizmo();
11216
+ this._gizmo = gizmo;
11217
+ root.add(gizmo);
11218
+ const plane = new TransformControlsPlane();
11219
+ this._plane = plane;
11220
+ root.add(plane);
10966
11221
  const scope = this;
10967
11222
  function defineProperty(propName2, defaultValue) {
10968
11223
  let propValue = defaultValue;
@@ -10973,16 +11228,16 @@ class TransformControls extends Object3D {
10973
11228
  set: function(value) {
10974
11229
  if (propValue !== value) {
10975
11230
  propValue = value;
10976
- _plane2[propName2] = value;
10977
- _gizmo[propName2] = value;
11231
+ plane[propName2] = value;
11232
+ gizmo[propName2] = value;
10978
11233
  scope.dispatchEvent({ type: propName2 + "-changed", value });
10979
11234
  scope.dispatchEvent(_changeEvent);
10980
11235
  }
10981
11236
  }
10982
11237
  });
10983
11238
  scope[propName2] = defaultValue;
10984
- _plane2[propName2] = defaultValue;
10985
- _gizmo[propName2] = defaultValue;
11239
+ plane[propName2] = defaultValue;
11240
+ gizmo[propName2] = defaultValue;
10986
11241
  }
10987
11242
  defineProperty("camera", camera);
10988
11243
  defineProperty("object", void 0);
@@ -10998,6 +11253,12 @@ class TransformControls extends Object3D {
10998
11253
  defineProperty("showX", true);
10999
11254
  defineProperty("showY", true);
11000
11255
  defineProperty("showZ", true);
11256
+ defineProperty("minX", -Infinity);
11257
+ defineProperty("maxX", Infinity);
11258
+ defineProperty("minY", -Infinity);
11259
+ defineProperty("maxY", Infinity);
11260
+ defineProperty("minZ", -Infinity);
11261
+ defineProperty("maxZ", Infinity);
11001
11262
  const worldPosition = new Vector3();
11002
11263
  const worldPositionStart = new Vector3();
11003
11264
  const worldQuaternion = new Quaternion();
@@ -11039,36 +11300,38 @@ class TransformControls extends Object3D {
11039
11300
  this._onPointerHover = onPointerHover.bind(this);
11040
11301
  this._onPointerMove = onPointerMove.bind(this);
11041
11302
  this._onPointerUp = onPointerUp.bind(this);
11303
+ if (domElement !== null) {
11304
+ this.connect(domElement);
11305
+ }
11306
+ }
11307
+ connect(element) {
11308
+ super.connect(element);
11042
11309
  this.domElement.addEventListener("pointerdown", this._onPointerDown);
11043
11310
  this.domElement.addEventListener("pointermove", this._onPointerHover);
11044
11311
  this.domElement.addEventListener("pointerup", this._onPointerUp);
11312
+ this.domElement.style.touchAction = "none";
11045
11313
  }
11046
- // updateMatrixWorld updates key transformation variables
11047
- updateMatrixWorld() {
11048
- if (this.object !== void 0) {
11049
- this.object.updateMatrixWorld();
11050
- if (this.object.parent === null) {
11051
- console.error("TransformControls: The attached 3D object must be a part of the scene graph.");
11052
- } else {
11053
- this.object.parent.matrixWorld.decompose(this._parentPosition, this._parentQuaternion, this._parentScale);
11054
- }
11055
- this.object.matrixWorld.decompose(this.worldPosition, this.worldQuaternion, this._worldScale);
11056
- this._parentQuaternionInv.copy(this._parentQuaternion).invert();
11057
- this._worldQuaternionInv.copy(this.worldQuaternion).invert();
11058
- }
11059
- this.camera.updateMatrixWorld();
11060
- this.camera.matrixWorld.decompose(this.cameraPosition, this.cameraQuaternion, this._cameraScale);
11061
- if (this.camera.isOrthographicCamera) {
11062
- this.camera.getWorldDirection(this.eye).negate();
11063
- } else {
11064
- this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize();
11065
- }
11066
- super.updateMatrixWorld(this);
11314
+ disconnect() {
11315
+ this.domElement.removeEventListener("pointerdown", this._onPointerDown);
11316
+ this.domElement.removeEventListener("pointermove", this._onPointerHover);
11317
+ this.domElement.removeEventListener("pointermove", this._onPointerMove);
11318
+ this.domElement.removeEventListener("pointerup", this._onPointerUp);
11319
+ this.domElement.style.touchAction = "auto";
11320
+ }
11321
+ /**
11322
+ * Returns the visual representation of the controls. Add the helper to your scene to
11323
+ * visually transform the attached 3D object.
11324
+ *
11325
+ * @return {TransformControlsRoot} The helper.
11326
+ */
11327
+ getHelper() {
11328
+ return this._root;
11067
11329
  }
11068
11330
  pointerHover(pointer) {
11069
11331
  if (this.object === void 0 || this.dragging === true)
11070
11332
  return;
11071
- _raycaster.setFromCamera(pointer, this.camera);
11333
+ if (pointer !== null)
11334
+ _raycaster.setFromCamera(pointer, this.camera);
11072
11335
  const intersect = intersectObjectWithRay(this._gizmo.picker[this.mode], _raycaster);
11073
11336
  if (intersect) {
11074
11337
  this.axis = intersect.object.name;
@@ -11077,10 +11340,11 @@ class TransformControls extends Object3D {
11077
11340
  }
11078
11341
  }
11079
11342
  pointerDown(pointer) {
11080
- if (this.object === void 0 || this.dragging === true || pointer.button !== 0)
11343
+ if (this.object === void 0 || this.dragging === true || pointer != null && pointer.button !== 0)
11081
11344
  return;
11082
11345
  if (this.axis !== null) {
11083
- _raycaster.setFromCamera(pointer, this.camera);
11346
+ if (pointer !== null)
11347
+ _raycaster.setFromCamera(pointer, this.camera);
11084
11348
  const planeIntersect = intersectObjectWithRay(this._plane, _raycaster, true);
11085
11349
  if (planeIntersect) {
11086
11350
  this.object.updateMatrixWorld();
@@ -11106,9 +11370,10 @@ class TransformControls extends Object3D {
11106
11370
  } else if (axis === "E" || axis === "XYZE" || axis === "XYZ") {
11107
11371
  space = "world";
11108
11372
  }
11109
- if (object === void 0 || axis === null || this.dragging === false || pointer.button !== -1)
11373
+ if (object === void 0 || axis === null || this.dragging === false || pointer !== null && pointer.button !== -1)
11110
11374
  return;
11111
- _raycaster.setFromCamera(pointer, this.camera);
11375
+ if (pointer !== null)
11376
+ _raycaster.setFromCamera(pointer, this.camera);
11112
11377
  const planeIntersect = intersectObjectWithRay(this._plane, _raycaster, true);
11113
11378
  if (!planeIntersect)
11114
11379
  return;
@@ -11162,6 +11427,9 @@ class TransformControls extends Object3D {
11162
11427
  }
11163
11428
  }
11164
11429
  }
11430
+ object.position.x = Math.max(this.minX, Math.min(this.maxX, object.position.x));
11431
+ object.position.y = Math.max(this.minY, Math.min(this.maxY, object.position.y));
11432
+ object.position.z = Math.max(this.minZ, Math.min(this.maxZ, object.position.z));
11165
11433
  } else if (mode === "scale") {
11166
11434
  if (axis.search("XYZ") !== -1) {
11167
11435
  let d = this.pointEnd.length() / this.pointStart.length();
@@ -11238,7 +11506,7 @@ class TransformControls extends Object3D {
11238
11506
  this.dispatchEvent(_objectChangeEvent);
11239
11507
  }
11240
11508
  pointerUp(pointer) {
11241
- if (pointer.button !== 0)
11509
+ if (pointer !== null && pointer.button !== 0)
11242
11510
  return;
11243
11511
  if (this.dragging && this.axis !== null) {
11244
11512
  _mouseUpEvent.mode = this.mode;
@@ -11248,30 +11516,34 @@ class TransformControls extends Object3D {
11248
11516
  this.axis = null;
11249
11517
  }
11250
11518
  dispose() {
11251
- this.domElement.removeEventListener("pointerdown", this._onPointerDown);
11252
- this.domElement.removeEventListener("pointermove", this._onPointerHover);
11253
- this.domElement.removeEventListener("pointermove", this._onPointerMove);
11254
- this.domElement.removeEventListener("pointerup", this._onPointerUp);
11255
- this.traverse(function(child) {
11256
- if (child.geometry)
11257
- child.geometry.dispose();
11258
- if (child.material)
11259
- child.material.dispose();
11260
- });
11519
+ this.disconnect();
11520
+ this._root.dispose();
11261
11521
  }
11262
- // Set current object
11522
+ /**
11523
+ * Sets the 3D object that should be transformed and ensures the controls UI is visible.
11524
+ *
11525
+ * @param {Object3D} object - The 3D object that should be transformed.
11526
+ * @return {TransformControls} A reference to this controls.
11527
+ */
11263
11528
  attach(object) {
11264
11529
  this.object = object;
11265
- this.visible = true;
11530
+ this._root.visible = true;
11266
11531
  return this;
11267
11532
  }
11268
- // Detach from object
11533
+ /**
11534
+ * Removes the current 3D object from the controls and makes the helper UI invisible.
11535
+ *
11536
+ * @return {TransformControls} A reference to this controls.
11537
+ */
11269
11538
  detach() {
11270
11539
  this.object = void 0;
11271
- this.visible = false;
11272
11540
  this.axis = null;
11541
+ this._root.visible = false;
11273
11542
  return this;
11274
11543
  }
11544
+ /**
11545
+ * Resets the object's position, rotation and scale to when the current transform began.
11546
+ */
11275
11547
  reset() {
11276
11548
  if (!this.enabled)
11277
11549
  return;
@@ -11284,28 +11556,68 @@ class TransformControls extends Object3D {
11284
11556
  this.pointStart.copy(this.pointEnd);
11285
11557
  }
11286
11558
  }
11559
+ /**
11560
+ * Returns the raycaster that is used for user interaction. This object is shared between all
11561
+ * instances of `TransformControls`.
11562
+ *
11563
+ * @returns {Raycaster} The internal raycaster.
11564
+ */
11287
11565
  getRaycaster() {
11288
11566
  return _raycaster;
11289
11567
  }
11290
- // TODO: deprecate
11568
+ /**
11569
+ * Returns the transformation mode.
11570
+ *
11571
+ * @returns {'translate'|'rotate'|'scale'} The transformation mode.
11572
+ */
11291
11573
  getMode() {
11292
11574
  return this.mode;
11293
11575
  }
11576
+ /**
11577
+ * Sets the given transformation mode.
11578
+ *
11579
+ * @param {'translate'|'rotate'|'scale'} mode - The transformation mode to set.
11580
+ */
11294
11581
  setMode(mode) {
11295
11582
  this.mode = mode;
11296
11583
  }
11584
+ /**
11585
+ * Sets the translation snap.
11586
+ *
11587
+ * @param {?number} translationSnap - The translation snap to set.
11588
+ */
11297
11589
  setTranslationSnap(translationSnap) {
11298
11590
  this.translationSnap = translationSnap;
11299
11591
  }
11592
+ /**
11593
+ * Sets the rotation snap.
11594
+ *
11595
+ * @param {?number} rotationSnap - The rotation snap to set.
11596
+ */
11300
11597
  setRotationSnap(rotationSnap) {
11301
11598
  this.rotationSnap = rotationSnap;
11302
11599
  }
11600
+ /**
11601
+ * Sets the scale snap.
11602
+ *
11603
+ * @param {?number} scaleSnap - The scale snap to set.
11604
+ */
11303
11605
  setScaleSnap(scaleSnap) {
11304
11606
  this.scaleSnap = scaleSnap;
11305
11607
  }
11608
+ /**
11609
+ * Sets the size of the helper UI.
11610
+ *
11611
+ * @param {number} size - The size to set.
11612
+ */
11306
11613
  setSize(size) {
11307
11614
  this.size = size;
11308
11615
  }
11616
+ /**
11617
+ * Sets the coordinate space in which transformations are applied.
11618
+ *
11619
+ * @param {'world'|'local'} space - The space to set.
11620
+ */
11309
11621
  setSpace(space) {
11310
11622
  this.space = space;
11311
11623
  }
@@ -11381,6 +11693,45 @@ const _unitZ = new Vector3(0, 0, 1);
11381
11693
  const _v1 = new Vector3();
11382
11694
  const _v2 = new Vector3();
11383
11695
  const _v3 = new Vector3();
11696
+ class TransformControlsRoot extends Object3D {
11697
+ constructor(controls) {
11698
+ super();
11699
+ this.isTransformControlsRoot = true;
11700
+ this.controls = controls;
11701
+ this.visible = false;
11702
+ }
11703
+ // updateMatrixWorld updates key transformation variables
11704
+ updateMatrixWorld(force) {
11705
+ const controls = this.controls;
11706
+ if (controls.object !== void 0) {
11707
+ controls.object.updateMatrixWorld();
11708
+ if (controls.object.parent === null) {
11709
+ console.error("TransformControls: The attached 3D object must be a part of the scene graph.");
11710
+ } else {
11711
+ controls.object.parent.matrixWorld.decompose(controls._parentPosition, controls._parentQuaternion, controls._parentScale);
11712
+ }
11713
+ controls.object.matrixWorld.decompose(controls.worldPosition, controls.worldQuaternion, controls._worldScale);
11714
+ controls._parentQuaternionInv.copy(controls._parentQuaternion).invert();
11715
+ controls._worldQuaternionInv.copy(controls.worldQuaternion).invert();
11716
+ }
11717
+ controls.camera.updateMatrixWorld();
11718
+ controls.camera.matrixWorld.decompose(controls.cameraPosition, controls.cameraQuaternion, controls._cameraScale);
11719
+ if (controls.camera.isOrthographicCamera) {
11720
+ controls.camera.getWorldDirection(controls.eye).negate();
11721
+ } else {
11722
+ controls.eye.copy(controls.cameraPosition).sub(controls.worldPosition).normalize();
11723
+ }
11724
+ super.updateMatrixWorld(force);
11725
+ }
11726
+ dispose() {
11727
+ this.traverse(function(child) {
11728
+ if (child.geometry)
11729
+ child.geometry.dispose();
11730
+ if (child.material)
11731
+ child.material.dispose();
11732
+ });
11733
+ }
11734
+ }
11384
11735
  class TransformControlsGizmo extends Object3D {
11385
11736
  constructor() {
11386
11737
  super();
@@ -12006,7 +12357,7 @@ class SimplePlane {
12006
12357
  /** {@link Hideable.visible } */
12007
12358
  set visible(state) {
12008
12359
  this._visible = state;
12009
- this._controls.visible = state;
12360
+ this._controls.object.visible = state;
12010
12361
  this._helper.visible = state;
12011
12362
  this.toggleControls(state);
12012
12363
  }
@@ -12073,7 +12424,7 @@ class SimplePlane {
12073
12424
  this._arrowBoundBox.removeFromParent();
12074
12425
  this._arrowBoundBox.geometry.dispose();
12075
12426
  this._planeMesh.geometry.dispose();
12076
- this._controls.removeFromParent();
12427
+ this._controls.object.removeFromParent();
12077
12428
  this._controls.dispose();
12078
12429
  this.onDisposed.trigger();
12079
12430
  this.onDisposed.reset();
@@ -12109,7 +12460,7 @@ class SimplePlane {
12109
12460
  const container = this.world.renderer.three.domElement;
12110
12461
  const controls = new TransformControls(camera, container);
12111
12462
  this.initializeControls(controls);
12112
- this.world.scene.three.add(controls);
12463
+ this.world.scene.three.add(controls.object);
12113
12464
  return controls;
12114
12465
  }
12115
12466
  initializeControls(controls) {
@@ -12118,7 +12469,7 @@ class SimplePlane {
12118
12469
  controls.showY = false;
12119
12470
  controls.setSpace("local");
12120
12471
  this.createArrowBoundingBox();
12121
- controls.children[0].children[0].add(this._arrowBoundBox);
12472
+ controls.object.children[0].children[0].add(this._arrowBoundBox);
12122
12473
  }
12123
12474
  createArrowBoundingBox() {
12124
12475
  this._arrowBoundBox.geometry = new THREE$1.CylinderGeometry(0.18, 0.18, 1.2);
@@ -12476,12 +12827,12 @@ const _Clipper = class _Clipper extends Component {
12476
12827
  return meshes;
12477
12828
  }
12478
12829
  createPlaneFromIntersection(world, intersect) {
12479
- var _a;
12830
+ var _a2;
12480
12831
  if (!world.renderer) {
12481
12832
  throw new Error("The given world must have a renderer!");
12482
12833
  }
12483
12834
  const constant = intersect.point.distanceTo(new THREE$1.Vector3(0, 0, 0));
12484
- const normal = (_a = intersect.face) == null ? void 0 : _a.normal;
12835
+ const normal = (_a2 = intersect.face) == null ? void 0 : _a2.normal;
12485
12836
  if (!constant || !normal) {
12486
12837
  return null;
12487
12838
  }
@@ -14389,7 +14740,7 @@ const IfcCategoryMap = {
14389
14740
  };
14390
14741
  class IfcPropertiesUtils {
14391
14742
  static async getUnits(group) {
14392
- var _a, _b, _c;
14743
+ var _a2, _b, _c;
14393
14744
  const { IFCUNITASSIGNMENT } = WEBIFC;
14394
14745
  const allUnitsSets = await group.getAllPropertiesOfType(IFCUNITASSIGNMENT);
14395
14746
  if (!allUnitsSets) {
@@ -14415,7 +14766,7 @@ class IfcPropertiesUtils {
14415
14766
  if (unit.Name.value === "FOOT") {
14416
14767
  unitValue = 0.3048;
14417
14768
  }
14418
- if (((_a = unit.Prefix) == null ? void 0 : _a.value) === "MILLI") {
14769
+ if (((_a2 = unit.Prefix) == null ? void 0 : _a2.value) === "MILLI") {
14419
14770
  factor = 1e-3;
14420
14771
  } else if (((_b = unit.Prefix) == null ? void 0 : _b.value) === "CENTI") {
14421
14772
  factor = 0.01;
@@ -14427,18 +14778,18 @@ class IfcPropertiesUtils {
14427
14778
  return 1;
14428
14779
  }
14429
14780
  static async findItemByGuid(model, guid) {
14430
- var _a;
14781
+ var _a2;
14431
14782
  const ids = model.getAllPropertiesIDs();
14432
14783
  for (const id of ids) {
14433
14784
  const property = await model.getProperties(id);
14434
- if (property && ((_a = property.GlobalId) == null ? void 0 : _a.value) === guid) {
14785
+ if (property && ((_a2 = property.GlobalId) == null ? void 0 : _a2.value) === guid) {
14435
14786
  return property;
14436
14787
  }
14437
14788
  }
14438
14789
  return null;
14439
14790
  }
14440
14791
  static async getRelationMap(model, relationType, onElementsFound) {
14441
- var _a;
14792
+ var _a2;
14442
14793
  const defaultCallback = async () => {
14443
14794
  };
14444
14795
  const _onElementsFound = onElementsFound ?? defaultCallback;
@@ -14458,7 +14809,7 @@ class IfcPropertiesUtils {
14458
14809
  );
14459
14810
  if (!(isRelation && relatingKey && relatedKey))
14460
14811
  continue;
14461
- const relating = await model.getProperties((_a = prop[relatingKey]) == null ? void 0 : _a.value);
14812
+ const relating = await model.getProperties((_a2 = prop[relatingKey]) == null ? void 0 : _a2.value);
14462
14813
  const related = prop[relatedKey];
14463
14814
  if (!relating || !related) {
14464
14815
  continue;
@@ -14506,7 +14857,7 @@ class IfcPropertiesUtils {
14506
14857
  return props.filter((prop) => prop !== null);
14507
14858
  }
14508
14859
  static async getPsetRel(model, psetID) {
14509
- var _a;
14860
+ var _a2;
14510
14861
  const prop = await model.getProperties(psetID);
14511
14862
  if (!prop) {
14512
14863
  return null;
@@ -14520,7 +14871,7 @@ class IfcPropertiesUtils {
14520
14871
  const allRels = Object.values(allPropsRels);
14521
14872
  let found = null;
14522
14873
  for (const rel of allRels) {
14523
- if (((_a = rel.RelatingPropertyDefinition) == null ? void 0 : _a.value) === psetID) {
14874
+ if (((_a2 = rel.RelatingPropertyDefinition) == null ? void 0 : _a2.value) === psetID) {
14524
14875
  found = rel.expressID;
14525
14876
  }
14526
14877
  }
@@ -14530,13 +14881,13 @@ class IfcPropertiesUtils {
14530
14881
  return IfcPropertiesUtils.getPsetRel(model, qsetID);
14531
14882
  }
14532
14883
  static async getEntityName(model, entityID) {
14533
- var _a;
14884
+ var _a2;
14534
14885
  const entity = await model.getProperties(entityID);
14535
14886
  if (!entity) {
14536
14887
  return { key: null, name: null };
14537
14888
  }
14538
14889
  const key = Object.keys(entity).find((key2) => key2.endsWith("Name")) ?? null;
14539
- const name = key ? (_a = entity[key]) == null ? void 0 : _a.value : null;
14890
+ const name = key ? (_a2 = entity[key]) == null ? void 0 : _a2.value : null;
14540
14891
  return { key, name };
14541
14892
  }
14542
14893
  static async getQuantityValue(model, quantityID) {
@@ -14567,7 +14918,7 @@ class IfcPropertiesUtils {
14567
14918
  return Object.keys(entity).includes(attribute);
14568
14919
  }
14569
14920
  static async groupEntitiesByType(model, expressIDs) {
14570
- var _a;
14921
+ var _a2;
14571
14922
  const categoriesMap = /* @__PURE__ */ new Map();
14572
14923
  for (const expressID of expressIDs) {
14573
14924
  const entity = await model.getProperties(expressID);
@@ -14578,7 +14929,7 @@ class IfcPropertiesUtils {
14578
14929
  const set = categoriesMap.get(key);
14579
14930
  if (!set)
14580
14931
  categoriesMap.set(key, /* @__PURE__ */ new Set());
14581
- (_a = categoriesMap.get(key)) == null ? void 0 : _a.add(expressID);
14932
+ (_a2 = categoriesMap.get(key)) == null ? void 0 : _a2.add(expressID);
14582
14933
  }
14583
14934
  return categoriesMap;
14584
14935
  }
@@ -15753,7 +16104,7 @@ class Units {
15753
16104
  matrix.copy(result);
15754
16105
  }
15755
16106
  setUp(webIfc) {
15756
- var _a, _b, _c;
16107
+ var _a2, _b, _c;
15757
16108
  this.factor = 1;
15758
16109
  const length = this.getLengthUnits(webIfc);
15759
16110
  if (!length) {
@@ -15767,7 +16118,7 @@ class Units {
15767
16118
  if (length.Name.value === "FOOT") {
15768
16119
  this.factor = 0.3048;
15769
16120
  }
15770
- if (((_a = length.Prefix) == null ? void 0 : _a.value) === "MILLI") {
16121
+ if (((_a2 = length.Prefix) == null ? void 0 : _a2.value) === "MILLI") {
15771
16122
  this.complement = 1e-3;
15772
16123
  } else if (((_b = length.Prefix) == null ? void 0 : _b.value) === "CENTI") {
15773
16124
  this.complement = 0.01;
@@ -16025,7 +16376,7 @@ class CivilReader {
16025
16376
  }
16026
16377
  class IfcMetadataReader {
16027
16378
  getNameInfo(webIfc) {
16028
- var _a;
16379
+ var _a2;
16029
16380
  const data = {};
16030
16381
  const { arguments: dataArguments } = webIfc.GetHeaderLine(0, WEBIFC.FILE_NAME) || {};
16031
16382
  if (!dataArguments)
@@ -16051,7 +16402,7 @@ class IfcMetadataReader {
16051
16402
  if (authorEmail == null ? void 0 : authorEmail.value)
16052
16403
  data.author.email = authorEmail.value;
16053
16404
  }
16054
- if (organization && ((_a = organization[0]) == null ? void 0 : _a.value)) {
16405
+ if (organization && ((_a2 = organization[0]) == null ? void 0 : _a2.value)) {
16055
16406
  data.organization = organization[0].value;
16056
16407
  }
16057
16408
  if (preprocessorVersion == null ? void 0 : preprocessorVersion.value) {
@@ -16066,13 +16417,13 @@ class IfcMetadataReader {
16066
16417
  return data;
16067
16418
  }
16068
16419
  getDescriptionInfo(webIfc) {
16069
- var _a;
16420
+ var _a2;
16070
16421
  const data = {};
16071
16422
  const { arguments: dataArguments } = webIfc.GetHeaderLine(0, WEBIFC.FILE_DESCRIPTION) || {};
16072
16423
  if (!dataArguments)
16073
16424
  return data;
16074
16425
  const [description, implementationLevel] = dataArguments;
16075
- if (Array.isArray(description) && ((_a = description[0]) == null ? void 0 : _a.value)) {
16426
+ if (Array.isArray(description) && ((_a2 = description[0]) == null ? void 0 : _a2.value)) {
16076
16427
  const viewDefinition = description[0].value.match(/\[([^\]]+)\]/);
16077
16428
  if (viewDefinition && viewDefinition[1]) {
16078
16429
  data.viewDefinition = viewDefinition[1];
@@ -22303,12 +22654,12 @@ class Comment {
22303
22654
  * @param value - The new comment text.
22304
22655
  */
22305
22656
  set comment(value) {
22306
- var _a;
22657
+ var _a2;
22307
22658
  const manager = this._components.get(BCFTopics);
22308
22659
  this._comment = value;
22309
22660
  this.modifiedDate = /* @__PURE__ */ new Date();
22310
22661
  this.modifiedAuthor = manager.config.author;
22311
- (_a = this.topic) == null ? void 0 : _a.comments.set(this.guid, this);
22662
+ (_a2 = this.topic) == null ? void 0 : _a2.comments.set(this.guid, this);
22312
22663
  }
22313
22664
  /**
22314
22665
  * Gets the comment text.
@@ -23191,12 +23542,12 @@ ${users}
23191
23542
  return comment;
23192
23543
  }
23193
23544
  getMarkupComments(markup, version) {
23194
- var _a;
23545
+ var _a2;
23195
23546
  let data;
23196
23547
  if (version === "2.1")
23197
23548
  data = markup.Comment;
23198
23549
  if (version === "3")
23199
- data = (_a = markup.Topic.Comments) == null ? void 0 : _a.Comment;
23550
+ data = (_a2 = markup.Topic.Comments) == null ? void 0 : _a2.Comment;
23200
23551
  if (!data)
23201
23552
  return [];
23202
23553
  data = Array.isArray(data) ? data : [data];
@@ -23205,36 +23556,36 @@ ${users}
23205
23556
  return array;
23206
23557
  }
23207
23558
  getMarkupLabels(markup, version) {
23208
- var _a;
23559
+ var _a2;
23209
23560
  let data;
23210
23561
  if (version === "2.1")
23211
23562
  data = markup.Topic.Labels;
23212
23563
  if (version === "3")
23213
- data = (_a = markup.Topic.Labels) == null ? void 0 : _a.Label;
23564
+ data = (_a2 = markup.Topic.Labels) == null ? void 0 : _a2.Label;
23214
23565
  if (!data)
23215
23566
  return [];
23216
23567
  const labels = Array.isArray(data) ? data : [data];
23217
23568
  return labels;
23218
23569
  }
23219
23570
  getMarkupViewpoints(markup, version) {
23220
- var _a;
23571
+ var _a2;
23221
23572
  let data;
23222
23573
  if (version === "2.1")
23223
23574
  data = markup.Viewpoints;
23224
23575
  if (version === "3")
23225
- data = (_a = markup.Topic.Viewpoints) == null ? void 0 : _a.ViewPoint;
23576
+ data = (_a2 = markup.Topic.Viewpoints) == null ? void 0 : _a2.ViewPoint;
23226
23577
  if (!data)
23227
23578
  return [];
23228
23579
  data = Array.isArray(data) ? data : [data];
23229
23580
  return data;
23230
23581
  }
23231
23582
  getMarkupRelatedTopics(markup, version) {
23232
- var _a;
23583
+ var _a2;
23233
23584
  let data;
23234
23585
  if (version === "2.1")
23235
23586
  data = markup.Topic.RelatedTopic;
23236
23587
  if (version === "3")
23237
- data = (_a = markup.Topic.RelatedTopics) == null ? void 0 : _a.RelatedTopic;
23588
+ data = (_a2 = markup.Topic.RelatedTopics) == null ? void 0 : _a2.RelatedTopic;
23238
23589
  if (!data)
23239
23590
  return [];
23240
23591
  const topics = Array.isArray(data) ? data : [data];
@@ -23251,7 +23602,7 @@ ${users}
23251
23602
  * @throws An error if the BCF version is not supported.
23252
23603
  */
23253
23604
  async load(data, world) {
23254
- var _a;
23605
+ var _a2;
23255
23606
  const {
23256
23607
  fallbackVersionOnImport,
23257
23608
  ignoreIncompleteTopicsOnImport,
@@ -23316,7 +23667,7 @@ ${users}
23316
23667
  ViewSetupHints = Components2.ViewSetupHints;
23317
23668
  }
23318
23669
  if (version === "3") {
23319
- ViewSetupHints = (_a = Components2.Visibility) == null ? void 0 : _a.ViewSetupHints;
23670
+ ViewSetupHints = (_a2 = Components2.Visibility) == null ? void 0 : _a2.ViewSetupHints;
23320
23671
  }
23321
23672
  if (ViewSetupHints) {
23322
23673
  if ("OpeningsVisible" in ViewSetupHints) {
@@ -24788,7 +25139,7 @@ const _Classifier = class _Classifier extends Component {
24788
25139
  * @throws Will throw an error if the fragment ID is not found.
24789
25140
  */
24790
25141
  async byPredefinedType(group) {
24791
- var _a;
25142
+ var _a2;
24792
25143
  if (!this.list.predefinedTypes) {
24793
25144
  this.list.predefinedTypes = {};
24794
25145
  }
@@ -24798,7 +25149,7 @@ const _Classifier = class _Classifier extends Component {
24798
25149
  const entity = await group.getProperties(id);
24799
25150
  if (!entity)
24800
25151
  continue;
24801
- const predefinedType = String((_a = entity.PredefinedType) == null ? void 0 : _a.value).toUpperCase();
25152
+ const predefinedType = String((_a2 = entity.PredefinedType) == null ? void 0 : _a2.value).toUpperCase();
24802
25153
  if (!currentTypes[predefinedType]) {
24803
25154
  currentTypes[predefinedType] = {
24804
25155
  map: {},
@@ -24901,7 +25252,7 @@ const _Classifier = class _Classifier extends Component {
24901
25252
  * @throws Will throw an error if the fragment ID is not found or if the model relations do not exist.
24902
25253
  */
24903
25254
  async bySpatialStructure(model, config = {}) {
24904
- var _a, _b;
25255
+ var _a2, _b;
24905
25256
  const indexer = this.components.get(IfcRelationsIndexer);
24906
25257
  const modelRelations = indexer.relationMaps[model.uuid];
24907
25258
  if (!modelRelations) {
@@ -24935,7 +25286,7 @@ const _Classifier = class _Classifier extends Component {
24935
25286
  if (!spatialRelAttrs) {
24936
25287
  continue;
24937
25288
  }
24938
- relName2 = (_a = spatialRelAttrs.Name) == null ? void 0 : _a.value;
25289
+ relName2 = (_a2 = spatialRelAttrs.Name) == null ? void 0 : _a2.value;
24939
25290
  }
24940
25291
  this.saveItem(model, systemName, relName2, expressID, id);
24941
25292
  }
@@ -26200,7 +26551,7 @@ class Viewpoint {
26200
26551
  }
26201
26552
  }
26202
26553
  async createComponentTags(from) {
26203
- var _a, _b;
26554
+ var _a2, _b;
26204
26555
  const fragments = this._components.get(FragmentsManager);
26205
26556
  const manager = this._components.get(BCFTopics);
26206
26557
  let tags = "";
@@ -26215,7 +26566,7 @@ class Viewpoint {
26215
26566
  const attrs = await model.getProperties(expressID);
26216
26567
  if (!attrs)
26217
26568
  continue;
26218
- const globalID = (_a = attrs.GlobalId) == null ? void 0 : _a.value;
26569
+ const globalID = (_a2 = attrs.GlobalId) == null ? void 0 : _a2.value;
26219
26570
  if (!globalID)
26220
26571
  continue;
26221
26572
  const tag = (_b = attrs.Tag) == null ? void 0 : _b.value;
@@ -27388,14 +27739,14 @@ class IDSAttribute extends IDSFacet {
27388
27739
  // All invalid cases have been treated as failures
27389
27740
  // FragmentsGroup do not hold some of the entities used in the tests
27390
27741
  async test(entities) {
27391
- var _a;
27742
+ var _a2;
27392
27743
  this.testResult = [];
27393
27744
  for (const _expressID in entities) {
27394
27745
  const expressID = Number(_expressID);
27395
27746
  const attrs = entities[expressID];
27396
27747
  const checks = [];
27397
27748
  const result2 = {
27398
- guid: (_a = attrs.GlobalId) == null ? void 0 : _a.value,
27749
+ guid: (_a2 = attrs.GlobalId) == null ? void 0 : _a2.value,
27399
27750
  expressID,
27400
27751
  pass: false,
27401
27752
  checks,
@@ -27489,7 +27840,7 @@ class IDSClassification extends IDSFacet {
27489
27840
  </classification>`;
27490
27841
  }
27491
27842
  async getEntities(model, collector = {}) {
27492
- var _a;
27843
+ var _a2;
27493
27844
  const result = [];
27494
27845
  const references = await model.getAllPropertiesOfType(
27495
27846
  WEBIFC.IFCCLASSIFICATIONREFERENCE
@@ -27504,7 +27855,7 @@ class IDSClassification extends IDSFacet {
27504
27855
  const attrs = await model.getProperties(classificationID);
27505
27856
  if (!attrs)
27506
27857
  continue;
27507
- const referencedSourceID = (_a = attrs.ReferencedSource) == null ? void 0 : _a.value;
27858
+ const referencedSourceID = (_a2 = attrs.ReferencedSource) == null ? void 0 : _a2.value;
27508
27859
  if (!referencedSourceID)
27509
27860
  continue;
27510
27861
  const classificationAttrs = await model.getProperties(referencedSourceID);
@@ -27541,14 +27892,14 @@ class IDSClassification extends IDSFacet {
27541
27892
  return result;
27542
27893
  }
27543
27894
  async test(entities, model) {
27544
- var _a;
27895
+ var _a2;
27545
27896
  this.testResult = [];
27546
27897
  for (const _expressID in entities) {
27547
27898
  const expressID = Number(_expressID);
27548
27899
  const attrs = entities[expressID];
27549
27900
  const checks = [];
27550
27901
  const result2 = {
27551
- guid: (_a = attrs.GlobalId) == null ? void 0 : _a.value,
27902
+ guid: (_a2 = attrs.GlobalId) == null ? void 0 : _a2.value,
27552
27903
  expressID,
27553
27904
  pass: false,
27554
27905
  checks,
@@ -27591,8 +27942,8 @@ class IDSClassification extends IDSFacet {
27591
27942
  return result;
27592
27943
  }
27593
27944
  async processReferencedSource(model, attrs) {
27594
- var _a;
27595
- const sourceID = (_a = attrs.ReferencedSource) == null ? void 0 : _a.value;
27945
+ var _a2;
27946
+ const sourceID = (_a2 = attrs.ReferencedSource) == null ? void 0 : _a2.value;
27596
27947
  if (!sourceID)
27597
27948
  return null;
27598
27949
  const sourceAttrs = await model.getProperties(sourceID);
@@ -27607,7 +27958,7 @@ class IDSClassification extends IDSFacet {
27607
27958
  return sourceAttrs;
27608
27959
  }
27609
27960
  async getSystems(model, expressID) {
27610
- var _a;
27961
+ var _a2;
27611
27962
  const result = [];
27612
27963
  const indexer = this.components.get(IfcRelationsIndexer);
27613
27964
  const ocurrenceAssociations = indexer.getEntityRelations(
@@ -27634,9 +27985,9 @@ class IDSClassification extends IDSFacet {
27634
27985
  }
27635
27986
  }
27636
27987
  const occurrenceSystems = result.map((attrs) => {
27637
- var _a2, _b, _c;
27988
+ var _a3, _b, _c;
27638
27989
  if (attrs.type === WEBIFC.IFCCLASSIFICATION) {
27639
- return (_a2 = attrs.Name) == null ? void 0 : _a2.value;
27990
+ return (_a3 = attrs.Name) == null ? void 0 : _a3.value;
27640
27991
  }
27641
27992
  if (attrs.type === WEBIFC.IFCCLASSIFICATIONREFERENCE) {
27642
27993
  return (_c = (_b = attrs.ReferencedSource) == null ? void 0 : _b.Name) == null ? void 0 : _c.value;
@@ -27658,7 +28009,7 @@ class IDSClassification extends IDSFacet {
27658
28009
  if (!attrs)
27659
28010
  continue;
27660
28011
  if (attrs.type === WEBIFC.IFCCLASSIFICATION) {
27661
- if (occurrenceSystems.includes((_a = attrs.Name) == null ? void 0 : _a.value))
28012
+ if (occurrenceSystems.includes((_a2 = attrs.Name) == null ? void 0 : _a2.value))
27662
28013
  continue;
27663
28014
  result.push(attrs);
27664
28015
  }
@@ -27675,9 +28026,9 @@ class IDSClassification extends IDSFacet {
27675
28026
  return result;
27676
28027
  }
27677
28028
  getSystemName(attrs) {
27678
- var _a, _b, _c, _d;
28029
+ var _a2, _b, _c, _d;
27679
28030
  if (attrs.type === WEBIFC.IFCCLASSIFICATION) {
27680
- return (_a = attrs.Name) == null ? void 0 : _a.value;
28031
+ return (_a2 = attrs.Name) == null ? void 0 : _a2.value;
27681
28032
  }
27682
28033
  if (attrs.type === WEBIFC.IFCCLASSIFICATIONREFERENCE) {
27683
28034
  if (((_b = attrs.ReferencedSource) == null ? void 0 : _b.type) === WEBIFC.IFCCLASSIFICATIONREFERENCE) {
@@ -27733,11 +28084,11 @@ class IDSClassification extends IDSFacet {
27733
28084
  return !!identifier;
27734
28085
  }
27735
28086
  evalURI(attrs, checks) {
27736
- var _a;
28087
+ var _a2;
27737
28088
  if (!this.uri)
27738
28089
  return true;
27739
28090
  const result = this.evalRequirement(
27740
- (_a = attrs.Location) == null ? void 0 : _a.value,
28091
+ (_a2 = attrs.Location) == null ? void 0 : _a2.value,
27741
28092
  {
27742
28093
  type: "simple",
27743
28094
  parameter: this.uri
@@ -27809,14 +28160,14 @@ class IDSEntity extends IDSFacet {
27809
28160
  return result;
27810
28161
  }
27811
28162
  async test(entities, model) {
27812
- var _a;
28163
+ var _a2;
27813
28164
  this.testResult = [];
27814
28165
  for (const _expressID in entities) {
27815
28166
  const expressID = Number(_expressID);
27816
28167
  const attrs = entities[expressID];
27817
28168
  const checks = [];
27818
28169
  const result = {
27819
- guid: (_a = attrs.GlobalId) == null ? void 0 : _a.value,
28170
+ guid: (_a2 = attrs.GlobalId) == null ? void 0 : _a2.value,
27820
28171
  expressID,
27821
28172
  pass: false,
27822
28173
  checks,
@@ -27835,12 +28186,12 @@ class IDSEntity extends IDSFacet {
27835
28186
  return result;
27836
28187
  }
27837
28188
  async evalPredefinedType(model, attrs, checks) {
27838
- var _a, _b, _c, _d;
28189
+ var _a2, _b, _c, _d;
27839
28190
  if (!this.predefinedType)
27840
28191
  return null;
27841
28192
  const indexer = this.components.get(IfcRelationsIndexer);
27842
28193
  const isRequirementUserDefined = typeof this.predefinedType.parameter === "string" && this.predefinedType.parameter === "USERDEFINED";
27843
- let value = (_a = attrs.PredefinedType) == null ? void 0 : _a.value;
28194
+ let value = (_a2 = attrs.PredefinedType) == null ? void 0 : _a2.value;
27844
28195
  if (value === "USERDEFINED" && !isRequirementUserDefined) {
27845
28196
  const attrNames = Object.keys(attrs);
27846
28197
  const result2 = attrNames.find(
@@ -27912,7 +28263,7 @@ class IDSProperty extends IDSFacet {
27912
28263
  </property>`;
27913
28264
  }
27914
28265
  async getEntities(model, collector = {}) {
27915
- var _a, _b;
28266
+ var _a2, _b;
27916
28267
  let sets = {};
27917
28268
  const psets = await model.getAllPropertiesOfType(WEBIFC.IFCPROPERTYSET);
27918
28269
  sets = { ...sets, ...psets };
@@ -27926,7 +28277,7 @@ class IDSProperty extends IDSFacet {
27926
28277
  const attrs = await model.getProperties(setID);
27927
28278
  if (!attrs)
27928
28279
  continue;
27929
- const nameMatches = ((_a = attrs.Name) == null ? void 0 : _a.value) === this.propertySet.parameter;
28280
+ const nameMatches = ((_a2 = attrs.Name) == null ? void 0 : _a2.value) === this.propertySet.parameter;
27930
28281
  if (!nameMatches)
27931
28282
  continue;
27932
28283
  let propsListName;
@@ -27975,14 +28326,14 @@ class IDSProperty extends IDSFacet {
27975
28326
  return [];
27976
28327
  }
27977
28328
  async test(entities, model) {
27978
- var _a;
28329
+ var _a2;
27979
28330
  this.testResult = [];
27980
28331
  for (const _expressID in entities) {
27981
28332
  const expressID = Number(_expressID);
27982
28333
  const attrs = entities[expressID];
27983
28334
  const checks = [];
27984
28335
  const result2 = {
27985
- guid: (_a = attrs.GlobalId) == null ? void 0 : _a.value,
28336
+ guid: (_a2 = attrs.GlobalId) == null ? void 0 : _a2.value,
27986
28337
  expressID,
27987
28338
  pass: false,
27988
28339
  checks,
@@ -28027,12 +28378,12 @@ class IDSProperty extends IDSFacet {
28027
28378
  }
28028
28379
  const items = set.Properties;
28029
28380
  const matchingItems = items.filter((item) => {
28030
- var _a2;
28381
+ var _a3;
28031
28382
  if (this._unsupportedTypes.includes(item.type)) {
28032
28383
  return false;
28033
28384
  }
28034
28385
  const result3 = this.evalRequirement(
28035
- ((_a2 = item.Name) == null ? void 0 : _a2.value) ?? null,
28386
+ ((_a3 = item.Name) == null ? void 0 : _a3.value) ?? null,
28036
28387
  this.baseName,
28037
28388
  "BaseName"
28038
28389
  );
@@ -28081,7 +28432,7 @@ class IDSProperty extends IDSFacet {
28081
28432
  );
28082
28433
  }
28083
28434
  async simplifyPset(model, attrs, propsListName) {
28084
- var _a;
28435
+ var _a2;
28085
28436
  const props = [];
28086
28437
  const list = attrs[propsListName];
28087
28438
  if (!list)
@@ -28092,7 +28443,7 @@ class IDSProperty extends IDSFacet {
28092
28443
  props.push(propAttrs);
28093
28444
  }
28094
28445
  const attrsClone = {
28095
- Name: (_a = attrs.Name) == null ? void 0 : _a.value,
28446
+ Name: (_a2 = attrs.Name) == null ? void 0 : _a2.value,
28096
28447
  Properties: props,
28097
28448
  type: attrs.type
28098
28449
  };
@@ -28119,7 +28470,7 @@ class IDSProperty extends IDSFacet {
28119
28470
  return sets;
28120
28471
  }
28121
28472
  async getPsets(model, expressID) {
28122
- var _a;
28473
+ var _a2;
28123
28474
  const typePsets = await this.getTypePsets(model, expressID);
28124
28475
  const indexer = this.components.get(IfcRelationsIndexer);
28125
28476
  const definitions = indexer.getEntityRelations(
@@ -28147,7 +28498,7 @@ class IDSProperty extends IDSFacet {
28147
28498
  );
28148
28499
  if (typePset) {
28149
28500
  for (const prop of typePset.Properties) {
28150
- const name = (_a = prop.Name) == null ? void 0 : _a.value;
28501
+ const name = (_a2 = prop.Name) == null ? void 0 : _a2.value;
28151
28502
  const existingProp = occurencePset.Properties.find(
28152
28503
  ({ Name }) => Name.value === name
28153
28504
  );