@needle-tools/engine 2.58.1-pre → 2.58.2-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 +5 -0
- package/dist/needle-engine.js +61659 -690
- package/dist/needle-engine.umd.cjs +4269 -0
- package/lib/engine/debug/debug.js +0 -2
- package/lib/engine/debug/debug.js.map +1 -1
- package/lib/engine/debug/debug_overlay.js +3 -3
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/debug/index.d.ts +1 -0
- package/lib/engine/debug/index.js +2 -0
- package/lib/engine/debug/index.js.map +1 -0
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_context_registry.d.ts +21 -0
- package/lib/engine/engine_context_registry.js +40 -0
- package/lib/engine/engine_context_registry.js.map +1 -0
- package/lib/engine/engine_hot_reload.js +2 -2
- package/lib/engine/engine_hot_reload.js.map +1 -1
- package/lib/engine/engine_loaders.js +6 -4
- package/lib/engine/engine_loaders.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.d.ts +8 -9
- package/lib/engine/engine_mainloop_utils.js +2 -2
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_files.js +4 -0
- package/lib/engine/engine_networking_files.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.js +6 -0
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_serialization_core.js +6 -4
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_setup.d.ts +2 -8
- package/lib/engine/engine_setup.js +12 -9
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_types.d.ts +33 -1
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine-components/Camera.js +11 -1
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +4 -0
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +1 -1
- package/lib/engine-components/ReflectionProbe.js +13 -5
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.js +1 -1
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/js-extensions/RGBAColor.d.ts +1 -0
- package/lib/engine-components/js-extensions/RGBAColor.js +4 -0
- package/lib/engine-components/js-extensions/RGBAColor.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/vite.config.d.ts +2 -0
- package/lib/vite.config.js +26 -0
- package/lib/vite.config.js.map +1 -0
- package/package.json +22 -8
- package/src/engine/debug/debug.ts +0 -3
- package/src/engine/debug/debug_overlay.ts +5 -3
- package/src/engine/debug/index.ts +1 -0
- package/src/engine/engine_addressables.ts +1 -1
- package/src/engine/engine_context_registry.ts +50 -0
- package/src/engine/engine_hot_reload.ts +2 -2
- package/src/engine/engine_loaders.ts +7 -4
- package/src/engine/engine_mainloop_utils.ts +12 -12
- package/src/engine/engine_networking.ts +0 -41
- package/src/engine/engine_networking_files.ts +7 -0
- package/src/engine/engine_networking_instantiate.ts +10 -1
- package/src/engine/engine_serialization_core.ts +6 -5
- package/src/engine/engine_setup.ts +17 -17
- package/src/engine/engine_types.ts +43 -3
- package/src/engine-components/Camera.ts +14 -1
- package/src/engine-components/CameraUtils.ts +7 -0
- package/src/engine-components/ReflectionProbe.ts +12 -4
- package/src/engine-components/Renderer.ts +1 -1
- package/src/engine-components/js-extensions/RGBAColor.ts +5 -0
- package/dist/needle-engine.d.ts +0 -6653
- package/dist/needle-engine.js.map +0 -7
- package/dist/needle-engine.min.js +0 -320
- package/dist/needle-engine.min.js.map +0 -7
- package/dist/needle-engine.tsbuildinfo +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Behaviour } from "./Component";
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
2
|
import { getParam } from "../engine/engine_utils";
|
|
3
3
|
import { serializable } from "../engine/engine_serialization_decorator";
|
|
4
4
|
import { RGBAColor } from "./js-extensions/RGBAColor";
|
|
@@ -9,6 +9,7 @@ import { getWorldPosition } from "../engine/engine_three_utils";
|
|
|
9
9
|
import { Gizmos } from "../engine/engine_gizmos";
|
|
10
10
|
|
|
11
11
|
import { EquirectangularReflectionMapping, OrthographicCamera, PerspectiveCamera, Ray, sRGBEncoding, Vector3 } from "three";
|
|
12
|
+
import { OrbitControls } from "./OrbitControls";
|
|
12
13
|
|
|
13
14
|
export enum ClearFlags {
|
|
14
15
|
Skybox = 1,
|
|
@@ -198,6 +199,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
198
199
|
this.buildCamera();
|
|
199
200
|
if (this.tag == "MainCamera" || !this.context.mainCameraComponent) {
|
|
200
201
|
this.context.setCurrentCamera(this);
|
|
202
|
+
handleFreeCam(this);
|
|
201
203
|
}
|
|
202
204
|
this.applyClearFlagsIfIsActiveCamera();
|
|
203
205
|
}
|
|
@@ -343,4 +345,15 @@ class CameraSkybox {
|
|
|
343
345
|
this.context.scene.background = this._skybox;
|
|
344
346
|
}
|
|
345
347
|
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
function handleFreeCam(cam: Camera) {
|
|
352
|
+
const isFreecam = getParam("freecam");
|
|
353
|
+
if (isFreecam) {
|
|
354
|
+
if (cam.context.mainCameraComponent === cam) {
|
|
355
|
+
GameObject.getOrAddComponent(cam.gameObject, OrbitControls);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
}
|
|
346
359
|
}
|
|
@@ -5,6 +5,13 @@ import { Color, Object3D, Scene, Vector3 } from "three";
|
|
|
5
5
|
import { ICamera, SourceIdentifier } from "../engine/engine_types";
|
|
6
6
|
import { lookAtInverse } from "../engine/engine_three_utils";
|
|
7
7
|
import { RGBAColor } from "./js-extensions/RGBAColor";
|
|
8
|
+
import { ContextEvent, ContextRegistry } from "../engine/engine_context_registry";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
ContextRegistry.registerCallback(ContextEvent.MissingCamera, (evt) => {
|
|
12
|
+
createCameraWithOrbitControl(evt.context.scene, "unknown");
|
|
13
|
+
});
|
|
14
|
+
|
|
8
15
|
|
|
9
16
|
export function createCameraWithOrbitControl(scene: Scene, source: SourceIdentifier): ICamera {
|
|
10
17
|
const srcId = source;
|
|
@@ -17,16 +17,24 @@ export class ReflectionProbe extends Behaviour {
|
|
|
17
17
|
|
|
18
18
|
private static _probes: Map<Context, ReflectionProbe[]> = new Map();
|
|
19
19
|
|
|
20
|
-
public static get(object: Object3D | null | undefined, context: Context, isAnchor: boolean): ReflectionProbe | null {
|
|
20
|
+
public static get(object: Object3D | null | undefined, context: Context, isAnchor: boolean, anchor?: Object3D): ReflectionProbe | null {
|
|
21
21
|
if (!object || object.isObject3D !== true) return null;
|
|
22
22
|
if (disable) return null;
|
|
23
23
|
const probes = ReflectionProbe._probes.get(context);
|
|
24
24
|
if (probes) {
|
|
25
25
|
for (const probe of probes) {
|
|
26
26
|
if (!probe.__didAwake) probe.__internalAwake();
|
|
27
|
-
if (probe.enabled
|
|
28
|
-
if (
|
|
29
|
-
|
|
27
|
+
if (probe.enabled) {
|
|
28
|
+
if (anchor) {
|
|
29
|
+
// test if anchor is reflection probe object
|
|
30
|
+
if (probe.gameObject === anchor) {
|
|
31
|
+
return probe;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if (probe.isInBox(object, undefined)) {
|
|
35
|
+
if (debug) console.log("Found reflection probe", object.name, probe.name);
|
|
36
|
+
return probe;
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
}
|
|
@@ -631,7 +631,7 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
631
631
|
private *_updateReflectionProbe() {
|
|
632
632
|
const obj = this.probeAnchor || this.gameObject;
|
|
633
633
|
const isAnchor = this.probeAnchor ? true : false;
|
|
634
|
-
this._reflectionProbe = ReflectionProbe.get(obj, this.context, isAnchor);
|
|
634
|
+
this._reflectionProbe = ReflectionProbe.get(obj, this.context, isAnchor, this.probeAnchor);
|
|
635
635
|
}
|
|
636
636
|
|
|
637
637
|
private setVisibility(visible: boolean) {
|
|
@@ -47,4 +47,9 @@ export class RGBAColor extends Color {
|
|
|
47
47
|
if(rgba.alpha) this.alpha = this.alpha * rgba.alpha;
|
|
48
48
|
return super.multiply(color);
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
fromArray(array: number[], offset: number = 0): this {
|
|
52
|
+
this.alpha = array[offset + 3];
|
|
53
|
+
return super.fromArray(array, offset);
|
|
54
|
+
}
|
|
50
55
|
}
|