@needle-tools/engine 2.56.2-pre → 2.58.0-pre
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/CHANGELOG.md +8 -0
- package/dist/needle-engine.d.ts +99 -160
- package/dist/needle-engine.js +279 -3420
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +18 -18
- package/dist/needle-engine.min.js.map +4 -4
- package/dist/needle-engine.tsbuildinfo +1 -1
- package/lib/engine/api.d.ts +2 -1
- package/lib/engine/api.js +2 -1
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +2 -6
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine.d.ts +2 -28
- package/lib/engine/engine.js +1 -0
- package/lib/engine/engine.js.map +1 -1
- package/lib/engine/engine_hot_reload.d.ts +3 -0
- package/lib/engine/engine_hot_reload.js +168 -0
- package/lib/engine/engine_hot_reload.js.map +1 -0
- package/lib/engine/engine_input.js +1 -1
- package/lib/engine/engine_scenetools.d.ts +1 -0
- package/lib/engine/engine_scenetools.js +8 -6
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_setup.d.ts +4 -2
- package/lib/engine/engine_setup.js +66 -50
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.d.ts +5 -0
- package/lib/engine/engine_utils_screenshot.js +32 -0
- package/lib/engine/engine_utils_screenshot.js.map +1 -0
- package/lib/engine-components/Fog.d.ts +20 -0
- package/lib/engine-components/Fog.js +61 -0
- package/lib/engine-components/Fog.js.map +1 -0
- package/lib/engine-components/Skybox.js +3 -1
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/WebXR.js +2 -2
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -0
- package/lib/engine-components/codegen/components.js +1 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.d.ts +1 -1
- package/lib/engine-components/ui/EventSystem.js +25 -10
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/PointerEvents.d.ts +3 -1
- package/lib/engine-components/ui/PointerEvents.js +1 -0
- package/lib/engine-components/ui/PointerEvents.js.map +1 -1
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/src/engine/api.ts +3 -2
- package/src/engine/codegen/register_types.js +4 -8
- package/src/engine/engine.ts +3 -1
- package/src/engine/engine_hot_reload.ts +186 -0
- package/src/engine/engine_input.ts +1 -1
- package/src/engine/engine_scenetools.ts +9 -6
- package/src/engine/engine_setup.ts +66 -52
- package/src/engine/engine_three_utils.ts +4 -4
- package/src/engine/engine_utils_screenshot.ts +41 -0
- package/src/engine-components/Fog.ts +60 -0
- package/src/engine-components/Skybox.ts +3 -1
- package/src/engine-components/TestRunner.ts +1 -1
- package/src/engine-components/WebXR.ts +2 -2
- package/src/engine-components/codegen/components.ts +1 -0
- package/src/engine-components/ui/EventSystem.ts +30 -15
- package/src/engine-components/ui/PointerEvents.ts +7 -4
- package/src/engine-components/ui/Raycaster.ts +6 -3
- package/lib/engine-components-experimental/annotation/LineDrawer.d.ts +0 -18
- package/lib/engine-components-experimental/annotation/LineDrawer.js +0 -175
- package/lib/engine-components-experimental/annotation/LineDrawer.js.map +0 -1
- package/lib/engine-components-experimental/annotation/LinesManager.d.ts +0 -54
- package/lib/engine-components-experimental/annotation/LinesManager.js +0 -155
- package/lib/engine-components-experimental/annotation/LinesManager.js.map +0 -1
- package/src/engine-components-experimental/annotation/LineDrawer.ts +0 -194
- package/src/engine-components-experimental/annotation/LinesManager.ts +0 -218
|
@@ -36,13 +36,12 @@ export class EventSystem extends Behaviour {
|
|
|
36
36
|
GameObject.addNewComponent(go, EventSystem);
|
|
37
37
|
context.scene.add(go);
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
static get systems(): EventSystem[]
|
|
41
|
-
{
|
|
39
|
+
|
|
40
|
+
static get systems(): EventSystem[] {
|
|
42
41
|
const context = Context.Current;
|
|
43
42
|
if (!this._eventSystemMap.has(context)) {
|
|
44
43
|
this._eventSystemMap.set(context, []);
|
|
45
|
-
}
|
|
44
|
+
}
|
|
46
45
|
return this._eventSystemMap.get(context)!;
|
|
47
46
|
}
|
|
48
47
|
|
|
@@ -91,6 +90,7 @@ export class EventSystem extends Behaviour {
|
|
|
91
90
|
private _selectStartFn?: any;
|
|
92
91
|
private _selectEndFn?: any;
|
|
93
92
|
private _selectUpdateFn?: any;
|
|
93
|
+
private _onBeforeUpdateFn?: any;
|
|
94
94
|
|
|
95
95
|
onEnable(): void {
|
|
96
96
|
|
|
@@ -118,7 +118,7 @@ export class EventSystem extends Behaviour {
|
|
|
118
118
|
opts.isPressed = ctrl.selectionPressed;
|
|
119
119
|
opts.isClicked = ctrl.selectionClick;
|
|
120
120
|
this.handleEvents(args.grab, opts);
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
const prevGrabbed = grabbed.get(ctrl);
|
|
123
123
|
grabbed.set(ctrl, null);
|
|
124
124
|
if (prevGrabbed) {
|
|
@@ -149,20 +149,22 @@ export class EventSystem extends Behaviour {
|
|
|
149
149
|
WebXRController.addEventListener(ControllerEvents.SelectEnd, this._selectEndFn);
|
|
150
150
|
WebXRController.addEventListener(ControllerEvents.Update, this._selectUpdateFn);
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
this.
|
|
152
|
+
// TODO: unregister
|
|
153
|
+
this._onBeforeUpdateFn ??= this.onBeforeUpdate.bind(this);
|
|
154
|
+
this.context.pre_update_callbacks.push(this._onBeforeUpdateFn);
|
|
155
|
+
this.context.input.addEventListener(InputEvents.PointerDown, this._onBeforeUpdateFn);
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
onDisable(): void {
|
|
157
159
|
WebXRController.removeEventListener(ControllerEvents.SelectStart, this._selectStartFn);
|
|
158
160
|
WebXRController.removeEventListener(ControllerEvents.SelectEnd, this._selectEndFn);
|
|
159
161
|
WebXRController.removeEventListener(ControllerEvents.Update, this._selectUpdateFn);
|
|
160
|
-
}
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
this.
|
|
163
|
+
this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._onBeforeUpdateFn), 1);
|
|
164
|
+
this.context.input.removeEventListener(InputEvents.PointerDown, this._onBeforeUpdateFn);
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
|
|
166
168
|
// doesnt work in dist
|
|
167
169
|
// onBeforeRender() {
|
|
168
170
|
// MeshUIHelper.update(this.context);
|
|
@@ -195,12 +197,25 @@ export class EventSystem extends Behaviour {
|
|
|
195
197
|
}
|
|
196
198
|
|
|
197
199
|
const hits = this.performRaycast(null);
|
|
198
|
-
|
|
200
|
+
let pointerId = 0;
|
|
201
|
+
for (const i of this.context.input.foreachPointerId()) {
|
|
202
|
+
const isDown = this.context.input.getPointerDown(i);
|
|
203
|
+
const isUp = this.context.input.getPointerUp(i);
|
|
204
|
+
if (isDown || isUp) {
|
|
205
|
+
pointerId = i;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const ptr = this.context.input.getPointerEvent(pointerId);
|
|
210
|
+
// console.log(ptr);
|
|
211
|
+
const args: PointerEventData = new PointerEventData(ptr);
|
|
199
212
|
args.inputSource = this.context.input;
|
|
200
|
-
args.
|
|
201
|
-
args.
|
|
202
|
-
args.
|
|
203
|
-
args.
|
|
213
|
+
args.pointerId = pointerId;
|
|
214
|
+
args.isClicked = this.context.input.getPointerClicked(pointerId)
|
|
215
|
+
args.isDown = this.context.input.getPointerDown(pointerId);
|
|
216
|
+
args.isUp = this.context.input.getPointerUp(pointerId);
|
|
217
|
+
args.isPressed = this.context.input.getPointerPressed(pointerId);
|
|
218
|
+
// if(args.isClicked || args.isUp) console.log("clicked", args);
|
|
204
219
|
this.lastPointerEvent = args;
|
|
205
220
|
if (!hits) return;
|
|
206
221
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Input } from "../../engine/engine_input";
|
|
2
|
+
|
|
1
3
|
export interface IInputEventArgs {
|
|
2
4
|
get used(): boolean;
|
|
3
5
|
Use(): void;
|
|
@@ -5,7 +7,7 @@ export interface IInputEventArgs {
|
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
export class PointerEventData implements IInputEventArgs {
|
|
8
|
-
used: boolean = false;
|
|
10
|
+
used: boolean = false;
|
|
9
11
|
|
|
10
12
|
Use() {
|
|
11
13
|
this.used = true;
|
|
@@ -15,17 +17,18 @@ export class PointerEventData implements IInputEventArgs {
|
|
|
15
17
|
this.event?.stopImmediatePropagation();
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
inputSource: any;
|
|
20
|
+
inputSource: Input | any;
|
|
19
21
|
object!: THREE.Object3D;
|
|
20
22
|
|
|
23
|
+
pointerId: number | undefined;
|
|
21
24
|
isDown: boolean | undefined;
|
|
22
25
|
isUp: boolean | undefined;
|
|
23
26
|
isPressed: boolean | undefined;
|
|
24
27
|
isClicked: boolean | undefined;
|
|
25
28
|
|
|
26
|
-
private event?:Event;
|
|
29
|
+
private event?: Event;
|
|
27
30
|
|
|
28
|
-
constructor(events?:Event){
|
|
31
|
+
constructor(events?: Event) {
|
|
29
32
|
this.event = events;
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Camera } from "three";
|
|
2
1
|
import { RaycastOptions } from "../../engine/engine_physics";
|
|
3
|
-
import { Behaviour } from "../Component";
|
|
2
|
+
import { Behaviour, Component } from "../Component";
|
|
4
3
|
import { EventSystem } from "./EventSystem";
|
|
5
4
|
|
|
5
|
+
|
|
6
6
|
export class Raycaster extends Behaviour {
|
|
7
7
|
awake(): void {
|
|
8
8
|
EventSystem.createIfNoneExists(this.context);
|
|
@@ -21,6 +21,7 @@ export class Raycaster extends Behaviour {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
|
|
24
25
|
export class ObjectRaycaster extends Raycaster {
|
|
25
26
|
private targets: THREE.Object3D[] | null = null;
|
|
26
27
|
private raycastHits: THREE.Intersection[] = [];
|
|
@@ -44,4 +45,6 @@ export class GraphicRaycaster extends ObjectRaycaster {
|
|
|
44
45
|
// eventCamera: Camera | null = null;
|
|
45
46
|
// ignoreReversedGraphics: boolean = false;
|
|
46
47
|
// rootRaycaster: GraphicRaycaster | null = null;
|
|
47
|
-
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Behaviour } from "../../engine-components/Component";
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import { LinesManager } from "./LinesManager";
|
|
4
|
-
export declare class LinesDrawer extends Behaviour {
|
|
5
|
-
lines: LinesManager;
|
|
6
|
-
colliders?: THREE.Object3D[];
|
|
7
|
-
alignToSurface: boolean;
|
|
8
|
-
addToPaintedObject: boolean;
|
|
9
|
-
private orbit?;
|
|
10
|
-
start(): void;
|
|
11
|
-
private _states;
|
|
12
|
-
update(): void;
|
|
13
|
-
private updateLine;
|
|
14
|
-
private _raycastOptions;
|
|
15
|
-
private static _raycaster;
|
|
16
|
-
private getHit;
|
|
17
|
-
private createRandomMaterial;
|
|
18
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { Behaviour, GameObject } from "../../engine-components/Component";
|
|
2
|
-
import { OrbitControls } from "../../engine-components/OrbitControls";
|
|
3
|
-
import * as THREE from 'three';
|
|
4
|
-
import { Raycaster, Vector3 } from "three";
|
|
5
|
-
import { RaycastOptions } from "../../engine/engine_physics";
|
|
6
|
-
import { LinesManager } from "./LinesManager";
|
|
7
|
-
import { Mathf } from "../../engine/engine_math";
|
|
8
|
-
import { getWorldPosition } from "../../engine/engine_three_utils";
|
|
9
|
-
import { MeshLineMaterial } from 'three.meshline';
|
|
10
|
-
import { KeyCode } from "../../engine/engine_input";
|
|
11
|
-
import { PlayerColor } from "../../engine-components/PlayerColor";
|
|
12
|
-
import { ControllerEvents, WebXRController } from "../../engine-components/WebXRController";
|
|
13
|
-
class LineState {
|
|
14
|
-
isDrawing;
|
|
15
|
-
lastHit;
|
|
16
|
-
currentHandle;
|
|
17
|
-
maxDistance;
|
|
18
|
-
prevDistance;
|
|
19
|
-
lastParent;
|
|
20
|
-
constructor() {
|
|
21
|
-
this.isDrawing = false;
|
|
22
|
-
this.lastHit = new Vector3();
|
|
23
|
-
this.currentHandle = null;
|
|
24
|
-
this.maxDistance = 0;
|
|
25
|
-
this.prevDistance = 0;
|
|
26
|
-
this.lastParent = null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export class LinesDrawer extends Behaviour {
|
|
30
|
-
lines;
|
|
31
|
-
colliders;
|
|
32
|
-
alignToSurface = true;
|
|
33
|
-
addToPaintedObject = true;
|
|
34
|
-
orbit;
|
|
35
|
-
start() {
|
|
36
|
-
if (!this.lines) {
|
|
37
|
-
this.lines = GameObject.getComponent(this.gameObject, LinesManager);
|
|
38
|
-
if (!this.lines)
|
|
39
|
-
this.lines = GameObject.addNewComponent(this.gameObject, LinesManager);
|
|
40
|
-
}
|
|
41
|
-
this.orbit = GameObject.findObjectOfType(OrbitControls, this.context) ?? undefined;
|
|
42
|
-
this._states["mouse"] = new LineState();
|
|
43
|
-
const xrControllerSelected = {};
|
|
44
|
-
WebXRController.addEventListener(ControllerEvents.SelectStart, (ctrl, _) => {
|
|
45
|
-
xrControllerSelected[ctrl.controller.uuid] = true;
|
|
46
|
-
});
|
|
47
|
-
WebXRController.addEventListener(ControllerEvents.Update, (ctrl, _) => {
|
|
48
|
-
if (xrControllerSelected[ctrl.controller.uuid] === true) {
|
|
49
|
-
const ray = ctrl.getRay();
|
|
50
|
-
this.updateLine(ctrl.controller.uuid, ray, true, false, false);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
WebXRController.addEventListener(ControllerEvents.SelectEnd, (ctrl, _) => {
|
|
54
|
-
xrControllerSelected[ctrl.controller.uuid] = false;
|
|
55
|
-
const ray = ctrl.getRay();
|
|
56
|
-
this.updateLine(ctrl.controller.uuid, ray, true, true, false);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
_states = {};
|
|
60
|
-
update() {
|
|
61
|
-
if (this.orbit && this._states["mouse"]) {
|
|
62
|
-
if (this.orbit)
|
|
63
|
-
this.orbit.enabled = !this._states["mouse"].isDrawing;
|
|
64
|
-
}
|
|
65
|
-
if (!this.context.mainCamera)
|
|
66
|
-
return;
|
|
67
|
-
const multi = this.context.input.getPointerPressedCount() > 1;
|
|
68
|
-
const sp = this.context.input.getPointerPositionRC(0);
|
|
69
|
-
if (!sp)
|
|
70
|
-
return;
|
|
71
|
-
LinesDrawer._raycaster.setFromCamera(sp, this.context.mainCamera);
|
|
72
|
-
const ray = LinesDrawer._raycaster.ray;
|
|
73
|
-
this.updateLine("mouse", ray, this.context.input.getPointerPressed(0), this.context.input.getPointerUp(0), multi || this.context.input.isKeyPressed(KeyCode.ALT));
|
|
74
|
-
}
|
|
75
|
-
updateLine(id, ray, active, finish, cancel = false) {
|
|
76
|
-
let state = this._states[id];
|
|
77
|
-
if (!state) {
|
|
78
|
-
this._states[id] = new LineState();
|
|
79
|
-
state = this._states[id];
|
|
80
|
-
}
|
|
81
|
-
if (finish) {
|
|
82
|
-
state.isDrawing = false;
|
|
83
|
-
if (state.currentHandle) {
|
|
84
|
-
// this.sendLineUpdate();
|
|
85
|
-
this.lines.endLine(state.currentHandle);
|
|
86
|
-
state.currentHandle = null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else if (active) {
|
|
90
|
-
if (cancel) {
|
|
91
|
-
return state;
|
|
92
|
-
}
|
|
93
|
-
const hit = this.getHit(ray);
|
|
94
|
-
let pt = null;
|
|
95
|
-
let prev = state.prevDistance;
|
|
96
|
-
if (hit) {
|
|
97
|
-
if (!state.currentHandle) {
|
|
98
|
-
state.maxDistance = hit.distance;
|
|
99
|
-
}
|
|
100
|
-
pt = hit.point;
|
|
101
|
-
if (hit.face)
|
|
102
|
-
pt.add(hit.face.normal.multiplyScalar(0.01));
|
|
103
|
-
state.prevDistance = hit.distance;
|
|
104
|
-
}
|
|
105
|
-
else if (state.maxDistance > 0) {
|
|
106
|
-
let dist = state.maxDistance;
|
|
107
|
-
// if we start drawing in thin air:
|
|
108
|
-
if (!state.currentHandle && state.lastHit) {
|
|
109
|
-
const wp = getWorldPosition(this.context.mainCamera);
|
|
110
|
-
dist = state.lastHit.distanceTo(wp);
|
|
111
|
-
}
|
|
112
|
-
pt = ray.origin.add(ray.direction.multiplyScalar(state.maxDistance));
|
|
113
|
-
state.prevDistance = state.maxDistance;
|
|
114
|
-
}
|
|
115
|
-
if (pt) {
|
|
116
|
-
if (!state.currentHandle) {
|
|
117
|
-
let parent = state.lastParent ?? this.gameObject;
|
|
118
|
-
if (this.addToPaintedObject && hit)
|
|
119
|
-
parent = hit.object;
|
|
120
|
-
state.lastParent = parent;
|
|
121
|
-
state.currentHandle = this.lines.startLine(parent, { material: this.createRandomMaterial() });
|
|
122
|
-
}
|
|
123
|
-
if (this.alignToSurface) {
|
|
124
|
-
if (state.prevDistance > state.maxDistance || Math.abs(prev - state.prevDistance) > 0.2) {
|
|
125
|
-
const newDistance = state.maxDistance;
|
|
126
|
-
// if (state.maxDistance === 0) state.maxDistance = newDistance;
|
|
127
|
-
// const camPos = getWorldPosition(this.context.mainCamera);
|
|
128
|
-
pt = ray.origin.add(ray.direction.multiplyScalar(newDistance));
|
|
129
|
-
// pt = camPos.add(dir.multiplyScalar(newDistance));
|
|
130
|
-
state.prevDistance = newDistance;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (state.lastHit && state.lastHit.distanceTo(pt) < state.prevDistance * .01) {
|
|
134
|
-
return state;
|
|
135
|
-
}
|
|
136
|
-
this.lines.updateLine(state.currentHandle, { point: pt });
|
|
137
|
-
state.lastHit.copy(pt);
|
|
138
|
-
}
|
|
139
|
-
state.isDrawing = state.currentHandle !== null;
|
|
140
|
-
}
|
|
141
|
-
return state;
|
|
142
|
-
}
|
|
143
|
-
_raycastOptions = new RaycastOptions();
|
|
144
|
-
static _raycaster = new Raycaster();
|
|
145
|
-
getHit(ray) {
|
|
146
|
-
if (!this.colliders || this.colliders.length === 0) {
|
|
147
|
-
this.colliders = [this.gameObject];
|
|
148
|
-
}
|
|
149
|
-
this._raycastOptions.targets = this.colliders;
|
|
150
|
-
this._raycastOptions.ray = ray;
|
|
151
|
-
const hits = this.context.physics.raycast(this._raycastOptions);
|
|
152
|
-
if (hits.length > 0) {
|
|
153
|
-
for (const hit of hits) {
|
|
154
|
-
if (!GameObject.isActiveInHierarchy(hit.object)) {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
return hit;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
createRandomMaterial() {
|
|
163
|
-
let col;
|
|
164
|
-
if (this.context.connection.connectionId)
|
|
165
|
-
col = PlayerColor.colorFromHashCode(PlayerColor.hashCode(this.context.connection.connectionId));
|
|
166
|
-
else
|
|
167
|
-
col = new THREE.Color("hsl(" + (Math.random() * 100).toFixed(0) + ", 80%, 30%)");
|
|
168
|
-
// const col = new THREE.Color("hsl(0, 100%, 50%)");
|
|
169
|
-
return new MeshLineMaterial({
|
|
170
|
-
color: col,
|
|
171
|
-
lineWidth: Mathf.lerp(0.005, 0.01, Math.random()),
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
//# sourceMappingURL=LineDrawer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LineDrawer.js","sourceRoot":"","sources":["../../../../engine-components-experimental/annotation/LineDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAA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,CAAC;IAEO,oBAAoB;QACxB,IAAI,GAAU,CAAC;QACf,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY;YACpC,GAAG,GAAG,WAAW,CAAC,iBAAiB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;;YAEhG,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;QACrF,oDAAoD;QAEpD,OAAO,IAAI,gBAAgB,CAAC;YACxB,KAAK,EAAE,GAAG;YACV,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;SACpD,CAAC,CAAC;IACP,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Behaviour } from "../../engine-components/Component";
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import { Color, Material } from "three";
|
|
4
|
-
import { MeshLine, MeshLineMaterial } from 'three.meshline';
|
|
5
|
-
export declare type LineOptions = {
|
|
6
|
-
material?: Material;
|
|
7
|
-
options?: LineMaterialOptions;
|
|
8
|
-
};
|
|
9
|
-
export declare type LineMaterialOptions = {
|
|
10
|
-
map?: THREE.Texture;
|
|
11
|
-
useMap?: number;
|
|
12
|
-
alphaMap?: THREE.Texture;
|
|
13
|
-
color?: Color;
|
|
14
|
-
opacity?: number;
|
|
15
|
-
lineWidth?: number;
|
|
16
|
-
};
|
|
17
|
-
export declare class LineInstanceHandler {
|
|
18
|
-
id: number;
|
|
19
|
-
points: Array<any>;
|
|
20
|
-
line: MeshLine;
|
|
21
|
-
material?: MeshLineMaterial;
|
|
22
|
-
mesh?: THREE.Mesh;
|
|
23
|
-
constructor(owner: THREE.Object3D, options?: LineOptions);
|
|
24
|
-
private static wp;
|
|
25
|
-
appendPoint(vec: Vec3): Vec3;
|
|
26
|
-
private defaultLineMaterial;
|
|
27
|
-
}
|
|
28
|
-
declare type Vec3 = {
|
|
29
|
-
x: number;
|
|
30
|
-
y: number;
|
|
31
|
-
z: number;
|
|
32
|
-
};
|
|
33
|
-
export declare type LineHandle = {
|
|
34
|
-
id: number;
|
|
35
|
-
};
|
|
36
|
-
declare type UpdateLineArgs = {
|
|
37
|
-
point: Vec3;
|
|
38
|
-
};
|
|
39
|
-
export declare class LinesManager extends Behaviour {
|
|
40
|
-
startLine(parent?: THREE.Object3D, options?: LineOptions): LineHandle;
|
|
41
|
-
updateLine(handle: LineHandle, args: UpdateLineArgs): void;
|
|
42
|
-
endLine(handle: LineHandle, send?: boolean): LineInstanceHandler | undefined;
|
|
43
|
-
getLine(handle: LineHandle): LineInstanceHandler | undefined;
|
|
44
|
-
private finished;
|
|
45
|
-
private inFlight;
|
|
46
|
-
private buffer;
|
|
47
|
-
private freeBuffer;
|
|
48
|
-
awake(): void;
|
|
49
|
-
private onEnsureLine;
|
|
50
|
-
private internalStartLine;
|
|
51
|
-
private sendLineStart;
|
|
52
|
-
private sendLineUpdate;
|
|
53
|
-
}
|
|
54
|
-
export {};
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { Behaviour, GameObject } from "../../engine-components/Component";
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import { MeshLine, MeshLineMaterial } from 'three.meshline';
|
|
4
|
-
export class LineInstanceHandler {
|
|
5
|
-
id = 0;
|
|
6
|
-
points = [];
|
|
7
|
-
line = new MeshLine();
|
|
8
|
-
material;
|
|
9
|
-
mesh;
|
|
10
|
-
constructor(owner, options) {
|
|
11
|
-
if (options) {
|
|
12
|
-
this.material = options.material;
|
|
13
|
-
}
|
|
14
|
-
if (!this.material)
|
|
15
|
-
this.material = this.defaultLineMaterial;
|
|
16
|
-
if (options) {
|
|
17
|
-
const opts = options.options;
|
|
18
|
-
if (opts) {
|
|
19
|
-
Object.assign(this.material, opts);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
this.mesh = new THREE.Mesh(this.line, this.material);
|
|
23
|
-
owner.add(this.mesh);
|
|
24
|
-
}
|
|
25
|
-
static wp = new THREE.Vector3();
|
|
26
|
-
appendPoint(vec) {
|
|
27
|
-
let localPoint = LineInstanceHandler.wp;
|
|
28
|
-
localPoint.set(vec.x, vec.y, vec.z);
|
|
29
|
-
const parent = this.mesh?.parent;
|
|
30
|
-
if (parent) {
|
|
31
|
-
localPoint = parent.worldToLocal(localPoint);
|
|
32
|
-
vec.x = localPoint.x;
|
|
33
|
-
vec.y = localPoint.y;
|
|
34
|
-
vec.z = localPoint.z;
|
|
35
|
-
}
|
|
36
|
-
this.points.push(vec.x, vec.y, vec.z);
|
|
37
|
-
this.line.setPoints(this.points);
|
|
38
|
-
return vec;
|
|
39
|
-
}
|
|
40
|
-
defaultLineMaterial = new MeshLineMaterial({ color: 0x999999, lineWidth: 0.01 });
|
|
41
|
-
}
|
|
42
|
-
export class LinesManager extends Behaviour {
|
|
43
|
-
startLine(parent, options) {
|
|
44
|
-
const id = Math.random() * Number.MAX_SAFE_INTEGER;
|
|
45
|
-
return this.internalStartLine(parent, id, true, options);
|
|
46
|
-
}
|
|
47
|
-
updateLine(handle, args) {
|
|
48
|
-
const line = this.inFlight[handle.id];
|
|
49
|
-
if (!line)
|
|
50
|
-
return;
|
|
51
|
-
if (args.point) {
|
|
52
|
-
args.point = line.appendPoint(args.point);
|
|
53
|
-
}
|
|
54
|
-
const buf = this.buffer[handle.id];
|
|
55
|
-
if (buf) {
|
|
56
|
-
if (args.point)
|
|
57
|
-
buf.push(args.point.x, args.point.y, args.point.z);
|
|
58
|
-
if (buf.length > 5) {
|
|
59
|
-
this.sendLineUpdate(line, false, undefined, buf);
|
|
60
|
-
buf.length = 0;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
endLine(handle, send = true) {
|
|
65
|
-
const line = this.inFlight[handle.id];
|
|
66
|
-
if (!line)
|
|
67
|
-
return undefined;
|
|
68
|
-
this.finished.push(line);
|
|
69
|
-
delete this.inFlight[handle.id];
|
|
70
|
-
if (send)
|
|
71
|
-
this.sendLineUpdate(line, true, 0);
|
|
72
|
-
const buf = this.buffer[handle.id];
|
|
73
|
-
if (buf) {
|
|
74
|
-
delete this.buffer[handle.id];
|
|
75
|
-
const arr = buf;
|
|
76
|
-
arr.length = 0;
|
|
77
|
-
this.freeBuffer.push(arr);
|
|
78
|
-
}
|
|
79
|
-
return line;
|
|
80
|
-
}
|
|
81
|
-
getLine(handle) {
|
|
82
|
-
return this.inFlight[handle.id];
|
|
83
|
-
}
|
|
84
|
-
finished = [];
|
|
85
|
-
inFlight = [];
|
|
86
|
-
buffer = {};
|
|
87
|
-
freeBuffer = new Array();
|
|
88
|
-
awake() {
|
|
89
|
-
this.context.connection.beginListen("line-start", (i) => {
|
|
90
|
-
this.onEnsureLine(i.id, i.parentGuid);
|
|
91
|
-
});
|
|
92
|
-
this.context.connection.beginListen("line-update", (evt) => {
|
|
93
|
-
let line = this.onEnsureLine(evt.guid, evt.parentGuid);
|
|
94
|
-
if (line && evt.points) {
|
|
95
|
-
if (evt.startIndex <= 0) {
|
|
96
|
-
line.points = evt.points;
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
if (evt.startIndex >= line.points.length) {
|
|
100
|
-
line.points.push(...evt.points);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
line.line.setPoints(line.points);
|
|
104
|
-
line.material.lineWidth = evt.width;
|
|
105
|
-
line.material.color.fromArray(evt.color);
|
|
106
|
-
if (evt.finished === true) {
|
|
107
|
-
this.endLine({ id: line.id }, false);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
onEnsureLine(lineId, parentGuid) {
|
|
113
|
-
if (this.inFlight[lineId])
|
|
114
|
-
return this.inFlight[lineId];
|
|
115
|
-
let obj = GameObject.findByGuid(parentGuid, this.context.scene);
|
|
116
|
-
if (!obj) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
this.internalStartLine(obj, lineId, false);
|
|
120
|
-
return this.inFlight[lineId];
|
|
121
|
-
}
|
|
122
|
-
internalStartLine(parent, id, send = true, options) {
|
|
123
|
-
const line = new LineInstanceHandler(parent ?? this.context.scene, options);
|
|
124
|
-
line.id = id;
|
|
125
|
-
this.inFlight[id] = line;
|
|
126
|
-
if (send)
|
|
127
|
-
this.sendLineStart(line);
|
|
128
|
-
let buf;
|
|
129
|
-
if (this.freeBuffer.length <= 0)
|
|
130
|
-
buf = new Array();
|
|
131
|
-
else
|
|
132
|
-
buf = this.freeBuffer.pop();
|
|
133
|
-
this.buffer[id] = buf;
|
|
134
|
-
return { id: id };
|
|
135
|
-
}
|
|
136
|
-
sendLineStart(instance) {
|
|
137
|
-
const parent = instance.mesh.parent;
|
|
138
|
-
this.context.connection.send("line-start", { id: instance.id, parentGuid: parent ? parent["guid"] : undefined });
|
|
139
|
-
}
|
|
140
|
-
sendLineUpdate(instance, finished, startIndex, points) {
|
|
141
|
-
if (instance) {
|
|
142
|
-
const model = {
|
|
143
|
-
parentGuid: instance.mesh.parent["guid"],
|
|
144
|
-
guid: instance.id,
|
|
145
|
-
points: points ? [...points] : instance.points,
|
|
146
|
-
width: instance.material.lineWidth,
|
|
147
|
-
color: instance.material.color.toArray(),
|
|
148
|
-
startIndex: startIndex !== undefined ? startIndex : instance.points.length,
|
|
149
|
-
finished: finished,
|
|
150
|
-
};
|
|
151
|
-
this.context.connection.send("line-update", model);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=LinesManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LinesManager.js","sourceRoot":"","sources":["../../../../engine-components-experimental/annotation/LinesManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SA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