@babylonjs/lite-compat 1.38.1-preview → 1.38.2-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 CHANGED
@@ -115,42 +115,42 @@ overloads within a supported area may still be absent.
115
115
 
116
116
  ### `@babylonjs/core`
117
117
 
118
- | Feature area | Status | Notes |
119
- | ----------------------------------------------------------------------------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
120
- | Math (`Vector*`, `Color*`, `Quaternion`, `Matrix`, `Plane`, `Ray`, `Frustum`, `Scalar`, `Axis`/`Space`, color temperature/white balance) | ✅ | Includes handedness-correct `LookDirection` matrices/quaternions; `Angle` / `Curve3` / `Path3D` partial |
121
- | Engine (`WebGPUEngine`, `Engine`, `ThinEngine`, `NullEngine`) | ⚡ | async startup + render loop; reverse-depth constructor options/state are exposed over Lite's fixed reverse-Z pipeline; `currentSampleCount` reports the active surface's MSAA count; `beginFrame`/`endFrame`, occlusion queries, engine-wide alpha-to-coverage, and manual `scene.render()` unsupported |
122
- | Compute + GPU buffers (`ComputeShader`, `StorageBuffer`, `UniformBuffer`) | ⚡ | WGSL compute, direct/indirect dispatch, storage buffers, and compute-oriented std140 uniform buffers forward to Lite; shader registries/preprocessing, texture bindings, in-frame immediate dispatch, and Effect-oriented UBO methods remain unsupported |
123
- | Scene (clear color, cameras/lights, fog, environment, observables, ready state) | ⚡ | `Node.accessibilityTag` forwards description, role, and ARIA metadata to Lite (DOM event handlers remain unsupported); sync `scene.pick` forwards to Lite's CPU triangle picker with thin-instance, predicate, normal, and UV detail; `scene.meshes` + `getMeshBy*`/`getNodeBy*` enumerate every mesh via a canonical wrapper registry; exposure/contrast/tone mapping are forwarded, while white balance and fluid rendering throw because Lite lacks their cross-cutting shader/render-pass subsystems |
124
- | Cameras (`ArcRotateCamera`, `FreeCamera`/`Universal`/`Target`, `FollowCamera`, `GeospatialCamera`) | ✅ | arc controls include pointer, wheel, touch, and BJS-default Arrow-key input; orthographic bounds and projection-mode switching forward to Lite; fully unconfigured orthographic extents use Lite's `halfHeight` + aspect-ratio derivation rather than Babylon.js render dimensions; XR / device-orientation / stereoscopic rigs unsupported |
125
- | Lights (`Hemispheric`, `Directional`, `Point`, `Spot`, `RectAreaLight`) | ⚡ | rectangular area lights use Lite's native LTC path, including `AreaLightTextureTools` emission preprocessing; Lite is stricter for invalid negative/non-finite emitter dimensions. `ClusteredLightContainer` clusters unshadowed point lights before engine start (⚡ partial), while clustered spot lights remain unsupported |
126
- | Shadows (`ShadowGenerator` directional ESM/PCF, spot PCF) | ⚡ | `CascadedShadowGenerator` uses Lite's native 2–4 cascade CSM |
127
- | 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; mesh-blending tag helpers and validated mesh metadata forward to native Lite; `MergeMeshes` bakes positions/normals/UVs and rejects unsupported attributes/animation; polygon/extruded-polygon, decal/text/tiled builders, `GreasedLine*` (thick lines), `InstancedMesh`, LOD/edges/outline, and hardware instances unsupported |
128
- | CSG / CSG2 | ✅ | over Lite boolean ops |
129
- | Gizmos (position/rotation/scale/bounding-box/light/camera + `GizmoManager`) | ⚡ | over Lite gizmo suite; `isEnabled` toggles per-axis interactivity (display-only when disabled) |
130
- | Materials (`StandardMaterial`, `PBRMaterial`, metallic-rough / spec-gloss, `NodeMaterial`) | ⚡ | `clone(name)` shares textures with its own renderable; fixed-slot custom WGSL `MaterialPluginBase` injection is supported (`#include`, regex replacement, and custom UBO/sampler hooks are not), while Gaussian-splat visualization plugins, `DitheredTileFadeMaterialPlugin`, BJS-preprocessed `ShaderMaterial`, `MultiMaterial`, `BackgroundMaterial`, and `OpenPBRMaterial` remain unsupported |
131
- | Textures (`Texture`, `RawTexture`, `RawTexture2DArray`, `RawTexture3D`, `DynamicTexture`, `HtmlTexture`, `ExternalTexture`, cube textures) | ⚡ | `ExternalTexture` wraps Lite's native external-video texture; `HDRCubeTexture` routes to native `loadHdrEnvironment`; `RawTexture2DArray` supports raw bytes, image sources/URLs, and single-file KTX2 arrays; `RawTexture3D` supports base-level RGBA8 volumes but not mip generation; `HtmlTexture` forwards native Lite DOM capture/update; `RenderTargetTexture` / `MirrorTexture` unsupported |
132
- | Animation (keyframe `Animation`, easing, `Animatable`, `AnimationGroup` incl. weighted/additive blend) | ⚡ | All standard easing classes, including `PowerEase` / `BezierCurveEase`, reuse Lite's native functional curves; `beginAnimation` / `beginDirectAnimation` delegate supported float/vector/quaternion tracks to Lite property animation; unsupported tracks use an explicit compat evaluator; structural groups remain compat-owned; loaded glTF skeletal blending supported; root-motion analysis/controller APIs throw |
133
- | Morph targets (`MorphTarget` / `MorphTargetManager`) | ✅ | over Lite morph targets |
134
- | Sprites (`SpriteManager` / `Sprite`) | ⚡ | camera-facing billboards; `SpriteMap` / packed atlas unsupported |
135
- | Behaviors / Actions (`AutoRotation`, `Framing`, `ActionManager`, conditions) | ⚡ | `ActionManager` is manual-dispatch; drag / six-DoF / XR-oriented mesh behaviors throw |
136
- | Misc (`Observable`, `Tools`, `SmartArray`, `Tags`, gradients, `PerformanceMonitor`) | ✅ | |
137
- | Audio V2 (`AudioEngineV2`, `StaticSound`, `StreamingSound`, `AudioBus`, buses/sources/analyzer) | ⚡ | over Lite's AudioV2 port; `MainAudioBus` spatial/analyzer and a second main bus unsupported |
138
- | Physics (`HavokPlugin`, `scene.enablePhysics`/`getPhysicsEngine`, `PhysicsAggregate`/`PhysicsBody`/`PhysicsShape`) | ⚡ | Native Havok V2 forwarding for common body/shape operations, thin-instance bodies, and filtered raycasts with instance indices; unrecognized enum values throw at the compat boundary |
139
- | Particles (`NodeParticleSystemSet` / `ParticleSystemSet` — Node Particle Editor) | ⚡ | NPE snippet/JSON graphs: `Parse`/`ParseFromSnippetAsync` → `buildAsync` → `start`, incl. per-system `set.systems[i]` runtime (`start`/`animate`/`updateSpeed`/`particleTexture`). Imperative classic/GPU/solid `ParticleSystem` construction + programmatic block authoring unsupported |
140
- | Post-processes, layers (glow/highlight), probes, WebXR | ❌ | Babylon.js wrapper classes are not implemented — use native Lite `create*Task` functions, including `createMeshBlendingPostProcessTask` with geometry-renderer tag/depth/albedo outputs |
118
+ | Feature area | Status | Notes |
119
+ | ------------------------------------------------------------------------------------------------------------------------------------------ | :----: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
120
+ | Math (`Vector*`, `Color*`, `Quaternion`, `Matrix`, `Plane`, `Ray`, `Frustum`, `Scalar`, `Axis`/`Space`, color temperature/white balance) | ✅ | Includes handedness-correct `LookDirection` matrices/quaternions; `Angle` / `Curve3` / `Path3D` partial |
121
+ | Engine (`WebGPUEngine`, `Engine`, `ThinEngine`, `NullEngine`) | ⚡ | async startup + render loop; reverse-depth constructor options/state are exposed over Lite's fixed reverse-Z pipeline; `currentSampleCount` reports the active surface's MSAA count; `beginFrame`/`endFrame`, occlusion queries, engine-wide alpha-to-coverage, and manual `scene.render()` unsupported |
122
+ | Compute + GPU buffers (`ComputeShader`, `StorageBuffer`, `UniformBuffer`) | ⚡ | WGSL compute, direct/indirect dispatch, storage buffers, and compute-oriented std140 uniform buffers forward to Lite; shader registries/preprocessing, texture bindings, in-frame immediate dispatch, and Effect-oriented UBO methods remain unsupported |
123
+ | Scene (clear color, cameras/lights, fog, environment, observables, ready state) | ⚡ | `Node.accessibilityTag` forwards description, role, and ARIA metadata to Lite (DOM event handlers remain unsupported); sync `scene.pick` forwards to Lite's CPU triangle picker with thin-instance, predicate, normal, and UV detail; `scene.meshes` + `getMeshBy*`/`getNodeBy*` enumerate every mesh via a canonical wrapper registry; exposure/contrast/tone mapping are forwarded, while white balance and fluid rendering throw because Lite lacks their cross-cutting shader/render-pass subsystems |
124
+ | Cameras (`ArcRotateCamera`, `FreeCamera`/`Universal`/`Target`, `FollowCamera`, `GeospatialCamera`) | ✅ | arc controls include pointer, wheel, touch, and BJS-default Arrow-key input; orthographic bounds and projection-mode switching forward to Lite; fully unconfigured orthographic extents use Lite's `halfHeight` + aspect-ratio derivation rather than Babylon.js render dimensions; XR / device-orientation / stereoscopic rigs unsupported |
125
+ | Lights (`Hemispheric`, `Directional`, `Point`, `Spot`, `RectAreaLight`) | ⚡ | rectangular area lights use Lite's native LTC path, including `AreaLightTextureTools` emission preprocessing; Lite is stricter for invalid negative/non-finite emitter dimensions. `ClusteredLightContainer` clusters unshadowed point lights before engine start (⚡ partial), while clustered spot lights remain unsupported |
126
+ | Shadows (`ShadowGenerator` directional ESM/PCF, spot PCF) | ⚡ | `CascadedShadowGenerator` uses Lite's native 2–4 cascade CSM |
127
+ | 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; mesh-blending tag helpers and validated mesh metadata forward to native Lite; `MergeMeshes` bakes positions/normals/UVs and rejects unsupported attributes/animation; polygon/extruded-polygon, decal/text/tiled builders, `GreasedLine*` (thick lines), `InstancedMesh`, LOD/edges/outline, and hardware instances unsupported |
128
+ | CSG / CSG2 | ✅ | over Lite boolean ops |
129
+ | Gizmos (position/rotation/scale/bounding-box/light/camera + `GizmoManager`) | ⚡ | over Lite gizmo suite; `isEnabled` toggles per-axis interactivity (display-only when disabled) |
130
+ | Materials (`StandardMaterial`, `PBRMaterial`, metallic-rough / spec-gloss, `NodeMaterial`) | ⚡ | `clone(name)` shares textures with its own renderable; fixed-slot custom WGSL `MaterialPluginBase` injection is supported (`#include`, regex replacement, and custom UBO/sampler hooks are not), while Gaussian-splat visualization plugins, `DitheredTileFadeMaterialPlugin`, BJS-preprocessed `ShaderMaterial`, `MultiMaterial`, `BackgroundMaterial`, and `OpenPBRMaterial` remain unsupported |
131
+ | Textures (`Texture`, `RawTexture`, `RawTexture2DArray`, `RawTexture3D`, `DynamicTexture`, `HtmlTexture`, `ExternalTexture`, cube textures) | ⚡ | `ExternalTexture` wraps Lite's native external-video texture; `HDRCubeTexture` routes to native `loadHdrEnvironment`; `RawTexture2DArray` supports raw bytes, image sources/URLs, and single-file KTX2 arrays; `RawTexture3D` supports base-level RGBA8 volumes but not mip generation; `HtmlTexture` forwards native Lite DOM capture/update; `RenderTargetTexture` / `MirrorTexture` unsupported |
132
+ | Animation (keyframe `Animation`, easing, `Animatable`, `AnimationGroup` incl. weighted/additive blend) | ⚡ | All standard easing classes, including `PowerEase` / `BezierCurveEase`, reuse Lite's native functional curves; `beginAnimation` / `beginDirectAnimation` delegate supported float/vector/quaternion tracks to Lite property animation; unsupported tracks use an explicit compat evaluator; structural groups remain compat-owned; loaded glTF skeletal blending supported; root-motion analysis/controller APIs throw |
133
+ | Morph targets (`MorphTarget` / `MorphTargetManager`) | ✅ | over Lite morph targets |
134
+ | Sprites (`SpriteManager` / `Sprite`) | ⚡ | camera-facing billboards; `SpriteMap` / packed atlas unsupported |
135
+ | Behaviors / Actions (`AutoRotation`, `Framing`, `ActionManager`, conditions) | ⚡ | `ActionManager` is manual-dispatch; drag / six-DoF / XR-oriented mesh behaviors throw |
136
+ | Misc (`Observable`, `Tools`, `SmartArray`, `Tags`, gradients, `PerformanceMonitor`) | ✅ | |
137
+ | Audio V2 (`AudioEngineV2`, `StaticSound`, `StreamingSound`, `AudioBus`, buses/sources/analyzer) | ⚡ | over Lite's AudioV2 port; `MainAudioBus` spatial/analyzer and a second main bus unsupported |
138
+ | Physics (`HavokPlugin`, `scene.enablePhysics`/`getPhysicsEngine`, `PhysicsAggregate`/`PhysicsBody`/`PhysicsShape`) | ⚡ | Native Havok V2 forwarding for common body/shape operations, thin-instance bodies, and filtered raycasts with instance indices; unrecognized enum values throw at the compat boundary |
139
+ | Particles (`NodeParticleSystemSet` / `ParticleSystemSet` — Node Particle Editor) | ⚡ | NPE snippet/JSON graphs: `Parse`/`ParseFromSnippetAsync` → `buildAsync` → `start`, incl. per-system `set.systems[i]` runtime (`start`/`animate`/`updateSpeed`/`particleTexture`). Imperative classic/GPU/solid `ParticleSystem` construction + programmatic block authoring unsupported |
140
+ | Post-processes, layers (glow/highlight), probes, WebXR | ❌ | Babylon.js wrapper classes are not implemented — use native Lite `create*Task` functions, including `createMeshBlendingPostProcessTask` with geometry-renderer tag/depth/albedo outputs |
141
141
 
