small medium large xlarge

Generic-user-small
01 Feb 2018, 02:21
guy dude guy (5 posts)

So, for some reason, the orthographic camera does not seem to be registering the blocks I’ve created when I switch from perspective: Here

I’ve done a lot of trouble shooting but I cannot discover the root of the problem. I hope it’s not simple :P If you could find a solution to this problem in which I don’t have to change much of the code below that start scene stuff, that would be wonderful. The reason I have this problem is that I was working on a project I thought would be good as 3d but I changed my mind, so now I want it 2d.

Thanks for the help!

Chris_strom_headshot_200_pragsmall
01 Feb 2018, 03:48
Chris Strom (278 posts)

Well, it’s definitely not a problem your code :)

Looks like you’ve hit a bug in the version of Three.js that we’re using. You can fix it either by switching to the WebGLRenderer or, if you stick with the CanvasRenderer, by doing something weird (but easy) to the orthographic camera.

The first 4 numbers in the orthographic camera describe the width and height of the camera. Those are fine. The next two number describe how close and how far away things can be so that that camera can see them. The first number, the one that says how close things can be, is the problem.

You should be able to set it to 1 to say that anything at a distance of 1 or more can be seen. That’s what your code does. And again, it works in with the WebGL renderer. But a bug in Three.js breaks that in the canvas renderer.

Happily, there’s a workaround. If you set that number to a negative number, it magically works! .

  var camera = new THREE.OrthographicCamera(
    width / -2, width / 2, height / 2, height / -2, -1, 10000
  );

.

That should get things working for you. Let me know if you still have any problems with it.

-Chris

You must be logged in to comment