@needle-tools/engine 4.3.0-alpha → 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 +3 -0
- package/dist/needle-engine.bundle.js +1467 -222
- package/dist/needle-engine.bundle.light.js +1467 -222
- package/dist/needle-engine.bundle.light.min.js +32 -32
- package/dist/needle-engine.bundle.light.umd.cjs +3 -3
- package/dist/needle-engine.bundle.min.js +3 -3
- package/dist/needle-engine.bundle.umd.cjs +3 -3
- package/dist/needle-engine.light.d.ts +9 -9
- 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.js +44 -0
- 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/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/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 +48 -1
- 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/webxr/WebXR.ts +144 -27
- package/src/engine-components-experimental/networking/PlayerSync.ts +85 -13
|
@@ -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
|
}
|
|
@@ -14,9 +14,12 @@ import { getParam } from "../engine/engine_utils.js";
|
|
|
14
14
|
import { RGBAColor } from "../engine/js-extensions/index.js";
|
|
15
15
|
import { Behaviour, GameObject } from "./Component.js";
|
|
16
16
|
import { OrbitControls } from "./OrbitControls.js";
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* The ClearFlags enum is used to determine how the camera clears the background
|
|
19
|
+
*/
|
|
18
20
|
export var ClearFlags;
|
|
19
21
|
(function (ClearFlags) {
|
|
22
|
+
/** Don't clear the background */
|
|
20
23
|
ClearFlags[ClearFlags["None"] = 0] = "None";
|
|
21
24
|
/** Clear the background with a skybox */
|
|
22
25
|
ClearFlags[ClearFlags["Skybox"] = 1] = "Skybox";
|
|
@@ -28,14 +31,26 @@ export var ClearFlags;
|
|
|
28
31
|
const debug = getParam("debugcam");
|
|
29
32
|
const debugscreenpointtoray = getParam("debugscreenpointtoray");
|
|
30
33
|
/**
|
|
34
|
+
* Camera component that handles rendering from a specific viewpoint in the scene.
|
|
35
|
+
* Supports both perspective and orthographic cameras with various rendering options.
|
|
36
|
+
* Internally, this component uses {@link PerspectiveCamera} and {@link OrthographicCamera} three.js objects.
|
|
37
|
+
*
|
|
31
38
|
* @category Camera Controls
|
|
32
39
|
* @group Components
|
|
33
40
|
*/
|
|
34
41
|
export class Camera extends Behaviour {
|
|
42
|
+
/**
|
|
43
|
+
* Returns whether this component is a camera
|
|
44
|
+
* @returns {boolean} Always returns true
|
|
45
|
+
*/
|
|
35
46
|
get isCamera() {
|
|
36
47
|
return true;
|
|
37
48
|
}
|
|
38
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Gets or sets the camera's aspect ratio (width divided by height).
|
|
51
|
+
* For perspective cameras, this directly affects the camera's projection matrix.
|
|
52
|
+
* When set, automatically updates the projection matrix.
|
|
53
|
+
*/
|
|
39
54
|
get aspect() {
|
|
40
55
|
if (this._cam instanceof PerspectiveCamera)
|
|
41
56
|
return this._cam.aspect;
|
|
@@ -49,7 +64,10 @@ export class Camera extends Behaviour {
|
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
66
|
}
|
|
52
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Gets or sets the camera's field of view in degrees for perspective cameras.
|
|
69
|
+
* When set, automatically updates the projection matrix.
|
|
70
|
+
*/
|
|
53
71
|
get fieldOfView() {
|
|
54
72
|
if (this._cam instanceof PerspectiveCamera) {
|
|
55
73
|
return this._cam.fov;
|
|
@@ -70,7 +88,11 @@ export class Camera extends Behaviour {
|
|
|
70
88
|
}
|
|
71
89
|
}
|
|
72
90
|
}
|
|
73
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Gets or sets the camera's near clipping plane distance.
|
|
93
|
+
* Objects closer than this distance won't be rendered.
|
|
94
|
+
* When set, automatically updates the projection matrix.
|
|
95
|
+
*/
|
|
74
96
|
get nearClipPlane() { return this._nearClipPlane; }
|
|
75
97
|
set nearClipPlane(val) {
|
|
76
98
|
const changed = this._nearClipPlane != val;
|
|
@@ -81,7 +103,11 @@ export class Camera extends Behaviour {
|
|
|
81
103
|
}
|
|
82
104
|
}
|
|
83
105
|
_nearClipPlane = 0.1;
|
|
84
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Gets or sets the camera's far clipping plane distance.
|
|
108
|
+
* Objects farther than this distance won't be rendered.
|
|
109
|
+
* When set, automatically updates the projection matrix.
|
|
110
|
+
*/
|
|
85
111
|
get farClipPlane() { return this._farClipPlane; }
|
|
86
112
|
set farClipPlane(val) {
|
|
87
113
|
const changed = this._farClipPlane != val;
|
|
@@ -93,7 +119,8 @@ export class Camera extends Behaviour {
|
|
|
93
119
|
}
|
|
94
120
|
_farClipPlane = 1000;
|
|
95
121
|
/**
|
|
96
|
-
*
|
|
122
|
+
* Applies both the camera's near and far clipping planes and updates the projection matrix.
|
|
123
|
+
* This ensures rendering occurs only within the specified distance range.
|
|
97
124
|
*/
|
|
98
125
|
applyClippingPlane() {
|
|
99
126
|
if (this._cam) {
|
|
@@ -102,7 +129,10 @@ export class Camera extends Behaviour {
|
|
|
102
129
|
this._cam.updateProjectionMatrix();
|
|
103
130
|
}
|
|
104
131
|
}
|
|
105
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Gets or sets the camera's clear flags that determine how the background is rendered.
|
|
134
|
+
* Options include skybox, solid color, or transparent background.
|
|
135
|
+
*/
|
|
106
136
|
get clearFlags() {
|
|
107
137
|
return this._clearFlags;
|
|
108
138
|
}
|
|
@@ -112,13 +142,24 @@ export class Camera extends Behaviour {
|
|
|
112
142
|
this._clearFlags = val;
|
|
113
143
|
this.applyClearFlagsIfIsActiveCamera();
|
|
114
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Determines if the camera should use orthographic projection instead of perspective.
|
|
147
|
+
*/
|
|
115
148
|
orthographic = false;
|
|
149
|
+
/**
|
|
150
|
+
* The size of the orthographic camera's view volume when in orthographic mode.
|
|
151
|
+
* Larger values show more of the scene.
|
|
152
|
+
*/
|
|
116
153
|
orthographicSize = 5;
|
|
154
|
+
/**
|
|
155
|
+
* Controls the transparency level of the camera background in AR mode on supported devices.
|
|
156
|
+
* Value from 0 (fully transparent) to 1 (fully opaque).
|
|
157
|
+
*/
|
|
117
158
|
ARBackgroundAlpha = 0;
|
|
118
159
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
|
|
160
|
+
* Gets or sets the layers mask that determines which objects this camera will render.
|
|
161
|
+
* Uses the {@link https://threejs.org/docs/#api/en/core/Layers.mask|three.js layers mask} convention.
|
|
162
|
+
*/
|
|
122
163
|
set cullingMask(val) {
|
|
123
164
|
this._cullingMask = val;
|
|
124
165
|
if (this._cam) {
|
|
@@ -131,13 +172,18 @@ export class Camera extends Behaviour {
|
|
|
131
172
|
return this._cullingMask;
|
|
132
173
|
}
|
|
133
174
|
_cullingMask = 0xffffffff;
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Sets only a specific layer to be active for rendering by this camera.
|
|
177
|
+
* This is equivalent to calling `layers.set(val)` on the three.js camera object.
|
|
178
|
+
* @param val The layer index to set active
|
|
179
|
+
*/
|
|
137
180
|
set cullingLayer(val) {
|
|
138
181
|
this.cullingMask = (1 << val | 0) >>> 0;
|
|
139
182
|
}
|
|
140
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Gets or sets the blurriness of the skybox background.
|
|
185
|
+
* Values range from 0 (sharp) to 1 (maximum blur).
|
|
186
|
+
*/
|
|
141
187
|
set backgroundBlurriness(val) {
|
|
142
188
|
if (val === this._backgroundBlurriness)
|
|
143
189
|
return;
|
|
@@ -151,7 +197,10 @@ export class Camera extends Behaviour {
|
|
|
151
197
|
return this._backgroundBlurriness;
|
|
152
198
|
}
|
|
153
199
|
_backgroundBlurriness = undefined;
|
|
154
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* Gets or sets the intensity of the skybox background.
|
|
202
|
+
* Values range from 0 (dark) to 10 (very bright).
|
|
203
|
+
*/
|
|
155
204
|
set backgroundIntensity(val) {
|
|
156
205
|
if (val === this._backgroundIntensity)
|
|
157
206
|
return;
|
|
@@ -165,7 +214,10 @@ export class Camera extends Behaviour {
|
|
|
165
214
|
return this._backgroundIntensity;
|
|
166
215
|
}
|
|
167
216
|
_backgroundIntensity = undefined;
|
|
168
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Gets or sets the rotation of the skybox background.
|
|
219
|
+
* Controls the orientation of the environment map.
|
|
220
|
+
*/
|
|
169
221
|
set backgroundRotation(val) {
|
|
170
222
|
if (val === this._backgroundRotation)
|
|
171
223
|
return;
|
|
@@ -179,7 +231,10 @@ export class Camera extends Behaviour {
|
|
|
179
231
|
return this._backgroundRotation;
|
|
180
232
|
}
|
|
181
233
|
_backgroundRotation = undefined;
|
|
182
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Gets or sets the intensity of the environment lighting.
|
|
236
|
+
* Controls how strongly the environment map affects scene lighting.
|
|
237
|
+
*/
|
|
183
238
|
set environmentIntensity(val) {
|
|
184
239
|
this._environmentIntensity = val;
|
|
185
240
|
}
|
|
@@ -187,7 +242,10 @@ export class Camera extends Behaviour {
|
|
|
187
242
|
return this._environmentIntensity;
|
|
188
243
|
}
|
|
189
244
|
_environmentIntensity = undefined;
|
|
190
|
-
/**
|
|
245
|
+
/**
|
|
246
|
+
* Gets or sets the background color of the camera when {@link ClearFlags} is set to {@link ClearFlags.SolidColor}.
|
|
247
|
+
* The alpha component controls transparency.
|
|
248
|
+
*/
|
|
191
249
|
get backgroundColor() {
|
|
192
250
|
return this._backgroundColor ?? null;
|
|
193
251
|
}
|
|
@@ -206,9 +264,10 @@ export class Camera extends Behaviour {
|
|
|
206
264
|
this._backgroundColor.alpha = 1;
|
|
207
265
|
this.applyClearFlagsIfIsActiveCamera();
|
|
208
266
|
}
|
|
209
|
-
/**
|
|
210
|
-
*
|
|
211
|
-
|
|
267
|
+
/**
|
|
268
|
+
* Gets or sets the texture that the camera should render to instead of the screen.
|
|
269
|
+
* Useful for creating effects like mirrors, portals or custom post processing.
|
|
270
|
+
*/
|
|
212
271
|
set targetTexture(rt) {
|
|
213
272
|
this._targetTexture = rt;
|
|
214
273
|
}
|
|
@@ -222,16 +281,16 @@ export class Camera extends Behaviour {
|
|
|
222
281
|
_clearFlags = ClearFlags.SolidColor;
|
|
223
282
|
_skybox;
|
|
224
283
|
/**
|
|
225
|
-
*
|
|
226
|
-
* @returns {PerspectiveCamera | OrthographicCamera}
|
|
227
|
-
* @deprecated
|
|
284
|
+
* Gets the three.js camera object. Creates one if it doesn't exist yet.
|
|
285
|
+
* @returns {PerspectiveCamera | OrthographicCamera} The three.js camera object
|
|
286
|
+
* @deprecated Use {@link threeCamera} instead
|
|
228
287
|
*/
|
|
229
288
|
get cam() {
|
|
230
289
|
return this.threeCamera;
|
|
231
290
|
}
|
|
232
291
|
/**
|
|
233
|
-
*
|
|
234
|
-
* @returns {PerspectiveCamera | OrthographicCamera}
|
|
292
|
+
* Gets the three.js camera object. Creates one if it doesn't exist yet.
|
|
293
|
+
* @returns {PerspectiveCamera | OrthographicCamera} The three.js camera object
|
|
235
294
|
*/
|
|
236
295
|
get threeCamera() {
|
|
237
296
|
if (this.activeAndEnabled)
|
|
@@ -240,6 +299,15 @@ export class Camera extends Behaviour {
|
|
|
240
299
|
}
|
|
241
300
|
static _origin = new Vector3();
|
|
242
301
|
static _direction = new Vector3();
|
|
302
|
+
/**
|
|
303
|
+
* Converts screen coordinates to a ray in world space.
|
|
304
|
+
* Useful for implementing picking or raycasting from screen to world.
|
|
305
|
+
*
|
|
306
|
+
* @param x The x screen coordinate
|
|
307
|
+
* @param y The y screen coordinate
|
|
308
|
+
* @param ray Optional ray object to reuse instead of creating a new one
|
|
309
|
+
* @returns {Ray} A ray originating from the camera position pointing through the screen point
|
|
310
|
+
*/
|
|
243
311
|
screenPointToRay(x, y, ray) {
|
|
244
312
|
const cam = this.threeCamera;
|
|
245
313
|
const origin = Camera._origin;
|
|
@@ -263,8 +331,10 @@ export class Camera extends Behaviour {
|
|
|
263
331
|
}
|
|
264
332
|
_frustum;
|
|
265
333
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
334
|
+
* Gets the camera's view frustum for culling and visibility checks.
|
|
335
|
+
* Creates the frustum if it doesn't exist and returns it.
|
|
336
|
+
*
|
|
337
|
+
* @returns {Frustum} The camera's view frustum
|
|
268
338
|
*/
|
|
269
339
|
getFrustum() {
|
|
270
340
|
if (!this._frustum) {
|
|
@@ -273,14 +343,21 @@ export class Camera extends Behaviour {
|
|
|
273
343
|
}
|
|
274
344
|
return this._frustum;
|
|
275
345
|
}
|
|
276
|
-
/**
|
|
346
|
+
/**
|
|
347
|
+
* Forces an update of the camera's frustum.
|
|
348
|
+
* This is automatically called every frame in onBeforeRender.
|
|
349
|
+
*/
|
|
277
350
|
updateFrustum() {
|
|
278
351
|
if (!this._frustum)
|
|
279
352
|
this._frustum = new Frustum();
|
|
280
353
|
this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix, true), this.context.renderer.coordinateSystem);
|
|
281
354
|
}
|
|
282
355
|
/**
|
|
283
|
-
*
|
|
356
|
+
* Gets this camera's projection-screen matrix.
|
|
357
|
+
*
|
|
358
|
+
* @param target Matrix4 object to store the result in
|
|
359
|
+
* @param forceUpdate Whether to force recalculation of the matrix
|
|
360
|
+
* @returns {Matrix4} The requested projection screen matrix
|
|
284
361
|
*/
|
|
285
362
|
getProjectionScreenMatrix(target, forceUpdate) {
|
|
286
363
|
if (forceUpdate) {
|
|
@@ -351,8 +428,9 @@ export class Camera extends Behaviour {
|
|
|
351
428
|
}
|
|
352
429
|
}
|
|
353
430
|
/**
|
|
354
|
-
* Creates a
|
|
355
|
-
|
|
431
|
+
* Creates a three.js camera object if it doesn't exist yet and sets its properties.
|
|
432
|
+
* This is called internally when accessing the {@link threeCamera} property.
|
|
433
|
+
*/
|
|
356
434
|
buildCamera() {
|
|
357
435
|
if (this._cam)
|
|
358
436
|
return;
|
|
@@ -393,12 +471,20 @@ export class Camera extends Behaviour {
|
|
|
393
471
|
this.context.setCurrentCamera(this);
|
|
394
472
|
}
|
|
395
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Applies clear flags if this is the active main camera.
|
|
476
|
+
* @param opts Options for applying clear flags
|
|
477
|
+
*/
|
|
396
478
|
applyClearFlagsIfIsActiveCamera(opts) {
|
|
397
479
|
if (this.context.mainCameraComponent === this) {
|
|
398
480
|
this.applyClearFlags(opts);
|
|
399
481
|
}
|
|
400
482
|
}
|
|
401
|
-
/**
|
|
483
|
+
/**
|
|
484
|
+
* Applies this camera's clear flags and related settings to the renderer.
|
|
485
|
+
* This controls how the background is rendered (skybox, solid color, transparent).
|
|
486
|
+
* @param opts Options for applying clear flags
|
|
487
|
+
*/
|
|
402
488
|
applyClearFlags(opts) {
|
|
403
489
|
if (!this._cam) {
|
|
404
490
|
if (debug)
|
|
@@ -465,16 +551,19 @@ export class Camera extends Behaviour {
|
|
|
465
551
|
}
|
|
466
552
|
}
|
|
467
553
|
/**
|
|
468
|
-
*
|
|
554
|
+
* Applies the skybox texture to the scene background.
|
|
469
555
|
*/
|
|
470
556
|
applySceneSkybox() {
|
|
471
557
|
if (!this._skybox)
|
|
472
558
|
this._skybox = new CameraSkybox(this);
|
|
473
559
|
this._skybox.apply();
|
|
474
560
|
}
|
|
475
|
-
/**
|
|
476
|
-
*
|
|
477
|
-
|
|
561
|
+
/**
|
|
562
|
+
* Determines if the background should be transparent when in passthrough AR mode.
|
|
563
|
+
*
|
|
564
|
+
* @param context The current rendering context
|
|
565
|
+
* @returns {boolean} True when in XR on a pass through device where the background should be invisible
|
|
566
|
+
*/
|
|
478
567
|
static backgroundShouldBeTransparent(context) {
|
|
479
568
|
const session = context.renderer.xr?.getSession();
|
|
480
569
|
if (!session)
|
|
@@ -548,6 +637,10 @@ __decorate([
|
|
|
548
637
|
__decorate([
|
|
549
638
|
serializable(RenderTexture)
|
|
550
639
|
], Camera.prototype, "targetTexture", null);
|
|
640
|
+
/**
|
|
641
|
+
* Helper class for managing skybox textures for cameras.
|
|
642
|
+
* Handles retrieving and applying skybox textures to the scene.
|
|
643
|
+
*/
|
|
551
644
|
class CameraSkybox {
|
|
552
645
|
_camera;
|
|
553
646
|
_skybox;
|
|
@@ -555,6 +648,10 @@ class CameraSkybox {
|
|
|
555
648
|
constructor(camera) {
|
|
556
649
|
this._camera = camera;
|
|
557
650
|
}
|
|
651
|
+
/**
|
|
652
|
+
* Applies the skybox texture to the scene background.
|
|
653
|
+
* Retrieves the texture based on the camera's source ID.
|
|
654
|
+
*/
|
|
558
655
|
apply() {
|
|
559
656
|
this._skybox = this.context.lightmaps.tryGetSkybox(this._camera.sourceId);
|
|
560
657
|
if (!this._skybox) {
|
|
@@ -571,6 +668,11 @@ class CameraSkybox {
|
|
|
571
668
|
}
|
|
572
669
|
}
|
|
573
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* Adds orbit controls to the camera if the freecam URL parameter is enabled.
|
|
673
|
+
*
|
|
674
|
+
* @param cam The camera to potentially add orbit controls to
|
|
675
|
+
*/
|
|
574
676
|
function handleFreeCam(cam) {
|
|
575
677
|
const isFreecam = getParam("freecam");
|
|
576
678
|
if (isFreecam) {
|