@needle-tools/engine 4.2.5 → 4.3.0-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/components.needle.json +1 -1
- package/dist/needle-engine.bundle.js +4245 -2977
- package/dist/needle-engine.bundle.light.js +4236 -2968
- package/dist/needle-engine.bundle.light.min.js +73 -73
- package/dist/needle-engine.bundle.light.umd.cjs +61 -61
- package/dist/needle-engine.bundle.min.js +62 -62
- package/dist/needle-engine.bundle.umd.cjs +61 -61
- package/dist/needle-engine.light.d.ts +9 -9
- package/dist/three-examples.js +825 -794
- package/dist/three-examples.light.js +825 -794
- package/dist/three-examples.light.min.js +12 -12
- package/dist/three-examples.light.umd.cjs +10 -10
- package/dist/three-examples.min.js +12 -12
- package/dist/three-examples.umd.cjs +10 -10
- package/lib/engine/engine_addressables.d.ts +3 -0
- package/lib/engine/engine_addressables.js +18 -0
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_input.d.ts +20 -1
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_types.d.ts +162 -17
- package/lib/engine-components/Animator.d.ts +129 -21
- package/lib/engine-components/Animator.js +115 -21
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.d.ts +161 -32
- package/lib/engine-components/AnimatorController.js +176 -29
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioListener.d.ts +16 -5
- package/lib/engine-components/AudioListener.js +16 -5
- package/lib/engine-components/AudioListener.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +120 -28
- package/lib/engine-components/AudioSource.js +120 -37
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/AvatarLoader.d.ts +61 -0
- package/lib/engine-components/AvatarLoader.js +61 -1
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/AxesHelper.d.ts +19 -1
- package/lib/engine-components/AxesHelper.js +19 -1
- package/lib/engine-components/AxesHelper.js.map +1 -1
- package/lib/engine-components/BoxHelperComponent.d.ts +26 -0
- package/lib/engine-components/BoxHelperComponent.js +26 -0
- package/lib/engine-components/BoxHelperComponent.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +126 -37
- package/lib/engine-components/Camera.js +139 -37
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +20 -0
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +95 -21
- package/lib/engine-components/Collider.js +100 -23
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +554 -106
- package/lib/engine-components/Component.js +352 -81
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +95 -21
- package/lib/engine-components/DragControls.js +126 -32
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.d.ts +99 -16
- package/lib/engine-components/DropListener.js +119 -14
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Light.d.ts +102 -5
- package/lib/engine-components/Light.js +102 -44
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/NeedleMenu.d.ts +28 -11
- package/lib/engine-components/NeedleMenu.js +28 -11
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +37 -5
- package/lib/engine-components/Networking.js +37 -5
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +8 -0
- package/lib/engine-components/SceneSwitcher.js +72 -8
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SpatialTrigger.d.ts +66 -1
- package/lib/engine-components/SpatialTrigger.js +74 -2
- package/lib/engine-components/SpatialTrigger.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.d.ts +66 -4
- package/lib/engine-components/SpectatorCamera.js +132 -6
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.d.ts +45 -6
- package/lib/engine-components/SyncedTransform.js +45 -6
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TransformGizmo.d.ts +49 -3
- package/lib/engine-components/TransformGizmo.js +49 -3
- package/lib/engine-components/TransformGizmo.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.d.ts +1 -0
- package/lib/engine-components/ui/EventSystem.js +8 -5
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +131 -22
- package/lib/engine-components/webxr/WebXR.js +132 -23
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +82 -9
- package/lib/engine-components-experimental/networking/PlayerSync.js +76 -11
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite/alias.js +6 -3
- package/src/engine/engine_addressables.ts +21 -0
- package/src/engine/engine_input.ts +20 -1
- package/src/engine/engine_types.ts +179 -18
- package/src/engine-components/Animator.ts +142 -22
- package/src/engine-components/AnimatorController.ts +184 -34
- package/src/engine-components/AudioListener.ts +16 -5
- package/src/engine-components/AudioSource.ts +126 -37
- package/src/engine-components/AvatarLoader.ts +61 -2
- package/src/engine-components/AxesHelper.ts +21 -1
- package/src/engine-components/BoxHelperComponent.ts +26 -0
- package/src/engine-components/Camera.ts +147 -41
- package/src/engine-components/CameraUtils.ts +20 -0
- package/src/engine-components/Collider.ts +102 -27
- package/src/engine-components/Component.ts +605 -129
- package/src/engine-components/DragControls.ts +134 -38
- package/src/engine-components/DropListener.ts +143 -23
- package/src/engine-components/Light.ts +105 -44
- package/src/engine-components/NeedleMenu.ts +29 -11
- package/src/engine-components/Networking.ts +37 -6
- package/src/engine-components/SceneSwitcher.ts +78 -9
- package/src/engine-components/SpatialTrigger.ts +80 -3
- package/src/engine-components/SpectatorCamera.ts +136 -18
- package/src/engine-components/SyncedTransform.ts +50 -7
- package/src/engine-components/TransformGizmo.ts +49 -4
- package/src/engine-components/ui/EventSystem.ts +9 -7
- package/src/engine-components/webxr/WebXR.ts +144 -27
- package/src/engine-components-experimental/networking/PlayerSync.ts +85 -13
|
@@ -9,15 +9,30 @@ import * as params from "../engine/engine_default_parameters.js";
|
|
|
9
9
|
import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
10
10
|
import { Behaviour } from "./Component.js";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Component that visualizes the axes of an object in the scene.
|
|
13
|
+
* Renders colored lines representing the X (red), Y (green) and Z (blue) axes.
|
|
13
14
|
* @category Helpers
|
|
14
15
|
* @group Components
|
|
15
16
|
*/
|
|
16
17
|
export class AxesHelper extends Behaviour {
|
|
18
|
+
/**
|
|
19
|
+
* The length of each axis line in scene units.
|
|
20
|
+
*/
|
|
17
21
|
length = 1;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the axes should be occluded by objects in the scene.
|
|
24
|
+
* When set to false, axes will always appear on top regardless of their depth.
|
|
25
|
+
*/
|
|
18
26
|
depthTest = true;
|
|
27
|
+
/**
|
|
28
|
+
* When true, this helper will only be visible if the debug flag `?gizmos` is enabled.
|
|
29
|
+
*/
|
|
19
30
|
isGizmo = false;
|
|
20
31
|
_axes = null;
|
|
32
|
+
/**
|
|
33
|
+
* Creates and adds the axes visualization to the scene when the component is enabled.
|
|
34
|
+
* If marked as a gizmo, it will only be shown when gizmos are enabled in the global parameters.
|
|
35
|
+
*/
|
|
21
36
|
onEnable() {
|
|
22
37
|
if (this.isGizmo && !params.showGizmos)
|
|
23
38
|
return;
|
|
@@ -32,6 +47,9 @@ export class AxesHelper extends Behaviour {
|
|
|
32
47
|
mat.depthTest = this.depthTest;
|
|
33
48
|
}
|
|
34
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Removes the axes visualization from the scene when the component is disabled.
|
|
52
|
+
*/
|
|
35
53
|
onDisable() {
|
|
36
54
|
if (!this._axes)
|
|
37
55
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxesHelper.js","sourceRoot":"","sources":["../../src/engine-components/AxesHelper.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C
|
|
1
|
+
{"version":3,"file":"AxesHelper.js","sourceRoot":"","sources":["../../src/engine-components/AxesHelper.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,OAAO,UAAW,SAAQ,SAAS;IACrC;;OAEG;IAEI,MAAM,GAAW,CAAC,CAAC;IAE1B;;;OAGG;IAEI,SAAS,GAAY,IAAI,CAAC;IAEjC;;OAEG;IAEI,OAAO,GAAY,KAAK,CAAC;IAExB,KAAK,GAAuB,IAAI,CAAC;IAEzC;;;OAGG;IACH,QAAQ;QACJ,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO;QAC/C,IAAI,CAAC,IAAI,CAAC,KAAK;YACX,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,GAAG,GAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QACrC,IAAI,GAAG,EAAE;YACL,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS;gBAC3B,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;SACtC;IACL,CAAC;IAED;;OAEG;IACH,SAAS;QACL,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO;QACxB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACJ;AA1CG;IADC,YAAY,EAAE;0CACW;AAO1B;IADC,YAAY,EAAE;6CACkB;AAMjC;IADC,YAAY,EAAE;2CACiB"}
|
|
@@ -1,21 +1,47 @@
|
|
|
1
1
|
import { Box3, type ColorRepresentation, Object3D } from "three";
|
|
2
2
|
import { Behaviour } from "./Component.js";
|
|
3
3
|
/**
|
|
4
|
+
* A component that creates a bounding box around an object and provides intersection testing functionality.
|
|
5
|
+
*
|
|
6
|
+
* Debug mode can be enabled with the URL parameter `?debugboxhelper`, which will visualize intersection tests.
|
|
7
|
+
* Helper visualization can be enabled with the URL parameter `?gizmos`.
|
|
8
|
+
*
|
|
4
9
|
* @category Helpers
|
|
5
10
|
* @group Components
|
|
6
11
|
*/
|
|
7
12
|
export declare class BoxHelperComponent extends Behaviour {
|
|
13
|
+
/** The bounding box for this component */
|
|
8
14
|
private box;
|
|
9
15
|
private static testBox;
|
|
10
16
|
private _lastMatrixUpdateFrame;
|
|
11
17
|
private static _position;
|
|
12
18
|
private static _size;
|
|
13
19
|
private static _emptyObjectSize;
|
|
20
|
+
/**
|
|
21
|
+
* Tests if an object intersects with this helper's bounding box
|
|
22
|
+
* @param obj The object to test for intersection
|
|
23
|
+
* @returns True if objects intersect, false if not, undefined if the provided object is invalid
|
|
24
|
+
*/
|
|
14
25
|
isInBox(obj: Object3D): boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Tests if this helper's bounding box intersects with another box
|
|
28
|
+
* @param box The {@link Box3} to test for intersection
|
|
29
|
+
* @returns True if boxes intersect, false otherwise
|
|
30
|
+
*/
|
|
15
31
|
intersects(box: Box3): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Updates the helper's bounding box based on the gameObject's position and scale
|
|
34
|
+
* @param force Whether to force an update regardless of frame count
|
|
35
|
+
* @returns The updated {@link Box3}
|
|
36
|
+
*/
|
|
16
37
|
updateBox(force?: boolean): Box3;
|
|
17
38
|
private _helper;
|
|
18
39
|
private _color;
|
|
19
40
|
awake(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Creates and displays a visual wireframe representation of this box helper
|
|
43
|
+
* @param col Optional color for the wireframe. If not provided, uses default color
|
|
44
|
+
* @param force If true, shows the helper even if gizmos are disabled
|
|
45
|
+
*/
|
|
20
46
|
showHelper(col?: ColorRepresentation | null, force?: boolean): void;
|
|
21
47
|
}
|
|
@@ -6,16 +6,27 @@ import { Behaviour } from "./Component.js";
|
|
|
6
6
|
const gizmos = getParam("gizmos");
|
|
7
7
|
const debug = getParam("debugboxhelper");
|
|
8
8
|
/**
|
|
9
|
+
* A component that creates a bounding box around an object and provides intersection testing functionality.
|
|
10
|
+
*
|
|
11
|
+
* Debug mode can be enabled with the URL parameter `?debugboxhelper`, which will visualize intersection tests.
|
|
12
|
+
* Helper visualization can be enabled with the URL parameter `?gizmos`.
|
|
13
|
+
*
|
|
9
14
|
* @category Helpers
|
|
10
15
|
* @group Components
|
|
11
16
|
*/
|
|
12
17
|
export class BoxHelperComponent extends Behaviour {
|
|
18
|
+
/** The bounding box for this component */
|
|
13
19
|
box = null;
|
|
14
20
|
static testBox = new Box3();
|
|
15
21
|
_lastMatrixUpdateFrame = -1;
|
|
16
22
|
static _position = new Vector3();
|
|
17
23
|
static _size = new Vector3(.01, .01, .01);
|
|
18
24
|
static _emptyObjectSize = new Vector3(.01, .01, .01);
|
|
25
|
+
/**
|
|
26
|
+
* Tests if an object intersects with this helper's bounding box
|
|
27
|
+
* @param obj The object to test for intersection
|
|
28
|
+
* @returns True if objects intersect, false if not, undefined if the provided object is invalid
|
|
29
|
+
*/
|
|
19
30
|
isInBox(obj) {
|
|
20
31
|
if (!obj)
|
|
21
32
|
return undefined;
|
|
@@ -35,11 +46,21 @@ export class BoxHelperComponent extends Behaviour {
|
|
|
35
46
|
}
|
|
36
47
|
return intersects;
|
|
37
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Tests if this helper's bounding box intersects with another box
|
|
51
|
+
* @param box The {@link Box3} to test for intersection
|
|
52
|
+
* @returns True if boxes intersect, false otherwise
|
|
53
|
+
*/
|
|
38
54
|
intersects(box) {
|
|
39
55
|
if (!box)
|
|
40
56
|
return false;
|
|
41
57
|
return this.updateBox(false).intersectsBox(box);
|
|
42
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Updates the helper's bounding box based on the gameObject's position and scale
|
|
61
|
+
* @param force Whether to force an update regardless of frame count
|
|
62
|
+
* @returns The updated {@link Box3}
|
|
63
|
+
*/
|
|
43
64
|
updateBox(force = false) {
|
|
44
65
|
if (!this.box) {
|
|
45
66
|
this.box = new Box3();
|
|
@@ -61,6 +82,11 @@ export class BoxHelperComponent extends Behaviour {
|
|
|
61
82
|
this._color = null;
|
|
62
83
|
this.box = null;
|
|
63
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Creates and displays a visual wireframe representation of this box helper
|
|
87
|
+
* @param col Optional color for the wireframe. If not provided, uses default color
|
|
88
|
+
* @param force If true, shows the helper even if gizmos are disabled
|
|
89
|
+
*/
|
|
64
90
|
showHelper(col = null, force = false) {
|
|
65
91
|
if (!gizmos && !force)
|
|
66
92
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BoxHelperComponent.js","sourceRoot":"","sources":["../../src/engine-components/BoxHelperComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA2D,OAAO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AAC,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC"}
|
|
@@ -4,8 +4,11 @@ import { RenderTexture } from "../engine/engine_texture.js";
|
|
|
4
4
|
import type { ICamera } from "../engine/engine_types.js";
|
|
5
5
|
import { RGBAColor } from "../engine/js-extensions/index.js";
|
|
6
6
|
import { Behaviour } from "./Component.js";
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The ClearFlags enum is used to determine how the camera clears the background
|
|
9
|
+
*/
|
|
8
10
|
export declare enum ClearFlags {
|
|
11
|
+
/** Don't clear the background */
|
|
9
12
|
None = 0,
|
|
10
13
|
/** Clear the background with a skybox */
|
|
11
14
|
Skybox = 1,
|
|
@@ -15,68 +18,124 @@ export declare enum ClearFlags {
|
|
|
15
18
|
Uninitialized = 4
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
21
|
+
* Camera component that handles rendering from a specific viewpoint in the scene.
|
|
22
|
+
* Supports both perspective and orthographic cameras with various rendering options.
|
|
23
|
+
* Internally, this component uses {@link PerspectiveCamera} and {@link OrthographicCamera} three.js objects.
|
|
24
|
+
*
|
|
18
25
|
* @category Camera Controls
|
|
19
26
|
* @group Components
|
|
20
27
|
*/
|
|
21
28
|
export declare class Camera extends Behaviour implements ICamera {
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether this component is a camera
|
|
31
|
+
* @returns {boolean} Always returns true
|
|
32
|
+
*/
|
|
22
33
|
get isCamera(): boolean;
|
|
23
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Gets or sets the camera's aspect ratio (width divided by height).
|
|
36
|
+
* For perspective cameras, this directly affects the camera's projection matrix.
|
|
37
|
+
* When set, automatically updates the projection matrix.
|
|
38
|
+
*/
|
|
24
39
|
get aspect(): number;
|
|
25
40
|
set aspect(value: number);
|
|
26
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Gets or sets the camera's field of view in degrees for perspective cameras.
|
|
43
|
+
* When set, automatically updates the projection matrix.
|
|
44
|
+
*/
|
|
27
45
|
get fieldOfView(): number | undefined;
|
|
28
46
|
set fieldOfView(val: number | undefined);
|
|
29
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Gets or sets the camera's near clipping plane distance.
|
|
49
|
+
* Objects closer than this distance won't be rendered.
|
|
50
|
+
* When set, automatically updates the projection matrix.
|
|
51
|
+
*/
|
|
30
52
|
get nearClipPlane(): number;
|
|
31
53
|
set nearClipPlane(val: number);
|
|
32
54
|
private _nearClipPlane;
|
|
33
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Gets or sets the camera's far clipping plane distance.
|
|
57
|
+
* Objects farther than this distance won't be rendered.
|
|
58
|
+
* When set, automatically updates the projection matrix.
|
|
59
|
+
*/
|
|
34
60
|
get farClipPlane(): number;
|
|
35
61
|
set farClipPlane(val: number);
|
|
36
62
|
private _farClipPlane;
|
|
37
63
|
/**
|
|
38
|
-
*
|
|
64
|
+
* Applies both the camera's near and far clipping planes and updates the projection matrix.
|
|
65
|
+
* This ensures rendering occurs only within the specified distance range.
|
|
39
66
|
*/
|
|
40
67
|
applyClippingPlane(): void;
|
|
41
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Gets or sets the camera's clear flags that determine how the background is rendered.
|
|
70
|
+
* Options include skybox, solid color, or transparent background.
|
|
71
|
+
*/
|
|
42
72
|
get clearFlags(): ClearFlags;
|
|
43
73
|
set clearFlags(val: ClearFlags);
|
|
74
|
+
/**
|
|
75
|
+
* Determines if the camera should use orthographic projection instead of perspective.
|
|
76
|
+
*/
|
|
44
77
|
orthographic: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The size of the orthographic camera's view volume when in orthographic mode.
|
|
80
|
+
* Larger values show more of the scene.
|
|
81
|
+
*/
|
|
45
82
|
orthographicSize: number;
|
|
83
|
+
/**
|
|
84
|
+
* Controls the transparency level of the camera background in AR mode on supported devices.
|
|
85
|
+
* Value from 0 (fully transparent) to 1 (fully opaque).
|
|
86
|
+
*/
|
|
46
87
|
ARBackgroundAlpha: number;
|
|
47
88
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
89
|
+
* Gets or sets the layers mask that determines which objects this camera will render.
|
|
90
|
+
* Uses the {@link https://threejs.org/docs/#api/en/core/Layers.mask|three.js layers mask} convention.
|
|
91
|
+
*/
|
|
51
92
|
set cullingMask(val: number);
|
|
52
93
|
get cullingMask(): number;
|
|
53
94
|
private _cullingMask;
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Sets only a specific layer to be active for rendering by this camera.
|
|
97
|
+
* This is equivalent to calling `layers.set(val)` on the three.js camera object.
|
|
98
|
+
* @param val The layer index to set active
|
|
99
|
+
*/
|
|
57
100
|
set cullingLayer(val: number);
|
|
58
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Gets or sets the blurriness of the skybox background.
|
|
103
|
+
* Values range from 0 (sharp) to 1 (maximum blur).
|
|
104
|
+
*/
|
|
59
105
|
set backgroundBlurriness(val: number | undefined);
|
|
60
106
|
get backgroundBlurriness(): number | undefined;
|
|
61
107
|
private _backgroundBlurriness?;
|
|
62
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Gets or sets the intensity of the skybox background.
|
|
110
|
+
* Values range from 0 (dark) to 10 (very bright).
|
|
111
|
+
*/
|
|
63
112
|
set backgroundIntensity(val: number | undefined);
|
|
64
113
|
get backgroundIntensity(): number | undefined;
|
|
65
114
|
private _backgroundIntensity?;
|
|
66
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Gets or sets the rotation of the skybox background.
|
|
117
|
+
* Controls the orientation of the environment map.
|
|
118
|
+
*/
|
|
67
119
|
set backgroundRotation(val: Euler | undefined);
|
|
68
120
|
get backgroundRotation(): Euler | undefined;
|
|
69
121
|
private _backgroundRotation?;
|
|
70
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* Gets or sets the intensity of the environment lighting.
|
|
124
|
+
* Controls how strongly the environment map affects scene lighting.
|
|
125
|
+
*/
|
|
71
126
|
set environmentIntensity(val: number | undefined);
|
|
72
127
|
get environmentIntensity(): number | undefined;
|
|
73
128
|
private _environmentIntensity?;
|
|
74
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Gets or sets the background color of the camera when {@link ClearFlags} is set to {@link ClearFlags.SolidColor}.
|
|
131
|
+
* The alpha component controls transparency.
|
|
132
|
+
*/
|
|
75
133
|
get backgroundColor(): RGBAColor | null;
|
|
76
134
|
set backgroundColor(val: RGBAColor | null);
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Gets or sets the texture that the camera should render to instead of the screen.
|
|
137
|
+
* Useful for creating effects like mirrors, portals or custom post processing.
|
|
138
|
+
*/
|
|
80
139
|
set targetTexture(rt: RenderTexture | null);
|
|
81
140
|
get targetTexture(): RenderTexture | null;
|
|
82
141
|
private _targetTexture;
|
|
@@ -86,29 +145,47 @@ export declare class Camera extends Behaviour implements ICamera {
|
|
|
86
145
|
private _clearFlags;
|
|
87
146
|
private _skybox?;
|
|
88
147
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @returns {PerspectiveCamera | OrthographicCamera}
|
|
91
|
-
* @deprecated
|
|
148
|
+
* Gets the three.js camera object. Creates one if it doesn't exist yet.
|
|
149
|
+
* @returns {PerspectiveCamera | OrthographicCamera} The three.js camera object
|
|
150
|
+
* @deprecated Use {@link threeCamera} instead
|
|
92
151
|
*/
|
|
93
152
|
get cam(): PerspectiveCamera | OrthographicCamera;
|
|
94
153
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @returns {PerspectiveCamera | OrthographicCamera}
|
|
154
|
+
* Gets the three.js camera object. Creates one if it doesn't exist yet.
|
|
155
|
+
* @returns {PerspectiveCamera | OrthographicCamera} The three.js camera object
|
|
97
156
|
*/
|
|
98
157
|
get threeCamera(): PerspectiveCamera | OrthographicCamera;
|
|
99
158
|
private static _origin;
|
|
100
159
|
private static _direction;
|
|
160
|
+
/**
|
|
161
|
+
* Converts screen coordinates to a ray in world space.
|
|
162
|
+
* Useful for implementing picking or raycasting from screen to world.
|
|
163
|
+
*
|
|
164
|
+
* @param x The x screen coordinate
|
|
165
|
+
* @param y The y screen coordinate
|
|
166
|
+
* @param ray Optional ray object to reuse instead of creating a new one
|
|
167
|
+
* @returns {Ray} A ray originating from the camera position pointing through the screen point
|
|
168
|
+
*/
|
|
101
169
|
screenPointToRay(x: number, y: number, ray?: Ray): Ray;
|
|
102
170
|
private _frustum?;
|
|
103
171
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
172
|
+
* Gets the camera's view frustum for culling and visibility checks.
|
|
173
|
+
* Creates the frustum if it doesn't exist and returns it.
|
|
174
|
+
*
|
|
175
|
+
* @returns {Frustum} The camera's view frustum
|
|
106
176
|
*/
|
|
107
177
|
getFrustum(): Frustum;
|
|
108
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Forces an update of the camera's frustum.
|
|
180
|
+
* This is automatically called every frame in onBeforeRender.
|
|
181
|
+
*/
|
|
109
182
|
updateFrustum(): void;
|
|
110
183
|
/**
|
|
111
|
-
*
|
|
184
|
+
* Gets this camera's projection-screen matrix.
|
|
185
|
+
*
|
|
186
|
+
* @param target Matrix4 object to store the result in
|
|
187
|
+
* @param forceUpdate Whether to force recalculation of the matrix
|
|
188
|
+
* @returns {Matrix4} The requested projection screen matrix
|
|
112
189
|
*/
|
|
113
190
|
getProjectionScreenMatrix(target: Matrix4, forceUpdate?: boolean): Matrix4;
|
|
114
191
|
private readonly _projScreenMatrix;
|
|
@@ -121,22 +198,34 @@ export declare class Camera extends Behaviour implements ICamera {
|
|
|
121
198
|
/** @internal */
|
|
122
199
|
onBeforeRender(): void;
|
|
123
200
|
/**
|
|
124
|
-
* Creates a
|
|
125
|
-
|
|
201
|
+
* Creates a three.js camera object if it doesn't exist yet and sets its properties.
|
|
202
|
+
* This is called internally when accessing the {@link threeCamera} property.
|
|
203
|
+
*/
|
|
126
204
|
buildCamera(): void;
|
|
205
|
+
/**
|
|
206
|
+
* Applies clear flags if this is the active main camera.
|
|
207
|
+
* @param opts Options for applying clear flags
|
|
208
|
+
*/
|
|
127
209
|
applyClearFlagsIfIsActiveCamera(opts?: {
|
|
128
210
|
applySkybox: boolean;
|
|
129
211
|
}): void;
|
|
130
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* Applies this camera's clear flags and related settings to the renderer.
|
|
214
|
+
* This controls how the background is rendered (skybox, solid color, transparent).
|
|
215
|
+
* @param opts Options for applying clear flags
|
|
216
|
+
*/
|
|
131
217
|
applyClearFlags(opts?: {
|
|
132
218
|
applySkybox: boolean;
|
|
133
219
|
}): void;
|
|
134
220
|
/**
|
|
135
|
-
*
|
|
221
|
+
* Applies the skybox texture to the scene background.
|
|
136
222
|
*/
|
|
137
223
|
applySceneSkybox(): void;
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Determines if the background should be transparent when in passthrough AR mode.
|
|
226
|
+
*
|
|
227
|
+
* @param context The current rendering context
|
|
228
|
+
* @returns {boolean} True when in XR on a pass through device where the background should be invisible
|
|
229
|
+
*/
|
|
141
230
|
static backgroundShouldBeTransparent(context: Context): boolean;
|
|
142
231
|
}
|