From c0f158d4e4c0591b32c4f6b0a57c57201be15139 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 29 Jan 2022 15:16:15 -0500 Subject: [PATCH] clean up lighting code --- src/moto/space.js | 61 +++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/src/moto/space.js b/src/moto/space.js index d7354e7f..1a63a1d5 100644 --- a/src/moto/space.js +++ b/src/moto/space.js @@ -79,9 +79,7 @@ factor: undefined, view: undefined }, - psize = { - - }, + psize = {}, timers = {}, fontColor = '#333333', fontScale = 1.4, // computed relative to grid size @@ -243,40 +241,6 @@ } } - // 4 corners bottom, 4 axis centers top - function updateLights(x, y, z) { - // remove old - for (let l of lights || []) { - SCENE.remove(l); - } - // override - x = y = z = 20000; - x *= 2; y *= 2; z *= 2; - // add new - let x0 = -x/2, y0 = -y/2, z0 = 0; - let x1 = x/2, y1 = y/2, z1 = z / 2, z2 = z; - lights = [ - // top - addLight( x0, y0, z1, lightIntensity * 2.5), - // addLight( x0, y1, z1, lightIntensity * 2.0), - addLight( x1, y1, z1, lightIntensity * 2.5), - // addLight( x1, y0, z1, lightIntensity * 2.0), - // middle - // addLight( x0, y0, z0, lightIntensity * 0.8), - // addLight( x0, y1, z0, lightIntensity * 1.2), // opt - // addLight( x1, y1, z0, lightIntensity * 0.8), - // addLight( x1, y0, z0, lightIntensity * 1.2), // opt - // bottom - // addLight( x0, y0, -z1, lightIntensity * 0.5), - addLight( x0, y1, -z1, lightIntensity * 0.5), - // addLight( x1, y1, -z1, lightIntensity * 0.5), - addLight( x1, y0, -z1, lightIntensity * 0.5), - // center top/bottom - addLight( 0, 0, z2, lightIntensity * 1.2), - addLight( 0, 0, -z2, lightIntensity * 0.8), - ]; - } - function addLight(x,y,z,i) { let l = new THREE.DirectionalLight(0xffffff, i, 0); l.position.set(x,z,y); @@ -288,6 +252,29 @@ return l; } + // 4 corners bottom, 4 axis centers top + function updateLights(x, y, z) { + // remove old + for (let l of lights || []) { + SCENE.remove(l); + } + // override + x *= 4; y *= 4; z *= 4; + // add new + let x0 = -x/2, y0 = -y/2, z0 = 0; + let x1 = x/2, y1 = y/2, z1 = z / 2, z2 = z; + lights = [ + // over + addLight( 0, 0, z2, lightIntensity * 1.2), + addLight( x0, y0, z1, lightIntensity * 2.5), + addLight( x1, y1, z1, lightIntensity * 2.5), + // under + addLight( x0, y1, -z1, lightIntensity * 0.5), + addLight( x1, y0, -z1, lightIntensity * 0.5), + addLight( 0, 0, -z2, lightIntensity * 0.8), + ]; + } + function updatePlatformPosition() { if (isRound) { platform.position.y = -platform.scale.y/2 - platformZOff;