WhoAteDaCake

PositionKind return unusual coordinates

3 posts in this topic

function addSphere(scene, { x, y, z }: Object, diameter: number = 0.05, color = new BABYLON.Color3(0, 0, 0)) {
  const sphere = BABYLON.MeshBuilder.CreateSphere("sphere", { diameter }, scene);
  const material = new BABYLON.StandardMaterial("texture1", scene);
  
  material.diffuseColor =  color;
  sphere.position = new BABYLON.Vector3(x, y, z);
  sphere.material = material;
}

const positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);

const zeroCoord = {
    x: positions[0],
    y: positions[1],
    z: positions[2],
 };
 addSphere(scene, zeroCoord, 1);

Demo 

As you can see in the code, I am just trying to get vertices of the foot. and the placing a sphere on the first vertice of the foot.

But for some reason, as can be seen in demo, the sphere is added somewhere not even remotely close of the foot.

You can download the mesh here.

Why is this happening ? I've been trying to fix this for two days now, but I can't seem to do it.

 

Edit: I am using babylonjs exported for blender.

Edit2: Added playground url  https://www.babylonjs-playground.com/#EEKFSK#2

Share this post


Link to post
Share on other sites

Hi, 

In fact, your mesh is exported from your 3d software with a scale, rotation, and translation. The vertex buffer come from your original mesh. Maybe you can try something like resetXfrom(in max), don't know the equivalent in blender. Hope this helps. 

"meshes":[{"name":"Sym_trie Sock sock","id":"Sym_trie Sock sock","materialId":"feet.Female_Mesh","billboardMode":0,
"position":[-1.4393,-0.0012,-0.0036],
"rotation":[-1.5708,0,0],
"scaling":[0.069,0.069,0.069],"isVisible":true,"freezeWorldMatrix":false,"isEnabled":true,"checkCollisions":false,"receiveShadows":false
,"positions":[38.3717,-10.4411,0.0043,

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.