Trying to align HTML content over a Threejs background where I need to match a div with a 3d plane.
Following this post I was able to get the div to follow the plane position, but i m still having trouble with the orientation even following advices from this post
So far this is my code:
screenPlane.updateWorldMatrix()
screenPlane.getWorldPosition(tempV)
screenPlane.getWorldQuaternion(tempQuat)
tempRotationV3.copy(screenPlane.up ).applyQuaternion(tempQuat)
tempV.project(camera)
const x = (tempV.x * .5 + .5) * container.clientWidth
const y = (tempV.y * -.5 + .5) * container.clientHeight
div.style.transform = `translate(-50%, -50%) translate(${x}px,${y}px) `
div.style.transform += ` rotateX(${tempRotationV3.x}rad) rotateY(-${tempRotationV3.y}rad) rotateZ(${tempRotationV3.z}rad)`
Position is good but orientation is clearly broken:
Here is a jsfiddle demo of the position only
Any help would be much appreciated.