Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new Box3().setFromObject() returns NaN #32

Open
enheit opened this issue Dec 4, 2018 · 2 comments
Open

new Box3().setFromObject() returns NaN #32

enheit opened this issue Dec 4, 2018 · 2 comments

Comments

@enheit
Copy link

enheit commented Dec 4, 2018

When I try to calcualte the boundingBox for the TextGeometry using .setFromObject method it returns an object with NaN valueses.

   const geometry = createGeometry({
     text: 'Lorem ipsum',
     align: 'left',
     width: 2000,
     font: font,
   });

   const material = new RawShaderMaterial(SDFShader({
     map: texture,
     transparent: true,
     color: 0xfffffff,
   }))

   const mesh = new Mesh(geometry, material);

   const box = new Box3();
   box.setFromObject(mesh);

   console.log(box); // { min: { x: NaN, y: NaN, z: NaN }, max: { x: NaN, y: NaN, z: NaN } }

UPDATE 1:
I found that three-bmfont-text attribute uses itemSize = 2. But Box3 expects Vector3 as well as itemSize = 3.

@enheit
Copy link
Author

enheit commented Dec 4, 2018

I found that on the last iteration on this line z coordinate is undefined.
image
image

@jmatsushita
Copy link

I think this PR solves this issue #5

You can give it a try with yarn add github:kig/three-bmfont-text#vec4-positions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants