Cleanup comments

This commit is contained in:
James B. Pollack 2015-09-18 15:40:39 -07:00
parent 031761fa57
commit ccf125c047
3 changed files with 12 additions and 35 deletions

View file

@ -23,7 +23,6 @@
var properties; var properties;
this.preload = function(entityID) { this.preload = function(entityID) {
// print('bubble preload')
_this.entityID = entityID; _this.entityID = entityID;
Script.update.connect(_this.update); Script.update.connect(_this.update);
}; };
@ -35,28 +34,20 @@
properties = tmpProperties; properties = tmpProperties;
} }
// var defaultBubbleData={ //we want to play the particle burst exactly once, so we make sure that this is a bubble we own.
// avatarID:'noAvatar'
// }
var entityData = getEntityCustomData(BUBBLE_USER_DATA_KEY, _this.entityID); var entityData = getEntityCustomData(BUBBLE_USER_DATA_KEY, _this.entityID);
if (entityData && entityData.avatarID && entityData.avatarID === MyAvatar.sessionUUID) { if (entityData && entityData.avatarID && entityData.avatarID === MyAvatar.sessionUUID) {
_this.bubbleCreator = true _this.bubbleCreator = true
} }
}; };
this.unload = function(entityID) { this.unload = function(entityID) {
Script.update.disconnect(this.update); Script.update.disconnect(this.update);
print('bubble unload') //only play particle burst for our bubbles
if (this.bubbleCreator) { if (this.bubbleCreator) {
print('PLAYING BURST')
this.createBurstParticles(); this.createBurstParticles();
} }
@ -84,7 +75,7 @@
emitRate: 100, emitRate: 100,
animationIsPlaying: true, animationIsPlaying: true,
position: position, position: position,
lifespan: 1, lifespan: 0.2,
dimensions: { dimensions: {
x: 1, x: 1,
y: 1, y: 1,

View file

@ -17,7 +17,7 @@ Script.include("../../libraries/utils.js");
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/wand.fbx'; var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/wand.fbx';
var WAND_COLLISION_SHAPE = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/collisionHull.obj'; var WAND_COLLISION_SHAPE = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/collisionHull.obj';
var WAND_SCRIPT_URL = Script.resolvePath("wand.js?"+randInt(0,500)); var WAND_SCRIPT_URL = Script.resolvePath("wand.js");
//create the wand in front of the avatar blahy //create the wand in front of the avatar blahy
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())));

View file

@ -18,7 +18,7 @@
var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/james/bubblewand/models/bubble/bubble.fbx"; var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/james/bubblewand/models/bubble/bubble.fbx";
var BUBBLE_SCRIPT = Script.resolvePath('bubble.js'); var BUBBLE_SCRIPT = Script.resolvePath('bubble.js');
//test
var BUBBLE_USER_DATA_KEY = "BubbleKey"; var BUBBLE_USER_DATA_KEY = "BubbleKey";
var BUBBLE_INITIAL_DIMENSIONS = { var BUBBLE_INITIAL_DIMENSIONS = {
x: 0.01, x: 0.01,
@ -36,10 +36,10 @@
var SHRINK_FACTOR = 0.001; var SHRINK_FACTOR = 0.001;
var SHRINK_LOWER_LIMIT = 0.02; var SHRINK_LOWER_LIMIT = 0.02;
var WAND_TIP_OFFSET = 0.095; var WAND_TIP_OFFSET = 0.095;
var VELOCITY_STRENGTH_LOWER_LIMIT = 0.01;
var VELOCITY_STRENGH_MAX = 10;
var VELOCITY_THRESHOLD = 0.5; var VELOCITY_THRESHOLD = 0.5;
var GRAB_USER_DATA_KEY = "grabKey";
var _this; var _this;
var BubbleWand = function() { var BubbleWand = function() {
@ -58,19 +58,16 @@
Script.update.disconnect(this.update); Script.update.disconnect(this.update);
}, },
update: function(deltaTime) { update: function(deltaTime) {
print('BW update')
var GRAB_USER_DATA_KEY = "grabKey";
var defaultGrabData = { var defaultGrabData = {
activated: false, activated: false,
avatarId: null avatarId: null
}; };
var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, _this.entityID, defaultGrabData); var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, _this.entityID, defaultGrabData);
print('grabData'+JSON.stringify(grabData))
if (grabData.activated && grabData.avatarId === MyAvatar.sessionUUID) {
if (grabData.activated && grabData.avatarId === MyAvatar.sessionUUID) {
// remember we're being grabbed so we can detect being released // remember we're being grabbed so we can detect being released
_this.beingGrabbed = true; _this.beingGrabbed = true;
print('being grabbed')
//the first time we want to make a bubble //the first time we want to make a bubble
if (_this.currentBubble === null) { if (_this.currentBubble === null) {
_this.createBubbleAtTipOfWand(); _this.createBubbleAtTipOfWand();
@ -90,7 +87,6 @@
} else if (_this.beingGrabbed) { } else if (_this.beingGrabbed) {
// if we are not being grabbed, and we previously were, then we were just released, remember that // if we are not being grabbed, and we previously were, then we were just released, remember that
print('let go')
_this.beingGrabbed = false; _this.beingGrabbed = false;
//remove the current bubble when the wand is released //remove the current bubble when the wand is released
@ -98,7 +94,7 @@
_this.currentBubble = null _this.currentBubble = null
return return
} }
print('not grabbed')
}, },
getWandTipPosition: function(properties) { getWandTipPosition: function(properties) {
@ -114,7 +110,6 @@
}, },
addCollisionsToBubbleAfterCreation: function(bubble) { addCollisionsToBubbleAfterCreation: function(bubble) {
print('adding collisions to bubble' + bubble);
Entities.editEntity(bubble, { Entities.editEntity(bubble, {
collisionsWillMove: true collisionsWillMove: true
}) })
@ -131,7 +126,6 @@
return gravity return gravity
}, },
growBubbleWithWandVelocity: function(properties, deltaTime) { growBubbleWithWandVelocity: function(properties, deltaTime) {
print('grow bubble')
var wandPosition = properties.position; var wandPosition = properties.position;
var wandTipPosition = this.getWandTipPosition(properties) var wandTipPosition = this.getWandTipPosition(properties)
@ -142,13 +136,6 @@
var velocityStrength = Vec3.length(velocity); var velocityStrength = Vec3.length(velocity);
velocityStrength = velocityStrength; velocityStrength = velocityStrength;
// if (velocityStrength < VELOCITY_STRENGTH_LOWER_LIMIT) {
// velocityStrength = 0
// }
// if (velocityStrength > VELOCITY_STRENGTH_MAX) {
// velocityStrength = VELOCITY_STRENGTH_MAX
// }
//store the last position of the wand for velocity calculations //store the last position of the wand for velocity calculations
this.lastPosition = wandPosition; this.lastPosition = wandPosition;
@ -157,7 +144,6 @@
var dimensions = Entities.getEntityProperties(this.currentBubble).dimensions; var dimensions = Entities.getEntityProperties(this.currentBubble).dimensions;
if (velocityStrength > VELOCITY_THRESHOLD) { if (velocityStrength > VELOCITY_THRESHOLD) {
print('velocity over threshold')
//add some variation in bubble sizes //add some variation in bubble sizes
var bubbleSize = randInt(BUBBLE_SIZE_MIN, BUBBLE_SIZE_MAX); var bubbleSize = randInt(BUBBLE_SIZE_MIN, BUBBLE_SIZE_MAX);
bubbleSize = bubbleSize / BUBBLE_DIVISOR; bubbleSize = bubbleSize / BUBBLE_DIVISOR;
@ -165,7 +151,6 @@
//release the bubble if its dimensions are bigger than the bubble size //release the bubble if its dimensions are bigger than the bubble size
if (dimensions.x > bubbleSize) { if (dimensions.x > bubbleSize) {
print('release the bubble')
//bubbles pop after existing for a bit -- so set a random lifetime //bubbles pop after existing for a bit -- so set a random lifetime
var lifetime = randInt(BUBBLE_LIFETIME_MIN, BUBBLE_LIFETIME_MAX); var lifetime = randInt(BUBBLE_LIFETIME_MIN, BUBBLE_LIFETIME_MAX);
@ -178,7 +163,9 @@
//wait to make the bubbles collidable, so that they dont hit each other and the wand //wait to make the bubbles collidable, so that they dont hit each other and the wand
Script.setTimeout(this.addCollisionsToBubbleAfterCreation(this.currentBubble), lifetime / 2); Script.setTimeout(this.addCollisionsToBubbleAfterCreation(this.currentBubble), lifetime / 2);
//we want to pop the bubble for just one person
this.setBubbleOwner(this.currentBubble); this.setBubbleOwner(this.currentBubble);
//release the bubble -- when we create a new bubble, it will carry on and this update loop will affect the new bubble //release the bubble -- when we create a new bubble, it will carry on and this update loop will affect the new bubble
this.createBubbleAtTipOfWand(); this.createBubbleAtTipOfWand();
return return
@ -206,7 +193,6 @@
}); });
}, },
setBubbleOwner: function(bubble) { setBubbleOwner: function(bubble) {
print('SET BUBBLE OWNER', bubble)
setEntityCustomData(BUBBLE_USER_DATA_KEY, bubble, { setEntityCustomData(BUBBLE_USER_DATA_KEY, bubble, {
avatarID: MyAvatar.sessionUUID, avatarID: MyAvatar.sessionUUID,
}); });