Can an unlimited number of renderers be activated in THREE.js?

To avoid getting sidetracked, let me provide some context. I am looking to display numerous waveforms stacked on top of each other using the same time axis in THREE.js. These waveforms are essentially THREE.Line objects and I am working on implementing zoom, pan, and scaling functionalities by adjusting the view bounds of an Orthographic camera.

My initial approach involved creating multiple canvas elements with fixed heights stacked vertically and attaching a THREE.WebGLRenderer to each one. Everything was working smoothly until I attempted to scale beyond 15 waveforms. At that point, THREE.js issued a warning about "too many active WebGL contexts" and began deleting old contexts.

I believe this method is valid since it mirrors the technique demonstrated here:

In the provided example, four WebGLRenderers are generated, each associated with a separate canvas element.

Is there a way to bypass this warning and create an unlimited number of canvas elements, each with its own renderer?

SIDE NOTE:

I have contemplated utilizing a single scene and positioning the waveforms accordingly within it, along with employing multiple cameras following a similar approach as shown here: .

However, this presents two challenges:

(1) It eliminates the convenience of easily applying key and mouse listeners specific to each waveform through DOM manipulation.

(2) This solution also seems to hit a barrier in terms of scalability. Once the height of the renderer surpasses around 6000px, strange rendering issues occur such as parts of the scene not displaying correctly while others appear stretched.

Any assistance provided would be greatly appreciated!

Answer №1

To create a seamless wave form visualization, you can utilize a single non-scrolling canvas that fills the entire window and placeholder DIVs for each waveform. With one renderer, set up a scene for each waveform and use renderer.setViewport and renderer.setScissor to define the location of each DIV before rendering.

The process can be implemented as follows:

renderer.setScissorTest( true );
scenes.forEach( function( scene ) {

  var viewElement = scene.viewElement;

  var rect = viewElement.getBoundingClientRect();

  if ( rect.bottom < 0 || rect.top  > renderer.domElement.clientHeight ||
     rect.right  < 0 || rect.left > renderer.domElement.clientWidth ) {
    return;  
  }

  var width  = rect.right - rect.left;
  var height = rect.bottom - rect.top;
  var left   = rect.left;
  var top    = rect.top;

  renderer.setViewport( left, top, width, height );
  renderer.setScissor( left, top, width, height );

  camera.aspect = width / height;
  camera.updateProjectionMatrix();

  renderer.render( scene, camera );
} );
renderer.setScissorTest( false );

For a practical example, refer to the code snippet provided below

...

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

Is it possible to modify the labels on CKEditor's toolbar elements?

Initializing CKEditor in the following manner: function init() { $( ".ckeditor" ).ckeditor( { format_tags: 'h3;p', toolbar: [ [ "Source", "-", "Bold", "Italic" ], [ "Link", "Unlink" ], [ "Blockquote", "F ...

Sort objects based on a specific property that they possess

In my current setup, I have an array of objects structured as shown below: $scope.people = [{name: {last:"Doe", first:"John"}}, {name: {last:"Smith", first:"Joe"}}]; My goal is to implement a live filt ...

What is the process of transforming an array object into an object containing the same key

I have a collection of objects, each containing the same field called roleMapping. My goal is to group all elements with the same key into an array. Below is the object collection I need to convert: a = [ { roleMapping: { 123: { shortNa ...

Ways to prevent other users from clicking or modifying a particular row

I have a data table in my project that will be accessed by multiple users simultaneously. My requirement is that once a row is selected and edited by one user, it should become unclickable for other users who are also viewing the same page or data table. ...

What steps should I take to transition from R66 to R67 now that the computeCentroids() function has been eliminated?

Recently, I updated my three.js library from version r66 to the latest version r69. However, after removing the computeCentroids() function from my code, my objects are no longer being positioned and rendered correctly (refer to http://jsfiddle.net/j8DN6/8 ...

Update my redirect functions in React Js

I've come across a situation where I have multiple components checking if the user is authenticated to redirect to the login page. componentWillReceiveProps({auth}) { if (auth) { this.props.history.push('/login') } } I fin ...

React component closes onBlur event when clicked inside

I recently developed a React component using Material UI which looks like the code snippet below: <Popper open={open} anchorEl={anchorRef.current} onBlur={handleToggle} transition disablePortal > <MenuList autoFocusItem={open}> ...

I am interested in deleting an element from Firebase using JavaScript

I'm struggling to grasp the concept of deleting an item from my Firebase database. I have successfully created a function (saveEmployee) to add items, but removing them is where I hit a roadblock. HTML <tbody ng-repeat="employee in employees"> ...

The && operator is not executed when the button is disabled

There is a button on the page that has been disabled using the [disabled] property. <button class="btn btn-primary center-block" (click)="sign(sf.value)" [disabled]="validateInsuredFirstName(firstName.value) && validateInsuredLastName(l ...

The unusual interactions between JavaScript and QML

Encountering strange behavior with JavaScript. I am currently working on a basic example application using QT-QML and JavaScript. Within this application, I have implemented HTTP Requests triggered by a button that sends the request through JavaScript. ...

Conceal a dropdown menu when clicked upon

I am currently working on a project that involves a dropdown menu. One of the options triggers an Ajax request to display data in another Div. My goal is to automatically hide the dropdown menu (close it) when this particular option is clicked. <div cl ...

Destructuring and For of Loop in ES6: Capturing the first object only

Working with my react app, I have a specific object called 'topics' that I am looping through: const topics = [ {name: 'Mon', color: 'blue', id: 1}, {name: 'Tue', color: 'red', id: 2}, {name: 'W ...

Guide on syncing Bootstrap 4 sliders using a single set of controls

Is it possible to synchronize a bootstrap 4 carousel with controls to a carousel without any controls? 1) When the control arrows are clicked, both carousels will slide simultaneously. 2) Hovering over either carousel will pause both carousels from slidi ...

The test may detect a variable that was not initialized

I'm trying to understand why I get the error message "variable may not have been initialized" when testing (variable === "some text"), but I don't receive the same error when using (typeof passwordHashOrg !== 'undefined') The code that ...

Ensuring Consistent Height for Bootstrap Card Headers

I am currently working with bootstrap cards on two different web pages. The challenge I am facing is that on one page, the header text has a fixed height so I can easily match their card-header height using min-height. However, on the second page, the card ...

Activating gzip compression using fetch.js

I am utilizing fetch.js (https://github.com/github/fetch) to transmit a rather substantial JSON object to the backend. The size of the JSON is significant due to it containing an SVG image string. My question is whether fetch.js applies gzip compression a ...

Communication between the Node development server and the Spring Boot application was hindered by a Cross-Origin Request

Here is the breakdown of my current setup: Backend: Utilizing Spring Boot (Java) with an endpoint at :8088 Frontend: Running Vue on a Node development server exposed at :8080 On the frontend, I have reconfigured axios in a file named http-common.js to s ...

Bot in discord.js refuses to exit voice channel

I've been struggling to get my bot to leave the voice channel despite trying multiple methods. Here's what I've attempted in the source code: Discord.VoiceConnection.disconnect(); Although this is the current code, I have also tested: messa ...

Integrating a footer into the enhanced search tab slider

I'm struggling to create a sticky footer like the one on w3schools. Even though I used the same code in my material UI demo, it's not functioning properly. I tried debugging by changing the position from fixed to absolute, but it still isn&apos ...

Refresh the location markers on Google Maps API to reflect their current positions

I'm currently in the process of learning how to utilize JavaScript with Rails, and I'm encountering some challenges when it comes to updating my markers based on my current position using AJAX. I suspect that the 'ready page:load' event ...