瀏覽代碼

fix viewZToPerspectiveDepth calculation (#28045)

Renaud Rohlinger 1 年之前
父節點
當前提交
0dd43bd6fe
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      examples/jsm/nodes/display/ViewportDepthNode.js

+ 1 - 1
examples/jsm/nodes/display/ViewportDepthNode.js

@@ -75,7 +75,7 @@ export const orthographicDepthToViewZ = ( depth, near, far ) => near.sub( far ).
 // NOTE: https://twitter.com/gonnavis/status/1377183786949959682
 
 // -near maps to 0; -far maps to 1
-export const viewZToPerspectiveDepth = ( viewZ, near, far ) => near.add( viewZ ).mul( far ).div( near.sub( far ).mul( viewZ ) );
+export const viewZToPerspectiveDepth = ( viewZ, near, far ) => near.add( viewZ ).mul( far ).div( far.sub( near ).mul( viewZ ) );
 
 // maps perspective depth in [ 0, 1 ] to viewZ
 export const perspectiveDepthToViewZ = ( depth, near, far ) => near.mul( far ).div( far.sub( near ).mul( depth ).sub( far ) );