@inweb/viewer-three 27.1.9 → 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.
- package/dist/viewer-three.js +22 -14
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +1 -1
- package/dist/viewer-three.module.js +22 -14
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +1 -1
- package/lib/Viewer/controls/WalkControls.d.ts +6 -1
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +1 -1
- package/src/Viewer/controls/WalkControls.ts +24 -15
|
@@ -1506,14 +1506,19 @@ class WalkControls extends Controls {
|
|
|
1506
1506
|
super(camera, canvas);
|
|
1507
1507
|
this.EYE_HEIGHT = 1.7;
|
|
1508
1508
|
this.FAILING_DISTANCE = 2;
|
|
1509
|
-
this.
|
|
1509
|
+
this.GROUND_FOLLOWING_SKIP_FRAMES = 3;
|
|
1510
|
+
this.GROUND_FOLLOWING_SPEED = 0.4;
|
|
1510
1511
|
this.LOOK_SPEED = 0.1;
|
|
1511
1512
|
this.WALK_SPEED_DELIMITER = 4;
|
|
1512
1513
|
this.WHEEL_SPEED_DELIMITER = 15000;
|
|
1513
1514
|
this.movementSpeed = 0.1;
|
|
1514
1515
|
this.multiplier = 3;
|
|
1516
|
+
this.groundFollowingSkippedFrames = 0;
|
|
1515
1517
|
this.moveWheel = 0;
|
|
1516
1518
|
this.mouseDragOn = false;
|
|
1519
|
+
this._up = new Vector3();
|
|
1520
|
+
this._forward = new Vector3();
|
|
1521
|
+
this._sideways = new Vector3();
|
|
1517
1522
|
this.onPointerDown = (event) => {
|
|
1518
1523
|
if (event.button !== 0)
|
|
1519
1524
|
return;
|
|
@@ -1583,6 +1588,14 @@ class WalkControls extends Controls {
|
|
|
1583
1588
|
this.raycaster = new Raycaster();
|
|
1584
1589
|
this.raycaster.near = 0;
|
|
1585
1590
|
this.raycaster.far = this.EYE_HEIGHT + this.FAILING_DISTANCE;
|
|
1591
|
+
this.raycaster.params = {
|
|
1592
|
+
Mesh: {},
|
|
1593
|
+
Line: { threshold: 0 },
|
|
1594
|
+
Line2: { threshold: 0 },
|
|
1595
|
+
LOD: { threshold: 0 },
|
|
1596
|
+
Points: { threshold: 0 },
|
|
1597
|
+
Sprite: { threshold: 0 },
|
|
1598
|
+
};
|
|
1586
1599
|
this.moveKeys = new Set();
|
|
1587
1600
|
this.moveClock = new Clock();
|
|
1588
1601
|
this.quaternion = camera.quaternion.clone();
|
|
@@ -1607,16 +1620,8 @@ class WalkControls extends Controls {
|
|
|
1607
1620
|
super.dispose();
|
|
1608
1621
|
}
|
|
1609
1622
|
updateGroundFollowing() {
|
|
1610
|
-
|
|
1611
|
-
this.raycaster.set(this.object.position,
|
|
1612
|
-
this.raycaster.params = this.raycaster.params = {
|
|
1613
|
-
Mesh: {},
|
|
1614
|
-
Line: { threshold: 0 },
|
|
1615
|
-
Line2: { threshold: 0 },
|
|
1616
|
-
LOD: { threshold: 0 },
|
|
1617
|
-
Points: { threshold: 0 },
|
|
1618
|
-
Sprite: { threshold: 0 },
|
|
1619
|
-
};
|
|
1623
|
+
this._up.copy(this.camera.up).negate();
|
|
1624
|
+
this.raycaster.set(this.object.position, this._up);
|
|
1620
1625
|
const intersects = this.raycaster.intersectObjects(this.groundObjects, false);
|
|
1621
1626
|
if (intersects.length > 0) {
|
|
1622
1627
|
const groundY = intersects[0].point.y;
|
|
@@ -1627,8 +1632,8 @@ class WalkControls extends Controls {
|
|
|
1627
1632
|
update() {
|
|
1628
1633
|
let moved = false;
|
|
1629
1634
|
let upgradeGroundFollowing = false;
|
|
1630
|
-
const forward =
|
|
1631
|
-
const sideways =
|
|
1635
|
+
const forward = this._forward;
|
|
1636
|
+
const sideways = this._sideways;
|
|
1632
1637
|
if (this.moveKeys.size > 0) {
|
|
1633
1638
|
upgradeGroundFollowing = true;
|
|
1634
1639
|
const timeDelta = this.moveClock.getDelta();
|
|
@@ -1680,8 +1685,11 @@ class WalkControls extends Controls {
|
|
|
1680
1685
|
this.moveWheel += -1 * Math.sign(this.moveWheel);
|
|
1681
1686
|
moved = true;
|
|
1682
1687
|
}
|
|
1683
|
-
|
|
1688
|
+
this.groundFollowingSkippedFrames++;
|
|
1689
|
+
if (upgradeGroundFollowing && this.groundFollowingSkippedFrames >= this.GROUND_FOLLOWING_SKIP_FRAMES) {
|
|
1690
|
+
this.groundFollowingSkippedFrames = 0;
|
|
1684
1691
|
this.updateGroundFollowing();
|
|
1692
|
+
}
|
|
1685
1693
|
if (moved) {
|
|
1686
1694
|
this.dispatchEvent({ type: "change" });
|
|
1687
1695
|
}
|