From a897c17eb254080f445ef08a82eea839d73eece6 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 18 Sep 2015 14:31:40 -0700 Subject: [PATCH 1/8] Remove grab-frame and reset position code --- examples/toys/flashlight/flashlight.js | 28 ++------------------------ 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/examples/toys/flashlight/flashlight.js b/examples/toys/flashlight/flashlight.js index 165f693e8e..d5bdb4a630 100644 --- a/examples/toys/flashlight/flashlight.js +++ b/examples/toys/flashlight/flashlight.js @@ -31,15 +31,6 @@ _this._spotlight = null; }; - - GRAB_FRAME_USER_DATA_KEY = "grabFrame"; - - // These constants define the Flashlight model Grab Frame - var MODEL_GRAB_FRAME = { - relativePosition: {x: 0, y: -0.1, z: 0}, - relativeRotation: Quat.angleAxis(180, {x: 1, y: 0, z: 0}) - }; - // These constants define the Spotlight position and orientation relative to the model var MODEL_LIGHT_POSITION = {x: 0, y: 0, z: 0}; var MODEL_LIGHT_ROTATION = Quat.angleAxis (-90, {x: 1, y: 0, z: 0}); @@ -98,8 +89,6 @@ }); _this._hasSpotlight = true; - _this._startModelPosition = modelProperties.position; - _this._startModelRotation = modelProperties.rotation; debugPrint("Flashlight:: creating a spotlight"); } else { @@ -120,10 +109,6 @@ _this._hasSpotlight = false; _this._spotlight = null; - // Reset model to initial position - Entities.editEntity(_this.entityID, {position: _this._startModelPosition, rotation: _this._startModelRotation, - velocity: {x: 0, y: 0, z: 0}, angularVelocity: {x: 0, y: 0, z: 0}}); - // if we are not being grabbed, and we previously were, then we were just released, remember that // and print out a message _this.beingGrabbed = false; @@ -139,17 +124,8 @@ _this.entityID = entityID; var modelProperties = Entities.getEntityProperties(entityID); - _this._startModelPosition = modelProperties.position; - _this._startModelRotation = modelProperties.rotation; - - // Make sure the Flashlight entity has a correct grab frame setup - var userData = getEntityUserData(entityID); - debugPrint(JSON.stringify(userData)); - if (!userData.grabFrame) { - setEntityCustomData(GRAB_FRAME_USER_DATA_KEY, entityID, MODEL_GRAB_FRAME); - debugPrint(JSON.stringify(MODEL_GRAB_FRAME)); - debugPrint("Assigned the grab frmae for the Flashlight entity"); - } + + Script.update.connect(this.update); }, From dc17985e291ce406d91b5c92a64ae524c8ca3f9d Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 18 Sep 2015 15:24:44 -0700 Subject: [PATCH 2/8] Add some logic for turning off the flashlight when squeeze trigger pressure is low, and turning it back on when squeeze pressure goes over certain amount --- examples/toys/flashlight/flashlight.js | 90 ++++++++++++++++++++------ 1 file changed, 72 insertions(+), 18 deletions(-) diff --git a/examples/toys/flashlight/flashlight.js b/examples/toys/flashlight/flashlight.js index d5bdb4a630..cc708beccf 100644 --- a/examples/toys/flashlight/flashlight.js +++ b/examples/toys/flashlight/flashlight.js @@ -12,9 +12,10 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +// TODO: update to use new grab signals, which will include handedness. (function() { - + function debugPrint(message) { //print(message); } @@ -25,24 +26,35 @@ // this is the "constructor" for the entity as a JS object we don't do much here, but we do want to remember // our this object, so we can access it in cases where we're called without a this (like in the case of various global signals) - Flashlight = function() { + Flashlight = function() { _this = this; _this._hasSpotlight = false; _this._spotlight = null; }; + var DISABLE_LIGHT_THRESHOLD = 0.5; // These constants define the Spotlight position and orientation relative to the model - var MODEL_LIGHT_POSITION = {x: 0, y: 0, z: 0}; - var MODEL_LIGHT_ROTATION = Quat.angleAxis (-90, {x: 1, y: 0, z: 0}); + var MODEL_LIGHT_POSITION = { + x: 0, + y: 0, + z: 0 + }; + var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { + x: 1, + y: 0, + z: 0 + }); // Evaluate the world light entity position and orientation from the model ones function evalLightWorldTransform(modelPos, modelRot) { - return {p: Vec3.sum(modelPos, Vec3.multiplyQbyV(modelRot, MODEL_LIGHT_POSITION)), - q: Quat.multiply(modelRot, MODEL_LIGHT_ROTATION)}; + return { + p: Vec3.sum(modelPos, Vec3.multiplyQbyV(modelRot, MODEL_LIGHT_POSITION)), + q: Quat.multiply(modelRot, MODEL_LIGHT_ROTATION) + }; }; Flashlight.prototype = { - + lightOn: false, // update() will be called regulary, because we've hooked the update signal in our preload() function @@ -56,7 +68,10 @@ var entityID = _this.entityID; // we want to assume that if there is no grab data, then we are not being grabbed - var defaultGrabData = { activated: false, avatarId: null }; + var defaultGrabData = { + activated: false, + avatarId: null + }; // this handy function getEntityCustomData() is available in utils.js and it will return just the specific section // of user data we asked for. If it's not available it returns our default data. @@ -81,8 +96,16 @@ position: lightTransform.p, rotation: lightTransform.q, isSpotlight: true, - dimensions: { x: 2, y: 2, z: 20 }, - color: { red: 255, green: 255, blue: 255 }, + dimensions: { + x: 2, + y: 2, + z: 20 + }, + color: { + red: 255, + green: 255, + blue: 255 + }, intensity: 2, exponent: 0.3, cutoff: 20 @@ -93,8 +116,11 @@ debugPrint("Flashlight:: creating a spotlight"); } else { // Updating the spotlight - Entities.editEntity(_this._spotlight, {position: lightTransform.p, rotation: lightTransform.q}); - + Entities.editEntity(_this._spotlight, { + position: lightTransform.p, + rotation: lightTransform.q + }); + _this.changeLightWithTriggerPressure(); debugPrint("Flashlight:: updating the spotlight"); } @@ -115,19 +141,47 @@ debugPrint("I'm was released..."); } }, + changeLightWithTriggerPressure: function(flashLightHand) { + var handClickString = flashLightHand + "_HAND_CLICK"; + + var handClick = Controller.findAction(handClickString); + + this.triggerValue = Controller.getActionValue(handClick); + + if (this.triggerValue < DISABLE_LIGHT_THRESHOLD && this.lightOn === true) { + this.turnLightOff(); + } else if (this.triggerValue >= DISABLE_LIGHT_THRESHOLD && this.lightOn === false) { + this.turnLightOn(); + } + + return triggerValue + }, + turnLightOff: function() { + Entities.editEntity(_this._spotlight, { + intensity: 0 + }); + this.lightOn = false + }, + turnLightOn: function() { + Entities.editEntity(_this._spotlight, { + intensity: 2 + }); + this.lightOn = true + }, + // preload() will be called when the entity has become visible (or known) to the interface // it gives us a chance to set our local JavaScript object up. In this case it means: // * remembering our entityID, so we can access it in cases where we're called without an entityID // * connecting to the update signal so we can check our grabbed state preload: function(entityID) { _this.entityID = entityID; - - var modelProperties = Entities.getEntityProperties(entityID); - - - Script.update.connect(this.update); + var modelProperties = Entities.getEntityProperties(entityID); + + + + Script.update.connect(this.update); }, // unload() will be called when our entity is no longer available. It may be because we were deleted, @@ -147,4 +201,4 @@ // entity scripts always need to return a newly constructed object of our type return new Flashlight(); -}) +}) \ No newline at end of file From c364189bc858f914121b3f98841fd88697ce32a7 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 18 Sep 2015 15:26:34 -0700 Subject: [PATCH 3/8] Update file header --- examples/toys/flashlight/flashlight.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/toys/flashlight/flashlight.js b/examples/toys/flashlight/flashlight.js index cc708beccf..9aa64a4435 100644 --- a/examples/toys/flashlight/flashlight.js +++ b/examples/toys/flashlight/flashlight.js @@ -1,6 +1,7 @@ // -// flashligh.js -// examples/entityScripts +// flashlight.js +// +// Script Type: Entity // // Created by Sam Gateau on 9/9/15. // Copyright 2015 High Fidelity, Inc. @@ -13,6 +14,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // TODO: update to use new grab signals, which will include handedness. +// BONUS: dim the light with pressure instead of binary on/off (function() { @@ -169,7 +171,7 @@ }); this.lightOn = true }, - + // preload() will be called when the entity has become visible (or known) to the interface // it gives us a chance to set our local JavaScript object up. In this case it means: // * remembering our entityID, so we can access it in cases where we're called without an entityID From fd67a2b86fd86f1f8a9f055d192eed6d4253741e Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 21 Sep 2015 16:10:08 -0700 Subject: [PATCH 4/8] Add on/off by pressure; add point bulb to end of flashlight --- examples/toys/flashlight/createFlashlight.js | 33 +-- examples/toys/flashlight/flashlight.js | 240 +++++++++++-------- 2 files changed, 153 insertions(+), 120 deletions(-) diff --git a/examples/toys/flashlight/createFlashlight.js b/examples/toys/flashlight/createFlashlight.js index bf03de547b..ad089e001a 100644 --- a/examples/toys/flashlight/createFlashlight.js +++ b/examples/toys/flashlight/createFlashlight.js @@ -15,30 +15,33 @@ Script.include("https://hifi-public.s3.amazonaws.com/scripts/utilities.js"); -var scriptURL = "https://hifi-public.s3.amazonaws.com/scripts/toys/flashlight/flashlight.js?"+randInt(0,1000); +var scriptURL = Script.resolvePath('flashlight.js?12322'); var modelURL = "https://hifi-public.s3.amazonaws.com/models/props/flashlight.fbx"; - -var center = Vec3.sum(Vec3.sum(MyAvatar.position, {x: 0, y: 0.5, z: 0}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation()))); +var center = Vec3.sum(Vec3.sum(MyAvatar.position, { + x: 0, + y: 0.5, + z: 0 +}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation()))); var flashlight = Entities.addEntity({ - type: "Model", - modelURL: modelURL, - position: center, - dimensions: { - x: 0.04, - y: 0.15, - z: 0.04 - }, - collisionsWillMove: true, - shapeType: 'box', - script: scriptURL + type: "Model", + modelURL: modelURL, + position: center, + dimensions: { + x: 0.04, + y: 0.15, + z: 0.04 + }, + collisionsWillMove: true, + shapeType: 'box', + script: scriptURL }); function cleanup() { - Entities.deleteEntity(flashlight); + Entities.deleteEntity(flashlight); } diff --git a/examples/toys/flashlight/flashlight.js b/examples/toys/flashlight/flashlight.js index 9aa64a4435..7f2bd210da 100644 --- a/examples/toys/flashlight/flashlight.js +++ b/examples/toys/flashlight/flashlight.js @@ -4,6 +4,7 @@ // Script Type: Entity // // Created by Sam Gateau on 9/9/15. +// Additions by James B. Pollack @imgntn on 9/21/2015 // Copyright 2015 High Fidelity, Inc. // // This is a toy script that can be added to the Flashlight model entity: @@ -13,15 +14,9 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// TODO: update to use new grab signals, which will include handedness. -// BONUS: dim the light with pressure instead of binary on/off (function() { - function debugPrint(message) { - //print(message); - } - Script.include("../../libraries/utils.js"); var _this; @@ -30,11 +25,11 @@ // our this object, so we can access it in cases where we're called without a this (like in the case of various global signals) Flashlight = function() { _this = this; - _this._hasSpotlight = false; - _this._spotlight = null; }; - var DISABLE_LIGHT_THRESHOLD = 0.5; + //if the trigger value goes below this while held, the flashlight will turn off. if it goes above, it will + var DISABLE_LIGHT_THRESHOLD = 0.7; + // These constants define the Spotlight position and orientation relative to the model var MODEL_LIGHT_POSITION = { x: 0, @@ -47,101 +42,131 @@ z: 0 }); - // Evaluate the world light entity position and orientation from the model ones + var GLOW_LIGHT_POSITION = { + x: 0, + y: -0.1, + z: 0 + } + + // Evaluate the world light entity positions and orientations from the model ones function evalLightWorldTransform(modelPos, modelRot) { + return { p: Vec3.sum(modelPos, Vec3.multiplyQbyV(modelRot, MODEL_LIGHT_POSITION)), q: Quat.multiply(modelRot, MODEL_LIGHT_ROTATION) }; }; + function glowLightWorldTransform(modelPos, modelRot) { + return { + p: Vec3.sum(modelPos, Vec3.multiplyQbyV(modelRot, GLOW_LIGHT_POSITION)), + q: Quat.multiply(modelRot, MODEL_LIGHT_ROTATION) + }; + }; + + Flashlight.prototype = { lightOn: false, + hand: null, + whichHand: null, + hasSpotlight: false, + spotlight: null, + setRightHand: function() { + this.hand = 'RIGHT'; + }, + setLeftHand: function() { + this.hand = 'LEFT'; + }, + startNearGrab: function() { + if (!_this.hasSpotlight) { + //this light casts the beam + this.spotlight = Entities.addEntity({ + type: "Light", + isSpotlight: true, + dimensions: { + x: 2, + y: 2, + z: 20 + }, + color: { + red: 255, + green: 255, + blue: 255 + }, + intensity: 2, + exponent: 0.3, + cutoff: 20 + }); - // update() will be called regulary, because we've hooked the update signal in our preload() function - // we will check out userData for the grabData. In the case of the hydraGrab script, it will tell us - // if we're currently being grabbed and if the person grabbing us is the current interfaces avatar. - // we will watch this for state changes and print out if we're being grabbed or released when it changes. - update: function() { - var GRAB_USER_DATA_KEY = "grabKey"; + //this light creates the effect of a bulb at the end of the flashlight + this.glowLight = Entities.addEntity({ + type: "Light", + dimensions: { + x: 0.25, + y: 0.25, + z: 0.25 + }, + isSpotlight: false, + color: { + red: 255, + green: 255, + blue: 255 + }, + exponent: 0, + cutoff: 90, // in degrees + }); - // because the update() signal doesn't have a valid this, we need to use our memorized _this to access our entityID - var entityID = _this.entityID; + this.hasSpotlight = true; - // we want to assume that if there is no grab data, then we are not being grabbed - var defaultGrabData = { - activated: false, - avatarId: null - }; - - // this handy function getEntityCustomData() is available in utils.js and it will return just the specific section - // of user data we asked for. If it's not available it returns our default data. - var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, entityID, defaultGrabData); - - - // if the grabData says we're being grabbed, and the owner ID is our session, then we are being grabbed by this interface - if (grabData.activated && grabData.avatarId == MyAvatar.sessionUUID) { - - // remember we're being grabbed so we can detect being released - _this.beingGrabbed = true; - - var modelProperties = Entities.getEntityProperties(entityID); - var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); - - // Create the spot light driven by this model if we don;t have one yet - // Or make sure to keep it's position in sync - if (!_this._hasSpotlight) { - - _this._spotlight = Entities.addEntity({ - type: "Light", - position: lightTransform.p, - rotation: lightTransform.q, - isSpotlight: true, - dimensions: { - x: 2, - y: 2, - z: 20 - }, - color: { - red: 255, - green: 255, - blue: 255 - }, - intensity: 2, - exponent: 0.3, - cutoff: 20 - }); - _this._hasSpotlight = true; - - - debugPrint("Flashlight:: creating a spotlight"); - } else { - // Updating the spotlight - Entities.editEntity(_this._spotlight, { - position: lightTransform.p, - rotation: lightTransform.q - }); - _this.changeLightWithTriggerPressure(); - debugPrint("Flashlight:: updating the spotlight"); - } - - debugPrint("I'm being grabbed..."); - - } else if (_this.beingGrabbed) { - - if (_this._hasSpotlight) { - Entities.deleteEntity(_this._spotlight); - debugPrint("Destroying flashlight spotlight..."); - } - _this._hasSpotlight = false; - _this._spotlight = null; - - // if we are not being grabbed, and we previously were, then we were just released, remember that - // and print out a message - _this.beingGrabbed = false; - debugPrint("I'm was released..."); } + + }, + setWhichHand: function() { + this.whichHand = this.hand; + }, + continueNearGrab: function() { + if (this.whichHand === null) { + //only set the active hand once -- if we always read the current hand, our 'holding' hand will get overwritten + this.setWhichHand(); + } else { + this.updateLightPositions(); + this.changeLightWithTriggerPressure(this.whichHand); + } + }, + releaseGrab: function() { + //delete the lights and reset state + if (this.hasSpotlight) { + Entities.deleteEntity(this.spotlight); + Entities.deleteEntity(this.glowLight); + this.hasSpotlight = false; + this.glowLight = null; + this.spotlight = null; + this.whichHand = null; + + } + }, + updateLightPositions: function() { + var modelProperties = Entities.getEntityProperties(this.entityID, ['position', 'rotation']); + + //move the two lights along the vectors we set above + var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); + var glowLightTransform = glowLightWorldTransform(modelProperties.position, modelProperties.rotation); + + + //move them with the entity model + Entities.editEntity(this.spotlight, { + position: lightTransform.p, + rotation: lightTransform.q, + }) + + + Entities.editEntity(this.glowLight, { + position: glowLightTransform.p, + rotation: glowLightTransform.q, + }) + + }, changeLightWithTriggerPressure: function(flashLightHand) { @@ -156,33 +181,34 @@ } else if (this.triggerValue >= DISABLE_LIGHT_THRESHOLD && this.lightOn === false) { this.turnLightOn(); } - - return triggerValue + return }, turnLightOff: function() { - Entities.editEntity(_this._spotlight, { + print('turn light off') + Entities.editEntity(this.spotlight, { + intensity: 0 + }); + Entities.editEntity(this.glowLight, { intensity: 0 }); this.lightOn = false }, turnLightOn: function() { - Entities.editEntity(_this._spotlight, { + print('turn light on') + Entities.editEntity(this.glowLight, { + intensity: 2 + }); + Entities.editEntity(this.spotlight, { intensity: 2 }); this.lightOn = true }, - // preload() will be called when the entity has become visible (or known) to the interface // it gives us a chance to set our local JavaScript object up. In this case it means: // * remembering our entityID, so we can access it in cases where we're called without an entityID // * connecting to the update signal so we can check our grabbed state preload: function(entityID) { - _this.entityID = entityID; - - var modelProperties = Entities.getEntityProperties(entityID); - - - + this.entityID = entityID; Script.update.connect(this.update); }, @@ -191,11 +217,15 @@ // to the update signal unload: function(entityID) { - if (_this._hasSpotlight) { - Entities.deleteEntity(_this._spotlight); + if (this.hasSpotlight) { + Entities.deleteEntity(this.spotlight); + Entities.deleteEntity(this.glowLight); + this.hasSpotlight = false; + this.glowLight = null; + this.spotlight = null; + this.whichHand = null; } - _this._hasSpotlight = false; - _this._spotlight = null; + Script.update.disconnect(this.update); }, From d79c1bec953e0b1f930b7adf158c86b0a895141d Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 21 Sep 2015 16:13:24 -0700 Subject: [PATCH 5/8] remove query string --- examples/toys/flashlight/createFlashlight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/toys/flashlight/createFlashlight.js b/examples/toys/flashlight/createFlashlight.js index ad089e001a..f0d31b6934 100644 --- a/examples/toys/flashlight/createFlashlight.js +++ b/examples/toys/flashlight/createFlashlight.js @@ -15,7 +15,7 @@ Script.include("https://hifi-public.s3.amazonaws.com/scripts/utilities.js"); -var scriptURL = Script.resolvePath('flashlight.js?12322'); +var scriptURL = Script.resolvePath('flashlight.js'); var modelURL = "https://hifi-public.s3.amazonaws.com/models/props/flashlight.fbx"; From bf22d5a942d5f71c0a745a5d8ae29d2a8e036787 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 21 Sep 2015 17:43:05 -0700 Subject: [PATCH 6/8] dont delete wand at cleanup from createWand.js --- examples/toys/flashlight/createFlashlight.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/toys/flashlight/createFlashlight.js b/examples/toys/flashlight/createFlashlight.js index f0d31b6934..65cafbcdaa 100644 --- a/examples/toys/flashlight/createFlashlight.js +++ b/examples/toys/flashlight/createFlashlight.js @@ -41,7 +41,8 @@ var flashlight = Entities.addEntity({ function cleanup() { - Entities.deleteEntity(flashlight); + //commenting out the line below makes this persistent. to delete at cleanup, uncomment + //Entities.deleteEntity(flashlight); } From 0ad238a5082a978e463d2b25acb28215a3f0e1d0 Mon Sep 17 00:00:00 2001 From: James Pollack Date: Tue, 22 Sep 2015 12:39:48 -0700 Subject: [PATCH 7/8] Enlarge flashlight --- examples/toys/flashlight/createFlashlight.js | 8 +++---- examples/toys/flashlight/flashlight.js | 24 ++++++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/examples/toys/flashlight/createFlashlight.js b/examples/toys/flashlight/createFlashlight.js index 65cafbcdaa..38907efa75 100644 --- a/examples/toys/flashlight/createFlashlight.js +++ b/examples/toys/flashlight/createFlashlight.js @@ -15,7 +15,7 @@ Script.include("https://hifi-public.s3.amazonaws.com/scripts/utilities.js"); -var scriptURL = Script.resolvePath('flashlight.js'); +var scriptURL = Script.resolvePath('flashlight.js?123123'); var modelURL = "https://hifi-public.s3.amazonaws.com/models/props/flashlight.fbx"; @@ -30,9 +30,9 @@ var flashlight = Entities.addEntity({ modelURL: modelURL, position: center, dimensions: { - x: 0.04, - y: 0.15, - z: 0.04 + x: 0.08, + y: 0.30, + z: 0.08 }, collisionsWillMove: true, shapeType: 'box', diff --git a/examples/toys/flashlight/flashlight.js b/examples/toys/flashlight/flashlight.js index 7f2bd210da..f5929dcfc8 100644 --- a/examples/toys/flashlight/flashlight.js +++ b/examples/toys/flashlight/flashlight.js @@ -33,7 +33,7 @@ // These constants define the Spotlight position and orientation relative to the model var MODEL_LIGHT_POSITION = { x: 0, - y: 0, + y: -0.3, z: 0 }; var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { @@ -117,6 +117,21 @@ cutoff: 90, // in degrees }); + this.debugBox = Entities.addEntity({ + type: 'Box', + color: { + red: 255, + blue: 0, + green: 0 + }, + dimensions: { + x: 0.25, + y: 0.25, + z: 0.25 + }, + ignoreForCollisions:true + }) + this.hasSpotlight = true; } @@ -166,6 +181,10 @@ rotation: glowLightTransform.q, }) + // Entities.editEntity(this.debugBox, { + // position: lightTransform.p, + // rotation: lightTransform.q, + // }) }, changeLightWithTriggerPressure: function(flashLightHand) { @@ -184,7 +203,6 @@ return }, turnLightOff: function() { - print('turn light off') Entities.editEntity(this.spotlight, { intensity: 0 }); @@ -194,7 +212,6 @@ this.lightOn = false }, turnLightOn: function() { - print('turn light on') Entities.editEntity(this.glowLight, { intensity: 2 }); @@ -227,7 +244,6 @@ } - Script.update.disconnect(this.update); }, }; From e5c42c76a23e2242e01cf5117d3ffc14256a5b89 Mon Sep 17 00:00:00 2001 From: James Pollack Date: Tue, 22 Sep 2015 12:41:00 -0700 Subject: [PATCH 8/8] Remove update loop refs --- examples/toys/flashlight/flashlight.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/toys/flashlight/flashlight.js b/examples/toys/flashlight/flashlight.js index f5929dcfc8..0465266b1c 100644 --- a/examples/toys/flashlight/flashlight.js +++ b/examples/toys/flashlight/flashlight.js @@ -223,15 +223,12 @@ // preload() will be called when the entity has become visible (or known) to the interface // it gives us a chance to set our local JavaScript object up. In this case it means: // * remembering our entityID, so we can access it in cases where we're called without an entityID - // * connecting to the update signal so we can check our grabbed state preload: function(entityID) { this.entityID = entityID; - Script.update.connect(this.update); }, // unload() will be called when our entity is no longer available. It may be because we were deleted, - // or because we've left the domain or quit the application. In all cases we want to unhook our connection - // to the update signal + // or because we've left the domain or quit the application. unload: function(entityID) { if (this.hasSpotlight) {