stone order

This commit is contained in:
monsterkodi 2016-08-30 21:24:34 +02:00
parent 8da4ab64a8
commit fb68cfbd18
2 changed files with 12 additions and 0 deletions

View File

@ -28,6 +28,7 @@ class Pos
if Number.isNaN @x
throw new Error
length: -> Math.sqrt @x*@x + @y*@y + @z*@z
vector: -> new Vector @x, @y, @z
minus: (p) -> new Pos @x-p.x, @y-p.y, @z-p.z
plus: (p) -> new Pos @x+p.x, @y+p.y, @z+p.z

View File

@ -678,6 +678,17 @@ class World extends Actor
@player.setOpacity clamp 0, 1, @player.camera.getPosition().minus(@player.current_position).length()-0.4
stones = []
for o in @objects
if o instanceof Stone
stones.push o
stones.sort (a,b) => b.getPos().minus(@player.camera.getPosition()).length() - a.getPos().minus(@player.camera.getPosition()).length()
order = 100
for stone in stones
stone.mesh.renderOrder = order
order += 1
@sun.position.copy camera.position
@renderer.render @scene, camera