Reflection of three.js CSS3D sprite on the z-axis

Each CSS3D sprite within my scene displays a reflection when the camera is rotated. Is there a way to prevent this? The Reflection does not appear consistently across different browsers and operating systems - it's not visible on Firefox on Mac, but it is on Linux. Another issue is that even if the reflection isn't visible, it remains clickable. To indicate the position of the reflection, you can use Firebug by hovering over the a-element in HTML-inspector.

Example:


<!DOCTYPE html>
<html>
<head>
<title>test11a</title>

<style>canvas { width: 100%; height: 100% } body {margin: 0px;overflow: hidden;}</style>

</head>
<body>
<script src="../build/three.min.js"></script>
<script src="js/renderers/CSS3DRenderer.js"></script>
<script>

var camera, scene, renderer;
var mesh;
var infoIcon;

var lon = 0;
var lat = 0;
var phi = 0;
var theta = 0;

init();
animate();

function init()
{
   renderer = new THREE.WebGLRenderer();
   renderer.setSize( window.innerWidth, window.innerHeight );
   document.body.appendChild( renderer.domElement );

   camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
   camera.target = new THREE.Vector3( 0, 0, 0 );

   scene = new THREE.Scene();
   htmlScene = new THREE.Scene();

   var geometry = new THREE.SphereGeometry( 100, 60, 40 );

   var texture = THREE.ImageUtils.loadTexture( 'textures/disturb.jpg' );
   texture.anisotropy = renderer.getMaxAnisotropy();

   var material = new THREE.MeshBasicMaterial( { map: texture } );

   mesh = new THREE.Mesh( geometry, material );

   scene.add( mesh );
   camera.position.z = 400;
   window.addEventListener( 'resize', onWindowResize, false );   

   //place infoIcon
   /*------------*/
   var imageInfoLink = document.createElement( 'a' );
   imageInfoLink.setAttribute("href", "http://www.google.de");
   var imageInfo = document.createElement( 'img' );
   imageInfo.src = 'textures/sprite0.png';
   imageInfoLink.appendChild(imageInfo);

   infoIcon = new THREE.CSS3DSprite( imageInfoLink );
   infoIcon.position.z = -500;

   htmlScene.add( infoIcon );

   htmlRenderer = new THREE.CSS3DRenderer();
   htmlRenderer.setSize( window.innerWidth, window.innerHeight );
   htmlRenderer.domElement.style.position = 'absolute';
   htmlRenderer.domElement.style.top = 0;
   htmlRenderer.domElement.style.zIndex = 10;
   document.body.appendChild( htmlRenderer.domElement );
}

function onWindowResize()
{
   camera.aspect = window.innerWidth / window.innerHeight;
   camera.updateProjectionMatrix();

   renderer.setSize( window.innerWidth, window.innerHeight );
}

function animate()
{
   requestAnimationFrame( animate );
   rotate();

   lon += 0.5;
   lat = Math.max( - 85, Math.min( 85, lat ) );
   phi = THREE.Math.degToRad( 90 - lat );
   theta = THREE.Math.degToRad( lon );

   camera.target.x = 500 * Math.sin( phi ) * Math.cos( theta );
   camera.target.y = 500 * Math.cos( phi );
   camera.target.z = 500 * Math.sin( phi ) * Math.sin( theta );

   camera.lookAt( camera.target );
   htmlRenderer.render( htmlScene, camera );
}

function rotate()
{
   mesh.rotation.y += 0.01;
   renderer.render( scene, camera );
}

</script>
</body>
</html>

Answer №1

Forget about it, I've switched to using THREE.Sprite now

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can direct sketching onto a model/texture in threejs be accomplished?

As I delve into my current project, I find myself searching for a unique solution. Is it possible to click on a plane geometry and use it as a canvas to draw in a paint-like style? And could this texture update in real-time as I draw on it? Additionally, ...

The visibility of the Google +1 button is lost during the partial postback process in ASP.NET

When trying to implement the Google Plus One button using AddThis on one of our localized pages, we encountered a strange issue. Despite retrieving data from the backend (let's assume a database), the plus button was not loading during an AJAX based p ...

Prevent screen from loading without JavaScript using an overlay

Is there a way to darken and lock the page, preventing clicking or scrolling, while displaying white text notifying the user that JavaScript is not enabled? I understand that the recommended approach is to gracefully degrade all elements when JavaScript i ...

Despite mutating the state, the Redux reducer does not trigger a rerender on my React Component

Lately, I've been facing challenges with redux as it sometimes doesn't trigger the rerendering of my React components. I understand that I need to update the state in order for Redux to detect changes. However, even after doing so, my React Compo ...

Why does it appear that Angular is undefined in this straightforward Angular demonstration?

I'm completely new to AngularJS and I've encountered an issue. Yesterday, I ran a very simple AngularJS application that I downloaded from a tutorial and it worked perfectly. The application consists of 2 files: 1) index.htm: <!DOCTYPE htm ...

