Leveraging three.js for visualizing temporal data series

What is the best approach for using time series data to control the animation of a three.js scene?

For instance:

  Time     | ObjA(x,y,z) | ObjB(x,y,z) | ...
  00:00:00 | 0,9,0       | 1,1,1       | ...
  00:00:10 | 0.1,0,0.1   | 1,0.5,1     | ...
  00:00:15 | 0.1,0.1,0.1 | 0.9,0.5,1   | ...

The data can consist of hundreds or even thousands of lines. Furthermore, the number of objects can vary from one dataset to another.

I have explored using tween.js and linking keyframes, but the idea of creating and connecting thousands of tweens during initialization does not seem like the ideal solution.

Is tween.js the most effective approach? Or is there another extension that would handle this scenario better? Are there any examples of a similar situation that could be beneficial?

UPDATE

Director.js seems capable of providing the desired outcome. However, it appears to be designed for tweening camera movement within a scene rather than controlling the movement of numerous meshes. Is chaining potentially thousands of tweens together across hundreds of meshes the optimal method for creating a scripted replay?

Answer №1

Your portrayal of the table may lead to confusion. In situations where the timeline is involved and the number of objects varies, it is advisable to create distinct timelines for each object. This simplifies the manipulation of the overall set.

var DataPoint = function(time, value){
    this.time = time;
    this.value = value;
};
var DataSignal = function(){
    this.dataPoints = [];
    this.searchValue = function(time){
        //... implementing divide and conquer technique
    }
    this.interpolateValue = function(time){...};
    this.addDataPoint = function(time,value){
        //ensure sequence preservation by checking if time is greater than previous data point time
        this.dataPoints.push(new DataPoint(time,value));
    }
};

var dataSignalA = new DataSignal();
var dataSignalB = new DataSignal();

For playback, some form of interpolation is necessary, and an animation manager is recommended. This manager would take pairs of (signal, object) and update object values based on the current time.

var DataBinding = function(signal, object){
    this.signal = signal;
    this.object = object;
    this.updateTime = function(t){
       var val = this.signal.interpolateValue(t);
       for(var prop in val){
           if(val.hasOwnProperty(prop)){
               this.object[prop] = val[prop]; //copy values into object
           }
       }
    }
}
var DataSimulator = function(){
    this.time = 0;
    this.bindings = [];
    this.advance = function(timeDelta){
        this.time += timeDelta;
        var time = this.time;
        this.bindings.forEach(function(b){
            b.updateTime(time);
        });
    }
}

If memory becomes a concern, consider storing DataPoints in a Float32Array or another binary buffer.

Update:

Please bear in mind that this approach aims to optimize memory usage and data processing. One focuses on reducing heap storage and garbage collection, while the other prioritizes CPU efficiency.

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

Retrieve the array element that is larger than the specified number, along with its adjacent index

Consider the following object: const myObject = { 1: 10, 2: 20, 3: 30, 4: 40, 5: 50, }; Suppose we also have a number, let's say 25. Now, I want to iterate over the myObject using Object.entries(myObject), and obtain a specific result. For ...

Troubleshooting ECONNREFUSED in NextJS API: App successfully runs in both deploy and development mode, but encounters issues when next build is executed

Detailing the Glitch I've developed an application using NextJS that incorporates an internal API, utilizing the getStaticProps methods to interact with the API. You can access the live app at this link: Additionally, you can find the project' ...

Sorting tables in Jquery with advanced filter options and seamless integration with an ajax pager

I've implemented a tablesorter library for sorting and filtering data in a table along with a plugin that allows me to paginate the table across multiple pages. Due to the increasing number of records in my table causing slow loading times (>60 se ...

What is the best way to implement custom serialization for Date types in JSON.stringify()?

