From fb68cfbd18fbeb967f248f1588a5c8d51c6b0772 Mon Sep 17 00:00:00 2001 From: monsterkodi Date: Tue, 30 Aug 2016 21:24:34 +0200 Subject: [PATCH] stone order --- coffee/lib/pos.coffee | 1 + coffee/world.coffee | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/coffee/lib/pos.coffee b/coffee/lib/pos.coffee index 0397a8a..6d2c437 100644 --- a/coffee/lib/pos.coffee +++ b/coffee/lib/pos.coffee @@ -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 diff --git a/coffee/world.coffee b/coffee/world.coffee index 6b21303..2a7a788 100644 --- a/coffee/world.coffee +++ b/coffee/world.coffee @@ -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