question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

camera is not an instance of THREE.Camera

See original GitHub issue

I am having a problem with the PerspectiveCamera.

Using the default scene in blender I exported it out using the three.js exporter. I included the camera amongst all the other objects and materials etc.

I have been building a JSON file - using it as a namespace (called gl) to set up future projects. It has a render function, a init function and update function. The init functions checks for browser compatibility and ensures that all the “libraries” (for lack of a better term) exist. Then it sets up webgl renderer and loads the JSON scene. It’s similar to the load geometries example, except without all the different loaders. The camera variable is assigned to the currentCamera in the scene.

gl.camera = scene.currentCamera;

According to google chome. The problem is in the render function.

"render" : function () {
    "use strict";
    gl.renderer.render(gl.scene.scene, gl.camera);
}

Google prints the message THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera. Using the watch expression the camera: THREE.PerspectiveCamera.

Why is the happening? doesn’t PerspectiveCamera inherit THREE.Camera?

Also I can access the .updateProjectionMatrix() for some reason.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
robolearycommented, Oct 17, 2013

Hi - I realize this is closed, and that it wasn’t suitable in the first place - but since the original poster doesn’t seem to have followed this up on StackOverflow, and a search for this problem only really returns this page, I thought it might be worth recording the solution here.

I got this same mysterious problem - and even debugging the object being passed to the render function showed it was a PerspectiveCamera. However, checking whether it was an instance of THREE.Camera showed it wasn’t! Black magic!

In fact, the cause was including two copies of three.js in the page - presumably resulting in a new copy of THREE.Camera being compared to an object created using the old copy of THREE.Camera. So the existing PerspectiveCamera instance indeed isn’t descending from THREE.Camera, because THREE.Camera has been replaced.

Remove the second include, and the problem is resolved.

0reactions
callmejerrycommented, Nov 10, 2014

Alright. Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Three.js error "camera is not an instance of ... - Stack Overflow
Camera " when trying to render a cube - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
Read more >
THREE.WebGLRenderer.render: camera is not an instance of ...
Hello, i created a scene in Blender and export all in a gltf file. Inside my JS file, i load the gltf, and...
Read more >
[SOLVED] Camera Rendering Instanced Objects Behind ...
AFAIK, THREE.InstancedMesh does set Object3D.frustumCulled to false in order to prevent view frustum culling. This default value makes sense ...
Read more >
MessyTable: Instance Association in Multiple Camera Views
statistics of MessyTable and the three datasets evaluated in ... Camera Poses and Extrinsic Calibration For each setup, cameras poses,.
Read more >
Using more than one camera - Unity - Manual
By default, a camera renders its view to cover the whole screen and so only one camera view can be seen at a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found