For a detailed explanation of what I am attempting to achieve, please refer to my previous question here.
In summary:
My goal is to have HTML elements rotate in sync with OrbitControls
to give the illusion that these elements are attached to a globe and move along with it (similar to map markers on a 3D earth above specific countries).
I managed to accomplish this using the THREE.js CSS3DRenderer
, successfully positioning the HTML elements on the 3D globe based on latitude and longitude calculations, making them rotate with the globe when using OrbitControls
.
The issue
However, the problem I'm facing is that the HTML elements scale dynamically based on their proximity to the camera. While this may enhance the sense of distance, it complicates sizing consistency and causes blurriness/pixelation for text and SVGs inside the elements.
Desired solution
I am seeking a way to disable this scaling behavior so that the HTML elements retain their original size regardless of position within the 3D renderer created by CSS3DRenderer
.
I anticipate having to modify the CSS3DRenderer.js code for this purpose, but I lack guidance on where to begin and haven't found relevant information elsewhere.
Thank you in advance.
Snippet of my code:
Initializing the CSS3DRenderer
//CSS3D Renderer
rendererHTML = new THREE.CSS3DRenderer();
rendererHTML.setSize(WIDTH, HEIGHT);
rendererHTML.domElement.classList.add('CSS3D-container');
containerHTML = document.querySelector('.globe__container');
containerHTML.appendChild(rendererHTML.domElement);
Resize function (triggered on window resize event)
HEIGHT = sizeControlElem.getBoundingClientRect().width;
WIDTH = sizeControlElem.getBoundingClientRect().width;
renderer.setSize(WIDTH, HEIGHT);
rendererHTML.setSize(WIDTH, HEIGHT);
camera.aspect = WIDTH / HEIGHT;
camera.updateProjectionMatrix();
Creating CSS3DSprite objects from <li>
elements in the HTML and assigning initial globe positions
for (let key in this.locationsObject) {
_this.locationsObject[key].coordinates = calcPosFromLatLonRad(this.locationsObject[key].lat, this.locationsObject[key].long, 300);
let CSS3D_Object = new THREE.CSS3DSprite(_this.locationsObject[key].element);
CSS3D_Object.position.set(_this.locationsObject[key].coordinates[0], _this.locationsObject[key].coordinates[1], _this.locationsObject[key].coordinates[2]);
CSS3D_Object.receiveShadow = false;
CSS3D_Object.castShadow = false;
sceneHTML.add(CSS3D_Object);
_this.locationsObject[key].CSS_Object = CSS3D_Object;
console.info(CSS3D_Object);
}
Additional code snippets can be viewed in the initial question here