Content duplication in Three.js with WebGL

I am currently working on a Website that features WebGL content. I have successfully implemented a div element to showcase the WebGL.

Now, my goal is to display this content in multiple divs on the same page, with identical animations across all divs. However, my attempts at creating a second renderer and adding it to another div have been unsuccessful.

Is there a way for me to show the same WebGL content in multiple divs on the same page?

The code snippet below shows how I set up the WebGL content. My attempt to append the renderer to a second div did not yield the desired results.

<div id="WebGLCanvas"/>
        <script>
            // WebGL content creation code here
        </script>
    

EDIT: After trying to add the renderer to a second div element, the scene only appears on the last added div element rather than both. Below is the code snippet illustrating my attempt to have the same content displayed on two separate div elements, with synchronized movements.

container = document.getElementById("webglcanvas");
    container2 = document.getElementById("webglcanvas2");
    containerWidth = container.clientWidth;
    containerHeight = container.clientHeight;
    renderer = new THREE.WebGLRenderer({antialias:true, alpha:true});
    renderer.setSize(containerWidth, containerHeight);
    container.appendChild(renderer.domElement);
    container2.appendChild(renderer.domElement);
    

Answer №1

Yes, it is definitely possible. You can achieve the same effect by using a single camera rather than four different ones. Here is an example for you to refer to:

Let me know if you need any further assistance.

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

What is the process for integrating three.js code manually into an iframe?

I recently posted a question on Stack Overflow inquiring about how to input code into an iframe without using a file or URL. While I was successful with simple cases like <h1>Hello World</h1>, my ultimate goal is to integrate three.js into thes ...

Developing an interactive website utilizing AngularJS, WCF Service, and SQL Server

Exploring the possibilities of creating a web application, I stumbled upon AngularJS. With plans to incorporate WCF Service and SQL Server into my project, I am intrigued by what these technologies can offer. I want to ensure that AngularJS aligns with my ...

What is the best way to create a new row at a specific index in an ng-repeat loop?

My Goal: I am aiming to insert a new row of ul after every 2 elements in my ng-repeat loop. For example: <ul class="col-sm-2"> <li><p>Automobile & Motorcycle</p></li> ...

What steps can be taken to execute a function when a button remains unclicked?

$("#RunCode").click(function(){ var $this = $(this); if($this.data('clicked')) { console.log("Is clicked"); $(".documentWrite").text("Is clicked"); } else { $this.data('clicked', true); consol ...

Whenever Ionic is paired with LokiJS, it consistently results in the error message: "ionic.bundle.js:26794 TypeError: Cannot read property 'insert' of undefined"

Having faced numerous issues with SQLite, I decided to explore LokiJS as an alternative solution for my Ionic app. However, even with LokiJS, I encountered challenges. Currently, I have a simple code that should function smoothly: .controller('Proje ...

What could be the underlying reason for the unusual behavior observed in this range polyfill implementation?

I am attempting to transform an HTML5 range input into a set of radio buttons. Each radio button corresponds to a value within the original range, with text displaying its value. However, I am encountering an issue where the last piece of text, meant to sh ...

How can I retrieve the SID received in a different tab using MSAL.js?

I have successfully integrated MSAL into a client-side library, and things are going smoothly so far. My next goal is to enable Single Sign-On (SSO) by following the instructions provided in the documentation at https://learn.microsoft.com/en-us/azure/act ...

Attempting to utilize the Optimist API's help() function to display the usage() information

I am relatively new to using optimist and despite my attempts at researching and experimenting, I have been unable to find a streamlined method for incorporating a --help option. In the documentation, there is mention of a help() function. Based on this i ...

It appears that Vue.js's this.$nextTick() function does not properly wait for the DOM to finish rendering

Having trouble with nextTick() in Vue. Here's the template code: In the template: <template> <div> <div v-if="editing"> <span ref="theInput" contenteditable="true">{{ someValue }}</span> < ...

Attempting to create a button cluster using Bootstrap and AngularJS for the purpose of navigating to various URLs

Looking to create a pair of buttons using bootstrap and angularjs that will redirect to different URLs when clicked. Here is the relevant code snippet: app.controller('LinkController',function(link, $scope, $location){ $scope.go = function() ...

The compatibility issue between Rails 7 and Bootstrap 5.2.3, along with importmaps JavaScript, is causing dysfunction in the

Feeling a bit lost here, as I've tried several solutions from Stack Overflow related to getting bootstrap 5.2.3 javascript to work for a dropdown menu. Importmaps seem like the best approach, although esbuild was attempted with no luck. Below is a sn ...

View the outcome of a form submission button within Adobe Analytics

In the classic version of my form, I have a submit button. <form action="" name="frm" method=""> <input type="submit" value="submit"> </input> I implemented a jQuery command to track successful form submissions in Adobe Analytics and ca ...

Having trouble with the JSFiddle dropdown button that is unresponsive to

I am currently in the process of developing a test drop-down menu. The open menu button functions correctly, however, the close button is unresponsive to clicking or hovering actions. Upon clicking the open menu button, it should make the other button visi ...

Seeking an efficient localStorage method for easy table modification (HTML page provided)

Currently, I am in the process of developing a custom 'tool' that consists of a main page with a menu and several subpages containing tables. This tool is intended for composing responses using prewritten components with my fellow colleagues at w ...

What could be causing Next.js middleware to run repeatedly?

Recently, I set up a brand new Next.js project using npx create-next-app@latest --typescript. Upon completing the installation (version 13.3.4), without making any modifications to existing files, I introduced a new file named middleware.ts within the src ...

Transforming the color of a globe from black to white with gio js

After searching for a solution to change the color of a Three.js globe, I came across a link that didn't work as expected: Change the color of a Three.js globe. My goal is to change the globe color from black to white using . I attempted to use the f ...

A method for automatically collapsing one div item when another is open

I have tried various methods but none seem to work. I am attempting to open only one div at a time, please click on the link above to see for yourself. Please provide any alternate solutions or suggestions. JsFiddle: http://jsfiddle.net/gm2k3ewp/ < ...

Ajax is failing to receive the PHP response

I've been struggling with retrieving values from the database using AJAX during the window load event. When I directly access the PHP script, I see the correct values on the screen. However, when trying to fetch these values through AJAX on another pa ...

Ways to avoid the occurrence of light banding problem in EffectsComposer

I am encountering an issue with the light quality in my scene when using a composer. While everything looks fine with the standard renderer, the light becomes banded when I add a bloompass with 0.001 strength. The same issue occurs with other passes like L ...

The attempt to access https://registry.npmjs.org/yargs was unsuccessful

I am experiencing difficulties in downloading packages from npm. When attempting to download from https://registry.npmjs.org/yargs, I am receiving an error message that states: write EPROTO 101057795:error:14077419:SSL routines:SSL23_GET_SERVER_HELLO:tls ...