-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
track the fact that a canvas is provided so we don't overwrite its size #1322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1cb1725
90f343f
78fdc3e
c44ac63
154452a
aab0734
7a82e7d
d42ce03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Embedded scene • A-Frame</title> | ||
| <meta name="description" content="Embedded scene • A-Frame"> | ||
| <script src="../../dist/aframe.js"></script> | ||
| <style> | ||
| #mycanvas { | ||
| width: 200px; | ||
| height: 200px; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <h2>Through the looking glass.</h2> | ||
| <!-- this canvas element may be anywhere in the document --> | ||
| <canvas id="mycanvas"></canvas> | ||
|
|
||
| <p>’Twas brillig, and the slithy toves | ||
| Did gyre and gimble in the wabe: | ||
| All mimsy were the borogoves, | ||
| And the mome raths outgrabe. | ||
| “Beware the Jabberwock, my son! | ||
| The jaws that bite, the claws that catch! | ||
| Beware the Jubjub bird, and shun | ||
| The frumious Bandersnatch!” | ||
| </p> | ||
|
|
||
| <!-- This scene will be rendered inside the referenced canvas element --> | ||
| <a-scene canvas="canvas: #mycanvas"> | ||
| <a-sphere position="0 1.25 -1" radius="1.25" color="#EF2D5E"></a-sphere> | ||
| <a-box position="-1 0.5 1" rotation="0 45 0" width="1" height="1" depth="1" color="#4CC3D9"></a-box> | ||
| <a-cylinder position="1 0.75 1" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder> | ||
| <a-plane rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane> | ||
| <!-- Sky --> | ||
| <a-sky color="#ecfcf4"></a-sky> | ||
| </a-scene> | ||
|
|
||
| <script> | ||
| var scene = document.querySelector('a-scene'); | ||
| function check () { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't want you want to call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm adding it, just to confirm that aframe's resize logic doesn't overwrite the user provided canvas dimensions. |
||
| var canvas = document.getElementById('mycanvas'); | ||
| console.log(canvas.width, canvas.height); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. necessary? |
||
| } | ||
| if (scene.hasLoaded) { | ||
| check(); | ||
| } else { | ||
| scene.addEventListener('loaded', check); | ||
| } | ||
| window.addEventListener('resize', check); | ||
| </script> | ||
| </body> | ||
| </html> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move the canvas into the scene element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to show that that's not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd encourage it to wrap everything up nicely.