spuemaacne
spuemaacne

Reputation: 239

Is positive Z axis going inward in threejs? Camera.near and camera.far behaves funny

I'm trying to render only slice of my 3d object. In orthographic camera I want camera.near as 2.0 and camera.far as 1.5 then iterate and give camera.near = 1.5 and camera.far = 1.0. And so on. But it is not working. When I pass smaller value(2) to camera.near and larger value (10) to camera.far it kind of works. But I want just the opposite. I thought Z axis is coming outward from the screen.

Upvotes: 2

Views: 1249

Answers (1)

Adam Finley
Adam Finley

Reputation: 1610

The z axis in Three.js is positive coming "out."

enter image description here

HOWEVER: the reason things can seem funny is that when you are setting view matrices, you actually specify the near/far planes as distance from the viewer. This is from the OpenGL spec:

Parameters

nearVal, farVal
Specify the distances to the nearer and farther depth clipping planes. These values are negative if the plane is to be behind the viewer.

FYI when you are using a perspective matrix, both values are always positive.

Upvotes: 4

Related Questions