@babylonjs/lite-compat 1.8.0-preview → 1.9.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/index.js CHANGED
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { V as Vector3, u as unsupported, L as LiteCompatError, N as Node, M as Matrix, a as Mesh, T as TransformNode, l as liteBackedVector3, B as BoundingInfo, Q as Quaternion } from "./meshes-CPZtn6G5.js";
5
5
  import { A, b, c, C, d, e, f, g, h, i, G, I, j, k, m, n, o, t, p } from "./meshes-CPZtn6G5.js";
6
- import { createEngine, onBeforeRender, stopEngine, resizeEngine, setEngineSize, disposeEngine, registerSceneWithShadowSupport, registerScene, startEngine, createArcRotateCamera, attachControl, getCameraPosition, getViewMatrix, getProjectionMatrix, createGeospatialCamera, setGeospatialOrientation, attachGeospatialControls, createFreeCamera, attachFreeControl, markMaterialUboDirty, createPbrMaterial, createSolidTexture2D, createStandardMaterial, setAnimationAdditive, playAnimation, pauseAnimation, goToFrame, stopAnimation, createSceneContext, updateAnimationManager, setFog, setClipPlane, 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, createTexture2DFromPixels, updateTexture2DFromPixels, loadBasisTexture2D, loadKtxTexture2D, loadTexture2D, getContainerMeshes, 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 } from "@babylonjs/lite";
6
+ import { createEngine, onBeforeRender, stopEngine, resizeEngine, setEngineSize, disposeEngine, registerSceneWithShadowSupport, registerScene, startEngine, createNullEngine, stepScene, setPhysicsTimestep, setPhysicsGravity, disposePhysics, createHavokWorld, createArcRotateCamera, attachControl, getCameraPosition, getViewMatrix, getProjectionMatrix, createGeospatialCamera, setGeospatialOrientation, attachGeospatialControls, createFreeCamera, attachFreeControl, markMaterialUboDirty, createPbrMaterial, createSolidTexture2D, createStandardMaterial, 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, createTexture2DFromPixels, updateTexture2DFromPixels, createTexture3DFromPixels, loadBasisTexture2D, loadKtxTexture2D, loadTexture2D, getContainerMeshes, 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 } from "@babylonjs/lite";
7
7
  class Color3 {
8
8
  constructor(r = 0, g2 = 0, b2 = 0) {
9
9
  this.r = r;
@@ -488,8 +488,8 @@ class AbstractEngine {
488
488
  __publicField(this, "_lite");
489
489
  /**
490
490
  * @internal Whether this engine has no GPU device (a {@link NullEngine}). Headless
491
- * engines drive a pure-JS animation/observable loop instead of Babylon Lite's
492
- * GPU render loop, so the compat `Scene` skips its Lite scene-context setup.
491
+ * engines build their Lite scene context with no frame-graph render task and are
492
+ * advanced by a pure-JS loop that steps Lite's simulation (see {@link NullEngine}).
493
493
  */
494
494
  __publicField(this, "_headless", false);
495
495
  __publicField(this, "_canvas");
@@ -767,14 +767,17 @@ class NullEngine extends WebGPUEngine {
767
767
  constructor() {
768
768
  super(NULL_CANVAS);
769
769
  this._headless = true;
770
+ this._lite = createNullEngine();
770
771
  this._initialized = true;
771
772
  }
772
773
  /** No GPU device to acquire. */
773
774
  async initAsync() {
774
775
  }
775
776
  /**
776
- * Drive a pure-JS frame loop: each tick advances every registered scene's CPU
777
- * animations + render observables, then runs the user callback(s). No GPU work.
777
+ * Drive a pure-JS frame loop: each tick advances every registered scene by the
778
+ * wall-clock delta between frames through Lite's `stepScene` (which fires the scene's before-render
779
+ * callbacks: CPU animations, physics, render observables), then runs the user
780
+ * callback(s). No GPU work is recorded or submitted.
778
781
  */
779
782
  runRenderLoop(callback) {
780
783
  this._loopCallbacks.push(callback);
@@ -788,7 +791,7 @@ class NullEngine extends WebGPUEngine {
788
791
  const deltaMs = current - last;
789
792
  last = current;
790
793
  for (const scene of this._scenes) {
791
- scene._tick(deltaMs);
794
+ stepScene(this._lite, scene._lite, deltaMs);
792
795
  }
793
796
  for (const cb of this._loopCallbacks) {
794
797
  cb();
@@ -933,6 +936,152 @@ class AbstractScene {
933
936
  return this._trackedMeshes.find((m2) => byId(m2)) ?? this._cameras.find((c2) => byId(c2)) ?? this._lights.find((l) => byId(l)) ?? null;
934
937
  }
935
938
  }
939
+ var PhysicsShapeType = /* @__PURE__ */ ((PhysicsShapeType2) => {
940
+ PhysicsShapeType2[PhysicsShapeType2["SPHERE"] = 0] = "SPHERE";
941
+ PhysicsShapeType2[PhysicsShapeType2["CAPSULE"] = 1] = "CAPSULE";
942
+ PhysicsShapeType2[PhysicsShapeType2["CYLINDER"] = 2] = "CYLINDER";
943
+ PhysicsShapeType2[PhysicsShapeType2["BOX"] = 3] = "BOX";
944
+ PhysicsShapeType2[PhysicsShapeType2["CONVEX_HULL"] = 4] = "CONVEX_HULL";
945
+ PhysicsShapeType2[PhysicsShapeType2["CONTAINER"] = 5] = "CONTAINER";
946
+ PhysicsShapeType2[PhysicsShapeType2["MESH"] = 6] = "MESH";
947
+ PhysicsShapeType2[PhysicsShapeType2["HEIGHTFIELD"] = 7] = "HEIGHTFIELD";
948
+ return PhysicsShapeType2;
949
+ })(PhysicsShapeType || {});
950
+ var PhysicsMotionType = /* @__PURE__ */ ((PhysicsMotionType2) => {
951
+ PhysicsMotionType2[PhysicsMotionType2["STATIC"] = 0] = "STATIC";
952
+ PhysicsMotionType2[PhysicsMotionType2["ANIMATED"] = 1] = "ANIMATED";
953
+ PhysicsMotionType2[PhysicsMotionType2["DYNAMIC"] = 2] = "DYNAMIC";
954
+ return PhysicsMotionType2;
955
+ })(PhysicsMotionType || {});
956
+ var PhysicsPrestepType = /* @__PURE__ */ ((PhysicsPrestepType2) => {
957
+ PhysicsPrestepType2[PhysicsPrestepType2["DISABLED"] = 0] = "DISABLED";
958
+ PhysicsPrestepType2[PhysicsPrestepType2["TELEPORT"] = 1] = "TELEPORT";
959
+ PhysicsPrestepType2[PhysicsPrestepType2["ACTION"] = 2] = "ACTION";
960
+ return PhysicsPrestepType2;
961
+ })(PhysicsPrestepType || {});
962
+ var PhysicsConstraintType = /* @__PURE__ */ ((PhysicsConstraintType2) => {
963
+ PhysicsConstraintType2[PhysicsConstraintType2["BALL_AND_SOCKET"] = 1] = "BALL_AND_SOCKET";
964
+ PhysicsConstraintType2[PhysicsConstraintType2["DISTANCE"] = 2] = "DISTANCE";
965
+ PhysicsConstraintType2[PhysicsConstraintType2["HINGE"] = 3] = "HINGE";
966
+ PhysicsConstraintType2[PhysicsConstraintType2["SLIDER"] = 4] = "SLIDER";
967
+ PhysicsConstraintType2[PhysicsConstraintType2["LOCK"] = 5] = "LOCK";
968
+ PhysicsConstraintType2[PhysicsConstraintType2["PRISMATIC"] = 6] = "PRISMATIC";
969
+ PhysicsConstraintType2[PhysicsConstraintType2["SIX_DOF"] = 7] = "SIX_DOF";
970
+ return PhysicsConstraintType2;
971
+ })(PhysicsConstraintType || {});
972
+ class HavokPlugin {
973
+ constructor(useDeltaForWorldStep = true, hpInjection) {
974
+ /** Name of the plugin. */
975
+ __publicField(this, "name", "HavokPlugin");
976
+ /** @internal Reference to the Havok WASM module (`@babylonjs/havok`). */
977
+ __publicField(this, "_hknp");
978
+ /** The native Lite physics world, created when the plugin is attached to a scene. */
979
+ __publicField(this, "world", null);
980
+ /** @internal Fixed timestep used when delta stepping is disabled, and by force scaling. */
981
+ __publicField(this, "_fixedTimeStep", 1 / 60);
982
+ /** @internal Whether to advance the world by the elapsed frame time (vs a fixed `1/60`). */
983
+ __publicField(this, "_useDeltaForWorldStep");
984
+ /** @internal Whether the injected Havok module looks usable. */
985
+ __publicField(this, "_supported");
986
+ this._useDeltaForWorldStep = useDeltaForWorldStep;
987
+ this._hknp = hpInjection;
988
+ this._supported = hpInjection != null && typeof hpInjection !== "function";
989
+ }
990
+ /** Whether the plugin has a usable Havok module. */
991
+ isSupported() {
992
+ return this._supported;
993
+ }
994
+ /** Babylon.js physics plugin version (Havok is V2). */
995
+ getPluginVersion() {
996
+ return 2;
997
+ }
998
+ /** Set the fixed timestep used when delta stepping is disabled. Matches Babylon.js. */
999
+ setTimeStep(timeStep) {
1000
+ this._fixedTimeStep = timeStep;
1001
+ if (this.world && !this._useDeltaForWorldStep) {
1002
+ setPhysicsTimestep(this.world, timeStep);
1003
+ }
1004
+ }
1005
+ /** Get the fixed timestep. Matches Babylon.js. */
1006
+ getTimeStep() {
1007
+ return this._fixedTimeStep;
1008
+ }
1009
+ /** Set the world gravity. */
1010
+ setGravity(gravity, worldPosition) {
1011
+ if (this.world) {
1012
+ setPhysicsGravity(this.world, gravity, worldPosition);
1013
+ }
1014
+ }
1015
+ /**
1016
+ * Manual single-step entry point. Babylon Lite drives world stepping
1017
+ * internally (once per rendered frame, via the scene's before-render hook),
1018
+ * so calling this directly is unsupported — use {@link Scene.enablePhysics}.
1019
+ */
1020
+ executeStep() {
1021
+ return unsupported("HavokPlugin.executeStep", "Babylon Lite advances the world internally each frame; manual stepping is not supported.");
1022
+ }
1023
+ /** Release the native physics world. */
1024
+ dispose() {
1025
+ if (this.world) {
1026
+ disposePhysics(this.world);
1027
+ this.world = null;
1028
+ }
1029
+ }
1030
+ /**
1031
+ * @internal Create the native Lite world for `liteScene` and select the step mode.
1032
+ *
1033
+ * Lite's native physics already steps a world by the live per-frame delta when it has no fixed
1034
+ * step (`createHavokWorld` leaves `_fixedDeltaMs === 0`), clamping to a tunnelling ceiling — which
1035
+ * is exactly Babylon.js's `useDeltaForWorldStep` behaviour. So delta stepping needs nothing extra
1036
+ * here; only the legacy fixed-step mode pins the world to {@link _fixedTimeStep}. The step is
1037
+ * driven from inside the world's own per-frame callback, so it is torn down together with the
1038
+ * world in {@link dispose} — nothing lingers on the scene after disposal.
1039
+ */
1040
+ _attachToLiteScene(liteScene, gravity) {
1041
+ if (!this._supported) {
1042
+ return unsupported("HavokPlugin", "The Havok module is not ready. `await HavokPhysics()` before constructing the plugin.");
1043
+ }
1044
+ this.world = createHavokWorld(liteScene, this._hknp, gravity);
1045
+ if (!this._useDeltaForWorldStep) {
1046
+ setPhysicsTimestep(this.world, this._fixedTimeStep);
1047
+ }
1048
+ }
1049
+ }
1050
+ class PhysicsEngine {
1051
+ constructor(plugin, gravity) {
1052
+ /** @internal */
1053
+ __publicField(this, "_plugin");
1054
+ /** Current world gravity. */
1055
+ __publicField(this, "gravity");
1056
+ this._plugin = plugin;
1057
+ this.gravity = gravity;
1058
+ }
1059
+ /** The underlying physics plugin. */
1060
+ getPhysicsPlugin() {
1061
+ return this._plugin;
1062
+ }
1063
+ /** Physics engine plugin version (Havok is V2). */
1064
+ getPluginVersion() {
1065
+ return this._plugin.getPluginVersion();
1066
+ }
1067
+ /** Set the world gravity. */
1068
+ setGravity(gravity) {
1069
+ this.gravity = gravity;
1070
+ this._plugin.setGravity(gravity);
1071
+ }
1072
+ /** Set the fixed timestep. */
1073
+ setTimeStep(newTimeStep) {
1074
+ this._plugin.setTimeStep(newTimeStep);
1075
+ }
1076
+ /** Get the fixed timestep. */
1077
+ getTimeStep() {
1078
+ return this._plugin.getTimeStep();
1079
+ }
1080
+ /** Release the underlying physics world. */
1081
+ dispose() {
1082
+ this._plugin.dispose();
1083
+ }
1084
+ }
936
1085
  class Camera extends Node {
937
1086
  constructor(name, scene) {
938
1087
  super(name, scene);
@@ -2235,14 +2384,6 @@ const DEFAULT_SKYBOX_URL = "https://assets.babylonjs.com/core/environments/backg
2235
2384
  const DEFAULT_GROUND_URL = "https://assets.babylonjs.com/core/environments/backgroundGround.png";
2236
2385
  const DEFAULT_BRDF_URL = "/brdf-lut.png";
2237
2386
  const DEFAULT_ENV_URL = "https://assets.babylonjs.com/environments/environmentSpecular.env";
2238
- function createHeadlessLite() {
2239
- return {
2240
- clearColor: { r: 0, g: 0, b: 0, a: 1 },
2241
- camera: null,
2242
- imageProcessing: { exposure: 1, contrast: 1, toneMappingEnabled: false },
2243
- animationGroups: []
2244
- };
2245
- }
2246
2387
  const _Scene = class _Scene extends AbstractScene {
2247
2388
  constructor(engine) {
2248
2389
  super();
@@ -2287,8 +2428,6 @@ const _Scene = class _Scene extends AbstractScene {
2287
2428
  __publicField(this, "_blendManager", null);
2288
2429
  __publicField(this, "_ambientColor", new Color3(0, 0, 0));
2289
2430
  __publicField(this, "_environmentIntensity", 1);
2290
- /** @internal Whether this scene is bound to a headless `NullEngine` (no GPU context). */
2291
- __publicField(this, "_headless", false);
2292
2431
  /** @internal Tracks whether at least one frame has ticked (gates `onAfterRenderObservable`). */
2293
2432
  __publicField(this, "_renderedAFrame", false);
2294
2433
  /** @internal `NodeMaterial`s whose async parse the engine drives after shadow generators are built. */
@@ -2305,10 +2444,12 @@ const _Scene = class _Scene extends AbstractScene {
2305
2444
  __publicField(this, "useRightHandedSystem", false);
2306
2445
  // ── Clip plane (Babylon.js `scene.clipPlane`) ──
2307
2446
  __publicField(this, "_clipPlane", null);
2447
+ /** @internal The active Physics V2 engine, once `enablePhysics` has wired one. */
2448
+ __publicField(this, "_physicsEngine", null);
2308
2449
  this._engine = engine;
2309
2450
  if (engine._headless) {
2310
- this._headless = true;
2311
- this._lite = createHeadlessLite();
2451
+ this._lite = createSceneContext(engine._lite, { defaultRenderTask: false });
2452
+ onBeforeRender(this._lite, (deltaMs) => this._tick(deltaMs));
2312
2453
  engine._registerScene(this);
2313
2454
  return;
2314
2455
  }
@@ -2681,7 +2822,7 @@ const _Scene = class _Scene extends AbstractScene {
2681
2822
  * exist when the scene builds.
2682
2823
  */
2683
2824
  async _loadPendingEnvironment() {
2684
- var _a;
2825
+ var _a, _b;
2685
2826
  const envUrl = ((_a = this._envTexture) == null ? void 0 : _a.url) ?? (this._defaultEnvOptions ? DEFAULT_ENV_URL : void 0);
2686
2827
  if (!envUrl) {
2687
2828
  return;
@@ -2690,7 +2831,17 @@ const _Scene = class _Scene extends AbstractScene {
2690
2831
  const skyboxUrl = (opts == null ? void 0 : opts.skyboxFromEnv) ? envUrl : (opts == null ? void 0 : opts.createSkybox) ? DEFAULT_SKYBOX_URL : void 0;
2691
2832
  const ip = this._lite.imageProcessing;
2692
2833
  const ipSnapshot = { exposure: ip.exposure, contrast: ip.contrast, toneMappingEnabled: ip.toneMappingEnabled };
2693
- if (envUrl.toLowerCase().endsWith(".dds")) {
2834
+ if (((_b = this._envTexture) == null ? void 0 : _b._envLoaderKind) === "hdr") {
2835
+ await loadHdrEnvironment(this._lite, envUrl, {
2836
+ // Forward the BJS `HDRCubeTexture` `size` as Lite's cubemap `faceSize`
2837
+ // so callers that request e.g. 512 are honoured (Lite otherwise defaults
2838
+ // to 256). Only `HDRCubeTexture` carries `_envLoaderKind === "hdr"`.
2839
+ faceSize: this._envTexture.size,
2840
+ skyboxSize: (opts == null ? void 0 : opts.skyboxSize) ?? 1e3,
2841
+ useCubemapSkybox: !!skyboxUrl,
2842
+ skipGround: !(opts == null ? void 0 : opts.createGround)
2843
+ });
2844
+ } else if (envUrl.toLowerCase().endsWith(".dds")) {
2694
2845
  await loadDdsEnvironment(this._lite, envUrl, {
2695
2846
  brdfUrl: DEFAULT_BRDF_URL,
2696
2847
  skipSkybox: !(opts == null ? void 0 : opts.createSkybox),
@@ -2753,6 +2904,44 @@ const _Scene = class _Scene extends AbstractScene {
2753
2904
  pickWithRay() {
2754
2905
  return unsupported("Scene.pickWithRay", "Synchronous CPU ray-mesh intersection is not implemented in Babylon Lite.");
2755
2906
  }
2907
+ /**
2908
+ * Babylon.js `scene.enablePhysics(gravity, plugin)`. Wires the given Havok V2
2909
+ * {@link HavokPlugin} to this scene, creating the native Lite physics world and
2910
+ * registering per-frame stepping. The plugin's `useDeltaForWorldStep` flag
2911
+ * controls whether the world advances by elapsed frame time (refresh-rate
2912
+ * independent — issue #332) or a fixed `1/60` step.
2913
+ *
2914
+ * Bodies are created with the native `createPhysicsAggregate` /
2915
+ * `createPhysicsBody` API against `scene.getPhysicsEngine().getPhysicsPlugin().world`.
2916
+ * @returns `true` once physics is enabled.
2917
+ */
2918
+ enablePhysics(gravity, plugin) {
2919
+ if (this._engine._headless) {
2920
+ return unsupported("Scene.enablePhysics", "A headless (NullEngine) scene has no render loop to step physics.");
2921
+ }
2922
+ if (!(plugin instanceof HavokPlugin)) {
2923
+ return unsupported("Scene.enablePhysics", "Pass a `HavokPlugin` instance (Babylon Lite physics is Havok-V2 only).");
2924
+ }
2925
+ const g2 = gravity ?? { x: 0, y: -9.81, z: 0 };
2926
+ plugin._attachToLiteScene(this._lite, g2);
2927
+ this._physicsEngine = new PhysicsEngine(plugin, g2);
2928
+ return true;
2929
+ }
2930
+ /** Babylon.js `scene.getPhysicsEngine()` — the active Physics V2 engine, or `null`. */
2931
+ getPhysicsEngine() {
2932
+ return this._physicsEngine;
2933
+ }
2934
+ /** Babylon.js `scene.isPhysicsEnabled()`. */
2935
+ isPhysicsEnabled() {
2936
+ return this._physicsEngine !== null;
2937
+ }
2938
+ /** Babylon.js `scene.disablePhysicsEngine()` — release the active physics world. */
2939
+ disablePhysicsEngine() {
2940
+ if (this._physicsEngine) {
2941
+ this._physicsEngine.dispose();
2942
+ this._physicsEngine = null;
2943
+ }
2944
+ }
2756
2945
  /**
2757
2946
  * Babylon.js `scene.beginDirectAnimation(target, animations, from, to, loop, speedRatio?)`.
2758
2947
  * Drives the given `Animation`s on the CPU each frame, writing onto the target's
@@ -2809,9 +2998,7 @@ const _Scene = class _Scene extends AbstractScene {
2809
2998
  }
2810
2999
  dispose() {
2811
3000
  this.onDisposeObservable.notifyObservers(this);
2812
- if (!this._headless) {
2813
- disposeScene(this._lite);
2814
- }
3001
+ disposeScene(this._lite);
2815
3002
  }
2816
3003
  };
2817
3004
  /** Babylon.js fog-mode constants. */
@@ -3551,6 +3738,55 @@ class RawTexture extends BaseTexture {
3551
3738
  return new RawTexture(data, width, height, scene);
3552
3739
  }
3553
3740
  }
3741
+ class RawTexture3D extends BaseTexture {
3742
+ constructor(data, width, height, depth, format, scene, _generateMipMaps = true, _invertY = false, _samplingMode = 3, _textureType, _creationFlags) {
3743
+ super();
3744
+ __publicField(this, "_scene");
3745
+ /** Babylon.js `RawTexture3D.is3D` — always true for a 3D texture. */
3746
+ __publicField(this, "is3D", true);
3747
+ this.format = format;
3748
+ this._scene = scene;
3749
+ const bytes = toRgbaBytes(data, width, height, depth);
3750
+ this._lite = createTexture3DFromPixels(scene.getEngine()._lite, bytes, width, height, depth);
3751
+ }
3752
+ getClassName() {
3753
+ return "RawTexture3D";
3754
+ }
3755
+ /** Gets the width of the texture. */
3756
+ get width() {
3757
+ var _a;
3758
+ return ((_a = this._lite) == null ? void 0 : _a.width) ?? 0;
3759
+ }
3760
+ /** Gets the height of the texture. */
3761
+ get height() {
3762
+ var _a;
3763
+ return ((_a = this._lite) == null ? void 0 : _a.height) ?? 0;
3764
+ }
3765
+ /** Gets the depth of the texture. */
3766
+ get depth() {
3767
+ var _a;
3768
+ return ((_a = this._lite) == null ? void 0 : _a.depth) ?? 0;
3769
+ }
3770
+ /**
3771
+ * Replace the texture's pixel contents. Babylon Lite has no in-place 3D update,
3772
+ * so the volume is re-uploaded (a fresh Lite 3D texture handle).
3773
+ */
3774
+ update(data) {
3775
+ const bytes = toRgbaBytes(data, this.width, this.height, this.depth);
3776
+ this._lite = createTexture3DFromPixels(this._scene.getEngine()._lite, bytes, this.width, this.height, this.depth);
3777
+ }
3778
+ whenReadyAsync() {
3779
+ return Promise.resolve();
3780
+ }
3781
+ }
3782
+ function toRgbaBytes(data, width, height, depth) {
3783
+ const expected = width * height * depth * 4;
3784
+ if (data === null) {
3785
+ return new Uint8Array(expected);
3786
+ }
3787
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
3788
+ return bytes.byteLength > expected ? bytes.subarray(0, expected) : bytes;
3789
+ }
3554
3790
  class DynamicTexture extends BaseTexture {
3555
3791
  constructor(name, options, scene) {
3556
3792
  super();
@@ -3616,18 +3852,25 @@ class CubeTexture {
3616
3852
  __publicField(this, "name");
3617
3853
  __publicField(this, "gammaSpace", true);
3618
3854
  __publicField(this, "level", 1);
3855
+ /**
3856
+ * @internal Which Lite environment loader the scene should route this handle
3857
+ * through at engine start. Plain `.env`/`.dds` cube maps load via
3858
+ * `loadEnvironment`/`loadDdsEnvironment`; `HDRCubeTexture` overrides this to
3859
+ * `"hdr"` so the scene picks `loadHdrEnvironment`.
3860
+ */
3861
+ __publicField(this, "_envLoaderKind", "cube");
3619
3862
  /** Fires when the cube map is "ready" (resolved on a microtask in this compat layer). */
3620
3863
  __publicField(this, "onLoadObservable", new Observable());
3621
3864
  __publicField(this, "_ready", false);
3622
3865
  this.url = url;
3623
3866
  this.name = url;
3624
- setTimeout(() => {
3867
+ queueMicrotask(() => {
3625
3868
  this._ready = true;
3626
3869
  if (onLoad) {
3627
3870
  onLoad();
3628
3871
  }
3629
3872
  this.onLoadObservable.notifyObservers(this);
3630
- }, 0);
3873
+ });
3631
3874
  }
3632
3875
  /** Babylon.js `BaseTexture.isReady()`. */
3633
3876
  isReady() {
@@ -3641,8 +3884,37 @@ class CubeTexture {
3641
3884
  }
3642
3885
  }
3643
3886
  class HDRCubeTexture {
3644
- constructor() {
3645
- unsupported("HDRCubeTexture", "Use the native `loadHdrEnvironment` API; a standalone HDR cube texture object is not wrapped.");
3887
+ constructor(url, _sceneOrEngine, size = 256, _noMipmap, _generateHarmonics, _gammaSpace, _prefilterOnLoad, onLoad) {
3888
+ /** Source URL of the `.hdr` panorama. */
3889
+ __publicField(this, "url");
3890
+ /** Requested cubemap face size (BJS `size`); forwarded to Lite's `faceSize`. */
3891
+ __publicField(this, "size");
3892
+ /** Babylon.js `coordinatesMode` (skybox = 5). Recorded for API parity. */
3893
+ __publicField(this, "coordinatesMode", 0);
3894
+ __publicField(this, "name");
3895
+ __publicField(this, "gammaSpace", true);
3896
+ __publicField(this, "level", 1);
3897
+ /** @internal Selects Lite's `loadHdrEnvironment` in the scene's env loader. */
3898
+ __publicField(this, "_envLoaderKind", "hdr");
3899
+ /** Fires when the HDR environment is "ready" (resolved on a microtask). */
3900
+ __publicField(this, "onLoadObservable", new Observable());
3901
+ __publicField(this, "_ready", false);
3902
+ this.url = url;
3903
+ this.size = size;
3904
+ this.name = url;
3905
+ queueMicrotask(() => {
3906
+ this._ready = true;
3907
+ if (onLoad) {
3908
+ onLoad();
3909
+ }
3910
+ this.onLoadObservable.notifyObservers(this);
3911
+ });
3912
+ }
3913
+ /** Babylon.js `BaseTexture.isReady()`. */
3914
+ isReady() {
3915
+ return this._ready;
3916
+ }
3917
+ dispose() {
3646
3918
  }
3647
3919
  }
3648
3920
  class RenderTargetTexture {
@@ -4102,9 +4374,24 @@ class PositionGizmo extends GizmoBase {
4102
4374
  /** @internal */
4103
4375
  __publicField(this, "_lite");
4104
4376
  __publicField(this, "_attached", null);
4377
+ __publicField(this, "_xGizmo", null);
4378
+ __publicField(this, "_yGizmo", null);
4379
+ __publicField(this, "_zGizmo", null);
4105
4380
  this._lite = createPositionGizmo(layer._engine, layer._lite);
4106
4381
  setPositionGizmoLocalCoordinates(this._lite, true);
4107
4382
  }
4383
+ /** Babylon.js `PositionGizmo.xGizmo/yGizmo/zGizmo` — the per-axis drag sub-gizmos.
4384
+ * Exposed so callers can toggle interactivity per axis (e.g. `xGizmo.isEnabled = false`
4385
+ * for a display-only gizmo). Wrappers are cached so identity is stable. */
4386
+ get xGizmo() {
4387
+ return this._xGizmo ?? (this._xGizmo = AxisDragGizmo._fromLite(this._lite.xGizmo, this._layer));
4388
+ }
4389
+ get yGizmo() {
4390
+ return this._yGizmo ?? (this._yGizmo = AxisDragGizmo._fromLite(this._lite.yGizmo, this._layer));
4391
+ }
4392
+ get zGizmo() {
4393
+ return this._zGizmo ?? (this._zGizmo = AxisDragGizmo._fromLite(this._lite.zGizmo, this._layer));
4394
+ }
4108
4395
  /** Babylon.js `Gizmo.updateGizmoRotationToMatchAttachedMesh` — orient widgets to the node's local axes. */
4109
4396
  set updateGizmoRotationToMatchAttachedMesh(value) {
4110
4397
  setPositionGizmoLocalCoordinates(this._lite, value);
@@ -4132,9 +4419,22 @@ class RotationGizmo extends GizmoBase {
4132
4419
  /** @internal */
4133
4420
  __publicField(this, "_lite");
4134
4421
  __publicField(this, "_attached", null);
4422
+ __publicField(this, "_xGizmo", null);
4423
+ __publicField(this, "_yGizmo", null);
4424
+ __publicField(this, "_zGizmo", null);
4135
4425
  this._lite = createRotationGizmo(layer._engine, layer._lite);
4136
4426
  setRotationGizmoLocalCoordinates(this._lite, true);
4137
4427
  }
4428
+ /** Babylon.js `RotationGizmo.xGizmo/yGizmo/zGizmo` — the per-plane rotation sub-gizmos. */
4429
+ get xGizmo() {
4430
+ return this._xGizmo ?? (this._xGizmo = PlaneRotationGizmo._fromLite(this._lite.xGizmo, this._layer));
4431
+ }
4432
+ get yGizmo() {
4433
+ return this._yGizmo ?? (this._yGizmo = PlaneRotationGizmo._fromLite(this._lite.yGizmo, this._layer));
4434
+ }
4435
+ get zGizmo() {
4436
+ return this._zGizmo ?? (this._zGizmo = PlaneRotationGizmo._fromLite(this._lite.zGizmo, this._layer));
4437
+ }
4138
4438
  /** Babylon.js `Gizmo.updateGizmoRotationToMatchAttachedMesh` — orient widgets to the node's local axes. */
4139
4439
  set updateGizmoRotationToMatchAttachedMesh(value) {
4140
4440
  setRotationGizmoLocalCoordinates(this._lite, value);
@@ -4162,9 +4462,22 @@ class ScaleGizmo extends GizmoBase {
4162
4462
  /** @internal */
4163
4463
  __publicField(this, "_lite");
4164
4464
  __publicField(this, "_attached", null);
4465
+ __publicField(this, "_xGizmo", null);
4466
+ __publicField(this, "_yGizmo", null);
4467
+ __publicField(this, "_zGizmo", null);
4165
4468
  this._lite = createScaleGizmo(layer._engine, layer._lite);
4166
4469
  setScaleGizmoLocalCoordinates(this._lite, true);
4167
4470
  }
4471
+ /** Babylon.js `ScaleGizmo.xGizmo/yGizmo/zGizmo` — the per-axis scale sub-gizmos. */
4472
+ get xGizmo() {
4473
+ return this._xGizmo ?? (this._xGizmo = AxisScaleGizmo._fromLite(this._lite.xGizmo, this._layer));
4474
+ }
4475
+ get yGizmo() {
4476
+ return this._yGizmo ?? (this._yGizmo = AxisScaleGizmo._fromLite(this._lite.yGizmo, this._layer));
4477
+ }
4478
+ get zGizmo() {
4479
+ return this._zGizmo ?? (this._zGizmo = AxisScaleGizmo._fromLite(this._lite.zGizmo, this._layer));
4480
+ }
4168
4481
  /** Babylon.js `Gizmo.updateGizmoRotationToMatchAttachedMesh` — orient widgets to the node's local axes. */
4169
4482
  set updateGizmoRotationToMatchAttachedMesh(value) {
4170
4483
  setScaleGizmoLocalCoordinates(this._lite, value);
@@ -4286,6 +4599,13 @@ function nodeLite(value) {
4286
4599
  const n2 = value;
4287
4600
  return n2._lite ?? n2._node ?? null;
4288
4601
  }
4602
+ function wrapSubGizmo(ctor, lite, layer) {
4603
+ const g2 = Object.create(ctor.prototype);
4604
+ g2._lite = lite;
4605
+ g2._layer = layer;
4606
+ g2._attached = null;
4607
+ return g2;
4608
+ }
4289
4609
  class AxisDragGizmo extends GizmoBase {
4290
4610
  constructor(dragAxis, color, layer) {
4291
4611
  super(layer);
@@ -4297,6 +4617,19 @@ class AxisDragGizmo extends GizmoBase {
4297
4617
  color: [color.r, color.g, color.b]
4298
4618
  });
4299
4619
  }
4620
+ /** @internal Wrap an existing Lite axis-drag gizmo (a composite's sub-gizmo). */
4621
+ static _fromLite(lite, layer) {
4622
+ return wrapSubGizmo(AxisDragGizmo, lite, layer);
4623
+ }
4624
+ /** Babylon.js `IAxisDragGizmo.isEnabled` — when false the gizmo is non-interactive
4625
+ * (no drag, and no GPU hover picking), while its meshes stay visible and keep
4626
+ * following the attached node. Toggles the underlying Lite pointer-drag. */
4627
+ get isEnabled() {
4628
+ return this._lite.drag.enabled;
4629
+ }
4630
+ set isEnabled(value) {
4631
+ this._lite.drag.enabled = value;
4632
+ }
4300
4633
  get attachedMesh() {
4301
4634
  return this._attached;
4302
4635
  }
@@ -4325,6 +4658,17 @@ class PlaneRotationGizmo extends GizmoBase {
4325
4658
  color: [color.r, color.g, color.b]
4326
4659
  });
4327
4660
  }
4661
+ /** @internal Wrap an existing Lite plane-rotation gizmo (a composite's sub-gizmo). */
4662
+ static _fromLite(lite, layer) {
4663
+ return wrapSubGizmo(PlaneRotationGizmo, lite, layer);
4664
+ }
4665
+ /** Babylon.js `IPlaneRotationGizmo.isEnabled` — toggles interactivity (drag + hover pick). */
4666
+ get isEnabled() {
4667
+ return this._lite.drag.enabled;
4668
+ }
4669
+ set isEnabled(value) {
4670
+ this._lite.drag.enabled = value;
4671
+ }
4328
4672
  get attachedMesh() {
4329
4673
  return this._attached;
4330
4674
  }
@@ -4353,6 +4697,17 @@ class PlaneDragGizmo extends GizmoBase {
4353
4697
  color: [color.r, color.g, color.b]
4354
4698
  });
4355
4699
  }
4700
+ /** @internal Wrap an existing Lite plane-drag gizmo (a composite's sub-gizmo). */
4701
+ static _fromLite(lite, layer) {
4702
+ return wrapSubGizmo(PlaneDragGizmo, lite, layer);
4703
+ }
4704
+ /** Babylon.js `IPlaneDragGizmo.isEnabled` — toggles interactivity (drag + hover pick). */
4705
+ get isEnabled() {
4706
+ return this._lite.drag.enabled;
4707
+ }
4708
+ set isEnabled(value) {
4709
+ this._lite.drag.enabled = value;
4710
+ }
4356
4711
  get attachedMesh() {
4357
4712
  return this._attached;
4358
4713
  }
@@ -4381,6 +4736,17 @@ class AxisScaleGizmo extends GizmoBase {
4381
4736
  color: [color.r, color.g, color.b]
4382
4737
  });
4383
4738
  }
4739
+ /** @internal Wrap an existing Lite axis-scale gizmo (a composite's sub-gizmo). */
4740
+ static _fromLite(lite, layer) {
4741
+ return wrapSubGizmo(AxisScaleGizmo, lite, layer);
4742
+ }
4743
+ /** Babylon.js `IAxisScaleGizmo.isEnabled` — toggles interactivity (drag + hover pick). */
4744
+ get isEnabled() {
4745
+ return this._lite.drag.enabled;
4746
+ }
4747
+ set isEnabled(value) {
4748
+ this._lite.drag.enabled = value;
4749
+ }
4384
4750
  get attachedMesh() {
4385
4751
  return this._attached;
4386
4752
  }
@@ -6971,11 +7337,6 @@ class PointsCloudSystem {
6971
7337
  unsupported("PointsCloudSystem", "Point-cloud systems are not implemented in Babylon Lite. For Gaussian splats use the native splat loaders.");
6972
7338
  }
6973
7339
  }
6974
- class HavokPlugin {
6975
- constructor() {
6976
- unsupported("HavokPlugin", "Use the native `createHavokWorld` API; the Babylon.js physics-plugin object is not wrapped.");
6977
- }
6978
- }
6979
7340
  class PhysicsAggregate {
6980
7341
  constructor() {
6981
7342
  unsupported("PhysicsAggregate", "Use the native `createPhysicsAggregate` API instead of the Babylon.js PhysicsAggregate class.");
@@ -7236,7 +7597,12 @@ export {
7236
7597
  PerformanceMonitor,
7237
7598
  PhysicsAggregate,
7238
7599
  PhysicsBody,
7600
+ PhysicsConstraintType,
7601
+ PhysicsEngine,
7602
+ PhysicsMotionType,
7603
+ PhysicsPrestepType,
7239
7604
  PhysicsShape,
7605
+ PhysicsShapeType,
7240
7606
  Plane,
7241
7607
  PlaneDragGizmo,
7242
7608
  PlaneRotationGizmo,
@@ -7252,6 +7618,7 @@ export {
7252
7618
  Quaternion,
7253
7619
  QuinticEase,
7254
7620
  RawTexture,
7621
+ RawTexture3D,
7255
7622
  Ray,
7256
7623
  RecastJSPlugin,
7257
7624
  RectAreaLight,