When the position value in three.js exceeds a certain threshold, the mesh starts to jitter uncontrollably

In search of a unique setting, I envision a universe where the gaps between meshes represent incredibly large numbers (for instance 10^15). Despite this vast distance, there is one mesh whose position (x, y, or z) quivers unsettlingly. Even after experimenting with the logarithmicDepthBuffer, the issue persists.

I find myself unable to diminish the distances as some meshes are separated by 1000 km while others span an incredible 1,000,000 light years. Is there a solution to address this anomaly? Feel free to view the example provided.

<html>

<head>
<script src="https://threejs.org/build/three.js"></script>
</head>

<body>
<script>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

var renderer = new THREE.WebGLRenderer({
logarithmicDepthBuffer: true
});

renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var geometry = new THREE.BoxGeometry(1, 1, 1);
var material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
var cube = new THREE.Mesh(geometry, material);

cube.position.x = Math.pow(10, 15) // Very large position x.
cube.add(camera)
scene.add(cube);

camera.position.z = 3;

function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
cube.rotation.y += 0.01;
}

animate();
</script>
</body>

</html>

Answer №1

It is recommended to include the camera in the scene rather than attaching it directly to the mesh:

scene.add(camera);

Additionally, while cube(camera) may function, remember to end the statement with a ;.

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

Despite creating a new array, Vuetify 2 continues to display 10 in the pagination options

I am facing an issue in Vuetify 2 where I have set the pagination options of a data table to be [50,60,70], but on the page, it displays [10,50,60,70]. It seems to be combining the default 10 into the list. https://codepen.io/anon/pen/NQRRzY?&editable ...

Increase the loading speed of the tooltip when hovering over the Legend of the Doughnut chart

I have a similar implementation to the answer provided in this response, which I will share here for better understanding. When you hover between items in the legend and do so quickly, you may notice that the tooltip on the chart does not always display. ...

What Occurs to Processed Messages in Azure Functions if Result is Not Output?

I have created an Azure function that is connected to the messaging endpoint of an IoT Hub in order to trigger the function for all incoming messages. The main purpose of this function is to decompress previously compressed messages using GZIP before they ...

Displaying a loading spinner while waiting for the Vue.js app to render

Currently, I am developing a Vue.js application and I'm facing a challenge in adding a loading spinner before the app component is rendered. Instagram has a similar feature where they display their logo before showing the page contents. I have tried v ...

"Encountered a console.log error in native code while using Google Chrome and Android browsers

Can someone help me troubleshoot an issue I'm having with displaying data after a user clicks on the sign-up button? The function works fine on Mozilla Firefox, but I get a native code error on Google Chrome and Android browsers. Can anyone spot what ...

"Enhance User Interaction with a Bootstrap Popup when Submitting Form Data via

As a junior web master, I have a simple question to ask. I have created a single page application for a client with a contact form at the end of the page. The validation is done using Bootstrap, but the only method I know to send the form data to a mail id ...

Top Method for Incorporating Syntax Highlighting into Code Blocks - React Sanity Blog

I'm currently exploring the most effective method to incorporate syntax highlighting into my react sanity.io blog. Here's a look at the article component I've developed using react: import React, {useEffect, useState} from "react"; import ...

Angular directive within a directive

I'm a beginner in AngularJS and I'm attempting to create a directive that contains another directive inside it. Here is how the first directive looks: ( function () { app.directive("cmEventBar", function () { var controller = func ...

Enhance your JQuery UI autocomplete feature by including images and multiple fields for a more interactive user experience

I am looking to incorporate Autocomplete functionality that will showcase names and avatars similar to the Facebook autocomplete feature. In a recent post Jquery UI autocomplete - images IN the results overlay, not outside like the demo and in the provide ...

Unzipping a .gz file in node.js: a simple guide

I have downloaded a .csv.gz file from a remote server, and I have the content of this file stored as a string. When I console.log it, here is a small sample of what it looks like: }v)tYj8p0eCR l1=6~̵r0c77LU:0g How can I decompress this in Node.js and c ...

An Unexpected Appearance of Special Characters in a Python dictionary created from AWS and transmitted to JavaScript via a Django view

In my quest to gather information about my infrastructure, I am working on constructing a dictionary that can be converted into JSON objects. These objects will then be passed to JavaScript for display purposes. I have experimented with using both json.du ...

conceal a targeted section from the bottom of the iframe

I have a website embedded inside an iframe for use in a webview application. <body> <iframe id="iframe" src="http://www.medicamall.com"></iframe> </body> This is the CSS code: body { margin:0; padding:0; height:10 ...

Utilizing variable index to access nested objects

When my Ajax request returns a response, the data takes the form of an object shown below: https://i.sstatic.net/wA2Px.png How can I access the value? Keep in mind that idVariable is a variable. data.test1.idVariable.test2.value The result of the code ...

If I reload or close my page immediately after sending an asynchronous Ajax request to the server, will the request still be completed?

Suppose I use jQuery's Ajax to make the following request: $(document).ready(function() { $('#some_button').click(function() { $.ajax({ url: '/some/request', type: 'POST', ...

Tips for finding data attribute in Select2?

Is it possible to search for items based on both the value and data-test attribute in select2? <option value="Test 1" data-test="user-1">Test 1</option> <option value="Test 2" data-test="user-2">T ...

Using an Array as an Argument in a JavaScript Function

Currently, I am utilizing a web service to populate a selection list. Now, I need to repeat this process for multiple selection lists, with the goal of minimizing the amount of code duplication. Below is the function I am using to make the web service call ...

Can you point me in the right direction to find the Configure function within the EasyRTC module for

As a newcomer to NodeJS, I may be getting ahead of myself, but I'm diving into running the EasyRTC demo with NodeJS. On the EasyRTC download page, there are "easy install instructions" that outline the steps required to get EasyRTC up and running smo ...

How to transfer the application version from package.json to a different non-JSON file in Angular and node.js

While developing my Angular application, I encountered a task where I needed to extract the version number from the package.json file and transfer it to a non-json file. The content of my package.json file is as follows: { "name": "my app ...

Images in Next.js work properly in a local environment, but encounter issues in the production environment

My Next.js images are working fine on local, but when I try to push it to production, it crashes. Here is my code View my image component here This is where I map the images Here is the part of my .json file where I fetch data It works properly in loca ...

What is the best method for retrieving a local value in Javascript?

Consider a scenario where there exists a variable named animationComplete (which is part of a 3rd-party library) and a function called happenAfterAnimation: An easy solution would involve the following code snippet: while(!animationComplete) { // Do n ...