@@ -31,6 +31,9 @@ function Game(opts) {
31
31
if ( ! opts ) opts = { }
32
32
if ( process . browser && this . notCapable ( opts ) ) return
33
33
34
+ // is this a client or a headless server
35
+ this . isClient = Boolean ( ( typeof opts . isClient !== 'undefined' ) ? opts . isClient : process . browser )
36
+
34
37
if ( ! ( 'generateChunks' in opts ) ) opts . generateChunks = true
35
38
this . generateChunks = opts . generateChunks
36
39
this . setConfigurablePositions ( opts )
@@ -100,12 +103,12 @@ function Game(opts) {
100
103
self . removeFarChunks ( )
101
104
} )
102
105
103
- if ( process . browser ) this . materials . load ( this . materialNames )
106
+ if ( this . isClient ) this . materials . load ( this . materialNames )
104
107
105
108
if ( this . generateChunks ) this . handleChunkGeneration ( )
106
109
107
110
// client side only after this point
108
- if ( ! process . browser ) return
111
+ if ( ! this . isClient ) return
109
112
110
113
this . paused = true
111
114
this . initializeRendering ( opts )
@@ -518,7 +521,7 @@ Game.prototype.loadPendingChunks = function(count) {
518
521
var chunkPos = pendingChunks [ i ] . split ( '|' )
519
522
var chunk = this . voxels . generateChunk ( chunkPos [ 0 ] | 0 , chunkPos [ 1 ] | 0 , chunkPos [ 2 ] | 0 )
520
523
521
- if ( process . browser ) this . showChunk ( chunk )
524
+ if ( this . isClient ) this . showChunk ( chunk )
522
525
}
523
526
524
527
if ( count ) pendingChunks . splice ( 0 , count )
@@ -538,7 +541,7 @@ Game.prototype.showChunk = function(chunk) {
538
541
this . voxels . chunks [ chunkIndex ] = chunk
539
542
if ( this . voxels . meshes [ chunkIndex ] ) this . scene . remove ( this . voxels . meshes [ chunkIndex ] [ this . meshType ] )
540
543
this . voxels . meshes [ chunkIndex ] = mesh
541
- if ( process . browser ) {
544
+ if ( this . isClient ) {
542
545
if ( this . meshType === 'wireMesh' ) mesh . createWireMesh ( )
543
546
else mesh . createSurfaceMesh ( this . materials . material )
544
547
this . materials . paint ( mesh )
0 commit comments