@needle-tools/engine 2.67.6-pre → 2.67.7-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 +9 -0
- package/dist/needle-engine.js +5784 -5766
- package/dist/needle-engine.umd.cjs +83 -83
- package/lib/engine/engine_context.d.ts +170 -0
- package/lib/engine/engine_context.js +855 -0
- package/lib/engine/engine_context.js.map +1 -0
- package/lib/engine/engine_setup.d.ts +1 -166
- package/lib/engine/engine_setup.js +2 -839
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_time.d.ts +2 -0
- package/lib/engine/engine_time.js +4 -1
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +4 -1
- package/lib/engine-components/ui/Canvas.js +17 -1
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.js +1 -2
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/Text.js +4 -0
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/ui/Utils.js +6 -4
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_context.ts +957 -0
- package/src/engine/engine_setup.ts +2 -941
- package/src/engine/engine_time.ts +4 -1
- package/src/engine-components/AnimatorController.ts +2 -2
- package/src/engine-components/ui/Canvas.ts +19 -1
- package/src/engine-components/ui/EventSystem.ts +1 -2
- package/src/engine-components/ui/Text.ts +3 -0
- package/src/engine-components/ui/Utils.ts +6 -4
|
@@ -20,11 +20,13 @@ export class Time {
|
|
|
20
20
|
|
|
21
21
|
get frameCount() { return this.frame; }
|
|
22
22
|
get smoothedFps() { return this._smoothedFps; }
|
|
23
|
+
get smoothedDeltaTime() { return 1 / this._smoothedFps; }
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
private clock = new Clock();
|
|
26
27
|
|
|
27
28
|
private _smoothedFps: number = 0;
|
|
29
|
+
private _smoothedDeltaTime: number = 0;
|
|
28
30
|
private _fpsSamples: number[] = [];
|
|
29
31
|
private _fpsSampleIndex: number = 0;
|
|
30
32
|
|
|
@@ -47,6 +49,7 @@ export class Time {
|
|
|
47
49
|
let sum = 0;
|
|
48
50
|
for (let i = 0; i < this._fpsSamples.length; i++)
|
|
49
51
|
sum += this._fpsSamples[i];
|
|
50
|
-
this.
|
|
52
|
+
this._smoothedDeltaTime = sum / this._fpsSamples.length;
|
|
53
|
+
this._smoothedFps = 1 / this._smoothedDeltaTime;
|
|
51
54
|
}
|
|
52
55
|
}
|
|
@@ -432,9 +432,9 @@ export class AnimatorController {
|
|
|
432
432
|
case AnimatorConditionMode.IfNot:
|
|
433
433
|
return param.value === false;
|
|
434
434
|
case AnimatorConditionMode.Greater:
|
|
435
|
-
return param.value > cond.threshold;
|
|
435
|
+
return param.value as number > cond.threshold;
|
|
436
436
|
case AnimatorConditionMode.Less:
|
|
437
|
-
return param.value < cond.threshold;
|
|
437
|
+
return param.value as number < cond.threshold;
|
|
438
438
|
case AnimatorConditionMode.Equals:
|
|
439
439
|
return param.value === cond.threshold;
|
|
440
440
|
case AnimatorConditionMode.NotEqual:
|
|
@@ -8,11 +8,13 @@ import { getComponentsInChildren } from "../../engine/engine_components";
|
|
|
8
8
|
import { IComponent } from "../../engine/engine_types";
|
|
9
9
|
import { GameObject } from "../Component";
|
|
10
10
|
import { showBalloonMessage, showBalloonWarning } from "../../engine/debug";
|
|
11
|
+
import { Object3D } from "three";
|
|
11
12
|
|
|
12
13
|
export enum RenderMode {
|
|
13
14
|
ScreenSpaceOverlay = 0,
|
|
14
15
|
ScreenSpaceCamera = 1,
|
|
15
16
|
WorldSpace = 2,
|
|
17
|
+
Undefined = -1,
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export class Canvas extends UIRootComponent {
|
|
@@ -74,7 +76,7 @@ export class Canvas extends UIRootComponent {
|
|
|
74
76
|
this._renderMode = val;
|
|
75
77
|
this.onRenderSettingsChanged();
|
|
76
78
|
}
|
|
77
|
-
private _renderMode: RenderMode =
|
|
79
|
+
private _renderMode: RenderMode = RenderMode.Undefined;
|
|
78
80
|
|
|
79
81
|
private _rootCanvas!: Canvas;
|
|
80
82
|
|
|
@@ -109,12 +111,28 @@ export class Canvas extends UIRootComponent {
|
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
private previousAspect: number = -1;
|
|
114
|
+
private previousParent: Object3D | null = null;
|
|
112
115
|
|
|
113
116
|
onBeforeRender() {
|
|
114
117
|
if (this.isScreenSpace && this.context.mainCameraComponent && this.context.mainCameraComponent.aspect !== this.previousAspect) {
|
|
115
118
|
this.previousAspect = this.context.mainCameraComponent.aspect;
|
|
116
119
|
this.updateRenderMode();
|
|
117
120
|
}
|
|
121
|
+
else if(this.renderOnTop){
|
|
122
|
+
// This is just a test but in reality it should be combined with all world canvases with render on top in one render pass
|
|
123
|
+
this.previousParent = this.gameObject.parent;
|
|
124
|
+
this.gameObject.removeFromParent();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
onAfterRender(): void {
|
|
129
|
+
if (this.renderOnTop && this.previousParent && this.context.mainCamera) {
|
|
130
|
+
this.previousParent.add(this.gameObject);
|
|
131
|
+
this.context.renderer.autoClear = false;
|
|
132
|
+
this.context.renderer.clearDepth();
|
|
133
|
+
this.context.renderer.render(this.gameObject, this.context.mainCamera);
|
|
134
|
+
this.context.renderer.autoClear = true;
|
|
135
|
+
}
|
|
118
136
|
}
|
|
119
137
|
|
|
120
138
|
applyRenderSettings(){
|
|
@@ -382,8 +382,7 @@ export class EventSystem extends Behaviour {
|
|
|
382
382
|
const actualGo = parent[$shadowDomOwner].gameObject;
|
|
383
383
|
if (actualGo) {
|
|
384
384
|
const res = UIRaycastUtils.isInteractable(actualGo, this.out);
|
|
385
|
-
|
|
386
|
-
if (!res) return this.out.canvasGroup?.interactable ?? false;
|
|
385
|
+
if (!res) return false;
|
|
387
386
|
canvasGroup = this.out.canvasGroup ?? null;
|
|
388
387
|
|
|
389
388
|
const handled = this.handleMeshUIIntersection(object, pressedOrClicked);
|
|
@@ -214,6 +214,9 @@ export class Text extends Graphic {
|
|
|
214
214
|
|
|
215
215
|
this.getAlignment(opts, isTextIntermediate);
|
|
216
216
|
const block = rt.createNewBlock(opts);
|
|
217
|
+
// The text block should never write depth to avoid z-fighting
|
|
218
|
+
const mat = block["backgroundMaterial"];
|
|
219
|
+
if(mat) mat.depthWrite = false;
|
|
217
220
|
if (content) {
|
|
218
221
|
if (Array.isArray(content)) {
|
|
219
222
|
block.add(...content);
|
|
@@ -34,11 +34,13 @@ export function updateRenderSettings(shadowComponent: THREE.Object3D, settings:
|
|
|
34
34
|
// console.log(shadowComponent)
|
|
35
35
|
const mat = shadowComponent["material"];
|
|
36
36
|
if (mat?.isMaterial === true) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const parent = shadowComponent.parent;
|
|
38
|
+
if (parent && parent["isText"] === true) {
|
|
39
|
+
// console.log(shadowComponent, shadowComponent.name);
|
|
40
|
+
}
|
|
41
|
+
// mat.depthTest = !settings.renderOnTop ?? true;
|
|
42
|
+
// mat.depthWrite = settings.depthWrite ?? false;
|
|
40
43
|
mat.side = (settings.doubleSided ?? true) ? DoubleSide : FrontSide;
|
|
41
|
-
mat.depthWrite = settings.depthWrite ?? false;
|
|
42
44
|
mat.shadowSide = settings.doubleSided ? DoubleSide : FrontSide;
|
|
43
45
|
shadowComponent.castShadow = settings.castShadows ? settings.castShadows : false;
|
|
44
46
|
shadowComponent.receiveShadow = settings.receiveShadows ? settings.receiveShadows : false;
|