Issue with THREE.CubeTextureLoader where edges appear 1px too small

My latest project involved creating a panorama cube using THREE.CubeTextureLoader:

pano = [
    'scenes/4/2048/px.jpg', 'scenes/4/2048/nx.jpg',
    'scenes/4/2048/py.jpg', 'scenes/4/2048/ny.jpg',
    'scenes/4/2048/pz.jpg', 'scenes/4/2048/nz.jpg',
];
newCubeTexture = cubeTextureLoader.load(pano);
geometry = new THREE.BoxGeometry(20000, 20000, 20000);
material = new THREE.MeshBasicMaterial({
    envMap: newCubeTexture,
    side: THREE.BackSide,
    color: 0xffffff,
    transparent: true,
    opacity: 0
});
mesh = new THREE.Mesh(geometry, material);

However, upon loading the textures, I noticed a strange 1px bug on the edges:

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

Can anyone explain why this is happening?

P.S. I found that loading textures for each side individually using map resolves this issue:

new THREE.MeshBasicMaterial({
    map: new THREE.ImageUtils.loadTexture(arr[i]),
    side: THREE.BackSide,
    transparent: true,
    opacity: 0
});

Answer №1

There are some valid points made by @WestLangley in his remarks. I would also like to mention that while the method of artificially creating a giant box has its advantages, it also has some weaknesses. One of the main drawbacks is that the box can still appear distorted and may be vulnerable to z-fighting along the borders.

For a more efficient approach in the latest versions of three.js, it is recommended to utilize the CubeTexture obtained through cubeTextureLoader.load and assign it to scene.background.

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

Angular decode UTF8 characters with pascalprecht.translate

I'm facing issues with UTF8 characters when using SanitizeValueStrategy('sanitize'). This is necessary because the client will be editing texts in language files and may include tags like <b> or <i>... I want to rely exclusively ...

Analyzing a text file against a string to identify discrepancies using Node.js

Recently, I came across a dilemma involving a text file containing information on all Wifi connections (such as ssid, mac no, strength, etc.) that were within my laptop's range just 2 minutes ago. Now, I've rerun the code and obtained the current ...

Guide on removing query parameters post a redirect using NextJS

Is there a way in NextJS to redirect a URL like /page?foo=bar to /page/bar? I checked out the documentation at https://nextjs.org/docs/api-reference/next.config.js/redirects but couldn't find a solution. This is what I have tried so far: { source: ...

Is it possible to access prop properties within the ready() function?

I am seeing the error message undefined in the console, specifically originating from the ready() function. The issue I am encountering is related to attempting to assign the value of this.users.name to this.userForm.name. Can someone please point out wh ...

Vue.js is rendering the chart inaccurately in dc.js

I am currently facing an issue with using dc.js inside a Vue component. My linechart has this filled black area and the brush tool looks different from the normal brush tool. I took this code from my plain JavaScript project. <template> <div> ...

Using a combination of jQuery and JavaScript to switch image tags between different classes

I'm really struggling with this issue and could use some guidance. Essentially, I have a code that should change the class of an img tag when a user clicks on a div element. Let's take a look at the HTML structure: <li><img src ...

display a dropdown menu with a default selection

Trying to pre-select a value in a dropdown from database but facing issues. Need assistance in resolving this problem. HTML <select class="form-control" ng-model="reportType.consolidationScopeId"> <option value="">Please select</option& ...

When using Owl Carousel in Chrome, the carousel unexpectedly stops after switching tabs

Hi there, I'm currently testing out the auto play feature in owl carousel. One issue I've encountered is that when I switch to another tab in Chrome and then return to my webpage with the carousel, it stops functioning unless I manually drag the ...

Tips for delivering a variable to a React Native Stylesheet

Is there a way to pass a variable to the "shadowColor" property in my stylesheet from an array declared in the code above? I keep encountering a "Can't find name" error. Attempting to use a template literal has not resolved the issue. Any assistance w ...

Exploring the contrast between using '-save' and '--save' when executing the 'npm install' command

After working with Node.js for half a year, I'm still puzzled about the distinction between npm install pkg -save and npm install pkg --save. Can someone please clarify the difference for me? ...

ngRepeat does not completely refresh the DOM when dealing with a basic array

I have a simple array of numbers shown below using ng-repeat: n = [1,2,3,4,5,6] The problem arises when I modify this array, for example: n=[1,2,3] Instead of fully reloading the DOM, only the last 3 div elements corresponding to array 4, 5, 6 are remo ...

Using the Javascript jQuery post() or get() method to pass a JSON object within a closure function prior to

Looking for the optimal approach to managing a JSON object that needs to be posted/retrieved upon document readiness in order to execute another function that constructs the DOM based on said JSON object. This JSON object also undergoes updates every 30 se ...

What is the best way to adjust the size of a Div slideshow using

I need help with creating a slideshow that covers my webpage width 100% and height 500px. The image resolution is 1200*575. Can someone assist me with this? CSS #slide{ width : 100%; height: 500px; } HTML <!DOCTYPE html> <html> ...

What is the best way to display a jpg image file stored on an SD card using PhoneGap?

My goal is to display a jpg image from the data directory of an Android phone, not a photo taken by the camera. Here's the code I've worked on so far: document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady(){ ...

Using JavaScript to open a new window and display CSS while it loads

I am looking to utilize a new window for printing a portion of HTML content. var cssLink = document.getElementByTagName('link')[2]; var prtContent = document.getElementById('print_body'); var WinPrint = window.open(' ...

In order to indicate the checkbox as checked, I must ensure that its value is set to

I have a requirement where I need to dynamically set the checkbox based on the value coming from the backend. If the value is true, the checkbox should be checked and if false, it should be unchecked. However, despite setting the value in the state rules, ...

Texture loaded onto a surface may appear blurry or even just one uniform color. Discover how to enhance the sharpness and clarity of the

I am currently experimenting with three.js to create some simple 3D graphics. One of the tasks I am working on involves applying a jpeg image as a texture onto a custom geometry. Here is the code snippet showcasing this: var floor = new THREE.Shape([ ...

Executing multiple jQuery Ajax requests with promises

I've been learning how to use promises gradually, and now I'm faced with the challenge of handling multiple promises. In my code snippet, I have two email inputs in a form that both create promises. These promises need to be processed before the ...

Discovering the art of interpreting the triumphant outcome of an Ajax request with jquery/javascript

I recently encountered a challenge with my function that deals with a short JSON string: <script id="local" type="text/javascript"> $( document ).ready(function() { $('tr').on('blur', 'td[contenteditable]', functi ...

Tips for displaying Ajax response in a modal popup

I have a link that, when clicked, sends an AJAX request and successfully receives a response in the form of an HTML file, which I then append to a div. However, I want to display this div as a modal popup and I have attempted the following: In the HTML fi ...