@needle-tools/engine 2.28.0-pre → 2.29.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 +10 -0
- package/dist/needle-engine.d.ts +188 -131
- package/dist/needle-engine.js +345 -345
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +19 -19
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/engine_input.d.ts +13 -1
- package/lib/engine/engine_input.js +47 -16
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +1 -0
- package/lib/engine/engine_physics.js +2 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_playerview.d.ts +26 -0
- package/lib/engine/engine_playerview.js +65 -0
- package/lib/engine/engine_playerview.js.map +1 -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 +3 -0
- package/lib/engine/engine_setup.js +17 -0
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_lighting_settings.js +6 -2
- package/lib/engine/extensions/NEEDLE_lighting_settings.js.map +1 -1
- package/lib/engine-components/Component.d.ts +1 -1
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/Light.js +1 -0
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +1 -2
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +0 -1
- package/lib/engine-components/ParticleSystem.js +24 -27
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/PlayerColor.js +1 -2
- package/lib/engine-components/PlayerColor.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.d.ts +24 -17
- package/lib/engine-components/SpectatorCamera.js +410 -181
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedCamera.d.ts +8 -4
- package/lib/engine-components/SyncedCamera.js +15 -18
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/WebXR.js +1 -0
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.d.ts +3 -0
- package/lib/engine-components/WebXRAvatar.js +16 -0
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/WebXRController.js +1 -1
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/WebXRSync.js +3 -3
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components/XRFlag.d.ts +2 -1
- package/lib/engine-components/XRFlag.js +1 -0
- package/lib/engine-components/XRFlag.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_components.js +16 -0
- package/src/engine/engine_input.ts +62 -20
- package/src/engine/engine_physics.ts +2 -1
- package/src/engine/engine_playerview.ts +80 -0
- package/src/engine/engine_serialization_core.ts +8 -0
- package/src/engine/engine_setup.ts +18 -0
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +4 -2
- package/src/engine-components/Component.ts +1 -1
- package/src/engine-components/Light.ts +3 -0
- package/src/engine-components/OrbitControls.ts +1 -2
- package/src/engine-components/ParticleSystem.ts +25 -26
- package/src/engine-components/PlayerColor.ts +1 -1
- package/src/engine-components/SpectatorCamera.ts +466 -194
- package/src/engine-components/SyncedCamera.ts +23 -22
- package/src/engine-components/WebXR.ts +1 -0
- package/src/engine-components/WebXRAvatar.ts +22 -2
- package/src/engine-components/WebXRController.ts +1 -1
- package/src/engine-components/WebXRSync.ts +3 -3
- package/src/engine-components/XRFlag.ts +1 -0
|
@@ -26,6 +26,7 @@ import { RendererData } from './engine_rendererdata';
|
|
|
26
26
|
import { Addressables } from './engine_addressables';
|
|
27
27
|
import { Application } from './engine_application';
|
|
28
28
|
import { LightDataRegistry, ILightDataRegistry } from './engine_lightdata';
|
|
29
|
+
import { PlayerViewManager } from './engine_playerview';
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
const debug = utils.getParam("debugSetup");
|
|
@@ -165,6 +166,7 @@ export class Context {
|
|
|
165
166
|
rendererData: RendererData;
|
|
166
167
|
addressables: Addressables;
|
|
167
168
|
lightmaps: ILightDataRegistry;
|
|
169
|
+
players : PlayerViewManager;
|
|
168
170
|
|
|
169
171
|
private _sizeChanged: boolean = false;
|
|
170
172
|
private _isCreated: boolean = false;
|
|
@@ -212,6 +214,7 @@ export class Context {
|
|
|
212
214
|
this.rendererData = new RendererData(this);
|
|
213
215
|
this.addressables = new Addressables(this);
|
|
214
216
|
this.lightmaps = new LightDataRegistry(this);
|
|
217
|
+
this.players = new PlayerViewManager(this);
|
|
215
218
|
|
|
216
219
|
window.addEventListener('resize', this.updateSize.bind(this));
|
|
217
220
|
const ro = new ResizeObserver(_ => this._sizeChanged = true);
|
|
@@ -310,6 +313,21 @@ export class Context {
|
|
|
310
313
|
(this.mainCameraComponent as Camera)?.applyClearFlagsIfIsActiveCamera();
|
|
311
314
|
}
|
|
312
315
|
|
|
316
|
+
removeCamera(cam?: Camera | null) {
|
|
317
|
+
if(!cam) return;
|
|
318
|
+
const index = this._cameraStack.indexOf(cam);
|
|
319
|
+
if (index >= 0) this._cameraStack.splice(index, 1);
|
|
320
|
+
|
|
321
|
+
if (this.mainCameraComponent === cam) {
|
|
322
|
+
this.mainCameraComponent = undefined;
|
|
323
|
+
|
|
324
|
+
if (this._cameraStack.length > 0) {
|
|
325
|
+
const last = this._cameraStack[this._cameraStack.length - 1];
|
|
326
|
+
this.setCurrentCamera(last);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
313
331
|
private _onBeforeRenderListeners: { [key: string]: OnBeforeRenderCallback[] } = {};
|
|
314
332
|
|
|
315
333
|
/** use this to subscribe to onBeforeRender events on threejs objects */
|
|
@@ -99,13 +99,14 @@ export class SceneLightSettings extends Behaviour {
|
|
|
99
99
|
onEnable() {
|
|
100
100
|
const isActive = this.context.mainCameraComponent?.sourceId === this.sourceId;
|
|
101
101
|
if (debug)
|
|
102
|
-
console.log("
|
|
102
|
+
console.log("Enable scene lighting", this.sourceId, isActive, this, this.context.mainCameraComponent?.sourceId);
|
|
103
103
|
if (!isActive) {
|
|
104
|
+
if(debug) console.warn("This is no active?!", this.context.mainCameraComponent?.sourceId)
|
|
104
105
|
// this.enabled = false;
|
|
105
106
|
// return;
|
|
106
107
|
}
|
|
107
108
|
if (this.ambientMode == AmbientMode.Flat) {
|
|
108
|
-
if (this.ambientLight) {
|
|
109
|
+
if (this.ambientLight && !this._ambientLightObj) {
|
|
109
110
|
this._ambientLightObj = new AmbientLight(this.ambientLight, Math.PI * this.ambientIntensity);
|
|
110
111
|
}
|
|
111
112
|
if (this._ambientLightObj) {
|
|
@@ -155,6 +156,7 @@ export class SceneLightSettings extends Behaviour {
|
|
|
155
156
|
if (debug)
|
|
156
157
|
console.log("disable", this.sourceId, this);
|
|
157
158
|
if (this._lightProbeObj) this._lightProbeObj.removeFromParent();
|
|
159
|
+
if(this._ambientLightObj) this._ambientLightObj.removeFromParent();
|
|
158
160
|
if (this.sourceId)
|
|
159
161
|
this.context.rendererData.disableReflection();
|
|
160
162
|
}
|
|
@@ -644,7 +644,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D {
|
|
|
644
644
|
return object.getComponentsInChildren(typeName, go, arr);
|
|
645
645
|
}
|
|
646
646
|
|
|
647
|
-
public static getComponentInParent<T>(go: GameObject | THREE.Object3D
|
|
647
|
+
public static getComponentInParent<T>(go: GameObject | THREE.Object3D | Array<Object3D>, typeName: Constructor<T>): T | null {
|
|
648
648
|
return object.getComponentInParent(typeName, go);
|
|
649
649
|
}
|
|
650
650
|
|
|
@@ -9,7 +9,6 @@ import { serializeable } from "../engine/engine_serialization_decorator";
|
|
|
9
9
|
import { Vector3 } from "three";
|
|
10
10
|
|
|
11
11
|
export class OrbitControls extends Behaviour {
|
|
12
|
-
|
|
13
12
|
public get controls() {
|
|
14
13
|
return this._controls;
|
|
15
14
|
}
|
|
@@ -31,7 +30,7 @@ export class OrbitControls extends Behaviour {
|
|
|
31
30
|
minZoom: number = 0;
|
|
32
31
|
maxZoom: number = Infinity;
|
|
33
32
|
enablePan: boolean = true;
|
|
34
|
-
@serializeable(
|
|
33
|
+
@serializeable()
|
|
35
34
|
lookAtConstraint: LookAtConstraint | null = null;
|
|
36
35
|
lookAtConstraint01: number = 1;
|
|
37
36
|
middleClickToFocus: boolean = true;
|
|
@@ -61,7 +61,7 @@ export class ParticleSystem extends Behaviour {
|
|
|
61
61
|
|
|
62
62
|
awake(): void {
|
|
63
63
|
this.renderer = GameObject.getComponent(this.gameObject, ParticleSystemRenderer)!;
|
|
64
|
-
if (debug)
|
|
64
|
+
// if (debug)
|
|
65
65
|
console.log(this);
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -108,31 +108,30 @@ export class ParticleSystem extends Behaviour {
|
|
|
108
108
|
this.activeCount = this.main.prewarm ? this.main.maxParticles : 0;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
update() {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
111
|
+
// update() {
|
|
112
|
+
// if (!this.geometry) return;
|
|
113
|
+
|
|
114
|
+
// const t = this.context.time.deltaTime;
|
|
115
|
+
// this.emit(t);
|
|
116
|
+
|
|
117
|
+
// for (let i = 0; i < this.activeCount; i += 1) {
|
|
118
|
+
// const ps = this.particleStates[i];
|
|
119
|
+
// if (!ps) continue;
|
|
120
|
+
// const vx = ps.velocity.x * t;
|
|
121
|
+
// const vy = ps.velocity.y * t;
|
|
122
|
+
// const vz = ps.velocity.z * t;
|
|
123
|
+
// ps.position.x += vx;
|
|
124
|
+
// ps.position.y += vy;
|
|
125
|
+
// ps.position.z += vz;
|
|
126
|
+
// this.updateOverLifetime(i, ps);
|
|
127
|
+
// this.geometry.attributes.position.setXYZ(i, ps.position.x, ps.position.y, ps.position.z);
|
|
128
|
+
// this.geometry.attributes.color.setXYZ(i, ps.color.r, ps.color.g, ps.color.b);
|
|
129
|
+
// }
|
|
130
|
+
// if (this.geometry) {
|
|
131
|
+
// this.geometry.attributes.position.needsUpdate = true;
|
|
132
|
+
// this.geometry.setDrawRange(0, this.activeCount);
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
136
135
|
|
|
137
136
|
emit(deltaTime: number) {
|
|
138
137
|
const count = this.activeCount;
|