The seamless integration of CocoonJS and Three.js with webGLRenderTarget for a smooth and efficient

When using three v 67's WebGLRenderTarget to render a second camera/scene to a buffer for future use in a texture, everything works fine in Three.js, but unfortunately, it encounters issues in CocoonJS.

Various attempts have been made to access the data in CocoonJS, such as trying to access gl.readPixels directly from the context, similar to what is discussed in this Stack Overflow thread. However, none of these methods seem to be successful. Has anyone else faced this problem?

Answer №1

After thoroughly analyzing the native C++ code of CocoonJS running the Three.js demo, I successfully identified and resolved the issue at hand.

Within Three.js, a framebuffer is created for the WebGLRenderTarget object, the color buffer (texture) is attached, a renderBuffer is generated, and a depth/stencil renderbuffer is connected to it. The root of the problem lies in the second argument of the WebGL renderbufferStorage method, resulting in an incomplete framebuffer status. Although Three.js should ideally detect this error through the checkFramebufferStatus method to prevent silent errors, it currently does not do so.

Rest assured, I have implemented the necessary fix, which will be included in the upcoming CocoonJS release.

In the meantime, you can apply a temporary fix in your JS code (which will no longer be required in the next release).

Simply replace the following line in Three.js:

j.renderbufferStorage(j.RENDERBUFFER,j.DEPTH_STENCIL,b.width,b.height)

With the updated version below:

j.renderbufferStorage(j.RENDERBUFFER,navigator.isCocoonJS?35056:j.DEPTH_STENCIL,b.width,b.height)

Best of luck with your game development endeavors :)

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 method for retrieving JSON data within the AngularJS repeat directive?

I am seeking guidance on how to retrieve the main menu and sub menus separately from a JSON file using ng-repeat. Here are the relevant files: menu.json {"data": { "main menu": { "menu1": [ ...

Every time I attempt to make a "post" request to the SailsJS server, I encounter a 403 CSRF Mismatch error

Having an issue with my sailsJS server. I am attempting to send a post request from a client on a different domain. I am sending _csrf from /csrfToken, but encountering a 403 csrf mismatch repeatedly. The client-side code appears as follows: $.ajax( ...

How can I update a specific element within an array of objects in JavaScript based on its reference rather than its index position?

I am dealing with multiple arrays of objects x=[ {a:1}, {b:2}, {c:3}, {d:4} ] y=[ {e:5}, {f:6}, {g:7}, {h:8} ] (etc) and I have a list of references pointing to the objects I need to replace. Instead of having an index into the array, I hold reference ...

Avoid repeated appending of data in JavaScript and HTML

I am working with an HTML table and I need to ensure that the values in the second column do not repeat within the grid. Below is the JavaScript code I have written for this purpose: var $addedProductCodes = []; function getProductData(value){ $t ...

Sending Ajax data to a controller function

I am looking for guidance on how to pass values from my view to my controller using ajax. As someone who is new to working with ajax, I would appreciate some assistance in understanding the process. Full Page @model ALSummary.Models.MonthReport @{ ...

The onBeforeRender callback in ThreeJS is experiencing difficulties with updating object geometry accurately

I've been experimenting with the ThreeJS framework and I'm interested in creating some custom classes based on core objects. Some of these classes require the material or geometry to be refreshed before each render. Let me share a specific issue ...

What is the process for extracting an array from an object?

How can I retrieve an object from an array using Node.js? I have tried the code below, but it's returning the entire object. What I actually need is to only print the name, for example, just "sethu". Code: var sethu = [{ name:'sethu', ...

Perform a bash command using PHP when an HTML button is clicked

Today, my brain seems to be on vacation. Currently, I have set up a Raspberry Pi with vlc running and connected to a mounted screen on the wall. There is a web page with simple controls to manage the pi, switch between different vlc streams, or stop stream ...

Enhance the appearance of the navbar on mobile devices by customizing the styling in Bootstrap 5

Hi everyone, this is my first time posting a question here so please be gentle :) I recently implemented a script to change the CSS of my navbar when scrolling. window.addEventListener("scroll", function () { let header = document.querySelector(".navbar") ...

VS Code sees JavaScript files as if they were Typescript

I have recently delved into the world of Typescript and have been using it for a few days now. Everything seems to be working smoothly - Emmet, linting, etc. However, I've encountered an issue when trying to open my older JavaScript projects in VS Cod ...

Utilize a for loop to reference variable names with numbers

Is there a way to extract values from req.body.answerX without manually coding each one using a for loop? I currently have values stored as "answer1, answer2" and so on. This is what I tried: for( var i = 1; i <= 10; i++){ console.log(req. ...

Encountering a failure when trying to run npm in a React project

I've removed the .lock file and node_modules, then reinstalled, but it's still not working. Can someone assist me with fixing this? npm ERR! gyp ERR! node -v v16.13.0 npm ERR! gyp ERR! node-gyp -v v8.2.0 npm ERR! gyp ERR! not ok npm ERR! node-pr ...

Dealing with AngularJS memory leaks caused by jQuery

How can I showcase a custom HTML on an AngularJS page using the given service? app.service('automaticFunctions', function ($timeout) { this.init = function initAutomaticFunctions(scope, $elem, attrs) { switch (scope.content.type) { ...

Having trouble with the Jquery click event not functioning on an interactive image map in Chrome browser

I currently have an interactive image-map embedded on my website. Here is the HTML code: <div id="italy-map" class="affiancato verticalmenteAllineato"> <div id="region-map"> <img src="./Immagini/transparent.gif" title="Click on ...

Switching images using jQuery

Issue I'm feeling overwhelmed by the abundance of JavaScript code hints and finding it difficult to determine where to begin. Any assistance would be greatly appreciated. Essentially, I have a primary full-screen background image set in the CSS on t ...

Updating a table without the need for a button in PHP and AJAX with an Excel-inspired approach

I'm facing a scenario where I need to dynamically update the contents of a table row. To achieve this, I want the cell to transform into a text box when clicked. Here's how I implemented it: <td contenteditable></td> After making ch ...

Configuring the data source for an autocomplete feature in ReactJS Material UI

For one of my React components, I am utilizing the Material UI autocomplete feature. The data source is retrieved from the server asynchronously and has the following structure: const dataSource = [{ id: 001 firstName: 'fname', lastName: &apo ...

An error message 'module.js:557 throw err' appeared while executing npm command in the terminal

Every time I try to run npm in the terminal, I encounter this error message and it prevents me from using any npm commands. This issue is also affecting my ability to install programs that rely on nodejs. $ npm module.js:557 throw err; ^ Error: Cannot ...

Printing feature not functioning properly on Internet Explorer version 11

Currently, I am facing an issue with printing a document using a blob URL and iFrame. Everything works perfectly in Chrome, but unfortunately, it's not functioning properly in IE browser. I need guidance on how to successfully print a blob URL that i ...

Establishing a distinct registry for a particular package within the .npmrc configuration file

Today, I encountered a new challenge that I've never faced before. I am currently in need of having private node packages published in both a private and public repository under the same @scope. The packages on npmjs.org are stable and open to the pu ...