Angular is unable to eliminate the focus outline from a custom checkbox created with Boostrap

Have you noticed that Angular doesn't blur out the clicked element for some strange reason? Well, I came up with a little 'fix' for it: *:focus { outline: none !important; } It's not a perfect solution because ideally every element sh ...

methods for detaching event listener from bootstrap carousel indicator elements

I am currently utilizing the bootstrap5 carousel feature and I am seeking a way to trigger a custom event when either the previous or next indicators are clicked. My goal is to stop the default bootstrap event from being triggered, however my attempts at v ...

Retrieve data from a local JSON file and showcase it in a list within a Next.js project. The error "Property 'data' does not exist on type String

Having trouble displaying the names of crates (which are filled with records/albums) from a local JSON file. The names aren't showing up and I'm wondering if I should be using params or if perhaps not stringifying the JSON would help. Visual Stud ...

What is the best way to calculate the days, exact hours, and exact minutes between two dates using JavaScript?

I need assistance with calculating the number of days, hours, and minutes between a start date time and an end time. For example: Start Date Time = "09-06-2017 10:30" End Date Time = "10-06-2017 11:45" I am looking for the result to be 1 day, 1 ...

The setTimeout function fails to behave as intended when used in conjunction with synchronous ajax

Within my code, I have a function that is being invoked multiple times due to iterating through an array of length n and creating 'Plants' with synchronous ajax calls. These calls involve querying the Google Maps API, so it is crucial to throttle ...

How can one ensure the preservation of array values in React?

I'm struggling to mount a dynamic 'select' component in React due to an issue I encountered. Currently, I am using a 'for' loop to make API calls, but each iteration causes me to lose the previous values stored in the state. Is t ...

What could be causing the "Undefned Jquery-ajax" error to pop up

I am struggling with the following code. My goal is to populate values into a dropdown <select> box, but I keep receiving an error of undefined. I have tried switching between Object.keys and Object.values, however, I am still facing the same issue. ...

What is the process for retrieving the value of the 2nd td by clicking on the checkbox in the 1st td with JavaScript

When I click on "in", I am looking to retrieve the value of "out". This can be easily understood by referring to the image below: The timesheet displayed is generated using an array. All the data is stored in the array and needs to be presented in a table ...

Web Browser Fails to Set Cookie during an Ajax Request

I am facing a perplexing issue. I have an AJAX call that triggers the processing of a login form and generates a cookie upon successful login. However, the web browser is failing to recognize the cookie. Upon troubleshooting, I have narrowed it down to so ...

Most efficient method for dynamically changing HTML content with JavaScript

Can anyone provide guidance on how to switch HTML content using JavaScript? For example: if($sid == 0) {insert one HTML code} else {insert another HTML code} Which method is preferable - LESS, jQuery, CSS3, etc? ...

Is the JSON data missing from the POST request?

I'm having trouble inserting data into the database using a POST request. Here is how I'm making the request: 127.0.0.1:3000/api/users?fname=asd&lname=edc&<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d7870 ...

What could be causing the issue with React Router not functioning properly in Material UI?

I'm currently working on creating a tab and adding routing inside the first tab. However, I am facing an issue where the desired page does not display after clicking on the link. Strangely, upon refreshing the page, the corresponding page appears as e ...

Guide on producing a milky overlay using Vue js

Currently, I am utilizing Vue 3 along with Bootstrap 5 in my project. In my application, there is a button and two input fields. Upon clicking the button, I would like to display a "milky" overlay as shown in this example: https://i.sstatic.net/K21k8.png ...

Using JavaScript to add a JSON string from a POST request to an already existing JSON file

I am currently working on a basic express application that receives a post request containing JSON data. My goal is to take this data and add it to an existing JSON file, if one already exists. The key value pairs in the incoming JSON may differ from those ...

Use the npm-search feature to show only the name and description columns in the search results

After running the command npm search packagename, I noticed that the results are shown in 6 columns: name, description, author, date, version, and keywords. Is there a way to customize npm-search so that it only displays the name and description columns? ...