@@ -41,17 +41,16 @@ class Game
4141 PixelRatio : window .devicePixelRatio
4242 @scene = new THREE.Scene
4343 @dimBg =
44- " minecraft:overworld" : new THREE.Color " #adc8ff "
45- " minecraft:the_end" : new THREE.Color " #011433 "
46- " minecraft:the_nether" : new THREE.Color " #85280f "
44+ " minecraft:overworld" : [ 173 / 255 , 200 / 255 , 255 / 255 ]
45+ " minecraft:the_end" : [ 1 / 255 , 20 / 255 , 51 / 255 ]
46+ " minecraft:the_nether" : [ 133 / 255 , 40 / 255 , 15 / 255 ]
4747 @camera = new THREE.PerspectiveCamera @fov , 2 , 0.1 , 1000
4848 @camera .rotation .order = " YXZ"
4949 @camera .position .set 26 , 26 , 26
5050 @scene .add new THREE.AmbientLight 0xcccccc
5151 directionalLight = new THREE.DirectionalLight 0x333333 , 2
5252 directionalLight .position .set (1 , 1 , 0.5 ).normalize ()
5353 @scene .add directionalLight
54-
5554 console .warn gpuInfo ()
5655
5756 @nick = document .location .hash .substring 1 ,document .location .hash .length
@@ -94,8 +93,12 @@ class Game
9493 _this .dimension = dim
9594 console .log " Player dimension has been changed: #{ dim} "
9695 _this .world .resetWorld ()
97- _this .scene .background = _this .dimBg [dim]
98- _this .scene .fog .color = _this .dimBg [dim]
96+ bg = _this .dimBg [dim]
97+ _this .scene .background = new THREE.Color bg...
98+ _this .world .ATA .uni .color .x = bg[0 ]
99+ _this .world .ATA .uni .color .y = bg[1 ]
100+ _this .world .ATA .uni .color .z = bg[2 ]
101+ _this .world .ATA .uni .color .w = 1
99102 return
100103 " mapChunk " : (sections ,x ,z ,biomes ,dim )->
101104 _this .world ._computeSections sections,x,z,biomes,dim
@@ -149,19 +152,14 @@ class Game
149152
150153 gui = new dat.GUI
151154 @params =
152- fog : false
153155 chunkdist : 3
154- gui .add ( @params , " fog" ).name ( " Enable fog" ).listen ().onChange ()->
155- if _this .params .fog
156- _this .scene .fog = new THREE.Fog _this .dimBg [_this .dimension ], (_this .params .chunkdist - 2.5 )* 16 , (_this .params .chunkdist - 0.5 )* 16
157- else
158- _this .scene .fog = null
156+ @world .ATA .uni .farnear .x = (@params .chunkdist - 1.5 )* 16
157+ @world .ATA .uni .farnear .y = (@params .chunkdist - 0.5 )* 16
159158 gui .add ( @world .material , " wireframe" ).name ( " Wireframe" ).listen ()
160159 chunkDist = gui .add ( @params , " chunkdist" ,0 ,10 ,1 ).name ( " Render distance" ).listen ()
161160 chunkDist .onChange (val)->
162- if _this .scene .fog isnt null
163- _this .scene .fog .near = (val- 2.5 )* 16
164- _this .scene .fog .far = (val- 0.5 )* 16
161+ _this .world .ATA .uni .farnear .x = (val- 1.5 )* 16
162+ _this .world .ATA .uni .farnear .y = (val- 0.5 )* 16
165163 console .log val
166164 return
167165 @mouse = false
@@ -209,6 +207,7 @@ class Game
209207 if @FPC .gameState is " inventory"
210208 @pii .render ()
211209 @inv_bar .tick ()
210+ @world .ATA .uni .view .copy (@camera .position ).applyMatrix4 (@camera .matrixWorldInverse )
212211
213212 @renderer .render @scene , @camera
214213 return
0 commit comments