3dtiles-inspector 0.2.3 → 0.2.5

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.
@@ -45136,10 +45136,10 @@ function createGeoCameraController({
45136
45136
  const right = new Vector3();
45137
45137
  const backward = new Vector3();
45138
45138
  const quaternion = new Quaternion();
45139
- function isCenterModePosition(value) {
45139
+ function isCenterModePosition2(value) {
45140
45140
  return value.lengthSq() <= centerModeDistanceSq;
45141
45141
  }
45142
- function getLocalFrame(referencePoint) {
45142
+ function getLocalFrame2(referencePoint) {
45143
45143
  const ellipsoid = getActiveEllipsoid();
45144
45144
  ellipsoid.getPositionToCartographic(referencePoint, cartographicTarget);
45145
45145
  ellipsoid.getEastNorthUpFrame(
@@ -45186,7 +45186,7 @@ function createGeoCameraController({
45186
45186
  if (referencePoint.lengthSq() < centerModeDistanceSq || !getActiveEllipsoid()) {
45187
45187
  return target.identity();
45188
45188
  }
45189
- getLocalFrame(referencePoint);
45189
+ getLocalFrame2(referencePoint);
45190
45190
  basis.makeBasis(east, north, up);
45191
45191
  return target.setFromRotationMatrix(basis);
45192
45192
  }
@@ -45201,7 +45201,7 @@ function createGeoCameraController({
45201
45201
  );
45202
45202
  return Math.max(radius / Math.sin(limitingHalfFov), 1);
45203
45203
  }
45204
- function getCenterModeHeadingPitchRollForward(heading, pitch) {
45204
+ function getCenterModeHeadingPitchRollForward2(heading, pitch) {
45205
45205
  const cosPitch = Math.cos(pitch);
45206
45206
  forward.set(
45207
45207
  Math.sin(heading) * cosPitch,
@@ -45210,14 +45210,14 @@ function createGeoCameraController({
45210
45210
  );
45211
45211
  return forward.normalize();
45212
45212
  }
45213
- function getHeadingPitchRollForward(referencePoint, heading, pitch) {
45214
- if (isCenterModePosition(referencePoint)) {
45215
- return getCenterModeHeadingPitchRollForward(heading, pitch);
45213
+ function getHeadingPitchRollForward2(referencePoint, heading, pitch) {
45214
+ if (isCenterModePosition2(referencePoint)) {
45215
+ return getCenterModeHeadingPitchRollForward2(heading, pitch);
45216
45216
  }
45217
45217
  if (referencePoint.lengthSq() < 1e-6) {
45218
45218
  return forward.set(0, 0, -1);
45219
45219
  }
45220
- getLocalFrame(referencePoint);
45220
+ getLocalFrame2(referencePoint);
45221
45221
  const cosPitch = Math.cos(pitch);
45222
45222
  const sinPitch = Math.sin(pitch);
45223
45223
  const cosHeading = Math.cos(heading);
@@ -45225,8 +45225,8 @@ function createGeoCameraController({
45225
45225
  forward.copy(north).multiplyScalar(cosHeading * cosPitch).addScaledVector(east, sinHeading * cosPitch).addScaledVector(up, sinPitch).normalize();
45226
45226
  return forward;
45227
45227
  }
45228
- function getCenterModeHeadingPitchRollBasis(heading, pitch, roll) {
45229
- getCenterModeHeadingPitchRollForward(heading, pitch);
45228
+ function getCenterModeHeadingPitchRollBasis2(heading, pitch, roll) {
45229
+ getCenterModeHeadingPitchRollForward2(heading, pitch);
45230
45230
  right.copy(WORLD_RIGHT).multiplyScalar(Math.cos(heading)).addScaledVector(CENTER_NORTH, -Math.sin(heading)).normalize();
45231
45231
  up.crossVectors(right, forward).normalize();
45232
45232
  if (roll !== 0) {
@@ -45235,14 +45235,14 @@ function createGeoCameraController({
45235
45235
  }
45236
45236
  backward.copy(forward).negate();
45237
45237
  }
45238
- function getHeadingPitchRollQuaternion(referencePoint, heading, pitch, roll) {
45239
- if (isCenterModePosition(referencePoint)) {
45240
- getCenterModeHeadingPitchRollBasis(heading, pitch, roll);
45238
+ function getHeadingPitchRollQuaternion2(referencePoint, heading, pitch, roll) {
45239
+ if (isCenterModePosition2(referencePoint)) {
45240
+ getCenterModeHeadingPitchRollBasis2(heading, pitch, roll);
45241
45241
  } else if (referencePoint.lengthSq() < 1e-6) {
45242
45242
  quaternion.identity();
45243
45243
  return quaternion;
45244
45244
  } else {
45245
- getHeadingPitchRollForward(referencePoint, heading, pitch);
45245
+ getHeadingPitchRollForward2(referencePoint, heading, pitch);
45246
45246
  right.copy(east).multiplyScalar(Math.cos(heading)).addScaledVector(north, -Math.sin(heading)).normalize();
45247
45247
  up.crossVectors(right, forward).normalize();
45248
45248
  if (roll !== 0) {
@@ -45254,7 +45254,7 @@ function createGeoCameraController({
45254
45254
  basis.makeBasis(right, up, backward);
45255
45255
  return quaternion.setFromRotationMatrix(basis);
45256
45256
  }
45257
- function getBoundingSphereFlyToPosition(target, range, options) {
45257
+ function getBoundingSphereFlyToPosition2(target, range, options) {
45258
45258
  const { heading, pitch } = options;
45259
45259
  if (heading === void 0 && pitch === void 0) {
45260
45260
  const direction = target.lengthSq() > 1e-6 ? position.copy(target).normalize() : camera.position.lengthSq() > 1e-6 ? position.copy(camera.position).normalize() : position.set(0, -1, 0);
@@ -45262,15 +45262,15 @@ function createGeoCameraController({
45262
45262
  }
45263
45263
  const resolvedHeading = heading ?? 0;
45264
45264
  const resolvedPitch = pitch ?? -Math.PI / 2;
45265
- const centerForward = getCenterModeHeadingPitchRollForward(
45265
+ const centerForward = getCenterModeHeadingPitchRollForward2(
45266
45266
  resolvedHeading,
45267
45267
  resolvedPitch
45268
45268
  );
45269
45269
  const centerPosition = position.copy(target).addScaledVector(centerForward, -range);
45270
- if (isCenterModePosition(centerPosition)) {
45270
+ if (isCenterModePosition2(centerPosition)) {
45271
45271
  return centerPosition;
45272
45272
  }
45273
- const resolvedForward = getHeadingPitchRollForward(
45273
+ const resolvedForward = getHeadingPitchRollForward2(
45274
45274
  target,
45275
45275
  resolvedHeading,
45276
45276
  resolvedPitch
@@ -45291,13 +45291,13 @@ function createGeoCameraController({
45291
45291
  } else {
45292
45292
  offsetDistance = getCameraDistanceForBoundingSphere(safeRadius);
45293
45293
  }
45294
- const nextPosition = getBoundingSphereFlyToPosition(
45294
+ const nextPosition = getBoundingSphereFlyToPosition2(
45295
45295
  target,
45296
45296
  offsetDistance,
45297
45297
  options
45298
45298
  );
45299
- const nextQuaternion = getHeadingPitchRollQuaternion(
45300
- isCenterModePosition(nextPosition) ? nextPosition : target,
45299
+ const nextQuaternion = getHeadingPitchRollQuaternion2(
45300
+ isCenterModePosition2(nextPosition) ? nextPosition : target,
45301
45301
  options.heading ?? 0,
45302
45302
  options.pitch ?? -Math.PI / 2,
45303
45303
  options.roll ?? 0
@@ -65854,7 +65854,7 @@ var init_cameraController = __esm({
65854
65854
  const minScale = 0;
65855
65855
  metrics.distanceScale = baseScale;
65856
65856
  metrics.transitionWeight = 0;
65857
- if (!__privateGet(this, _ellipsoid)) {
65857
+ if (!__privateGet(this, _ellipsoid) || __privateMethod(this, _CameraController_instances, isCameraCenterMode_fn).call(this)) {
65858
65858
  return metrics;
65859
65859
  }
65860
65860
  const taperStartRadius = __privateGet(this, _ellipsoidMaxRadius) * 1.5;
@@ -65903,7 +65903,7 @@ var init_cameraController = __esm({
65903
65903
  const source = _vec4.copy(__privateGet(this, _camera3).position);
65904
65904
  let distanceScale = 1;
65905
65905
  let transitionWeight = 0;
65906
- if (zoomAmount < 0 && __privateGet(this, _ellipsoid)) {
65906
+ if (zoomAmount < 0 && __privateGet(this, _ellipsoid) && !__privateMethod(this, _CameraController_instances, isCameraCenterMode_fn).call(this)) {
65907
65907
  const metrics = __privateMethod(this, _CameraController_instances, getZoomOutMetrics_fn).call(this, source, hit.virtual ? null : hit);
65908
65908
  distanceScale = metrics.distanceScale;
65909
65909
  transitionWeight = metrics.transitionWeight;
@@ -66096,9 +66096,9 @@ function createViewerScene({
66096
66096
  60,
66097
66097
  window.innerWidth / window.innerHeight,
66098
66098
  1,
66099
- 2e7
66099
+ 12e6
66100
66100
  );
66101
- camera.position.set(0, 0, 175e5);
66101
+ camera.position.set(0, 0, 12e6);
66102
66102
  camera.updateMatrixWorld(true);
66103
66103
  const contentGroup = new Group();
66104
66104
  scene.add(contentGroup);
@@ -67650,6 +67650,502 @@ var init_setPositionController = __esm({
67650
67650
  }
67651
67651
  });
67652
67652
 
67653
+ // src/viewer/navigation/cameraFlyTo.js
67654
+ function eastNorthUpToFixedFrame(origin) {
67655
+ _geoUp.copy(origin).multiply(_oneOverRadiiSquared).normalize();
67656
+ _geoEast.set(0, 0, 1).cross(_geoUp).normalize();
67657
+ _geoNorth.copy(_geoUp).cross(_geoEast).normalize();
67658
+ return _matrix3.set(
67659
+ _geoEast.x,
67660
+ _geoNorth.x,
67661
+ _geoUp.x,
67662
+ origin.x,
67663
+ _geoEast.y,
67664
+ _geoNorth.y,
67665
+ _geoUp.y,
67666
+ origin.y,
67667
+ _geoEast.z,
67668
+ _geoNorth.z,
67669
+ _geoUp.z,
67670
+ origin.z,
67671
+ 0,
67672
+ 0,
67673
+ 0,
67674
+ 1
67675
+ );
67676
+ }
67677
+ function createCameraFlight(camera, position, target, options = {}) {
67678
+ const duration = options.duration ?? 2500;
67679
+ const endPosition = position.clone();
67680
+ const endQuaternion = getEndQuaternion(endPosition, target, options);
67681
+ const endPose = getUprightHeadingPitchAtPose(endPosition, endQuaternion);
67682
+ const endRoll = getRollAtPose(endPosition, endQuaternion);
67683
+ const endZoom = camera instanceof OrthographicCamera ? Math.max(options.endZoom ?? camera.zoom, 1e-6) : null;
67684
+ return buildFlightState(camera, {
67685
+ duration,
67686
+ endPosition,
67687
+ endQuaternion,
67688
+ endZoom,
67689
+ endHeading: endPose.heading,
67690
+ endPitch: endPose.pitch,
67691
+ endRoll
67692
+ });
67693
+ }
67694
+ function getFlyToParamsFromBoundingSphere(camera, target, radius, options = {}) {
67695
+ const safeRadius = Math.max(radius, 1);
67696
+ let offsetDistance = safeRadius;
67697
+ let endZoom = options.endZoom;
67698
+ if (camera instanceof PerspectiveCamera) {
67699
+ const verticalFov = MathUtils.degToRad(camera.fov);
67700
+ const horizontalFov = 2 * Math.atan(Math.tan(verticalFov / 2) * camera.aspect);
67701
+ const minHalfFov = Math.max(0.1, Math.min(verticalFov, horizontalFov) / 2);
67702
+ offsetDistance = safeRadius / Math.sin(minHalfFov) + safeRadius * 0.75;
67703
+ } else if (camera instanceof OrthographicCamera) {
67704
+ const visibleHeight = Math.max(safeRadius * 2.8, 1);
67705
+ endZoom = (camera.top - camera.bottom) / visibleHeight;
67706
+ offsetDistance = Math.max(safeRadius * 2, visibleHeight * 0.5);
67707
+ }
67708
+ const position = getBoundingSphereFlyToPosition(
67709
+ camera,
67710
+ target,
67711
+ offsetDistance,
67712
+ options
67713
+ );
67714
+ return {
67715
+ position,
67716
+ target: target.clone(),
67717
+ options: {
67718
+ ...options,
67719
+ endZoom
67720
+ }
67721
+ };
67722
+ }
67723
+ function flyTo(camera, flight, time) {
67724
+ if (flight.startTime === null) {
67725
+ flight.startTime = time;
67726
+ }
67727
+ const rawT = MathUtils.clamp(
67728
+ (time - flight.startTime) / flight.duration,
67729
+ 0,
67730
+ 1
67731
+ );
67732
+ const easedT = rawT < 0.5 ? 4 * rawT * rawT * rawT : 1 - Math.pow(-2 * rawT + 2, 3) / 2;
67733
+ const position = getFlyToPosition(flight, easedT);
67734
+ const quaternion = flight.maintainUpright ? getUprightInterpolatedQuaternion(flight, position, easedT) : _flyQuaternion.slerpQuaternions(
67735
+ flight.startQuaternion,
67736
+ flight.endQuaternion,
67737
+ easedT
67738
+ );
67739
+ const zoom = flight.startZoom !== null && flight.endZoom !== null ? MathUtils.lerp(flight.startZoom, flight.endZoom, easedT) : null;
67740
+ applyFlyToPose(camera, position, quaternion, zoom);
67741
+ return rawT === 1;
67742
+ }
67743
+ function getFlyToPosition(flight, t2) {
67744
+ const { startPosition, endPosition, arcHeight } = flight;
67745
+ const startLength = startPosition.length();
67746
+ const endLength = endPosition.length();
67747
+ if (startLength < 1e-6 || endLength < 1e-6) {
67748
+ return _flyDirection.lerpVectors(startPosition, endPosition, t2);
67749
+ }
67750
+ _flyDirectionStart.copy(startPosition).divideScalar(startLength);
67751
+ _flyDirectionEnd.copy(endPosition).divideScalar(endLength);
67752
+ const angle = _flyDirectionStart.angleTo(_flyDirectionEnd);
67753
+ if (angle > 1e-5) {
67754
+ if (angle < Math.PI - 1e-5) {
67755
+ _flyAxis.crossVectors(_flyDirectionStart, _flyDirectionEnd).normalize();
67756
+ } else {
67757
+ _flyAxis.crossVectors(_flyDirectionStart, _flyWorldUp);
67758
+ if (_flyAxis.lengthSq() < 1e-6) {
67759
+ _flyAxis.crossVectors(_flyDirectionStart, _flyWorldNorth);
67760
+ }
67761
+ _flyAxis.normalize();
67762
+ }
67763
+ _flyDirection.copy(_flyDirectionStart).applyAxisAngle(_flyAxis, angle * t2).normalize();
67764
+ } else {
67765
+ _flyDirection.lerpVectors(_flyDirectionStart, _flyDirectionEnd, t2);
67766
+ if (_flyDirection.lengthSq() < 1e-12) {
67767
+ _flyDirection.copy(_flyDirectionEnd);
67768
+ } else {
67769
+ _flyDirection.normalize();
67770
+ }
67771
+ }
67772
+ const radius = MathUtils.lerp(startLength, endLength, t2) + Math.sin(Math.PI * t2) * arcHeight;
67773
+ return _flyDirection.multiplyScalar(radius);
67774
+ }
67775
+ function getUprightInterpolatedQuaternion(flight, position, t2) {
67776
+ const heading = lerpAngle(flight.startHeading, flight.endHeading, t2);
67777
+ const pitch = MathUtils.lerp(flight.startPitch, flight.endPitch, t2);
67778
+ return getHeadingPitchRollQuaternion(position, heading, pitch, 0);
67779
+ }
67780
+ function buildFlightState(camera, {
67781
+ duration,
67782
+ endPosition,
67783
+ endQuaternion,
67784
+ endZoom,
67785
+ endHeading,
67786
+ endPitch,
67787
+ endRoll
67788
+ }) {
67789
+ const startPosition = camera.position.clone();
67790
+ const startQuaternion = camera.quaternion.clone();
67791
+ const startPose = getUprightHeadingPitchAtPose(
67792
+ startPosition,
67793
+ startQuaternion
67794
+ );
67795
+ const startRoll = getRollAtPose(startPosition, startQuaternion);
67796
+ const startZoom = camera instanceof OrthographicCamera ? camera.zoom : null;
67797
+ if (isImmediateFlight(
67798
+ duration,
67799
+ startPosition,
67800
+ endPosition,
67801
+ startQuaternion,
67802
+ endQuaternion,
67803
+ startZoom,
67804
+ endZoom
67805
+ )) {
67806
+ applyFlyToPose(camera, endPosition, endQuaternion, endZoom);
67807
+ return null;
67808
+ }
67809
+ return {
67810
+ startTime: null,
67811
+ duration,
67812
+ startPosition,
67813
+ endPosition,
67814
+ startQuaternion,
67815
+ endQuaternion,
67816
+ startZoom,
67817
+ endZoom,
67818
+ arcHeight: getArcHeight(startPosition, endPosition),
67819
+ maintainUpright: shouldMaintainUpright(startRoll, endRoll),
67820
+ startHeading: startPose.heading,
67821
+ endHeading,
67822
+ startPitch: startPose.pitch,
67823
+ endPitch
67824
+ };
67825
+ }
67826
+ function isImmediateFlight(duration, startPosition, endPosition, startQuaternion, endQuaternion, startZoom, endZoom) {
67827
+ return duration <= 0 || startPosition.distanceToSquared(endPosition) < 1e-6 && startQuaternion.angleTo(endQuaternion) < 1e-6 && (startZoom === null || endZoom === null || Math.abs(startZoom - endZoom) < 1e-6);
67828
+ }
67829
+ function getArcHeight(startPosition, endPosition) {
67830
+ const chordLength = startPosition.distanceTo(endPosition);
67831
+ return Math.max(
67832
+ chordLength * 0.35,
67833
+ Math.abs(endPosition.length() - startPosition.length()) * 0.5,
67834
+ 500
67835
+ );
67836
+ }
67837
+ function shouldMaintainUpright(startRoll, endRoll) {
67838
+ return Math.abs(startRoll) <= UPRIGHT_ROLL_THRESHOLD && Math.abs(endRoll) <= UPRIGHT_ROLL_THRESHOLD;
67839
+ }
67840
+ function getLookAtQuaternion(position, target) {
67841
+ if (isCenterModePosition(position)) {
67842
+ _matrix3.lookAt(position, target, _flyCenterUp);
67843
+ return new Quaternion().setFromRotationMatrix(_matrix3);
67844
+ }
67845
+ _flyUp.copy(target);
67846
+ if (_flyUp.lengthSq() < 1e-6) {
67847
+ _flyUp.copy(_flyWorldUp);
67848
+ } else {
67849
+ _flyUp.normalize();
67850
+ }
67851
+ _flyEast.crossVectors(_flyWorldNorth, _flyUp);
67852
+ if (_flyEast.lengthSq() < 1e-6) {
67853
+ _flyEast.crossVectors(_flyWorldUp, _flyUp);
67854
+ }
67855
+ if (_flyEast.lengthSq() < 1e-6) {
67856
+ _flyEast.set(1, 0, 0);
67857
+ }
67858
+ _flyEast.normalize();
67859
+ _flyUp.crossVectors(_flyUp, _flyEast).normalize();
67860
+ _matrix3.lookAt(position, target, _flyUp);
67861
+ return new Quaternion().setFromRotationMatrix(_matrix3);
67862
+ }
67863
+ function getForwardFromQuaternion(quaternion, target) {
67864
+ return target.set(0, 0, -1).applyQuaternion(quaternion).normalize();
67865
+ }
67866
+ function getUprightHeadingPitchAtPose(position, quaternion) {
67867
+ if (isCenterModePosition(position)) {
67868
+ const forward2 = getForwardFromQuaternion(quaternion, _flyForward);
67869
+ _flyCameraRight.set(1, 0, 0).applyQuaternion(quaternion);
67870
+ _flyReferenceRight.copy(_flyCameraRight).projectOnPlane(_flyCenterUp);
67871
+ let heading2 = 0;
67872
+ if (_flyReferenceRight.lengthSq() > HEADING_RIGHT_DEGENERATE_EPSILON) {
67873
+ _flyReferenceRight.normalize();
67874
+ heading2 = Math.atan2(
67875
+ -_flyReferenceRight.dot(_flyCenterNorth),
67876
+ _flyReferenceRight.dot(_flyWorldRight)
67877
+ );
67878
+ } else {
67879
+ const horizontalForward = _flyDirection.copy(forward2).projectOnPlane(_flyCenterUp);
67880
+ if (horizontalForward.lengthSq() > HEADING_RIGHT_DEGENERATE_EPSILON) {
67881
+ horizontalForward.normalize();
67882
+ heading2 = Math.atan2(
67883
+ horizontalForward.dot(_flyWorldRight),
67884
+ horizontalForward.dot(_flyCenterNorth)
67885
+ );
67886
+ }
67887
+ }
67888
+ return {
67889
+ heading: heading2,
67890
+ pitch: Math.asin(MathUtils.clamp(forward2.dot(_flyCenterUp), -1, 1))
67891
+ };
67892
+ }
67893
+ if (position.lengthSq() < 1e-6) {
67894
+ return {
67895
+ heading: 0,
67896
+ pitch: 0
67897
+ };
67898
+ }
67899
+ const forward = getForwardFromQuaternion(quaternion, _flyForward);
67900
+ getLocalFrame(position);
67901
+ _flyCameraRight.set(1, 0, 0).applyQuaternion(quaternion);
67902
+ _flyReferenceRight.copy(_flyCameraRight).projectOnPlane(_flyUp);
67903
+ let heading = 0;
67904
+ if (_flyReferenceRight.lengthSq() > HEADING_RIGHT_DEGENERATE_EPSILON) {
67905
+ _flyReferenceRight.normalize();
67906
+ heading = Math.atan2(
67907
+ -_flyReferenceRight.dot(_flyNorth),
67908
+ _flyReferenceRight.dot(_flyEast)
67909
+ );
67910
+ } else {
67911
+ const horizontalForward = _flyDirection.copy(forward).projectOnPlane(_flyUp);
67912
+ if (horizontalForward.lengthSq() > HEADING_RIGHT_DEGENERATE_EPSILON) {
67913
+ horizontalForward.normalize();
67914
+ heading = Math.atan2(
67915
+ horizontalForward.dot(_flyEast),
67916
+ horizontalForward.dot(_flyNorth)
67917
+ );
67918
+ }
67919
+ }
67920
+ return {
67921
+ heading,
67922
+ pitch: Math.asin(MathUtils.clamp(forward.dot(_flyUp), -1, 1))
67923
+ };
67924
+ }
67925
+ function getRollAtPose(position, quaternion) {
67926
+ const forward = getForwardFromQuaternion(quaternion, _flyForward);
67927
+ if (isCenterModePosition(position)) {
67928
+ if (Math.abs(forward.dot(_flyCenterUp)) >= ROLL_UNDEFINED_DOT_THRESHOLD) {
67929
+ return 0;
67930
+ }
67931
+ getReferenceBasis(
67932
+ forward,
67933
+ _flyWorldRight,
67934
+ _flyCenterUp,
67935
+ _flyReferenceRight,
67936
+ _flyReferenceUp
67937
+ );
67938
+ } else {
67939
+ if (position.lengthSq() < 1e-6) {
67940
+ return 0;
67941
+ }
67942
+ getLocalFrame(position);
67943
+ if (Math.abs(forward.dot(_flyUp)) >= ROLL_UNDEFINED_DOT_THRESHOLD) {
67944
+ return 0;
67945
+ }
67946
+ getReferenceBasis(
67947
+ forward,
67948
+ _flyEast,
67949
+ _flyUp,
67950
+ _flyReferenceRight,
67951
+ _flyReferenceUp
67952
+ );
67953
+ }
67954
+ _flyReferenceUp.projectOnPlane(forward);
67955
+ _flyCameraUp.set(0, 1, 0).applyQuaternion(quaternion).projectOnPlane(forward);
67956
+ if (_flyReferenceUp.lengthSq() < 1e-6 || _flyCameraUp.lengthSq() < 1e-6) {
67957
+ return 0;
67958
+ }
67959
+ _flyReferenceUp.normalize();
67960
+ _flyCameraUp.normalize();
67961
+ return Math.atan2(
67962
+ _flyDirection.crossVectors(_flyReferenceUp, _flyCameraUp).dot(forward),
67963
+ _flyReferenceUp.dot(_flyCameraUp)
67964
+ );
67965
+ }
67966
+ function getEndQuaternion(position, target, options) {
67967
+ const { heading, pitch, roll } = options;
67968
+ if (heading === void 0 && pitch === void 0 && roll === void 0) {
67969
+ return getLookAtQuaternion(position, target);
67970
+ }
67971
+ if (heading === void 0 && pitch === void 0) {
67972
+ const quaternion = getLookAtQuaternion(position, target);
67973
+ if (roll) {
67974
+ _flyForward.subVectors(target, position).normalize();
67975
+ quaternion.multiply(_flyQuaternion.setFromAxisAngle(_flyForward, roll));
67976
+ }
67977
+ return quaternion;
67978
+ }
67979
+ return getHeadingPitchRollQuaternion(
67980
+ isCenterModePosition(position) ? position : target,
67981
+ heading ?? 0,
67982
+ pitch ?? -Math.PI / 2,
67983
+ roll ?? 0
67984
+ );
67985
+ }
67986
+ function getBoundingSphereFlyToPosition(camera, target, range, options) {
67987
+ const { heading, pitch } = options;
67988
+ if (heading === void 0 && pitch === void 0) {
67989
+ const direction = target.lengthSq() > 1e-6 ? _flyDirection.copy(target).normalize() : camera.position.lengthSq() > 1e-6 ? _flyDirection.copy(camera.position).normalize() : _flyDirection.set(0, -1, 0);
67990
+ return direction.multiplyScalar(range).add(target);
67991
+ }
67992
+ const resolvedHeading = heading ?? 0;
67993
+ const resolvedPitch = pitch ?? -Math.PI / 2;
67994
+ const centerForward = getCenterModeHeadingPitchRollForward(
67995
+ resolvedHeading,
67996
+ resolvedPitch
67997
+ );
67998
+ const centerPosition = _flyDirection.copy(target).addScaledVector(centerForward, -range);
67999
+ if (isCenterModePosition(centerPosition)) {
68000
+ return centerPosition;
68001
+ }
68002
+ const forward = getHeadingPitchRollForward(
68003
+ target,
68004
+ resolvedHeading,
68005
+ resolvedPitch
68006
+ );
68007
+ return _flyDirection.copy(target).addScaledVector(forward, -range);
68008
+ }
68009
+ function getHeadingPitchRollQuaternion(referencePoint, heading, pitch, roll) {
68010
+ if (isCenterModePosition(referencePoint)) {
68011
+ getCenterModeHeadingPitchRollBasis(heading, pitch, roll);
68012
+ _matrix1.makeBasis(_flyRight, _flyUp, _flyBackward);
68013
+ return new Quaternion().setFromRotationMatrix(_matrix1);
68014
+ }
68015
+ if (referencePoint.lengthSq() < 1e-6) {
68016
+ return new Quaternion();
68017
+ }
68018
+ getHeadingPitchRollBasis(referencePoint, heading, pitch, roll);
68019
+ _matrix1.makeBasis(_flyRight, _flyUp, _flyBackward);
68020
+ return new Quaternion().setFromRotationMatrix(_matrix1);
68021
+ }
68022
+ function getHeadingPitchRollForward(referencePoint, heading, pitch) {
68023
+ if (isCenterModePosition(referencePoint)) {
68024
+ return getCenterModeHeadingPitchRollForward(heading, pitch);
68025
+ }
68026
+ if (referencePoint.lengthSq() < 1e-6) {
68027
+ return _flyForward.set(0, 0, -1);
68028
+ }
68029
+ getLocalFrame(referencePoint);
68030
+ const cosPitch = Math.cos(pitch);
68031
+ const sinPitch = Math.sin(pitch);
68032
+ const cosHeading = Math.cos(heading);
68033
+ const sinHeading = Math.sin(heading);
68034
+ _flyForward.copy(_flyNorth).multiplyScalar(cosHeading * cosPitch).addScaledVector(_flyEast, sinHeading * cosPitch).addScaledVector(_flyUp, sinPitch).normalize();
68035
+ return _flyForward;
68036
+ }
68037
+ function getCenterModeHeadingPitchRollForward(heading, pitch) {
68038
+ const cosPitch = Math.cos(pitch);
68039
+ const sinPitch = Math.sin(pitch);
68040
+ const cosHeading = Math.cos(heading);
68041
+ const sinHeading = Math.sin(heading);
68042
+ _flyForward.set(sinHeading * cosPitch, cosHeading * cosPitch, sinPitch);
68043
+ return _flyForward.normalize();
68044
+ }
68045
+ function getHeadingPitchRollBasis(referencePoint, heading, pitch, roll) {
68046
+ if (isCenterModePosition(referencePoint)) {
68047
+ getCenterModeHeadingPitchRollBasis(heading, pitch, roll);
68048
+ return;
68049
+ }
68050
+ getHeadingPitchRollForward(referencePoint, heading, pitch);
68051
+ _flyRight.copy(_flyEast).multiplyScalar(Math.cos(heading)).addScaledVector(_flyNorth, -Math.sin(heading)).normalize();
68052
+ _flyUp.crossVectors(_flyRight, _flyForward).normalize();
68053
+ if (roll !== 0) {
68054
+ _flyRight.applyAxisAngle(_flyForward, roll).normalize();
68055
+ _flyUp.applyAxisAngle(_flyForward, roll).normalize();
68056
+ }
68057
+ _flyBackward.copy(_flyForward).negate();
68058
+ }
68059
+ function getCenterModeHeadingPitchRollBasis(heading, pitch, roll) {
68060
+ getCenterModeHeadingPitchRollForward(heading, pitch);
68061
+ _flyRight.copy(_flyWorldRight).multiplyScalar(Math.cos(heading)).addScaledVector(_flyCenterNorth, -Math.sin(heading)).normalize();
68062
+ _flyUp.crossVectors(_flyRight, _flyForward).normalize();
68063
+ if (roll !== 0) {
68064
+ _flyRight.applyAxisAngle(_flyForward, roll).normalize();
68065
+ _flyUp.applyAxisAngle(_flyForward, roll).normalize();
68066
+ }
68067
+ _flyBackward.copy(_flyForward).negate();
68068
+ }
68069
+ function getLocalFrame(target) {
68070
+ _matrix1.copy(eastNorthUpToFixedFrame(target));
68071
+ _flyEast.setFromMatrixColumn(_matrix1, 0).normalize();
68072
+ _flyNorth.setFromMatrixColumn(_matrix1, 1).normalize();
68073
+ _flyUp.setFromMatrixColumn(_matrix1, 2).normalize();
68074
+ }
68075
+ function isCenterModePosition(position) {
68076
+ return position.lengthSq() <= CAMERA_CENTER_MODE_DISTANCE_SQ;
68077
+ }
68078
+ function getReferenceBasis(forward, east, up, rightTarget, upTarget) {
68079
+ rightTarget.crossVectors(forward, up);
68080
+ if (rightTarget.lengthSq() < 1e-6) {
68081
+ rightTarget.copy(east).projectOnPlane(forward);
68082
+ if (rightTarget.lengthSq() < 1e-6) {
68083
+ rightTarget.set(1, 0, 0).projectOnPlane(forward);
68084
+ }
68085
+ }
68086
+ rightTarget.normalize();
68087
+ upTarget.crossVectors(rightTarget, forward).normalize();
68088
+ }
68089
+ function lerpAngle(start, end, t2) {
68090
+ let delta = end - start;
68091
+ if (delta > Math.PI) {
68092
+ delta -= Math.PI * 2;
68093
+ } else if (delta < -Math.PI) {
68094
+ delta += Math.PI * 2;
68095
+ }
68096
+ return start + delta * t2;
68097
+ }
68098
+ function applyFlyToPose(camera, position, quaternion, zoom = null) {
68099
+ camera.position.copy(position);
68100
+ camera.quaternion.copy(quaternion);
68101
+ if (camera instanceof OrthographicCamera && zoom !== null) {
68102
+ camera.zoom = Math.max(zoom, 1e-6);
68103
+ camera.updateProjectionMatrix();
68104
+ }
68105
+ camera.updateMatrixWorld();
68106
+ }
68107
+ var _matrix3, _matrix1, _flyDirectionStart, _flyDirectionEnd, _flyDirection, _flyAxis, _flyWorldNorth, _flyWorldRight, _flyCenterNorth, _flyCenterUp, _flyWorldUp, _flyUp, _flyEast, _flyNorth, _flyForward, _flyRight, _flyBackward, _flyCameraUp, _flyCameraRight, _flyReferenceUp, _flyReferenceRight, _flyQuaternion, _ellipsoidRadii, _oneOverRadiiSquared, _geoEast, _geoNorth, _geoUp, UPRIGHT_ROLL_THRESHOLD, ROLL_UNDEFINED_DOT_THRESHOLD, HEADING_RIGHT_DEGENERATE_EPSILON;
68108
+ var init_cameraFlyTo = __esm({
68109
+ "src/viewer/navigation/cameraFlyTo.js"() {
68110
+ init_three_module();
68111
+ init_config();
68112
+ _matrix3 = new Matrix4();
68113
+ _matrix1 = new Matrix4();
68114
+ _flyDirectionStart = new Vector3();
68115
+ _flyDirectionEnd = new Vector3();
68116
+ _flyDirection = new Vector3();
68117
+ _flyAxis = new Vector3();
68118
+ _flyWorldNorth = new Vector3(0, 0, 1);
68119
+ _flyWorldRight = new Vector3(1, 0, 0);
68120
+ _flyCenterNorth = new Vector3(0, 1, 0);
68121
+ _flyCenterUp = new Vector3(0, 0, 1);
68122
+ _flyWorldUp = new Vector3(0, 1, 0);
68123
+ _flyUp = new Vector3();
68124
+ _flyEast = new Vector3();
68125
+ _flyNorth = new Vector3();
68126
+ _flyForward = new Vector3();
68127
+ _flyRight = new Vector3();
68128
+ _flyBackward = new Vector3();
68129
+ _flyCameraUp = new Vector3();
68130
+ _flyCameraRight = new Vector3();
68131
+ _flyReferenceUp = new Vector3();
68132
+ _flyReferenceRight = new Vector3();
68133
+ _flyQuaternion = new Quaternion();
68134
+ _ellipsoidRadii = new Vector3(6378137, 6378137, 6356752314245179e-9);
68135
+ _oneOverRadiiSquared = new Vector3(
68136
+ 1 / (_ellipsoidRadii.x * _ellipsoidRadii.x),
68137
+ 1 / (_ellipsoidRadii.y * _ellipsoidRadii.y),
68138
+ 1 / (_ellipsoidRadii.z * _ellipsoidRadii.z)
68139
+ );
68140
+ _geoEast = new Vector3();
68141
+ _geoNorth = new Vector3();
68142
+ _geoUp = new Vector3();
68143
+ UPRIGHT_ROLL_THRESHOLD = MathUtils.degToRad(5);
68144
+ ROLL_UNDEFINED_DOT_THRESHOLD = Math.cos(MathUtils.degToRad(5));
68145
+ HEADING_RIGHT_DEGENERATE_EPSILON = 1e-6;
68146
+ }
68147
+ });
68148
+
67653
68149
  // src/viewer/navigation/flyTo.js
67654
68150
  function createFlyToController({
67655
68151
  camera,
@@ -67669,6 +68165,8 @@ function createFlyToController({
67669
68165
  const pickRaycaster = new Raycaster();
67670
68166
  const pickTargets = [];
67671
68167
  const sphere = new Sphere();
68168
+ let activeCameraFlight = null;
68169
+ let activeCameraFlightStatus = "";
67672
68170
  function getActiveEllipsoid() {
67673
68171
  return getTiles()?.ellipsoid || globeController.getEllipsoid();
67674
68172
  }
@@ -67710,6 +68208,43 @@ function createFlyToController({
67710
68208
  }
67711
68209
  return geoCamera.getCartographicFromWorldPosition(coordinateWorldPosition);
67712
68210
  }
68211
+ function startCameraFlight(position, target, options = {}, { activeStatus = "Moving camera.", doneStatus = "Moved camera." } = {}) {
68212
+ cameraController.setCamera(camera);
68213
+ activeCameraFlight = createCameraFlight(camera, position, target, options);
68214
+ activeCameraFlightStatus = doneStatus;
68215
+ if (!activeCameraFlight) {
68216
+ cameraController.setCamera(camera);
68217
+ setStatus(doneStatus);
68218
+ return;
68219
+ }
68220
+ setStatus(activeStatus);
68221
+ }
68222
+ function startBoundingSphereFlight(target, radius, options = {}, status = {}) {
68223
+ const flyToParams = getFlyToParamsFromBoundingSphere(
68224
+ camera,
68225
+ target,
68226
+ radius,
68227
+ options
68228
+ );
68229
+ startCameraFlight(
68230
+ flyToParams.position,
68231
+ flyToParams.target,
68232
+ flyToParams.options,
68233
+ status
68234
+ );
68235
+ }
68236
+ function update(time = performance.now()) {
68237
+ if (!activeCameraFlight) {
68238
+ return false;
68239
+ }
68240
+ const done = flyTo(camera, activeCameraFlight, time);
68241
+ if (done) {
68242
+ activeCameraFlight = null;
68243
+ setStatus(activeCameraFlightStatus);
68244
+ activeCameraFlightStatus = "";
68245
+ }
68246
+ return true;
68247
+ }
67713
68248
  async function applyTilesSetPositionFromPointerEvent(event) {
67714
68249
  const coordinate = pickCoordinateFromPointerEvent(event);
67715
68250
  if (!coordinate) {
@@ -67731,27 +68266,29 @@ function createFlyToController({
67731
68266
  return null;
67732
68267
  }
67733
68268
  }
67734
- function frameTileset() {
68269
+ function frameTileset({
68270
+ activeStatus = "Moving camera to the tileset.",
68271
+ doneStatus = "Moved camera to the tileset."
68272
+ } = {}) {
67735
68273
  if (!getTilesetBoundingSphere(sphere)) {
67736
68274
  return false;
67737
68275
  }
67738
- const pose = geoCamera.getFlyToPoseFromBoundingSphere(
68276
+ startBoundingSphereFlight(
67739
68277
  sphere.center,
67740
- sphere.radius,
67741
- moveToTilesPose
68278
+ sphere.radius / 2,
68279
+ moveToTilesPose,
68280
+ {
68281
+ activeStatus,
68282
+ doneStatus
68283
+ }
67742
68284
  );
67743
- camera.position.copy(pose.position);
67744
- camera.quaternion.copy(pose.quaternion);
67745
- camera.updateMatrixWorld(true);
67746
- cameraController.setCamera(camera);
67747
68285
  return true;
67748
68286
  }
67749
68287
  function moveCameraToTiles() {
67750
68288
  if (frameTileset()) {
67751
- setStatus("Moved camera to the tileset.");
67752
- } else {
67753
- setStatus("Tileset is not ready to frame yet.", true);
68289
+ return;
67754
68290
  }
68291
+ setStatus("Tileset is not ready to frame yet.", true);
67755
68292
  }
67756
68293
  function moveCameraToCoordinate(coordinate) {
67757
68294
  geoCamera.getCoordinateWorldPosition(
@@ -67760,16 +68297,15 @@ function createFlyToController({
67760
68297
  coordinate.height,
67761
68298
  coordinateWorldPosition
67762
68299
  );
67763
- const pose = geoCamera.getFlyToPoseFromBoundingSphere(
68300
+ startBoundingSphereFlight(
67764
68301
  coordinateWorldPosition,
67765
68302
  moveToCoordinateRadius,
67766
- moveToTilesPose
68303
+ moveToTilesPose,
68304
+ {
68305
+ activeStatus: "Moving camera to the specified coordinate.",
68306
+ doneStatus: "Moved camera to the specified coordinate."
68307
+ }
67767
68308
  );
67768
- camera.position.copy(pose.position);
67769
- camera.quaternion.copy(pose.quaternion);
67770
- camera.updateMatrixWorld(true);
67771
- cameraController.setCamera(camera);
67772
- setStatus("Moved camera to the specified coordinate.");
67773
68309
  }
67774
68310
  return {
67775
68311
  applyTilesSetPositionFromPointerEvent,
@@ -67777,12 +68313,14 @@ function createFlyToController({
67777
68313
  getActiveEllipsoid,
67778
68314
  moveCameraToCoordinate,
67779
68315
  moveCameraToTiles,
67780
- pickCoordinateFromPointerEvent
68316
+ pickCoordinateFromPointerEvent,
68317
+ update
67781
68318
  };
67782
68319
  }
67783
68320
  var init_flyTo = __esm({
67784
68321
  "src/viewer/navigation/flyTo.js"() {
67785
68322
  init_three_module();
68323
+ init_cameraFlyTo();
67786
68324
  init_utils();
67787
68325
  }
67788
68326
  });
@@ -70686,7 +71224,7 @@ var require_app = __commonJS({
70686
71224
  var geoCamera = createGeoCameraController({
70687
71225
  camera,
70688
71226
  centerModeDistanceSq: CAMERA_CENTER_MODE_DISTANCE_SQ,
70689
- getActiveEllipsoid: () => flyTo.getActiveEllipsoid()
71227
+ getActiveEllipsoid: () => flyTo2.getActiveEllipsoid()
70690
71228
  });
70691
71229
  var geometricError = createGeometricErrorController({
70692
71230
  defaultErrorTarget: DEFAULT_ERROR_TARGET,
@@ -70705,7 +71243,7 @@ var require_app = __commonJS({
70705
71243
  target.radius *= editableGroup.matrixWorld.getMaxScaleOnAxis();
70706
71244
  return true;
70707
71245
  }
70708
- var flyTo = createFlyToController({
71246
+ var flyTo2 = createFlyToController({
70709
71247
  camera,
70710
71248
  cameraController,
70711
71249
  domElement: renderer.domElement,
@@ -70727,7 +71265,7 @@ var require_app = __commonJS({
70727
71265
  syncTransformControlsState: () => transformModeController.syncControls(),
70728
71266
  transformControls,
70729
71267
  applyTilesPlacementFromPointerEvent: async (event) => {
70730
- const coordinate = await flyTo.applyTilesSetPositionFromPointerEvent(event);
71268
+ const coordinate = await flyTo2.applyTilesSetPositionFromPointerEvent(event);
70731
71269
  if (coordinate) {
70732
71270
  updateCoordinateInputs(
70733
71271
  coordinate.latitude,
@@ -70815,7 +71353,7 @@ var require_app = __commonJS({
70815
71353
  transformModeController.setMode(null);
70816
71354
  function moveCameraToTiles() {
70817
71355
  cancelPositionPickModes();
70818
- flyTo.moveCameraToTiles();
71356
+ flyTo2.moveCameraToTiles();
70819
71357
  }
70820
71358
  function moveCameraToCoordinate() {
70821
71359
  cancelPositionPickModes();
@@ -70823,7 +71361,7 @@ var require_app = __commonJS({
70823
71361
  if (!coordinate) {
70824
71362
  return;
70825
71363
  }
70826
- flyTo.moveCameraToCoordinate(coordinate);
71364
+ flyTo2.moveCameraToCoordinate(coordinate);
70827
71365
  }
70828
71366
  async function moveTilesToCoordinate() {
70829
71367
  cancelPositionPickModes();
@@ -70837,6 +71375,7 @@ var require_app = __commonJS({
70837
71375
  coordinate.longitude,
70838
71376
  coordinate.height
70839
71377
  );
71378
+ flyTo2.moveCameraToTiles();
70840
71379
  setStatus(
70841
71380
  "Moved tileset root to the specified coordinate using ENU orientation. Click Save to persist."
70842
71381
  );
@@ -70898,9 +71437,11 @@ var require_app = __commonJS({
70898
71437
  if (framed) {
70899
71438
  return;
70900
71439
  }
70901
- if (flyTo.frameTileset()) {
71440
+ if (flyTo2.frameTileset({
71441
+ activeStatus: "Framing tileset...",
71442
+ doneStatus: "Tileset ready."
71443
+ })) {
70902
71444
  framed = true;
70903
- setStatus("Tileset ready.");
70904
71445
  }
70905
71446
  };
70906
71447
  next.addEventListener(
@@ -71021,6 +71562,7 @@ var require_app = __commonJS({
71021
71562
  loadTileset(TILESET_URL);
71022
71563
  function frame() {
71023
71564
  cameraController.update();
71565
+ flyTo2.update();
71024
71566
  rootTransform.flush();
71025
71567
  globeController.update();
71026
71568
  tiles?.update();