When I showing block model with SPS, There are distortion in the shape of cube, how can I solve it?

Hello everyone

I use SPS for building my Block model but there are some problem when I zoom in to the Block Model as can be seen in the following gif:

chrome-capture (6)

and here is my code :

const myAttributeFunction = function (particle, i) {

  particle.position.x = xxx + parseFloat(cubes[i].X);
  particle.position.y = 1200 + parseFloat(cubes[i].Z);
  particle.position.z = zzz - parseFloat(cubes[i].Y);
  particle.color = new BABYLON.Color3(1, parseFloat(cubes[i].G), 1);

const cube = new BABYLON.BoxBuilder.CreateBox(
  { height: 1, width: 1, depth: 1 },

let SPS = new BABYLON.SolidParticleSystem("SPS", scene, {
  isPickable: true,
// SPS.billboard = true;

SPS.addShape(cube, nb, { positionFunction: myAttributeFunction });
let mat = new BABYLON.StandardMaterial("mat", scene);
// mat.diffuseColor = new BABYLON.Color3.Lerp(color1, color2, cubes[i].G);
mat.specularColor = new BABYLON.Color3(0, 0, 0);
let mesh = SPS.buildMesh();
mesh.material = mat;

SPS.refreshVisibleSize(); // force the SPS BBox recomputation

// SPS.computeParticleRotation = false;
// SPS.computeParticleColor = false;
// SPS.computeParticleTexture = false;
   // SPS.computeParticleVertex = true;


how can I solve this problem?

Pinging @jerome (Happy new year buddy :))

1 Like

Happy new year to you :slightly_smiling_face:
Thank you so much for pinging Jerome.

1 Like

Could you please provide a PG repro ? and tell me what is the problem ?

and happy new year to everyone :smiley:

1 Like

Happy new year to you. and thank you for your helping.

here is PG : Babylon.js Playground

as can be seen in the PG when I try to move the camera the cubes have distortion. I mean they are not like a cube.

and here is the problem just for one cube: https://playground.babylonjs.com/#BN86FQ#1

It is to do with setting _currentTarget values, which is a private variable and future compatibility cannot be guaranteed, see https://playground.babylonjs.com/#BN86FQ#2


Hi @JohnK , Thanks a lot for helping me
But again the problem exist as can be seen here : https://playground.babylonjs.com/#BN86FQ#4

my problem is with the SPS particle not the cube.

Size of numbers is a problem, smaller numbers work https://playground.babylonjs.com/#BN86FQ#5

Dividing numbers by 100 works https://playground.babylonjs.com/#BN86FQ#6 but not by 10

@Arash_Bagheri You will need to play around with scale and positioning https://playground.babylonjs.com/#BN86FQ#9

Thanks a lot @JohnK ,
I am trying to show the cube in actual location of latitude and longitude when it converted to xyz coordinate, and there is a height map over my model, and the height map also has an actual numbers. and I don’t want to scale them, is it any way except scaling?

Sorry, scaling is the only way I can think of. A cube of size 10 viewed from a distance of 10 will appear on screen the same as one of size 100 from a distance of 100.

1 Like