@onerjs/core 8.31.6 → 8.31.8

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.
Files changed (52) hide show
  1. package/Animations/animation.d.ts +2 -1
  2. package/Animations/animation.js +3 -2
  3. package/Animations/animation.js.map +1 -1
  4. package/Behaviors/Cameras/interpolatingBehavior.d.ts +2 -1
  5. package/Behaviors/Cameras/interpolatingBehavior.js +2 -2
  6. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  7. package/Cameras/geospatialCamera.d.ts +12 -3
  8. package/Cameras/geospatialCamera.js +91 -36
  9. package/Cameras/geospatialCamera.js.map +1 -1
  10. package/Cameras/geospatialCameraMovement.d.ts +6 -2
  11. package/Cameras/geospatialCameraMovement.js +10 -10
  12. package/Cameras/geospatialCameraMovement.js.map +1 -1
  13. package/Engines/abstractEngine.js +2 -2
  14. package/Engines/abstractEngine.js.map +1 -1
  15. package/Engines/thinEngine.js +1 -1
  16. package/Engines/thinEngine.js.map +1 -1
  17. package/FrameGraph/Node/nodeRenderGraph.d.ts +22 -5
  18. package/FrameGraph/Node/nodeRenderGraph.js +39 -18
  19. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  20. package/FrameGraph/Passes/pass.d.ts +2 -0
  21. package/FrameGraph/Passes/pass.js +2 -0
  22. package/FrameGraph/Passes/pass.js.map +1 -1
  23. package/FrameGraph/Passes/renderPass.d.ts +2 -0
  24. package/FrameGraph/Passes/renderPass.js +4 -0
  25. package/FrameGraph/Passes/renderPass.js.map +1 -1
  26. package/FrameGraph/frameGraph.d.ts +13 -4
  27. package/FrameGraph/frameGraph.js +45 -5
  28. package/FrameGraph/frameGraph.js.map +1 -1
  29. package/FrameGraph/frameGraphRenderTarget.d.ts +1 -0
  30. package/FrameGraph/frameGraphRenderTarget.js +3 -0
  31. package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
  32. package/FrameGraph/frameGraphTask.d.ts +6 -0
  33. package/FrameGraph/frameGraphTask.js +15 -0
  34. package/FrameGraph/frameGraphTask.js.map +1 -1
  35. package/FrameGraph/frameGraphTypes.d.ts +2 -0
  36. package/FrameGraph/frameGraphTypes.js.map +1 -1
  37. package/Materials/Node/nodeMaterial.js +3 -0
  38. package/Materials/Node/nodeMaterial.js.map +1 -1
  39. package/Materials/materialHelper.functions.d.ts +29 -7
  40. package/Materials/materialHelper.functions.js +59 -24
  41. package/Materials/materialHelper.functions.js.map +1 -1
  42. package/Materials/shaderMaterial.d.ts +1 -0
  43. package/Materials/shaderMaterial.js +6 -17
  44. package/Materials/shaderMaterial.js.map +1 -1
  45. package/Meshes/mesh.js +1 -1
  46. package/Meshes/mesh.js.map +1 -1
  47. package/Misc/screenshotTools.js +2 -8
  48. package/Misc/screenshotTools.js.map +1 -1
  49. package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +1 -0
  50. package/ShadersWGSL/iblVoxelGrid.vertex.js +53 -64
  51. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  52. package/package.json +1 -1
@@ -12,6 +12,7 @@ import type { Material } from "./material.js";
12
12
  import type { Nullable } from "../types.js";
13
13
  import type { MorphTargetManager } from "../Morph/morphTargetManager.js";
14
14
  import type { Color3 } from "../Maths/math.color.js";
15
+ import type { Geometry } from "../Meshes/geometry.js";
15
16
  export * from "./materialHelper.functions.pure.js";
16
17
  /**
17
18
  * Binds the fog information from the scene to the effect for the given mesh.
@@ -180,13 +181,34 @@ export declare function HandleFallbacksForShadows(defines: any, fallbacks: Effec
180
181
  */
181
182
  export declare function GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
