@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.
- package/dist/viewer-three.js +9 -28
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +1 -1
- package/dist/viewer-three.module.js +9 -28
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/controls/WalkControls.d.ts +1 -8
- package/package.json +5 -5
- package/src/Viewer/controls/WalkControls.ts +3 -35
- package/src/Viewer/draggers/WalkDragger.ts +7 -7
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { Camera, Controls, Vector2, Object3D } from "three";
|
|
2
|
-
import { Viewer } from "../Viewer";
|
|
3
|
-
import { IModelImpl } from "../models/IModelImpl";
|
|
4
|
-
import { HighlighterComponent } from "../components/HighlighterComponent";
|
|
5
2
|
interface WalkControlsEventMap {
|
|
6
3
|
change: {
|
|
7
4
|
type: "change";
|
|
@@ -30,9 +27,7 @@ export declare class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
30
27
|
private mouseDragOn;
|
|
31
28
|
rotateDelta: Vector2;
|
|
32
29
|
private camera;
|
|
33
|
-
|
|
34
|
-
protected highlighter: HighlighterComponent;
|
|
35
|
-
constructor(camera: Camera, canvas: HTMLElement, groundObjects: Object3D[], viewer: Viewer);
|
|
30
|
+
constructor(camera: Camera, canvas: HTMLElement, groundObjects: Object3D[]);
|
|
36
31
|
dispose(): void;
|
|
37
32
|
onPointerDown: (event: PointerEvent) => void;
|
|
38
33
|
onPointerMove: (event: PointerEvent) => void;
|
|
@@ -42,8 +37,6 @@ export declare class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
42
37
|
onKeyDown: (event: KeyboardEvent) => void;
|
|
43
38
|
onKeyUp: (event: KeyboardEvent) => void;
|
|
44
39
|
private updateGroundFollowing;
|
|
45
|
-
select(objects: Object3D | Object3D[], model?: IModelImpl): void;
|
|
46
|
-
initHighlighter: () => void;
|
|
47
40
|
update(): void;
|
|
48
41
|
rotateCamera(delta: Vector2): void;
|
|
49
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "26.9.
|
|
3
|
+
"version": "26.9.6",
|
|
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": "~26.9.
|
|
39
|
-
"@inweb/eventemitter2": "~26.9.
|
|
40
|
-
"@inweb/markup": "~26.9.
|
|
41
|
-
"@inweb/viewer-core": "~26.9.
|
|
38
|
+
"@inweb/client": "~26.9.6",
|
|
39
|
+
"@inweb/eventemitter2": "~26.9.6",
|
|
40
|
+
"@inweb/markup": "~26.9.6",
|
|
41
|
+
"@inweb/viewer-core": "~26.9.6"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/three": "^0.179.0",
|
|
@@ -22,9 +22,6 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Clock, Camera, Controls, Quaternion, Vector2, Vector3, Raycaster, Object3D, MathUtils } from "three";
|
|
25
|
-
import { Viewer } from "../Viewer";
|
|
26
|
-
import { IModelImpl } from "../models/IModelImpl";
|
|
27
|
-
import { HighlighterComponent } from "../components/HighlighterComponent";
|
|
28
25
|
|
|
29
26
|
interface WalkControlsEventMap {
|
|
30
27
|
change: { type: "change" };
|
|
@@ -55,13 +52,10 @@ export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
55
52
|
public rotateDelta: Vector2;
|
|
56
53
|
|
|
57
54
|
private camera: Camera;
|
|
58
|
-
private viewer: Viewer;
|
|
59
|
-
protected highlighter: HighlighterComponent;
|
|
60
55
|
|
|
61
|
-
constructor(camera: Camera, canvas: HTMLElement, groundObjects: Object3D[]
|
|
56
|
+
constructor(camera: Camera, canvas: HTMLElement, groundObjects: Object3D[]) {
|
|
62
57
|
super(camera, canvas);
|
|
63
58
|
this.camera = camera;
|
|
64
|
-
this.viewer = viewer;
|
|
65
59
|
|
|
66
60
|
this.groundObjects = groundObjects;
|
|
67
61
|
this.raycaster = new Raycaster();
|
|
@@ -171,7 +165,8 @@ export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
171
165
|
};
|
|
172
166
|
|
|
173
167
|
private updateGroundFollowing() {
|
|
174
|
-
|
|
168
|
+
const up = new Vector3().copy(this.camera.up);
|
|
169
|
+
this.raycaster.set(this.object.position, up.negate());
|
|
175
170
|
|
|
176
171
|
this.raycaster.params = this.raycaster.params = {
|
|
177
172
|
Mesh: {},
|
|
@@ -189,36 +184,9 @@ export class WalkControls extends Controls<WalkControlsEventMap> {
|
|
|
189
184
|
|
|
190
185
|
// Smoothly interpolate the camera's y position to the target height
|
|
191
186
|
this.object.position.y = MathUtils.lerp(this.object.position.y, targetY, this.GROUND_FOLLOWING_SPEED);
|
|
192
|
-
|
|
193
|
-
// Only for debug
|
|
194
|
-
// const model = this.viewer.models[0];
|
|
195
|
-
// const handles = model.getHandlesByObjects(intersects[0].object);
|
|
196
|
-
// const objects = model.getObjectsByHandles(handles);
|
|
197
|
-
// this.viewer.clearSelected();
|
|
198
|
-
// this.select(objects, model);
|
|
199
187
|
}
|
|
200
188
|
}
|
|
201
189
|
|
|
202
|
-
select(objects: Object3D | Object3D[], model?: IModelImpl) {
|
|
203
|
-
if (!model) {
|
|
204
|
-
this.viewer.models.forEach((model) => this.select(objects, model));
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (!Array.isArray(objects)) objects = [objects];
|
|
209
|
-
if (!objects.length) return;
|
|
210
|
-
|
|
211
|
-
model.showOriginalObjects(objects);
|
|
212
|
-
this.highlighter.highlight(objects);
|
|
213
|
-
|
|
214
|
-
objects.forEach((object: any) => this.viewer.selected.push(object));
|
|
215
|
-
objects.forEach((object: any) => (object.isSelected = true));
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
initHighlighter = () => {
|
|
219
|
-
this.highlighter = this.viewer.getComponent("HighlighterComponent") as HighlighterComponent;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
190
|
override update() {
|
|
223
191
|
let moved = false;
|
|
224
192
|
let upgradeGroundFollowing = false;
|
|
@@ -33,14 +33,14 @@ export class WalkDragger implements IDragger {
|
|
|
33
33
|
|
|
34
34
|
constructor(viewer: Viewer) {
|
|
35
35
|
const meshOnlyGround: Mesh[] = [];
|
|
36
|
-
viewer.models
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
meshOnlyGround.push(
|
|
36
|
+
viewer.models.forEach((model) =>
|
|
37
|
+
model.getVisibleObjects().forEach((obj) => {
|
|
38
|
+
if (obj instanceof Mesh) {
|
|
39
|
+
meshOnlyGround.push(obj);
|
|
40
40
|
}
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
this.controls = new WalkControls(viewer.camera, viewer.canvas, meshOnlyGround
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
this.controls = new WalkControls(viewer.camera, viewer.canvas, meshOnlyGround);
|
|
44
44
|
this.controls.addEventListener("change", this.controlsChange);
|
|
45
45
|
this.controls.addEventListener("walkspeedchange", this.walkspeedChange);
|
|
46
46
|
this.viewer = viewer;
|