File tree Expand file tree Collapse file tree 3 files changed +24
-17
lines changed
Expand file tree Collapse file tree 3 files changed +24
-17
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ function Setup (game) {
6363 ] )
6464 const gui = new dat . GUI ( )
6565 game . params = {
66- chunkdist : 4
66+ chunkdist : 4 ,
67+ frustumtest : false
6768 }
6869 game . distanceBasedFog . updateDistance ( game . params . chunkdist )
6970 gui
@@ -103,6 +104,10 @@ function Setup (game) {
103104 . add ( game . world . material , 'wireframe' )
104105 . name ( 'Wireframe' )
105106 . listen ( )
107+ gui
108+ . add ( game . params , 'frustumtest' )
109+ . name ( 'Frustum test' )
110+ . listen ( )
106111 game . eh = new EventHandler ( game )
107112}
108113
Original file line number Diff line number Diff line change @@ -123,24 +123,26 @@ class Game {
123123 this . bb . startDigging ( time )
124124 } )
125125 setInterval ( ( ) => {
126- const frustum = new Frustum ( )
127- const cameraViewProjectionMatrix = new Matrix4 ( )
126+ if ( this . params . frustumtest ) {
127+ const frustum = new Frustum ( )
128+ const cameraViewProjectionMatrix = new Matrix4 ( )
128129
129- this . camera . updateMatrixWorld ( )
130- this . camera . matrixWorldInverse . copy ( this . camera . matrixWorld ) . invert ( )
131- cameraViewProjectionMatrix . multiplyMatrices ( this . camera . projectionMatrix , this . camera . matrixWorldInverse )
132- frustum . setFromProjectionMatrix ( cameraViewProjectionMatrix )
130+ this . camera . updateMatrixWorld ( )
131+ this . camera . matrixWorldInverse . copy ( this . camera . matrixWorld ) . invert ( )
132+ cameraViewProjectionMatrix . multiplyMatrices ( this . camera . projectionMatrix , this . camera . matrixWorldInverse )
133+ frustum . setFromProjectionMatrix ( cameraViewProjectionMatrix )
133134
134- this . scene . traverse ( ( node ) => {
135- if ( node instanceof Mesh ) {
136- if ( frustum . intersectsObject ( node ) ) {
137- node . visible = true
138- } else {
139- node . visible = false
135+ this . scene . traverse ( ( node ) => {
136+ if ( node instanceof Mesh ) {
137+ if ( frustum . intersectsObject ( node ) ) {
138+ node . visible = true
139+ } else {
140+ node . visible = false
141+ }
140142 }
141- }
142- } )
143- } , 1000 )
143+ } )
144+ }
145+ } , 2000 )
144146 return this . animate ( )
145147 }
146148
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class TerrainManager {
8686 let nearestDistance = - 1
8787 let isNearest = false
8888 for ( const chunkId in this . chunkNeedsUpdate ) {
89- const pos = chunkTerrain . strToVec ( chunkId )
89+ const pos = this . chunkTerrain . strToVec ( chunkId )
9090 const dist = this . distance ( chunkId )
9191 if (
9292 ( nearestDistance === - 1 || nearestDistance > dist ) &&
You can’t perform that action at this time.
0 commit comments