142
142
  ### `@babylonjs/loaders`
143
143
 
144
- | Feature area | Status | Notes |
145
- | ---------------------------------------------------------------------------------------------- | :----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
146
- | glTF 2.0 (+ extensions), `.babylon` | ✅ | via Lite `loadGltf` / `loadBabylon`; KHR_interactivity assets run through Lite's native flow-graph runtime |
147
- | `GLTF2.KHR_interactivity` public helpers | ⚡ | pure operation/data normalization and exporter data types are implemented; BJS FlowGraph registry/parser/block/export planning throws with named structural blockers |
148
- | glTF 1.0 loader and extensions | ❌ | named `GLTF1` stubs throw; Lite has no legacy parser, extension registry, or material-conversion subsystem |
149
- | OpenPBR glTF material adapter | ❌ | exported at root and under `GLTF2`; throws because Lite has no OpenPBR material subsystem |
150
- | OpenUSD (`USDFileLoader`) | ⚡ | delegates binary import, virtual files, callbacks, diagnostics, asset containers, and disposal to Lite; all four custom runtime assets must share one directory |
151
- | `SceneLoader` (`ImportMeshAsync` / `AppendAsync` / `LoadAssetContainerAsync`), `AssetsManager` | ⚡ | `AssetContainer` partial |
144
+ | Feature area | Status | Notes |
145
+ | ---------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
146
+ | glTF 2.0 (+ extensions), `.babylon` | ✅ | via Lite `loadGltf` / `loadBabylon`; KHR_interactivity assets run through Lite's native flow-graph runtime |
147
+ | `GLTF2.KHR_interactivity` public helpers | ⚡ | pure operation/data normalization and exporter data types are implemented; BJS FlowGraph registry/parser/block/export planning throws with named structural blockers |
148
+ | glTF 1.0 loader and extensions | ❌ | named `GLTF1` stubs throw; Lite has no legacy parser, extension registry, or material-conversion subsystem |
149
+ | OpenPBR glTF material adapter | ❌ | exported at root and under `GLTF2`; throws because Lite has no OpenPBR material subsystem |
150
+ | OpenUSD (`USDFileLoader`) | ⚡ | delegates binary import, virtual files, callbacks, diagnostics, asset containers, and disposal to Lite; all four custom runtime assets must share one directory |
151
+ | `SceneLoader` (`ImportMeshAsync` / `AppendAsync` / `LoadAssetContainerAsync`), `AssetsManager` | ⚡ | `AssetContainer` partial |
152
152
  | Gaussian Splatting (`.ply` / `.splat` / `.sog` / `.spz`) | ⚡ | `GaussianSplattingMesh` wraps eager Lite loaders and Lite's opt-in point renderer; point render scale supports `"auto"` or exact `1 / n` multipliers for divisors 1–8. BJS streaming and standalone point-renderer/blit classes remain named stubs |
