@onerjs/core 8.52.9 → 8.53.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { type Nullable } from "../../types.js";
2
2
  import { type InternalTexture } from "../../Materials/Textures/internalTexture.js";
3
- import { type ThinEngine } from "../../Engines/thinEngine.js";
3
+ import { type AbstractEngine } from "../../Engines/abstractEngine.js";
4
4
  import { type IRenderTargetTexture, type RenderTargetWrapper } from "../../Engines/renderTargetWrapper.js";
5
5
  import { ThinTexture } from "./thinTexture.js";
6
6
  import { type TextureSize, type RenderTargetCreationOptions } from "./textureCreationOptions.js";
@@ -19,12 +19,12 @@ export declare class ThinRenderTargetTexture extends ThinTexture implements IRen
19
19
  /**
20
20
  * Instantiates a new ThinRenderTargetTexture.
21
21
  * Tiny helper class to wrap a RenderTargetWrapper in a texture.
22
- * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache and to hold on the associated RTT
23
- * @param engine Define the internalTexture to wrap
22
+ * This can be used as an internal texture wrapper to benefit from the cache and to hold on the associated RTT
23
+ * @param engine Define the engine used to create and host the render target
24
24
  * @param size Define the size of the RTT to create
25
25
  * @param options Define rendertarget options
26
26
  */
