-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: janusweb action: commit revision: path_from: revision_from: 472f238fcf471f9c95fda9932b2e9142dc8ffdd7: path_to: revision_to:
commit 472f238fcf471f9c95fda9932b2e9142dc8ffdd7 Author: James Baicoianu <james_github@baicoianu.com> Date: Thu Sep 29 03:06:52 2016 -0700 Allow updating of light properties at runtime diff --git a/scripts/januslight.js b/scripts/januslight.js
--- a/scripts/januslight.js +++ b/scripts/januslight.js @@ -3,35 +3,52 @@ elation.require(['janusweb.janusbase'], function() { this.postinit = function() { elation.engine.things.januslight.extendclass.postinit.call(this); this.defineProperties({ - light_range: { type: 'float', default: 10 }, - light_intensity: { type: 'float', default: 100 }, - light_cone_angle: { type: 'float', default: 0 }, - light_cone_exponent: { type: 'float', default: 1 }, + light_range: { type: 'float', default: 10, set: this.updateLight }, + light_intensity: { type: 'float', default: 100, set: this.updateLight }, + light_cone_angle: { type: 'float', default: 0, set: this.updateLight }, + light_cone_exponent: { type: 'float', default: 1, set: this.updateLight }, }); } this.createObject3D = function() { var obj = new THREE.Object3D(); if (this.light_cone_angle == 0) { - this.light = new THREE.PointLight(0xff0000, this.light_intensity / 1); + this.light = new THREE.PointLight(this.properties.color, this.light_intensity / 100, this.light_range); this.light.position.set(0,0,0); obj.add(this.light); } else if (this.light_cone_angle > 0) { var angle = Math.acos(this.light_cone_angle); - this.light = new THREE.SpotLight(this.color, this.light_intensity / 1, this.light_range, angle); - this.light.position.set(0,0,0); + this.light = new THREE.SpotLight(0xff0000, this.light_intensity / 100, this.light_range, angle); + //this.light.position.set(0,0,0); obj.add(this.light); } return obj; } this.createChildren = function() { + // TODO - should be an easy way of toggling helpers + /* + var scene = this.objects['3d']; + while (scene.parent) { + scene = scene.parent; + } + if (this.light_cone_angle == 0) { var helper = new THREE.PointLightHelper(this.light); - this.parent.objects['3d'].add(helper); + scene.add(helper); } else { var helper = new THREE.SpotLightHelper(this.light); - this.parent.objects['3d'].add(helper); + scene.add(helper); + } + */ + } + this.physics_update = function() { + this.localToWorld(this.light.target.position.set(0,0,-1)); + this.light.target.updateMatrixWorld(); + } + this.updateLight = function() { + if (this.light) { + this.light.intensity = this.light_intensity / 100; + this.light.color.copy(this.color); } - } this.getProxyObject = function() { var proxy = elation.engine.things.janusobject.extendclass.getProxyObject.call(this);
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 15:04:12 2024