@needle-tools/engine 4.10.0-next.55c0bf9 → 4.10.0-next.f5ce0ae
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-CUo74dPe.js → needle-engine.bundle-DSzlnhCs.js} +7419 -7146
- package/dist/{needle-engine.bundle-Cf5H9Zy9.umd.cjs → needle-engine.bundle-VqrrECGF.umd.cjs} +154 -141
- package/dist/needle-engine.bundle-pI8o_eru.min.js +1652 -0
- package/dist/needle-engine.js +259 -257
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/vendor-CPuBPspY.umd.cjs +1121 -0
- package/dist/vendor-DPCU8cUF.min.js +1121 -0
- package/dist/vendor-MBoqSyFm.js +16240 -0
- package/lib/engine/codegen/register_types.js +2 -0
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_camera.d.ts +7 -1
- package/lib/engine/engine_camera.fit.d.ts +1 -1
- package/lib/engine/engine_camera.fit.js +3 -30
- package/lib/engine/engine_camera.fit.js.map +1 -1
- package/lib/engine/engine_camera.js +46 -6
- package/lib/engine/engine_camera.js.map +1 -1
- package/lib/engine/engine_context.d.ts +6 -0
- package/lib/engine/engine_context.js +48 -9
- package/lib/engine/engine_context.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/engine_license.js +1 -1
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_lightdata.d.ts +3 -3
- package/lib/engine/engine_lightdata.js +10 -10
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_physics_rapier.js +4 -0
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_scenelighting.d.ts +1 -1
- package/lib/engine/engine_scenelighting.js +4 -5
- package/lib/engine/engine_scenelighting.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +3 -1
- package/lib/engine/engine_utils.js +11 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_lightmaps.js +1 -1
- package/lib/engine/extensions/NEEDLE_lightmaps.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/webcomponents/logo-element.d.ts +1 -1
- package/lib/engine/webcomponents/logo-element.js +29 -5
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +4 -3
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +22 -0
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.d.ts +0 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +3 -36
- package/lib/engine/webcomponents/needle-engine.loading.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/CameraUtils.js +2 -1
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +4 -1
- package/lib/engine-components/OrbitControls.js +30 -6
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/Renderer.js +6 -1
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/Skybox.js +22 -4
- package/lib/engine-components/Skybox.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/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.d.ts +7 -0
- package/lib/engine-components/timeline/PlayableDirector.js +8 -1
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/TimelineModels.d.ts +9 -1
- package/lib/engine-components/timeline/TimelineTracks.d.ts +2 -1
- package/lib/engine-components/timeline/TimelineTracks.js +30 -25
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/utils/LookAt.js +5 -1
- package/lib/engine-components/utils/LookAt.js.map +1 -1
- package/lib/engine-components/web/Clickthrough.js +10 -2
- package/lib/engine-components/web/Clickthrough.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +23 -0
- package/lib/engine-components/web/ScrollFollow.js +166 -41
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +27 -0
- package/lib/engine-components/web/ViewBox.js +242 -0
- package/lib/engine-components/web/ViewBox.js.map +1 -0
- package/lib/engine-components/web/index.d.ts +1 -0
- package/lib/engine-components/web/index.js +1 -0
- package/lib/engine-components/web/index.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 +2 -1
- package/src/engine/codegen/register_types.ts +2 -0
- package/src/engine/engine_camera.fit.ts +2 -32
- package/src/engine/engine_camera.ts +61 -9
- package/src/engine/engine_context.ts +50 -10
- package/src/engine/engine_gizmos.ts +37 -23
- package/src/engine/engine_license.ts +1 -1
- package/src/engine/engine_lightdata.ts +11 -11
- package/src/engine/engine_physics_rapier.ts +3 -0
- package/src/engine/engine_scenelighting.ts +5 -6
- package/src/engine/engine_utils.ts +12 -0
- package/src/engine/extensions/NEEDLE_lightmaps.ts +1 -1
- package/src/engine/extensions/extension_utils.ts +1 -1
- package/src/engine/webcomponents/logo-element.ts +29 -4
- package/src/engine/webcomponents/needle menu/needle-menu.ts +4 -3
- package/src/engine/webcomponents/needle-engine.loading.ts +32 -32
- package/src/engine/webcomponents/needle-engine.ts +33 -6
- package/src/engine/xr/NeedleXRController.ts +36 -4
- package/src/engine-components/CameraUtils.ts +1 -1
- package/src/engine-components/OrbitControls.ts +40 -1
- package/src/engine-components/Renderer.ts +6 -1
- package/src/engine-components/Skybox.ts +26 -7
- package/src/engine-components/codegen/components.ts +1 -0
- package/src/engine-components/debug/LogStats.ts +1 -0
- package/src/engine-components/timeline/PlayableDirector.ts +10 -1
- package/src/engine-components/timeline/TimelineModels.ts +9 -1
- package/src/engine-components/timeline/TimelineTracks.ts +30 -25
- package/src/engine-components/utils/LookAt.ts +5 -1
- package/src/engine-components/web/Clickthrough.ts +11 -2
- package/src/engine-components/web/ScrollFollow.ts +199 -48
- package/src/engine-components/web/ViewBox.ts +262 -0
- package/src/engine-components/web/index.ts +2 -1
- package/src/engine-components-experimental/Presentation.ts +1 -0
- package/dist/needle-engine.bundle-DlAVTipB.min.js +0 -1639
- package/dist/vendor-D0Yvltn9.umd.cjs +0 -1121
- package/dist/vendor-DU8tJyl_.js +0 -14366
- package/dist/vendor-JyrX4DVM.min.js +0 -1121
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var ViewBox_1;
|
|
8
|
+
import { PerspectiveCamera } from "three";
|
|
9
|
+
import { isDevEnvironment } from "../../engine/debug/debug.js";
|
|
10
|
+
import { Gizmos } from "../../engine/engine_gizmos.js";
|
|
11
|
+
import { serializable } from "../../engine/engine_serialization_decorator.js";
|
|
12
|
+
import { getTempVector } from "../../engine/engine_three_utils.js";
|
|
13
|
+
import { registerType } from "../../engine/engine_typestore.js";
|
|
14
|
+
import { getParam } from "../../engine/engine_utils.js";
|
|
15
|
+
import { RGBAColor } from "../../engine/js-extensions/RGBAColor.js";
|
|
16
|
+
import { Behaviour } from "../Component.js";
|
|
17
|
+
const debugParam = getParam("debugviewbox");
|
|
18
|
+
const disabledGizmoColor = new RGBAColor(.5, .5, .5, .5);
|
|
19
|
+
/**
|
|
20
|
+
* This component can be used to automatically fit a certain box area into the camera view - no matter your screen size or aspect ratio.
|
|
21
|
+
*
|
|
22
|
+
* Add the ViewBox to an object into your scene
|
|
23
|
+
*/
|
|
24
|
+
let ViewBox = ViewBox_1 = class ViewBox extends Behaviour {
|
|
25
|
+
static instances = [];
|
|
26
|
+
/**
|
|
27
|
+
* The reference field of view is used to calculate the box size. This should usually be the same as your camera's fov.
|
|
28
|
+
* @default undefined (meaning it will use the camera fov on the first frame)
|
|
29
|
+
*/
|
|
30
|
+
referenceFieldOfView = undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Enable debug logs and rendering for this component instance
|
|
33
|
+
*/
|
|
34
|
+
debug = false;
|
|
35
|
+
onEnable() {
|
|
36
|
+
if (debugParam || this.debug || isDevEnvironment())
|
|
37
|
+
console.debug("[ViewBox] Using camera fov:", this.referenceFieldOfView);
|
|
38
|
+
// register instance
|
|
39
|
+
ViewBox_1.instances.push(this);
|
|
40
|
+
}
|
|
41
|
+
onDisable() {
|
|
42
|
+
if (debugParam || this.debug)
|
|
43
|
+
console.debug("[ViewBox] Disabled");
|
|
44
|
+
// unregister instance
|
|
45
|
+
const idx = ViewBox_1.instances.indexOf(this);
|
|
46
|
+
if (idx !== -1)
|
|
47
|
+
ViewBox_1.instances.splice(idx, 1);
|
|
48
|
+
this._projectedBoxElement?.remove();
|
|
49
|
+
}
|
|
50
|
+
onBeforeRender() {
|
|
51
|
+
if (this.context.isInXR)
|
|
52
|
+
return;
|
|
53
|
+
if (this.destroyed)
|
|
54
|
+
return;
|
|
55
|
+
const isActive = ViewBox_1.instances[ViewBox_1.instances.length - 1] === this;
|
|
56
|
+
if (!isActive) {
|
|
57
|
+
if (debugParam || this.debug) {
|
|
58
|
+
Gizmos.DrawWireBox(this.gameObject.worldPosition, this.gameObject.worldScale, disabledGizmoColor);
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (debugParam || this.debug)
|
|
63
|
+
Gizmos.DrawWireBox(this.gameObject.worldPosition, this.gameObject.worldScale, 0xdddd00, 0, true, this.gameObject.worldQuaternion);
|
|
64
|
+
// calculate box size to fit the camera frustrum size at the current position (just scale)
|
|
65
|
+
const camera = this.context.mainCamera;
|
|
66
|
+
if (!camera)
|
|
67
|
+
return;
|
|
68
|
+
if (!(camera instanceof PerspectiveCamera)) {
|
|
69
|
+
// TODO: support orthographic camera
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (this.referenceFieldOfView === undefined) {
|
|
73
|
+
this.referenceFieldOfView = camera.fov;
|
|
74
|
+
}
|
|
75
|
+
if (this.referenceFieldOfView === undefined || this.referenceFieldOfView <= 0) {
|
|
76
|
+
if (debugParam || this.debug)
|
|
77
|
+
console.warn("[ViewBox] No valid referenceFieldOfView set, cannot adjust box size:", this.referenceFieldOfView);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const domWidth = this.context.domWidth;
|
|
81
|
+
const domHeight = this.context.domHeight;
|
|
82
|
+
let rectPosX = 0;
|
|
83
|
+
let rectPosY = 0;
|
|
84
|
+
let rectWidth = domWidth;
|
|
85
|
+
let rectHeight = domHeight;
|
|
86
|
+
let diffWidth = 1;
|
|
87
|
+
let diffHeight = 1;
|
|
88
|
+
// use focus rect if available
|
|
89
|
+
const focusRectSize = this.context.focusRectSize;
|
|
90
|
+
if (focusRectSize) {
|
|
91
|
+
// console.log(focusRectSize)
|
|
92
|
+
rectPosX = focusRectSize.x;
|
|
93
|
+
rectPosY = focusRectSize.y;
|
|
94
|
+
rectWidth = focusRectSize.width;
|
|
95
|
+
rectHeight = focusRectSize.height;
|
|
96
|
+
diffWidth = domWidth / rectWidth;
|
|
97
|
+
diffHeight = domHeight / rectHeight;
|
|
98
|
+
}
|
|
99
|
+
const view = camera.view;
|
|
100
|
+
const zoom = camera.zoom;
|
|
101
|
+
const aspect = camera.aspect;
|
|
102
|
+
const fov = camera.fov;
|
|
103
|
+
camera.view = null;
|
|
104
|
+
camera.zoom = 1;
|
|
105
|
+
camera.fov = this.referenceFieldOfView;
|
|
106
|
+
camera.updateProjectionMatrix();
|
|
107
|
+
const boxPosition = this.gameObject.worldPosition;
|
|
108
|
+
const boxScale = this.gameObject.worldScale;
|
|
109
|
+
const cameraPosition = camera.worldPosition;
|
|
110
|
+
const distance = cameraPosition.distanceTo(boxPosition);
|
|
111
|
+
// #region camera fixes
|
|
112
|
+
// If the camera is inside the box, move it out
|
|
113
|
+
const boxSizeMax = Math.max(boxScale.x, boxScale.y, boxScale.z);
|
|
114
|
+
const direction = getTempVector(cameraPosition).sub(boxPosition);
|
|
115
|
+
if (distance < boxSizeMax) {
|
|
116
|
+
// move camera out of bounds
|
|
117
|
+
if (this.debug || debugParam)
|
|
118
|
+
console.warn("[ViewBox] Moving camera out of bounds", distance, "<", boxSizeMax);
|
|
119
|
+
const positionDirection = getTempVector(direction);
|
|
120
|
+
positionDirection.y *= .00000001; // stay on horizontal plane mostly
|
|
121
|
+
positionDirection.normalize();
|
|
122
|
+
const lengthToMove = (boxSizeMax - distance);
|
|
123
|
+
const newPosition = cameraPosition.add(positionDirection.multiplyScalar(lengthToMove));
|
|
124
|
+
camera.worldPosition = newPosition.lerp(cameraPosition, 1 - this.context.time.deltaTime);
|
|
125
|
+
}
|
|
126
|
+
// Ensure the camera looks at the ViewBox
|
|
127
|
+
// TOOD: smooth lookat over multiple frames if we have multiple viewboxes
|
|
128
|
+
// const dot = direction.normalize().dot(camera.worldForward);
|
|
129
|
+
// if (dot < .9) {
|
|
130
|
+
// console.log(dot);
|
|
131
|
+
// const targetRotation = direction;
|
|
132
|
+
// const rotation = getTempQuaternion();
|
|
133
|
+
// rotation.setFromUnitVectors(camera.worldForward.multiplyScalar(-1), targetRotation);
|
|
134
|
+
// camera.worldQuaternion = rotation;
|
|
135
|
+
// camera.updateMatrixWorld();
|
|
136
|
+
// }
|
|
137
|
+
const boxPositionInCameraSpace = getTempVector(boxPosition);
|
|
138
|
+
camera.worldToLocal(boxPositionInCameraSpace);
|
|
139
|
+
camera.lookAt(boxPosition);
|
|
140
|
+
camera.updateMatrixWorld();
|
|
141
|
+
// #region calculate fit
|
|
142
|
+
const vFOV = this.referenceFieldOfView * Math.PI / 180; // convert vertical fov to radians
|
|
143
|
+
const height = 2 * Math.tan(vFOV / 2) * distance; // visible height
|
|
144
|
+
const width = height * camera.aspect; // visible width
|
|
145
|
+
const projectedBox = this.projectBoxIntoCamera(camera, 1);
|
|
146
|
+
// return
|
|
147
|
+
const boxWidth = (projectedBox.maxX - projectedBox.minX);
|
|
148
|
+
const boxHeight = (projectedBox.maxY - projectedBox.minY);
|
|
149
|
+
const scale = this.fit(boxWidth * camera.aspect, boxHeight, width / diffWidth, height / diffHeight);
|
|
150
|
+
// console.log({ scale, width, height, boxWidth: boxWidth * camera.aspect, boxHeight, diffWidth, diffHeight, aspect: camera.aspect, distance })
|
|
151
|
+
// this.context.focusRectSettings.zoom = 1.39;
|
|
152
|
+
// if (!this.context.focusRect) this.context.setCameraFocusRect(this.context.domElement);
|
|
153
|
+
// return
|
|
154
|
+
const vec = getTempVector(boxPosition);
|
|
155
|
+
vec.project(camera);
|
|
156
|
+
this.context.focusRectSettings.offsetX = vec.x;
|
|
157
|
+
this.context.focusRectSettings.offsetY = vec.y;
|
|
158
|
+
this.context.focusRectSettings.zoom = scale / (height * .5);
|
|
159
|
+
// if we don't have a focus rect yet, set it to the dom element
|
|
160
|
+
if (!this.context.focusRect)
|
|
161
|
+
this.context.setCameraFocusRect(this.context.domElement);
|
|
162
|
+
// Reset values
|
|
163
|
+
camera.view = view;
|
|
164
|
+
camera.zoom = zoom;
|
|
165
|
+
camera.aspect = aspect;
|
|
166
|
+
camera.fov = fov;
|
|
167
|
+
// camera.updateProjectionMatrix();
|
|
168
|
+
// BACKLOG: some code for box scale of an object (different component)
|
|
169
|
+
// this.gameObject.worldScale = getTempVector(width, height, worldscale.z);
|
|
170
|
+
// this.gameObject.scale.multiplyScalar(.98)
|
|
171
|
+
// const minscale = Math.min(width, height);
|
|
172
|
+
// console.log(width, height);
|
|
173
|
+
// this.gameObject.worldScale = getTempVector(scale, scale, scale);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Cover fit
|
|
177
|
+
*/
|
|
178
|
+
fit(width1, height1, width2, height2) {
|
|
179
|
+
const scaleX = width2 / width1;
|
|
180
|
+
const scaleY = height2 / height1;
|
|
181
|
+
return Math.min(scaleX, scaleY);
|
|
182
|
+
}
|
|
183
|
+
projectBoxIntoCamera(camera, _factor) {
|
|
184
|
+
const factor = .5 * _factor;
|
|
185
|
+
const corners = [
|
|
186
|
+
getTempVector(-factor, -factor, -factor),
|
|
187
|
+
getTempVector(factor, -factor, -factor),
|
|
188
|
+
getTempVector(-factor, factor, -factor),
|
|
189
|
+
getTempVector(factor, factor, -factor),
|
|
190
|
+
getTempVector(-factor, -factor, factor),
|
|
191
|
+
getTempVector(factor, -factor, factor),
|
|
192
|
+
getTempVector(-factor, factor, factor),
|
|
193
|
+
getTempVector(factor, factor, factor),
|
|
194
|
+
];
|
|
195
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
196
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
197
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
198
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
199
|
+
for (let i = 0; i < corners.length; i++) {
|
|
200
|
+
const c = corners[i];
|
|
201
|
+
c.applyMatrix4(this.gameObject.matrixWorld);
|
|
202
|
+
c.project(camera);
|
|
203
|
+
if (c.x < minX)
|
|
204
|
+
minX = c.x;
|
|
205
|
+
if (c.x > maxX)
|
|
206
|
+
maxX = c.x;
|
|
207
|
+
if (c.y < minY)
|
|
208
|
+
minY = c.y;
|
|
209
|
+
if (c.y > maxY)
|
|
210
|
+
maxY = c.y;
|
|
211
|
+
}
|
|
212
|
+
if (debugParam) {
|
|
213
|
+
if (!this._projectedBoxElement) {
|
|
214
|
+
this._projectedBoxElement = document.createElement("div");
|
|
215
|
+
}
|
|
216
|
+
if (this._projectedBoxElement.parentElement !== this.context.domElement)
|
|
217
|
+
this.context.domElement.appendChild(this._projectedBoxElement);
|
|
218
|
+
this._projectedBoxElement.style.position = "fixed";
|
|
219
|
+
// dotted but with larger gaps
|
|
220
|
+
this._projectedBoxElement.style.outline = "2px dashed rgba(255,0,0,.5)";
|
|
221
|
+
this._projectedBoxElement.style.left = ((minX * .5 + .5) * this.context.domWidth) + "px";
|
|
222
|
+
this._projectedBoxElement.style.top = ((-maxY * .5 + .5) * this.context.domHeight) + "px";
|
|
223
|
+
this._projectedBoxElement.style.width = ((maxX - minX) * .5 * this.context.domWidth) + "px";
|
|
224
|
+
this._projectedBoxElement.style.height = ((maxY - minY) * .5 * this.context.domHeight) + "px";
|
|
225
|
+
this._projectedBoxElement.style.pointerEvents = "none";
|
|
226
|
+
this._projectedBoxElement.style.zIndex = "1000";
|
|
227
|
+
}
|
|
228
|
+
return { minX, maxX, minY, maxY };
|
|
229
|
+
}
|
|
230
|
+
_projectedBoxElement = null;
|
|
231
|
+
};
|
|
232
|
+
__decorate([
|
|
233
|
+
serializable()
|
|
234
|
+
], ViewBox.prototype, "referenceFieldOfView", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
serializable()
|
|
237
|
+
], ViewBox.prototype, "debug", void 0);
|
|
238
|
+
ViewBox = ViewBox_1 = __decorate([
|
|
239
|
+
registerType
|
|
240
|
+
], ViewBox);
|
|
241
|
+
export { ViewBox };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AoB,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;YACvD,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;SACnD;QAGD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAEtC,CAAC;IACO,oBAAoB,GAAuB,IAAI,CAAC;;AAlOxD;IADC,YAAY,EAAE;qDACsC;AAMrD;IADC,YAAY,EAAE;sCACQ;AAfd,OAAO;IADnB,YAAY;GACA,OAAO,CAgPnB;SAhPY,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine-components/web/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine-components/web/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../src/engine-components-experimental/Presentation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAE3C,SAAS,GAAY,MAAM,CAAC;IAE5B,MAAM;QACF,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC9C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;SACjE;IACL,CAAC;CACJ"}
|
|
1
|
+
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../src/engine-components-experimental/Presentation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,gBAAgB;AAChB,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAE3C,SAAS,GAAY,MAAM,CAAC;IAE5B,MAAM;QACF,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC9C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;SACjE;IACL,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "4.10.0-next.
|
|
3
|
+
"version": "4.10.0-next.f5ce0ae",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.",
|
|
5
5
|
"main": "dist/needle-engine.min.js",
|
|
6
6
|
"exports": {
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"n8ao": "^1.9.3",
|
|
102
102
|
"peerjs": "1.4.7",
|
|
103
103
|
"postprocessing": "^6.36.6",
|
|
104
|
+
"scroll-timeline-polyfill": "^1.1.0",
|
|
104
105
|
"simplex-noise": "^4.0.1",
|
|
105
106
|
"stats.js": "^0.17.0",
|
|
106
107
|
"three": "npm:@needle-tools/three@0.169.10",
|
|
@@ -142,6 +142,7 @@ import { ClickThrough } from "../../engine-components/web/Clickthrough.js";
|
|
|
142
142
|
import { CursorFollow } from "../../engine-components/web/CursorFollow.js";
|
|
143
143
|
import { HoverAnimation } from "../../engine-components/web/HoverAnimation.js";
|
|
144
144
|
import { ScrollFollow } from "../../engine-components/web/ScrollFollow.js";
|
|
145
|
+
import { ViewBox } from "../../engine-components/web/ViewBox.js";
|
|
145
146
|
import { Avatar } from "../../engine-components/webxr/Avatar.js";
|
|
146
147
|
import { XRControllerFollow } from "../../engine-components/webxr/controllers/XRControllerFollow.js";
|
|
147
148
|
import { XRControllerModel } from "../../engine-components/webxr/controllers/XRControllerModel.js";
|
|
@@ -300,6 +301,7 @@ TypeStore.add("ClickThrough", ClickThrough);
|
|
|
300
301
|
TypeStore.add("CursorFollow", CursorFollow);
|
|
301
302
|
TypeStore.add("HoverAnimation", HoverAnimation);
|
|
302
303
|
TypeStore.add("ScrollFollow", ScrollFollow);
|
|
304
|
+
TypeStore.add("ViewBox", ViewBox);
|
|
303
305
|
TypeStore.add("Avatar", Avatar);
|
|
304
306
|
TypeStore.add("XRControllerFollow", XRControllerFollow);
|
|
305
307
|
TypeStore.add("XRControllerModel", XRControllerModel);
|
|
@@ -87,7 +87,7 @@ export type FitCameraReturnType = {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
export function fitCamera(
|
|
90
|
+
export function fitCamera(options?: FitCameraOptions): null | FitCameraReturnType {
|
|
91
91
|
|
|
92
92
|
if (NeedleXRSession.active) {
|
|
93
93
|
// camera fitting in XR is not supported
|
|
@@ -102,37 +102,6 @@ export function fitCamera(objectsOrOptions?: Object3D | Array<Object3D> | FitCam
|
|
|
102
102
|
}
|
|
103
103
|
const camera = options?.camera || context.mainCamera;
|
|
104
104
|
|
|
105
|
-
let objects: Object3D | Array<Object3D> | undefined = undefined;
|
|
106
|
-
// If the user passed in an array as first argument
|
|
107
|
-
if (Array.isArray(objectsOrOptions)) {
|
|
108
|
-
objects = objectsOrOptions;
|
|
109
|
-
}
|
|
110
|
-
// If the user passed in an object as first argument
|
|
111
|
-
else if (objectsOrOptions && "type" in objectsOrOptions) {
|
|
112
|
-
objects = objectsOrOptions;
|
|
113
|
-
}
|
|
114
|
-
// If the user passed in an object as first argument and options as second argument
|
|
115
|
-
else if (objectsOrOptions && typeof objectsOrOptions === "object") {
|
|
116
|
-
if (!(objectsOrOptions instanceof Object3D) && !Array.isArray(objectsOrOptions)) {
|
|
117
|
-
options = objectsOrOptions;
|
|
118
|
-
objects = options.objects;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// Ensure objects are setup correctly
|
|
122
|
-
if (objects && !Array.isArray(objects)) {
|
|
123
|
-
objects = [objects];
|
|
124
|
-
}
|
|
125
|
-
if (!Array.isArray(objects) || objects && objects.length <= 0) {
|
|
126
|
-
objects = context.scene.children;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Make sure there's anything to fit to
|
|
130
|
-
if (!Array.isArray(objects) || objects.length <= 0) {
|
|
131
|
-
console.warn("No objects to fit camera to...");
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
105
|
// const controls = this._controls as ThreeOrbitControls | null;
|
|
137
106
|
|
|
138
107
|
if (!camera) {
|
|
@@ -155,6 +124,7 @@ export function fitCamera(objectsOrOptions?: Object3D | Array<Object3D> | FitCam
|
|
|
155
124
|
const size = new Vector3();
|
|
156
125
|
const center = new Vector3();
|
|
157
126
|
const aspect = camera instanceof PerspectiveCamera ? camera.aspect : 1;
|
|
127
|
+
const objects = options.objects || context.scene;
|
|
158
128
|
// TODO would be much better to calculate the bounds in camera space instead of world space -
|
|
159
129
|
// we would get proper view-dependant fit.
|
|
160
130
|
// Right now it's independent from where the camera is actually looking from,
|
|
@@ -2,6 +2,7 @@ import { Camera, HemisphereLightHelper, Object3D, PerspectiveCamera, Vector2, We
|
|
|
2
2
|
|
|
3
3
|
import { Mathf } from "./engine_math.js";
|
|
4
4
|
import type { ICameraController } from "./engine_types.js";
|
|
5
|
+
import { getParam } from "./engine_utils.js";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
const $cameraController = "needle:cameraController";
|
|
@@ -52,17 +53,29 @@ export type FocusRectSettings = {
|
|
|
52
53
|
/** Lower values will result in faster alignment with the rect (value ~= seconds to reach target)
|
|
53
54
|
* Minimum value is 0.
|
|
54
55
|
*/
|
|
55
|
-
damping: number
|
|
56
|
+
damping: number,
|
|
57
|
+
|
|
58
|
+
/** X offset in camera coordinates. Used by ViewBox component */
|
|
59
|
+
offsetX: number,
|
|
60
|
+
/** Y offset in camera coordinates. Used by ViewBox component */
|
|
61
|
+
offsetY: number,
|
|
62
|
+
/** Zoom factor. Used by ViewBox component */
|
|
63
|
+
zoom: number,
|
|
56
64
|
}
|
|
57
65
|
export type FocusRect = DOMRect | Element | { x: number, y: number, width: number, height: number };
|
|
58
66
|
|
|
59
67
|
let rendererRect: DOMRect | undefined = undefined;
|
|
60
68
|
const overlapRect = { x: 0, y: 0, width: 0, height: 0 };
|
|
69
|
+
const _testTime = 1;
|
|
70
|
+
const debug = getParam("debugfocusrect");
|
|
61
71
|
|
|
62
72
|
/** Used internally by the Needle Engine context via 'setFocusRect(<rect>)' */
|
|
63
|
-
export function updateCameraFocusRect(focusRect: FocusRect, dt: number, camera: PerspectiveCamera, renderer: WebGLRenderer) {
|
|
73
|
+
export function updateCameraFocusRect(focusRect: FocusRect, settings: FocusRectSettings, dt: number, camera: PerspectiveCamera, renderer: WebGLRenderer) {
|
|
64
74
|
|
|
65
75
|
if (focusRect instanceof Element) {
|
|
76
|
+
if(debug && focusRect instanceof HTMLElement) {
|
|
77
|
+
focusRect.style.outline = "2px dashed rgba(255, 150, 0, .8)";
|
|
78
|
+
}
|
|
66
79
|
focusRect = focusRect.getBoundingClientRect();
|
|
67
80
|
}
|
|
68
81
|
rendererRect = renderer.domElement.getBoundingClientRect();
|
|
@@ -76,16 +89,55 @@ export function updateCameraFocusRect(focusRect: FocusRect, dt: number, camera:
|
|
|
76
89
|
rect.x -= rendererRect.x;
|
|
77
90
|
rect.y -= rendererRect.y;
|
|
78
91
|
|
|
79
|
-
const
|
|
80
|
-
const
|
|
92
|
+
const sourceWidth = rendererRect.width;
|
|
93
|
+
const sourceHeight = rendererRect.height;
|
|
81
94
|
|
|
82
|
-
const view = camera.view;
|
|
95
|
+
const view = camera.view as PerspectiveCamera["view"];
|
|
83
96
|
|
|
97
|
+
// Apply zoom
|
|
98
|
+
const zoom = settings.zoom;
|
|
84
99
|
let offsetX = view?.offsetX || 0;
|
|
85
100
|
let offsetY = view?.offsetY || 0;
|
|
86
|
-
offsetX = Mathf.lerp(offsetX, targetX, dt);
|
|
87
|
-
offsetY = Mathf.lerp(offsetY, targetY, dt);
|
|
88
101
|
|
|
89
|
-
|
|
102
|
+
let width = rendererRect.width;
|
|
103
|
+
let height = rendererRect.height;
|
|
104
|
+
width /= zoom;
|
|
105
|
+
height /= zoom;
|
|
106
|
+
offsetX = width * (zoom - 1) * .5;
|
|
107
|
+
offsetY = height * (zoom - 1) * .5;
|
|
108
|
+
|
|
109
|
+
const focusRectCenterX = rect.x + rect.width * .5;
|
|
110
|
+
const focusRectCenterY = rect.y + rect.height * .5;
|
|
111
|
+
const rendererCenterX = rendererRect.width * .5;
|
|
112
|
+
const rendererCenterY = rendererRect.height * .5;
|
|
113
|
+
|
|
114
|
+
const diffx = focusRectCenterX - rendererCenterX;
|
|
115
|
+
const diffy = focusRectCenterY - rendererCenterY;
|
|
116
|
+
offsetX -= diffx / zoom;
|
|
117
|
+
offsetY -= diffy / zoom;
|
|
118
|
+
if (settings.offsetX !== undefined) {
|
|
119
|
+
offsetX += settings.offsetX * (rendererRect.width * .5);
|
|
120
|
+
}
|
|
121
|
+
if (settings.offsetY !== undefined) {
|
|
122
|
+
offsetY -= settings.offsetY * (rendererRect.height * .5);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
const currentOffsetX = view?.offsetX || offsetX;
|
|
127
|
+
const currentOffsetY = view?.offsetY || offsetY;
|
|
128
|
+
offsetX = Mathf.lerp(currentOffsetX, offsetX, dt);
|
|
129
|
+
offsetY = Mathf.lerp(currentOffsetY, offsetY, dt);
|
|
130
|
+
const currentWidth = view?.width || sourceWidth;
|
|
131
|
+
const currentHeight = view?.height || sourceHeight;
|
|
132
|
+
width = Mathf.lerp(currentWidth, width, dt);
|
|
133
|
+
height = Mathf.lerp(currentHeight, height, dt);
|
|
134
|
+
|
|
135
|
+
camera.setViewOffset(sourceWidth, sourceHeight, offsetX, offsetY, width, height);
|
|
90
136
|
camera.updateProjectionMatrix();
|
|
91
|
-
|
|
137
|
+
|
|
138
|
+
if (settings.damping > 0) {
|
|
139
|
+
settings.damping *= (1.0 - dt);
|
|
140
|
+
if (settings.damping < 0.01) settings.damping = 0;
|
|
141
|
+
settings.damping = Math.max(0, settings.damping);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -1382,21 +1382,61 @@ export class Context implements IContext {
|
|
|
1382
1382
|
* @param settings Optional settings for the focus rect. These will override the `focusRectSettings` property
|
|
1383
1383
|
*/
|
|
1384
1384
|
public setCameraFocusRect(rect: FocusRect | null, settings?: Partial<FocusRectSettings>) {
|
|
1385
|
+
const oldRect = this._focusRect;
|
|
1385
1386
|
this._focusRect = rect;
|
|
1386
1387
|
if (settings) {
|
|
1387
1388
|
Object.assign(this.focusRectSettings, settings);
|
|
1388
1389
|
}
|
|
1390
|
+
if (settings?.damping === undefined) {
|
|
1391
|
+
// if the new rect is on screen then set damping
|
|
1392
|
+
if (oldRect) {
|
|
1393
|
+
let domRect = oldRect as DOMRect;
|
|
1394
|
+
if (oldRect instanceof HTMLElement) {
|
|
1395
|
+
domRect = oldRect.getBoundingClientRect();
|
|
1396
|
+
}
|
|
1397
|
+
if (domRect && "top" in domRect) {
|
|
1398
|
+
const allowedDistance = 100;
|
|
1399
|
+
const isVisible = domRect.bottom >= -allowedDistance && domRect.right >= -allowedDistance && domRect.top <= window.innerHeight + allowedDistance && domRect.left <= window.innerWidth + allowedDistance;
|
|
1400
|
+
if (isVisible) this.focusRectSettings.damping = .2;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1389
1405
|
}
|
|
1390
1406
|
get focusRect() { return this._focusRect; }
|
|
1407
|
+
get focusRectSize(): null | { x: number, y: number, width: number, height: number } {
|
|
1408
|
+
const rect = this._focusRect;
|
|
1409
|
+
if (rect && (rect instanceof DOMRect || ("width" in rect && "height" in rect && "x" in rect && "y" in rect))) {
|
|
1410
|
+
return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
|
|
1411
|
+
}
|
|
1412
|
+
else if (rect instanceof HTMLElement) {
|
|
1413
|
+
const r = rect.getBoundingClientRect();
|
|
1414
|
+
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
1415
|
+
}
|
|
1416
|
+
return null;
|
|
1417
|
+
}
|
|
1391
1418
|
/** Settings when a focus rect is set. Use `setCameraFocusRect(...)` to do so.
|
|
1392
1419
|
* This can be used to offset the renderer center e.g. to a specific DOM element.
|
|
1393
1420
|
*/
|
|
1394
1421
|
readonly focusRectSettings: FocusRectSettings = {
|
|
1395
1422
|
/** Controls how fast the rect is centered. Smaller values mean the rect is centered faster.
|
|
1396
1423
|
* A minimum value of 0 means the rect is centered instantly.
|
|
1397
|
-
* @default
|
|
1424
|
+
* @default 0
|
|
1398
1425
|
*/
|
|
1399
|
-
damping:
|
|
1426
|
+
damping: 0,
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Zoom factor when a focus rect is set.
|
|
1430
|
+
*/
|
|
1431
|
+
zoom: 1,
|
|
1432
|
+
/**
|
|
1433
|
+
* Additional offset in pixels from the center of the rect
|
|
1434
|
+
*/
|
|
1435
|
+
offsetX: 0,
|
|
1436
|
+
/**
|
|
1437
|
+
* Additional offset in pixels from the center of the rect
|
|
1438
|
+
*/
|
|
1439
|
+
offsetY: 0,
|
|
1400
1440
|
};
|
|
1401
1441
|
private _focusRect: FocusRect | null = null;
|
|
1402
1442
|
|
|
@@ -1528,14 +1568,6 @@ export class Context implements IContext {
|
|
|
1528
1568
|
|
|
1529
1569
|
if (this.isVisibleToUser || this.runInBackground) {
|
|
1530
1570
|
|
|
1531
|
-
if (this._focusRect) {
|
|
1532
|
-
if (this.mainCamera instanceof PerspectiveCamera) {
|
|
1533
|
-
const settings = this.focusRectSettings;
|
|
1534
|
-
const dt = settings.damping > 0 ? this.time.deltaTime / settings.damping : 1;
|
|
1535
|
-
updateCameraFocusRect(this._focusRect, dt, this.mainCamera, this.renderer);
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
1571
|
this._currentFrameEvent = FrameEvent.OnBeforeRender;
|
|
1540
1572
|
|
|
1541
1573
|
// should we move these callbacks in the regular three onBeforeRender events?
|
|
@@ -1552,6 +1584,14 @@ export class Context implements IContext {
|
|
|
1552
1584
|
this.executeCoroutines(FrameEvent.OnBeforeRender);
|
|
1553
1585
|
invokeLifecycleFunctions(this, FrameEvent.OnBeforeRender);
|
|
1554
1586
|
|
|
1587
|
+
if (this._focusRect) {
|
|
1588
|
+
if (this.mainCamera instanceof PerspectiveCamera) {
|
|
1589
|
+
const settings = this.focusRectSettings;
|
|
1590
|
+
const dt = settings.damping > 0 ? this.time.deltaTime / settings.damping : 1;
|
|
1591
|
+
updateCameraFocusRect(this._focusRect, this.focusRectSettings, dt, this.mainCamera, this.renderer);
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1555
1595
|
if (this._needsUpdateSize)
|
|
1556
1596
|
this.updateSize();
|
|
1557
1597
|
|