File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,12 @@ class Background extends DataMap {
106106
107107 // compute vertex position
108108 const modifiedPosition = isOrtho . select ( positionLocal . mul ( orthoScale ) , positionLocal ) ;
109- let viewProj = cameraProjectionMatrix . mul ( modelViewMatrix . mul ( vec4 ( modifiedPosition , 1.0 ) ) ) ;
109+
110+ // by using a w component of 0, the skybox will not translate when the camera moves through the scene
111+ const viewPosition = modelViewMatrix . mul ( vec4 ( modifiedPosition , 0.0 ) ) ;
112+
113+ // we force w=1.0 here to prevent the w_clip=0 divide-by-zero error for ortho cameras.
114+ let viewProj = cameraProjectionMatrix . mul ( vec4 ( viewPosition . xyz , 1.0 ) ) ;
110115
111116 // force background to far plane so it does not occlude objects
112117 viewProj = viewProj . setZ ( viewProj . w ) ;
@@ -127,12 +132,6 @@ class Background extends DataMap {
127132 backgroundMesh . frustumCulled = false ;
128133 backgroundMesh . name = 'Background.mesh' ;
129134
130- backgroundMesh . onBeforeRender = function ( renderer , scene , camera ) {
131-
132- this . matrixWorld . copyPosition ( camera . matrixWorld ) ;
133-
134- } ;
135-
136135 function onBackgroundDispose ( ) {
137136
138137 background . removeEventListener ( 'dispose' , onBackgroundDispose ) ;
You can’t perform that action at this time.
0 commit comments