@inweb/viewer-three 27.1.8 → 27.2.0

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.
@@ -35108,14 +35108,19 @@ void main() {
35108
35108
  super(camera, canvas);
35109
35109
  this.EYE_HEIGHT = 1.7;
35110
35110
  this.FAILING_DISTANCE = 2;
35111
- this.GROUND_FOLLOWING_SPEED = 0.05;
35111
+ this.GROUND_FOLLOWING_SKIP_FRAMES = 3;
35112
+ this.GROUND_FOLLOWING_SPEED = 0.4;
35112
35113
  this.LOOK_SPEED = 0.1;
35113
35114
  this.WALK_SPEED_DELIMITER = 4;
35114
35115
  this.WHEEL_SPEED_DELIMITER = 15000;
35115
35116
  this.movementSpeed = 0.1;
35116
35117
  this.multiplier = 3;
35118
+ this.groundFollowingSkippedFrames = 0;
35117
35119
  this.moveWheel = 0;
35118
35120
  this.mouseDragOn = false;
35121
+ this._up = new Vector3();
35122
+ this._forward = new Vector3();
35123
+ this._sideways = new Vector3();
35119
35124
  this.onPointerDown = (event) => {
35120
35125
  if (event.button !== 0)
35121
35126
  return;
@@ -35185,6 +35190,14 @@ void main() {
35185
35190
  this.raycaster = new Raycaster();
35186
35191
  this.raycaster.near = 0;
35187
35192
  this.raycaster.far = this.EYE_HEIGHT + this.FAILING_DISTANCE;
35193
+ this.raycaster.params = {
35194
+ Mesh: {},
35195
+ Line: { threshold: 0 },
35196
+ Line2: { threshold: 0 },
35197
+ LOD: { threshold: 0 },
35198
+ Points: { threshold: 0 },
35199
+ Sprite: { threshold: 0 },
35200
+ };
35188
35201
  this.moveKeys = new Set();
35189
35202
  this.moveClock = new Clock();
35190
35203
  this.quaternion = camera.quaternion.clone();
@@ -35209,16 +35222,8 @@ void main() {
35209
35222
  super.dispose();
35210
35223
  }
35211
35224
  updateGroundFollowing() {
35212
- const up = new Vector3().copy(this.camera.up);
35213
- this.raycaster.set(this.object.position, up.negate());
35214
- this.raycaster.params = this.raycaster.params = {
35215
- Mesh: {},
35216
- Line: { threshold: 0 },
35217
- Line2: { threshold: 0 },
35218
- LOD: { threshold: 0 },
35219
- Points: { threshold: 0 },
35220
- Sprite: { threshold: 0 },
35221
- };
35225
+ this._up.copy(this.camera.up).negate();
35226
+ this.raycaster.set(this.object.position, this._up);
35222
35227
  const intersects = this.raycaster.intersectObjects(this.groundObjects, false);
35223
35228
  if (intersects.length > 0) {
35224
35229
  const groundY = intersects[0].point.y;
@@ -35229,8 +35234,8 @@ void main() {
35229
35234
  update() {
35230
35235
  let moved = false;
35231
35236
  let upgradeGroundFollowing = false;
35232
- const forward = new Vector3();
35233
- const sideways = new Vector3();
35237
+ const forward = this._forward;
35238
+ const sideways = this._sideways;
35234
35239
  if (this.moveKeys.size > 0) {
35235
35240
  upgradeGroundFollowing = true;
35236
35241
  const timeDelta = this.moveClock.getDelta();
@@ -35282,8 +35287,11 @@ void main() {
35282
35287
  this.moveWheel += -1 * Math.sign(this.moveWheel);
35283
35288
  moved = true;
35284
35289
  }
35285
- if (upgradeGroundFollowing)
35290
+ this.groundFollowingSkippedFrames++;
35291
+ if (upgradeGroundFollowing && this.groundFollowingSkippedFrames >= this.GROUND_FOLLOWING_SKIP_FRAMES) {
35292
+ this.groundFollowingSkippedFrames = 0;
35286
35293
  this.updateGroundFollowing();
35294
+ }
35287
35295
  if (moved) {
35288
35296
  this.dispatchEvent({ type: "change" });
35289
35297
  }