@needle-tools/engine 2.36.0-pre → 2.38.0-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 +33 -0
- package/dist/needle-engine.d.ts +248 -151
- package/dist/needle-engine.js +451 -437
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +82 -82
- package/dist/needle-engine.min.js.map +4 -4
- 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.d.ts +1 -0
- package/lib/engine/debug/debug.js +3 -0
- package/lib/engine/debug/debug.js.map +1 -1
- package/lib/engine/engine_addressables.d.ts +3 -1
- package/lib/engine/engine_addressables.js +12 -5
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_element.js +3 -2
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_overlay.js +4 -3
- package/lib/engine/engine_element_overlay.js.map +1 -1
- package/lib/engine/engine_gameobject.js +2 -1
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_input.d.ts +2 -0
- package/lib/engine/engine_input.js +14 -3
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +35 -46
- package/lib/engine/engine_physics.js +479 -386
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics.types.d.ts +23 -0
- package/lib/engine/engine_physics.types.js +27 -0
- package/lib/engine/engine_physics.types.js.map +1 -0
- package/lib/engine/engine_serialization_core.d.ts +3 -0
- package/lib/engine/engine_serialization_core.js +5 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_setup.d.ts +7 -1
- package/lib/engine/engine_setup.js +13 -3
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_types.d.ts +45 -26
- package/lib/engine/engine_types.js +24 -37
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_util_decorator.d.ts +6 -0
- package/lib/engine/engine_util_decorator.js +54 -0
- package/lib/engine/engine_util_decorator.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js +1 -1
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_gameobject_data.js +2 -0
- package/lib/engine/extensions/NEEDLE_gameobject_data.js.map +1 -1
- package/lib/engine-components/Animation.d.ts +7 -5
- package/lib/engine-components/Animation.js +7 -7
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimatorController.js +14 -7
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/BoxHelperComponent.js +1 -0
- package/lib/engine-components/BoxHelperComponent.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +1 -0
- package/lib/engine-components/Camera.js +20 -5
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CharacterController.d.ts +31 -0
- package/lib/engine-components/CharacterController.js +167 -0
- package/lib/engine-components/CharacterController.js.map +1 -0
- package/lib/engine-components/Collider.d.ts +16 -5
- package/lib/engine-components/Collider.js +45 -23
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +6 -15
- package/lib/engine-components/Component.js +7 -112
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.js +9 -6
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/Light.d.ts +2 -0
- package/lib/engine-components/Light.js +13 -2
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/NavMesh.d.ts +0 -5
- package/lib/engine-components/NavMesh.js +100 -10
- package/lib/engine-components/NavMesh.js.map +1 -1
- package/lib/engine-components/NestedGltf.js +2 -0
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/Renderer.js +4 -0
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +45 -25
- package/lib/engine-components/RigidBody.js +290 -142
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SmoothFollow.d.ts +2 -1
- package/lib/engine-components/SmoothFollow.js +25 -17
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/SpatialTrigger.js +1 -1
- package/lib/engine-components/SpatialTrigger.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.d.ts +1 -0
- package/lib/engine-components/SpectatorCamera.js +9 -2
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SpringJoint.d.ts +0 -13
- package/lib/engine-components/SpringJoint.js +42 -41
- package/lib/engine-components/SpringJoint.js.map +1 -1
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/WebXR.d.ts +1 -0
- package/lib/engine-components/WebXR.js +13 -6
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRController.js +12 -6
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +4 -3
- package/lib/engine-components/codegen/components.js +4 -3
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/package.json +3 -4
- package/src/engine/api.ts +2 -1
- package/src/engine/codegen/register_types.js +16 -12
- package/src/engine/debug/debug.ts +4 -0
- package/src/engine/dist/engine_physics.js +739 -0
- package/src/engine/dist/engine_setup.js +777 -0
- package/src/engine/engine_addressables.ts +18 -8
- package/src/engine/engine_element.ts +3 -2
- package/src/engine/engine_element_overlay.ts +4 -3
- package/src/engine/engine_gameobject.ts +4 -4
- package/src/engine/engine_input.ts +12 -3
- package/src/engine/engine_physics.ts +492 -418
- package/src/engine/engine_physics.types.ts +28 -0
- package/src/engine/engine_serialization_core.ts +8 -1
- package/src/engine/engine_setup.ts +31 -18
- package/src/engine/engine_types.ts +83 -56
- package/src/engine/engine_util_decorator.ts +69 -0
- package/src/engine/engine_utils.ts +3 -3
- package/src/engine/extensions/NEEDLE_gameobject_data.ts +2 -0
- package/src/engine-components/Animation.ts +18 -12
- package/src/engine-components/AnimatorController.ts +16 -11
- package/src/engine-components/BoxHelperComponent.ts +1 -0
- package/src/engine-components/Camera.ts +21 -4
- package/src/engine-components/CharacterController.ts +171 -0
- package/src/engine-components/Collider.ts +49 -39
- package/src/engine-components/Component.ts +15 -130
- package/src/engine-components/DragControls.ts +9 -5
- package/src/engine-components/Light.ts +17 -3
- package/src/engine-components/NavMesh.ts +114 -115
- package/src/engine-components/NestedGltf.ts +2 -0
- package/src/engine-components/Renderer.ts +5 -1
- package/src/engine-components/RigidBody.ts +292 -149
- package/src/engine-components/SmoothFollow.ts +21 -18
- package/src/engine-components/SpatialTrigger.ts +1 -1
- package/src/engine-components/SpectatorCamera.ts +10 -2
- package/src/engine-components/SpringJoint.ts +41 -41
- package/src/engine-components/VideoPlayer.ts +1 -2
- package/src/engine-components/WebXR.ts +15 -6
- package/src/engine-components/WebXRController.ts +16 -7
- package/src/engine-components/codegen/components.ts +4 -3
- package/src/engine-components/dist/CharacterController.js +123 -0
- package/src/engine-components/dist/RigidBody.js +458 -0
|
@@ -5,7 +5,7 @@ import { Context } from "./engine_setup";
|
|
|
5
5
|
import { Group, Object3D, Scene } from "three";
|
|
6
6
|
import { processNewScripts } from "./engine_mainloop_utils";
|
|
7
7
|
import { InstantiateEvent, registerPrefabProvider, syncInstantiate } from "./engine_networking_instantiate";
|
|
8
|
-
import { download } from "./engine_web_api";
|
|
8
|
+
import { download, hash } from "./engine_web_api";
|
|
9
9
|
import { getLoader } from "./engine_gltf";
|
|
10
10
|
import { SourceIdentifier } from "./engine_types";
|
|
11
11
|
import { destroy, instantiate, InstantiateOptions } from "./engine_gameobject";
|
|
@@ -51,11 +51,11 @@ export class AssetReference {
|
|
|
51
51
|
|
|
52
52
|
static getOrCreate(sourceId: SourceIdentifier, uri: string, context: Context): AssetReference {
|
|
53
53
|
const fullPath = getPath(sourceId, uri);
|
|
54
|
-
if(debug) console.log("GetOrCreate Addressable from", sourceId, uri, "FinalPath=", fullPath);
|
|
54
|
+
if (debug) console.log("GetOrCreate Addressable from", sourceId, uri, "FinalPath=", fullPath);
|
|
55
55
|
const addressables = context.addressables;
|
|
56
56
|
const existing = addressables.findAssetReference(fullPath);
|
|
57
57
|
if (existing) return existing;
|
|
58
|
-
const ref = new AssetReference(fullPath);
|
|
58
|
+
const ref = new AssetReference(fullPath, context.hash);
|
|
59
59
|
addressables.registerAssetReference(ref);
|
|
60
60
|
return ref;
|
|
61
61
|
}
|
|
@@ -63,6 +63,7 @@ export class AssetReference {
|
|
|
63
63
|
get asset(): any {
|
|
64
64
|
return this._glbRoot ?? this._asset;
|
|
65
65
|
}
|
|
66
|
+
|
|
66
67
|
protected set asset(val: any) {
|
|
67
68
|
this._asset = val;
|
|
68
69
|
}
|
|
@@ -70,7 +71,7 @@ export class AssetReference {
|
|
|
70
71
|
private _loading?: PromiseLike<any>;
|
|
71
72
|
|
|
72
73
|
get uri(): string {
|
|
73
|
-
return this._uri
|
|
74
|
+
return this._uri;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
get rawAsset(): any { return this._asset; }
|
|
@@ -80,11 +81,20 @@ export class AssetReference {
|
|
|
80
81
|
private _uri: string;
|
|
81
82
|
private _progressListeners: ProgressCallback[] = [];
|
|
82
83
|
|
|
84
|
+
private _hash?: string;
|
|
85
|
+
private _hashedUri: string;
|
|
86
|
+
|
|
83
87
|
private _isLoadingRawBinary: boolean = false;
|
|
84
88
|
private _rawBinary?: ArrayBuffer | null;
|
|
85
89
|
|
|
86
|
-
constructor(uri: string) {
|
|
90
|
+
constructor(uri: string, hash?: string) {
|
|
87
91
|
this._uri = uri;
|
|
92
|
+
this._hash = hash;
|
|
93
|
+
if (uri.includes("?v="))
|
|
94
|
+
this._hashedUri = uri;
|
|
95
|
+
else
|
|
96
|
+
this._hashedUri = hash ? uri + "?v=" + hash : uri;
|
|
97
|
+
|
|
88
98
|
registerPrefabProvider(this._uri, this.onResolvePrefab.bind(this));
|
|
89
99
|
}
|
|
90
100
|
|
|
@@ -120,8 +130,8 @@ export class AssetReference {
|
|
|
120
130
|
if (this._isLoadingRawBinary) return null;
|
|
121
131
|
if (this._rawBinary !== undefined) return this._rawBinary;
|
|
122
132
|
this._isLoadingRawBinary = true;
|
|
123
|
-
if (debug) console.log("Preload", this.
|
|
124
|
-
const res = await download(this.
|
|
133
|
+
if (debug) console.log("Preload", this._hashedUri);
|
|
134
|
+
const res = await download(this._hashedUri, p => {
|
|
125
135
|
this.raiseProgressEvent(p);
|
|
126
136
|
});
|
|
127
137
|
this._rawBinary = res?.buffer ?? null;
|
|
@@ -148,7 +158,7 @@ export class AssetReference {
|
|
|
148
158
|
}
|
|
149
159
|
else {
|
|
150
160
|
if (debug) console.log("Load async", this.uri);
|
|
151
|
-
this._loading = getLoader().loadSync(context, this.
|
|
161
|
+
this._loading = getLoader().loadSync(context, this._hashedUri, null, true, prog => {
|
|
152
162
|
this.raiseProgressEvent(prog);
|
|
153
163
|
});
|
|
154
164
|
}
|
|
@@ -133,7 +133,8 @@ export class EngineElement extends HTMLElement implements INeedleEngineComponent
|
|
|
133
133
|
if (srcAttributeValue) src = srcAttributeValue;
|
|
134
134
|
|
|
135
135
|
const alias = this.getAttribute("alias");
|
|
136
|
-
|
|
136
|
+
const hash = this.getAttribute("hash");
|
|
137
|
+
this._context = new Context({ name: src, domElement: this, alias: alias, hash: hash ?? undefined });
|
|
137
138
|
this._watcher = new EngineElementSourceFileWatcher(this.getAttribute("id") ?? alias ?? "", this._context);
|
|
138
139
|
|
|
139
140
|
if (src && src.length > 0) {
|
|
@@ -234,7 +235,7 @@ export class EngineElement extends HTMLElement implements INeedleEngineComponent
|
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
static get observedAttributes() {
|
|
237
|
-
return ["src", "loadstart", "progress", "loadfinished", "dracoDecoderPath", "dracoDecoderType", "ktx2DecoderPath"];
|
|
238
|
+
return ["hash", "src", "loadstart", "progress", "loadfinished", "dracoDecoderPath", "dracoDecoderType", "ktx2DecoderPath"];
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
|
|
@@ -73,11 +73,12 @@ export class AROverlayHandler {
|
|
|
73
73
|
return element;
|
|
74
74
|
}
|
|
75
75
|
if (element.children) {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
for (let i = 0; i < element.children.length; i++) {
|
|
77
|
+
const ch = element.children[i] as HTMLElement;
|
|
78
78
|
if (!ch || !ch.classList) continue;
|
|
79
|
-
if (ch.classList.contains(arContainerClassName))
|
|
79
|
+
if (ch.classList.contains(arContainerClassName)) {
|
|
80
80
|
return ch;
|
|
81
|
+
}
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -8,6 +8,7 @@ import { getParam, tryFindObject } from "./engine_utils";
|
|
|
8
8
|
import { apply } from "../engine-components/js-extensions/Object3D";
|
|
9
9
|
import { InstancingUtil } from "./engine_instancing";
|
|
10
10
|
import { activeInHierarchyFieldName } from "./engine_constants";
|
|
11
|
+
import { assign } from "./engine_serialization_core";
|
|
11
12
|
|
|
12
13
|
const debug = getParam("debuggetcomponent");
|
|
13
14
|
|
|
@@ -61,9 +62,9 @@ export function isActiveSelf(go: Object3D): boolean {
|
|
|
61
62
|
return go[$isActive] && visible;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
export function setActive(go:Object3D, active:boolean, setVisible = true){
|
|
65
|
+
export function setActive(go: Object3D, active: boolean, setVisible = true) {
|
|
65
66
|
go[$isActive] = active;
|
|
66
|
-
if(setVisible) go.visible = active;
|
|
67
|
+
if (setVisible) go.visible = active;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
export function isActiveInHierarchy(go: Object3D): boolean {
|
|
@@ -319,12 +320,11 @@ function internalInstantiate(
|
|
|
319
320
|
for (let i = 0; i < components.length; i++) {
|
|
320
321
|
const comp = components[i];
|
|
321
322
|
const copy = Object.create(comp);
|
|
322
|
-
|
|
323
|
+
assign(copy, comp);
|
|
323
324
|
newComponents.push(copy);
|
|
324
325
|
copy.gameObject = clone;
|
|
325
326
|
// copy.transform = clone;
|
|
326
327
|
componentsList.push(copy);
|
|
327
|
-
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
|
|
@@ -147,6 +147,10 @@ export class Input extends EventTarget {
|
|
|
147
147
|
if (i >= this._mouseWheelChanged.length) return false;
|
|
148
148
|
return this._mouseWheelChanged[i];
|
|
149
149
|
}
|
|
150
|
+
getMouseWheelDeltaY(i: number = 0): number {
|
|
151
|
+
if (i >= this._mouseWheelDeltaY.length) return 0;
|
|
152
|
+
return this._mouseWheelDeltaY[i];
|
|
153
|
+
}
|
|
150
154
|
getPointerEvent(i: number): Event | undefined {
|
|
151
155
|
if (i >= this._pointerEvent.length) return undefined;
|
|
152
156
|
return this._pointerEvent[i] ?? undefined;
|
|
@@ -169,6 +173,7 @@ export class Input extends EventTarget {
|
|
|
169
173
|
private _pointerIds: number[] = [];
|
|
170
174
|
private _pointerTypes: string[] = [""];
|
|
171
175
|
private _mouseWheelChanged: boolean[] = [false];
|
|
176
|
+
private _mouseWheelDeltaY: number[] = [0];
|
|
172
177
|
private _pointerEvent: Event[] = [];
|
|
173
178
|
|
|
174
179
|
getKeyDown(): string | null {
|
|
@@ -269,11 +274,12 @@ export class Input extends EventTarget {
|
|
|
269
274
|
this._pointerClick[i] = false;
|
|
270
275
|
for (let i = 0; i < this._pointerDoubleClick.length; i++)
|
|
271
276
|
this._pointerDoubleClick[i] = false;
|
|
272
|
-
for (const pt of this._pointerPositionsDelta)
|
|
277
|
+
for (const pt of this._pointerPositionsDelta)
|
|
273
278
|
pt.set(0, 0);
|
|
274
|
-
}
|
|
275
279
|
for (let i = 0; i < this._mouseWheelChanged.length; i++)
|
|
276
280
|
this._mouseWheelChanged[i] = false;
|
|
281
|
+
for (let i = 0; i < this._mouseWheelDeltaY.length; i++)
|
|
282
|
+
this._mouseWheelDeltaY[i] = 0;
|
|
277
283
|
}
|
|
278
284
|
|
|
279
285
|
|
|
@@ -307,9 +313,12 @@ export class Input extends EventTarget {
|
|
|
307
313
|
this.onDispatchEvent(InputEvents.KeyUp, new KeyEventArgs(evt));
|
|
308
314
|
}
|
|
309
315
|
|
|
310
|
-
private onMouseWheel(
|
|
316
|
+
private onMouseWheel(evt: WheelEvent) {
|
|
317
|
+
if (this._mouseWheelDeltaY.length <= 0) this._mouseWheelDeltaY.push(0);
|
|
311
318
|
if (this._mouseWheelChanged.length <= 0) this._mouseWheelChanged.push(false);
|
|
312
319
|
this._mouseWheelChanged[0] = true;
|
|
320
|
+
const current = this._mouseWheelDeltaY[0];
|
|
321
|
+
this._mouseWheelDeltaY[0] = current + evt.deltaY;
|
|
313
322
|
}
|
|
314
323
|
|
|
315
324
|
private onTouchMove(_evt) {
|