@onerjs/core 8.44.3 → 8.44.5
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/Bones/skeleton.d.ts +6 -0
- package/Bones/skeleton.js +10 -0
- package/Bones/skeleton.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.js +5 -1
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/imageProcessing.js +1 -1
- package/Materials/imageProcessing.js.map +1 -1
- package/Materials/materialHelper.functions.js +3 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Meshes/abstractMesh.js +9 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.js +12 -8
- package/Meshes/mesh.js.map +1 -1
- package/Misc/tools.js +1 -1
- package/Misc/tools.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +1 -0
- package/Particles/solidParticleSystem.js +32 -2
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Rendering/boundingBoxRenderer.js +9 -4
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.js +7 -4
- package/Rendering/edgesRenderer.js.map +1 -1
- package/node.d.ts +14 -0
- package/node.js +17 -10
- package/node.js.map +1 -1
- package/package.json +1 -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
|
-
|
|
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
|
-
|
|
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) : [];
|