@inweb/viewer-three 27.2.2 → 27.2.4
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 +2 -30
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +1 -1
- package/dist/viewer-three.module.js +3 -31
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/controls/WalkControls.d.ts +0 -8
- package/package.json +5 -5
- package/src/Viewer/controls/WalkControls.ts +3 -41
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { draggersRegistry, commandsRegistry, Options, componentsRegistry, Info, Loader, loadersRegistry, CANVAS_EVENTS } from '@inweb/viewer-core';
|
|
25
25
|
export * from '@inweb/viewer-core';
|
|
26
|
-
import { Line, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide, EventDispatcher, Vector3, MOUSE, TOUCH, Spherical, Quaternion, Vector2, Plane, Object3D, Line3, Raycaster, MathUtils, EdgesGeometry, Matrix4, Vector4, Controls,
|
|
26
|
+
import { Line, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide, EventDispatcher, Vector3, MOUSE, TOUCH, Spherical, Quaternion, Vector2, Plane, Object3D, Line3, Raycaster, MathUtils, EdgesGeometry, Matrix4, Vector4, Controls, Clock, Box3, Color, PerspectiveCamera, OrthographicCamera, AmbientLight, DirectionalLight, HemisphereLight, REVISION, MeshPhongMaterial, WebGLRenderTarget, UnsignedByteType, RGBAFormat, CylinderGeometry, Sprite, CanvasTexture, SRGBColorSpace, SpriteMaterial, TextureLoader, BufferAttribute, PointsMaterial, Points, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, LineLoop, Group, NormalBlending, LoadingManager, LoaderUtils, FileLoader, UniformsUtils, ShaderMaterial, AdditiveBlending, HalfFloatType, Scene, WebGLRenderer, LinearSRGBColorSpace } from 'three';
|
|
27
27
|
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
|
|
28
28
|
import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry.js';
|
|
29
29
|
import { Wireframe } from 'three/examples/jsm/lines/Wireframe.js';
|
|
@@ -1544,12 +1544,6 @@ class WalkControls extends Controls {
|
|
|
1544
1544
|
this.movementSpeed = 0.1;
|
|
1545
1545
|
this.multiplier = 3;
|
|
1546
1546
|
this.groundFollowingSkippedFrames = 0;
|
|
1547
|
-
this.GROUND_BOX_HALF_SIZE = 20;
|
|
1548
|
-
this.GROUND_BOX_REFRESH_THRESHOLD = 0.3;
|
|
1549
|
-
this._groundObjectBoxes = new Map();
|
|
1550
|
-
this._activeGroundObjects = [];
|
|
1551
|
-
this._groundBox = new Box3();
|
|
1552
|
-
this._groundBoxCenter = new Vector3();
|
|
1553
1547
|
this.moveWheel = 0;
|
|
1554
1548
|
this.mouseDragOn = false;
|
|
1555
1549
|
this._up = new Vector3();
|
|
@@ -1621,9 +1615,6 @@ class WalkControls extends Controls {
|
|
|
1621
1615
|
};
|
|
1622
1616
|
this.camera = camera;
|
|
1623
1617
|
this.groundObjects = groundObjects;
|
|
1624
|
-
for (const obj of groundObjects) {
|
|
1625
|
-
this._groundObjectBoxes.set(obj, new Box3().setFromObject(obj));
|
|
1626
|
-
}
|
|
1627
1618
|
this.raycaster = new Raycaster();
|
|
1628
1619
|
this.raycaster.near = 0;
|
|
1629
1620
|
this.raycaster.far = this.EYE_HEIGHT + this.FAILING_DISTANCE;
|
|
@@ -1658,29 +1649,10 @@ class WalkControls extends Controls {
|
|
|
1658
1649
|
window.removeEventListener("keyup", this.onKeyUp);
|
|
1659
1650
|
super.dispose();
|
|
1660
1651
|
}
|
|
1661
|
-
_rebuildGroundBox(center) {
|
|
1662
|
-
const h = this.GROUND_BOX_HALF_SIZE;
|
|
1663
|
-
this._groundBoxCenter.copy(center);
|
|
1664
|
-
this._groundBox.set(new Vector3(center.x - h, center.y - h * 4, center.z - h), new Vector3(center.x + h, center.y + h * 4, center.z + h));
|
|
1665
|
-
this._activeGroundObjects = this.groundObjects.filter((obj) => {
|
|
1666
|
-
const objectBox = this._groundObjectBoxes.get(obj);
|
|
1667
|
-
return objectBox !== undefined && this._groundBox.intersectsBox(objectBox);
|
|
1668
|
-
});
|
|
1669
|
-
}
|
|
1670
|
-
_needsGroundBoxRebuild(pos) {
|
|
1671
|
-
if (this._activeGroundObjects.length === 0 && this.groundObjects.length > 0)
|
|
1672
|
-
return true;
|
|
1673
|
-
const threshold = this.GROUND_BOX_HALF_SIZE * this.GROUND_BOX_REFRESH_THRESHOLD;
|
|
1674
|
-
return (Math.abs(pos.x - this._groundBoxCenter.x) > threshold || Math.abs(pos.z - this._groundBoxCenter.z) > threshold);
|
|
1675
|
-
}
|
|
1676
1652
|
updateGroundFollowing() {
|
|
1677
|
-
const pos = this.object.position;
|
|
1678
|
-
if (this._needsGroundBoxRebuild(pos)) {
|
|
1679
|
-
this._rebuildGroundBox(pos);
|
|
1680
|
-
}
|
|
1681
1653
|
this._up.copy(this.camera.up).negate();
|
|
1682
|
-
this.raycaster.set(
|
|
1683
|
-
const intersects = this.raycaster.intersectObjects(this.
|
|
1654
|
+
this.raycaster.set(this.object.position, this._up);
|
|
1655
|
+
const intersects = this.raycaster.intersectObjects(this.groundObjects, false);
|
|
1684
1656
|
if (intersects.length > 0) {
|
|
1685
1657
|
const groundY = intersects[0].point.y;
|
|
1686
1658
|
const targetY = groundY + this.EYE_HEIGHT;
|