I am trying to build a React component to render the Leapmotion boneHand model from 'leapjs-plugins'. As advertised in the boneHand plugin demo code below should be the easiest way to add hands to a THREE.js application. In vanila JS this was straightforward with a canvas element.
// At the simplest:
Leap.loop()
.use('boneHand', {
targetEl: document.body,
arm: true
});
However I found that in React, I need to use React-Three-Renderer (R3R), which is a Three.js wrapper. I am running into issues trying to inject the Leap boneHand meshes into the Scene that is created by R3R in the React component Render method, just like bellow.
There is an optional parameter to provide a THREE.scene to Leap.loop(). I need to get the reference of the scene component above into an instance variable like so
<scene ref={node => this.setupScene(node)}>
Now, the first thing that I tried was to use React lifecycle componentDidMount method to start the Leap.loop
`componentDidMount(){
console.log('componentDidMount');
console.log(this.leapScene);
(window.controller = new Leap.Controller())
.use('boneHand', {
scene: this.leapScene,
opacity: 3,
arm : false
})
.connect()
// Leap.loop({background: true}) // ALTERNATIVE CODE THAT YIELDS THE SAME ERRORS
// .use('boneHand', {
// scene: this.leapScene,
// opacity: 3,
// arm : false
// })
// .connect()
}`
This approach gives 86 errors of this type, which must refer to the different elements of the hand models.
_index.js:2178 THREE.Object3D.add: object not an instance of THREE.Object3D. ./node_modules/leapjs-plugins/nodemodules/three/three.js.THREE.Mesh
I'm not sure what it is but it seems an internal incompatible type in the Leap.controller or Leap plugin.
Hello,
I am trying to build a React component to render the Leapmotion boneHand model from 'leapjs-plugins'. As advertised in the boneHand plugin demo code below should be the easiest way to add hands to a THREE.js application. In vanila JS this was straightforward with a canvas element.
However I found that in React, I need to use React-Three-Renderer (R3R), which is a Three.js wrapper. I am running into issues trying to inject the Leap boneHand meshes into the Scene that is created by R3R in the React component Render method, just like bellow.
There is an optional parameter to provide a THREE.scene to Leap.loop(). I need to get the reference of the scene component above into an instance variable like so
<scene ref={node => this.setupScene(node)}>
Now, the first thing that I tried was to use React lifecycle
componentDidMount
method to start the Leap.loop`componentDidMount(){
}`
This approach gives 86 errors of this type, which must refer to the different elements of the hand models.
_index.js:2178 THREE.Object3D.add: object not an instance of THREE.Object3D. ./node_modules/leapjs-plugins/nodemodules/three/three.js.THREE.Mesh
I'm not sure what it is but it seems an internal incompatible type in the Leap.controller or Leap plugin.
Any ideas about this?