@babylonjs/lite-compat 1.12.0-preview → 1.14.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.d.ts CHANGED
@@ -1366,15 +1366,16 @@ export declare class DirectionalLight extends Light {
1366
1366
  constructor(name: stri
1367
1367
  /**
1368
1368
  * Babylon.js `DynamicTexture` — a canvas-backed texture. Draw into
1369
1369
  * `getContext()`, then call `update()` to upload the canvas pixels to the GPU.
1370
- * Backed by Babylon Lite's pixel-texture path.
1370
+ * Backed by Babylon Lite's `createDynamicTexture` / `updateDynamicTexture`, which
1371
+ * blit the canvas straight to the GPU via `copyExternalImageToTexture` (no
1372
+ * `getImageData` CPU readback).
1371
1373
  */
1372
1374
  export declare class DynamicTexture extends BaseTexture {
1373
1375
  private readonly _scene;
1374
1376
  private readonly _canvas;
1375
1377
  private readonly _context;
1376
1378
  private readonly _width;
1377
- private readonly _height;
1378
- constructor(name: string, options: {
1379
+ private readonly _height;
1379
1380
  constructor(name: string, options: {
1380
1381
  width: number;
1381
1382
  height: number;
1382
1383
  }, scene: Scene);
@@ -1386,8 +1387,13 @@ export declare class DynamicTexture extends BaseTexture {
1386
1387
  };
1387
1388
  /** Draw `text` and refresh the GPU texture. */
1388
1389
  drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string | null): void;
1389
- /** Upload the current canvas pixels to the GPU. */
1390
- update(): void;
1390
+ /**
1391
+ * Blit the current canvas pixels straight to the GPU texture (no CPU readback).
1392
+ * @param invertY - Flip V so a top-down canvas samples upright. Default `true` (Babylon.js parity).
1393
+ * @param premulAlpha - Treat the upload as premultiplied alpha. Default `false`.
1394
+ * @param _allowGPUOptimization - Accepted for Babylon.js signature parity; the blit is already GPU-direct, so this is a no-op.
1395
+ */
1396
+ update(invertY?: boolean, premulAlpha?: boolean, _allowGPUOptimization?: boolean): void;
1391
1397
  whenReadyAsync(): Promise<void>;
1392
1398
  }
1393
1399
 
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 { VERSION, 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";
6
+ import { VERSION, 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, createDynamicTexture, updateDynamicTexture, 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;
@@ -3871,6 +3871,9 @@ class DynamicTexture extends BaseTexture {
3871
3871
  __publicField(this, "_context");
3872
3872
  __publicField(this, "_width");
3873
3873
  __publicField(this, "_height");
3874
+ /** @internal Branded Lite dynamic texture; aliases `_lite` and is the only
3875
+ * handle `updateDynamicTexture` accepts. */
3876
+ __publicField(this, "_dyn");
3874
3877
  this.name = name;
3875
3878
  this._scene = scene;
3876
3879
  this._width = options.width;
@@ -3883,6 +3886,8 @@ class DynamicTexture extends BaseTexture {
3883
3886
  throw new Error("DynamicTexture: 2D canvas context unavailable.");
3884
3887
  }
3885
3888
  this._context = ctx;
3889
+ this._dyn = createDynamicTexture(scene.getEngine()._lite, options.width, options.height);
3890
+ this._lite = this._dyn;
3886
3891
  }
3887
3892
  getClassName() {
3888
3893
  return "DynamicTexture";
@@ -3905,15 +3910,14 @@ class DynamicTexture extends BaseTexture {
3905
3910
  ctx.fillText(text, x, y);
3906
3911
  this.update();
3907
3912
  }
3908
- /** Upload the current canvas pixels to the GPU. */
3909
- update() {
3910
- const image = this._context.getImageData(0, 0, this._width, this._height);
3911
- const data = new Uint8Array(image.data.buffer);
3912
- if (!this._lite) {
3913
- this._lite = createTexture2DFromPixels(this._scene.getEngine()._lite, data, this._width, this._height);
3914
- } else {
3915
- updateTexture2DFromPixels(this._scene.getEngine()._lite, this._lite, data);
3916
- }
3913
+ /**
3914
+ * Blit the current canvas pixels straight to the GPU texture (no CPU readback).
3915
+ * @param invertY - Flip V so a top-down canvas samples upright. Default `true` (Babylon.js parity).
3916
+ * @param premulAlpha - Treat the upload as premultiplied alpha. Default `false`.
3917
+ * @param _allowGPUOptimization - Accepted for Babylon.js signature parity; the blit is already GPU-direct, so this is a no-op.
3918
+ */
3919
+ update(invertY = true, premulAlpha = false, _allowGPUOptimization = false) {
3920
+ updateDynamicTexture(this._scene.getEngine()._lite, this._dyn, this._canvas, { invertY, premultiplyAlpha: premulAlpha });
3917
3921
  }
3918
3922
  whenReadyAsync() {
3919
3923
  return Promise.resolve();