@needle-tools/engine 3.2.3-alpha → 3.2.4-alpha.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/CHANGELOG.md +9 -0
- package/dist/needle-engine.js +24012 -22890
- package/dist/needle-engine.min.js +363 -363
- package/dist/needle-engine.umd.cjs +369 -369
- package/lib/engine/api.d.ts +33 -11
- package/lib/engine/api.js +33 -11
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_addressables.d.ts +3 -3
- package/lib/engine/engine_addressables.js +0 -1
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_context.d.ts +11 -12
- package/lib/engine/engine_context.js +16 -17
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_fileloader.d.ts +2 -2
- package/lib/engine/engine_fileloader.js +2 -2
- package/lib/engine/engine_fileloader.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +8 -8
- package/lib/engine/engine_gameobject.js +1 -1
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gizmos.d.ts +2 -3
- package/lib/engine/engine_gizmos.js +3 -3
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js +4 -5
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_input.d.ts +7 -7
- package/lib/engine/engine_input.js +12 -12
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_license.js +2 -2
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.d.ts +1 -1
- package/lib/engine/engine_mainloop_utils.js +1 -1
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking_auto.d.ts +1 -1
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_networking_files.d.ts +4 -4
- package/lib/engine/engine_networking_files.js +4 -5
- package/lib/engine/engine_networking_files.js.map +1 -1
- package/lib/engine/engine_three_utils.d.ts +19 -19
- package/lib/engine/engine_three_utils.js +17 -18
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.d.ts +6 -5
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_lighting_settings.js +14 -6
- package/lib/engine/extensions/NEEDLE_lighting_settings.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +3 -4
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +25 -26
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine-components/Animation.d.ts +6 -7
- package/lib/engine-components/Animation.js +5 -6
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/Animator.d.ts +3 -4
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.js +3 -4
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioListener.d.ts +2 -2
- package/lib/engine-components/AudioListener.js +2 -2
- package/lib/engine-components/AudioListener.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +2 -2
- package/lib/engine-components/AudioSource.js +4 -4
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/AvatarLoader.d.ts +7 -7
- package/lib/engine-components/AvatarLoader.js +3 -4
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/AxesHelper.js.map +1 -1
- package/lib/engine-components/BasicIKConstraint.js +2 -2
- package/lib/engine-components/BasicIKConstraint.js.map +1 -1
- package/lib/engine-components/BoxHelperComponent.d.ts +5 -5
- package/lib/engine-components/BoxHelperComponent.js +6 -6
- package/lib/engine-components/BoxHelperComponent.js.map +1 -1
- package/lib/engine-components/Component.d.ts +45 -47
- package/lib/engine-components/Component.js +16 -17
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +3 -3
- package/lib/engine-components/DragControls.js +22 -24
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/api.d.ts +3 -0
- package/lib/engine-components/api.js +3 -0
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/ui/Utils.d.ts +4 -3
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/engine-components-experimental/api.d.ts +1 -0
- package/lib/engine-components-experimental/api.js +2 -0
- package/lib/engine-components-experimental/api.js.map +1 -0
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +2 -1
- package/lib/engine-components-experimental/networking/PlayerSync.js +18 -1
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/lib/needle-engine.d.ts +1 -5
- package/lib/needle-engine.js +4 -5
- package/lib/needle-engine.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/plugins/vite/license.js +2 -2
- package/src/engine/api.ts +39 -20
- package/src/engine/codegen/register_types.js +2 -2
- package/src/engine/engine_addressables.ts +6 -7
- package/src/engine/engine_context.ts +31 -28
- package/src/engine/engine_fileloader.js +2 -2
- package/src/engine/engine_gameobject.ts +21 -21
- package/src/engine/engine_gizmos.ts +5 -6
- package/src/engine/engine_gltf_builtin_components.ts +9 -10
- package/src/engine/engine_input.ts +17 -18
- package/src/engine/engine_license.ts +2 -2
- package/src/engine/engine_mainloop_utils.ts +5 -5
- package/src/engine/engine_networking_auto.ts +1 -1
- package/src/engine/engine_networking_files.ts +10 -11
- package/src/engine/engine_three_utils.ts +37 -37
- package/src/engine/extensions/NEEDLE_components.ts +7 -6
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +15 -6
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +29 -30
- package/src/engine-components/Animation.ts +17 -19
- package/src/engine-components/Animator.ts +4 -5
- package/src/engine-components/AnimatorController.ts +16 -17
- package/src/engine-components/AudioListener.ts +4 -4
- package/src/engine-components/AudioSource.ts +8 -8
- package/src/engine-components/AvatarLoader.ts +15 -16
- package/src/engine-components/AxesHelper.ts +1 -1
- package/src/engine-components/BasicIKConstraint.ts +2 -2
- package/src/engine-components/BoxHelperComponent.ts +13 -13
- package/src/engine-components/Component.ts +65 -68
- package/src/engine-components/DragControls.ts +42 -43
- package/src/engine-components/ParticleSystemModules.ts +1483 -1483
- package/src/engine-components/api.ts +3 -0
- package/src/engine-components/ui/Utils.ts +4 -4
- package/src/engine-components-experimental/api.ts +1 -0
- package/src/engine-components-experimental/networking/PlayerSync.ts +17 -4
- package/src/needle-engine.ts +5 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
import { FrontSide, DoubleSide,
|
|
2
|
+
import { FrontSide, DoubleSide, Object3D } from "three"
|
|
3
3
|
import { FrameEvent } from "../../engine/engine_setup";
|
|
4
4
|
import { Behaviour } from "../Component";
|
|
5
5
|
import { $shadowDomOwner, BaseUIComponent } from "./BaseUIComponent";
|
|
6
6
|
|
|
7
|
-
export function tryGetUIComponent(obj:
|
|
7
|
+
export function tryGetUIComponent(obj: Object3D): BaseUIComponent | null {
|
|
8
8
|
const owner = obj[$shadowDomOwner];
|
|
9
9
|
if (owner) {
|
|
10
10
|
return owner;
|
|
@@ -15,7 +15,7 @@ export function tryGetUIComponent(obj: THREE.Object3D): BaseUIComponent | null {
|
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function isUIObject(obj:
|
|
18
|
+
export function isUIObject(obj: Object3D) {
|
|
19
19
|
return obj["isUI"] === true || typeof obj[$shadowDomOwner] === "object";
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -27,7 +27,7 @@ export type RenderSettings = {
|
|
|
27
27
|
receiveShadows?: boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function updateRenderSettings(shadowComponent:
|
|
30
|
+
export function updateRenderSettings(shadowComponent: Object3D, settings: RenderSettings) {
|
|
31
31
|
if (!shadowComponent) return;
|
|
32
32
|
// const owner = shadowComponent[$shadowDomOwner];
|
|
33
33
|
// if (!owner)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./networking/PlayerSync";
|
|
@@ -3,11 +3,12 @@ import { AssetReference } from "../../engine/engine_addressables";
|
|
|
3
3
|
import { serializable } from "../../engine/engine_serialization_decorator";
|
|
4
4
|
import { syncField } from "../../engine/engine_networking_auto"
|
|
5
5
|
import { RoomEvents } from "../../engine/engine_networking";
|
|
6
|
-
import { Object3D } from "three";
|
|
7
6
|
import { syncDestroy } from "../../engine/engine_networking_instantiate";
|
|
8
|
-
import {
|
|
7
|
+
import { getParam } from "../../engine/engine_utils";
|
|
9
8
|
|
|
9
|
+
import { Object3D } from "three";
|
|
10
10
|
|
|
11
|
+
const debug = getParam("debugplayersync");
|
|
11
12
|
|
|
12
13
|
export class PlayerSync extends Behaviour {
|
|
13
14
|
@serializable(AssetReference)
|
|
@@ -28,12 +29,20 @@ export class PlayerSync extends Behaviour {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
private async onUserJoined(_model) {
|
|
32
|
+
if (debug) console.log("PlayerSync.onUserJoined", _model);
|
|
31
33
|
const instance = await this.asset?.instantiateSynced({ parent: this.gameObject }, true);
|
|
32
34
|
if (instance) {
|
|
33
|
-
let pl = GameObject.getComponent(instance
|
|
35
|
+
let pl = GameObject.getComponent(instance, PlayerState);
|
|
34
36
|
if (pl) {
|
|
35
37
|
pl.owner = this.context.connection.connectionId!;
|
|
36
38
|
}
|
|
39
|
+
else {
|
|
40
|
+
console.error("<strong>Failed finding PlayerState on " + this.asset?.uri + "</strong>: please make sure the asset has a PlayerState component!");
|
|
41
|
+
GameObject.destroySynced(instance);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else{
|
|
45
|
+
console.warn("PlayerSync: failed instantiating asset!")
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
// TODO: previously created instances are not re-created when re-joining room
|
|
@@ -87,7 +96,7 @@ export class PlayerState extends Behaviour {
|
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
//** use to check if a component or gameobject is part of a instance owned by the local player */
|
|
90
|
-
static isLocalPlayer(obj:
|
|
99
|
+
static isLocalPlayer(obj: Object3D | Component): boolean {
|
|
91
100
|
if (obj instanceof Object3D) {
|
|
92
101
|
const state = GameObject.getComponentInParent(obj, PlayerState);
|
|
93
102
|
return state?.isLocalPlayer ?? false;
|
|
@@ -129,6 +138,8 @@ export class PlayerState extends Behaviour {
|
|
|
129
138
|
}
|
|
130
139
|
|
|
131
140
|
private onOwnerChange(newOwner: string, oldOwner: string) {
|
|
141
|
+
if (debug) console.log("PlayerSync.onOwnerChange", this, "newOwner", newOwner, "oldOwner", oldOwner);
|
|
142
|
+
|
|
132
143
|
// Remove from local owner array if it was local before
|
|
133
144
|
const index = PlayerState._local.indexOf(this);
|
|
134
145
|
if (index >= 0) PlayerState._local.splice(index, 1);
|
|
@@ -154,6 +165,7 @@ export class PlayerState extends Behaviour {
|
|
|
154
165
|
|
|
155
166
|
awake(): void {
|
|
156
167
|
PlayerState.all.push(this);
|
|
168
|
+
if(debug) console.log("Registered new PlayerState", this, PlayerState.all.length-1, PlayerState.all)
|
|
157
169
|
|
|
158
170
|
this.context.connection.beginListen(RoomEvents.UserLeftRoom, (model: { userId: string }) => {
|
|
159
171
|
// console.log("USER LEFT", model.userId)
|
|
@@ -177,6 +189,7 @@ export class PlayerState extends Behaviour {
|
|
|
177
189
|
|
|
178
190
|
/** this tells the server that this client has been destroyed and the networking message for the instantiate will be removed */
|
|
179
191
|
doDestroy() {
|
|
192
|
+
if (debug) console.log("PlayerSync.doDestroy → syncDestroy", this);
|
|
180
193
|
syncDestroy(this.gameObject, this.context.connection);
|
|
181
194
|
}
|
|
182
195
|
|
package/src/needle-engine.ts
CHANGED
|
@@ -3,22 +3,18 @@ makeErrorsVisibleForDevelopment();
|
|
|
3
3
|
|
|
4
4
|
import "./engine/engine_element";
|
|
5
5
|
import "./engine/engine_setup";
|
|
6
|
-
|
|
7
6
|
import "./engine-components/CameraUtils"
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
export { GameObject, Behaviour } from "./engine-components/Component";
|
|
11
|
-
export { serializable, serializeable } from "./engine/engine_serialization_decorator";
|
|
12
|
-
export { Collision } from "./engine/engine_types";
|
|
13
8
|
export * from "./engine/api";
|
|
14
9
|
export * from "./engine-components/api";
|
|
15
|
-
export * from "./engine-components/
|
|
16
|
-
export * from "./engine-components/js-extensions/Object3D";
|
|
17
|
-
|
|
10
|
+
export * from "./engine-components-experimental/api";
|
|
18
11
|
|
|
19
12
|
// make accessible for external javascript
|
|
20
13
|
import { Context } from "./engine/engine_setup";
|
|
21
14
|
const Needle = { Context: Context };
|
|
15
|
+
if (globalThis["Needle"] !== undefined) {
|
|
16
|
+
console.warn("Needle Engine is already imported");
|
|
17
|
+
}
|
|
22
18
|
globalThis["Needle"] = Needle;
|
|
23
19
|
function registerGlobal(obj: object) {
|
|
24
20
|
for (const key in obj) {
|
|
@@ -47,7 +43,7 @@ for (const method of Object.getOwnPropertyNames(GameObject)) {
|
|
|
47
43
|
|
|
48
44
|
// make three accessible
|
|
49
45
|
import * as THREE from "three";
|
|
50
|
-
if(!globalThis["THREE"]) {
|
|
46
|
+
if (!globalThis["THREE"]) {
|
|
51
47
|
globalThis["THREE"] = THREE;
|
|
52
48
|
}
|
|
53
49
|
else console.warn("Threejs is already imported");
|