From a2cd885c7f93de51e5caaa820609b58b7633ca58 Mon Sep 17 00:00:00 2001 From: monsterkodi Date: Thu, 1 Sep 2016 10:44:59 +0200 Subject: [PATCH] misc --- coffee/lib/pos.coffee | 1 - coffee/pushable.coffee | 2 +- coffee/wall.coffee | 2 +- coffee/world.coffee | 12 +++++++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/coffee/lib/pos.coffee b/coffee/lib/pos.coffee index 6d2c437..fcbb3e3 100644 --- a/coffee/lib/pos.coffee +++ b/coffee/lib/pos.coffee @@ -5,7 +5,6 @@ # 000 000 000 000 # 000 0000000 0000000 -log = require '/Users/kodi/s/ko/js/tools/log' Vector = require './vector' class Pos diff --git a/coffee/pushable.coffee b/coffee/pushable.coffee index b48968d..e90fc16 100644 --- a/coffee/pushable.coffee +++ b/coffee/pushable.coffee @@ -34,7 +34,7 @@ class Pushable extends Item pushAction = @getActionWithId Action.PUSH @pusher = object @move_action = pushAction - @direction = dir + @direction = new Vector dir pushAction.duration = world.unmapMsTime duration Timer.addAction pushAction diff --git a/coffee/wall.coffee b/coffee/wall.coffee index 236c6df..9f96da0 100644 --- a/coffee/wall.coffee +++ b/coffee/wall.coffee @@ -24,7 +24,7 @@ class Wall extends Item geom = Cage.wallTiles new Pos(1,1,1), 'outside', Cage.gap geom.translate -0.5, -0.5, -0.5 - @plates = new THREE.Mesh geom, Material.plate + @plates = new THREE.Mesh geom, Material.plate.clone() @plates.receiveShadow = true @mesh = new THREE.Object3D diff --git a/coffee/world.coffee b/coffee/world.coffee index 8f41950..faec886 100644 --- a/coffee/world.coffee +++ b/coffee/world.coffee @@ -37,6 +37,7 @@ Pos = require './lib/pos' _ = require 'lodash' now = require 'performance-now' { +Wall, Wire, Gear, Stone, @@ -685,12 +686,21 @@ class World extends Actor 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() + stones.sort (a,b) => b.position.minus(@player.camera.getPosition()).length() - a.position.minus(@player.camera.getPosition()).length() order = 100 for stone in stones stone.mesh.renderOrder = order order += 1 + + d = stone.position.minus(@player.camera.getPosition()).length() + if d < 1.0 + console.log 'd', d + stone.mesh.material.orig_opacity = stone.mesh.material.opacity if not stone.mesh.material.orig_opacity? + stone.mesh.material.opacity = 0.2 + d * 0.5 + else if stone.mesh.material.orig_opacity? + stone.mesh.material.opacity = stone.mesh.material.orig_opacity + delete stone.mesh.material.orig_opacity @sun.position.copy camera.position @renderer.autoClearColor = false