Can A-frame 'look-at' component look at the default camera?
Can A-frame 'look-at' component look at the default camera?
Is it possible to get the a-frame look-at
component to look at the default camera? Since it does not have an ID or a class by default I don't know how to target it.
look-at
I have tried adding [camera]
as the selector value as per the docs like so;
[camera]
<a-text
value="Look at test"
look-at="[camera]">
</a-text>
but it does not seem to work for me. I feel I am missing something obvious here.
Any help appreciated
2 Answers
2
What you are doing is correct, but at the time the look-at
component is initialized, the camera is not yet on the scene.
look-at
Try creating a component, which will wait until the scene is loaded,
this.el.sceneEl.addEventListener("loaded", (e)=>{....
or at least for window.onload
.
window.onload
Check it out here.
<a-text value="Look at test" look-at="#cam"></a-text>
<a-camera id="cam"></a-camera>
this should work.....
Hi Karan, thanks for your answer but that does not work, the default camera does not have an ID. I have just found another very similar component that can look at the default camera github.com/blairmacintyre/aframe-look-at-billboard-component. I'm not going to post that as an answer just in case there is a way to do it with the original mentioned in the question.
– Nick
Jun 29 at 9:37
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– slm
2 days ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thank you Piotr, that does work. It seems a shame you cannot use the component in that way without writing a script. Thanks for the explanation. If anyone is looking for a way to do this without writing a script, this similar component will do it github.com/blairmacintyre/aframe-look-at-billboard-component
– Nick
Jun 29 at 10:15