firtoz / react-three-renderer

Render into a three.js canvas using React.
https://toxicfork.github.com/react-three-renderer-example/
MIT License
1.49k stars 155 forks source link

Render object3D with custom data #198

Closed dav92lee closed 7 years ago

dav92lee commented 7 years ago

Hello friends,

I am trying to render a object3D component with my own data onto the three scene. Using the OBJLoader built into threejs, the callback provides me a variable representing an object3D from the loaded file. However, I am uncertain on how I should go about adding it to the scene.

As of right now, I am assigning the object3D variable in the render function to a variable. <object3D ref={(model) => { this.model = model; }}/> And in the callback of the loader function, I am assigning the obj to the ref:

        const objLoader = new this.THREE.OBJLoader();
        objLoader.load(
            './model.obj',
            (object) => {
                console.log(object)
                this.model = object
            }
            //todo: onprogres,
            //todo: onerror
        )

To no avail :(. Maybe it's because i don't have a material assigned to this object3D; however, I am struggling to place that as a child of the object3D.

dav92lee commented 7 years ago

whoops just saw this: https://github.com/toxicFork/react-three-renderer/issues/57