153
- | `OBJ` / `STL` / `FBX` / `BVH` | ❌ | parser/materializer subsystems are not in Lite — convert to glTF |
153
+ | `OBJ` / `STL` / `FBX` / `BVH` | ❌ | parser/materializer subsystems are not in Lite — convert to glTF |
154
154
 
155
155
  > **glTF hierarchy:** `result.meshes` is a flattened view of the glTF node hierarchy (transform nodes plus the
156
156
  > primitive meshes beneath them), not one mesh per node as in Babylon.js. Reparent with `setParent()`, not `.parent =`,
@@ -178,6 +178,38 @@ The intended migration path is:
178
178
  @babylonjs/core → @babylonjs/lite-compat → babylon-lite (native)
179
179
  ```
180
180
 
181
+ ## Per-mesh opacity
182
+
183
+ `mesh.visibility` works automatically for ordinary Standard and PBR meshes, independently of
184
+ `mesh.isVisible`. It never changes or clones the material, so meshes sharing a material can
185
+ fade independently. Native Lite users explicitly import `setMeshOpacity` / `getMeshOpacity`
186
+ from the package root; compat needs no enabler.
187
+
188
+ ```ts
189
+ mesh.visibility = 0.5; // Sorted blending, depth writes off.
190
+ mesh.visibility = 0; // No colour or geometry-output draws; still pickable.
191
+ mesh.visibility = 1; // Original material route.
192
+ ```
193
+
194
+ - The getter retains the raw finite value; rendering clamps it to `[0, 1]`. NaN and infinities
195
+ throw `RangeError` (a deliberate deviation from Babylon.js).
196
+ - Shadows remain full strength, including at zero. Picking, `isVisible`, and enabled state
197
+ are unchanged. Geometry outputs apply opacity before their existing `> 0.4` alpha gate.
198
+ - Fading node/shader/line materials throws `LiteCompatError`; assigning one to a faded
199
+ mesh is rejected before changing its material. Pending `NodeMaterial` handles are also
200
+ rejected. Resetting visibility to 1 is allowed unless the native mesh is disposed.
201
+ - Imported glTF OPAQUE/MASK materials deliberately fade too, unlike Babylon.js's explicit
202
+ transparency-mode behaviour. MASK cutoff uses the original alpha **before** opacity.
203
+ - A glTF-node wrapper updates its immediate primitive meshes atomically, not a child glTF
204
+ node's primitives. Visibility is not inherited; a synthetic root has no geometry to fade.
205
+ Raw getters belong to the wrapper assigned, even when its primitive wrappers share the
206
+ resulting native rendering factor. Clones copy raw values and own new GPU bindings.
207
+ - Thin instances share their mesh's opacity. `InstancedMesh.visibility`, MeshLoD opacity,
208
+ per-submesh opacity, and per-thin-instance opacity are not supported.
209
+
210
+ See the [mesh-opacity architecture](../../docs/lite/architecture/mesh-opacity.md) for native
211
+ contracts and the explicitly normalized reference policies.
212
+
181
213
  ## glTF import hierarchy and reparenting
182
214
 
183
215
  Babylon Lite keeps the glTF node hierarchy: every glTF node becomes a transform node, and every primitive of its mesh
package/index.d.ts CHANGED
@@ -257,12 +257,19 @@ export declare interface AbstractEngineOptions extends EngineOptions_2 {
257
257
  * visibility, and shadow-receipt. Concrete meshes derive from this.
258
258
  */
259
259
  export declare class AbstractMesh extends TransformNode {
260
260
  private _material;
261
261
  private _meshBlendingTag;
262
+ protected _visibilityValue: number;
262
263
  protected _visible: boolean;
263
264
  constructor(name: string, lite: Mesh_2, scene?: Scene);
264
265
  getClassName(): string;
265
266
  get material(): CompatMaterial | null;
266
267
  set material(value: CompatMaterial | null);
267
268
  get isVisible(): boolean;
268
269
  set isVisible(value: boolean);
270
+ /** Raw finite Babylon visibility; rendering clamps it to [0, 1]. Independent of isVisible. */
271
+ get visibility(): number;
272
+ set visibility(value: number);
273
+ private _validateCompatOpacityMaterial;
274
+ /** A glTF node owns its immediate primitive meshes, never a child glTF node's primitives. */
275
+ private _opacityTargets;
269
276
  get isPickable(): boolean;
270
277
  set isPickable(value: boolean);
271
278
  get receiveShadows(): boolean;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as Vector4, A as PBRClearCoatConfiguration, B as Observable, C as RegisterPolygonBuilder, D as registerMeshAtStart, E as VertexData, F as PBRSpecularGlossinessMaterial, G as transformCoordinates, H as BoundingInfo, I as PushMaterial, J as Color3, K as transformNormal, L as StandardMaterial, M as PBRMaterial, N as PBRMetallicRoughnessMaterial, O as Material, P as PBRSheenConfiguration, Q as Vector3, R as attachMaterialToScene, S as PolygonBuilder, T as VertexBuffer, U as BoundingSphere, V as BoundingBox, W as Matrix, X as liteBackedColor3, Y as Color4, Z as Vector2, _ as GroundMesh, a as CreateDisc, b as Mesh, c as CreateLines, d as CreatePolygonVertexData, et as liteBackedVector3, f as CreateSphere, g as ExtrudePolygon, h as CreateTorus, i as CreateDashedLines, j as PBRIridescenceConfiguration, k as PBRAnisotropicConfiguration, l as CreatePlane, m as CreateTiledPlane, n as CreateBox, nt as unsupported, o as CreateGround, p as CreateTiledBox, q as Quaternion, r as CreateCylinder, s as CreateLineSystem, t as AbstractMesh, tt as LiteCompatError, u as CreatePolygon, v as InstancedMesh, w as TransformNode, x as MeshBuilder, y as LinesMesh, z as Node } from "./meshes-CTqDBeGc.js";
1
+ import { $ as Vector4, A as PBRClearCoatConfiguration, B as Observable, C as RegisterPolygonBuilder, D as registerMeshAtStart, E as VertexData, F as PBRSpecularGlossinessMaterial, G as transformCoordinates, H as BoundingInfo, I as PushMaterial, J as Color3, K as transformNormal, L as StandardMaterial, M as PBRMaterial, N as PBRMetallicRoughnessMaterial, O as Material, P as PBRSheenConfiguration, Q as Vector3, R as attachMaterialToScene, S as PolygonBuilder, T as VertexBuffer, U as BoundingSphere, V as BoundingBox, W as Matrix, X as liteBackedColor3, Y as Color4, Z as Vector2, _ as GroundMesh, a as CreateDisc, b as Mesh, c as CreateLines, d as CreatePolygonVertexData, et as liteBackedVector3, f as CreateSphere, g as ExtrudePolygon, h as CreateTorus, i as CreateDashedLines, j as PBRIridescenceConfiguration, k as PBRAnisotropicConfiguration, l as CreatePlane, m as CreateTiledPlane, n as CreateBox, nt as unsupported, o as CreateGround, p as CreateTiledBox, q as Quaternion, r as CreateCylinder, s as CreateLineSystem, t as AbstractMesh, tt as LiteCompatError, u as CreatePolygon, v as InstancedMesh, w as TransformNode, x as MeshBuilder, y as LinesMesh, z as Node } from "./meshes-Bt_UAqXU.js";
2
2
  import { CharacterSupportedState as CharacterSupportedState$1, GAUSSIAN_SPLATTING_MAX_PART_COUNT, MaxTintMagnitude, MinTemperatureKelvin, PhysicsConstraintAxis as PhysicsConstraintAxis$1, PhysicsConstraintType as PhysicsConstraintType$1, PhysicsMotionType as PhysicsMotionType$1, PhysicsPrestepType as PhysicsPrestepType$1, PhysicsShapeType as PhysicsShapeType$1, VERSION, _getGaussianPointSplattingPackedShBytesPerSplat, _hasGaussianPointSplattingProjectedDepth, addAnimationGroup, addBillboardSpriteIndex, addClusteredLightContainer, addComputeDispatch, addFacingBillboardSystem, addPolarToRef, addSphericalToRef, addSprite2DIndex, addToScene, animateParticleSystem, applyPhysicsBodyForce, applyPhysicsBodyImpulse, attachAxisDragGizmoToNode, attachAxisScaleGizmoToNode, attachBoundingBoxGizmoToNode, attachCameraGizmoToCamera, attachControl, attachFreeControl, attachGeospatialControls, attachLightGizmoToLight, attachPlaneDragGizmoToNode, attachPlaneRotationGizmoToNode, attachPositionGizmoToNode, attachRotationGizmoToNode, attachScaleGizmoToNode, backEase, bakeCurrentTransformIntoVertices, bezierCurveEase, billboardBlendAdditive, billboardBlendAlpha, bounceEase, calculatePhysicsCharacterMovementToRef, circleEase, clearAnimationManager, clearBoneOverride, clearStorageBuffer, computeStorageBufferBinding, computeUniformBufferBinding, createAnimationManager, createArcRotateCamera, createAudioBusAsync, createAudioEngineAsync, createAxisDragGizmo, createAxisScaleGizmo, createBankedFreeCamera, createBoundingBoxGizmo, createCameraGizmo, createClusteredLightContainer, createClusteredPointLight, createComputeBindingSet, createComputeDispatch, createComputeIndirectDispatch, createComputeShader, createComputeTask, createCsg2FromMesh, createCsgFromMesh, createCsmDirectionalShadowGenerator, createDefaultCamera, createDefaultMeshBlendRadiusDefinitions, createDirectionalLight, createDynamicTexture, createEngine, createEsmDirectionalShadowGenerator, createExternalTexture, createFacingBillboardSystem, createFreeCamera, createGeospatialCamera, createGpuPicker, createGridMaterial, createHavokWorld, createHemisphericLight, createHtmlTexture, createKhrInteractivityRuntimeValueSnapshot, createLightGizmo, createMeshFromCsg, createMeshesFromCsg2, createMicrophoneSoundSourceAsync, createMorphTargets, createNullEngine, createParticleBillboard, createPcfDirectionalShadowGenerator, createPcfSpotlightShadowGenerator, createPhysicsAggregate, createPhysicsBody, createPhysicsCharacterController, createPhysicsConstraint, createPhysicsShape, createPickingRay, createPlaneDragGizmo, createPlaneRotationGizmo, createPointLight, createPositionGizmo, createPropertyAnimationClip, createPropertyAnimationGroup, createRectAreaLight, createRotationGizmo, createScaleGizmo, createSceneContext, createSoundAsync, createSoundBufferAsync, createSoundSourceAsync, createSpotLight, createSprite2DLayer, createSpriteRenderer, createStorageBuffer, createStreamingSoundAsync, createTexture2DArray, createTexture2DArrayFromKtx2, createTexture2DArrayFromPixels, createTexture2DArrayFromUrls, createTexture2DFromPixels, createTexture3DFromPixels, createTransformNode, createUniformBuffer, createUtilityLayer, csg2Add, csg2Intersect, csg2Subtract, csgIntersect, csgSubtract, csgUnion, cubicEase, disableGaussianPointSplatting, disableOrthographicCamera, disposeAudioBus, disposeAudioEngine, disposeAxisDragGizmo, disposeAxisScaleGizmo, disposeBoundingBoxGizmo, disposeCameraGizmo, disposeComputeBindingSet, disposeComputeShader, disposeCsg2, disposeEngine, disposeHtmlTexture, disposeLightGizmo, disposePhysics, disposePicker, disposePlaneDragGizmo, disposePlaneRotationGizmo, disposePositionGizmo, disposeRotationGizmo, disposeScaleGizmo, disposeScene, disposeSound, disposeSoundSource, disposeStorageBuffer, disposeStreamingSound, disposeUniformBuffer, disposeUsd, disposeUtilityLayer, dividePolarToRef, divideSphericalToRef, elasticEase, enableAnalyzer, enableAnimationBlending, enableArcRotateKeyboardControls, enableBoneControlForSkinnedAssets, enableGaussianPointSplatting, enableHavokThinInstancePhysicsSync, enableMirroredMeshes, enableOrthographicCamera, enableRectAreaLights, enableSpatial, enableStereo, encodeIdToColor, exponentialEase, getBoneByName, getByteFrequencyData, getByteTimeDomainData, getCameraPosition, getFloatFrequencyData, getFloatTimeDomainData, getGaussianSplattingMaxPartCount, getGaussianSplattingPartIndexVaryingDeclaration, getMasterVolume, getPhysicsBodyAngularVelocity, getPhysicsBodyLinearVelocity, getPickedUV, getProjectionMatrix, getVariantNames, getViewMatrix, getWhiteBalanceMatrix, goToFrame, hasDefaultInteractivityFlowInput, initializeCsg2Async, inverseLerp, invertMat4, isExternalTextureReady, loadBabylon, loadBasisTexture2D, loadDdsEnvironment, loadEnvironment, loadGltf, loadHdrEnvironment, loadImageToArrayLayer, loadKtxTexture2D, loadSOG, loadSPZ, loadSplat, loadSpriteAtlas, loadTexture2D, loadUsd, markClusteredLightContainerDirty, multiplyMat4, multiplyPolarToRef, multiplySphericalToRef, normalizeInteractivityEventDataConfiguration, normalizeKhrInteractivityRuntimeValue, onBeforeRender, onEngineDeviceLost, onPhysicsAfterStep, onSceneDispose, packMeshBlendingTag, parseNodeMaterialFromSnippet, parseNodeParticleSetFromSnippet, pauseAnimation, pauseSound, pauseStreamingSound, physicsRaycast, pickAsync, pickMeshesWithRayPrecise, playAnimation, playSound, playStreamingSound, polarFromVec2ToRef, polarToVec2ToRef, powerEase, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, processAreaLightTexture, quadraticEase, quarticEase, quinticEase, readStorageBufferAfterFrame, rebuildSceneRenderables, registerNodeParticleSet, registerScene, registerSceneWithShadowSupport, registerSpriteRenderer, registerUtilityLayer, releasePhysicsConstraint, releasePhysicsShape, releaseTexture, removeAnimationGroup, removeFromScene, removePhysicsBody, requestHtmlTextureUpdate, resetVariant, resizeEngine, resolveCameraViewport, resumeSound, resumeStreamingSound, sampleCatmullRomSpline, sampleHermiteSpline, scalePolarToRef, scaleSphericalToRef, selectVariant, setAnimationAdditive, setBonePosition, setBoneRotationQuaternion, setBoneScaling, setBusVolume, setClipPlane, setEngineSize, setEnvironmentLightingRotation, setEnvironmentSkyboxRotation, setFog, setGeospatialOrientation, setMasterVolume, setMorphTargetWeights, setParent, setPhysicsBodyAngularVelocity, setPhysicsBodyLinearVelocity, setPhysicsBodyMassProperties, setPhysicsBodyMotionType, setPhysicsBodyPrestepType, setPhysicsBodyShape, setPhysicsGravity, setPhysicsShapeFilterCollideMask, setPhysicsShapeFilterMembershipMask, setPhysicsShapeIsTrigger, setPhysicsShapeMaterial, setPhysicsTimestep, setPositionGizmoLocalCoordinates, setRotationGizmoLocalCoordinates, setScaleGizmoLocalCoordinates, setShadowTaskCasterMeshes, setSoundSourceVolume, setSoundVolume, setSpatialListener, setSpatialListenerPosition, setSpatialOrientation, setSpatialPosition, setStereoPan, setStreamingSoundVolume, sineEase, sphericalFromVec3ToRef, sphericalToVec3ToRef, spriteBlendAdditive, spriteBlendAlpha, spriteBlendPremultiplied, startEngine, startParticleSystem, stepScene, stopAnimation, stopEngine, stopParticleSystem, stopSound, stopStreamingSound, submitComputeTasks, subtractPolarToRef, subtractSphericalToRef, syncParticleBillboard, temperatureTintToXyz, unlockAudioEngineAsync, unpackMeshBlendingTag, updateAnimationManager, updateBillboardSpriteIndex, updateDynamicTexture, updateHtmlTexture, updateSpatialAudio, updateSprite2DIndex, updateStorageBufferRange, updateTexture2DArrayFromPixels, updateTexture2DFromPixels, updateUniformBuffer, uploadImageToArrayLayer, whenHtmlTextureReady } from "@babylonjs/lite";
3
3
  // \0rolldown/runtime.js
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- import { addToScene, cloneTransformNode, computeAabb, createBox, createCylinder, createDashedLines, createDisc, createExtrudeShape, createGround, createGroundFromHeightMap, createLineMaterial, createLineSystem, createMeshFromData, createPbrMaterial, createPlane, createPolyhedron, createQuatFromRotationMat4, createRibbon, createSolidTexture2D, createSphere, createStandardMaterial, createTorus, createTorusKnot, createTransformNode, createTube, markMaterialUboDirty, maximizeMat4InPlace, normalizeVec2ToRef, projectPointToViewportToRef, rebuildMaterial, removeFromScene, resizeMeshGeometry, scaleBoundsFromCenterToRef, setAccessibilityTag, setLineMaterialColor, setMat4Translation, setMeshVisible, setParent, setPbrAnisotropy, setPbrClearCoat, setPbrEmissive, setPbrGammaAlbedo, setPbrIridescence, setPbrSheen, setStandardBumpTexture, setStandardEmissiveTexture, setThinInstanceColors, setThinInstances, updateDashedLines, updateLineSystem, updateMeshGeometry, updateMeshUvs, writeMat4FromLookDirectionLHIntoBuffer, writeMat4FromLookDirectionRHIntoBuffer, writeMat4FromQuatIntoBuffer, writeQuatFromRotationMat4IntoRef } from "@babylonjs/lite";
1
+ import { addToScene, cloneTransformNode, computeAabb, createBox, createCylinder, createDashedLines, createDisc, createExtrudeShape, createGround, createGroundFromHeightMap, createLineMaterial, createLineSystem, createMeshFromData, createPbrMaterial, createPlane, createPolyhedron, createQuatFromRotationMat4, createRibbon, createSolidTexture2D, createSphere, createStandardMaterial, createTorus, createTorusKnot, createTransformNode, createTube, getMaterialFamily, getMeshOpacity, markMaterialUboDirty, maximizeMat4InPlace, normalizeVec2ToRef, projectPointToViewportToRef, rebuildMaterial, removeFromScene, resizeMeshGeometry, scaleBoundsFromCenterToRef, setAccessibilityTag, setLineMaterialColor, setMat4Translation, setMeshOpacity, setMeshVisible, setParent, setPbrAnisotropy, setPbrClearCoat, setPbrEmissive, setPbrGammaAlbedo, setPbrIridescence, setPbrSheen, setStandardBumpTexture, setStandardEmissiveTexture, setThinInstanceColors, setThinInstances, updateDashedLines, updateLineSystem, updateMeshGeometry, updateMeshUvs, writeMat4FromLookDirectionLHIntoBuffer, writeMat4FromLookDirectionRHIntoBuffer, writeMat4FromQuatIntoBuffer, writeQuatFromRotationMat4IntoRef } from "@babylonjs/lite";
2
2
  // src/error.ts
3
3
  /**
4
4
  * Error thrown when Babylon.js code reaches an API surface that the Babylon Lite
@@ -2733,6 +2733,12 @@ function liteNodeOf(node) {
2733
2733
  const n = node;
2734
2734
  return n._node ?? n._lite ?? null;
2735
2735
  }
2736
+ function validateOpacityMaterial(api, name, material) {
2737
+ if (material) {
2738
+ const family = getMaterialFamily(material);
2739
+ if (family !== "standard" && family !== "pbr") unsupported(api, `Mesh "${name}" uses a "${family}" material; visibility below 1 supports only Standard and PBR materials.`);
2740
+ }
2741
+ }
2736
2742
  var PLACEHOLDER_POSITIONS = new Float32Array([
2737
2743
  0,
2738
2744
  0,
@@ -2961,11 +2967,13 @@ var AbstractMesh = class extends TransformNode {
2961
2967
  */
2962
2968
  _liteOnlyMaterial = false;
2963
2969
  _meshBlendingTag = 0;
2970
+ _visibilityValue = 1;
2964
2971
  _visible = true;
2965
2972
  constructor(name, lite, scene) {
2966
2973
  super(name, scene, lite);
2967
2974
  this._lite = lite;
2968
2975
  this._lite.name = name;
2976
+ this._visibilityValue = "_gpu" in lite ? getMeshOpacity(lite) : 1;
2969
2977
  if (scene) {
2970
2978
  this.material = scene.defaultMaterial;
2971
2979
  scene._registerMesh(this, this._lite);
@@ -2989,10 +2997,11 @@ var AbstractMesh = class extends TransformNode {
2989
2997
  return this._material;
2990
2998
  }
2991
2999
  set material(value) {
2992
- this._material = value;
2993
- this._liteOnlyMaterial = false;
2994
3000
  const scene = this._scene;
2995
3001
  const renderMaterial = value ?? scene?.defaultMaterial;
3002
+ if (renderMaterial && (this._visibilityValue < 1 || this._opacityTargets().some((target) => getMeshOpacity(target) < 1))) this._validateCompatOpacityMaterial("Mesh.material", renderMaterial);
3003
+ this._material = value;
3004
+ this._liteOnlyMaterial = false;
2996
3005
  if (renderMaterial && scene) {
2997
3006
  if (scene._hasStarted) attachMaterialToScene(renderMaterial, scene);
2998
3007
  else adoptMaterialScene(renderMaterial, scene);
@@ -3007,6 +3016,30 @@ var AbstractMesh = class extends TransformNode {
3007
3016
  this._visible = value;
3008
3017
  this._syncVisibility(this.isEnabled());
3009
3018
  }
3019
+ /** Raw finite Babylon visibility; rendering clamps it to [0, 1]. Independent of isVisible. */
3020
+ get visibility() {
3021
+ return this._visibilityValue;
3022
+ }
3023
+ set visibility(value) {
3024
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new RangeError("Mesh.visibility must be a finite number.");
3025
+ const targets = this._opacityTargets();
3026
+ if (value < 1 && this._material) this._validateCompatOpacityMaterial("Mesh.visibility", this._material);
3027
+ for (const target of targets) {
3028
+ if (target._disposed) throw new Error(`Mesh "${target.name}" cannot set opacity: it was disposed when it left its last scene. Create a new mesh instead.`);
3029
+ if (value < 1) validateOpacityMaterial("Mesh.visibility", target.name ?? this.name, target.material);
3030
+ }
3031
+ for (const target of targets) setMeshOpacity(target, value);
3032
+ this._visibilityValue = value;
3033
+ }
3034
+ _validateCompatOpacityMaterial(api, material) {
3035
+ if (!material._lite) unsupported(api, `Mesh "${this.name}" cannot fade a deferred ${material.getClassName()} material; visibility below 1 supports only Standard and PBR materials.`);
3036
+ validateOpacityMaterial(api, this.name, material._lite);
3037
+ }
3038
+ /** A glTF node owns its immediate primitive meshes, never a child glTF node's primitives. */
3039
+ _opacityTargets() {
3040
+ const node = this._lite;
3041
+ return "_gpu" in node ? [node] : node.children.filter((child) => "_gpu" in child);
3042
+ }
3010
3043
  get isPickable() {
3011
3044
  return this._lite.pickable !== false;
3012
3045
  }
@@ -3421,6 +3454,7 @@ var Mesh = class Mesh extends AbstractMesh {
3421
3454
  wrapper.metadata = source.metadata;
3422
3455
  wrapper.setEnabled(source.isEnabled(false));
3423
3456
  if (wrapper instanceof Mesh && source instanceof Mesh) {
3457
+ wrapper._visibilityValue = source._visibilityValue;
3424
3458
  if (source._liteOnlyMaterial) wrapper._liteOnlyMaterial = true;
3425
3459
  else wrapper.material = source.material;
3426
3460
  wrapper.isVisible = source.isVisible;
@@ -3937,4 +3971,4 @@ var PolygonBuilder = {
3937
3971
  function RegisterPolygonBuilder() {}
3938
3972
  export { Vector4 as $, PBRClearCoatConfiguration as A, Observable as B, RegisterPolygonBuilder as C, registerMeshAtStart as D, VertexData as E, PBRSpecularGlossinessMaterial as F, transformCoordinates as G, BoundingInfo as H, PushMaterial as I, Color3 as J, transformNormal as K, StandardMaterial as L, PBRMaterial as M, PBRMetallicRoughnessMaterial as N, Material as O, PBRSheenConfiguration as P, Vector3 as Q, attachMaterialToScene as R, PolygonBuilder as S, VertexBuffer as T, BoundingSphere as U, BoundingBox as V, Matrix as W, liteBackedColor3 as X, Color4 as Y, Vector2 as Z, GroundMesh as _, CreateDisc as a, Mesh as b, CreateLines as c, CreatePolygonVertexData as d, liteBackedVector3 as et, CreateSphere as f, ExtrudePolygon as g, CreateTorus as h, CreateDashedLines as i, PBRIridescenceConfiguration as j, PBRAnisotropicConfiguration as k, CreatePlane as l, CreateTiledPlane as m, CreateBox as n, unsupported as nt, CreateGround as o, CreateTiledBox as p, Quaternion as q, CreateCylinder as r, CreateLineSystem as s, AbstractMesh as t, LiteCompatError as tt, CreatePolygon as u, InstancedMesh as v, TransformNode as w, MeshBuilder as x, LinesMesh as y, Node as z };
3939
3973
 
3940
- //# sourceMappingURL=meshes-CTqDBeGc.js.map
3974
+ //# sourceMappingURL=meshes-Bt_UAqXU.js.map