@needle-tools/engine 2.62.1-pre → 2.62.2-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 +13 -0
- package/dist/needle-engine.js +9270 -9157
- package/dist/needle-engine.umd.cjs +223 -223
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine.js +0 -2
- package/lib/engine/engine.js.map +1 -1
- package/lib/engine/engine_camera.d.ts +4 -0
- package/lib/engine/engine_camera.js +13 -0
- package/lib/engine/engine_camera.js.map +1 -0
- package/lib/engine/engine_element.d.ts +1 -0
- package/lib/engine/engine_element.js +17 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_input.d.ts +2 -0
- package/lib/engine/engine_input.js +14 -0
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_setup.js +1 -1
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_types.d.ts +4 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/extensions/extension_utils.js +1 -1
- package/lib/engine/extensions/extension_utils.js.map +1 -1
- package/lib/engine/js-extensions/Camera.d.ts +1 -0
- package/lib/engine/js-extensions/Camera.js +37 -0
- package/lib/engine/js-extensions/Camera.js.map +1 -0
- package/lib/engine/js-extensions/Layers.js +1 -0
- package/lib/engine/js-extensions/Layers.js.map +1 -1
- package/lib/engine/js-extensions/index.d.ts +2 -0
- package/lib/engine/js-extensions/index.js +3 -0
- package/lib/engine/js-extensions/index.js.map +1 -0
- package/lib/engine-components/CameraUtils.d.ts +1 -3
- package/lib/engine-components/CameraUtils.js +34 -17
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/Light.d.ts +4 -1
- package/lib/engine-components/Light.js +17 -2
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +4 -1
- package/lib/engine-components/OrbitControls.js +13 -2
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.js +7 -1
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/ui/BaseUIComponent.d.ts +3 -0
- package/lib/engine-components/ui/BaseUIComponent.js +20 -10
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
- package/lib/engine-components/ui/Button.js +7 -3
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.js +21 -42
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/Graphic.d.ts +1 -0
- package/lib/engine-components/ui/Graphic.js +7 -0
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Interfaces.d.ts +2 -1
- package/lib/engine-components/ui/RaycastUtils.js +2 -0
- package/lib/engine-components/ui/RaycastUtils.js.map +1 -1
- package/lib/engine-components/ui/Text.js +10 -1
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/needle-engine.d.ts +1 -0
- package/lib/needle-engine.js +1 -2
- package/lib/needle-engine.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/engine/api.ts +2 -1
- package/src/engine/engine.ts +0 -3
- package/src/engine/engine_camera.ts +18 -0
- package/src/engine/engine_element.ts +17 -1
- package/src/engine/engine_input.ts +17 -5
- package/src/engine/engine_setup.ts +2 -1
- package/src/engine/engine_types.ts +9 -4
- package/src/engine/extensions/extension_utils.ts +1 -1
- package/src/engine/js-extensions/Camera.ts +35 -0
- package/src/engine/js-extensions/Layers.ts +2 -1
- package/src/engine/js-extensions/index.ts +2 -0
- package/src/engine-components/CameraUtils.ts +42 -20
- package/src/engine-components/Light.ts +16 -3
- package/src/engine-components/OrbitControls.ts +18 -6
- package/src/engine-components/timeline/TimelineTracks.ts +9 -3
- package/src/engine-components/ui/BaseUIComponent.ts +21 -11
- package/src/engine-components/ui/Button.ts +7 -3
- package/src/engine-components/ui/EventSystem.ts +20 -42
- package/src/engine-components/ui/Graphic.ts +7 -0
- package/src/engine-components/ui/Interfaces.ts +3 -1
- package/src/engine-components/ui/RaycastUtils.ts +2 -1
- package/src/engine-components/ui/Text.ts +11 -2
- package/src/needle-engine.ts +2 -2
|
@@ -13,6 +13,7 @@ import { ICanvasGroup, IGraphic } from "./Interfaces";
|
|
|
13
13
|
import { getParam } from "../../engine/engine_utils";
|
|
14
14
|
import { UIRaycastUtils } from "./RaycastUtils";
|
|
15
15
|
import { $shadowDomOwner } from "./BaseUIComponent";
|
|
16
|
+
import { showBalloonMessage, showBalloonWarning } from "../../engine/debug";
|
|
16
17
|
|
|
17
18
|
const debug = getParam("debugeventsystem");
|
|
18
19
|
|
|
@@ -248,6 +249,8 @@ export class EventSystem extends Behaviour {
|
|
|
248
249
|
args: args,
|
|
249
250
|
hasActiveUI: this.currentActiveMeshUIComponents.length > 0,
|
|
250
251
|
}
|
|
252
|
+
if(debug && args.isClicked)
|
|
253
|
+
showBalloonMessage("EventSystem: " + args.pointerId + " - " + this.context.time.frame + " - Up:" + args.isUp + ", Down:" + args.isDown)
|
|
251
254
|
this.dispatchEvent(new CustomEvent(EventSystemEvents.BeforeHandleInput, { detail: evt }))
|
|
252
255
|
this.handleIntersections(hits, args);
|
|
253
256
|
this.dispatchEvent(new CustomEvent(EventSystemEvents.AfterHandleInput, { detail: evt }))
|
|
@@ -261,11 +264,11 @@ export class EventSystem extends Behaviour {
|
|
|
261
264
|
else return;
|
|
262
265
|
|
|
263
266
|
if (this.lastPointerEvent.isUp) {
|
|
264
|
-
for (const obj of this.raisedPointerDownEvents) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
267
|
+
// for (const obj of this.raisedPointerDownEvents) {
|
|
268
|
+
// if (obj.onPointerUp) {
|
|
269
|
+
// obj.onPointerUp(this.lastPointerEvent);
|
|
270
|
+
// }
|
|
271
|
+
// }
|
|
269
272
|
this.raisedPointerDownEvents.length = 0;
|
|
270
273
|
this.raisedPointerDownObjects.length = 0;
|
|
271
274
|
}
|
|
@@ -398,8 +401,8 @@ export class EventSystem extends Behaviour {
|
|
|
398
401
|
}
|
|
399
402
|
}
|
|
400
403
|
|
|
401
|
-
|
|
402
|
-
|
|
404
|
+
if (clicked && debug)
|
|
405
|
+
console.log(this.context.time.frame, object);
|
|
403
406
|
this.objectsHoveredThisFrame.push(object);
|
|
404
407
|
|
|
405
408
|
if (canvasGroup === null || canvasGroup.interactable) {
|
|
@@ -488,7 +491,7 @@ export class EventSystem extends Behaviour {
|
|
|
488
491
|
class MeshUIHelper {
|
|
489
492
|
|
|
490
493
|
private static lastSelected: THREE.Object3D | null = null;
|
|
491
|
-
private static lastUpdateFrame: { context: Context, frame: number }[] = [];
|
|
494
|
+
private static lastUpdateFrame: { context: Context, frame: number, nextUpdate: number }[] = [];
|
|
492
495
|
private static needsUpdate: boolean = false;
|
|
493
496
|
|
|
494
497
|
static markDirty() {
|
|
@@ -496,11 +499,15 @@ class MeshUIHelper {
|
|
|
496
499
|
}
|
|
497
500
|
|
|
498
501
|
static update(threeMeshUI: any, context: Context) {
|
|
502
|
+
const currentFrame = context.time.frameCount;
|
|
499
503
|
for (const lu of this.lastUpdateFrame) {
|
|
500
504
|
if (lu.context === context) {
|
|
501
|
-
if (
|
|
502
|
-
lu.frame =
|
|
503
|
-
|
|
505
|
+
if (currentFrame === lu.frame) return;
|
|
506
|
+
lu.frame = currentFrame;
|
|
507
|
+
let shouldUpdate = this.needsUpdate || currentFrame < 1;
|
|
508
|
+
if(lu.nextUpdate === context.time.frameCount) shouldUpdate = true;
|
|
509
|
+
if(this.needsUpdate) lu.nextUpdate = currentFrame + 3;
|
|
510
|
+
if (shouldUpdate) {
|
|
504
511
|
if (debug)
|
|
505
512
|
console.log("Update threemeshui");
|
|
506
513
|
this.needsUpdate = false;
|
|
@@ -509,11 +516,11 @@ class MeshUIHelper {
|
|
|
509
516
|
return;
|
|
510
517
|
}
|
|
511
518
|
}
|
|
512
|
-
this.lastUpdateFrame = [{ context, frame:
|
|
519
|
+
this.lastUpdateFrame = [{ context, frame: currentFrame, nextUpdate: currentFrame }];
|
|
513
520
|
threeMeshUI.update();
|
|
514
521
|
}
|
|
515
522
|
|
|
516
|
-
static updateState(intersect: THREE.Object3D,
|
|
523
|
+
static updateState(intersect: THREE.Object3D, _selectState: boolean): ThreeMeshUI.Block | null {
|
|
517
524
|
let foundBlock: ThreeMeshUI.Block | null = null;
|
|
518
525
|
|
|
519
526
|
if (intersect) {
|
|
@@ -522,30 +529,10 @@ class MeshUIHelper {
|
|
|
522
529
|
if (foundBlock && foundBlock !== this.lastSelected) {
|
|
523
530
|
const interactable = foundBlock["interactable"];
|
|
524
531
|
if (interactable === false) return null;
|
|
525
|
-
if (selectState) {
|
|
526
|
-
this.lastSelected = foundBlock;
|
|
527
|
-
//@ts-ignore
|
|
528
|
-
if (foundBlock.states["pressed"])
|
|
529
|
-
//@ts-ignore
|
|
530
|
-
foundBlock.setState("pressed");
|
|
531
|
-
|
|
532
|
-
} else {
|
|
533
|
-
//@ts-ignore
|
|
534
|
-
if (foundBlock.states["hovered"])
|
|
535
|
-
//@ts-ignore
|
|
536
|
-
foundBlock.setState("hovered");
|
|
537
|
-
};
|
|
538
532
|
this.needsUpdate = true;
|
|
539
533
|
}
|
|
540
534
|
}
|
|
541
535
|
|
|
542
|
-
// Update non-targeted buttons state
|
|
543
|
-
// MeshUIBaseComponent.objectsWithState.forEach((obj) => {
|
|
544
|
-
// if ((!intersect || obj !== foundBlock) && obj.isUI) {
|
|
545
|
-
// obj.setState('idle');
|
|
546
|
-
// };
|
|
547
|
-
// });
|
|
548
|
-
|
|
549
536
|
return foundBlock;
|
|
550
537
|
}
|
|
551
538
|
|
|
@@ -558,15 +545,6 @@ class MeshUIHelper {
|
|
|
558
545
|
|
|
559
546
|
static resetState(obj: any) {
|
|
560
547
|
if (!obj) return;
|
|
561
|
-
const interactable = obj["interactable"];
|
|
562
|
-
if (interactable === false) {
|
|
563
|
-
if (obj.states["disabled"])
|
|
564
|
-
obj.setState("disabled");
|
|
565
|
-
}
|
|
566
|
-
else if (obj === this.lastSelected && obj.states["selected"]) {
|
|
567
|
-
obj.setState("selected");
|
|
568
|
-
}
|
|
569
|
-
else obj.setState('normal');
|
|
570
548
|
this.needsUpdate = true;
|
|
571
549
|
}
|
|
572
550
|
|
|
@@ -51,6 +51,13 @@ export class Graphic extends BaseUIComponent implements IGraphic {
|
|
|
51
51
|
return this._rect!;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
__internalNewInstanceCreated(): void {
|
|
55
|
+
super.__internalNewInstanceCreated();
|
|
56
|
+
this._rect = null;
|
|
57
|
+
this.uiObject = null;
|
|
58
|
+
if(this._color) this._color = this._color.clone();
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
setState(state: string) {
|
|
55
62
|
this.makePanel();
|
|
56
63
|
if (this.uiObject) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { IComponent } from "../../engine/engine_types";
|
|
2
|
+
|
|
1
3
|
export interface ICanvasGroup {
|
|
2
4
|
get isCanvasGroup() : boolean;
|
|
3
5
|
blocksRaycasts: boolean;
|
|
4
6
|
interactable: boolean;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
export interface IGraphic {
|
|
9
|
+
export interface IGraphic extends IComponent {
|
|
8
10
|
get isGraphic() : boolean;
|
|
9
11
|
raycastTarget: boolean;
|
|
10
12
|
}
|
|
@@ -33,7 +33,7 @@ export class UIRaycastUtils {
|
|
|
33
33
|
if (canvasGroup.interactable === false) return false;
|
|
34
34
|
}
|
|
35
35
|
// handle Graphic Raycast target
|
|
36
|
-
const graphic = foreachComponent(obj, c => {
|
|
36
|
+
const graphic : IGraphic | undefined = foreachComponent(obj, c => {
|
|
37
37
|
if ((c as unknown as IGraphic).isGraphic === true) return c;
|
|
38
38
|
return undefined;
|
|
39
39
|
}, false);
|
|
@@ -43,6 +43,7 @@ export class UIRaycastUtils {
|
|
|
43
43
|
out.graphic = graphic as IGraphic;
|
|
44
44
|
}
|
|
45
45
|
if (graphic?.raycastTarget === false) return false;
|
|
46
|
+
if (graphic?.layer === 2) return false;
|
|
46
47
|
|
|
47
48
|
return true;
|
|
48
49
|
}
|
|
@@ -160,7 +160,7 @@ export class Text extends Graphic {
|
|
|
160
160
|
private _text: string = "";
|
|
161
161
|
private _fontSize: number = 12;
|
|
162
162
|
private _textMeshUi: Array<ThreeMeshUI.Text> | null = null;
|
|
163
|
-
private _textContainer:
|
|
163
|
+
private _textContainer: ThreeMeshUI.Block | null = null;
|
|
164
164
|
|
|
165
165
|
private getTextOpts(): object {
|
|
166
166
|
let fontSize = this.fontSize;
|
|
@@ -185,7 +185,16 @@ export class Text extends Graphic {
|
|
|
185
185
|
this._didHandleTextRenderOnTop = false;
|
|
186
186
|
if (this.uiObject) {
|
|
187
187
|
// @ts-ignore
|
|
188
|
-
this.uiObject.onAfterUpdate =
|
|
188
|
+
this.uiObject.onAfterUpdate = () => {
|
|
189
|
+
this.updateWidth();
|
|
190
|
+
// We need to update the shadow owner when the text updates
|
|
191
|
+
// because once the font has loaded we get new children (a new mesh)
|
|
192
|
+
// which is the text, it needs to be linked back to this component
|
|
193
|
+
// to be properly handled by the EventSystem
|
|
194
|
+
// since the EventSystem looks for shadow component owners to handle events
|
|
195
|
+
this.setShadowComponentOwner(this.uiObject);
|
|
196
|
+
this.markDirty();
|
|
197
|
+
};
|
|
189
198
|
}
|
|
190
199
|
|
|
191
200
|
setTimeout(()=> this.markDirty(), 10);
|
package/src/needle-engine.ts
CHANGED
|
@@ -3,8 +3,8 @@ makeErrorsVisibleForDevelopment();
|
|
|
3
3
|
|
|
4
4
|
import "./engine/engine_element";
|
|
5
5
|
import "./engine/engine_setup";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
import "./engine-components/CameraUtils"
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
export { GameObject, Behaviour } from "./engine-components/Component";
|