While it is commonly believed that three.js requires the HTML5 <canvas>
element, I have found success in using a simple <div>
by assigning height and width properties and then adding the WebGLRenderer.domElement
as its child within the HTML structure. Surprisingly, when I try to use a <canvas>
instead of a <div>
, the scene remains entirely black.
What could be causing this difference? How should the approach change in each scenario?
My hypothesis is that <div>
elements, when properly sized, can function similarly to a canvas while still offering the benefits of an <canvas>
element. However, full support for the HTML5 <canvas>
element from the browser may be necessary for proper functionality. It would be reassuring to verify this theory with someone more knowledgeable in the subject.