class MyClass { myString: string; myDate: Date; } function foo() { const myClassArray: MyClass[] = .... return JSON.stringify(myClassArray); // or expressApp.status(200).json(myClassArray); } foo will generate a JSON string with the date format o ...

Using Symbol.iterator in Typescript: A step-by-step guide

I have decided to upgrade my old React JavaScript app to React Typescript. While trying to reuse some code that worked perfectly fine in the old app, I encountered errors in TS - this is also my first time using TS. The data type I am exporting is as foll ...

Nested within an it block are Protractor Jasmine describe blocks

Initially, the code provided below appears to be functioning properly. However, I have not come across anyone using this method before, leading me to question its validity and potential unforeseen drawbacks. The scenario involves writing an end-to-end tes ...

Encountering a 500 error when making API requests after deploying Next.js on Vercel, although they work fine

I recently deployed my Next.js app to Vercel, and I'm experiencing issues with my API calls returning a 500 status code, even though they work perfectly fine on localhost. The initial load using getStaticProps seems to be working, so I suspect the con ...

`Loading CSS and JS files in node.js: A step-by-step guide`

I've searched through numerous similar questions without success, so I'm reaching out for help. My folder structure looks like this: Source Code Frontend Graphs.html Graphs.css Temperature.js Server_Backend server.js I aim ...

Combining user input with React's useState function

I have a form with three Quantity inputs. (Although more can be added dynamically, let's keep it simple for now and stick to three.) | - | - | Quantity | |---|---|----------| | - | - | 3 | | - | - | 4 | | - | - | 5 | Now, I want ...

Tips for defining a relative path in the base URL with AngularJS

Encountering an issue with AngularJS routes related to file paths. The folder structure is as follows: js -> Angular -> css -> Bootstrap -> index.html Routes work fine when hosted on a server like IIS. However, copying and pasting the direct ...

Unable to transfer data from Laravel's Blade template to a Vue component

Need help passing a value from Laravel to Vue. I'm facing an issue where the props I receive are always showing as undefined in the console.log output. I've double-checked for camel case errors but can't seem to find the root cause of the pr ...

A curious phenomenon observed in the behavior of the jQuery offset() method

Once I executed the following code snippet multiple times: $view.offset({ left : X, //X remains constant top : this.y }); console.log($view.offset()); //displays expected output I noticed (using Firebug) that the HTML code looked like this: <di ...

Updating a section of a webpage using jQuery Mobile

I'm currently facing an issue with modifying a specific section of my webpage. Although this problem has been discussed before, I haven't found a satisfactory solution yet. The element in red on the page needs to change dynamically based on the ...

Displaying sorted objects from Angular serviceIn Angular 8, let's retrieve an object

In my Angular8 application, I am running a query that fetches a data object. My goal is to sort this data object based on the order value and then display each product item on the browser. For example, here is an example of how the output should look like ...

Having trouble getting dayjs to work in the browser with Vue.js?

Trying to display date differences in a human-readable format using the guide found here: I'm attempting to incorporate DayJS as a component in my VueJS application like this: <script src="{{ asset('/vendor/vuejs/vue.js') }}" t ...

Encountering issues when using array.map with null entries in a react application

Struggling to iterate over the location array and map it? Despite several attempts, handling the null object within the array seems challenging. What am I missing here? While using a for loop resolves the issue, the map function is proving to be a roadbloc ...

What is the correct method for iterating through this array of objects and eliminating those with either null or empty item.text values?

Currently, I am working with the following Array: const contactInfo = computed(() => { return [ { id: 'address', icon: 'detail/clubLocation', text: `${props.data.contactInfo.address}` ...

Having difficulty executing the .exec() method of the nodejs simple-ssh module

I am currently using npm's simple-ssh library to establish a connection with a remote host as the root user. I have an additional superuser account named serviceUser. My objective is to switch to this user by running su serviceUser (Note: su service ...

What is the maximum amount of information that can be stored in a data attribute within the DOM?

Occasionally, I find myself wanting to include a substantial amount of data on the webpage in order to minimize additional AJAX calls for dynamic content. However, I am concerned about potential performance implications. Is there a penalty I should be aw ...

Switching between a secondary menu using ClassieJS or jQuery?

Currently, the code is configured to toggle the same menu for every icon. To see my current progress, you can check out this fiddle: http://jsfiddle.net/2Lyttauv/ My goal is to have a unique menu for each individual icon. I began by creating the followi ...