Rhino3dmLoader in react-three-fiber?

Can anyone get Rhino3dmLoader working with react-three-fiber?

I have the following sandbox example: https://codesandbox.io/s/rhino3dmloader-in-react-three-fiber-vhh1x?file=/src/index.js

I am getting the following error: Uncaught SyntaxError: Unexpected token '<'

I am pretty much just doing:

import { Rhino3dmLoader } from 'three/examples/jsm/loaders/3DMLoader'

const model = useLoader(Rhino3dmLoader, url)

in threejs rhino needs some extra files to be present in your public folder, it doesn’t just work ootb: Rhino3dmLoader in react-three-fiber (forked) - CodeSandbox

also, the return value is an object3d, containing all the meshes and materials. if you want to put an already existing thing into the scene you use primitive: react-three-fiber/api.md at e925b35f58dea8a98875e2306a5ee85c65cd5e4b · pmndrs/react-three-fiber · GitHub

function Rhino3dmLogo({ url, ...props }) {
  const model = useLoader(Rhino3dmLoader, url, (loader) => loader.setLibraryPath('/rhino3dm/'))
  return <primitive object={model} />

always check three docs and examples. the examples can be a bit tough to untangle but they’ll have everything you’re missing if something doesn’t work.

1 Like

Thanks! Perfect. Andrew

Hey folks! This code pen seems to be broken now. Any ideas on the source? It looks like an error retrieving the Rhino model, but all fo the sources look correct.

i deleted it, both the file and the rhino wasm encoder, because i only have 500mb caps on codesandbox. the code is still valid. just put model and wasm into your public, load it.

here’s a working example: r3f gltf fonts (forked) - CodeSandbox