@sienci/gviewer 0.1.22 → 0.1.23

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.
@@ -2974,7 +2974,7 @@ function Fi(r) {
2974
2974
  }
2975
2975
  };
2976
2976
  }
2977
- const Gi = 25.4, fi = 500, bi = 260;
2977
+ const Gi = 25.4, fi = 500, bi = 300;
2978
2978
  class Yi {
2979
2979
  constructor(Q) {
2980
2980
  this.viewCube = null, this.resizeObserver = null, this.onWindowResize = null, this.animationFrameId = null, this.gridGroup = null, this.axesGroup = null, this.gridLabelsGroup = null, this.boundingBoxGroup = null, this.machineBedGroup = null, this.bitMarker = null, this.preLaserBitType = "drill", this.toolpathStreams = [], this.toolpathCutBucketCount = 1, this.toolpathRotationA = 0, this.lastBitPosition = { x: 0, y: 0, z: 0, a: 0 }, this.sim3dHandle = null, this.currentLines = [], this.linePositions = null, this.renderSequence = 0, this.currentBounds = null, this.cameraFocusTransition = null, this.cameraFollowRequested = !1, this.cameraFollowInterrupted = !1, this.cameraFollowOffset = null, this.id = Q.id, this.container = Q.container, this.callbacks = Q.callbacks ?? {}, this.options = Et(GP, Q.options), this.canvas = document.createElement("canvas"), this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", this.container.appendChild(this.canvas), KP(this.container), this.renderer = new a.WebGLRenderer({
@@ -3011,7 +3011,7 @@ class Yi {
3011
3011
  var A;
3012
3012
  if (this.ensureBitMarker(), this.lastBitPosition = { ...this.lastBitPosition, ...Q }, (A = this.bitMarker) == null || A.setTarget(Q, B), this.cameraFollowRequested && !this.cameraFollowInterrupted && this.cameraFollowOffset) {
3013
3013
  const t = new a.Vector3(this.lastBitPosition.x, this.lastBitPosition.y, this.controls.target.z), P = t.clone().add(this.cameraFollowOffset);
3014
- this.startCameraLerp(t, P, bi);
3014
+ this.startCameraLerp(t, P, bi, "linear");
3015
3015
  }
3016
3016
  }
3017
3017
  /**
@@ -3133,7 +3133,7 @@ class Yi {
3133
3133
  // Shared tween kickoff for any camera position+target move (view snapping,
3134
3134
  // model focus, tool-follow engage/track): saves/restores damping around the
3135
3135
  // transition and hands off to updateCameraFocusTransition() each frame.
3136
- startCameraLerp(Q, B, A) {
3136
+ startCameraLerp(Q, B, A, t = "easeInOutCubic") {
3137
3137
  this.cameraFocusTransition && (this.controls.enableDamping = this.cameraFocusTransition.dampingEnabled), this.cameraFocusTransition = {
3138
3138
  startedAt: performance.now(),
3139
3139
  duration: A,
@@ -3141,7 +3141,8 @@ class Yi {
3141
3141
  toPosition: B,
3142
3142
  fromTarget: this.controls.target.clone(),
3143
3143
  toTarget: Q,
3144
- dampingEnabled: this.controls.enableDamping
3144
+ dampingEnabled: this.controls.enableDamping,
3145
+ easing: t
3145
3146
  }, this.controls.enableDamping = !1;
3146
3147
  }
3147
3148
  async loadFromUrl(Q, B = {}) {
@@ -3490,20 +3491,12 @@ class Yi {
3490
3491
  const A = new a.Vector3();
3491
3492
  Q.getSize(A);
3492
3493
  const t = Math.max(A.x, A.y, 1) / 2, P = a.MathUtils.degToRad(this.camera.fov), e = t / Math.tan(P / 2) * 1.25 + A.z, i = JA("front-top-left"), s = B.clone().add(i.multiplyScalar(e)), v = Math.max(A.x, A.y, A.z, 1);
3493
- this.camera.near = v / 1e3, this.camera.far = v * 50, this.camera.updateProjectionMatrix(), this.cameraFocusTransition && (this.controls.enableDamping = this.cameraFocusTransition.dampingEnabled), this.cameraFocusTransition = {
3494
- startedAt: performance.now(),
3495
- duration: this.options.camera.focusDurationMs,
3496
- fromPosition: this.camera.position.clone(),
3497
- toPosition: s,
3498
- fromTarget: this.controls.target.clone(),
3499
- toTarget: B,
3500
- dampingEnabled: this.controls.enableDamping
3501
- }, this.controls.enableDamping = !1;
3494
+ this.camera.near = v / 1e3, this.camera.far = v * 50, this.camera.updateProjectionMatrix(), this.startCameraLerp(B, s, this.options.camera.focusDurationMs);
3502
3495
  }
3503
3496
  updateCameraFocusTransition() {
3504
3497
  if (!this.cameraFocusTransition)
3505
3498
  return;
3506
- const B = performance.now() - this.cameraFocusTransition.startedAt, A = Math.min(1, Math.max(0, B / this.cameraFocusTransition.duration)), t = ZP(A);
3499
+ const B = performance.now() - this.cameraFocusTransition.startedAt, A = Math.min(1, Math.max(0, B / this.cameraFocusTransition.duration)), t = this.cameraFocusTransition.easing === "linear" ? A : ZP(A);
3507
3500
  if (this.camera.position.lerpVectors(this.cameraFocusTransition.fromPosition, this.cameraFocusTransition.toPosition, t), this.controls.target.lerpVectors(this.cameraFocusTransition.fromTarget, this.cameraFocusTransition.toTarget, t), A >= 1) {
3508
3501
  const P = this.cameraFocusTransition.dampingEnabled;
3509
3502
  this.camera.position.copy(this.cameraFocusTransition.toPosition), this.controls.target.copy(this.cameraFocusTransition.toTarget), this.cameraFocusTransition = null, this.controls.enableDamping = !1, this.controls.update(), this.controls.enableDamping = P;