Remove space before function calls, add spaces before functions

This commit is contained in:
James Pollack 2015-09-24 14:07:15 -07:00
parent fa1d5be310
commit c1f8cbd1a3

View file

@ -15,9 +15,10 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
(function () { (function() {
Script.include("../../libraries/utils.js"); Script.include("../../libraries/utils.js");
var ON_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/flashlight_on.wav'; var ON_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/flashlight_on.wav';
var OFF_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/flashlight_off.wav'; var OFF_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/flashlight_off.wav';
@ -31,22 +32,10 @@
var DISABLE_LIGHT_THRESHOLD = 0.7; var DISABLE_LIGHT_THRESHOLD = 0.7;
// These constants define the Spotlight position and orientation relative to the model // These constants define the Spotlight position and orientation relative to the model
var MODEL_LIGHT_POSITION = { var MODEL_LIGHT_POSITION = { x: 0, y: -0.3, z: 0 };
x: 0, var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { x: 1, y: 0, z: 0 });
y: -0.3,
z: 0
};
var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, {
x: 1,
y: 0,
z: 0
});
var GLOW_LIGHT_POSITION = { var GLOW_LIGHT_POSITION = { x: 0, y: -0.1, z: 0};
x: 0,
y: -0.1,
z: 0
};
// Evaluate the world light entity positions and orientations from the model ones // Evaluate the world light entity positions and orientations from the model ones
function evalLightWorldTransform(modelPos, modelRot) { function evalLightWorldTransform(modelPos, modelRot) {
@ -64,20 +53,21 @@
}; };
} }
Flashlight.prototype = { Flashlight.prototype = {
lightOn: false, lightOn: false,
hand: null, hand: null,
whichHand: null, whichHand: null,
hasSpotlight: false, hasSpotlight: false,
spotlight: null, spotlight: null,
setRightHand: function () { setRightHand: function() {
this.hand = 'RIGHT'; this.hand = 'RIGHT';
}, },
setLeftHand: function () {
setLeftHand: function() {
this.hand = 'LEFT'; this.hand = 'LEFT';
}, },
startNearGrab: function () {
startNearGrab: function() {
if (!this.hasSpotlight) { if (!this.hasSpotlight) {
//this light casts the beam //this light casts the beam
@ -117,16 +107,17 @@
cutoff: 90, // in degrees cutoff: 90, // in degrees
}); });
this.hasSpotlight = true; this.hasSpotlight = true;
} }
}, },
setWhichHand: function () {
setWhichHand: function() {
this.whichHand = this.hand; this.whichHand = this.hand;
}, },
continueNearGrab: function () {
continueNearGrab: function() {
if (this.whichHand === null) { if (this.whichHand === null) {
//only set the active hand once -- if we always read the current hand, our 'holding' hand will get overwritten //only set the active hand once -- if we always read the current hand, our 'holding' hand will get overwritten
this.setWhichHand(); this.setWhichHand();
@ -135,7 +126,8 @@
this.changeLightWithTriggerPressure(this.whichHand); this.changeLightWithTriggerPressure(this.whichHand);
} }
}, },
releaseGrab: function () {
releaseGrab: function() {
//delete the lights and reset state //delete the lights and reset state
if (this.hasSpotlight) { if (this.hasSpotlight) {
Entities.deleteEntity(this.spotlight); Entities.deleteEntity(this.spotlight);
@ -147,29 +139,28 @@
this.lightOn = false; this.lightOn = false;
} }
}, },
updateLightPositions: function () {
updateLightPositions: function() {
var modelProperties = Entities.getEntityProperties(this.entityID, ['position', 'rotation']); var modelProperties = Entities.getEntityProperties(this.entityID, ['position', 'rotation']);
//move the two lights along the vectors we set above //move the two lights along the vectors we set above
var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation);
var glowLightTransform = glowLightWorldTransform(modelProperties.position, modelProperties.rotation); var glowLightTransform = glowLightWorldTransform(modelProperties.position, modelProperties.rotation);
//move them with the entity model //move them with the entity model
Entities.editEntity(this.spotlight, { Entities.editEntity(this.spotlight, {
position: lightTransform.p, position: lightTransform.p,
rotation: lightTransform.q, rotation: lightTransform.q,
}); });
Entities.editEntity(this.glowLight, { Entities.editEntity(this.glowLight, {
position: glowLightTransform.p, position: glowLightTransform.p,
rotation: glowLightTransform.q, rotation: glowLightTransform.q,
}); });
}, },
changeLightWithTriggerPressure: function (flashLightHand) {
changeLightWithTriggerPressure: function(flashLightHand) {
var handClickString = flashLightHand + "_HAND_CLICK"; var handClickString = flashLightHand + "_HAND_CLICK";
var handClick = Controller.findAction(handClickString); var handClick = Controller.findAction(handClickString);
@ -183,7 +174,8 @@
} }
return; return;
}, },
turnLightOff: function () {
turnLightOff: function() {
this.playSoundAtCurrentPosition(false); this.playSoundAtCurrentPosition(false);
Entities.editEntity(this.spotlight, { Entities.editEntity(this.spotlight, {
intensity: 0 intensity: 0
@ -193,7 +185,8 @@
}); });
this.lightOn = false; this.lightOn = false;
}, },
turnLightOn: function () {
turnLightOn: function() {
this.playSoundAtCurrentPosition(true); this.playSoundAtCurrentPosition(true);
Entities.editEntity(this.glowLight, { Entities.editEntity(this.glowLight, {
@ -204,16 +197,8 @@
}); });
this.lightOn = true; 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
preload: function (entityID) {
this.entityID = entityID;
this.ON_SOUND = SoundCache.getSound(ON_SOUND_URL);
this.OFF_SOUND = SoundCache.getSound(OFF_SOUND_URL);
}, playSoundAtCurrentPosition: function(playOnSound) {
playSoundAtCurrentPosition: function (playOnSound) {
var position = Entities.getEntityProperties(this.entityID, "position").position; var position = Entities.getEntityProperties(this.entityID, "position").position;
var audioProperties = { var audioProperties = {
@ -228,10 +213,21 @@
} }
}, },
preload: function(entityID) {
// 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
// * preloading sounds
this.entityID = entityID;
this.ON_SOUND = SoundCache.getSound(ON_SOUND_URL);
this.OFF_SOUND = SoundCache.getSound(OFF_SOUND_URL);
},
unload: function() {
// unload() will be called when our entity is no longer available. It may be because we were deleted, // 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. // or because we've left the domain or quit the application.
unload: function () {
if (this.hasSpotlight) { if (this.hasSpotlight) {
Entities.deleteEntity(this.spotlight); Entities.deleteEntity(this.spotlight);
Entities.deleteEntity(this.glowLight); Entities.deleteEntity(this.glowLight);
@ -242,8 +238,8 @@
this.lightOn = false; this.lightOn = false;
} }
}, },
}; };
// entity scripts always need to return a newly constructed object of our type // entity scripts always need to return a newly constructed object of our type