rhodonite 0.21.0 → 0.22.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/README.md +4 -4
- package/VERSION-FILE +1 -1
- package/dist/esm/foundation/components/Camera/CameraComponent.d.ts +15 -0
- package/dist/esm/foundation/components/Light/LightComponent.d.ts +116 -4
- package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.d.ts +2 -0
- package/dist/esm/foundation/core/Config.d.ts +199 -3
- package/dist/esm/foundation/helpers/Shadow/PointShadowMap.d.ts +3 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowSystem.d.ts +13 -0
- package/dist/esm/foundation/math/Transform3D.d.ts +26 -2
- package/dist/esm/foundation/renderer/index.d.ts +1 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterBuilder.d.ts +97 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterLayout.d.ts +98 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.d.ts +171 -0
- package/dist/esm/foundation/renderer/lightCluster/index.d.ts +1 -0
- package/dist/esm/foundation/system/Engine.d.ts +20 -2
- package/dist/esm/foundation/textures/TextureArray.d.ts +1 -1
- package/dist/esm/index.js +1216 -650
- package/dist/esm/webgl/WebGLStrategyWebGL2.d.ts +16 -0
- package/dist/esm/webgpu/WebGpuGpuTimer.d.ts +18 -7
- package/dist/esm/webgpu/WebGpuLightClusterBuilder.d.ts +37 -0
- package/dist/esm/webgpu/WebGpuResourceRepository.d.ts +28 -3
- package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +18 -1
- package/dist/esmdev/foundation/components/Camera/CameraComponent.d.ts +15 -0
- package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +116 -4
- package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.d.ts +2 -0
- package/dist/esmdev/foundation/core/Config.d.ts +199 -3
- package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.d.ts +3 -1
- package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.d.ts +13 -0
- package/dist/esmdev/foundation/math/Transform3D.d.ts +26 -2
- package/dist/esmdev/foundation/renderer/index.d.ts +1 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterBuilder.d.ts +97 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterLayout.d.ts +98 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.d.ts +171 -0
- package/dist/esmdev/foundation/renderer/lightCluster/index.d.ts +1 -0
- package/dist/esmdev/foundation/system/Engine.d.ts +20 -2
- package/dist/esmdev/foundation/textures/TextureArray.d.ts +1 -1
- package/dist/esmdev/index.js +2394 -214
- package/dist/esmdev/webgl/WebGLStrategyWebGL2.d.ts +16 -0
- package/dist/esmdev/webgpu/WebGpuGpuTimer.d.ts +18 -7
- package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.d.ts +37 -0
- package/dist/esmdev/webgpu/WebGpuResourceRepository.d.ts +28 -3
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +18 -1
- package/package.json +1 -1
|
@@ -56,6 +56,8 @@ export declare class WebGLStrategyWebGL2 implements CGAPIStrategy, WebGLStrategy
|
|
|
56
56
|
private __lastBlendShapeComponentsUpdateCountForWeights;
|
|
57
57
|
private __lastMorphMaxIndex;
|
|
58
58
|
private __lastMaterialsUpdateCount;
|
|
59
|
+
private __lastLightClusterDataVersion;
|
|
60
|
+
private __lastLightComponentsUpdateCount;
|
|
59
61
|
private __lastTotalSizeOfGPUShaderDataStorageExceptMorphData;
|
|
60
62
|
private __lastTransformComponentsUpdateCount;
|
|
61
63
|
private __lastSceneGraphComponentsUpdateCount;
|
|
@@ -232,6 +234,15 @@ export declare class WebGLStrategyWebGL2 implements CGAPIStrategy, WebGLStrategy
|
|
|
232
234
|
* - Manages texture alignment and padding requirements
|
|
233
235
|
*/
|
|
234
236
|
private __createAndUpdateDataTextureInner;
|
|
237
|
+
/**
|
|
238
|
+
* Uploads the bytes `[start, end)` of the GPU instance data (16-byte aligned, in the concatenated layers) to the
|
|
239
|
+
* data texture, where texel `n` holds bytes `16n` to `16n + 15`. The range is split into a partial first row, full
|
|
240
|
+
* rows and a partial last row.
|
|
241
|
+
*
|
|
242
|
+
* @param layerArray - The whole memory of the layer that contains the range
|
|
243
|
+
* @param layerByteOffset - The byte offset of the layer in the concatenated layers
|
|
244
|
+
*/
|
|
245
|
+
private __uploadDataTextureTexels;
|
|
235
246
|
/**
|
|
236
247
|
* Deletes the current data texture and frees associated GPU resources.
|
|
237
248
|
* This method should be called when the data texture needs to be recreated
|
|
@@ -483,6 +494,11 @@ export declare class WebGLStrategyWebGL2 implements CGAPIStrategy, WebGLStrategy
|
|
|
483
494
|
* same program by the previous upload. Uniform values persist in the program object, so
|
|
484
495
|
* consecutive draws of the same material (e.g. a shadow pass) do not need to upload again.
|
|
485
496
|
*/
|
|
497
|
+
/**
|
|
498
|
+
* Uploads the light cluster view of the camera of the draw (`u_lightClusterView`) when the program uses it and
|
|
499
|
+
* the camera or the light cluster data changed since the last upload to the program.
|
|
500
|
+
*/
|
|
501
|
+
private __uploadLightClusterView;
|
|
486
502
|
private __uploadCurrentComponentSIDs;
|
|
487
503
|
/**
|
|
488
504
|
* Binds the data texture to the WebGL context for shader access.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Measures the GPU time of each frame with the `timestamp-query` feature.
|
|
3
3
|
*
|
|
4
|
-
* Every render pass begun between beginFrame() and endFrame() writes timestamps at its beginning and
|
|
5
|
-
* the frame's GPU time is the sum of the pass durations. The timestamps are resolved when the command
|
|
4
|
+
* Every render or compute pass begun between beginFrame() and endFrame() writes timestamps at its beginning and
|
|
5
|
+
* end; the frame's GPU time is the sum of the pass durations. The timestamps are resolved when the command
|
|
6
6
|
* encoder is submitted and read back asynchronously, so `lastGpuTimeMilliseconds` reports the latest
|
|
7
|
-
* frame whose results have arrived, not the current one.
|
|
7
|
+
* frame whose results have arrived, not the current one. The duration of each pass label is also published.
|
|
8
8
|
*
|
|
9
9
|
* Browsers may quantize timestamps (e.g. to 100µs) unless developer features are enabled.
|
|
10
10
|
*/
|
|
@@ -16,25 +16,36 @@ export declare class WebGpuGpuTimer {
|
|
|
16
16
|
private __readbackBufferCount;
|
|
17
17
|
/** Timestamps written by passes recorded into the current command encoder. */
|
|
18
18
|
private __timestampCount;
|
|
19
|
+
/** The labels of the passes recorded into the current command encoder, one per pass. */
|
|
20
|
+
private __encoderPassLabels;
|
|
19
21
|
/** The frame the timestamps of the current command encoder belong to. */
|
|
20
22
|
private __encoderFrame?;
|
|
21
23
|
private __currentFrame?;
|
|
22
24
|
private __readbacksToMap;
|
|
23
25
|
private __lastGpuTimeMilliseconds?;
|
|
26
|
+
private __lastPassGpuTimesMilliseconds?;
|
|
24
27
|
constructor(device: GPUDevice);
|
|
25
28
|
/** Whether the device supports timestamp queries. */
|
|
26
29
|
get isSupported(): boolean;
|
|
27
30
|
/** The GPU time of the latest measured frame in milliseconds, or undefined if none is available yet. */
|
|
28
31
|
get lastGpuTimeMilliseconds(): number | undefined;
|
|
29
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The GPU time of each pass of the latest measured frame in milliseconds, keyed by the pass label.
|
|
34
|
+
* Undefined until a complete frame is available.
|
|
35
|
+
*/
|
|
36
|
+
get lastPassGpuTimesMilliseconds(): ReadonlyMap<string, number> | undefined;
|
|
37
|
+
/** Starts measuring the render and compute passes begun from now on. */
|
|
30
38
|
beginFrame(): void;
|
|
31
39
|
/** Stops measuring. The frame's time is published once all of its timestamps have been read back. */
|
|
32
40
|
endFrame(): void;
|
|
33
41
|
/**
|
|
34
|
-
* Returns the timestamp writes to set on a render pass descriptor, or undefined when the
|
|
35
|
-
* measured (outside a frame, or when the query set is full).
|
|
42
|
+
* Returns the timestamp writes to set on a render or compute pass descriptor, or undefined when the
|
|
43
|
+
* pass is not measured (outside a frame, or when the query set is full).
|
|
44
|
+
*
|
|
45
|
+
* @param label - The label of the pass, used to report its duration in
|
|
46
|
+
* {@link WebGpuGpuTimer.lastPassGpuTimesMilliseconds}. Passes with the same label are summed.
|
|
36
47
|
*/
|
|
37
|
-
getTimestampWrites(): GPURenderPassTimestampWrites | undefined;
|
|
48
|
+
getTimestampWrites(label: string): GPURenderPassTimestampWrites | undefined;
|
|
38
49
|
/**
|
|
39
50
|
* Encodes the resolve of the timestamps written by the passes of `encoder`.
|
|
40
51
|
* Call this before finishing the encoder, and call afterSubmit() after submitting it.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LightClusterGpuBuildParams } from '../foundation/renderer/lightCluster/LightClusterSystem';
|
|
2
|
+
import type { WebGpuGpuTimer } from './WebGpuGpuTimer';
|
|
3
|
+
/**
|
|
4
|
+
* Builds the light cluster tables of Clustered Forward rendering with compute shaders.
|
|
5
|
+
* The tables are written into the storage buffer of the GPU instance data, where the CPU build would write them.
|
|
6
|
+
*
|
|
7
|
+
* The sorted light input of the views (spheres, entries and Z slice ranges) is uploaded to a separate storage buffer,
|
|
8
|
+
* because it is small (some tens of KiB) and reused for all views.
|
|
9
|
+
*/
|
|
10
|
+
export declare class WebGpuLightClusterBuilder {
|
|
11
|
+
private __device;
|
|
12
|
+
private __bindGroupLayout;
|
|
13
|
+
private __pipeline;
|
|
14
|
+
private __paramsBuffer?;
|
|
15
|
+
private __paramsStride;
|
|
16
|
+
private __paramsCapacity;
|
|
17
|
+
private __paramsArray;
|
|
18
|
+
private __buildDataBuffer?;
|
|
19
|
+
private __buildDataCapacity;
|
|
20
|
+
private __bindGroup?;
|
|
21
|
+
private __bindGroupStorageBuffer?;
|
|
22
|
+
constructor(device: GPUDevice);
|
|
23
|
+
/**
|
|
24
|
+
* Builds the clusters of the views and submits the work immediately, so that it runs after the upload of the
|
|
25
|
+
* GPU instance data (queue.writeBuffer) and before the render commands of the frame.
|
|
26
|
+
*
|
|
27
|
+
* @param storageBuffer - The storage buffer of the GPU instance data
|
|
28
|
+
* @param params - The views to build and their sorted light input
|
|
29
|
+
* @param gpuTimer - When set (and a frame is being measured), measures the build as the
|
|
30
|
+
* 'LightClusterBuild' pass
|
|
31
|
+
*/
|
|
32
|
+
build(storageBuffer: GPUBuffer, params: LightClusterGpuBuildParams, gpuTimer?: WebGpuGpuTimer): void;
|
|
33
|
+
/**
|
|
34
|
+
* Releases the GPU resources.
|
|
35
|
+
*/
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
@@ -92,6 +92,8 @@ export declare class WebGpuResourceRepository extends CGAPIResourceRepository im
|
|
|
92
92
|
/** Cached `gpuDevice.queue` ([SameObject]), read on every frame by flush(). */
|
|
93
93
|
private __gpuQueue?;
|
|
94
94
|
private __renderBundles;
|
|
95
|
+
/** Fragment module of the depth prepass pipelines (it writes nothing; the color targets use writeMask 0). */
|
|
96
|
+
private __depthOnlyFragmentModule?;
|
|
95
97
|
private __renderBundleEncoder?;
|
|
96
98
|
private __renderBundleEncoderKey?;
|
|
97
99
|
private __systemDepthTexture?;
|
|
@@ -476,8 +478,13 @@ export declare class WebGpuResourceRepository extends CGAPIResourceRepository im
|
|
|
476
478
|
* @param renderPass - The render pass defining render targets and clear operations
|
|
477
479
|
* @param cameraId - Identifier for the camera used for rendering
|
|
478
480
|
* @param zWrite - Whether to enable depth writing during rendering
|
|
481
|
+
* @param options - `depthOnly` draws the primitive with a depth-only pipeline (the depth prepass);
|
|
482
|
+
* `allowEqualDepth` lets the color pass pass the depth written by the prepass
|
|
479
483
|
*/
|
|
480
|
-
draw(engine: Engine, primitive: Primitive, material: Material, renderPass: RenderPass, cameraId: number, zWrite: boolean, _displayIdx: number
|
|
484
|
+
draw(engine: Engine, primitive: Primitive, material: Material, renderPass: RenderPass, cameraId: number, zWrite: boolean, _displayIdx: number, options?: {
|
|
485
|
+
depthOnly?: boolean;
|
|
486
|
+
allowEqualDepth?: boolean;
|
|
487
|
+
}): void;
|
|
481
488
|
/**
|
|
482
489
|
* Creates a render bundle encoder for efficient rendering.
|
|
483
490
|
* Render bundles allow pre-recording of rendering commands for better performance.
|
|
@@ -575,7 +582,11 @@ export declare class WebGpuResourceRepository extends CGAPIResourceRepository im
|
|
|
575
582
|
finishRenderBundleEncoderAndKeepRenderPass(engine: Engine, renderPass: RenderPass, displayIdx: number): GPURenderPassEncoder | undefined;
|
|
576
583
|
getOrCreateRenderPassEncoderForExternalRendering(engine: Engine, renderPass: RenderPass, displayIdx: number): GPURenderPassEncoder | undefined;
|
|
577
584
|
endRenderPassEncoderForExternalRendering(): void;
|
|
578
|
-
|
|
585
|
+
private __getDepthOnlyFragmentModule;
|
|
586
|
+
getOrCreateRenderPipeline(renderPipelineId: string, pipelineLayoutKey: string, pipelineLayout: GPUPipelineLayout, primitive: Primitive, material: Material, renderPass: RenderPass, zWrite: boolean, options?: {
|
|
587
|
+
depthOnly?: boolean;
|
|
588
|
+
allowEqualDepth?: boolean;
|
|
589
|
+
}): [GPURenderPipeline, boolean];
|
|
579
590
|
/**
|
|
580
591
|
* Submits all recorded commands to the GPU queue and resets the command encoder.
|
|
581
592
|
* This method must be called to execute any recorded rendering commands.
|
|
@@ -633,7 +644,21 @@ export declare class WebGpuResourceRepository extends CGAPIResourceRepository im
|
|
|
633
644
|
* @param storageBufferHandle - Handle to the storage buffer to update
|
|
634
645
|
* @param gpuInstanceDataBuffers - New data to write to the buffer
|
|
635
646
|
*/
|
|
636
|
-
updateStorageBuffer(storageBufferHandle: WebGPUResourceHandle, gpuInstanceDataBuffers: Buffer[]): void;
|
|
647
|
+
updateStorageBuffer(storageBufferHandle: WebGPUResourceHandle, gpuInstanceDataBuffers: Buffer[], excludedByteRanges?: readonly [number, number][]): void;
|
|
648
|
+
/**
|
|
649
|
+
* Writes byte ranges of the GPU instance data to the storage buffer.
|
|
650
|
+
*
|
|
651
|
+
* @param storageBufferHandle - Handle to the storage buffer
|
|
652
|
+
* @param gpuInstanceDataBuffers - The GPU instance data buffers (layers)
|
|
653
|
+
* @param byteRanges - The ranges `[start, end)` in the concatenated layers. A range must not span layers.
|
|
654
|
+
*/
|
|
655
|
+
updateStorageBufferRanges(storageBufferHandle: WebGPUResourceHandle, gpuInstanceDataBuffers: Buffer[], byteRanges: readonly [number, number][]): void;
|
|
656
|
+
/**
|
|
657
|
+
* The storage buffer of the GPU instance data (bound at group 0, binding 0 of the render pipelines).
|
|
658
|
+
*
|
|
659
|
+
* @internal
|
|
660
|
+
*/
|
|
661
|
+
_getStorageBuffer(): GPUBuffer | undefined;
|
|
637
662
|
destroyStorageBuffer(storageBufferHandle: WebGPUResourceHandle): void;
|
|
638
663
|
/**
|
|
639
664
|
* Updates a portion of a storage buffer with new data at a specific offset.
|
|
@@ -32,6 +32,10 @@ export declare class WebGpuStrategyBasic implements CGAPIStrategy {
|
|
|
32
32
|
private __uniformMorphOffsetsTypedArray?;
|
|
33
33
|
private __uniformMorphWeightsTypedArray?;
|
|
34
34
|
private __lastMaterialsUpdateCount;
|
|
35
|
+
private __lastLightClusterDataVersion;
|
|
36
|
+
private __lastLightComponentsUpdateCount;
|
|
37
|
+
private __lightClusterBuilder?;
|
|
38
|
+
private __lastLightClusterBuildDataVersion;
|
|
35
39
|
private __lastTransformComponentsUpdateCount;
|
|
36
40
|
private __lastSceneGraphComponentsUpdateCount;
|
|
37
41
|
private __lastCameraComponentsUpdateCount;
|
|
@@ -157,6 +161,11 @@ export declare class WebGpuStrategyBasic implements CGAPIStrategy {
|
|
|
157
161
|
* @param renderPass - The render pass containing the material and rendering configuration
|
|
158
162
|
*/
|
|
159
163
|
private __renderWithoutBuffers;
|
|
164
|
+
/**
|
|
165
|
+
* Whether the depth prepass can run for the render pass: it must be enabled, draw the scene itself (render passes
|
|
166
|
+
* with a material override such as shadow maps and post effects are excluded), and write depth.
|
|
167
|
+
*/
|
|
168
|
+
private __isDepthPrepassAvailable;
|
|
160
169
|
/**
|
|
161
170
|
* Renders a single primitive with the specified material and render settings.
|
|
162
171
|
* Handles shader setup, uniform buffer updates, and the actual draw call.
|
|
@@ -167,13 +176,21 @@ export declare class WebGpuStrategyBasic implements CGAPIStrategy {
|
|
|
167
176
|
* @param displayIdx - The index of the display to render to
|
|
168
177
|
* @returns True if the primitive was successfully rendered
|
|
169
178
|
*/
|
|
170
|
-
renderInner(primitiveUid: PrimitiveUID, renderPass: RenderPass, zWrite: boolean, displayIdx: Index
|
|
179
|
+
renderInner(primitiveUid: PrimitiveUID, renderPass: RenderPass, zWrite: boolean, displayIdx: Index, options?: {
|
|
180
|
+
depthOnly?: boolean;
|
|
181
|
+
allowEqualDepth?: boolean;
|
|
182
|
+
}): boolean;
|
|
171
183
|
/**
|
|
172
184
|
* Creates or updates the main storage buffer containing all GPU instance data.
|
|
173
185
|
* This buffer holds transform matrices, material properties, and other per-instance data
|
|
174
186
|
* required for rendering all objects in the scene.
|
|
175
187
|
*/
|
|
176
188
|
private __createAndUpdateStorageBuffer;
|
|
189
|
+
/**
|
|
190
|
+
* Builds the Clustered Forward light cluster tables with compute shaders when the LightClusterSystem
|
|
191
|
+
* builds them on the GPU. It must run after every upload of the GPU instance data, which overwrites the tables.
|
|
192
|
+
*/
|
|
193
|
+
private __buildLightClustersOnGpu;
|
|
177
194
|
/**
|
|
178
195
|
* Creates or updates the storage buffer containing blend shape vertex data.
|
|
179
196
|
* This buffer holds morph target positions and other vertex attributes needed for blend shape animation.
|
|
@@ -8,6 +8,7 @@ import type { ICameraEntity } from '../../helpers/EntityHelper';
|
|
|
8
8
|
import { Matrix44 } from '../../math/Matrix44';
|
|
9
9
|
import { MutableMatrix44 } from '../../math/MutableMatrix44';
|
|
10
10
|
import { MutableVector3 } from '../../math/MutableVector3';
|
|
11
|
+
import { MutableVector4 } from '../../math/MutableVector4';
|
|
11
12
|
import { Vector3 } from '../../math/Vector3';
|
|
12
13
|
import { Vector4 } from '../../math/Vector4';
|
|
13
14
|
import type { Engine } from '../../system/Engine';
|
|
@@ -39,6 +40,7 @@ export declare class CameraComponent extends Component {
|
|
|
39
40
|
private _projectionMatrix;
|
|
40
41
|
private _viewMatrix;
|
|
41
42
|
private _viewPosition;
|
|
43
|
+
private _lightClusterViewInfo;
|
|
42
44
|
private static __currentMap;
|
|
43
45
|
private static returnVector3;
|
|
44
46
|
private static __tmpVector3_0;
|
|
@@ -486,6 +488,19 @@ export declare class CameraComponent extends Component {
|
|
|
486
488
|
* @param projectionMatrix - The projection matrix to set
|
|
487
489
|
*/
|
|
488
490
|
set projectionMatrix(projectionMatrix: Matrix44);
|
|
491
|
+
/**
|
|
492
|
+
* The projection matrix that is uploaded to the GPU (in XR mode, the matrix of the eye copied in $logic).
|
|
493
|
+
*
|
|
494
|
+
* @internal
|
|
495
|
+
*/
|
|
496
|
+
get _projectionMatrixForGpu(): Matrix44;
|
|
497
|
+
/**
|
|
498
|
+
* The light cluster view info uploaded to the GPU.
|
|
499
|
+
* x: the vec4 index of the light cluster view region of this camera (-1: none).
|
|
500
|
+
*
|
|
501
|
+
* @internal
|
|
502
|
+
*/
|
|
503
|
+
get _lightClusterViewInfoForGpu(): MutableVector4;
|
|
489
504
|
/**
|
|
490
505
|
* Gets the combined view-projection matrix.
|
|
491
506
|
*
|
|
@@ -2,7 +2,9 @@ import type { ComponentSID, ComponentTID, EntityUID } from '../../../types/Commo
|
|
|
2
2
|
import { Component } from '../../core/Component';
|
|
3
3
|
import type { IEntity } from '../../core/Entity';
|
|
4
4
|
import { type EntityRepository } from '../../core/EntityRepository';
|
|
5
|
+
import { type LightTypeEnum } from '../../definitions/LightType';
|
|
5
6
|
import type { ILightEntity } from '../../helpers/EntityHelper';
|
|
7
|
+
import { MutableVector4 } from '../../math/MutableVector4';
|
|
6
8
|
import { Vector3 } from '../../math/Vector3';
|
|
7
9
|
import type { Engine } from '../../system/Engine';
|
|
8
10
|
import type { ComponentToComponentMethods } from '../ComponentTypes';
|
|
@@ -13,15 +15,17 @@ import type { ComponentToComponentMethods } from '../ComponentTypes';
|
|
|
13
15
|
* the light looks towards the local -Z axis in right hand coordinate system.
|
|
14
16
|
*/
|
|
15
17
|
export declare class LightComponent extends Component {
|
|
16
|
-
|
|
18
|
+
private __type;
|
|
17
19
|
private __color;
|
|
20
|
+
/** The components of the color at the last change, to detect changes of a mutated color object. */
|
|
21
|
+
private __lastColor;
|
|
18
22
|
private __intensity;
|
|
19
23
|
private readonly __initialDirection;
|
|
20
24
|
private __direction;
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
private __innerConeAngle;
|
|
26
|
+
private __outerConeAngle;
|
|
23
27
|
private __range;
|
|
24
|
-
|
|
28
|
+
private __enable;
|
|
25
29
|
private __shadowAreaSizeForDirectionalLight;
|
|
26
30
|
private __shadowZNearForDirectionalLight;
|
|
27
31
|
private __shadowCameraOffsetForDirectionalLight;
|
|
@@ -32,9 +36,14 @@ export declare class LightComponent extends Component {
|
|
|
32
36
|
private _lightProperty;
|
|
33
37
|
private static __lightNumber;
|
|
34
38
|
private __lightGizmo?;
|
|
39
|
+
/** The shadow slot assigned by a ShadowSystem. `undefined` means the default slot (see `_shadowSlot`). */
|
|
40
|
+
private __shadowSlot;
|
|
35
41
|
private __updateCount;
|
|
36
42
|
private __lastUpdateCount;
|
|
37
43
|
private __lastTransformUpdateCount;
|
|
44
|
+
private __lastRangeScale;
|
|
45
|
+
/** The number of changes of all light components, per engine. */
|
|
46
|
+
private static __updateCountMap;
|
|
38
47
|
/**
|
|
39
48
|
* Creates a new LightComponent instance.
|
|
40
49
|
*
|
|
@@ -45,6 +54,56 @@ export declare class LightComponent extends Component {
|
|
|
45
54
|
* @param isReUse - Whether this component is being reused from a pool
|
|
46
55
|
*/
|
|
47
56
|
constructor(engine: Engine, entityUid: EntityUID, componentSid: ComponentSID, entityRepository: EntityRepository, isReUse: boolean);
|
|
57
|
+
/**
|
|
58
|
+
* Gets the number of changes of all light components of the engine (creation, destruction and property changes).
|
|
59
|
+
* The engine and the rendering strategies use it to process and upload the light data only when it changed.
|
|
60
|
+
*
|
|
61
|
+
* @param engine - The engine instance
|
|
62
|
+
* @returns The update count
|
|
63
|
+
*/
|
|
64
|
+
static getUpdateCount(engine: Engine): number;
|
|
65
|
+
private static __incrementUpdateCount;
|
|
66
|
+
/**
|
|
67
|
+
* Cleans up the static data of the engine.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
static _cleanupForEngine(engine: Engine): void;
|
|
71
|
+
/**
|
|
72
|
+
* Records a change of a property, so that the light data is recomputed and uploaded.
|
|
73
|
+
*/
|
|
74
|
+
private __markUpdated;
|
|
75
|
+
/**
|
|
76
|
+
* Gets the type of the light.
|
|
77
|
+
*/
|
|
78
|
+
get type(): LightTypeEnum;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the type of the light.
|
|
81
|
+
*/
|
|
82
|
+
set type(value: LightTypeEnum);
|
|
83
|
+
/**
|
|
84
|
+
* Gets whether the light is enabled.
|
|
85
|
+
*/
|
|
86
|
+
get enable(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Sets whether the light is enabled. A disabled light does not light anything.
|
|
89
|
+
*/
|
|
90
|
+
set enable(value: boolean);
|
|
91
|
+
/**
|
|
92
|
+
* Gets the inner cone angle of the spot light (in radian).
|
|
93
|
+
*/
|
|
94
|
+
get innerConeAngle(): number;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the inner cone angle of the spot light (in radian).
|
|
97
|
+
*/
|
|
98
|
+
set innerConeAngle(value: number);
|
|
99
|
+
/**
|
|
100
|
+
* Gets the outer cone angle of the spot light (in radian).
|
|
101
|
+
*/
|
|
102
|
+
get outerConeAngle(): number;
|
|
103
|
+
/**
|
|
104
|
+
* Sets the outer cone angle of the spot light (in radian).
|
|
105
|
+
*/
|
|
106
|
+
set outerConeAngle(value: number);
|
|
48
107
|
/**
|
|
49
108
|
* Gets the component type identifier for LightComponent.
|
|
50
109
|
*
|
|
@@ -144,6 +203,48 @@ export declare class LightComponent extends Component {
|
|
|
144
203
|
* @returns The RGB color vector
|
|
145
204
|
*/
|
|
146
205
|
get color(): Vector3;
|
|
206
|
+
/**
|
|
207
|
+
* The index of the shadow data of this light in the per-material shadow arrays
|
|
208
|
+
* (`depthTextureIndexList` and `depthBiasPV`), or -1 when the light has no shadow data.
|
|
209
|
+
*
|
|
210
|
+
* @remarks
|
|
211
|
+
* A ShadowSystem assigns the slots of the lights it manages. Otherwise the slot is the component SID
|
|
212
|
+
* when it is below `Config.maxLightNumber`, which is the convention of manual shadow map setups.
|
|
213
|
+
*
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
get _shadowSlot(): number;
|
|
217
|
+
/**
|
|
218
|
+
* Sets the shadow slot of this light. `undefined` restores the default slot.
|
|
219
|
+
*
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
222
|
+
set _shadowSlot(slot: number | undefined);
|
|
223
|
+
/**
|
|
224
|
+
* The world position of the light as uploaded to the GPU (updated in $logic).
|
|
225
|
+
*
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
get _lightPositionForGpu(): MutableVector4;
|
|
229
|
+
/**
|
|
230
|
+
* The world direction of the light as uploaded to the GPU (updated in $logic).
|
|
231
|
+
*
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
234
|
+
get _lightDirectionForGpu(): MutableVector4;
|
|
235
|
+
/**
|
|
236
|
+
* The light property (type, effective range, cos of the inner and outer cone angles) as uploaded to the GPU
|
|
237
|
+
* (updated in $logic).
|
|
238
|
+
*
|
|
239
|
+
* @internal
|
|
240
|
+
*/
|
|
241
|
+
get _lightPropertyForGpu(): MutableVector4;
|
|
242
|
+
/**
|
|
243
|
+
* The intensity of the light (color * intensity) as uploaded to the GPU (updated in $logic).
|
|
244
|
+
*
|
|
245
|
+
* @internal
|
|
246
|
+
*/
|
|
247
|
+
get _lightIntensityForGpu(): MutableVector4;
|
|
147
248
|
/**
|
|
148
249
|
* Gets the up vector for the light in local space.
|
|
149
250
|
* This is used for light orientation calculations.
|
|
@@ -195,6 +296,17 @@ export declare class LightComponent extends Component {
|
|
|
195
296
|
* to avoid unnecessary recalculations when nothing has changed.
|
|
196
297
|
*/
|
|
197
298
|
$logic(): void;
|
|
299
|
+
/**
|
|
300
|
+
* Returns the intensity factor that compensates the shortened range. The factors are the measured brightness
|
|
301
|
+
* balance of the Sponza scene: 0.9 -> 1.16 and 0.8 -> 1.35. Values in between interpolate; below 0.8 the last
|
|
302
|
+
* slope continues. A constant factor compensates the range window approximately, not exactly.
|
|
303
|
+
*/
|
|
304
|
+
private static __getIntensityScale;
|
|
305
|
+
/**
|
|
306
|
+
* Returns the range used for shading. Point and spot lights without a range get an automatic range
|
|
307
|
+
* when `Config.lightAutoRangeThreshold` is greater than 0.
|
|
308
|
+
*/
|
|
309
|
+
private __getEffectiveRange;
|
|
198
310
|
/**
|
|
199
311
|
* Cleans up the light component when it's being destroyed.
|
|
200
312
|
* Resets the light intensity values in the global data arrays.
|
|
@@ -55,6 +55,8 @@ export declare class SceneGraphComponent extends Component {
|
|
|
55
55
|
private __rotationGizmo?;
|
|
56
56
|
private __scaleGizmo?;
|
|
57
57
|
private __jointGizmo?;
|
|
58
|
+
/** True when any gizmo of this node has been set up: skips the per-frame gizmo checks of plain nodes. */
|
|
59
|
+
private __hasGizmos;
|
|
58
60
|
private __transformGizmoSpace;
|
|
59
61
|
private __latestPrimitivePositionAccessorVersion;
|
|
60
62
|
toMakeWorldMatrixTheSameAsLocalMatrix: boolean;
|