BufferGeometry lines in THREE.js are failing to render when their starting point is outside the view of the camera

Currently, I am in the process of developing a trace-line function for a visualization project that involves transitioning between different time step values. However, I have encountered an issue while using THREE.js's BufferGeometry and the setDrawRange method to create the line. It seems that the line is only visible when the origin point of the line is within the camera's view. If I pan away from the origin point, the line disappears, but it reappears when panning back towards the origin (typically located at 0,0,0). Is there a specific reason for this behavior, and is there a workaround available? I have already experimented with various render settings without success.

The provided code snippet is currently utilized for testing purposes and focuses on visualizing the object's trace as time progresses.

var traceHandle = {
    /* setup() returns trace-line */
    setup : function (MAX_POINTS) {
        var lineGeo = new THREE.BufferGeometry();
        //var MAX_POINTS = 500*10;
        var positions = new Float32Array( MAX_POINTS * 3 ); // 3 vertices per point
        lineGeo.addAttribute('position', new THREE.BufferAttribute(positions, 3));
        var lineMaterial = new THREE.LineBasicMaterial({color:0x00ff00 });  
        var traceLine = new THREE.Line(lineGeo, lineMaterial);
        scene.add(traceLine);
        return traceLine;
    },
    /****
    * updateTrace() updates and draws trace line
    * Need 'index' saved globally for this
    ****/
    updateTrace : function (traceLine, obj, timeStep, index) {
        traceLine.geometry.setDrawRange( 0, timeStep );
        traceLine.geometry.dynamic = true;
        var positions = traceLine.geometry.attributes.position.array;
        positions[index++]=obj.position.x;
        positions[index++]=obj.position.y;
        positions[index++]=obj.position.z;

        // required after the first render
        traceLine.geometry.attributes.position.needsUpdate = true; 
        return index;       
    }
};

Your help and insights are greatly appreciated!

Answer №1

It appears that the bounding sphere may be undefined or has a radius of zero. When adding points dynamically, consider setting:

traceLine.frustumCulled = false;

Alternatively, you can ensure that the bounding sphere is up to date, but this may be too taxing on computational resources based on your current scenario.

Using three.js version r.73

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

In JavaScript, I am looking to duplicate an image and place it back at its original location after it has been moved from its initial position

I am working with 3 draggable images and my objective is to ensure that each image returns to its original position when moved. Ultimately, I want the user to be able to interact with multiple instances of images 1, 2, and 3 on the page, all of which are d ...

JavaScript => Compare elements in an array based on their respective dates

I have an array consisting of more than 50 objects. This array is created by concatenating two arrays together. Each object in this array contains a 'date' key with the date string formatted as: `"2017-03-31T11:30:00.000Z"` Additionally, there ...

Excluding null values when using Mongoose populate query: A simple guide

I'm currently working on an app where I've defined 2 models. const UserSchema = new Schema({ _id: Schema.Types.ObjectId, account:{ type: String, unique: true }, email: String, first_name: String, last_name ...

Automatically trigger a page reload using a jQuery function

Currently facing an issue with jQuery. I created a drop-down menu and would like it to expand when the li tag within the menu is clicked. Even though I am using the jQuery click function successfully, there seems to be a problem where the webpage refreshe ...

How can I adjust the size and alignment of each line within a single cell in an HTML table?

<!DOCTYPE html> <html> <head> <title></title> <meta charset="UTF-8"> <style> .chess-board { border-spacing: 0; border-collapse: collapse; } .chess-board ...

Can Firebase lists be reversed?

I have searched extensively on SO for an answer to this question, but I haven't found a solution yet. Therefore, please do not mark this as a duplicate. Currently, I am working with AngularFire in Angular 2 and Typescript. I am using FirebaseListObse ...

Creating interactive touchpoints with pop-up text or interactive text fields is a great way to engage your audience and make your

While developing a game with react-three-fiber, I have successfully integrated touchpoints. Now, I am facing a challenge in creating interactive pop-ups that will provide questions or text for the player to answer. Can anyone lend a hand in accomplishing ...

Issue with Material UI Autocomplete: onChange event not firing

When using Material UI's Autocomplete example, I am trying to choose an option using keyboard events: Navigate through options with the Up and Down arrow keys Press ENTER to select the desired option However, the onChange event is not being triggere ...

Dynamic parameters can be passed in Rails using the link_to method

Feeling a bit stuck, maybe this is just a simple question. I have a sort button that I need to use to organize my list of questions. To do this, I create a link_to like this: <%= link_to xx_path(:is_sort => true, :remote=> true , :method=> :p ...

Guide to integrating Bootstrap-Vue / Vue 2 with Vite

In the process of migrating my project from webpacker to vite, I encountered some Bootstrap Vue issues such as Multiple instances of Vue detected and $attr and $listeners is readonly, which are detailed in BootstrapVue's documentation here Previously ...

The input field automatically populates with the username that has been stored in the browser's form

Issue: I have created an input field with the type text, but upon page load, it gets automatically filled with a username saved in the browser's form data for this website's login page. I want it to show up clean when the page loads. <input t ...

Ways to update the DOM once a function has been executed in VUE 3 JS

I'm working on implementing a "like" or "add to favorite" feature in VUE 3. However, I'm facing an issue where the UI doesn't update when I like or unlike something. It only refreshes properly. I'm using backend functions for liking and ...

The Vue component appears to be missing from the HTML code

I recently began learning Vue.js in school, and for my first assignment I need to print a h2 from a Vue component. However, I am having trouble getting it to work. Below is the code for the Vue component that I have created. var app = new Vue({ ...

Making changes to HTML on a webpage using jQuery's AJAX with synchronous requests

Seeking assistance to resolve an issue, I am currently stuck and have invested a significant amount of time. The situation at hand involves submitting a form using the traditional post method. However, prior to submitting the form, I am utilizing the jQue ...

Leverage the power of Three.js PositionalAudio to create an immersive cone of audio

Currently, I am in the process of creating an array of sounds utilizing PositionalAudio: var newSound = new THREE.PositionalAudio(listener); newSound.setBuffer(buffer); newSound.setRefDistance(20); newSound.autoplay = true; newSound.setLoop(true); s ...

The checkbox is not being triggered when an <a> tag is placed within a <label>

I have a unique case where I need to incorporate <a> within a <label> tag. This is due to the fact that various CSS styles in our current system are specifically designed for <a> elements. The <a> tag serves a purpose of styling and ...

"Encountered an error when using the pop method on a split function: 'undefined is not

I am working with an array of filenames called ret, and I need to extract the extension of each file name. var cList=""; var fName=""; var ext=""; for(var i=0;i<=ret.length-1;i++){ fName=ret[i]; ext=fName.s ...

What is the best way to convert a deeply nested PHP array/object into JSON format?

For those who want a shorter explanation, here it is: I have a JavaScript array filled with objects. Some properties of these objects contain arrays of objects, which in turn may have more arrays or objects nested within them. This results in 5 levels of n ...

Alert! Server node encountered an issue while handling the response: process.nextTick(function(){throw err;});

Currently, I am working on a simple application to familiarize myself with Mongo, Express, and Node. An issue arises when I attempt to utilize res.json(docs) in the success conditional during the GET request, generating an error process.nextTick(function( ...

Which is better for cycling through a list of items: CSS or JavaScript?

Currently, I have a navigation bar set up as an unordered list (<ul>), but some list items are not visible. I want to implement functionality where clicking arrows will move the elements left or right by hiding or showing the leftmost or rightmost it ...