Skip to content

Commit 5442ffc

Browse files
committed
FaceVertex Color prototype
1 parent 607a008 commit 5442ffc

File tree

10 files changed

+39
-12
lines changed

10 files changed

+39
-12
lines changed

coffee/client/module/World/AnimatedTextureAtlas.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class AnimatedTextureAtlas
7272
@material=new THREE.MeshStandardMaterial({
7373
side: 0
7474
map:null
75+
vertexColors: true
7576
})
7677
@atlasCreator=new TextureAtlasCreator({
7778
textureX:@al.get "blocksAtlasFull"

coffee/client/module/World/BlockGeo.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,51 @@ class BlockGeo
2626
else
2727
toxX=@blocksMapping["debug"]["x"]
2828
toxY=28-@blocksMapping["debug"]["y"]
29+
li = [255,255,255]
30+
sh = [0,0,0]
2931
uv=@getToxel toxX,toxY
3032
switch type
3133
when "pz"
3234
return {
3335
pos:[-0.5+pos[0], -0.5+pos[1], 0.5+pos[2],0.5+pos[0], -0.5+pos[1], 0.5+pos[2],-0.5+pos[0], 0.5+pos[1], 0.5+pos[2],-0.5+pos[0], 0.5+pos[1], 0.5+pos[2],0.5+pos[0], -0.5+pos[1], 0.5+pos[2],0.5+pos[0], 0.5+pos[1], 0.5+pos[2]]
3436
norm:[0, 0, 1,0, 0, 1,0, 0, 1,0, 0, 1,0, 0, 1,0, 0, 1]
3537
uv:[uv[0]...,uv[2]...,uv[1]...,uv[1]...,uv[2]...,uv[3]...]
38+
color:[]
3639
}
3740
when "nx"
3841
return {
3942
pos:[ 0.5+pos[0], -0.5+pos[1], 0.5+pos[2], 0.5+pos[0], -0.5+pos[1], -0.5+pos[2],0.5+pos[0], 0.5+pos[1], 0.5+pos[2], 0.5+pos[0], 0.5+pos[1], 0.5+pos[2],0.5+pos[0], -0.5+pos[1], -0.5+pos[2], 0.5+pos[0], 0.5+pos[1], -0.5+pos[2]]
4043
norm:[ 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]
4144
uv:[uv[0]...,uv[2]...,uv[1]...,uv[1]...,uv[2]...,uv[3]...]
45+
color:[]
4246
}
4347
when "nz"
4448
return {
4549
pos:[ 0.5+pos[0], -0.5+pos[1], -0.5+pos[2],-0.5+pos[0], -0.5+pos[1], -0.5+pos[2],0.5+pos[0], 0.5+pos[1], -0.5+pos[2], 0.5+pos[0], 0.5+pos[1], -0.5+pos[2],-0.5+pos[0], -0.5+pos[1], -0.5+pos[2],-0.5+pos[0], 0.5+pos[1], -0.5+pos[2]]
4650
norm:[ 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1]
4751
uv:[uv[0]...,uv[2]...,uv[1]...,uv[1]...,uv[2]...,uv[3]...]
52+
color:[]
4853
}
4954
when "px"
5055
return {
5156
pos:[-0.5+pos[0], -0.5+pos[1], -0.5+pos[2],-0.5+pos[0], -0.5+pos[1], 0.5+pos[2],-0.5+pos[0], 0.5+pos[1], -0.5+pos[2],-0.5+pos[0], 0.5+pos[1], -0.5+pos[2],-0.5+pos[0], -0.5+pos[1], 0.5+pos[2],-0.5+pos[0], 0.5+pos[1], 0.5+pos[2]]
5257
norm:[-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0]
5358
uv:[uv[0]...,uv[2]...,uv[1]...,uv[1]...,uv[2]...,uv[3]...]
59+
color:[]
5460
}
5561
when "py"
5662
return {
5763
pos:[ 0.5+pos[0], 0.5+pos[1], -0.5+pos[2],-0.5+pos[0], 0.5+pos[1], -0.5+pos[2],0.5+pos[0], 0.5+pos[1], 0.5+pos[2], 0.5+pos[0], 0.5+pos[1], 0.5+pos[2],-0.5+pos[0], 0.5+pos[1], -0.5+pos[2],-0.5+pos[0], 0.5+pos[1], 0.5+pos[2]]
5864
norm:[ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]
5965
uv:[uv[0]...,uv[2]...,uv[1]...,uv[1]...,uv[2]...,uv[3]...]
66+
color:[]
6067
}
6168
when "ny"
6269
return {
6370
pos:[ 0.5+pos[0], -0.5+pos[1], 0.5+pos[2],-0.5+pos[0], -0.5+pos[1], 0.5+pos[2],0.5+pos[0], -0.5+pos[1], -0.5+pos[2], 0.5+pos[0], -0.5+pos[1], -0.5+pos[2],-0.5+pos[0], -0.5+pos[1], 0.5+pos[2],-0.5+pos[0], -0.5+pos[1], -0.5+pos[2]]
6471
norm:[ 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0]
6572
uv:[uv[0]...,uv[2]...,uv[1]...,uv[1]...,uv[2]...,uv[3]...]
73+
color:[]
6674
}
6775

6876
export {BlockGeo}

coffee/client/module/World/ChunkWorker.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ class TerrainManager
1818
positions=[]
1919
normals=[]
2020
uvs=[]
21+
colors=[]
2122
addFace=(type,pos)->
2223
faceVertex=_this.BlockGeo.genBlockFace type,_this.cellTerrain.getBlock(pos...),pos
2324
positions.push faceVertex.pos...
2425
normals.push faceVertex.norm...
2526
uvs.push faceVertex.uv...
27+
colors.push(0.5,0.5,0.5,0.5,0.5,0.5,1,1,1,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5)
2628
return
2729
for i in [0..@cellSize-1]
2830
for j in [0..@cellSize-1]
@@ -58,6 +60,7 @@ class TerrainManager
5860
positions
5961
normals
6062
uvs
63+
colors
6164
}
6265

6366
addEventListener "message", (e)->

coffee/client/module/World/World.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ class World
8585
geometry.setAttribute 'position',new THREE.BufferAttribute(new Float32Array(cell.positions), 3)
8686
geometry.setAttribute 'normal',new THREE.BufferAttribute(new Float32Array(cell.normals), 3)
8787
geometry.setAttribute 'uv',new THREE.BufferAttribute(new Float32Array(cell.uvs), 2)
88+
geometry.setAttribute 'color',new THREE.BufferAttribute(new Float32Array(cell.colors), 3)
8889
if mesh is undefined
90+
console.log geometry
8991
@cellMesh[cellId]=new THREE.Mesh geometry,@material
9092
@scene.add @cellMesh[cellId]
9193
else

coffee/client/module/index.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ init = ()->
1717
PixelRatio:window.devicePixelRatio
1818
}
1919
scene=new THREE.Scene
20-
camera = new THREE.PerspectiveCamera 90, 2, 0.1, 1000
20+
camera = new THREE.PerspectiveCamera 100, 2, 0.1, 1000
2121
camera.rotation.order = "YXZ"
2222
camera.position.set 26, 26, 26
2323

src/client/module/World/AnimatedTextureAtlas.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/module/World/BlockGeo.js

Lines changed: 15 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/module/World/ChunkWorker.js

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/module/World/World.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/module/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)