Hey there, I'm diving into the world of three.js and I'm on a mission to recreate the awesome interactive 3D experience that Google has with their game at
Check it out - they have this cool Three.js scene taking up the entire screen with text and buttons seamlessly placed on top (which are clearly HTML divs, not generated via JS)
I've checked out some resources like
and similar questions but I'm struggling to figure out the right approach. I really don't want to create my UI elements in Three.js - I simply want to use regular HTML.
So far, I've created my Three.js canvas and added it to my document so it fills the full width/height of my window:
var controls, camera, renderer, scene, container, w, h;
renderer = new THREE.WebGLRenderer()
// container = document.getElementById('canvas');
container = window;
w = container.innerWidth;
h = container.innerHeight;
renderer.setSize(w, h)
renderer.setPixelRatio( window.devicePixelRatio );
document.body.appendChild(renderer.domElement);
And then, using my existing HTML:
<body>
<div id="ui">
<p id="message">Test to change</p>
</div>
I find that the UI div stays on top no matter how I adjust the CSS or z-index:
https://i.sstatic.net/UdVda.png
How can I achieve the same effect as Google with HTML overlaid on my three.js scene? What am I missing?
I really want my canvas to fill the whole window just like Google's does but I'm struggling to make it happen by creating the canvas element beforehand and trying to attach everything through JS.