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

Why is Mesh.showBoundingBox not available as a prop? #345

Open
nene opened this issue Jan 14, 2025 · 2 comments
Open

Why is Mesh.showBoundingBox not available as a prop? #345

nene opened this issue Jan 14, 2025 · 2 comments
Assignees

Comments

@nene
Copy link

nene commented Jan 14, 2025

I was hoping to write the following:

function MyComp() {
  return (<box name="myBox" showBoundingBox={true} />);
}

But no such prop is available. So instead I need to do the following:

function MyComp() {
  const ref = useRef(null);
  useEffect(() => {
    if (ref.current) {
      ref.current.showBoundingBox = true;
    }
  }, []);
  return (<box name="myBox" ref={ref} />);
}

Interestingly showSubMeshesBoundingBox prop is available. But no showBoundingBox.

Using version 3.2.2 of react-babylonjs.

@brianzinn
Copy link
Owner

Well, agree it should be there. The reason it's not showing is because it's declared here:
https://github.com/BabylonJS/Babylon.js/blob/84580a00705d4513393988e3eb2cab0f2d9053b3/packages/dev/core/src/Rendering/boundingBoxRenderer.ts#L75

I'm using ts-morph to generate the props. Let me look into it. The prop you did find is declared on AbstractMesh:
https://github.com/BabylonJS/Babylon.js/blob/84580a00705d4513393988e3eb2cab0f2d9053b3/packages/dev/core/src/Meshes/abstractMesh.ts#L602

@brianzinn
Copy link
Owner

it's a bit hideous, but can be added following same way instancedBuffers were added, since it's declared in a different area of the code base of babylon.js and dynamically applied:
https://github.com/brianzinn/react-babylonjs/blob/master/packages/react-babylonjs/tools/generate-code.ts#L509

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

No branches or pull requests

2 participants