27
- constructor(engine: ThinEngine, size: TextureSize, options: RenderTargetCreationOptions);
27
+ constructor(engine: AbstractEngine, size: TextureSize, options: RenderTargetCreationOptions);
28
28
  /**
29
29
  * Resize the texture to a new desired size.
30
30
  * Be careful as it will recreate all the data in the new texture.
@@ -13,8 +13,8 @@ export class ThinRenderTargetTexture extends ThinTexture {
13
13
  /**
14
14
  * Instantiates a new ThinRenderTargetTexture.
15
15
  * Tiny helper class to wrap a RenderTargetWrapper in a texture.
16
- * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache and to hold on the associated RTT
17
- * @param engine Define the internalTexture to wrap
16
+ * This can be used as an internal texture wrapper to benefit from the cache and to hold on the associated RTT
17
+ * @param engine Define the engine used to create and host the render target
18
18
  * @param size Define the size of the RTT to create
19
19
  * @param options Define rendertarget options
20
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"thinRenderTargetTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/thinRenderTargetTexture.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IAMpD;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;;;OAOG;IACH,YAAY,MAAkB,EAAE,IAAiB,EAAE,OAAoC;QACnF,KAAK,CAAC,IAAI,CAAC,CAAC;QAnBR,kBAAa,GAAkC,IAAI,CAAC;QAoBxD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,IAAiB;QAC3B,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAElB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACvG,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAa,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACa,kBAAkB;QAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,yBAAyB,CAAC;IACrC,CAAC;IAED;;;OAGG;IACa,OAAO,CAAC,uBAAuB,GAAG,KAAK;QACnD,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAE1B,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { type Nullable } from \"../../types\";\r\nimport { type InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\n\r\nimport { type ThinEngine } from \"../../Engines/thinEngine\";\r\nimport { type IRenderTargetTexture, type RenderTargetWrapper } from \"../../Engines/renderTargetWrapper\";\r\nimport { ThinTexture } from \"./thinTexture\";\r\nimport { type TextureSize, type RenderTargetCreationOptions } from \"./textureCreationOptions\";\r\n\r\n/**\r\n * This is a tiny helper class to wrap a RenderTargetWrapper in a texture\r\n * usable as the input of an effect.\r\n */\r\nexport class ThinRenderTargetTexture extends ThinTexture implements IRenderTargetTexture {\r\n private readonly _renderTargetOptions: RenderTargetCreationOptions;\r\n\r\n private _renderTarget: Nullable<RenderTargetWrapper> = null;\r\n private _size: TextureSize;\r\n\r\n /**\r\n * Gets the render target wrapper associated with this render target\r\n */\r\n public get renderTarget(): Nullable<RenderTargetWrapper> {\r\n return this._renderTarget;\r\n }\r\n\r\n /**\r\n * Instantiates a new ThinRenderTargetTexture.\r\n * Tiny helper class to wrap a RenderTargetWrapper in a texture.\r\n * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache and to hold on the associated RTT\r\n * @param engine Define the internalTexture to wrap\r\n * @param size Define the size of the RTT to create\r\n * @param options Define rendertarget options\r\n */\r\n constructor(engine: ThinEngine, size: TextureSize, options: RenderTargetCreationOptions) {\r\n super(null);\r\n this._engine = engine;\r\n this._renderTargetOptions = options;\r\n this.resize(size);\r\n }\r\n\r\n /**\r\n * Resize the texture to a new desired size.\r\n * Be careful as it will recreate all the data in the new texture.\r\n * @param size Define the new size. It can be:\r\n * - a number for squared texture,\r\n * - an object containing { width: number, height: number }\r\n */\r\n public resize(size: TextureSize): void {\r\n this._renderTarget?.dispose();\r\n this._renderTarget = null;\r\n this._texture = null;\r\n this._size = size;\r\n\r\n if (this._engine) {\r\n this._renderTarget = this._engine.createRenderTargetTexture(this._size, this._renderTargetOptions);\r\n }\r\n this._texture = this.renderTarget!.texture;\r\n }\r\n\r\n /**\r\n * Get the underlying lower level texture from Babylon.\r\n * @returns the internal texture\r\n */\r\n public override getInternalTexture(): Nullable<InternalTexture> {\r\n return this._texture;\r\n }\r\n\r\n /**\r\n * Get the class name of the texture.\r\n * @returns \"ThinRenderTargetTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"ThinRenderTargetTexture\";\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n * @param disposeOnlyFramebuffers if set to true it will dispose only the frame buffers (default: false)\r\n */\r\n public override dispose(disposeOnlyFramebuffers = false): void {\r\n this._renderTarget?.dispose(true);\r\n this._renderTarget = null;\r\n\r\n if (!disposeOnlyFramebuffers) {\r\n super.dispose();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"thinRenderTargetTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/thinRenderTargetTexture.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IAMpD;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;;;OAOG;IACH,YAAY,MAAsB,EAAE,IAAiB,EAAE,OAAoC;QACvF,KAAK,CAAC,IAAI,CAAC,CAAC;QAnBR,kBAAa,GAAkC,IAAI,CAAC;QAoBxD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,IAAiB;QAC3B,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAElB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACvG,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAa,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACa,kBAAkB;QAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,yBAAyB,CAAC;IACrC,CAAC;IAED;;;OAGG;IACa,OAAO,CAAC,uBAAuB,GAAG,KAAK;QACnD,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAE1B,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { type Nullable } from \"../../types\";\r\nimport { type InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\n\r\nimport { type AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport { type IRenderTargetTexture, type RenderTargetWrapper } from \"../../Engines/renderTargetWrapper\";\r\nimport { ThinTexture } from \"./thinTexture\";\r\nimport { type TextureSize, type RenderTargetCreationOptions } from \"./textureCreationOptions\";\r\n\r\n/**\r\n * This is a tiny helper class to wrap a RenderTargetWrapper in a texture\r\n * usable as the input of an effect.\r\n */\r\nexport class ThinRenderTargetTexture extends ThinTexture implements IRenderTargetTexture {\r\n private readonly _renderTargetOptions: RenderTargetCreationOptions;\r\n\r\n private _renderTarget: Nullable<RenderTargetWrapper> = null;\r\n private _size: TextureSize;\r\n\r\n /**\r\n * Gets the render target wrapper associated with this render target\r\n */\r\n public get renderTarget(): Nullable<RenderTargetWrapper> {\r\n return this._renderTarget;\r\n }\r\n\r\n /**\r\n * Instantiates a new ThinRenderTargetTexture.\r\n * Tiny helper class to wrap a RenderTargetWrapper in a texture.\r\n * This can be used as an internal texture wrapper to benefit from the cache and to hold on the associated RTT\r\n * @param engine Define the engine used to create and host the render target\r\n * @param size Define the size of the RTT to create\r\n * @param options Define rendertarget options\r\n */\r\n constructor(engine: AbstractEngine, size: TextureSize, options: RenderTargetCreationOptions) {\r\n super(null);\r\n this._engine = engine;\r\n this._renderTargetOptions = options;\r\n this.resize(size);\r\n }\r\n\r\n /**\r\n * Resize the texture to a new desired size.\r\n * Be careful as it will recreate all the data in the new texture.\r\n * @param size Define the new size. It can be:\r\n * - a number for squared texture,\r\n * - an object containing { width: number, height: number }\r\n */\r\n public resize(size: TextureSize): void {\r\n this._renderTarget?.dispose();\r\n this._renderTarget = null;\r\n this._texture = null;\r\n this._size = size;\r\n\r\n if (this._engine) {\r\n this._renderTarget = this._engine.createRenderTargetTexture(this._size, this._renderTargetOptions);\r\n }\r\n this._texture = this.renderTarget!.texture;\r\n }\r\n\r\n /**\r\n * Get the underlying lower level texture from Babylon.\r\n * @returns the internal texture\r\n */\r\n public override getInternalTexture(): Nullable<InternalTexture> {\r\n return this._texture;\r\n }\r\n\r\n /**\r\n * Get the class name of the texture.\r\n * @returns \"ThinRenderTargetTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"ThinRenderTargetTexture\";\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n * @param disposeOnlyFramebuffers if set to true it will dispose only the frame buffers (default: false)\r\n */\r\n public override dispose(disposeOnlyFramebuffers = false): void {\r\n this._renderTarget?.dispose(true);\r\n this._renderTarget = null;\r\n\r\n if (!disposeOnlyFramebuffers) {\r\n super.dispose();\r\n }\r\n }\r\n}\r\n"]}
@@ -887,6 +887,18 @@ export function PrepareDefinesForFrameBoundValues(scene, engine, material, defin
887
887
  defines.markAsUnprocessed();
888
888
  }
889
889
  }
