supermedium / aframe-react

:atom: Build virtual reality experiences with A-Frame and React.
https://ngokevin.github.io/aframe-react-boilerplate/
MIT License
1.42k stars 151 forks source link

How to create own mouse-control component #56

Closed ufon closed 7 years ago

ufon commented 7 years ago

Hello! I'm try to work some mouse look component but have a problem. (component: https://github.com/alexrkass/no-click-look-controls) When i try get canvas element i have undefined. but a-scene i get it perfectly.

var sceneEl = this.el.sceneEl;
var canvasEl = sceneEl.canvas;
console.log(canvasEl,sceneEl);

in react component i have:

              <Scene className="aframebox" embedded={true} >
                <a-entity  camera no-click-look-controls="maxyaw:0.5π; maxpitch:0.2π;" ></a-entity>
                <a-sky src="images/city.jpg" rotation="0 -130 0"></a-sky>
              </Scene>

image

Thank u for any help!

ngokevin commented 7 years ago

That component is probably outdated, you'll need to get it updated. Maybe file an issue?

Make sure you're running code within A-Frame components so that the canvas and scene are initialized: https://aframe.io/docs/0.4.0/guides/using-javascript-and-dom-apis.html#where-to-place-javascript-code-for-a-frame