encountering the recurring issue of receiving the error message "THREE.WebGLRenderer.render

I encountered an issue with my code after adding the update function. I am now constantly receiving an error message: "THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera" and I am unsure of how to resolve it. While I did find a similar question on StackOverflow, the answer provided was not helpful.

function initialize(){
var scene = new THREE.Scene();

var box = getBox(1 , 1, 1);
var plane = getPlane(4);

scene.add(box);
scene.add(plane);

box.position.y = box.geometry.parameters.height/2;
plane.rotation.x = Math.PI/2; 

var camera = new THREE.PerspectiveCamera(
    45,
    window.innerWidth/window.innerHeight,
    1,
    1000
);
camera.position.z = 5;
camera.position.x = 1;
camera.position.y = 2;

camera.lookAt(new THREE.Vector3(0, 0, 0));

var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth,window.innerHeight);
document.getElementById('webgl').appendChild(renderer.domElement);

update(renderer,scene,camera);

return scene;
 }
function getBox(width, height, depth){
var geometry = new THREE.BoxGeometry(width, height, depth);
var material = new THREE.MeshBasicMaterial({
    color: 0x00ff00
});
var mesh = new THREE.Mesh(
    geometry,
    material
);
return mesh;
 }
function getPlane(size){
var geometry = new THREE.PlaneGeometry(size,size);
var material = new THREE.MeshBasicMaterial({
    color: 0xff0000,
    side : THREE.DoubleSide
});
var mesh = new THREE.Mesh(
    geometry,
    material
);
return mesh;
 }
function update(renderer, scene, camera) {
renderer.render(
    camera,
    scene
);
requestAnimationFrame(function () {
    update(renderer,scene,camera);
});
}
var scene = initialize();

Answer №1

The issue lies within the "update" function.

function update(renderer, scene, camera) {
    renderer.render(
        scene,
        camera
    );
}

The sequence of parameters is incorrect.

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

Interactive HTML Table - Capture Modified Fields

I currently have an HTML table that I am working with. The structure of the table is as follows: <table style="width:100%"> <tr> <th>id</th> <th>Lastname</th> <th>Age</th> </tr> <t ...

Using Node.js and the Jade templating engine, display the value of a passed variable

Asking such a basic question makes me feel guilty. app.get('/skumanagement/:id', function (req, res){ var options = req.params.id; // req.params.id = itemidx database.skuGetDetail(options, function (error, data){ winston.log('inf ...

How can I update a dropdown menu depending on the selection made in another dropdown using Angular

I am trying to dynamically change the options in one dropdown based on the selection made in another dropdown. ts.file Countries: Array<any> = [ { name: '1st of the month', states: [ {name: '16th of the month&apos ...

What is the best way to incorporate tooltips in SVG?

My teacher wants me to display a tooltip on an SVG circle with links and information when we hover over it. They suggested using jQuery UI, but I've done extensive research and nothing has been able to assist me so far. ...

Having trouble with Next Js and Typescript, specifically receiving the error TS2304: Unable to locate name 'AppProps'?

I encountered the error message "TS2304: Cannot find name 'AppProps' when trying to launch a basic Next Js project using TypeScript. After searching on Stack Overflow for similar issues, I haven't found any solutions that work for me. imp ...

Buefy's Loading Feature in Action with b-table

I am currently working on enhancing the animation of the Buefy loader to display text while loading data into my b-table. Is there a way for me to customize the default loader? It would be great if I could personalize the vue spinner to include text in th ...

JavaScript Control for Embedding Facebook Videos (Start / Stop)

I need assistance on how to correctly utilize this API with the code provided in the following URL: https://developers.facebook.com/docs/plugins/embedded-video-player/api/#control-reference https://i.sstatic.net/jQQeN.png window.fbAsyncInit = function() ...

Two interactive dropdown menus featuring custom data attributes, each influencing the options available in the other

Looking to create interactive select boxes based on the data attribute values? This is the code I currently have: HTML <select id="hours" onchange="giveSelection()"> <option value="somethingA" data-option="1">optionA</option> <o ...

Controlling the HTML5 dialog element within a React application

Struggling to implement a basic configuration dialog with a close icon in the top-right corner using React. In other frameworks, it's easy to show/hide a dialog with .showModal()/close(), but manipulating the DOM directly in React is not recommended. ...

CSS Flexibility

Greetings everyone, it's been a while since I dabbled in web development. I recently worked on my site with the intention of making it responsive using flexbox. This is my first time posting here, so please guide me on how to seek help more effective ...

Are you ensuring compliance with licensing in your Webpack bundles?

Can webpack be used to verify license compliance? I'm looking for a way to ensure that the license headers from all modules built by webpack are included in the final output file. How can we confirm this is happening? Furthermore, I am also intereste ...

JavaScript: Analyzing the occurrence rate of emojis within text

I'm currently working on a project to tally the frequency of emojis within a body of text. For instance: "I adore ...

Effortless Like/Unlike feature with a text button option enhanced with ajax functionality and

Struggling to create a simple Like/Unlike button in PHP without refreshing the page. Despite an abundance of tutorials on AJAX and jQuery, implementation remains elusive due to lack of experience. Uncertain where each part of the code goes within which fil ...

steps to eliminate a cookie upon second click

I have successfully implemented a feature where the color of a button is stored in a cookie, so that when the button is clicked, the CSS color remains even after page refresh. However, I am struggling to figure out how to destroy the cookie after the secon ...

Data is not loaded until after the HTML for the Nuxt page has been

My issue is that I have a dynamic page where product details are loaded, but the html code loads before the data. This results in errors when trying to use static elements like images because the "product" object does not exist. To address this problem, I ...

Encountering a Circular JSON stringify error on Nest.js without a useful stack trace

My application is being plagued by this critical error in production: /usr/src/app/node_modules/@nestjs/common/services/console-logger.service.js:137 ? `${this.colorize('Object:', logLevel)}\n${JSON.stringify(message, (key, value ...

Implementing Canvas Offset in a jQuery Mobile Environment

I have positioned a pen ready for use at this location. http://codepen.io/prantikv/pen/LEbRKY Currently, I am utilizing a canvas to track mouse movements or touch input. It performs as expected when jQuery or jQuery mobile is not included. However, upon ...

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 ...

What is the solution for fixing the error when setting the Content-Type to "application/x-www-form-urlencoded" using xhttp.setRequestHeader()?

Despite searching extensively, I couldn't find the solution to this particular issue on Stack Overflow. Currently, my focus is on saving a large amount of HTML data to a database using AJAX JavaScript with PHP. Below is the snippet of my JavaScript c ...

A guide on displaying a text file from a URL in a reactjs application

When utilizing the code provided below, I have successfully managed to display the content of a local text file on a webpage. However, when attempting to render a text file from a URL, the state becomes null resulting in an empty display. In order to ren ...