@inweb/viewer-three 26.9.4 → 26.9.6

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.
@@ -1251,7 +1251,7 @@ class PanDragger extends OrbitDragger {
1251
1251
  }
1252
1252
 
1253
1253
  class WalkControls extends Controls {
1254
- constructor(camera, canvas, groundObjects, viewer) {
1254
+ constructor(camera, canvas, groundObjects) {
1255
1255
  super(camera, canvas);
1256
1256
  this.EYE_HEIGHT = 1.7;
1257
1257
  this.FAILING_DISTANCE = 2;
@@ -1327,11 +1327,7 @@ class WalkControls extends Controls {
1327
1327
  if (this.moveKeys.delete(event.code))
1328
1328
  this.update();
1329
1329
  };
1330
- this.initHighlighter = () => {
1331
- this.highlighter = this.viewer.getComponent("HighlighterComponent");
1332
- };
1333
1330
  this.camera = camera;
1334
- this.viewer = viewer;
1335
1331
  this.groundObjects = groundObjects;
1336
1332
  this.raycaster = new Raycaster();
1337
1333
  this.raycaster.near = 0;
@@ -1360,7 +1356,8 @@ class WalkControls extends Controls {
1360
1356
  super.dispose();
1361
1357
  }
1362
1358
  updateGroundFollowing() {
1363
- this.raycaster.set(this.object.position, new Vector3(0, -1, 0));
1359
+ const up = new Vector3().copy(this.camera.up);
1360
+ this.raycaster.set(this.object.position, up.negate());
1364
1361
  this.raycaster.params = this.raycaster.params = {
1365
1362
  Mesh: {},
1366
1363
  Line: { threshold: 0 },
@@ -1376,20 +1373,6 @@ class WalkControls extends Controls {
1376
1373
  this.object.position.y = MathUtils.lerp(this.object.position.y, targetY, this.GROUND_FOLLOWING_SPEED);
1377
1374
  }
1378
1375
  }
1379
- select(objects, model) {
1380
- if (!model) {
1381
- this.viewer.models.forEach((model) => this.select(objects, model));
1382
- return;
1383
- }
1384
- if (!Array.isArray(objects))
1385
- objects = [objects];
1386
- if (!objects.length)
1387
- return;
1388
- model.showOriginalObjects(objects);
1389
- this.highlighter.highlight(objects);
1390
- objects.forEach((object) => this.viewer.selected.push(object));
1391
- objects.forEach((object) => (object.isSelected = true));
1392
- }
1393
1376
  update() {
1394
1377
  let moved = false;
1395
1378
  let upgradeGroundFollowing = false;
@@ -1489,14 +1472,12 @@ class WalkDragger {
1489
1472
  this.controls.rotateDelta.set(0, 0);
1490
1473
  };
1491
1474
  const meshOnlyGround = [];
1492
- viewer.models[0].getObjects().forEach((obj) => {
1493
- obj.traverse((child) => {
1494
- if (child instanceof Mesh) {
1495
- meshOnlyGround.push(child);
1496
- }
1497
- });
1498
- });
1499
- this.controls = new WalkControls(viewer.camera, viewer.canvas, meshOnlyGround, viewer);
1475
+ viewer.models.forEach((model) => model.getVisibleObjects().forEach((obj) => {
1476
+ if (obj instanceof Mesh) {
1477
+ meshOnlyGround.push(obj);
1478
+ }
1479
+ }));
1480
+ this.controls = new WalkControls(viewer.camera, viewer.canvas, meshOnlyGround);
1500
1481
  this.controls.addEventListener("change", this.controlsChange);
1501
1482
  this.controls.addEventListener("walkspeedchange", this.walkspeedChange);
1502
1483
  this.viewer = viewer;