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:
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(
"cube",
{ height: 1, width: 1, depth: 1 },
scene
);
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;
cube.dispose();
SPS.initParticles();
SPS.setParticles();
SPS.refreshVisibleSize(); // force the SPS BBox recomputation
// SPS.computeParticleRotation = false;
// SPS.computeParticleColor = false;
// SPS.computeParticleTexture = false;
// SPS.computeParticleVertex = true;
SPS.mesh.freezeWorldMatrix();
SPS.mesh.freezeNormals();
how can I solve this problem?
Pinging @jerome (Happy new year buddy :))
1 Like
Happy new year to you
Thank you so much for pinging Jerome.
1 Like
jerome
January 5, 2021, 4:54pm
4
Hello,
Could you please provide a PG repro ? and tell me what is the problem ?
and happy new year to everyone
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
JohnK
January 7, 2021, 10:54am
7
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
2 Likes
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.
JohnK
January 9, 2021, 9:20am
9
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
JohnK
January 9, 2021, 9:25am
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?
JohnK
January 9, 2021, 12:30pm
12
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