890
+ // Sizing the bone-uniform budget reserves room for the rest of the vertex stage (base uniforms +
891
+ // plugins + clip planes), mirroring GetGaussianSplattingMaxPartCount's reserve. Multiview duplicates
892
+ // the per-eye view/projection, so it reserves more.
893
+ const _BoneUniformBaseReserve = 40;
894
+ const _BoneUniformMultiviewReserve = 64;
895
+ // PrepareDefinesForBones is on the defines-evaluation hot path, so the budget diagnostic only
896
+ // re-evaluates when its inputs change for a skeleton: the WeakMap stores the last-seen signature
897
+ // (bone count + multiview bit) and the steady-state cost is one lookup plus an integer compare.
898
+ const _BoneUniformBudgetCheckedSignature = new WeakMap();
899
+ // The diagnostic logs once PER SKELETON: its message varies by skeleton/bone-count/caps/multiview,
900
+ // so Logger's per-message limit would not dedupe it. Weak collections let disposed skeletons be GC'd.
901
+ const _BoneUniformBudgetWarnedSkeletons = new WeakSet();
890
902
  /**
891
903
  * Prepares the defines for bones
892
904
  * @param mesh The mesh containing the geometry data we will draw
@@ -902,11 +914,43 @@ export function PrepareDefinesForBones(mesh, defines) {
902
914
  else {
903
915
  defines["BonesPerMesh"] = mesh.skeleton.bones.length + 1;
904
916
  defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
905
- const prePassRenderer = mesh.getScene().prePassRenderer;
917
+ const scene = mesh.getScene();
918
+ const prePassRenderer = scene.prePassRenderer;
906
919
  if (prePassRenderer && prePassRenderer.enabled) {
907
920
  const nonExcluded = prePassRenderer.excludedSkinnedMesh.indexOf(mesh) === -1;
908
921
  defines["BONES_VELOCITY_ENABLED"] = nonExcluded;
909
922
  }
923
+ // Bones stored as vertex uniforms cost one mat4 (4 vectors) each, drawn from the same
924
+ // maxVertexUniformVectors budget as the rest of the vertex stage. Some drivers fail SILENTLY
925
+ // when a program exceeds that budget — the skinned mesh just never renders, with no error or
926
+ // warning (see Babylon's "A Mysterious Case of Skinned Mesh Disappearances"). Multiview is the
927
+ // common trigger: it duplicates per-eye matrices and adds driver overhead, shrinking the
928
+ // practical budget below what the device reports.
929
+ //
930
+ // Hot-path note: everything below the signature gate runs only when the inputs change for
931
+ // this skeleton (bone count or MULTIVIEW — already set on the defines by
932
+ // PrepareDefinesForFrameBoundValues, which materials run before the attributes/bones
933
+ // prepare). Steady-state cost: one WeakMap lookup and an integer compare.
934
+ const isMultiview = defines["MULTIVIEW"] === true;
935
+ const signature = defines["BonesPerMesh"] * 2 + (isMultiview ? 1 : 0);
936
+ if (_BoneUniformBudgetCheckedSignature.get(mesh.skeleton) !== signature) {
937
+ _BoneUniformBudgetCheckedSignature.set(mesh.skeleton, signature);
938
+ const maxVertexUniformVectors = scene.getEngine().getCaps().maxVertexUniformVectors;
939
+ if (maxVertexUniformVectors && !_BoneUniformBudgetWarnedSkeletons.has(mesh.skeleton)) {
940
+ const boneUniformVectors = defines["BonesPerMesh"] * 4;
941
+ const reservedVertexUniforms = isMultiview ? _BoneUniformMultiviewReserve : _BoneUniformBaseReserve;
942
+ const available = Math.max(maxVertexUniformVectors - reservedVertexUniforms, 0);
943
+ // Overflow the budget outright, or — under multiview, where the practical budget is
944
+ // smaller than reported — merely dominate it (bones alone are a third or more of nominal).
945
+ if (boneUniformVectors > available || (isMultiview && boneUniformVectors * 3 > maxVertexUniformVectors)) {
946
+ _BoneUniformBudgetWarnedSkeletons.add(mesh.skeleton);
947
+ Logger.Warn(`Skeleton "${mesh.skeleton.name}": ${mesh.skeleton.bones.length} bones stored as vertex uniforms use ` +
948
+ `${boneUniformVectors} of ~${available} usable uniform vectors${isMultiview ? " (multiview)" : ""} on a ` +
949
+ `device reporting ${maxVertexUniformVectors}. This can exceed the GPU vertex-uniform limit and make the ` +
950
+ `mesh silently fail to render. Set skeleton.useTextureToStoreBoneMatrices = true to store bone matrices in a texture.`);
951
+ }
952
+ }
953
+ }
910
954
  }
911
955
  }
912
956
  else {