@needle-tools/engine 4.10.0-beta.3 → 4.10.0-beta.4
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/components.needle.json +1 -1
- package/dist/{needle-engine.bundle-CLzMgxkO.min.js → needle-engine.bundle-BFTyp4Pf.min.js} +132 -130
- package/dist/{needle-engine.bundle-Ddybtee9.js → needle-engine.bundle-CsVLA8Ze.js} +6114 -6075
- package/dist/{needle-engine.bundle-Ckr5KE6m.umd.cjs → needle-engine.bundle-D9nl4ea6.umd.cjs} +134 -132
- package/dist/needle-engine.js +106 -106
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/codegen/register_types.js +2 -2
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_camera.js +5 -5
- package/lib/engine/engine_camera.js.map +1 -1
- package/lib/engine/engine_gizmos.d.ts +11 -10
- package/lib/engine/engine_gizmos.js +24 -10
- package/lib/engine/engine_gizmos.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/xr/NeedleXRController.d.ts +3 -3
- package/lib/engine/xr/NeedleXRController.js +28 -0
- package/lib/engine/xr/NeedleXRController.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -1
- package/lib/engine-components/codegen/components.js +1 -1
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/debug/LogStats.d.ts +1 -0
- package/lib/engine-components/debug/LogStats.js +1 -0
- package/lib/engine-components/debug/LogStats.js.map +1 -1
- package/lib/engine-components/timeline/PlayableDirector.js +1 -1
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.d.ts +2 -1
- package/lib/engine-components/timeline/TimelineTracks.js +24 -19
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.js +36 -34
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +2 -2
- package/lib/engine-components/web/ViewBox.js +35 -26
- package/lib/engine-components/web/ViewBox.js.map +1 -1
- package/lib/engine-components-experimental/Presentation.d.ts +1 -0
- package/lib/engine-components-experimental/Presentation.js +1 -0
- package/lib/engine-components-experimental/Presentation.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/codegen/register_types.ts +2 -2
- package/src/engine/engine_camera.ts +5 -7
- package/src/engine/engine_gizmos.ts +37 -23
- package/src/engine/extensions/extension_utils.ts +1 -1
- package/src/engine/xr/NeedleXRController.ts +36 -4
- package/src/engine-components/codegen/components.ts +1 -1
- package/src/engine-components/debug/LogStats.ts +1 -0
- package/src/engine-components/timeline/PlayableDirector.ts +1 -1
- package/src/engine-components/timeline/TimelineTracks.ts +24 -19
- package/src/engine-components/web/ScrollFollow.ts +40 -36
- package/src/engine-components/web/ViewBox.ts +35 -23
- package/src/engine-components-experimental/Presentation.ts +1 -0
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { Camera, PerspectiveCamera, Vector2, Vector3 } from "three";
|
|
1
|
+
import { Camera, PerspectiveCamera, Quaternion, Vector2, Vector3 } from "three";
|
|
2
2
|
|
|
3
3
|
import { isDevEnvironment } from "../../engine/debug/debug.js";
|
|
4
4
|
import { Gizmos } from "../../engine/engine_gizmos.js";
|
|
5
5
|
import { serializable } from "../../engine/engine_serialization_decorator.js";
|
|
6
|
-
import {
|
|
6
|
+
import { getTempVector } from "../../engine/engine_three_utils.js";
|
|
7
7
|
import { registerType } from "../../engine/engine_typestore.js";
|
|
8
8
|
import { getParam } from "../../engine/engine_utils.js";
|
|
9
|
+
import { RGBAColor } from "../../engine/js-extensions/RGBAColor.js";
|
|
9
10
|
import { Behaviour } from "../Component.js";
|
|
10
11
|
|
|
12
|
+
|
|
11
13
|
const debugParam = getParam("debugviewbox");
|
|
14
|
+
const disabledGizmoColor = new RGBAColor(.5, .5, .5, .5);
|
|
12
15
|
|
|
13
16
|
@registerType
|
|
14
|
-
export class
|
|
17
|
+
export class ResponsiveBox extends Behaviour {
|
|
15
18
|
|
|
16
|
-
static instances:
|
|
19
|
+
static instances: ResponsiveBox[] = [];
|
|
17
20
|
|
|
18
21
|
@serializable()
|
|
19
22
|
referenceFieldOfView: number = 60;
|
|
@@ -31,24 +34,31 @@ export class ViewBox extends Behaviour {
|
|
|
31
34
|
|
|
32
35
|
onEnable(): void {
|
|
33
36
|
if (debugParam || this.debug || isDevEnvironment()) console.debug("[ViewBox] Using camera fov:", this.referenceFieldOfView);
|
|
34
|
-
|
|
37
|
+
ResponsiveBox.instances.push(this);
|
|
38
|
+
// this.context.pre_render_callbacks.push(this.internalUpdate);
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
onDisable(): void {
|
|
38
42
|
if (debugParam || this.debug) console.debug("[ViewBox] Disabled");
|
|
39
|
-
const idx =
|
|
40
|
-
if (idx !== -1)
|
|
43
|
+
const idx = ResponsiveBox.instances.indexOf(this);
|
|
44
|
+
if (idx !== -1) ResponsiveBox.instances.splice(idx, 1);
|
|
41
45
|
this._projectedBoxElement?.remove();
|
|
46
|
+
|
|
47
|
+
// const cb_idx = this.context.pre_render_callbacks.indexOf(this.internalUpdate);
|
|
48
|
+
// if (cb_idx !== -1) this.context.pre_render_callbacks.splice(cb_idx, 1);
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
onBeforeRender() {
|
|
51
|
+
onBeforeRender(): void {
|
|
45
52
|
if (this.context.isInXR) return;
|
|
46
|
-
|
|
53
|
+
if(this.destroyed) return;
|
|
54
|
+
const isActive = ResponsiveBox.instances[ResponsiveBox.instances.length - 1] === this;
|
|
47
55
|
if (!isActive) {
|
|
48
|
-
if (debugParam || this.debug)
|
|
56
|
+
if (debugParam || this.debug) {
|
|
57
|
+
Gizmos.DrawWireBox(this.gameObject.worldPosition, this.gameObject.worldScale, disabledGizmoColor);
|
|
58
|
+
}
|
|
49
59
|
return;
|
|
50
60
|
}
|
|
51
|
-
if (debugParam || this.debug) Gizmos.DrawWireBox(this.gameObject.worldPosition, this.gameObject.worldScale, 0xdddd00);
|
|
61
|
+
if (debugParam || this.debug) Gizmos.DrawWireBox(this.gameObject.worldPosition, this.gameObject.worldScale, 0xdddd00, 0, true, this.gameObject.worldQuaternion);
|
|
52
62
|
|
|
53
63
|
// calculate box size to fit the camera frustrum size at the current position (just scale)
|
|
54
64
|
const camera = this.context.mainCamera;
|
|
@@ -94,6 +104,7 @@ export class ViewBox extends Behaviour {
|
|
|
94
104
|
camera.fov = this.referenceFieldOfView;
|
|
95
105
|
camera.updateProjectionMatrix();
|
|
96
106
|
|
|
107
|
+
|
|
97
108
|
const boxPosition = this.gameObject.worldPosition;
|
|
98
109
|
const boxScale = this.gameObject.worldScale;
|
|
99
110
|
|
|
@@ -138,7 +149,7 @@ export class ViewBox extends Behaviour {
|
|
|
138
149
|
const height = 2 * Math.tan(vFOV / 2) * distance; // visible height
|
|
139
150
|
const width = height * camera.aspect; // visible width
|
|
140
151
|
|
|
141
|
-
const projectedBox = this.projectBoxIntoCamera(
|
|
152
|
+
const projectedBox = this.projectBoxIntoCamera(camera, 1);
|
|
142
153
|
// return
|
|
143
154
|
const boxWidth = (projectedBox.maxX - projectedBox.minX);
|
|
144
155
|
const boxHeight = (projectedBox.maxY - projectedBox.minY);
|
|
@@ -189,18 +200,18 @@ export class ViewBox extends Behaviour {
|
|
|
189
200
|
|
|
190
201
|
|
|
191
202
|
|
|
192
|
-
private projectBoxIntoCamera(
|
|
203
|
+
private projectBoxIntoCamera(camera: Camera, _factor: number) {
|
|
193
204
|
const factor = .5 * _factor;
|
|
194
205
|
|
|
195
206
|
const corners = [
|
|
196
|
-
getTempVector(-
|
|
197
|
-
getTempVector(
|
|
198
|
-
getTempVector(-
|
|
199
|
-
getTempVector(
|
|
200
|
-
getTempVector(-
|
|
201
|
-
getTempVector(
|
|
202
|
-
getTempVector(-
|
|
203
|
-
getTempVector(
|
|
207
|
+
getTempVector(-factor, -factor, -factor),
|
|
208
|
+
getTempVector(factor, -factor, -factor),
|
|
209
|
+
getTempVector(-factor, factor, -factor),
|
|
210
|
+
getTempVector(factor, factor, -factor),
|
|
211
|
+
getTempVector(-factor, -factor, factor),
|
|
212
|
+
getTempVector(factor, -factor, factor),
|
|
213
|
+
getTempVector(-factor, factor, factor),
|
|
214
|
+
getTempVector(factor, factor, factor),
|
|
204
215
|
];
|
|
205
216
|
let minX = Number.POSITIVE_INFINITY;
|
|
206
217
|
let maxX = Number.NEGATIVE_INFINITY;
|
|
@@ -208,7 +219,7 @@ export class ViewBox extends Behaviour {
|
|
|
208
219
|
let maxY = Number.NEGATIVE_INFINITY;
|
|
209
220
|
for (let i = 0; i < corners.length; i++) {
|
|
210
221
|
const c = corners[i];
|
|
211
|
-
c.
|
|
222
|
+
c.applyMatrix4(this.gameObject.matrixWorld);
|
|
212
223
|
c.project(camera);
|
|
213
224
|
if (c.x < minX) minX = c.x;
|
|
214
225
|
if (c.x > maxX) maxX = c.x;
|
|
@@ -223,7 +234,8 @@ export class ViewBox extends Behaviour {
|
|
|
223
234
|
if (this._projectedBoxElement.parentElement !== this.context.domElement)
|
|
224
235
|
this.context.domElement.appendChild(this._projectedBoxElement);
|
|
225
236
|
this._projectedBoxElement.style.position = "fixed";
|
|
226
|
-
|
|
237
|
+
// dotted but with larger gaps
|
|
238
|
+
this._projectedBoxElement.style.outline = "2px dashed rgba(255,0,0,.5)";
|
|
227
239
|
this._projectedBoxElement.style.left = ((minX * .5 + .5) * this.context.domWidth) + "px";
|
|
228
240
|
this._projectedBoxElement.style.top = ((-maxY * .5 + .5) * this.context.domHeight) + "px";
|
|
229
241
|
this._projectedBoxElement.style.width = ((maxX - minX) * .5 * this.context.domWidth) + "px";
|