Utilizing a perspective camera in Three.js results in face clipping of 3D textures at various MIP depth levels

I've been developing a web GUI for one of my light simulators using three.js. The GUI involves rendering a 3D volume (containing integers or floats), so I modified the 3D texture demo script and created a test page.

After some adjustments, I managed to render the 3D texture in MIP style. However, I encountered an issue with depth rendering where certain bounding box faces disappear at particular camera angles, resulting in inaccurate rendering.

The image below illustrates the problem. The texture is a 40x20x30 volume with two z-layers: value 1.0 for 0<z<20 and value 2.0 for 20<z<30.

https://i.sstatic.net/EhLsj.png

As seen in the screenshot above, the MIP rendering is fine from the left view angle but exhibits jagged boundaries (or missing bbx faces) from most other angles shown on the right.

You can see this issue yourself by clicking on the link below:

To input this volume, click on the "JSON" tab, remove the existing text, and copy/paste the JSON data provided below. The "Shapes" object defines a 3D volume utilizing the JData ND array format, decoded as a numjs NdArray object. After replacing the JSON text, switch to the "Preview" tab to view the rendering.

{
  "Session": {
    "ID": "mcx",
    …
}

My script was heavily based on the 3D texture demo. I attempted to enhance the material settings by adding

transparent: true, opacity: 0.6, alphaTest: 0.5, depthWrite: false
without success.

While my data matches the float32 array used in the demo, the demo runs smoothly in MIP mode. I'm curious if I missed something during the adaptation.

Your feedback and suggestions are greatly valued! Thank you


…

     let jd=new jdata(cfg.Shapes,{});
     let vol=jd.decode().data;
     boundingbox.add( drawvolume(vol.transpose()) );
…

In addition, I'm struggling to render a 3D integer array instead of a float array. I tried updating the texture setting as follows, but it displays a uniform block. I suspect I may need to create a new shader for this scenario?

  const texture = new THREE.DataTexture3D( volume.selection.data, dim[2], dim[1], dim[0]);
  texture.format = THREE.RedIntegerFormat;
  texture.type = dtype[volume.dtype];
  texture.minFilter = texture.magFilter = THREE.LinearFilter;
  texture.unpackAlignment = 1;

Answer №1

It seems to me like the problem might be related to the side that the material is being applied to. Have you considered using THREE.DoubleSide or THREE.FrontSide in your ShaderMaterial? This could potentially resolve the issue you're experiencing.

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

Comparing Jquery ajax object in Internet Explorer is not possible

Currently, I am utilizing jQuery's ajax function to fetch an HTML page. Upon success, a data object is retrieved. I aim to compare this data object to a string to determine the necessary actions. This functionality performs as expected in Firefox and ...

Storing a blank field in a Kendo grid

Is there a way to clear the content of a cell and save it as an empty field? I attempted to specify my field in the parameter update map using the following code: ((data.Value) ? '","Value": "' + data.Value : "") + and in the schema like this: ...

Is it possible to solve a mathematical equation entered into a text box that resembles an Excel cell, complete with an equal sign?

On my php website, I have text boxes within a form. I'm looking for a way to enter formulas like "=4*6" or "=5/12*30" (without the quotes) into the text box and have it calculate the result. I have an onchange event set up on the text box to trigger a ...

Exploring JSON parsing in AngularJS without running into reserved keywords

var jsonURL='../../json/xx.json' var myApp = angular.module('myApp',[]); myApp.controller('loaddata_traceroute', ['$scope','$http',function($scope, $http){ $http.get(jsonURL).success(function(data) { ...

Image gradually disappears after being loaded via ajax request

I am trying to achieve a fade-in effect for images after they have been loaded following an ajax call. The goal is to make the fade-in occur smoothly, rather than having the user observe the image loading process. Is there anyone who can assist me with ...

Even with React.memo(), functional components continue to trigger re-renders

I am facing an issue with my button component that contains a button inside it. The button has a state isActive and a click function passed to it. Upon clicking the button, the isActive flag changes, triggering the app to fetch data accordingly. However, t ...

What is the reason behind React re-rendering child components despite passing props that have been memoized with useMemo?

While exploring this topic, I stumbled upon an answer that seems relevant: When does React re-render child component? However, my inquiry delves into a more intricate question. Why does React typically re-render child components when utilizing the useMemo ...

Hidden text within a webpage that remains concealed until a specific link is activated

Just getting started with HTML and wanting to add animation to my project. I have a vision of an animation where clicking on an image will split open a half page of text and stuff. It should be similar to this example: ...

Saving Information to a Specific Location on the Client Side in a CSV File

I am currently working on a static application that uses Angular JS technology. My goal is to write data into a CSV file at a specific path in order for another API to read the data from that location. Despite searching extensively on the internet, I hav ...

Exploring the challenging surfaces of a mesh through raycasting in Three.js

I successfully built a box using three.js var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 100, window.innerWidth/window.innerHeight, 0.1, 1000 ); camera.position.set(5, 5, 10); var geo = new THREE.BoxGeometry(5,2,5); var mat = n ...

Numbered keys in JSON

I'm dealing with a JSON object that is passed to a script, and the keys are dynamic which makes it hard for me to access the data. The keys in the JSON object are actually numbers, but no matter how I try to access them, I can't seem to get the ...

Display unformatted JSON code and format it into a visually appealing structure within a DIV element

I am currently working on a function that accepts unformatted JSON code as input and I am attempting to utilize the stringify method to format it into a more visually appealing (pretty) view. Here is the code snippet: function prettyPrintJSON(selectionInf ...

What is the best way to start up node.js and react?

Can you help me with running a server node js and a react app simultaneously? Here is my package.json { "name": "mon-app", "version": "0.1.0", "private": true, "dependencies": { "express": "^4.17.1", "react": "^16.14.0", "react-dom": ...

Is there a way to verify the presence of a selector in Puppeteer?

How can I use Puppeteer to check if #idProductType exists and if not, assign producttype to ""? I have tried multiple solutions but none seem to work. const urls = [myurls, ...] const productsList = []; for (let i = 0; i < urls.length; i++) ...

Exploring the intricacies of Node-Craigslist syntax

Greetings! I am currently utilizing the node-craigslist package found at https://github.com/brozeph/node-craigslist and I am in need of assistance with some syntax related to the details method. The documentation provides the following example: client . ...

Ways to execute additional grunt tasks from a registered plugin

I am currently in the process of developing a custom Grunt plugin to streamline a frequently used build process. Normally, I find myself copying and pasting my GruntFile across different projects, but I believe creating a plugin would be more efficient. Th ...

Is there a way to pause the current page rendering process when moving to a different page?

In my Vuejs application, I have a page that displays many elements. While these elements are being rendered, I click on a link to navigate to another page. However, the navigation does not occur until the current page is fully rendered. Is there a way to ...

displaying a progress bar with percentage using jQuery mobile

Currently, I am in the process of creating a mobile app with jquery mobile and integrating it with a web service. My goal is to incorporate a progress bar that shows the completion percentage. ...

Retrieve the content within a div using Jquery

Is it possible to extract the content from a <div> upon clicking a link? For example: Imagine there are two separate div elements on a webpage <div id="1" > This Is First Div </div> <div id="2" > This Is Second Div </div> & ...

Issue with Pebble SDK/SimplyJS failing to recognize the tab character

Currently, I am facing an interesting challenge while attempting to make my Pebble watch recognize the escape sequence character \t when sending data to my watch using SimplyJS. Here is the code snippet I have been working with: simply.scrollable(tr ...