@needle-tools/engine 3.10.1-beta → 3.10.2-beta

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/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.10.2-beta] - 2023-07-19
8
+ - Fix: iOS double touch / input
9
+ - Change: minor WebXRController refactor moving functionality into separate methods to be patchable
10
+
7
11
  ## [3.10.1-beta] - 2023-07-18
8
12
  - Fix: prebundled package
9
13
  - Fix: runtime license check
@@ -22404,8 +22404,8 @@ class oz extends EventTarget {
22404
22404
  if (e.pointerType === "mouse") {
22405
22405
  const g = this._pointerUpTimestamp[e.button];
22406
22406
  if (g > 0 && ((t = e.source) == null ? void 0 : t.timeStamp) !== void 0) {
22407
- const I = g - e.source.timeStamp;
22408
- if (I < 30 && I > 0) {
22407
+ const I = e.source.timeStamp - g;
22408
+ if (I < 60 && I >= 0) {
22409
22409
  ro && console.log("Ignoring mouse.down for touch.up");
22410
22410
  return;
22411
22411
  }
@@ -45273,7 +45273,7 @@ class QD {
45273
45273
  B(this, "lightmapScaleOffsetUniform", { value: new de(1, 1, 0, 0) });
45274
45274
  B(this, "lightmapUniform", { value: null });
45275
45275
  B(this, "onBeforeCompile", (A, e) => {
45276
- _0 && console.log("Lightmaps, before compile"), A.lightMapUv = "uv1", this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset, this.lightmapUniform.value = this.lightmapTexture, A.uniforms.lightmap = this.lightmapUniform, A.uniforms.lightmapScaleOffset = this.lightmapScaleOffsetUniform;
45276
+ _0 && console.log("Lightmaps, before compile", A), A.lightMapUv = "uv1", this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset, this.lightmapUniform.value = this.lightmapTexture, A.uniforms.lightmapScaleOffset = this.lightmapScaleOffsetUniform;
45277
45277
  });
45278
45278
  this.gameObject = A, this.context = e;
45279
45279
  }
@@ -45288,7 +45288,7 @@ class QD {
45288
45288
  }
45289
45289
  updateLightmapUniforms(A) {
45290
45290
  const e = A.uniforms;
45291
- e && e.lightmap && (this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset, this.lightmapUniform.value = this.lightmapTexture, e.lightmap = this.lightmapUniform, e.lightmapScaleOffset = this.lightmapScaleOffsetUniform);
45291
+ e && e.lightmap && (this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset, e.lightmapScaleOffset = this.lightmapScaleOffsetUniform);
45292
45292
  }
45293
45293
  applyLightmap() {
45294
45294
  if (this.gameObject.type === "Object3D") {
@@ -45311,9 +45311,9 @@ class QD {
45311
45311
  const e = this.gameObject.material.clone();
45312
45312
  this.gameObject.material = e, this.gameObject.material.onBeforeCompile = this.onBeforeCompile;
45313
45313
  }
45314
- if (this.lightmapIndex >= 0) {
45315
- const e = this.lightmapTexture, t = this.gameObject.material;
45316
- t && e && (t.uniforms || (t.uniforms = {}), t.lightMap = e, t.uniforms.lightmap = { value: e });
45314
+ if (this.lightmapIndex >= 0 && this.lightmapTexture) {
45315
+ const e = this.gameObject.material;
45316
+ e && (e.lightMap = this.lightmapTexture, e.needsUpdate = !0);
45317
45317
  }
45318
45318
  }
45319
45319
  setLightmapDebugMaterial() {
@@ -45327,7 +45327,7 @@ class QD {
45327
45327
  }
45328
45328
  `,
45329
45329
  fragmentShader: `
45330
- uniform sampler2D lightmap;
45330
+ uniform sampler2D lightMap;
45331
45331
  uniform float lightMapIntensity;
45332
45332
  uniform vec4 lightmapScaleOffset;
45333
45333
  varying vec2 vUv1;
@@ -45340,11 +45340,11 @@ class QD {
45340
45340
  void main() {
45341
45341
  vec2 lUv = vUv1.xy * lightmapScaleOffset.xy + vec2(lightmapScaleOffset.z, (1. - (lightmapScaleOffset.y + lightmapScaleOffset.w)));
45342
45342
 
45343
- vec4 lightMapTexel = texture2D( lightmap, lUv);
45343
+ vec4 lightMapTexel = texture2D( lightMap, lUv);
45344
45344
  // The range of RGBM lightmaps goes from 0 to 34.49 (5^2.2) in linear space, and from 0 to 5 in gamma space.
45345
- //lightMapTexel.rgb *= lightMapTexel.a * 8.; // no idea where that "8" comes from... heuristically derived
45346
- //lightMapTexel.a = 1.;
45347
- //lightMapTexel = conv_sRGBToLinear(lightMapTexel);
45345
+ // lightMapTexel.rgb *= lightMapTexel.a * 8.; // no idea where that "8" comes from... heuristically derived
45346
+ // lightMapTexel.a = 1.;
45347
+ // lightMapTexel = conv_sRGBToLinear(lightMapTexel);
45348
45348
  // lightMapTexel.rgb = vec3(1.);
45349
45349
 
45350
45350
  // gl_FragColor = vec4(vUv1.xy, 0, 1);
@@ -46158,6 +46158,7 @@ const $Y = class extends GA {
46158
46158
  var A;
46159
46159
  return (A = this._lightmaps) != null && A.length ? this._lightmaps[0].lightmap : null;
46160
46160
  }
46161
+ /** set undefined to return to default lightmap */
46161
46162
  set lightmap(A) {
46162
46163
  var e;
46163
46164
  if (this._lightmapTextureOverride = A, A === void 0 && (A = this.context.lightmaps.tryGetLightmap(this.sourceId, this.lightmapIndex)), (e = this._lightmaps) != null && e.length)
@@ -60309,6 +60310,21 @@ const eg = class extends GA {
60309
60310
  break;
60310
60311
  }
60311
60312
  }
60313
+ raycastUpdate(e, t) {
60314
+ const g = this.showRaycastLine && this.type !== 1;
60315
+ if (this.type === 1)
60316
+ e.visible = !1;
60317
+ else if (this.isUsingHands) {
60318
+ e.visible = !this.grabbed && g, Gi(e, t);
60319
+ const I = this.hand.joints;
60320
+ if (I && I.wrist && this.grabbed && this.grabbed.isCloseGrab) {
60321
+ const s = this.getWristQuaternion();
60322
+ s && this.rayRotation.copy(s);
60323
+ }
60324
+ XI(e, this.rayRotation);
60325
+ } else
60326
+ e.visible = g, XI(e, this.rayRotation), Gi(e, t);
60327
+ }
60312
60328
  update() {
60313
60329
  this.context.time.frameCount % 60 === 0 && (this.setControllerLayers(this.controller, 2), this.setControllerLayers(this.controllerGrip, 2), this.setControllerLayers(this.hand, 2));
60314
60330
  const e = eg.eventSubs.update;
@@ -60318,22 +60334,7 @@ const eg = class extends GA {
60318
60334
  let t = 1;
60319
60335
  this.type === 0 ? t = this.context.time.deltaTime / 0.1 : this.isUsingHands && this.handPointerModel.pinched && (t = this.context.time.deltaTime / 0.3), this.rayRotation.slerp(gg(this.controller), this.useSmoothing ? t : 1);
60320
60336
  const g = ye(this.controller);
60321
- if (this.isUsingHands && this.handPointerModel.cursorObject && (this.handPointerModel.cursorObject.visible = !1), this.raycastLine) {
60322
- const I = this.showRaycastLine && this.type !== 1;
60323
- if (this.type === 1)
60324
- this.raycastLine.visible = !1;
60325
- else if (this.isUsingHands) {
60326
- this.raycastLine.visible = !this.grabbed && I, Gi(this.raycastLine, g);
60327
- const o = this.hand.joints;
60328
- if (o && o.wrist && this.grabbed && this.grabbed.isCloseGrab) {
60329
- const C = this.getWristQuaternion();
60330
- C && this.rayRotation.copy(C);
60331
- }
60332
- XI(this.raycastLine, this.rayRotation);
60333
- } else
60334
- this.raycastLine.visible = I, XI(this.raycastLine, this.rayRotation), Gi(this.raycastLine, g);
60335
- }
60336
- this.lastHit = this.updateLastHit(), this.grabbed && this.grabbed.update(), this._selectionPressedLastFrame = this._selectionPressed, this.selectStartCallback && this.selectStartCallback();
60337
+ this.isUsingHands && this.handPointerModel.cursorObject && (this.handPointerModel.cursorObject.visible = !1), this.raycastLine && this.raycastUpdate(this.raycastLine, g), this.lastHit = this.updateLastHit(), this.grabbed && this.grabbed.update(), this._selectionPressedLastFrame = this._selectionPressed, this.selectStartCallback && this.selectStartCallback();
60337
60338
  }
60338
60339
  onUpdate(e) {
60339
60340
  var I, o;
@@ -60350,25 +60351,31 @@ const eg = class extends GA {
60350
60351
  const g = (o = (I = this.input) == null ? void 0 : I.gamepad) == null ? void 0 : o.buttons;
60351
60352
  switch (this.input.handedness) {
60352
60353
  case "left":
60353
- const s = 3 * eg.MovementSpeedFactor, C = 2, n = ie.clamp01(this.joystick.length() * 2), a = this.joystick.x > 0 ? 1 : -1;
60354
- let r = Math.pow(this.joystick.x, C);
60355
- r *= a, r *= n;
60356
- const Q = this.joystick.y > 0 ? 1 : -1;
60357
- let E = Math.pow(this.joystick.y, C);
60358
- E *= Q, r *= n, t.getWorldQuaternion(this.worldRot), this.movementVector.set(r, 0, E), this.movementVector.applyQuaternion(this.webXR.TransformOrientation), this.movementVector.y = 0, this.movementVector.applyQuaternion(this.worldRot), this.movementVector.multiplyScalar(s * this.context.time.deltaTime), t.position.add(this.movementVector), this.isUsingHands && this.runTeleport(t, g);
60354
+ this.movementUpdate(t, g);
60359
60355
  break;
60360
60356
  case "right":
60361
- const h = this.joystick.x, l = Math.abs(h);
60362
- if (l < 0.4)
60363
- this.didRotate = !1;
60364
- else if (l > 0.5 && !this.didRotate) {
60365
- const d = h > 0 ? -1 : 1;
60366
- t.rotateY(ie.toRadians(30 * d)), this.didRotate = !0;
60367
- }
60368
- this.runTeleport(t, g);
60357
+ this.rotationUpdate(t, g);
60369
60358
  break;
60370
60359
  }
60371
60360
  }
60361
+ movementUpdate(e, t) {
60362
+ const g = 3 * eg.MovementSpeedFactor, I = 2, o = ie.clamp01(this.joystick.length() * 2), s = this.joystick.x > 0 ? 1 : -1;
60363
+ let C = Math.pow(this.joystick.x, I);
60364
+ C *= s, C *= o;
60365
+ const n = this.joystick.y > 0 ? 1 : -1;
60366
+ let a = Math.pow(this.joystick.y, I);
60367
+ a *= n, C *= o, e.getWorldQuaternion(this.worldRot), this.movementVector.set(C, 0, a), this.movementVector.applyQuaternion(this.webXR.TransformOrientation), this.movementVector.y = 0, this.movementVector.applyQuaternion(this.worldRot), this.movementVector.multiplyScalar(g * this.context.time.deltaTime), e.position.add(this.movementVector), this.isUsingHands && this.runTeleport(e, t);
60368
+ }
60369
+ rotationUpdate(e, t) {
60370
+ const g = this.joystick.x, I = Math.abs(g);
60371
+ if (I < 0.4)
60372
+ this.didRotate = !1;
60373
+ else if (I > 0.5 && !this.didRotate) {
60374
+ const o = g > 0 ? -1 : 1;
60375
+ e.rotateY(ie.toRadians(30 * o)), this.didRotate = !0;
60376
+ }
60377
+ this.runTeleport(e, t);
60378
+ }
60372
60379
  runTeleport(e, t) {
60373
60380
  var C, n, a;
60374
60381
  let g = -this.joystick.y;
@@ -60385,16 +60392,10 @@ const eg = class extends GA {
60385
60392
  if (Q.pressed && !this.didChangeScale && this.webXR.IsInVR) {
60386
60393
  this.didChangeScale = !0;
60387
60394
  const E = this.webXR.Rig;
60388
- if (E)
60389
- if (o) {
60390
- o = !1, E.scale.set(1, 1, 1), s = 1, eg.MovementSpeedFactor = 1;
60391
- const h = this.context.mainCamera;
60392
- eg.PreviousCameraFarDistance && (h.far = eg.PreviousCameraFarDistance);
60393
- } else {
60394
- o = !0, I = !0, s = 0.1, eg.MovementSpeedFactor = s * 2;
60395
- const h = this.context.mainCamera;
60396
- eg.PreviousCameraFarDistance = h.far, h.far /= s;
60397
- }
60395
+ if (E) {
60396
+ let h = this.switchScale(E, I, o, s);
60397
+ I = h.doTeleport, o = h.isInMiniatureMode, s = h.newRigScale;
60398
+ }
60398
60399
  } else
60399
60400
  Q.pressed || (this.didChangeScale = !1);
60400
60401
  }
@@ -60416,6 +60417,18 @@ const eg = class extends GA {
60416
60417
  isValidTeleportTarget(e) {
60417
60418
  return tA.getComponentInParent(e, FU) != null;
60418
60419
  }
60420
+ switchScale(e, t, g, I) {
60421
+ if (g) {
60422
+ g = !1, e.scale.set(1, 1, 1), I = 1, eg.MovementSpeedFactor = 1;
60423
+ const o = this.context.mainCamera;
60424
+ eg.PreviousCameraFarDistance && (o.far = eg.PreviousCameraFarDistance);
60425
+ } else {
60426
+ g = !0, t = !0, I = 0.1, eg.MovementSpeedFactor = I * 2;
60427
+ const o = this.context.mainCamera;
60428
+ eg.PreviousCameraFarDistance = o.far, o.far /= I;
60429
+ }
60430
+ return { doTeleport: t, isInMiniatureMode: g, newRigScale: I };
60431
+ }
60419
60432
  updateStick(e) {
60420
60433
  var t;
60421
60434
  !e || !e.gamepad || ((t = e.gamepad.axes) == null ? void 0 : t.length) < 4 || (this.joystick.x = e.gamepad.axes[2], this.joystick.y = e.gamepad.axes[3]);
@@ -22404,8 +22404,8 @@ class Oj extends EventTarget {
22404
22404
  if (t.pointerType === "mouse") {
22405
22405
  const s = this._pointerUpTimestamp[t.button];
22406
22406
  if (s > 0 && ((i = t.source) == null ? void 0 : i.timeStamp) !== void 0) {
22407
- const r = s - t.source.timeStamp;
22408
- if (r < 30 && r > 0) {
22407
+ const r = t.source.timeStamp - s;
22408
+ if (r < 60 && r >= 0) {
22409
22409
  $r && console.log("Ignoring mouse.down for touch.up");
22410
22410
  return;
22411
22411
  }
@@ -45273,7 +45273,7 @@ class Sb {
45273
45273
  u(this, "lightmapScaleOffsetUniform", { value: new At(1, 1, 0, 0) });
45274
45274
  u(this, "lightmapUniform", { value: null });
45275
45275
  u(this, "onBeforeCompile", (e, t) => {
45276
- CS && console.log("Lightmaps, before compile"), e.lightMapUv = "uv1", this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset, this.lightmapUniform.value = this.lightmapTexture, e.uniforms.lightmap = this.lightmapUniform, e.uniforms.lightmapScaleOffset = this.lightmapScaleOffsetUniform;
45276
+ CS && console.log("Lightmaps, before compile", e), e.lightMapUv = "uv1", this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset, this.lightmapUniform.value = this.lightmapTexture, e.uniforms.lightmapScaleOffset = this.lightmapScaleOffsetUniform;
45277
45277
  });
45278
45278
  this.gameObject = e, this.context = t;
45279
45279
  }
@@ -45288,7 +45288,7 @@ class Sb {
45288
45288
  }
45289
45289
  updateLightmapUniforms(e) {
45290
45290
  const t = e.uniforms;
45291
- t && t.lightmap && (this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset, this.lightmapUniform.value = this.lightmapTexture, t.lightmap = this.lightmapUniform, t.lightmapScaleOffset = this.lightmapScaleOffsetUniform);
45291
+ t && t.lightmap && (this.lightmapScaleOffsetUniform.value = this.lightmapScaleOffset, t.lightmapScaleOffset = this.lightmapScaleOffsetUniform);
45292
45292
  }
45293
45293
  applyLightmap() {
45294
45294
  if (this.gameObject.type === "Object3D") {
@@ -45311,9 +45311,9 @@ class Sb {
45311
45311
  const t = this.gameObject.material.clone();
45312
45312
  this.gameObject.material = t, this.gameObject.material.onBeforeCompile = this.onBeforeCompile;
45313
45313
  }
45314
- if (this.lightmapIndex >= 0) {
45315
- const t = this.lightmapTexture, i = this.gameObject.material;
45316
- i && t && (i.uniforms || (i.uniforms = {}), i.lightMap = t, i.uniforms.lightmap = { value: t });
45314
+ if (this.lightmapIndex >= 0 && this.lightmapTexture) {
45315
+ const t = this.gameObject.material;
45316
+ t && (t.lightMap = this.lightmapTexture, t.needsUpdate = !0);
45317
45317
  }
45318
45318
  }
45319
45319
  setLightmapDebugMaterial() {
@@ -45327,7 +45327,7 @@ class Sb {
45327
45327
  }
45328
45328
  `,
45329
45329
  fragmentShader: `
45330
- uniform sampler2D lightmap;
45330
+ uniform sampler2D lightMap;
45331
45331
  uniform float lightMapIntensity;
45332
45332
  uniform vec4 lightmapScaleOffset;
45333
45333
  varying vec2 vUv1;
@@ -45340,11 +45340,11 @@ class Sb {
45340
45340
  void main() {
45341
45341
  vec2 lUv = vUv1.xy * lightmapScaleOffset.xy + vec2(lightmapScaleOffset.z, (1. - (lightmapScaleOffset.y + lightmapScaleOffset.w)));
45342
45342
 
45343
- vec4 lightMapTexel = texture2D( lightmap, lUv);
45343
+ vec4 lightMapTexel = texture2D( lightMap, lUv);
45344
45344
  // The range of RGBM lightmaps goes from 0 to 34.49 (5^2.2) in linear space, and from 0 to 5 in gamma space.
45345
- //lightMapTexel.rgb *= lightMapTexel.a * 8.; // no idea where that "8" comes from... heuristically derived
45346
- //lightMapTexel.a = 1.;
45347
- //lightMapTexel = conv_sRGBToLinear(lightMapTexel);
45345
+ // lightMapTexel.rgb *= lightMapTexel.a * 8.; // no idea where that "8" comes from... heuristically derived
45346
+ // lightMapTexel.a = 1.;
45347
+ // lightMapTexel = conv_sRGBToLinear(lightMapTexel);
45348
45348
  // lightMapTexel.rgb = vec3(1.);
45349
45349
 
45350
45350
  // gl_FragColor = vec4(vUv1.xy, 0, 1);
@@ -46158,6 +46158,7 @@ const _N = class extends we {
46158
46158
  var e;
46159
46159
  return (e = this._lightmaps) != null && e.length ? this._lightmaps[0].lightmap : null;
46160
46160
  }
46161
+ /** set undefined to return to default lightmap */
46161
46162
  set lightmap(e) {
46162
46163
  var t;
46163
46164
  if (this._lightmapTextureOverride = e, e === void 0 && (e = this.context.lightmaps.tryGetLightmap(this.sourceId, this.lightmapIndex)), (t = this._lightmaps) != null && t.length)
@@ -60309,6 +60310,21 @@ const Vn = class extends we {
60309
60310
  break;
60310
60311
  }
60311
60312
  }
60313
+ raycastUpdate(t, i) {
60314
+ const s = this.showRaycastLine && this.type !== 1;
60315
+ if (this.type === 1)
60316
+ t.visible = !1;
60317
+ else if (this.isUsingHands) {
60318
+ t.visible = !this.grabbed && s, An(t, i);
60319
+ const r = this.hand.joints;
60320
+ if (r && r.wrist && this.grabbed && this.grabbed.isCloseGrab) {
60321
+ const a = this.getWristQuaternion();
60322
+ a && this.rayRotation.copy(a);
60323
+ }
60324
+ zr(t, this.rayRotation);
60325
+ } else
60326
+ t.visible = s, zr(t, this.rayRotation), An(t, i);
60327
+ }
60312
60328
  update() {
60313
60329
  this.context.time.frameCount % 60 === 0 && (this.setControllerLayers(this.controller, 2), this.setControllerLayers(this.controllerGrip, 2), this.setControllerLayers(this.hand, 2));
60314
60330
  const t = Vn.eventSubs.update;
@@ -60318,22 +60334,7 @@ const Vn = class extends we {
60318
60334
  let i = 1;
60319
60335
  this.type === 0 ? i = this.context.time.deltaTime / 0.1 : this.isUsingHands && this.handPointerModel.pinched && (i = this.context.time.deltaTime / 0.3), this.rayRotation.slerp(Xn(this.controller), this.useSmoothing ? i : 1);
60320
60336
  const s = wt(this.controller);
60321
- if (this.isUsingHands && this.handPointerModel.cursorObject && (this.handPointerModel.cursorObject.visible = !1), this.raycastLine) {
60322
- const r = this.showRaycastLine && this.type !== 1;
60323
- if (this.type === 1)
60324
- this.raycastLine.visible = !1;
60325
- else if (this.isUsingHands) {
60326
- this.raycastLine.visible = !this.grabbed && r, An(this.raycastLine, s);
60327
- const o = this.hand.joints;
60328
- if (o && o.wrist && this.grabbed && this.grabbed.isCloseGrab) {
60329
- const l = this.getWristQuaternion();
60330
- l && this.rayRotation.copy(l);
60331
- }
60332
- zr(this.raycastLine, this.rayRotation);
60333
- } else
60334
- this.raycastLine.visible = r, zr(this.raycastLine, this.rayRotation), An(this.raycastLine, s);
60335
- }
60336
- this.lastHit = this.updateLastHit(), this.grabbed && this.grabbed.update(), this._selectionPressedLastFrame = this._selectionPressed, this.selectStartCallback && this.selectStartCallback();
60337
+ this.isUsingHands && this.handPointerModel.cursorObject && (this.handPointerModel.cursorObject.visible = !1), this.raycastLine && this.raycastUpdate(this.raycastLine, s), this.lastHit = this.updateLastHit(), this.grabbed && this.grabbed.update(), this._selectionPressedLastFrame = this._selectionPressed, this.selectStartCallback && this.selectStartCallback();
60337
60338
  }
60338
60339
  onUpdate(t) {
60339
60340
  var r, o;
@@ -60350,25 +60351,31 @@ const Vn = class extends we {
60350
60351
  const s = (o = (r = this.input) == null ? void 0 : r.gamepad) == null ? void 0 : o.buttons;
60351
60352
  switch (this.input.handedness) {
60352
60353
  case "left":
60353
- const a = 3 * Vn.MovementSpeedFactor, l = 2, c = tt.clamp01(this.joystick.length() * 2), h = this.joystick.x > 0 ? 1 : -1;
60354
- let d = Math.pow(this.joystick.x, l);
60355
- d *= h, d *= c;
60356
- const f = this.joystick.y > 0 ? 1 : -1;
60357
- let p = Math.pow(this.joystick.y, l);
60358
- p *= f, d *= c, i.getWorldQuaternion(this.worldRot), this.movementVector.set(d, 0, p), this.movementVector.applyQuaternion(this.webXR.TransformOrientation), this.movementVector.y = 0, this.movementVector.applyQuaternion(this.worldRot), this.movementVector.multiplyScalar(a * this.context.time.deltaTime), i.position.add(this.movementVector), this.isUsingHands && this.runTeleport(i, s);
60354
+ this.movementUpdate(i, s);
60359
60355
  break;
60360
60356
  case "right":
60361
- const m = this.joystick.x, A = Math.abs(m);
60362
- if (A < 0.4)
60363
- this.didRotate = !1;
60364
- else if (A > 0.5 && !this.didRotate) {
60365
- const v = m > 0 ? -1 : 1;
60366
- i.rotateY(tt.toRadians(30 * v)), this.didRotate = !0;
60367
- }
60368
- this.runTeleport(i, s);
60357
+ this.rotationUpdate(i, s);
60369
60358
  break;
60370
60359
  }
60371
60360
  }
60361
+ movementUpdate(t, i) {
60362
+ const s = 3 * Vn.MovementSpeedFactor, r = 2, o = tt.clamp01(this.joystick.length() * 2), a = this.joystick.x > 0 ? 1 : -1;
60363
+ let l = Math.pow(this.joystick.x, r);
60364
+ l *= a, l *= o;
60365
+ const c = this.joystick.y > 0 ? 1 : -1;
60366
+ let h = Math.pow(this.joystick.y, r);
60367
+ h *= c, l *= o, t.getWorldQuaternion(this.worldRot), this.movementVector.set(l, 0, h), this.movementVector.applyQuaternion(this.webXR.TransformOrientation), this.movementVector.y = 0, this.movementVector.applyQuaternion(this.worldRot), this.movementVector.multiplyScalar(s * this.context.time.deltaTime), t.position.add(this.movementVector), this.isUsingHands && this.runTeleport(t, i);
60368
+ }
60369
+ rotationUpdate(t, i) {
60370
+ const s = this.joystick.x, r = Math.abs(s);
60371
+ if (r < 0.4)
60372
+ this.didRotate = !1;
60373
+ else if (r > 0.5 && !this.didRotate) {
60374
+ const o = s > 0 ? -1 : 1;
60375
+ t.rotateY(tt.toRadians(30 * o)), this.didRotate = !0;
60376
+ }
60377
+ this.runTeleport(t, i);
60378
+ }
60372
60379
  runTeleport(t, i) {
60373
60380
  var l, c, h;
60374
60381
  let s = -this.joystick.y;
@@ -60385,16 +60392,10 @@ const Vn = class extends we {
60385
60392
  if (f.pressed && !this.didChangeScale && this.webXR.IsInVR) {
60386
60393
  this.didChangeScale = !0;
60387
60394
  const p = this.webXR.Rig;
60388
- if (p)
60389
- if (o) {
60390
- o = !1, p.scale.set(1, 1, 1), a = 1, Vn.MovementSpeedFactor = 1;
60391
- const m = this.context.mainCamera;
60392
- Vn.PreviousCameraFarDistance && (m.far = Vn.PreviousCameraFarDistance);
60393
- } else {
60394
- o = !0, r = !0, a = 0.1, Vn.MovementSpeedFactor = a * 2;
60395
- const m = this.context.mainCamera;
60396
- Vn.PreviousCameraFarDistance = m.far, m.far /= a;
60397
- }
60395
+ if (p) {
60396
+ let m = this.switchScale(p, r, o, a);
60397
+ r = m.doTeleport, o = m.isInMiniatureMode, a = m.newRigScale;
60398
+ }
60398
60399
  } else
60399
60400
  f.pressed || (this.didChangeScale = !1);
60400
60401
  }
@@ -60416,6 +60417,18 @@ const Vn = class extends we {
60416
60417
  isValidTeleportTarget(t) {
60417
60418
  return ee.getComponentInParent(t, AI) != null;
60418
60419
  }
60420
+ switchScale(t, i, s, r) {
60421
+ if (s) {
60422
+ s = !1, t.scale.set(1, 1, 1), r = 1, Vn.MovementSpeedFactor = 1;
60423
+ const o = this.context.mainCamera;
60424
+ Vn.PreviousCameraFarDistance && (o.far = Vn.PreviousCameraFarDistance);
60425
+ } else {
60426
+ s = !0, i = !0, r = 0.1, Vn.MovementSpeedFactor = r * 2;
60427
+ const o = this.context.mainCamera;
60428
+ Vn.PreviousCameraFarDistance = o.far, o.far /= r;
60429
+ }
60430
+ return { doTeleport: i, isInMiniatureMode: s, newRigScale: r };
60431
+ }
60419
60432
  updateStick(t) {
60420
60433
  var i;
60421
60434
  !t || !t.gamepad || ((i = t.gamepad.axes) == null ? void 0 : i.length) < 4 || (this.joystick.x = t.gamepad.axes[2], this.joystick.y = t.gamepad.axes[3]);