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

Customizing JSCadFixture #25

Open
r-bt opened this issue Jul 20, 2024 · 3 comments
Open

Customizing JSCadFixture #25

r-bt opened this issue Jul 20, 2024 · 3 comments

Comments

@r-bt
Copy link
Collaborator

r-bt commented Jul 20, 2024

I'd like to be able to custom JSCadFixture. Specifically the size, background colour, and positioning of the ThreeJS camera.

I was wondering are there any thoughts about the best way to do this. My initial ideas are either:

  1. Expose props on the existing JSCadFixture component
  2. Integrating with react-three-fiber to be able to declaratively specify lights, camera, etc

Other thoughts?

@seveibar
Copy link
Contributor

seveibar commented Jul 20, 2024

I like the idea of exposing props for basic customization, but I would recommend we create a component called <JscadMesh> or <JscadThreeMesh> that neatly integrates into ThreeJS, it's not too hard to do this but it does require some knowledge of how fiber works. I can try to give some pointers in a moment

@seveibar
Copy link
Contributor

seveibar commented Jul 20, 2024

So the basic idea of the implementation is this, @r-bt lmk if you're interested in implementing otherwise I can probably implement ~tomorrow

import { createRoot } from "../somewhere-in-jscad-fiber"

export const JscadThreeMesh = ({ children }) => {
  const threeMesh = useMemo(() => {
    const jscadElms = []
    createRoot(children, jscadElms)
    const mesh = convertCsgToThree(jscadElms)
  }, [])
  return <primitive mesh={mesh} />
}

Usage would be like:

<Scene>
  <Light {/* ... */} />
  <JscadThreeMesh>
    <Cube size={1} />
  </JscadThreeMesh>
</Scene>

@r-bt
Copy link
Collaborator Author

r-bt commented Jul 20, 2024

Awesome, I can give it a shot

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