@needle-tools/engine 4.10.0-beta → 4.10.0-beta.1
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-42AmEGfk.umd.cjs → needle-engine.bundle-6so_os_w.umd.cjs} +141 -130
- package/dist/{needle-engine.bundle-Dj6faVbC.js → needle-engine.bundle-Dj2DYdMY.js} +6063 -5884
- package/dist/{needle-engine.bundle-C6zhyLF5.min.js → needle-engine.bundle-Djy6H4lx.min.js} +163 -152
- package/dist/needle-engine.js +258 -257
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- 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/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.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-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 +4 -1
- package/lib/engine-components/Renderer.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/timeline/PlayableDirector.d.ts +7 -0
- package/lib/engine-components/timeline/PlayableDirector.js +7 -0
- 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.js +4 -2
- 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 +22 -0
- package/lib/engine-components/web/ScrollFollow.js +124 -13
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +16 -0
- package/lib/engine-components/web/ViewBox.js +183 -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/package.json +1 -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 +62 -8
- package/src/engine/engine_context.ts +50 -10
- 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-components/OrbitControls.ts +40 -1
- package/src/engine-components/Renderer.ts +4 -1
- package/src/engine-components/codegen/components.ts +1 -0
- package/src/engine-components/timeline/PlayableDirector.ts +9 -0
- package/src/engine-components/timeline/TimelineModels.ts +9 -1
- package/src/engine-components/timeline/TimelineTracks.ts +4 -2
- 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 +149 -15
- package/src/engine-components/web/ViewBox.ts +199 -0
- package/src/engine-components/web/index.ts +2 -1
|
@@ -0,0 +1,183 @@
|
|
|
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 { serializable } from "../../engine/engine_serialization_decorator.js";
|
|
10
|
+
import { registerType } from "../../engine/engine_typestore.js";
|
|
11
|
+
import { getTempVector } from "../../engine/engine_three_utils.js";
|
|
12
|
+
import { Behaviour } from "../Component.js";
|
|
13
|
+
import { isDevEnvironment } from "../../engine/debug/debug.js";
|
|
14
|
+
import { getParam } from "../../engine/engine_utils.js";
|
|
15
|
+
const debugParam = getParam("debugviewbox");
|
|
16
|
+
let ViewBox = ViewBox_1 = class ViewBox extends Behaviour {
|
|
17
|
+
static instances = [];
|
|
18
|
+
referenceFieldOfView = 60;
|
|
19
|
+
debug = false;
|
|
20
|
+
awake() {
|
|
21
|
+
// this.referenceFieldOfView = (this.context.mainCamera as PerspectiveCamera)?.fov || 60;
|
|
22
|
+
// setInterval(()=>{
|
|
23
|
+
// this.enabled = !this.enabled
|
|
24
|
+
// }, 1000)
|
|
25
|
+
}
|
|
26
|
+
onEnable() {
|
|
27
|
+
if (debugParam || this.debug || isDevEnvironment())
|
|
28
|
+
console.debug("[ViewBox] Using camera fov:", this.referenceFieldOfView);
|
|
29
|
+
ViewBox_1.instances.push(this);
|
|
30
|
+
}
|
|
31
|
+
onDisable() {
|
|
32
|
+
const idx = ViewBox_1.instances.indexOf(this);
|
|
33
|
+
if (idx !== -1)
|
|
34
|
+
ViewBox_1.instances.splice(idx, 1);
|
|
35
|
+
}
|
|
36
|
+
onBeforeRender() {
|
|
37
|
+
if (this.context.isInXR)
|
|
38
|
+
return;
|
|
39
|
+
const isActive = ViewBox_1.instances[ViewBox_1.instances.length - 1] === this;
|
|
40
|
+
if (!isActive)
|
|
41
|
+
return;
|
|
42
|
+
// calculate box size to fit the camera frustrum size at the current position (just scale)
|
|
43
|
+
const camera = this.context.mainCamera;
|
|
44
|
+
if (!camera)
|
|
45
|
+
return;
|
|
46
|
+
if (!(camera instanceof PerspectiveCamera)) {
|
|
47
|
+
// TODO: support orthographic camera
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (this.referenceFieldOfView === undefined || this.referenceFieldOfView <= 0) {
|
|
51
|
+
if (debugParam || this.debug)
|
|
52
|
+
console.warn("[ViewBox] No valid referenceFieldOfView set, cannot adjust box size:", this.referenceFieldOfView);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const domRect = this.context.domElement.getBoundingClientRect();
|
|
56
|
+
const domX = domRect.x;
|
|
57
|
+
const domY = domRect.y;
|
|
58
|
+
const domWidth = domRect.width;
|
|
59
|
+
const domHeight = domRect.height;
|
|
60
|
+
let rectPosX = 0;
|
|
61
|
+
let rectPosY = 0;
|
|
62
|
+
let rectWidth = domWidth;
|
|
63
|
+
let rectHeight = domHeight;
|
|
64
|
+
let diffWidth = 1;
|
|
65
|
+
let diffHeight = 1;
|
|
66
|
+
// use focus rect if available
|
|
67
|
+
const focusRectSize = this.context.focusRectSize;
|
|
68
|
+
if (focusRectSize) {
|
|
69
|
+
// console.log(focusRectSize)
|
|
70
|
+
rectPosX = focusRectSize.x;
|
|
71
|
+
rectPosY = focusRectSize.y;
|
|
72
|
+
rectWidth = focusRectSize.width;
|
|
73
|
+
rectHeight = focusRectSize.height;
|
|
74
|
+
diffWidth = domWidth / rectWidth;
|
|
75
|
+
diffHeight = domHeight / rectHeight;
|
|
76
|
+
}
|
|
77
|
+
// const view = camera.view;
|
|
78
|
+
const view = camera.view;
|
|
79
|
+
const zoom = camera.zoom;
|
|
80
|
+
const aspect = camera.aspect;
|
|
81
|
+
const fov = camera.fov;
|
|
82
|
+
camera.view = null;
|
|
83
|
+
camera.zoom = 1;
|
|
84
|
+
// camera.aspect = rectWidth / rectHeight;
|
|
85
|
+
camera.fov = this.referenceFieldOfView;
|
|
86
|
+
camera.updateProjectionMatrix();
|
|
87
|
+
const boxPosition = this.gameObject.worldPosition;
|
|
88
|
+
const boxScale = this.gameObject.worldScale;
|
|
89
|
+
// const fov = this.referenceFieldOfView
|
|
90
|
+
const distance = camera.worldPosition.distanceTo(boxPosition);
|
|
91
|
+
const vFOV = this.referenceFieldOfView * Math.PI / 180; // convert vertical fov to radians
|
|
92
|
+
const height = 2 * Math.tan(vFOV / 2) * distance; // visible height
|
|
93
|
+
const width = height * camera.aspect; // visible width
|
|
94
|
+
const projectedBox = this.projectBoxIntoCamera(boxPosition, boxScale, camera, height * .5);
|
|
95
|
+
const boxWidth = (projectedBox.maxX - projectedBox.minX);
|
|
96
|
+
const boxHeight = (projectedBox.maxY - projectedBox.minY);
|
|
97
|
+
// TODO: take the rect size different into account
|
|
98
|
+
const scale = this.fit(boxWidth * camera.aspect, boxHeight, width / diffWidth, height / diffHeight);
|
|
99
|
+
const vec = getTempVector(boxPosition);
|
|
100
|
+
vec.project(camera);
|
|
101
|
+
this.context.focusRectSettings.offsetX = vec.x;
|
|
102
|
+
this.context.focusRectSettings.offsetY = vec.y;
|
|
103
|
+
this.context.focusRectSettings.zoom = scale;
|
|
104
|
+
// if we don't have a focus rect yet, set it to the dom element
|
|
105
|
+
if (!this.context.focusRect)
|
|
106
|
+
this.context.setCameraFocusRect(this.context.domElement);
|
|
107
|
+
// Reset values
|
|
108
|
+
camera.view = view;
|
|
109
|
+
camera.zoom = zoom;
|
|
110
|
+
camera.aspect = aspect;
|
|
111
|
+
camera.fov = fov;
|
|
112
|
+
// camera.updateProjectionMatrix();
|
|
113
|
+
// BACKLOG: some code for box scale of an object (different component)
|
|
114
|
+
// this.gameObject.worldScale = getTempVector(width, height, worldscale.z);
|
|
115
|
+
// this.gameObject.scale.multiplyScalar(.98)
|
|
116
|
+
// const minscale = Math.min(width, height);
|
|
117
|
+
// console.log(width, height);
|
|
118
|
+
// this.gameObject.worldScale = getTempVector(scale, scale, scale);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Cover fit
|
|
122
|
+
*/
|
|
123
|
+
fit(width1, height1, width2, height2) {
|
|
124
|
+
const scaleX = width2 / width1;
|
|
125
|
+
const scaleY = height2 / height1;
|
|
126
|
+
return Math.min(scaleX, scaleY);
|
|
127
|
+
}
|
|
128
|
+
projectBoxIntoCamera(position, scale, camera, diff) {
|
|
129
|
+
const factor = .5 * diff;
|
|
130
|
+
const corners = [
|
|
131
|
+
getTempVector(-scale.x * factor, -scale.y * factor, -scale.z * factor),
|
|
132
|
+
getTempVector(scale.x * factor, -scale.y * factor, -scale.z * factor),
|
|
133
|
+
getTempVector(-scale.x * factor, scale.y * factor, -scale.z * factor),
|
|
134
|
+
getTempVector(scale.x * factor, scale.y * factor, -scale.z * factor),
|
|
135
|
+
getTempVector(-scale.x * factor, -scale.y * factor, scale.z * factor),
|
|
136
|
+
getTempVector(scale.x * factor, -scale.y * factor, scale.z * factor),
|
|
137
|
+
getTempVector(-scale.x * factor, scale.y * factor, scale.z * factor),
|
|
138
|
+
getTempVector(scale.x * factor, scale.y * factor, scale.z * factor),
|
|
139
|
+
];
|
|
140
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
141
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
142
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
143
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
144
|
+
for (let i = 0; i < corners.length; i++) {
|
|
145
|
+
const c = corners[i];
|
|
146
|
+
c.add(position);
|
|
147
|
+
c.project(camera);
|
|
148
|
+
if (c.x < minX)
|
|
149
|
+
minX = c.x;
|
|
150
|
+
if (c.x > maxX)
|
|
151
|
+
maxX = c.x;
|
|
152
|
+
if (c.y < minY)
|
|
153
|
+
minY = c.y;
|
|
154
|
+
if (c.y > maxY)
|
|
155
|
+
maxY = c.y;
|
|
156
|
+
}
|
|
157
|
+
// if(!this._projectedBoxElement) {
|
|
158
|
+
// this._projectedBoxElement = document.createElement("div");
|
|
159
|
+
// this.context.domElement.appendChild(this._projectedBoxElement);
|
|
160
|
+
// }
|
|
161
|
+
// this._projectedBoxElement.style.position = "fixed";
|
|
162
|
+
// this._projectedBoxElement.style.outline = "10px solid red";
|
|
163
|
+
// this._projectedBoxElement.style.left = ((minX * .5 + .5) * this.context.domWidth) + "px";
|
|
164
|
+
// this._projectedBoxElement.style.top = ((-maxY * .5 + .5) * this.context.domHeight) + "px";
|
|
165
|
+
// this._projectedBoxElement.style.width = ((maxX - minX) * .5 * this.context.domWidth) + "px";
|
|
166
|
+
// this._projectedBoxElement.style.height = ((maxY - minY) * .5 * this.context.domHeight) + "px";
|
|
167
|
+
// this._projectedBoxElement.style.pointerEvents = "none";
|
|
168
|
+
// this._projectedBoxElement.style.zIndex = "1000";
|
|
169
|
+
return { minX, maxX, minY, maxY };
|
|
170
|
+
}
|
|
171
|
+
_projectedBoxElement = null;
|
|
172
|
+
};
|
|
173
|
+
__decorate([
|
|
174
|
+
serializable()
|
|
175
|
+
], ViewBox.prototype, "referenceFieldOfView", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
serializable()
|
|
178
|
+
], ViewBox.prototype, "debug", void 0);
|
|
179
|
+
ViewBox = ViewBox_1 = __decorate([
|
|
180
|
+
registerType
|
|
181
|
+
], ViewBox);
|
|
182
|
+
export { ViewBox };
|
|
183
|
+
//# sourceMappingURL=ViewBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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tC,CAAC;IACO,oBAAoB,GAAuB,IAAI,CAAC;;AAjLxD;IADC,YAAY,EAAE;qDACmB;AAGlC;IADC,YAAY,EAAE;sCACQ;AARd,OAAO;IADnB,YAAY;GACA,OAAO,CA2LnB;SA3LY,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "4.10.0-beta",
|
|
3
|
+
"version": "4.10.0-beta.1",
|
|
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": {
|
|
@@ -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,
|
|
@@ -52,15 +52,23 @@ export type FocusRectSettings = {
|
|
|
52
52
|
/** Lower values will result in faster alignment with the rect (value ~= seconds to reach target)
|
|
53
53
|
* Minimum value is 0.
|
|
54
54
|
*/
|
|
55
|
-
damping: number
|
|
55
|
+
damping: number,
|
|
56
|
+
|
|
57
|
+
/** X offset in camera coordinates. Used by ViewBox component */
|
|
58
|
+
offsetX: number,
|
|
59
|
+
/** Y offset in camera coordinates. Used by ViewBox component */
|
|
60
|
+
offsetY: number,
|
|
61
|
+
/** Zoom factor. Used by ViewBox component */
|
|
62
|
+
zoom: number,
|
|
56
63
|
}
|
|
57
64
|
export type FocusRect = DOMRect | Element | { x: number, y: number, width: number, height: number };
|
|
58
65
|
|
|
59
66
|
let rendererRect: DOMRect | undefined = undefined;
|
|
60
67
|
const overlapRect = { x: 0, y: 0, width: 0, height: 0 };
|
|
68
|
+
let _testTime = 1;
|
|
61
69
|
|
|
62
70
|
/** Used internally by the Needle Engine context via 'setFocusRect(<rect>)' */
|
|
63
|
-
export function updateCameraFocusRect(focusRect: FocusRect, dt: number, camera: PerspectiveCamera, renderer: WebGLRenderer) {
|
|
71
|
+
export function updateCameraFocusRect(focusRect: FocusRect, settings: FocusRectSettings, dt: number, camera: PerspectiveCamera, renderer: WebGLRenderer) {
|
|
64
72
|
|
|
65
73
|
if (focusRect instanceof Element) {
|
|
66
74
|
focusRect = focusRect.getBoundingClientRect();
|
|
@@ -76,16 +84,62 @@ export function updateCameraFocusRect(focusRect: FocusRect, dt: number, camera:
|
|
|
76
84
|
rect.x -= rendererRect.x;
|
|
77
85
|
rect.y -= rendererRect.y;
|
|
78
86
|
|
|
79
|
-
const
|
|
80
|
-
const
|
|
87
|
+
const sourceWidth = rendererRect.width;
|
|
88
|
+
const sourceHeight = rendererRect.height;
|
|
81
89
|
|
|
82
|
-
const view = camera.view;
|
|
90
|
+
const view = camera.view as PerspectiveCamera["view"];
|
|
83
91
|
|
|
92
|
+
// Apply zoom
|
|
93
|
+
let zoom = settings.zoom;
|
|
84
94
|
let offsetX = view?.offsetX || 0;
|
|
85
95
|
let offsetY = view?.offsetY || 0;
|
|
86
|
-
offsetX = Mathf.lerp(offsetX, targetX, dt);
|
|
87
|
-
offsetY = Mathf.lerp(offsetY, targetY, dt);
|
|
88
96
|
|
|
89
|
-
|
|
97
|
+
let width = rendererRect.width;
|
|
98
|
+
let height = rendererRect.height;
|
|
99
|
+
width /= zoom;
|
|
100
|
+
height /= zoom;
|
|
101
|
+
offsetX = width * (zoom - 1) * .5;
|
|
102
|
+
offsetY = height * (zoom - 1) * .5;
|
|
103
|
+
|
|
104
|
+
const focusRectCenterX = rect.x + rect.width * .5;
|
|
105
|
+
const focusRectCenterY = rect.y + rect.height * .5;
|
|
106
|
+
const rendererCenterX = rendererRect.width * .5;
|
|
107
|
+
const rendererCenterY = rendererRect.height * .5;
|
|
108
|
+
|
|
109
|
+
const diffx = focusRectCenterX - rendererCenterX;
|
|
110
|
+
const diffy = focusRectCenterY - rendererCenterY;
|
|
111
|
+
offsetX -= diffx / zoom;
|
|
112
|
+
offsetY -= diffy / zoom;
|
|
113
|
+
if (settings.offsetX !== undefined) {
|
|
114
|
+
offsetX += settings.offsetX * (rendererRect.width * .5);
|
|
115
|
+
}
|
|
116
|
+
if (settings.offsetY !== undefined) {
|
|
117
|
+
offsetY -= settings.offsetY * (rendererRect.height * .5);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
const currentOffsetX = view?.offsetX || offsetX;
|
|
122
|
+
const currentOffsetY = view?.offsetY || offsetY;
|
|
123
|
+
offsetX = Mathf.lerp(currentOffsetX, offsetX, dt);
|
|
124
|
+
offsetY = Mathf.lerp(currentOffsetY, offsetY, dt);
|
|
125
|
+
const currentWidth = view?.width || sourceWidth;
|
|
126
|
+
const currentHeight = view?.height || sourceHeight;
|
|
127
|
+
width = Mathf.lerp(currentWidth, width, dt);
|
|
128
|
+
height = Mathf.lerp(currentHeight, height, dt);
|
|
129
|
+
|
|
130
|
+
camera.setViewOffset(sourceWidth, sourceHeight, offsetX, offsetY, width, height);
|
|
90
131
|
camera.updateProjectionMatrix();
|
|
132
|
+
|
|
133
|
+
if (settings.damping > 0) {
|
|
134
|
+
settings.damping *= (1.0 - dt);
|
|
135
|
+
if (settings.damping < 0.01) settings.damping = 0;
|
|
136
|
+
settings.damping = Math.max(0, settings.damping);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
function fit(width1: number, height1: number, width2: number, height2: number) {
|
|
142
|
+
const scaleX = width2 / width1;
|
|
143
|
+
const scaleY = height2 / height1;
|
|
144
|
+
return Math.max(scaleX, scaleY);
|
|
91
145
|
}
|
|
@@ -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
|
|
|
@@ -32,10 +32,22 @@ export class NeedleLogoElement extends HTMLElement {
|
|
|
32
32
|
cursor: pointer;
|
|
33
33
|
}
|
|
34
34
|
img {
|
|
35
|
-
width: 95px;
|
|
36
35
|
height: 100%;
|
|
37
36
|
align-self: end;
|
|
38
37
|
margin-left: 0.6rem;
|
|
38
|
+
transition: transform 0.2s;
|
|
39
|
+
}
|
|
40
|
+
img.with-text {
|
|
41
|
+
width: 11.5ch;
|
|
42
|
+
&:hover {
|
|
43
|
+
transform: scale(1.02);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
img.compact {
|
|
47
|
+
width: 1.7em;
|
|
48
|
+
&:hover {
|
|
49
|
+
transform: scale(1.1);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
52
|
span {
|
|
41
53
|
font-size: 1rem;
|
|
@@ -43,12 +55,14 @@ export class NeedleLogoElement extends HTMLElement {
|
|
|
43
55
|
}
|
|
44
56
|
</style>
|
|
45
57
|
<div class="wrapper">
|
|
46
|
-
<img class="logo" src=${needleLogoSVG} />
|
|
58
|
+
<img class="logo with-text" src=${needleLogoSVG} />
|
|
47
59
|
</div>
|
|
48
60
|
`;
|
|
49
61
|
this._root.appendChild(template.content.cloneNode(true));
|
|
50
62
|
this.wrapper = this._root.querySelector(".wrapper") as HTMLDivElement;
|
|
51
63
|
this._root.appendChild(this.wrapper);
|
|
64
|
+
this.logoElement = this._root.querySelector("img.logo") as HTMLImageElement;
|
|
65
|
+
|
|
52
66
|
// this.wrapper.classList.add("wrapper");
|
|
53
67
|
|
|
54
68
|
// this.wrapper.appendChild(this.logoElement);
|
|
@@ -67,13 +81,24 @@ export class NeedleLogoElement extends HTMLElement {
|
|
|
67
81
|
|
|
68
82
|
private readonly _root: ShadowRoot;
|
|
69
83
|
private readonly wrapper: HTMLDivElement;
|
|
70
|
-
private readonly logoElement: HTMLImageElement
|
|
71
|
-
private readonly textElement: HTMLSpanElement = document.createElement("span");
|
|
84
|
+
private readonly logoElement: HTMLImageElement;
|
|
72
85
|
|
|
73
86
|
setLogoVisible(val: boolean) {
|
|
74
87
|
this.logoElement.style.display = val ? "block" : "none";
|
|
75
88
|
}
|
|
76
89
|
|
|
90
|
+
setType(type: "full" | "compact") {
|
|
91
|
+
if (type === "full") {
|
|
92
|
+
this.logoElement.src = needleLogoSVG;
|
|
93
|
+
this.logoElement.classList.remove("with-text");
|
|
94
|
+
this.logoElement.classList.remove("compact");
|
|
95
|
+
} else {
|
|
96
|
+
this.logoElement.src = needleLogoOnlySVG;
|
|
97
|
+
this.logoElement.classList.add("with-text");
|
|
98
|
+
this.logoElement.classList.add("compact");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
77
102
|
}
|
|
78
103
|
if (!customElements.get(elementName))
|
|
79
104
|
customElements.define(elementName, NeedleLogoElement);
|
|
@@ -459,7 +459,7 @@ export class NeedleMenuElement extends HTMLElement {
|
|
|
459
459
|
|
|
460
460
|
.logo {
|
|
461
461
|
cursor: pointer;
|
|
462
|
-
padding-left: 0.
|
|
462
|
+
padding-left: 0.0rem;
|
|
463
463
|
padding-bottom: .02rem;
|
|
464
464
|
margin-right: 0.5rem;
|
|
465
465
|
}
|
|
@@ -664,8 +664,8 @@ export class NeedleMenuElement extends HTMLElement {
|
|
|
664
664
|
<slot name="end"></slot>
|
|
665
665
|
</div>
|
|
666
666
|
</div>
|
|
667
|
-
<div style="user-select:none" class="logo">
|
|
668
|
-
<span class="madewith notranslate">powered by</span>
|
|
667
|
+
<div style="user-select:none;" class="logo">
|
|
668
|
+
<span class="madewith notranslate" style="display:none;">powered by</span>
|
|
669
669
|
</div>
|
|
670
670
|
</div>
|
|
671
671
|
<button class="compact-menu-button">
|
|
@@ -698,6 +698,7 @@ export class NeedleMenuElement extends HTMLElement {
|
|
|
698
698
|
this.wrapper.classList.add("wrapper");
|
|
699
699
|
|
|
700
700
|
const logo = NeedleLogoElement.create();
|
|
701
|
+
logo.setType("compact");
|
|
701
702
|
logo.style.minHeight = "1rem";
|
|
702
703
|
this.logoContainer.append(logo);
|
|
703
704
|
this.logoContainer.addEventListener("click", () => {
|
|
@@ -374,40 +374,40 @@ export class EngineLoadingView implements ILoadingViewHandler {
|
|
|
374
374
|
// }
|
|
375
375
|
// }
|
|
376
376
|
|
|
377
|
-
this.handleRuntimeLicense(this._loadingElement);
|
|
377
|
+
// this.handleRuntimeLicense(this._loadingElement);
|
|
378
378
|
|
|
379
379
|
return this._loadingElement;
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
private async handleRuntimeLicense(loadingElement: HTMLElement) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
382
|
+
// private async handleRuntimeLicense(loadingElement: HTMLElement) {
|
|
383
|
+
// // First check if we have a commercial license
|
|
384
|
+
// let commercialLicense = hasCommercialLicense();
|
|
385
|
+
// // if it's the case then we don't need to perform a runtime check
|
|
386
|
+
// if (commercialLicense) return;
|
|
387
|
+
|
|
388
|
+
// // If we don't have a commercial license, then we need to display our message
|
|
389
|
+
// if (debugLicense) console.log("Loading UI has commercial license?", commercialLicense);
|
|
390
|
+
// const nonCommercialContainer = document.createElement("div");
|
|
391
|
+
// nonCommercialContainer.style.paddingTop = ".6em";
|
|
392
|
+
// nonCommercialContainer.style.fontSize = ".8em";
|
|
393
|
+
// nonCommercialContainer.style.textTransform = "uppercase";
|
|
394
|
+
// nonCommercialContainer.innerText = "NEEDLE ENGINE NON COMMERCIAL VERSION\nCLICK HERE TO GET A LICENSE";
|
|
395
|
+
// nonCommercialContainer.style.cursor = "pointer";
|
|
396
|
+
// nonCommercialContainer.style.userSelect = "none";
|
|
397
|
+
// nonCommercialContainer.style.textAlign = "center";
|
|
398
|
+
// nonCommercialContainer.style.pointerEvents = "all";
|
|
399
|
+
// nonCommercialContainer.addEventListener("click", () => window.open("https://needle.tools/pricing", "_self"));
|
|
400
|
+
// nonCommercialContainer.style.opacity = "0";
|
|
401
|
+
// loadingElement.appendChild(nonCommercialContainer);
|
|
402
|
+
|
|
403
|
+
// // Use the runtime license check
|
|
404
|
+
// if (!isDevEnvironment() && runtimeLicenseCheckPromise) {
|
|
405
|
+
// if (debugLicense) console.log("Waiting for runtime license check");
|
|
406
|
+
// await runtimeLicenseCheckPromise;
|
|
407
|
+
// commercialLicense = hasCommercialLicense();
|
|
408
|
+
// }
|
|
409
|
+
// if (commercialLicense) return;
|
|
410
|
+
// nonCommercialContainer.style.transition = "opacity .5s ease-in-out";
|
|
411
|
+
// nonCommercialContainer.style.opacity = "1";
|
|
412
|
+
// }
|
|
413
413
|
}
|