@onerjs/core 8.44.4 → 8.44.6

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 (40) hide show
  1. package/Bones/skeleton.d.ts +6 -0
  2. package/Bones/skeleton.js +10 -0
  3. package/Bones/skeleton.js.map +1 -1
  4. package/Engines/Extensions/engine.rawTexture.js +2 -2
  5. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  6. package/Engines/abstractEngine.js +19 -9
  7. package/Engines/abstractEngine.js.map +1 -1
  8. package/Engines/thinEngine.js.map +1 -1
  9. package/FlowGraph/flowGraphCoordinator.js +5 -1
  10. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  11. package/FlowGraph/serialization.js +0 -1
  12. package/FlowGraph/serialization.js.map +1 -1
  13. package/Materials/Textures/equiRectangularCubeTexture.d.ts +5 -0
  14. package/Materials/Textures/equiRectangularCubeTexture.js +19 -0
  15. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  16. package/Materials/materialHelper.functions.js +3 -0
  17. package/Materials/materialHelper.functions.js.map +1 -1
  18. package/Meshes/abstractMesh.js +9 -0
  19. package/Meshes/abstractMesh.js.map +1 -1
  20. package/Meshes/mesh.js +12 -8
  21. package/Meshes/mesh.js.map +1 -1
  22. package/Misc/tools.js +1 -1
  23. package/Misc/tools.js.map +1 -1
  24. package/Particles/solidParticleSystem.d.ts +1 -0
  25. package/Particles/solidParticleSystem.js +32 -2
  26. package/Particles/solidParticleSystem.js.map +1 -1
  27. package/Physics/v2/Plugins/havokPlugin.d.ts +5 -3
  28. package/Physics/v2/Plugins/havokPlugin.js +9 -5
  29. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  30. package/Physics/v2/physicsBody.d.ts +5 -3
  31. package/Physics/v2/physicsBody.js +7 -5
  32. package/Physics/v2/physicsBody.js.map +1 -1
  33. package/Rendering/boundingBoxRenderer.js +9 -4
  34. package/Rendering/boundingBoxRenderer.js.map +1 -1
  35. package/Rendering/edgesRenderer.js +7 -4
  36. package/Rendering/edgesRenderer.js.map +1 -1
  37. package/package.json +1 -1
  38. package/Meshes/Compression/test/integration/draco.test.d.ts +0 -1
  39. package/Meshes/Compression/test/integration/draco.test.js +0 -30
  40. package/Meshes/Compression/test/integration/draco.test.js.map +0 -1
@@ -282,9 +282,12 @@ export class SolidParticleSystem {
282
282
  const meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
283
283
  const meshInd = mesh.getIndices();
284
284
  const meshUV = mesh.getVerticesData(this._getUVKind(mesh, options?.uvKind ?? 0));
285
- const meshCol = mesh.getVerticesData(VertexBuffer.ColorKind);
285
+ let meshCol = mesh.getVerticesData(VertexBuffer.ColorKind);
286
286
  const meshNor = mesh.getVerticesData(VertexBuffer.NormalKind);
287
287
  const storage = options && options.storage ? options.storage : null;
288
+ // Normalize vertex colors to RGBA (4 components) since the code below always reads 4 components per color.
289
+ // Source meshes (e.g. from glTF) may provide RGB (3 components) vertex colors.
290
+ meshCol = this._normalizeMeshVertexColors(mesh, meshPos, meshCol);
288
291
  let f = 0; // facet counter
289
292
  const totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
290
293
  // compute size from number
@@ -605,6 +608,30 @@ export class SolidParticleSystem {
605
608
  target.push(sp);
606
609
  return sp;
607
610
  }
611
+ _normalizeMeshVertexColors(mesh, meshPos, meshCol) {
612
+ if (!meshCol) {
613
+ return meshCol;
614
+ }
615
+ const vertexCount = meshPos.length / 3;
616
+ if (!vertexCount) {
617
+ return meshCol;
618
+ }
619
+ const colorBuffer = mesh.getVertexBuffer(VertexBuffer.ColorKind);
620
+ const colorStride = colorBuffer ? colorBuffer.getSize() : Math.round(meshCol.length / vertexCount);
621
+ if (colorStride !== 3 || meshCol.length !== vertexCount * 3) {
622
+ return meshCol;
623
+ }
624
+ const rgba = new Float32Array(vertexCount * 4);
625
+ for (let i = 0; i < vertexCount; i++) {
626
+ const rgbIndex = i * 3;
627
+ const rgbaIndex = i * 4;
628
+ rgba[rgbaIndex] = meshCol[rgbIndex];
629
+ rgba[rgbaIndex + 1] = meshCol[rgbIndex + 1];
630
+ rgba[rgbaIndex + 2] = meshCol[rgbIndex + 2];
631
+ rgba[rgbaIndex + 3] = 1;
632
+ }
633
+ return rgba;
634
+ }
608
635
  /**
609
636
  * Adds some particles to the SPS from the model shape. Returns the shape id.
610
637
  * Please read the doc : https://doc.babylonjs.com/features/featuresDeepDive/particles/solid_particle_system/immutable_sps
@@ -622,9 +649,12 @@ export class SolidParticleSystem {
622
649
  const meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
623
650
  const meshInd = mesh.getIndices();
624
651
  const meshUV = mesh.getVerticesData(VertexBuffer.UVKind);
625
- const meshCol = mesh.getVerticesData(VertexBuffer.ColorKind);
652
+ let meshCol = mesh.getVerticesData(VertexBuffer.ColorKind);
626
653
  const meshNor = mesh.getVerticesData(VertexBuffer.NormalKind);
627
654
  this.recomputeNormals = meshNor ? false : true;
655
+ // Normalize vertex colors to RGBA (4 components) since _meshBuilder always reads 4 components per color.
656
+ // Source meshes (e.g. from glTF) may provide RGB (3 components) vertex colors.
657
+ meshCol = this._normalizeMeshVertexColors(mesh, meshPos, meshCol);
628
658
  const indices = Array.from(meshInd);
629
659
  const shapeNormals = meshNor ? Array.from(meshNor) : [];
630
660
  const shapeColors = meshCol ? Array.from(meshCol) : [];