@babylonjs/lite-compat 1.20.0-preview → 1.22.0-preview
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 +1 -1
- package/index.d.ts +78 -2
- package/index.js +250 -13
- package/index.js.map +1 -1
- package/{meshes-eNVvq5sm.js → meshes-CidWpEh8.js} +6 -6
- package/meshes-CidWpEh8.js.map +1 -0
- package/navigation.js +1 -1
- package/package.json +4 -4
- package/meshes-eNVvq5sm.js.map +0 -1
package/README.md
CHANGED
|
@@ -121,7 +121,7 @@ overloads within a supported area may still be absent.
|
|
|
121
121
|
| Engine (`WebGPUEngine`, `Engine`, `ThinEngine`, `NullEngine`) | ⚡ | async startup + render loop; `beginFrame`/`endFrame`, MSAA/alpha-to-coverage (`currentSampleCount`/`get`/`setAlphaToCoverage`), and manual `scene.render()` unsupported |
|
|
122
122
|
| Scene (clear color, cameras/lights, fog, environment, observables, ready state) | ⚡ | sync `scene.pick` unsupported (use async `GPUPicker`); `scene.meshes` + `getMeshBy*`/`getNodeBy*` now enumerate every mesh via a canonical wrapper registry |
|
|
123
123
|
| Cameras (`ArcRotateCamera`, `FreeCamera`/`Universal`/`Target`, `FollowCamera`, `GeospatialCamera`) | ✅ | XR / device-orientation / stereoscopic rigs unsupported |
|
|
124
|
-
| Lights (`Hemispheric`, `Directional`, `Point`, `Spot`) | ✅ | `
|
|
124
|
+
| Lights (`Hemispheric`, `Directional`, `Point`, `Spot`) | ✅ | `ClusteredLightContainer` clusters point lights (⚡ partial); `RectAreaLight` unsupported |
|
|
125
125
|
| Shadows (`ShadowGenerator` directional ESM/PCF, spot PCF) | ⚡ | `CascadedShadowGenerator` falls back to single cascade |
|
|
126
126
|
| Meshes & geometry (class chain, `MeshBuilder` primitives, transforms, thin instances, `clone`, `VertexData`, `Mesh.MergeMeshes`) | ⚡ | `CreateLines`/`CreateLineSystem` support fixed-topology line lists and RGBA point colors; `CreateDashedLines` supports uniform-color dashed line lists; `MergeMeshes` bakes positions/normals/UVs and rejects unsupported attributes/animation; `CreateDecal`/`CreateText`/`CreateTiledBox`/`CreateTiledPlane`, `GreasedLine*` (thick lines), `InstancedMesh`, LOD/edges/outline, hardware instances unsupported |
|
|
127
127
|
| CSG / CSG2 | ✅ | over Lite boolean ops |
|
package/index.d.ts
CHANGED
|
@@ -1179,8 +1179,62 @@ export declare class CircleEase extends EasingFunction {
|
|
|
1179
1179
|
easeInCore(gradient: number): number;
|
|
1180
1180
|
}
|
|
1181
1181
|
|
|
1182
|
-
|
|
1183
|
-
|
|
1182
|
+
/**
|
|
1183
|
+
* Babylon.js `ClusteredLightContainer` — a `Light` that renders a large set of
|
|
1184
|
+
* point lights through a clustered / forward+ system.
|
|
1185
|
+
*/
|
|
1186
|
+
export declare class ClusteredLightContainer extends Light {
|
|
1184
1187
|
private _maxRange;
|
|
1188
|
+
private _selfIntensity;
|
|
1189
|
+
/**
|
|
1190
|
+
* True if a point/spot light can be clustered by this container. Babylon Lite
|
|
1191
|
+
* clusters point lights only.
|
|
1192
|
+
*/
|
|
1193
|
+
static IsLightSupported(light: Light): boolean;
|
|
1194
|
+
/**
|
|
1195
|
+
* Creates a new clustered light container.
|
|
1196
|
+
*
|
|
1197
|
+
* @param name - The container's node name.
|
|
1198
|
+
* @param lights - Initial lights to cluster (point lights).
|
|
1199
|
+
* @param scene - Owning scene; when supplied the container is registered and
|
|
1200
|
+
* built into the Lite scene at engine start.
|
|
1201
|
+
*/
|
|
1202
|
+
constructor(name: string, lights?: Light[], scene?: Scene);
|
|
1203
|
+
getClassName(): string;
|
|
1204
|
+
/** Babylon.js `light.getTypeID()` — `LIGHTTYPEID_CLUSTERED_CONTAINER`. */
|
|
1205
|
+
getTypeID(): number;
|
|
1206
|
+
/** True when clustered lighting is available (Babylon Lite backs it on WebGPU). */
|
|
1207
|
+
get isSupported(): boolean;
|
|
1208
|
+
/** The lights added to this clustering system. */
|
|
1209
|
+
get lights(): readonly Light[];
|
|
1210
|
+
/** Number of cluster tiles across the screen horizontally (default `64`). */
|
|
1211
|
+
get horizontalTiles(): number;
|
|
1212
|
+
set horizontalTiles(value: number);
|
|
1213
|
+
/** Number of cluster tiles across the screen vertically (default `64`). */
|
|
1214
|
+
get verticalTiles(): number;
|
|
1215
|
+
set verticalTiles(value: number);
|
|
1216
|
+
/** Number of depth slices used to bin lights along view-space Z (default `16`). */
|
|
1217
|
+
get depthSlices(): number;
|
|
1218
|
+
set depthSlices(value: number);
|
|
1219
|
+
/**
|
|
1220
|
+
* Upper bound applied to clustered light ranges. Babylon Lite manages range
|
|
1221
|
+
* binning internally, so this is stored for API-shape parity and does not
|
|
1222
|
+
* re-cluster the lights.
|
|
1223
|
+
*/
|
|
1224
|
+
get maxRange(): number;
|
|
1225
|
+
set maxRange(value: number);
|
|
1226
|
+
/** Babylon.js `container.addLight(light)`. Only point lights are clustered. */
|
|
1227
|
+
addLight(light: Light): void;
|
|
1228
|
+
/**
|
|
1229
|
+
* Babylon.js `container.removeLight(light)`. Returns the index the light held
|
|
1230
|
+
* in the container's light list, or `-1` if it was not present.
|
|
1231
|
+
*/
|
|
1232
|
+
removeLight(light: Light): number;
|
|
1185
1233
|
/** Container-level intensity (Babylon.js inherits it from `Light`; each child light carries its own). */
|
|
1234
|
+
get intensity(): number;
|
|
1235
|
+
set intensity(value: number);
|
|
1236
|
+
/** Clustered lights do not cast shadows in Babylon.js; the toggle is a no-op. */
|
|
1237
|
+
set shadowEnabled(_enabled: boolean);
|
|
1238
|
+
protected _onEffectiveEnabledStateChanged(_enabled: boolean): void;
|
|
1239
|
+
dispose(): void;
|
|
1186
1240
|
}
|
|
1187
1241
|
|
|
1188
1242
|
/**
|
|
@@ -2007,6 +2061,19 @@ declare interface GroundOptions {
|
|
|
2007
2061
|
subdivisions?: number;
|
|
2008
2062
|
}
|
|
2009
2063
|
|
|
2064
|
+
/**
|
|
2065
|
+
* Namespace-like object used to manipulate GUIDs, matching Babylon.js `GUID`.
|
|
2066
|
+
* Babylon.js declares `GUID` as a `const` object literal rather than a class, so the
|
|
2067
|
+
* compat layer mirrors that shape: consumers call `GUID.RandomId()` without `new`.
|
|
2068
|
+
*/
|
|
2069
|
+
export declare const GUID: {
|
|
2070
|
+
/**
|
|
2071
|
+
* Generate a pseudo-random RFC4122 v4 UUID. Alias of {@link RandomGUID}.
|
|
2072
|
+
* @returns a pseudo random id
|
|
2073
|
+
*/
|
|
2074
|
+
RandomId: typeof RandomGUID;
|
|
2075
|
+
};
|
|
2076
|
+
|
|
2010
2077
|
export declare class HandConstraintBehavior {
|
|
2011
2078
|
constructor();
|
|
2012
2079
|
}
|
|
@@ -3614,6 +3681,15 @@ export declare class QuinticEase extends EasingFunction {
|
|
|
3614
3681
|
easeInCore(gradient: number): number;
|
|
3615
3682
|
}
|
|
3616
3683
|
|
|
3684
|
+
/** Babylon.js-compatible GUID helpers (`@babylonjs/core` `Misc/guid`). */
|
|
3685
|
+
/**
|
|
3686
|
+
* Generate a pseudo-random RFC4122 v4 UUID, matching Babylon.js `RandomGUID`.
|
|
3687
|
+
* Be aware `Math.random()` could cause collisions, but all except 6 of the 128 bits are
|
|
3688
|
+
* randomly generated, so any two ids have a 1 in 2^122 chance of colliding.
|
|
3689
|
+
* @returns a pseudo random id
|
|
3690
|
+
*/
|
|
3691
|
+
export declare function RandomGUID(): string;
|
|
3692
|
+
|
|
3617
3693
|
/**
|
|
3618
3694
|
* Babylon.js `RawTexture` — a texture created from raw pixel bytes. Backed by
|
|
3619
3695
|
* Babylon Lite's `createTexture2DFromPixels`; the GPU handle is available
|
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { V as Vector3, u as unsupported, L as LiteCompatError, N as Node, M as Matrix, C as Color3, S as StandardMaterial, a as Color4, b as Mesh, T as TransformNode, l as liteBackedVector3, Q as Quaternion } from "./meshes-
|
|
5
|
-
import { A, B, c, d, e, f, g, h, i, j, k, m, n, o, p, q, G, I, r, s, t, P, v, w, x, y, z, D, E, F, H, J, K, O, R } from "./meshes-
|
|
6
|
-
import { VERSION, createEngine, onBeforeRender, stopEngine, resizeEngine, setEngineSize, disposeEngine, uploadImageToArrayLayer, enableMirroredMeshes, registerSceneWithShadowSupport, registerScene, startEngine, createNullEngine, stepScene, setPhysicsTimestep, setPhysicsGravity, disposePhysics, createHavokWorld, createArcRotateCamera, attachControl, getCameraPosition, getViewMatrix, getProjectionMatrix, createGeospatialCamera, setGeospatialOrientation, attachGeospatialControls, createFreeCamera, attachFreeControl, setAnimationAdditive, playAnimation, pauseAnimation, goToFrame, stopAnimation, createSceneContext, updateAnimationManager, setFog, setClipPlane, loadHdrEnvironment, loadDdsEnvironment, loadEnvironment, createDefaultCamera, addToScene, createHemisphericLight, createAnimationManager, enableAnimationBlending, addAnimationGroup, disposeScene, createDirectionalLight, createPointLight, createSpotLight, createCsgFromMesh, csgSubtract, csgIntersect, csgUnion, createMeshFromCsg, createCsg2FromMesh, csg2Subtract, csg2Intersect, csg2Add, createMeshesFromCsg2, disposeCsg2, initializeCsg2Async, createMorphTargets, setMorphTargetWeights, createTransformNode, bakeCurrentTransformIntoVertices, loadSOG, loadSPZ, loadSplat, createDynamicTexture, updateDynamicTexture, createTexture2DFromPixels, updateTexture2DFromPixels, createTexture3DFromPixels, loadBasisTexture2D, loadKtxTexture2D, loadTexture2D, createTexture2DArrayFromUrls, createTexture2DArrayFromKtx2, loadImageToArrayLayer, createTexture2DArray, createTexture2DArrayFromPixels, updateTexture2DArrayFromPixels, loadBabylon, loadGltf, resetVariant, getVariantNames, selectVariant, disposePicker, createGpuPicker, pickAsync, createAxisDragGizmo, attachAxisDragGizmoToNode, disposeAxisDragGizmo, createAxisScaleGizmo, attachAxisScaleGizmoToNode, disposeAxisScaleGizmo, createBoundingBoxGizmo, attachBoundingBoxGizmoToNode, disposeBoundingBoxGizmo, createCameraGizmo, attachCameraGizmoToCamera, disposeCameraGizmo, createLightGizmo, attachLightGizmoToLight, disposeLightGizmo, createPlaneDragGizmo, attachPlaneDragGizmoToNode, disposePlaneDragGizmo, createPlaneRotationGizmo, attachPlaneRotationGizmoToNode, disposePlaneRotationGizmo, createPositionGizmo, setPositionGizmoLocalCoordinates, attachPositionGizmoToNode, disposePositionGizmo, createRotationGizmo, setRotationGizmoLocalCoordinates, attachRotationGizmoToNode, disposeRotationGizmo, createScaleGizmo, setScaleGizmoLocalCoordinates, attachScaleGizmoToNode, disposeScaleGizmo, createUtilityLayer, registerUtilityLayer, disposeUtilityLayer, addBillboardSpriteIndex, updateBillboardSpriteIndex, loadSpriteAtlas, createFacingBillboardSystem, addFacingBillboardSystem, billboardBlendAdditive, billboardBlendAlpha, spriteBlendPremultiplied, spriteBlendAdditive, spriteBlendAlpha, createSprite2DLayer, addSprite2DIndex, createSpriteRenderer, registerSpriteRenderer, updateSprite2DIndex, createPcfSpotlightShadowGenerator, createPcfDirectionalShadowGenerator, createEsmDirectionalShadowGenerator, setShadowTaskCasterMeshes, parseNodeMaterialFromSnippet, createGridMaterial, getByteFrequencyData, getFloatFrequencyData, getByteTimeDomainData, getFloatTimeDomainData, enableAnalyzer, setSpatialPosition, setSpatialOrientation, enableSpatial, setSpatialListenerPosition, setSpatialListener, updateSpatialAudio, enableStereo, setStereoPan, disposeAudioBus, setBusVolume, getMasterVolume, setMasterVolume, unlockAudioEngineAsync, createSoundAsync, createSoundBufferAsync, createStreamingSoundAsync, createAudioBusAsync, createSoundSourceAsync, createMicrophoneSoundSourceAsync, disposeAudioEngine, createAudioEngineAsync, disposeSoundSource, setSoundSourceVolume, playSound, pauseSound, resumeSound, stopSound, disposeSound, setSoundVolume, playStreamingSound, pauseStreamingSound, resumeStreamingSound, stopStreamingSound, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, disposeStreamingSound, setStreamingSoundVolume, startParticleSystem, animateParticleSystem, stopParticleSystem, createParticleBillboard, syncParticleBillboard, parseNodeParticleSetFromSnippet, registerNodeParticleSet } from "@babylonjs/lite";
|
|
4
|
+
import { V as Vector3, u as unsupported, L as LiteCompatError, N as Node, M as Matrix, C as Color3, S as StandardMaterial, a as Color4, b as Mesh, T as TransformNode, l as liteBackedVector3, Q as Quaternion } from "./meshes-CidWpEh8.js";
|
|
5
|
+
import { A, B, c, d, e, f, g, h, i, j, k, m, n, o, p, q, G, I, r, s, t, P, v, w, x, y, z, D, E, F, H, J, K, O, R } from "./meshes-CidWpEh8.js";
|
|
6
|
+
import { VERSION, createEngine, onBeforeRender, stopEngine, resizeEngine, setEngineSize, disposeEngine, uploadImageToArrayLayer, enableMirroredMeshes, registerSceneWithShadowSupport, registerScene, startEngine, createNullEngine, stepScene, setPhysicsTimestep, setPhysicsGravity, disposePhysics, createHavokWorld, createArcRotateCamera, attachControl, getCameraPosition, getViewMatrix, getProjectionMatrix, createGeospatialCamera, setGeospatialOrientation, attachGeospatialControls, createFreeCamera, attachFreeControl, setAnimationAdditive, playAnimation, pauseAnimation, goToFrame, stopAnimation, createSceneContext, updateAnimationManager, setFog, setClipPlane, loadHdrEnvironment, loadDdsEnvironment, loadEnvironment, createDefaultCamera, addToScene, createHemisphericLight, createAnimationManager, enableAnimationBlending, addAnimationGroup, disposeScene, createDirectionalLight, createPointLight, createSpotLight, createClusteredLightContainer, createClusteredPointLight, removeFromScene, addClusteredLightContainer, markClusteredLightContainerDirty, createCsgFromMesh, csgSubtract, csgIntersect, csgUnion, createMeshFromCsg, createCsg2FromMesh, csg2Subtract, csg2Intersect, csg2Add, createMeshesFromCsg2, disposeCsg2, initializeCsg2Async, createMorphTargets, setMorphTargetWeights, createTransformNode, bakeCurrentTransformIntoVertices, loadSOG, loadSPZ, loadSplat, createDynamicTexture, updateDynamicTexture, createTexture2DFromPixels, updateTexture2DFromPixels, createTexture3DFromPixels, loadBasisTexture2D, loadKtxTexture2D, loadTexture2D, createTexture2DArrayFromUrls, createTexture2DArrayFromKtx2, loadImageToArrayLayer, createTexture2DArray, createTexture2DArrayFromPixels, updateTexture2DArrayFromPixels, loadBabylon, loadGltf, resetVariant, getVariantNames, selectVariant, disposePicker, createGpuPicker, pickAsync, createAxisDragGizmo, attachAxisDragGizmoToNode, disposeAxisDragGizmo, createAxisScaleGizmo, attachAxisScaleGizmoToNode, disposeAxisScaleGizmo, createBoundingBoxGizmo, attachBoundingBoxGizmoToNode, disposeBoundingBoxGizmo, createCameraGizmo, attachCameraGizmoToCamera, disposeCameraGizmo, createLightGizmo, attachLightGizmoToLight, disposeLightGizmo, createPlaneDragGizmo, attachPlaneDragGizmoToNode, disposePlaneDragGizmo, createPlaneRotationGizmo, attachPlaneRotationGizmoToNode, disposePlaneRotationGizmo, createPositionGizmo, setPositionGizmoLocalCoordinates, attachPositionGizmoToNode, disposePositionGizmo, createRotationGizmo, setRotationGizmoLocalCoordinates, attachRotationGizmoToNode, disposeRotationGizmo, createScaleGizmo, setScaleGizmoLocalCoordinates, attachScaleGizmoToNode, disposeScaleGizmo, createUtilityLayer, registerUtilityLayer, disposeUtilityLayer, addBillboardSpriteIndex, updateBillboardSpriteIndex, loadSpriteAtlas, createFacingBillboardSystem, addFacingBillboardSystem, billboardBlendAdditive, billboardBlendAlpha, spriteBlendPremultiplied, spriteBlendAdditive, spriteBlendAlpha, createSprite2DLayer, addSprite2DIndex, createSpriteRenderer, registerSpriteRenderer, updateSprite2DIndex, createPcfSpotlightShadowGenerator, createPcfDirectionalShadowGenerator, createEsmDirectionalShadowGenerator, setShadowTaskCasterMeshes, parseNodeMaterialFromSnippet, createGridMaterial, getByteFrequencyData, getFloatFrequencyData, getByteTimeDomainData, getFloatTimeDomainData, enableAnalyzer, setSpatialPosition, setSpatialOrientation, enableSpatial, setSpatialListenerPosition, setSpatialListener, updateSpatialAudio, enableStereo, setStereoPan, disposeAudioBus, setBusVolume, getMasterVolume, setMasterVolume, unlockAudioEngineAsync, createSoundAsync, createSoundBufferAsync, createStreamingSoundAsync, createAudioBusAsync, createSoundSourceAsync, createMicrophoneSoundSourceAsync, disposeAudioEngine, createAudioEngineAsync, disposeSoundSource, setSoundSourceVolume, playSound, pauseSound, resumeSound, stopSound, disposeSound, setSoundVolume, playStreamingSound, pauseStreamingSound, resumeStreamingSound, stopStreamingSound, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, disposeStreamingSound, setStreamingSoundVolume, startParticleSystem, animateParticleSystem, stopParticleSystem, createParticleBillboard, syncParticleBillboard, parseNodeParticleSetFromSnippet, registerNodeParticleSet } from "@babylonjs/lite";
|
|
7
7
|
const Epsilon = 1e-3;
|
|
8
8
|
const ToRadians = Math.PI / 180;
|
|
9
9
|
const ToDegrees = 180 / Math.PI;
|
|
@@ -879,6 +879,7 @@ class AbstractEngine {
|
|
|
879
879
|
scene._bakeGroundUvs();
|
|
880
880
|
scene._flushPendingAdds();
|
|
881
881
|
scene._buildMorphTargets();
|
|
882
|
+
scene._buildClusteredContainers();
|
|
882
883
|
await scene._loadPendingEnvironment();
|
|
883
884
|
await enableMirroredMeshes(scene._lite);
|
|
884
885
|
if (scene._hasShadows()) {
|
|
@@ -2144,6 +2145,8 @@ const _Scene = class _Scene extends AbstractScene {
|
|
|
2144
2145
|
__publicField(this, "_nodeMaterials", []);
|
|
2145
2146
|
/** Babylon.js `scene.uniqueId` — a process-unique numeric id. */
|
|
2146
2147
|
__publicField(this, "uniqueId", ++_Scene._uidCounter);
|
|
2148
|
+
/** @internal Clustered light containers to register on the Lite scene at engine start. */
|
|
2149
|
+
__publicField(this, "_pendingClusteredContainers", []);
|
|
2147
2150
|
/** Babylon.js `scene.performancePriority` — accepted for parity; Babylon Lite tunes its own pipeline. */
|
|
2148
2151
|
__publicField(this, "performancePriority", 0);
|
|
2149
2152
|
/**
|
|
@@ -2318,6 +2321,33 @@ const _Scene = class _Scene extends AbstractScene {
|
|
|
2318
2321
|
}
|
|
2319
2322
|
this._pendingMorphBuilds.length = 0;
|
|
2320
2323
|
}
|
|
2324
|
+
/** @internal Register a compat `ClusteredLightContainer` to be wired into the scene at engine start. */
|
|
2325
|
+
_registerClusteredLightContainer(container) {
|
|
2326
|
+
this._pendingClusteredContainers.push(container);
|
|
2327
|
+
}
|
|
2328
|
+
/** @internal Drop a container from the pending list (it was disposed before engine start). */
|
|
2329
|
+
_unregisterClusteredLightContainer(container) {
|
|
2330
|
+
const i2 = this._pendingClusteredContainers.indexOf(container);
|
|
2331
|
+
if (i2 !== -1) {
|
|
2332
|
+
this._pendingClusteredContainers.splice(i2, 1);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
/**
|
|
2336
|
+
* @internal Register all clustered light containers on the Lite scene. Called by
|
|
2337
|
+
* the engine after meshes/materials are settled (clustered wiring reads the
|
|
2338
|
+
* scene's materials) and before `registerScene`. Containers disposed before this
|
|
2339
|
+
* point are skipped — registering one would build GPU state for an object the
|
|
2340
|
+
* caller has already thrown away. The list is drained up front so a container
|
|
2341
|
+
* disposed while another builds cannot perturb the iteration.
|
|
2342
|
+
*/
|
|
2343
|
+
_buildClusteredContainers() {
|
|
2344
|
+
const containers = this._pendingClusteredContainers.splice(0);
|
|
2345
|
+
for (const container of containers) {
|
|
2346
|
+
if (!container.isDisposed()) {
|
|
2347
|
+
container._build();
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2321
2351
|
/** @internal Whether any shadow generator is present (engine uses shadow-aware registration). */
|
|
2322
2352
|
_hasShadows() {
|
|
2323
2353
|
return this._shadowGenerators.length > 0;
|
|
@@ -2790,6 +2820,14 @@ let Scene = _Scene;
|
|
|
2790
2820
|
class Light extends Node {
|
|
2791
2821
|
constructor(name, scene) {
|
|
2792
2822
|
super(name, scene);
|
|
2823
|
+
/**
|
|
2824
|
+
* @internal The {@link ClusteredLightContainer} that owns this light, if any.
|
|
2825
|
+
* Babylon.js moves a light out of the normal light path when it is added to a
|
|
2826
|
+
* clustered container; this back-link mirrors BJS's `light._clusteredContainer`
|
|
2827
|
+
* so a light cannot be added to two containers. Typed loosely to avoid a cycle
|
|
2828
|
+
* with the container module.
|
|
2829
|
+
*/
|
|
2830
|
+
__publicField(this, "_clusteredContainer", null);
|
|
2793
2831
|
/**
|
|
2794
2832
|
* @internal When the light is effectively disabled, its Lite intensity is
|
|
2795
2833
|
* forced to `0` (zero contribution) and the caller-visible intensity is
|
|
@@ -3069,6 +3107,198 @@ class SpotLight extends Light {
|
|
|
3069
3107
|
writeColor(this._lite.specular, value);
|
|
3070
3108
|
}
|
|
3071
3109
|
}
|
|
3110
|
+
const LIGHTTYPEID_CLUSTERED_CONTAINER = 5;
|
|
3111
|
+
class ClusteredLightContainer extends Light {
|
|
3112
|
+
/**
|
|
3113
|
+
* Creates a new clustered light container.
|
|
3114
|
+
*
|
|
3115
|
+
* @param name - The container's node name.
|
|
3116
|
+
* @param lights - Initial lights to cluster (point lights).
|
|
3117
|
+
* @param scene - Owning scene; when supplied the container is registered and
|
|
3118
|
+
* built into the Lite scene at engine start.
|
|
3119
|
+
*/
|
|
3120
|
+
constructor(name, lights = [], scene) {
|
|
3121
|
+
super(name, scene);
|
|
3122
|
+
/**
|
|
3123
|
+
* @internal The underlying Babylon Lite clustered light container. The base
|
|
3124
|
+
* `Light._lite` is typed as `LightBase`, but a clustered container is a distinct
|
|
3125
|
+
* Lite object (not a punctual light); every base member that dereferences `_lite`
|
|
3126
|
+
* as a light is overridden below, so the value is only ever read back through
|
|
3127
|
+
* {@link _container}.
|
|
3128
|
+
*/
|
|
3129
|
+
__publicField(this, "_lite");
|
|
3130
|
+
/** @internal Point lights added to this container (Babylon.js `container.lights`). */
|
|
3131
|
+
__publicField(this, "_childLights", []);
|
|
3132
|
+
/** @internal Lite clustered point lights, parallel to {@link _childLights}. */
|
|
3133
|
+
__publicField(this, "_liteLights", []);
|
|
3134
|
+
/** @internal Whether the container has been registered on the Lite scene (engine start). */
|
|
3135
|
+
__publicField(this, "_built", false);
|
|
3136
|
+
__publicField(this, "_maxRange", 16383);
|
|
3137
|
+
__publicField(this, "_selfIntensity", 1);
|
|
3138
|
+
this._lite = createClusteredLightContainer();
|
|
3139
|
+
if (scene) {
|
|
3140
|
+
scene._registerClusteredLightContainer(this);
|
|
3141
|
+
}
|
|
3142
|
+
for (const light of lights) {
|
|
3143
|
+
this.addLight(light);
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
/** @internal Typed handle to the Lite clustered container held in {@link _lite}. */
|
|
3147
|
+
get _container() {
|
|
3148
|
+
return this._lite;
|
|
3149
|
+
}
|
|
3150
|
+
/**
|
|
3151
|
+
* True if a point/spot light can be clustered by this container. Babylon Lite
|
|
3152
|
+
* clusters point lights only.
|
|
3153
|
+
*/
|
|
3154
|
+
static IsLightSupported(light) {
|
|
3155
|
+
return light instanceof PointLight;
|
|
3156
|
+
}
|
|
3157
|
+
getClassName() {
|
|
3158
|
+
return "ClusteredLightContainer";
|
|
3159
|
+
}
|
|
3160
|
+
/** Babylon.js `light.getTypeID()` — `LIGHTTYPEID_CLUSTERED_CONTAINER`. */
|
|
3161
|
+
getTypeID() {
|
|
3162
|
+
return LIGHTTYPEID_CLUSTERED_CONTAINER;
|
|
3163
|
+
}
|
|
3164
|
+
/** True when clustered lighting is available (Babylon Lite backs it on WebGPU). */
|
|
3165
|
+
get isSupported() {
|
|
3166
|
+
return true;
|
|
3167
|
+
}
|
|
3168
|
+
/** The lights added to this clustering system. */
|
|
3169
|
+
get lights() {
|
|
3170
|
+
return this._childLights;
|
|
3171
|
+
}
|
|
3172
|
+
/** Number of cluster tiles across the screen horizontally (default `64`). */
|
|
3173
|
+
get horizontalTiles() {
|
|
3174
|
+
return this._container.horizontalTiles;
|
|
3175
|
+
}
|
|
3176
|
+
set horizontalTiles(value) {
|
|
3177
|
+
this._container.horizontalTiles = value;
|
|
3178
|
+
this._markDirty();
|
|
3179
|
+
}
|
|
3180
|
+
/** Number of cluster tiles across the screen vertically (default `64`). */
|
|
3181
|
+
get verticalTiles() {
|
|
3182
|
+
return this._container.verticalTiles;
|
|
3183
|
+
}
|
|
3184
|
+
set verticalTiles(value) {
|
|
3185
|
+
this._container.verticalTiles = value;
|
|
3186
|
+
this._markDirty();
|
|
3187
|
+
}
|
|
3188
|
+
/** Number of depth slices used to bin lights along view-space Z (default `16`). */
|
|
3189
|
+
get depthSlices() {
|
|
3190
|
+
return this._container.zSlices;
|
|
3191
|
+
}
|
|
3192
|
+
set depthSlices(value) {
|
|
3193
|
+
this._container.zSlices = value;
|
|
3194
|
+
this._markDirty();
|
|
3195
|
+
}
|
|
3196
|
+
/**
|
|
3197
|
+
* Upper bound applied to clustered light ranges. Babylon Lite manages range
|
|
3198
|
+
* binning internally, so this is stored for API-shape parity and does not
|
|
3199
|
+
* re-cluster the lights.
|
|
3200
|
+
*/
|
|
3201
|
+
get maxRange() {
|
|
3202
|
+
return this._maxRange;
|
|
3203
|
+
}
|
|
3204
|
+
set maxRange(value) {
|
|
3205
|
+
this._maxRange = value;
|
|
3206
|
+
}
|
|
3207
|
+
/** Babylon.js `container.addLight(light)`. Only point lights are clustered. */
|
|
3208
|
+
addLight(light) {
|
|
3209
|
+
if (!ClusteredLightContainer.IsLightSupported(light) || light._clusteredContainer) {
|
|
3210
|
+
return;
|
|
3211
|
+
}
|
|
3212
|
+
const point = light;
|
|
3213
|
+
light._clusteredContainer = this;
|
|
3214
|
+
const pos = point.position;
|
|
3215
|
+
const diffuse = point.diffuse;
|
|
3216
|
+
const liteLight = createClusteredPointLight(this._container, {
|
|
3217
|
+
position: [pos.x, pos.y, pos.z],
|
|
3218
|
+
diffuse: [diffuse.r, diffuse.g, diffuse.b],
|
|
3219
|
+
range: point.range,
|
|
3220
|
+
intensity: point.intensity
|
|
3221
|
+
});
|
|
3222
|
+
this._childLights.push(point);
|
|
3223
|
+
this._liteLights.push(liteLight);
|
|
3224
|
+
const lightScene = point.getScene();
|
|
3225
|
+
if (lightScene) {
|
|
3226
|
+
lightScene._unregisterNode(point);
|
|
3227
|
+
removeFromScene(lightScene._lite, point._lite);
|
|
3228
|
+
}
|
|
3229
|
+
this._markDirty();
|
|
3230
|
+
}
|
|
3231
|
+
/**
|
|
3232
|
+
* Babylon.js `container.removeLight(light)`. Returns the index the light held
|
|
3233
|
+
* in the container's light list, or `-1` if it was not present.
|
|
3234
|
+
*/
|
|
3235
|
+
removeLight(light) {
|
|
3236
|
+
const index = this._childLights.indexOf(light);
|
|
3237
|
+
if (index === -1) {
|
|
3238
|
+
return -1;
|
|
3239
|
+
}
|
|
3240
|
+
this._childLights.splice(index, 1);
|
|
3241
|
+
const liteLight = this._liteLights.splice(index, 1)[0];
|
|
3242
|
+
const pool = this._container.pointLights;
|
|
3243
|
+
const j2 = liteLight ? pool.indexOf(liteLight) : -1;
|
|
3244
|
+
if (j2 !== -1) {
|
|
3245
|
+
pool.splice(j2, 1);
|
|
3246
|
+
}
|
|
3247
|
+
light._clusteredContainer = null;
|
|
3248
|
+
const point = light;
|
|
3249
|
+
const lightScene = point.getScene();
|
|
3250
|
+
if (lightScene) {
|
|
3251
|
+
lightScene._registerLight(point);
|
|
3252
|
+
addToScene(lightScene._lite, point._lite);
|
|
3253
|
+
}
|
|
3254
|
+
this._markDirty();
|
|
3255
|
+
return index;
|
|
3256
|
+
}
|
|
3257
|
+
/**
|
|
3258
|
+
* @internal Register the container on the Lite scene, wiring its clustered
|
|
3259
|
+
* lights into the scene's PBR materials. Deferred to engine start so meshes and
|
|
3260
|
+
* materials are settled; skipped on the device-less `NullEngine` and after
|
|
3261
|
+
* disposal. `_built` only flips once registration actually happened, so a skipped
|
|
3262
|
+
* build leaves the container re-buildable and keeps {@link _markDirty} from
|
|
3263
|
+
* touching GPU state that was never created.
|
|
3264
|
+
*/
|
|
3265
|
+
_build() {
|
|
3266
|
+
if (this._built || this.isDisposed()) {
|
|
3267
|
+
return;
|
|
3268
|
+
}
|
|
3269
|
+
const scene = this._scene;
|
|
3270
|
+
if (!scene || scene.getEngine()._headless) {
|
|
3271
|
+
return;
|
|
3272
|
+
}
|
|
3273
|
+
this._built = true;
|
|
3274
|
+
addClusteredLightContainer(scene._lite, this._container);
|
|
3275
|
+
}
|
|
3276
|
+
/** @internal Force a GPU re-upload of the clustered light set on the next frame (post-build). */
|
|
3277
|
+
_markDirty() {
|
|
3278
|
+
if (this._built) {
|
|
3279
|
+
markClusteredLightContainerDirty(this._container);
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
// ─── Base `Light` members overridden: a clustered container is not a punctual
|
|
3283
|
+
// Lite light, so intensity/shadow/enable/dispose must not touch `_lite`. ───
|
|
3284
|
+
/** Container-level intensity (Babylon.js inherits it from `Light`; each child light carries its own). */
|
|
3285
|
+
get intensity() {
|
|
3286
|
+
return this._selfIntensity;
|
|
3287
|
+
}
|
|
3288
|
+
set intensity(value) {
|
|
3289
|
+
this._selfIntensity = value;
|
|
3290
|
+
}
|
|
3291
|
+
/** Clustered lights do not cast shadows in Babylon.js; the toggle is a no-op. */
|
|
3292
|
+
set shadowEnabled(_enabled) {
|
|
3293
|
+
}
|
|
3294
|
+
_onEffectiveEnabledStateChanged(_enabled) {
|
|
3295
|
+
}
|
|
3296
|
+
dispose() {
|
|
3297
|
+
var _a;
|
|
3298
|
+
(_a = this._scene) == null ? void 0 : _a._unregisterClusteredLightContainer(this);
|
|
3299
|
+
super.dispose();
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3072
3302
|
function deferAddCsgMesh(mesh, scene, material) {
|
|
3073
3303
|
scene._deferAdd(() => {
|
|
3074
3304
|
const engine = scene.getEngine()._lite;
|
|
@@ -5678,6 +5908,20 @@ class BounceEase extends EasingFunction {
|
|
|
5678
5908
|
return -Math.pow(1 / bounciness, num - num7) / (num13 * num13) * (num12 - num13) * (num12 + num13);
|
|
5679
5909
|
}
|
|
5680
5910
|
}
|
|
5911
|
+
function RandomGUID() {
|
|
5912
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c2) => {
|
|
5913
|
+
const r2 = Math.random() * 16 | 0;
|
|
5914
|
+
const v2 = c2 === "x" ? r2 : r2 & 3 | 8;
|
|
5915
|
+
return v2.toString(16);
|
|
5916
|
+
});
|
|
5917
|
+
}
|
|
5918
|
+
const GUID = {
|
|
5919
|
+
/**
|
|
5920
|
+
* Generate a pseudo-random RFC4122 v4 UUID. Alias of {@link RandomGUID}.
|
|
5921
|
+
* @returns a pseudo random id
|
|
5922
|
+
*/
|
|
5923
|
+
RandomId: RandomGUID
|
|
5924
|
+
};
|
|
5681
5925
|
const Tools = {
|
|
5682
5926
|
/** High-resolution timestamp in milliseconds. */
|
|
5683
5927
|
Now() {
|
|
@@ -5695,11 +5939,7 @@ const Tools = {
|
|
|
5695
5939
|
},
|
|
5696
5940
|
/** Generate an RFC4122 v4 UUID (used by Babylon.js for unique ids). */
|
|
5697
5941
|
RandomId() {
|
|
5698
|
-
return
|
|
5699
|
-
const r2 = Math.random() * 16 | 0;
|
|
5700
|
-
const v2 = c2 === "x" ? r2 : r2 & 3 | 8;
|
|
5701
|
-
return v2.toString(16);
|
|
5702
|
-
});
|
|
5942
|
+
return RandomGUID();
|
|
5703
5943
|
}
|
|
5704
5944
|
};
|
|
5705
5945
|
const ActionManagerTriggers = {
|
|
@@ -7026,11 +7266,6 @@ class RectAreaLight {
|
|
|
7026
7266
|
unsupported("RectAreaLight", "Area lights are not implemented in Babylon Lite. Use Point/Spot/Directional/Hemispheric lights.");
|
|
7027
7267
|
}
|
|
7028
7268
|
}
|
|
7029
|
-
class ClusteredLightContainer {
|
|
7030
|
-
constructor() {
|
|
7031
|
-
unsupported("ClusteredLightContainer", "Clustered lighting is not exposed by the Babylon Lite public API; the compat layer cannot wrap it.");
|
|
7032
|
-
}
|
|
7033
|
-
}
|
|
7034
7269
|
class GPUParticleSystem {
|
|
7035
7270
|
constructor() {
|
|
7036
7271
|
unsupported(
|
|
@@ -8001,6 +8236,7 @@ export {
|
|
|
8001
8236
|
FxaaPostProcess,
|
|
8002
8237
|
GPUParticleSystem,
|
|
8003
8238
|
GPUPicker,
|
|
8239
|
+
GUID,
|
|
8004
8240
|
GamepadCamera,
|
|
8005
8241
|
GaussianSplattingMesh,
|
|
8006
8242
|
GaussianSplattingStream,
|
|
@@ -8107,6 +8343,7 @@ export {
|
|
|
8107
8343
|
QuarticEase,
|
|
8108
8344
|
Quaternion,
|
|
8109
8345
|
QuinticEase,
|
|
8346
|
+
RandomGUID,
|
|
8110
8347
|
RawTexture,
|
|
8111
8348
|
RawTexture2DArray,
|
|
8112
8349
|
RawTexture3D,
|