Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed an aframe scene into a div

Tags:

aframe

I am trying to embed a .OBJ model into an element so that it is confined to a specific width and height, instead of a full page canvas. I'm trying to replicate the "scene" embedded into the header of https://sketchfab.com/. I would like the camera in my scene to pan round the central axis of the model(just like in the example).

I'm having trouble accomplishing this... so far, I am able to successful load the following afame scene into my browser:

<a-scene>
  <a-box color="#6173F4" width="4" height="10" depth="2"></a-box>
</a-scene>

But I can't get the scene to be resized and confined within a div or within a canvas (i think canvas would be better?).


I tried:
1. to nest the a-scene into a div and size the div in CSS

<div class="aframebox"><a-scene></a-scene></div>
2. I also tried to following which I guess is no longer part of version 0.3.0?
<a-scene canvas="height: 50; width: 50"></a-scene> 0.2.0 information


If someone could please let me know how to do this I would really appreciate it,
Thank you.

like image 412
AlextheTryhard Avatar asked Oct 27 '25 16:10

AlextheTryhard


1 Answers

A-Frame's embedded component is intended to remove fullscreen styles, allowing you to style/size the canvas as needed.

<a-scene embedded></a-scene>

More details here: https://aframe.io/docs/0.3.0/components/embedded.html

like image 198
Don McCurdy Avatar answered Oct 29 '25 19:10

Don McCurdy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!