Exploring the capabilities of nested WebGL render targets in the three.js library

I am currently developing an application for the Oculus Rift using JavaScript, three.js, and OculusRiftEffect.js.

In order to create a transparent portion of a 2D ring for the menu, I am attempting to generate a MeshBasicMaterial.alphaMap texture on a WebGLRenderTarget. However, I am encountering conflicts with OculusRiftEffect.js as it also utilizes a WebGLRenderTarget. The specific issue arises during:

The setup for rendering the texture:

menuAlphaScene = new THREE.Scene();
menuAlphaCamera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000); // perhaps an orthographic camera would be more suitable
menuAlphaCamera.position.z = 1;
menuAlphaRT = new THREE.WebGLRenderTarget(512, 512, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBFormat });

Assigning the texture to the object (note that I am currently using map for debugging purposes instead of alphaMap):

menuObject = new THREE.Mesh(new THREE.RingGeometry(0.7, 1, 30, 30), new THREE.MeshBasicMaterial({
    side: THREE.DoubleSide,
    map: menuAlphaRT
}));

Rendering the texture:

function regenMenuAlphaTexture(sixth) {
    var rtScene = new THREE.Scene();
    if (sixth >= 0) {
        var angle = 2 * Math.PI / 6 * sixth;
        var obj = new THREE.Mesh(new THREE.RingGeometry(0.5, 1, 30, 30, angle, angle + 2 * Math.PI / 6), new THREE.MeshBasicMaterial({
            color: 0xaaaaaa,
            side: THREE.DoubleSide
        }));
        rtScene.add(obj);
    }
    renderer.setClearColor(0xff0000, 1);
    renderer.render(rtScene, menuAlphaCamera, menuAlphaRT);
}

The code within the requestAnimationFrame block:

function render() {
    update();
    renderer.clear();
    regenMenuAlphaTexture(0);
    oculusRiftEffect.render(scene, camera);
    requestAnimationFrame(render);
}

When using oculusRiftEffect, the texture displays as black. However, when using renderer.render, the ring renders correctly.

No OpenGL errors are being reported (at least none that I can see in the console). I am unsure of what may be causing this issue.

Answer №1

Instead of the OculusRiftEffect plugin, I would suggest using VREffect along with VRControls and a specialized Firefox VR browser or a Chrome VR browser.

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

Having issues with the script not functioning when placed in an HTML document or saved as a .js file

Even though the database insertion is working, my script doesn't seem to be functioning properly. The message "successfully inserted" appears on the saveclient.php page instead of the index.html. In my script (member_script.js), I have placed this in ...

What is the specific function of $('id').on('click', this.method.bind(this)) in this scenario?

Check out the app I'm talking about here: I am delving into the bind method in JavaScript to grasp its essence. Upon experimenting with it in the console, my interpretation is that bind produces a duplicate of the function, wherein "this" is tethere ...

"Access denied" error when using Internet Explorer and jQuery

Attempting to make an AJAX call using jQuery's $.post in Internet Explorer is resulting in an error message stating "Permission denied." This peculiar issue only seems to occur when accessing a page after having visited another page. For example, if ...

Discover Your Location in the Web Browser

My webpage includes the following JavaScript code to obtain the user's location: state.currentTimer = navigator.geolocation.watchPosition(success, error, { enableHighAccuracy: true, maximumAge: 5000 }); The page is designed to be accesse ...

Using Vue Router's `push()` method within an asynchronous function will solely modify the URL address

I created a custom loading component that displays while the route is being changed. To ensure the loading component properly waits for a second, the method needs to be asynchronous. However, since implementing this feature, I noticed that the router.push ...

Fetch a document from a NodeJS Server utilizing Express

Is there a way to download a file from my server to my machine by accessing a page on a nodeJS server? I am currently using ExpressJS and I have attempted the following: app.get('/download', function(req, res){ var file = fs.readFileSync(__d ...

Using JQuery's ajax() method within a for loop

I'm currently working on implementing default edit mode in a Razor view. Everything seems to be functioning properly except for the filling function for the dropdown list. As part of my task, I need to populate the state dropdown list based on the cur ...

Accessing Private Files with Signed URLs from AWS S3

Issue: The challenge is to securely allow users to upload a file and retrieve it later. The files are stored in private Buckets and objects using S3 pre-signed URLs for uploading. However, fetching the file poses a problem as the signed URLs expire after ...

Encode image into base64 format without the need for file uploads

Is there a way to save an image in localStorage in base64 format without uploading it? I want to convert an existing image into base64. Can someone provide guidance on how to achieve this? function loadImageFileAsURL() { var filesSelected = document ...

Having trouble making an AJAX request work in AngularJS?

Just dipped my toes into the world of Angular (only a few hours in). Managed to tweak the demo to get close to what I need, but hitting a roadblock with my AJAX request. After trying a variety of fixes, one puts me in an endless loop (discovered that&apos ...

Adjust the position of the object in relation to its current orientation

I am facing a challenge in moving an object upwards in relation to its current direction. I am working with a CubeGeometry that has a specific height, and my goal is to place an object at the top of it and have it rotate along with the cube. Simply adding ...

Determine the daily volume of emails sent from the "no-reply email" address using the Nodemailer library

Our company currently utilizes Nodemailer for internal email communication. Lately, we have been encountering issues with exceeding our daily SMTP relays, resulting in some emails failing to send. To investigate further, I have been tasked with monitoring ...

Struggling to determine if the checkbox has been ticked?

I have integrated a like button on my website using socket io to ensure that it updates for all users when the like button is clicked. I have successfully implemented a like() function that emits liked, increments a counter, and displays it on the page. Ho ...

Highlighting menu elements when landing on a page and making another menu element bold upon clicking in WordPress

I've been searching extensively for a solution to this issue. I'm trying to make the menu item DE appear bold when entering the site, and if I click on EN, I want DE to return to normal (thin) font while EN becomes bold. You can find the site he ...

Ways to place an item within the field of view

I'm currently exploring ways to position an object within the camera's field of view if it extends beyond the edges. I came across this helpful resource: Three.js - Width of view. However, after inputting the values, it provides a result of 5.12 ...

jQuery load fails to fill select dropdown

Upon page load, my code executes a call to mysql to populate a select element with data. This process works smoothly on the initial load or when the page is refreshed. However, I am encountering an issue when attempting to update or repopulate the select e ...

Limiting zero is ineffective when it comes to pop-up issues

Hey there, I'm looking to prevent users from inputting zero and dot in a specific field, which is currently working fine. However, when the field is within a pop-up, the code below doesn't seem to work. <script> $('#name').keyp ...

JavaScript condensed into a single table cell rather than occupying an entire webpage

Hey there, I have a simple question that I can't seem to find the answer to anywhere. I'm working on a JavaScript function that pulls data from my database and I want it to display in one cell of a table instead of outputting to the entire page. ...

Sorting through an array using a different array of values

Looking to filter one array with another, where values in the first array should match 'id' in the second array for filtering. The arrays in question are: const array1 = [a, b, c, d] The array to be filtered based on matching 'id' va ...

Having difficulty assigning an argument to an HTTP get request in AngularJS

I am new to working with AngularJS and I am attempting to pass an integer argument to an HTTP GET request in my controller. Here is a snippet of my code: (function() { angular .module('myApp.directory', []) .factory('Ne ...