WhoAteDaCake

PositionKind return unusual coordinates

Recommended Posts

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.