How can I address the "z-index" issue with mesh materials?

Within my JSON model, I am aware of the two settings available for each material: depthTest and depthWrite.

I have set these values to false because some materials contain RGBA textures, and setting them to true causes the alpha channel to match the background color.

Currently, the textures seem to be controlled by a sort of z-index, placing them either above or below other elements.

Is there a way to address this issue?

EDIT:
Check out the page here:
And here's the corresponding code:

var camera, scene, renderer, mesh, loader;

        init();
        animate();

        function init() {

            camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
            camera.position.z = 1000;

            scene = new THREE.Scene();

            loader = new THREE.JSONLoader();

            loader.load( "alisopoli/alisopoli.js", function( geometry, materials ) {
                for ( var i = 0; i < materials.length; i ++ ) {
                    materials[ i ].side = THREE.DoubleSide
                    //materials[ i ].overdraw = true;
                }
                //var faceMaterials = new THREE.MeshFaceMaterial( materials );
                //faceMaterials.map.magFilter = THREE.NearestFilter;
                //mesh = new THREE.Mesh( geometry, faceMaterials );
                mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
                mesh.scale.set( 100, 100, 100 );
                mesh.rotation.x = 45 * Math.PI / 180;
                scene.add( mesh );
            } );


            var ambientLight = new THREE.AmbientLight(0xFFFFFF);
            scene.add(ambientLight);

            renderer = new THREE.WebGLRenderer();
            renderer.setSize( window.innerWidth, window.innerHeight );

            document.body.appendChild( renderer.domElement );

        }

        function animate() {

            requestAnimationFrame( animate );

            mesh.rotation.y += 0.005;

            renderer.render( scene, camera );
        }

Access the model here:

Answer №1

Responding to my own query.
Realized that the adjustments made with depthTest and depthWrite were incorrect.
Critical update was only required in alphaTest.

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

Guide on setting up JSME, a chemistry portal integrated with JavaScript, within vuejs

I am looking to integrate the JSME chemistry portal into my Vuejs application. Upon the initial page load, an error is displayed: JSME initialization error: HTML id jsme_container not found. Strangely, upon refreshing the page, the error disappears. How ...

prettyPhoto popup exceeds maximum width and height limitations

I am currently using the most up-to-date version from No Margin for Errors and I have set allow_resize to true. However, the size of the display is still too large. Is there a way to set a maximum width/height? I have already configured the viewport as fo ...

creating dynamic routes with Next.js

I am in the process of creating a Next.js application that showcases a product catalog sorted by categories and subcategories. The category and subcategory information is stored in an array of objects structured like this: const categories = [ { id: ...

PHP working with Ajax, receiving a status of 200 but still showing a readyState of 0

Snippet: function handleXMLHttpRequest() { var xhr; try { xhr = new XMLHttpRequest(); } catch (e) { try { alert("Error occurred"); xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ x ...

Could the php function json_encode() be a security risk if used within a script tag?

A while back, I had read OWASP's XSS Prevention Cheat Sheet and created a wrapper function that included JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP by default to ensure safety. However, a user on Freenode/##php pointed out that this approac ...

The ajax form is failing to update a specific div after calling $("#formName").submit();

Having an AJAX form with a submit button, I encounter an issue where pressing the submit button loads content and puts it in a specified div. However, when attempting to use the pager-next link, the content ends up on a new page instead of within the conte ...

Consistently encountering incorrect values during onClick events

I am using a Table to display certain values const [selected, setSelected] = React.useState<readonly number[]>([]); const isSelected = (id: number) => selected.indexOf(id) !== -1; return ( <TableContainer> <Table sx={{ width ...

Using ThreeJS to assign various textures based on the position of the object

Recently, I delved into the world of ThreeJS and embarked on creating a model of the Earth using a Sphere mesh. Alongside this, I crafted a model of the Sun and now desire to infuse two distinct textures onto the Earth model based on its orientation. Speci ...

How do I showcase the array value on top of a form using Javascript?

My current form displays errors using alerts, but I want to update it so that the errors are printed above the input fields for easy reference by users. This is the existing code for displaying errors: function showErrors() { if (errList.length >= ...

Issue with offset calculation in bootstrap table occurs when the bootstrap-table is closed and the window is resized

In a recent project, I utilized the bootstrap table. However, upon closing the bootstrap table with the following script: $(document).ready(function () { $(".removetable").click(function (e) { $(".table-aria").remove(); ...

Passing props from parent component to map function in ReactJS results in undefined props

In my project, I dynamically create <textarea> elements using the map() function. Each textarea should have a unique value when the component is rendered. // Within the render method of ComponentA fruits.map((fruit) => { return <textarea na ...

An error was encountered in the index.js file within the app directory when running the webpack

Recently, I was told to learn react.js even though my knowledge of javascript is limited. Nevertheless, I decided to dive in and start with a simple "Hello World" project. Initially, when I used the index.js file below and ran webpack -p, everything worke ...

Unable to adjust the width of the content and sidebar

I've been attempting to adjust the width of content and sidebar on my website , but I'm not having much luck. It may seem like a simple question, but even after tweaking the CSS, I am still not seeing the desired outcome. Any assistance would be ...

unable to append double quotation marks at the end of a string in node.js

I have a large translation file and I need to add double quotes at the end of each string. My Objective. input string ===> _your_report_is_being_prepared = Your report is being prepared desired output ===> "_your_report_is_being_prepared" : "Your ...

Firebug is failing to display the error warning in the bottom right corner

I am experiencing an issue where the firebug tool is no longer displaying the small red 'X' icon in the bottom right corner on my localhost development environment. Could it be possible that I accidentally altered a specific setting? Even after ...

The color scheme detection feature for matching media is malfunctioning on Safari

As I strive to incorporate a Dark Mode feature based on the user's system preferences, I utilize the @media query prefers-color-scheme: dark. While this approach is effective, I also find it necessary to conduct additional checks using JavaScript. de ...

A-Frame VR: Image missing from display on Chrome browser

UPDATE: I discovered that the issue was caused by running the HTML file from my local hard drive instead of a web server. Once I uploaded it to my web server and ran it from there, everything worked perfectly. A-Frame Version: 0.4.0, Chrome: 55.0.2883.87, ...

Go all the way down to see the latest messages

I have developed a messaging system using Vue. The latest messages are displayed from bottom to top. I want to automatically scroll to the end of a conversation when it is clicked and all the messages have been loaded via axios. Conversation Messages Comp ...

Transferring data from a React file to a plain HTML page

What is the best way to transfer information from a React app to a static HTML file? For instance, if I collect data through a form in a React app.js file, how can I then send that data to a basic HTML file? ...

Tips for displaying a loading indicator above a form

I've been struggling to figure out how to display a loading indicator on top of my form without messing up the styling... https://i.sstatic.net/FFCRW.png My goal is to show the loading indicator when any action, like deleting an item or changing qua ...