Crafting a see-through circular prism

Is there a way to create a transparent cylinder in Three.js? I've tried using different settings like transparent or opacity but haven't had much success. Should I load a dummy texture with an alpha channel, or is there a simpler solution?

material = new THREE.MeshBasicMaterial({wireframe: true});
material.transparent = true;
mesh = new THREE.Mesh(new THREE.CylinderGeometry(4, 4, 50, 8, 1, true), material);
scene.add(mesh);

Update: I managed to make it work by using ShaderMaterial even though it feels somewhat unconventional.

material = new THREE.ShaderMaterial({wireframe: true, transparent: true});
mesh = new THREE.Mesh(new THREE.CylinderGeometry(4, 4, 50, 8, 1, true), material);
scene.add(mesh);

Update: Below are some image links for reference:

  • I unfortunately can't share the images due to my lack of reputation points, so I will provide faulty links that can be fixed by adding 'h' at the beginning of each URL.

ttp://img692.imageshack.us/img692/6412/shadermaterial.png A demonstration of the use of ShaderMaterial showing a grey Sprite within a transparent cylinder.

Using MeshBasicMaterial with Opacity set to 0.0.

Using MeshBasicMaterial with Opacity set to 0.5.

Using MeshBasicMaterial with Opacity set to 1.0.

Answer №1

Wouldn't it make more sense if we used this code instead?

material = new THREE.MeshBasicMaterial( { wireframe: true, opacity: 0.5 } );

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

Leverage scope Variable in Angular Service URL

Currently, I am aiming to retrieve data from an API by sending specific search parameters through an AngularJS service. Within my ng-model, I have a variable named "search" that I want to utilize as a parameter in the API URL. My initial (unsuccessful) at ...

What is the best way to import the axios post method from a JavaScript file into a Vue component

I'm encountering an issue when trying to export the data received from the API in my JavaScript file and display it in my Vue file. Currently, I am sending a security JSON to the server using the POST method. Although I am able to retrieve the output ...

Searching through text in Node JS using Mongoose for Full-Text queries

I am facing an issue while attempting to perform a full-text search on an array of strings using Mongoose. The error message I receive is as follows: { [MongoError: text index required for $text query] name: 'MongoError', message: 'text ...

How can you utilize data captured through a JavaScript onchange event in conjunction with another event?

Is there a way to utilize the firmType data captured during event 1 in event 2? code event 1 $("body").on("change","#so_customer", function(v){ customerFirm = $(this).find(":selected").data("employer"); $("#customer_employer").val(cust ...

What is the purpose of incorporating the replace function in my regular expression for Palindromes?

I'm currently tackling some challenges on FreeCodeCamp and I've hit a roadblock in a simple task which requires checking for palindromes. The solution provided involves the following step: str = str.replace(/[^a-zA-Z]/g, '').toLowerCas ...

Node.js's async functions seem to be running sluggishly

My list of queries is all set and ready to go: var array = [ 'UPDATE EVALUATION SET mark = "16" WHERE id_eval = "21" AND id_usr = "125"', 'UPDATE EVALUATION SET mark = "9" WHERE id_eval = "22" AND id_usr = "125"', ...

The array is arranged properly, yet React is failing to render it in the correct order

Here's the code snippet I am working with: { this.state.rows.map((qc) => qc.BinsByDayByOrchardsQCs.map((qc2) => qc2.BinsByDayByOrchardsQCsDefects.map((qc3) => !defectsArray.includes(qc3.Defect) &am ...

"Javascript encountered an unrecognizable expression when trying to parse a single

Whenever this event occurs, I'm encountering a console error that states "unrecognized expression: .". Everything seems to be working fine so I'm not entirely sure what the issue is other than possibly a syntax error. Any suggestions or ideas on ...

Ways to conceal the initial value of a form field?

Currently, my form includes two options - 10 and Other. There is also a text field next to the option for 'Other' where users can enter a specific amount. Here's how it's set up: <input class="mainForm" id="Amount" name="Amount" typ ...

What could be causing my AngularJs routing and animation to bypass the second redirection?

Recently started working with Angular and experimenting with routing and animations to manage my page transitions. I followed a helpful guide that helped me set everything up. I encountered a few issues: When trying to link back to the landing page (home ...

Prevent selection of jQuery UI calendar dates when radio button is chosen

I am new to jQuery and trying to enhance the functionality of a jQuery UI calendar. However, I am facing some challenges with my code. Here is what I have so far: JS Fiddle link <input name="button" type="radio" value="3days"/><label>Add 3 Da ...

How can I fill the data array of arrays using an Angular Table component?

I am struggling to populate an Angular Table with data in the array of arrays format. Despite my efforts, the code I have written does not seem to work. Any suggestions for a solution would be greatly appreciated. Here is the data that I am trying to popu ...

Determine the data attribute values of all checkboxes using jQuery and store them in a string

I am faced with a challenge involving a series of checkboxes that are structured like this: <input type="checkbox" class="pcb" value="1" data-id="99"> <input type="checkbox" class="pcb" value="2" data-id="98"> <input type="checkbox" class=" ...

Guidelines for sorting through items in Vue 3

In the past, Vue 2 allowed us to easily filter items using the | and filters syntax. However, this method is no longer supported in Vue 3. Instead, we now use the "computed" property to transform a single value into another. But what about changing values ...

Discover the best way to sort products by category

I'm in the process of developing an online store where customers can choose from three options: "body lotion," "body wash," and "body scrub." Once a selection is made, the corresponding product will be displayed. The products are stored in an array n ...

Endless cycle occurs when an asynchronous action is dispatched within useEffect

I encountered a never-ending loop problem when I added a dispatch function in my code within the useEffect hook. Despite looking into similar issues raised by others, I still can't seem to figure out the root cause of the problem. Here is how my compo ...

Search a database for a specific set of ObjectID using Mongoose

I'm currently developing an API using node.js, express, and mongoose. As I am still new to mongosse, I have been exploring different approaches to achieve what I need. In my database, I have two collections: users and expenses. Here's an exampl ...

Alternatives to .live() for events on dynamically added elements in jQuery version 1.9

Similar Question: jquery: on vs live In the past, I relied on the .live() method when dealing with elements created dynamically via JavaScript. This was because at the time of attaching an event listener (such as a click), the element did not yet exist ...

Implementing JavaScript functionality to read and interact with a Boolean field in a

Within my models.py file, I've defined the following: urgency = models.BooleanField(blank=True, default=False, verbose_name="Hitno otklanjanje") I am attempting to execute a javascript function that will modify a text field based on whether ...

AgGrid Encounters Difficulty in Recovering Original Grid Information

After making an initial API call, I populate the grid with data. One of the fields that is editable is the Price cell. If I edit a Price cell and then click the Restore button, the original dataset is restored. However, if I edit a Price cell again, the ...