@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.
- 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
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
99
99
|
*
|
|
100
100
|
* @param file - File to load. Can be:
|
|
101
101
|
*
|
|
102
|
-
* - `File`, `Assembly
|
|
102
|
+
* - `File`, `Assembly`, or `Model` instance from the Open Cloud Server
|
|
103
103
|
* - `URL` string
|
|
104
104
|
* - {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string
|
|
105
105
|
* - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
|
|
@@ -11,12 +11,14 @@ interface WalkControlsEventMap {
|
|
|
11
11
|
export declare class WalkControls extends Controls<WalkControlsEventMap> {
|
|
12
12
|
readonly EYE_HEIGHT = 1.7;
|
|
13
13
|
readonly FAILING_DISTANCE = 2;
|
|
14
|
-
readonly
|
|
14
|
+
readonly GROUND_FOLLOWING_SKIP_FRAMES = 3;
|
|
15
|
+
readonly GROUND_FOLLOWING_SPEED = 0.4;
|
|
15
16
|
readonly LOOK_SPEED = 0.1;
|
|
16
17
|
readonly WALK_SPEED_DELIMITER = 4;
|
|
17
18
|
readonly WHEEL_SPEED_DELIMITER = 15000;
|
|
18
19
|
movementSpeed: number;
|
|
19
20
|
multiplier: number;
|
|
21
|
+
private groundFollowingSkippedFrames;
|
|
20
22
|
private raycaster;
|
|
21
23
|
private groundObjects;
|
|
22
24
|
private moveKeys;
|
|
@@ -27,6 +29,9 @@ export declare class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
27
29
|
private mouseDragOn;
|
|
28
30
|
rotateDelta: Vector2;
|
|
29
31
|
private camera;
|
|
32
|
+
private readonly _up;
|
|
33
|
+
private readonly _forward;
|
|
34
|
+
private readonly _sideways;
|
|
30
35
|
constructor(camera: Camera, canvas: HTMLElement, groundObjects: Object3D[]);
|
|
31
36
|
dispose(): void;
|
|
32
37
|
onPointerDown: (event: PointerEvent) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "27.
|
|
3
|
+
"version": "27.2.0",
|
|
4
4
|
"description": "JavaScript library for rendering CAD and BIM files in a browser using Three.js",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"docs": "typedoc"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@inweb/client": "~27.
|
|
39
|
-
"@inweb/eventemitter2": "~27.
|
|
40
|
-
"@inweb/markup": "~27.
|
|
41
|
-
"@inweb/viewer-core": "~27.
|
|
38
|
+
"@inweb/client": "~27.2.0",
|
|
39
|
+
"@inweb/eventemitter2": "~27.2.0",
|
|
40
|
+
"@inweb/markup": "~27.2.0",
|
|
41
|
+
"@inweb/viewer-core": "~27.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@streamparser/json": "^0.0.22",
|
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -389,7 +389,7 @@ export class Viewer
|
|
|
389
389
|
*
|
|
390
390
|
* @param file - File to load. Can be:
|
|
391
391
|
*
|
|
392
|
-
* - `File`, `Assembly
|
|
392
|
+
* - `File`, `Assembly`, or `Model` instance from the Open Cloud Server
|
|
393
393
|
* - `URL` string
|
|
394
394
|
* - {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string
|
|
395
395
|
* - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
|
|
@@ -31,13 +31,15 @@ interface WalkControlsEventMap {
|
|
|
31
31
|
export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
32
32
|
readonly EYE_HEIGHT = 1.7;
|
|
33
33
|
readonly FAILING_DISTANCE = 2;
|
|
34
|
-
readonly
|
|
34
|
+
readonly GROUND_FOLLOWING_SKIP_FRAMES = 3;
|
|
35
|
+
readonly GROUND_FOLLOWING_SPEED = 0.4;
|
|
35
36
|
readonly LOOK_SPEED = 0.1;
|
|
36
37
|
readonly WALK_SPEED_DELIMITER = 4;
|
|
37
38
|
readonly WHEEL_SPEED_DELIMITER = 15000;
|
|
38
39
|
|
|
39
40
|
public movementSpeed = 0.1;
|
|
40
41
|
public multiplier = 3;
|
|
42
|
+
private groundFollowingSkippedFrames = 0;
|
|
41
43
|
|
|
42
44
|
private raycaster: Raycaster;
|
|
43
45
|
private groundObjects: Object3D[];
|
|
@@ -53,6 +55,10 @@ export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
53
55
|
|
|
54
56
|
private camera: Camera;
|
|
55
57
|
|
|
58
|
+
private readonly _up = new Vector3();
|
|
59
|
+
private readonly _forward = new Vector3();
|
|
60
|
+
private readonly _sideways = new Vector3();
|
|
61
|
+
|
|
56
62
|
constructor(camera: Camera, canvas: HTMLElement, groundObjects: Object3D[]) {
|
|
57
63
|
super(camera, canvas);
|
|
58
64
|
this.camera = camera;
|
|
@@ -61,6 +67,14 @@ export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
61
67
|
this.raycaster = new Raycaster();
|
|
62
68
|
this.raycaster.near = 0;
|
|
63
69
|
this.raycaster.far = this.EYE_HEIGHT + this.FAILING_DISTANCE;
|
|
70
|
+
this.raycaster.params = {
|
|
71
|
+
Mesh: {},
|
|
72
|
+
Line: { threshold: 0 },
|
|
73
|
+
Line2: { threshold: 0 },
|
|
74
|
+
LOD: { threshold: 0 },
|
|
75
|
+
Points: { threshold: 0 },
|
|
76
|
+
Sprite: { threshold: 0 },
|
|
77
|
+
};
|
|
64
78
|
|
|
65
79
|
this.moveKeys = new Set();
|
|
66
80
|
this.moveClock = new Clock();
|
|
@@ -165,17 +179,8 @@ export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
165
179
|
};
|
|
166
180
|
|
|
167
181
|
private updateGroundFollowing() {
|
|
168
|
-
|
|
169
|
-
this.raycaster.set(this.object.position,
|
|
170
|
-
|
|
171
|
-
this.raycaster.params = this.raycaster.params = {
|
|
172
|
-
Mesh: {},
|
|
173
|
-
Line: { threshold: 0 },
|
|
174
|
-
Line2: { threshold: 0 },
|
|
175
|
-
LOD: { threshold: 0 },
|
|
176
|
-
Points: { threshold: 0 },
|
|
177
|
-
Sprite: { threshold: 0 },
|
|
178
|
-
};
|
|
182
|
+
this._up.copy(this.camera.up).negate();
|
|
183
|
+
this.raycaster.set(this.object.position, this._up);
|
|
179
184
|
|
|
180
185
|
const intersects = this.raycaster.intersectObjects(this.groundObjects, false);
|
|
181
186
|
if (intersects.length > 0) {
|
|
@@ -190,8 +195,8 @@ export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
190
195
|
override update() {
|
|
191
196
|
let moved = false;
|
|
192
197
|
let upgradeGroundFollowing = false;
|
|
193
|
-
const forward =
|
|
194
|
-
const sideways =
|
|
198
|
+
const forward = this._forward;
|
|
199
|
+
const sideways = this._sideways;
|
|
195
200
|
|
|
196
201
|
if (this.moveKeys.size > 0) {
|
|
197
202
|
upgradeGroundFollowing = true;
|
|
@@ -252,7 +257,11 @@ export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
252
257
|
moved = true;
|
|
253
258
|
}
|
|
254
259
|
|
|
255
|
-
|
|
260
|
+
this.groundFollowingSkippedFrames++;
|
|
261
|
+
if (upgradeGroundFollowing && this.groundFollowingSkippedFrames >= this.GROUND_FOLLOWING_SKIP_FRAMES) {
|
|
262
|
+
this.groundFollowingSkippedFrames = 0;
|
|
263
|
+
this.updateGroundFollowing();
|
|
264
|
+
}
|
|
256
265
|
|
|
257
266
|
if (moved) {
|
|
258
267
|
this.dispatchEvent({ type: "change" });
|