Observing a refraction phenomenon in both the background scenery and the three-dimensional models

My goal is to apply a refraction material to a sphere object. The challenge is to make the sphere transparent enough to see not only the scene background but also other 3D geometry within the scene. One possible solution is to configure the envMap parameter using the Scene.background method.

let scene = new THREE.Scene();

scene.background = new THREE.CubeTextureLoader().setPath( '/path/to/my/assets/' )
                                                 .load( [ 'pX.png', 'nX.png', 
                                                          'pY.png', 'nY.png', 
                                                          'pZ.png', 'nZ.png' ] );

let geometry = new THREE.SphereBufferGeometry( 50, 25, 15 );

let refractedMaterial = new THREE.MeshBasicMaterial( { color: 0xfffffc, 
                                                      envMap: scene.background, 
                                             refractionRatio: 1.00 } );

let sphereMesh = new THREE.Mesh( geometry, refractedMaterial );

// Additionally, there are some examples of 3D text
// These 3D texts can be viewed in the scene 
// However, they cannot be seen through the refractive sphere
let textMesh = new THREE.Mesh( textGeometry, textMaterial );

scene.add( sphereMesh );
scene.add( textMesh );

QUESTION:

Which parameter of

MeshBasicMaterial( parameters : Object )
controls the visibility of the scene geometry, rather than just the scene background?

Answer №1

This technique for refraction may not achieve the desired outcome you are seeking. It only interacts with the environment map or background, and does not affect other objects within the scene.

If you want to account for other objects in your scene, consider using THREE.Refractor. You can see how it works by checking out the official demo here:

Keep in mind that THREE.Refractor is limited to flat surfaces and cannot be applied to curved geometries like spheres.

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

Display or conceal a vue-strap spinner within a parent or child component

To ensure the spinner appears before a component mounts and hides after an AJAX request is complete, I am utilizing the yuche/vue-strap spinner. This spinner is positioned in the parent days.vue template immediately preceding the cycles.vue template. The ...

Is there a way to download a file using an ajax request?

We are faced with a particular scenario in our application where: Client sends a request Server processes the request and generates a file Server sends the file back as a response Client's browser prompts a dialog for downloading the file Our appli ...

Obtaining a JavaScript proxy from a WCF service using webHttpBinding

I have configured all the necessary endpoints, bindings, and behaviors to consume a service using JSON. However, I am struggling to find a way to generate a JavaScript proxy for accessing the service from my client-side JavaScript with jQuery through Ajax. ...

Just diving into React and learning how to retrieve data using axios

I have encountered an issue where I can see my data within the async function, but when I try to pass it outside, all I get is the promise object. My question consists of two parts: first, how can I successfully pass this data outside of the async functio ...

AngularJS: Controller causing an unchecked error

I'm a beginner to AngularJS and I'm struggling to understand why I'm not getting a response when clicking the button. Any help would be greatly appreciated. I've reviewed other examples of controllers being used but I can't seem to ...

How can I send a variable into the DOM using AJAX?

Apologies for posting a question earlier about creating a condition for checkbox without proper investigation. It appears that I need to pass my variables here. function setsession(sessionid, action, data) { $("#totalselection").show(); $. ...

What is the best way to conceal text that overflows from a div and seamlessly return to the beginning once the end of the text has been reached?

I am struggling to figure out how to hide the overflow text that is spilling out of the div. I attempted using overflow: hidden;, but unfortunately, it didn't work as expected. Additionally, I would like the text to loop back to the beginning once it ...

Node.js: Configuring keep-alive settings in Express.js

How can I properly implement "keep alive" in an express.js web server? I came across a few examples.. Example 1: var express = require('express'); var app = express(); var server = app.listen(5001); server.on('connection', function(s ...

"Utilizing the Nuxt Vue Router afterEach Guard for Added Security

Is there a way to implement an afterEach handler in Nuxt that runs after route changes? While middleware can be used as a beforeEach, I'm struggling to find a solution for the afterEach hook. ...

Tips for moving an input bar aside to make room for another

Is it feasible to have two input bars next to each other and keep one open until the other is clicked, then the first one closes as well? I attempted using a transition with "autofocus," but the bar ends up closing when clicked on in my site. If anyone ca ...

Revolutionize iPad user experience with seamless HTML5 video integration

What is the most effective method for dynamically embedding HTML5 video to ensure compatibility with the iPad? (using pure Javascript) I'm having difficulty getting this approach to work: <div id="placeholder"><script type="text/javascript" ...

Ways to create a vertical bottom-up tree view using d3.js

I am trying to create a reverse tree view, starting from the bottom and moving up. What modifications do I need to make? Here is the link to my JS Fiddle: ...

Determining Byte Location Within Upload Loop

Currently, I am in the process of developing a function that is responsible for sending data to a server in small chunks using a 3rd party API. With some assistance from the Stack Overflow community, I have managed to achieve this task successfully. The is ...

Struggling to access YouTube account via Google sign-in using Puppeteer framework

I am facing an issue with my puppeteer code where I am unable to proceed past the email page after clicking next due to some bot protection by Google advising me to "Try using a different browser...etc". Is there a way to bypass this using puppeteer? I h ...

Updating a numeric field in Mongoose by a percentage of its current value

Looking for a way to reduce prices of items in Mongoose. { name:"itemname", price: 30 } I want to apply a 10% reduction to the price, but $inc and $mul won't work for this scenario. {$mul: {price:0.10}} This code would reduce the price to 10% of t ...

Checking the validity of subdomain names using JavaScript/jQuery

For users signing up, my form allows them to choose a subdomain for their account. The valid characters allowed in the subdomain are letters, numbers, and dashes. Spaces and most special characters should be filtered out. http://_________.ourapp.com To r ...

Guide to transferring text to clipboard using PHP and JS

Forgive me if this sounds a bit silly. I've been trying to figure this out for a while now, and it seems like the only solution I found involves clicking some sort of button. I have a form that generates license keys, and after generating one, I wan ...

Retrieve custom attributes of child elements using jQuery selectors

I am looking to modify the data-answersetid attribute of all child controls under the .cloneable class in a table. Each row in the table contains a single control - either a textarea, checkbox, radio button, or input[type=number]. Each control has a custom ...

Having trouble converting svg to png, thinking it might be due to discrepancies in svg elements

I am facing a puzzling issue where two different SVG elements are causing my JavaScript to work in one scenario but not the other. I have replaced the SVG elements in both examples, and surprisingly, only one works while the other does not. You can view th ...

Relocating sprite graphic to designated location

I am currently immersed in creating a captivating fish animation. My fish sprite is dynamically moving around the canvas, adding a sense of life to the scene. However, my next goal is to introduce food items for the fishes to feast on within the canvas. Un ...