@needle-tools/engine 2.61.0-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 +24 -0
- package/dist/needle-engine.js +25826 -25563
- package/dist/needle-engine.umd.cjs +244 -246
- 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/debug/debug_overlay.js +9 -9
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/engine.js +0 -2
- package/lib/engine/engine.js.map +1 -1
- package/lib/engine/engine_addressables.js +16 -5
- package/lib/engine/engine_addressables.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_loaders.d.ts +1 -0
- package/lib/engine/engine_loaders.js +12 -0
- package/lib/engine/engine_loaders.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/Animation.js +12 -3
- package/lib/engine-components/Animation.js.map +1 -1
- 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/PlayableDirector.js +27 -17
- package/lib/engine-components/timeline/PlayableDirector.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 +23 -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 +11 -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/debug/debug_overlay.ts +9 -9
- package/src/engine/engine.ts +0 -3
- package/src/engine/engine_addressables.ts +13 -5
- 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_loaders.ts +13 -0
- 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/Animation.ts +11 -3
- 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/PlayableDirector.ts +25 -17
- 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 +22 -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 +13 -2
- package/src/needle-engine.ts +2 -2
|
@@ -149,7 +149,11 @@ export class PlayableDirector extends Behaviour {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
pause() {
|
|
152
|
+
if (!this.isValid()) return;
|
|
153
|
+
this._isPlaying = false;
|
|
154
|
+
if (this._isPaused) return;
|
|
152
155
|
this._isPaused = true;
|
|
156
|
+
this.evaluate();
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
stop() {
|
|
@@ -267,8 +271,10 @@ export class PlayableDirector extends Behaviour {
|
|
|
267
271
|
for (const handler of this._animationTracks) {
|
|
268
272
|
handler.evaluate(time);
|
|
269
273
|
}
|
|
270
|
-
|
|
271
|
-
handler.
|
|
274
|
+
if (AudioSource.userInteractionRegistered) {
|
|
275
|
+
for (const handler of this._audioTracks) {
|
|
276
|
+
handler.evaluate(time);
|
|
277
|
+
}
|
|
272
278
|
}
|
|
273
279
|
for (const sig of this._signalTracks) {
|
|
274
280
|
sig.evaluate(time);
|
|
@@ -279,7 +285,6 @@ export class PlayableDirector extends Behaviour {
|
|
|
279
285
|
for (const cust of this._customTracks) {
|
|
280
286
|
cust.evaluate(time);
|
|
281
287
|
}
|
|
282
|
-
|
|
283
288
|
}
|
|
284
289
|
|
|
285
290
|
private resolveBindings() {
|
|
@@ -358,6 +363,7 @@ export class PlayableDirector extends Behaviour {
|
|
|
358
363
|
|
|
359
364
|
if (!this.playableAsset) return;
|
|
360
365
|
const audioTracks: Array<Models.TrackModel> = [];
|
|
366
|
+
const audioAllowedCallbacks : any = [];
|
|
361
367
|
for (const track of this.playableAsset!.tracks) {
|
|
362
368
|
const type = track.type;
|
|
363
369
|
const registered = PlayableDirector.createTrackFunctions[type];
|
|
@@ -425,7 +431,20 @@ export class PlayableDirector extends Behaviour {
|
|
|
425
431
|
}
|
|
426
432
|
else if (track.type === Models.TrackType.Audio) {
|
|
427
433
|
if (track.clips.length <= 0) continue;
|
|
428
|
-
|
|
434
|
+
const audio = new Tracks.AudioTrackHandler();
|
|
435
|
+
audio.director = this;
|
|
436
|
+
audio.track = track;
|
|
437
|
+
this._audioTracks.push(audio);
|
|
438
|
+
|
|
439
|
+
audioAllowedCallbacks.push(() => {
|
|
440
|
+
const listener = GameObject.findObjectOfType(AudioListener, this.context) as AudioListener;
|
|
441
|
+
if (!listener) return;
|
|
442
|
+
audio.listener = listener.listener;
|
|
443
|
+
for (let i = 0; i < track.clips.length; i++) {
|
|
444
|
+
const clipModel = track.clips[i];
|
|
445
|
+
audio.addModel(clipModel);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
429
448
|
}
|
|
430
449
|
else if (track.type === Models.TrackType.Marker) {
|
|
431
450
|
const signalHandler: Tracks.SignalTrackHandler = new Tracks.SignalTrackHandler();
|
|
@@ -473,19 +492,8 @@ export class PlayableDirector extends Behaviour {
|
|
|
473
492
|
}
|
|
474
493
|
|
|
475
494
|
AudioSource.registerWaitForAllowAudio(() => {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
for (const track of audioTracks) {
|
|
479
|
-
const audio = new Tracks.AudioTrackHandler();
|
|
480
|
-
audio.director = this;
|
|
481
|
-
audio.track = track;
|
|
482
|
-
audio.listener = listener.listener;
|
|
483
|
-
for (let i = 0; i < track.clips.length; i++) {
|
|
484
|
-
const clipModel = track.clips[i];
|
|
485
|
-
audio.addModel(clipModel);
|
|
486
|
-
}
|
|
487
|
-
this._audioTracks.push(audio);
|
|
488
|
-
}
|
|
495
|
+
audioAllowedCallbacks.forEach((cb: any) => cb());
|
|
496
|
+
audioAllowedCallbacks.length = 0;
|
|
489
497
|
});
|
|
490
498
|
}
|
|
491
499
|
|
|
@@ -276,7 +276,7 @@ export class AnimationTrackHandler extends TrackHandler {
|
|
|
276
276
|
const isInTimeRange = time >= model.start && time <= model.end;
|
|
277
277
|
const postExtrapolation: Models.ClipExtrapolation = model.postExtrapolationMode;
|
|
278
278
|
let isActive = isInTimeRange;
|
|
279
|
-
if (!isActive && !didPostExtrapolate && model.end < time &&
|
|
279
|
+
if (!isActive && !didPostExtrapolate && model.end < time && postExtrapolation !== Models.ClipExtrapolation.None) {
|
|
280
280
|
const nextClip = i < this.clips.length - 1 ? this.models[i + 1] : null;
|
|
281
281
|
// use post extrapolate if its the last clip of the next clip has not yet started
|
|
282
282
|
if (!nextClip || nextClip.start > time) {
|
|
@@ -284,6 +284,12 @@ export class AnimationTrackHandler extends TrackHandler {
|
|
|
284
284
|
didPostExtrapolate = true;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
+
const preExtrapolation: Models.ClipExtrapolation = model.preExtrapolationMode;
|
|
288
|
+
if (i == 0 && !isActive && !didPostExtrapolate && model.start > time && preExtrapolation !== Models.ClipExtrapolation.None) {
|
|
289
|
+
isActive = true;
|
|
290
|
+
if (preExtrapolation !== Models.ClipExtrapolation.Hold)
|
|
291
|
+
time += model.start;
|
|
292
|
+
}
|
|
287
293
|
if (isActive) {
|
|
288
294
|
// const clip = this.clips[i];
|
|
289
295
|
let weight = 1;
|
|
@@ -316,9 +322,9 @@ export class AnimationTrackHandler extends TrackHandler {
|
|
|
316
322
|
}
|
|
317
323
|
}
|
|
318
324
|
|
|
319
|
-
if(model.reversed === true) action.time = action.getClip().duration - t;
|
|
325
|
+
if (model.reversed === true) action.time = action.getClip().duration - t;
|
|
320
326
|
else action.time = t;
|
|
321
|
-
|
|
327
|
+
|
|
322
328
|
action.timeScale = 0;
|
|
323
329
|
const effectiveWeight = weight * this.director.weight;
|
|
324
330
|
action.weight = effectiveWeight;
|
|
@@ -53,6 +53,13 @@ export class BaseUIComponent extends Behaviour {
|
|
|
53
53
|
// private _intermediate?: Object3D;
|
|
54
54
|
protected _parentComponent?: BaseUIComponent | null = undefined;
|
|
55
55
|
|
|
56
|
+
__internalNewInstanceCreated() {
|
|
57
|
+
super.__internalNewInstanceCreated();
|
|
58
|
+
this.shadowComponent = null;
|
|
59
|
+
this._root = undefined;
|
|
60
|
+
this._parentComponent = undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
onEnable() {
|
|
57
64
|
super.onEnable();
|
|
58
65
|
}
|
|
@@ -79,17 +86,7 @@ export class BaseUIComponent extends Behaviour {
|
|
|
79
86
|
// this.gameObject.layers.set(2)
|
|
80
87
|
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
container.traverse(c => {
|
|
84
|
-
if (c[$shadowDomOwner] === undefined) {
|
|
85
|
-
c[$shadowDomOwner] = this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// // this makes text not render anymore when enabled again
|
|
89
|
-
// if (raycastTarget === false) {
|
|
90
|
-
// c.layers.set(2);
|
|
91
|
-
// }
|
|
92
|
-
});
|
|
89
|
+
this.setShadowComponentOwner(container);
|
|
93
90
|
|
|
94
91
|
let needsUpdate = false;
|
|
95
92
|
|
|
@@ -136,6 +133,19 @@ export class BaseUIComponent extends Behaviour {
|
|
|
136
133
|
// })
|
|
137
134
|
}
|
|
138
135
|
|
|
136
|
+
protected setShadowComponentOwner(current: Object3D | null | undefined) {
|
|
137
|
+
if (!current) return;
|
|
138
|
+
// TODO: only traverse our own hierarchy, we can stop if we find another owner
|
|
139
|
+
if (current[$shadowDomOwner] === undefined || current[$shadowDomOwner] === this) {
|
|
140
|
+
current[$shadowDomOwner] = this;
|
|
141
|
+
if (current.children) {
|
|
142
|
+
for (const ch of current.children) {
|
|
143
|
+
this.setShadowComponentOwner(ch);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
139
149
|
private traverseOwnedShadowComponents(current: Object3D, owner: any, callback: (obj: any) => void) {
|
|
140
150
|
if (!current) return;
|
|
141
151
|
if (current[$shadowDomOwner] === owner) {
|
|
@@ -6,6 +6,7 @@ import { RGBAColor } from "../js-extensions/RGBAColor";
|
|
|
6
6
|
import { serializable } from "../../engine/engine_serialization_decorator";
|
|
7
7
|
import { Animator } from "../Animator";
|
|
8
8
|
import { getParam } from "../../engine/engine_utils";
|
|
9
|
+
import { showBalloonMessage } from "../../engine/debug";
|
|
9
10
|
|
|
10
11
|
const debug = getParam("debugbutton");
|
|
11
12
|
|
|
@@ -102,7 +103,7 @@ export class Button extends Behaviour implements IPointerEventHandler {
|
|
|
102
103
|
|
|
103
104
|
onPointerUp(_) {
|
|
104
105
|
if (debug)
|
|
105
|
-
console.
|
|
106
|
+
console.warn("Button Up", this.animationTriggers?.highlightedTrigger, this.animator, this._isHovered);
|
|
106
107
|
if (this.transition == Transition.Animation && this.animationTriggers && this.animator) {
|
|
107
108
|
this.animator.SetTrigger(this._isHovered ? this.animationTriggers.highlightedTrigger : this.animationTriggers.normalTrigger);
|
|
108
109
|
}
|
|
@@ -112,8 +113,10 @@ export class Button extends Behaviour implements IPointerEventHandler {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
onPointerClick(_args: PointerEventData) {
|
|
115
|
-
if (debug)
|
|
116
|
-
console.
|
|
116
|
+
if (debug) {
|
|
117
|
+
console.warn("Button Click", this.onClick);
|
|
118
|
+
showBalloonMessage("CLICKED button " + this.name + " at " + this.context.time.frameCount);
|
|
119
|
+
}
|
|
117
120
|
this.onClick?.invoke();
|
|
118
121
|
}
|
|
119
122
|
|
|
@@ -153,6 +156,7 @@ export class Button extends Behaviour implements IPointerEventHandler {
|
|
|
153
156
|
super.awake();
|
|
154
157
|
if (debug)
|
|
155
158
|
console.log(this);
|
|
159
|
+
this._isInit = false;
|
|
156
160
|
this.init();
|
|
157
161
|
}
|
|
158
162
|
|
|
@@ -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,22 +499,28 @@ 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) {
|
|
511
|
+
if (debug)
|
|
512
|
+
console.log("Update threemeshui");
|
|
504
513
|
this.needsUpdate = false;
|
|
505
514
|
threeMeshUI.update();
|
|
506
515
|
}
|
|
507
516
|
return;
|
|
508
517
|
}
|
|
509
518
|
}
|
|
510
|
-
this.lastUpdateFrame = [{ context, frame:
|
|
519
|
+
this.lastUpdateFrame = [{ context, frame: currentFrame, nextUpdate: currentFrame }];
|
|
511
520
|
threeMeshUI.update();
|
|
512
521
|
}
|
|
513
522
|
|
|
514
|
-
static updateState(intersect: THREE.Object3D,
|
|
523
|
+
static updateState(intersect: THREE.Object3D, _selectState: boolean): ThreeMeshUI.Block | null {
|
|
515
524
|
let foundBlock: ThreeMeshUI.Block | null = null;
|
|
516
525
|
|
|
517
526
|
if (intersect) {
|
|
@@ -520,30 +529,10 @@ class MeshUIHelper {
|
|
|
520
529
|
if (foundBlock && foundBlock !== this.lastSelected) {
|
|
521
530
|
const interactable = foundBlock["interactable"];
|
|
522
531
|
if (interactable === false) return null;
|
|
523
|
-
if (selectState) {
|
|
524
|
-
this.lastSelected = foundBlock;
|
|
525
|
-
//@ts-ignore
|
|
526
|
-
if (foundBlock.states["pressed"])
|
|
527
|
-
//@ts-ignore
|
|
528
|
-
foundBlock.setState("pressed");
|
|
529
|
-
|
|
530
|
-
} else {
|
|
531
|
-
//@ts-ignore
|
|
532
|
-
if (foundBlock.states["hovered"])
|
|
533
|
-
//@ts-ignore
|
|
534
|
-
foundBlock.setState("hovered");
|
|
535
|
-
};
|
|
536
532
|
this.needsUpdate = true;
|
|
537
533
|
}
|
|
538
534
|
}
|
|
539
535
|
|
|
540
|
-
// Update non-targeted buttons state
|
|
541
|
-
// MeshUIBaseComponent.objectsWithState.forEach((obj) => {
|
|
542
|
-
// if ((!intersect || obj !== foundBlock) && obj.isUI) {
|
|
543
|
-
// obj.setState('idle');
|
|
544
|
-
// };
|
|
545
|
-
// });
|
|
546
|
-
|
|
547
536
|
return foundBlock;
|
|
548
537
|
}
|
|
549
538
|
|
|
@@ -556,15 +545,6 @@ class MeshUIHelper {
|
|
|
556
545
|
|
|
557
546
|
static resetState(obj: any) {
|
|
558
547
|
if (!obj) return;
|
|
559
|
-
const interactable = obj["interactable"];
|
|
560
|
-
if (interactable === false) {
|
|
561
|
-
if (obj.states["disabled"])
|
|
562
|
-
obj.setState("disabled");
|
|
563
|
-
}
|
|
564
|
-
else if (obj === this.lastSelected && obj.states["selected"]) {
|
|
565
|
-
obj.setState("selected");
|
|
566
|
-
}
|
|
567
|
-
else obj.setState('normal');
|
|
568
548
|
this.needsUpdate = true;
|
|
569
549
|
}
|
|
570
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,8 +185,19 @@ 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
|
}
|
|
199
|
+
|
|
200
|
+
setTimeout(()=> this.markDirty(), 10);
|
|
190
201
|
}
|
|
191
202
|
|
|
192
203
|
private createBlock(rt: RectTransform, hideOverflow: boolean, content: THREE.Object3D | Array<THREE.Object3D> | null, isTextIntermediate: boolean = false): ThreeMeshUI.Block | null {
|
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";
|