182
183
  /**
183
- * Helper used to prepare vertex pulling metadata defines (stride, offset, component count)
184
- * This should be called when USE_VERTEX_PULLING is enabled to properly configure buffer access
185
- * @param mesh The mesh being rendered
186
- * @param defines The defines object to update
187
- * @param attributeNames Array of attribute names to configure (e.g., ["position", "normal"])
188
- */
189
- export declare function PrepareDefinesForVertexPullingMetadata(mesh: AbstractMesh, defines: any, attributeNames?: string[]): void;
184
+ * Interface representing metadata for vertex pulling
185
+ */
186
+ export interface IVertexPullingMetadata {
187
+ /**
188
+ * Offset in vertex buffer where data starts
189
+ */
190
+ offset: number;
191
+ /**
192
+ * Stride between elements in the vertex buffer
193
+ */
194
+ stride: number;
195
+ /**
196
+ * Type of the vertex buffer (e.g., float, int)
197
+ */
198
+ type: number;
199
+ }
200
+ /**
201
+ * Prepares vertex pulling uniforms for the given attributes and mesh
202
+ * @param geometry The geometry containing the vertex buffers
203
+ * @returns A map of attribute names to their metadata, or null if unavailable
204
+ */
205
+ export declare function PrepareVertexPullingUniforms(geometry: Geometry): Nullable<Map<string, IVertexPullingMetadata>>;
206
+ /**
207
+ * Bind vertex pulling uniforms to the effect
208
+ * @param effect The effect to bind the uniforms to
209
+ * @param metadata The vertex pulling metadata
210
+ */
211
+ export declare function BindVertexPullingUniforms(effect: Effect, metadata: Map<string, IVertexPullingMetadata>): void;
190
212
  /**
191
213
  * Helper used to prepare the list of defines associated with misc. values for shader compilation
192
214
  * @param mesh defines the current mesh
@@ -5,7 +5,7 @@ import { LightConstants } from "../Lights/lightConstants.js";
5
5
  import { PrepareDefinesForClipPlanes } from "./clipPlaneMaterialHelper.js";
6
6
  import { MaterialFlags } from "./materialFlags.js";
7
7
  import { Texture } from "./Textures/texture.js";
8
- import { GetTypeByteLength } from "../Buffers/bufferUtils.js";
8
+ import { Vector3 } from "../Maths/math.vector.js";
9
9
  // For backwards compatibility, we export everything from the pure version of this file.
10
10
  export * from "./materialHelper.functions.pure.js";
11
11
  // Temps
@@ -502,34 +502,69 @@ export function HandleFallbacksForShadows(defines, fallbacks, maxSimultaneousLig
502
502
  export function GetFogState(mesh, scene) {
503
503
  return scene.fogEnabled && mesh.applyFog && scene.fogMode !== 0;
504
504
  }
505
+ // Store vertex pulling metadata per geometry
506
+ const _VertexPullingMetadataCache = new WeakMap();
505
507
  /**
506
- * Helper used to prepare vertex pulling metadata defines (stride, offset, component count)
507
- * This should be called when USE_VERTEX_PULLING is enabled to properly configure buffer access
508
- * @param mesh The mesh being rendered
509
- * @param defines The defines object to update
510
- * @param attributeNames Array of attribute names to configure (e.g., ["position", "normal"])
508
+ * Prepares vertex pulling uniforms for the given attributes and mesh
509
+ * @param geometry The geometry containing the vertex buffers
510
+ * @returns A map of attribute names to their metadata, or null if unavailable
511
511
  */
512
- export function PrepareDefinesForVertexPullingMetadata(mesh, defines, attributeNames = ["position"]) {
513
- if (!defines["USE_VERTEX_PULLING"]) {
514
- return;
515
- }
516
- const geometry = mesh.geometry;
512
+ export function PrepareVertexPullingUniforms(geometry) {
517
513
  if (!geometry) {
518
- return;
514
+ return null;
515
+ }
516
+ const vertexBuffers = geometry.getVertexBuffers();
517
+ if (!vertexBuffers) {
518
+ return null;
519
+ }
520
+ // Check cache first
521
+ let metadata = _VertexPullingMetadataCache.get(geometry);
522
+ if (!metadata) {
523
+ metadata = new Map();
524
+ _VertexPullingMetadataCache.set(geometry, metadata);
519
525
  }
520
- for (const attributeName of attributeNames) {
521
- const vertexBuffer = geometry.getVertexBuffer(attributeName);
522
- if (!vertexBuffer) {
523
- continue;
526
+ else {
527
+ // Return cached metadata if it exists and hasn't changed
528
+ let needsUpdate = false;
529
+ for (const vb in vertexBuffers) {
530
+ if (!metadata.has(vb)) {
531
+ needsUpdate = true;
532
+ break;
533
+ }
534
+ }
535
+ if (!needsUpdate) {
536
+ return metadata;
524
537
  }
525
- const upperName = attributeName.toUpperCase();
526
- const sizeInBytes = GetTypeByteLength(vertexBuffer.type);
527
- // Calculate stride in float32 elements
528
- const stride = vertexBuffer.effectiveByteStride / sizeInBytes;
529
- defines[`${upperName}_STRIDE`] = stride || vertexBuffer.getSize();
530
- // Calculate offset in float32 elements
531
- const offset = vertexBuffer.effectiveByteOffset / sizeInBytes;
532
- defines[`${upperName}_OFFSET`] = offset;
538
+ }
539
+ // Build or update metadata
540
+ for (const vb in vertexBuffers) {
541
+ const vertexBuffer = vertexBuffers[vb];
542
+ if (vertexBuffer) {
543
+ const offset = vertexBuffer.byteOffset;
544
+ const stride = vertexBuffer.byteStride;
545
+ const type = vertexBuffer.type;
546
+ metadata.set(vb, {
547
+ offset: offset,
548
+ stride: stride,
549
+ type: type,
550
+ });
551
+ }
552
+ }
553
+ return metadata;
554
+ }
555
+ /**
556
+ * Bind vertex pulling uniforms to the effect
557
+ * @param effect The effect to bind the uniforms to
558
+ * @param metadata The vertex pulling metadata
559
+ */
560
+ export function BindVertexPullingUniforms(effect, metadata) {
561
+ if (!metadata || !effect) {
562
+ return;
563
+ }
564
+ for (const [attribute, data] of metadata.entries()) {
565
+ const uniformName = `vp_${attribute}_info`;
566
+ // Pack into vec3: (offset, stride, type)
567
+ effect.setVector3(uniformName, new Vector3(data.offset, data.stride, data.type));
533
568
  }
534
569
  }
535
570
  /**