Skip to content

Commit d6eaf76

Browse files
committed
mała optymalizacja
1 parent 9257d6f commit d6eaf76

22 files changed

+86
-87
lines changed

coffee/client/module/AnimatedTextureAtlas.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as THREE from './../module/build/three.module.js'
1+
import * as THREE from './build/three.module.js'
22

33
class TextureAtlasCreator
44
constructor: (options)->
@@ -22,7 +22,7 @@ class TextureAtlasCreator
2222
canvasx.height=@willSize*16
2323
toxelX=1
2424
toxelY=1
25-
for i of @textureMapping
25+
for i of @textureMapping
2626
if i.includes "@"
2727
xd=@decodeName i
2828
if multi[xd.pref].loaded is undefined
@@ -64,7 +64,7 @@ class TextureAtlasCreator
6464
#option2
6565
col=Math.ceil(tick/h)-1
6666
row=(tick-1)%h;
67-
return {row,col}
67+
return {row,col}
6868
class AnimatedTextureAtlas
6969
constructor:(options)->
7070
_this=@
@@ -92,4 +92,4 @@ class AnimatedTextureAtlas
9292
return
9393
,100)
9494

95-
export {AnimatedTextureAtlas}
95+
export {AnimatedTextureAtlas}

coffee/client/module/AssetLoader.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as THREE from './../module/build/three.module.js'
2-
import {FBXLoader} from './../module/jsm/loaders/FBXLoader.js'
1+
import * as THREE from './build/three.module.js'
2+
import {FBXLoader} from './jsm/loaders/FBXLoader.js'
33

44
class AssetLoader
55
constructor: (options)->
@@ -45,4 +45,4 @@ class AssetLoader
4545
get: (assetName)->
4646
return @assets[assetName]
4747

48-
export {AssetLoader}
48+
export {AssetLoader}

coffee/client/module/FirstPersonControls.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as THREE from './../module/build/three.module.js'
1+
import * as THREE from './build/three.module.js'
22

33
class FirstPersonControls
44
constructor: (options)->

coffee/client/module/Players.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {SkeletonUtils} from './../module/jsm/utils/SkeletonUtils.js'
2-
import * as THREE from './../module/build/three.module.js'
1+
import {SkeletonUtils} from './jsm/utils/SkeletonUtils.js'
2+
import * as THREE from './build/three.module.js'
33

44
class Player
55
constructor: (options)->
@@ -49,5 +49,5 @@ class Players
4949
delete _this.playersx[p]
5050
return
5151
return
52-
53-
export {Players}
52+
53+
export {Players}

coffee/client/module/Terrain.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as THREE from './../module/build/three.module.js'
1+
import * as THREE from './build/three.module.js'
22
import {CellTerrain} from './CellTerrain.js'
33

44
class Terrain
@@ -17,7 +17,7 @@ class Terrain
1717
cellSize:@cellSize
1818
}
1919
@neighbours=[[-1, 0, 0],[1, 0, 0],[0, -1, 0],[0, 1, 0],[0, 0, -1],[0, 0, 1]]
20-
@worker=new Worker "./module/TerrainWorker.js", {type:'module'}
20+
@worker=new Worker "/module/TerrainWorker.js", {type:'module'}
2121
@worker.onmessage=(message)->
2222
_this.updateCell message.data
2323
@worker.postMessage {

coffee/client/module/TerrainWorker.coffee

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,16 @@ handlers={
180180
setVoxel:(data)->
181181
terrain.setVoxel data...
182182
genCellGeo: (data)->
183-
postMessage {
184-
cell:terrain.genCellGeo data...
185-
info:data
186-
}
183+
184+
if ((terrain.cellTerrain.vec3 data...) of terrain.cellTerrain.cells) is true
185+
geo=terrain.genCellGeo data...
186+
# if terrain.cellTerrain.cells[terrain.cellTerrain.vec3 data...] isnt undefined
187+
postMessage {
188+
cell:geo
189+
info:data
190+
}
191+
else
192+
console.log 'xd'
187193
setCell: (data)->
188194
terrain.cellTerrain.cells["#{data[0]}:#{data[1]}:#{data[2]}"]=data[3]
189195
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11

22
scene=null;materials=null;parameters=null;canvas=null;renderer=null;camera=null;terrain=null;cursor=null;FPC=null;socket=null;stats=null;worker=null;playerObject=null;inv_bar=null
3-
import * as THREE from './module/build/three.module.js'
4-
import {SkeletonUtils} from './module/jsm/utils/SkeletonUtils.js'
5-
import Stats from './module/jsm/libs/stats.module.js'
6-
import {Terrain} from './module/Terrain.js'
7-
import {FirstPersonControls} from './module/FirstPersonControls.js'
8-
import {gpuInfo} from './module/gpuInfo.js'
9-
import {AssetLoader} from './module/AssetLoader.js'
10-
import {InventoryBar} from './module/InventoryBar.js'
11-
import {AnimatedTextureAtlas} from './module/AnimatedTextureAtlas.js'
12-
import {Players} from './module/Players.js'
13-
import {RandomNick} from './module/RandomNick.js'
3+
import * as THREE from './build/three.module.js'
4+
import {SkeletonUtils} from './jsm/utils/SkeletonUtils.js'
5+
import Stats from './jsm/libs/stats.module.js'
6+
import {Terrain} from './Terrain.js'
7+
import {FirstPersonControls} from './FirstPersonControls.js'
8+
import {gpuInfo} from './gpuInfo.js'
9+
import {AssetLoader} from './AssetLoader.js'
10+
import {InventoryBar} from './InventoryBar.js'
11+
import {AnimatedTextureAtlas} from './AnimatedTextureAtlas.js'
12+
import {Players} from './Players.js'
13+
import {RandomNick} from './RandomNick.js'
1414

1515
init = ()->
1616

17-
chunkWorker=new Worker "./module/ChunkWorker.js", {type:'module'}
18-
17+
chunkWorker=new Worker "/module/ChunkWorker.js", {type:'module'}
1918
chunkWorker.onmessage=(data)->
19+
2020
result=data.data.result
2121
for i in result
2222
if i isnt null
@@ -197,8 +197,8 @@ render = ->
197197
cursor.visible=false
198198

199199
#Rendering
200-
renderer.render scene, camera
201200
terrain.updateCells()
201+
renderer.render scene, camera
202202
return
203203
animate = ->
204204
try

coffee/index.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
opn=require "opn"
33
fs=require "fs"
4-
config=JSON.parse fs.readFileSync(__dirname+"/config.json")
4+
config=JSON.parse fs.readFileSync(__dirname+"/../config.json")
55
require("./server")(config)
66

77
opn("http://#{config.host}:#{config['express-port']}")

coffee/server.coffee

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ module.exports=(config)->
5656
cell=new Chunk()
5757
cell.load packet.chunkData,packet.bitMap,false,true
5858
io.to(socket.id).emit "mapChunk", cell.sections,packet.x,packet.z
59-
6059
# console.log packet
6160
return
6261

File renamed without changes.

0 commit comments

Comments
 (0)