mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:57:25 +02:00
added some logging while things were broken
This commit is contained in:
parent
15ea9219d6
commit
031761fa57
3 changed files with 53 additions and 44 deletions
|
@ -18,12 +18,6 @@
|
||||||
|
|
||||||
var BUBBLE_USER_DATA_KEY = "BubbleKey";
|
var BUBBLE_USER_DATA_KEY = "BubbleKey";
|
||||||
|
|
||||||
BUBBLE_PARTICLE_COLOR = {
|
|
||||||
red: 0,
|
|
||||||
green: 40,
|
|
||||||
blue: 255,
|
|
||||||
};
|
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
var properties;
|
var properties;
|
||||||
|
@ -41,18 +35,28 @@
|
||||||
properties = tmpProperties;
|
properties = tmpProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var defaultBubbleData={
|
||||||
|
// avatarID:'noAvatar'
|
||||||
|
// }
|
||||||
|
|
||||||
|
var entityData = getEntityCustomData(BUBBLE_USER_DATA_KEY, _this.entityID);
|
||||||
|
|
||||||
|
if (entityData && entityData.avatarID && entityData.avatarID === MyAvatar.sessionUUID) {
|
||||||
|
_this.bubbleCreator = true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.unload = function(entityID) {
|
this.unload = function(entityID) {
|
||||||
Script.update.disconnect(this.update);
|
Script.update.disconnect(this.update);
|
||||||
|
|
||||||
var defaultGrabData = {
|
print('bubble unload')
|
||||||
avatarId: null
|
|
||||||
};
|
|
||||||
|
|
||||||
var bubbleCreator = getEntityCustomData(BUBBLE_USER_DATA_KEY, entityID, defaultGrabData);
|
if (this.bubbleCreator) {
|
||||||
|
print('PLAYING BURST')
|
||||||
if (bubbleCreator === MyAvatar.sessionUUID) {
|
|
||||||
this.createBurstParticles();
|
this.createBurstParticles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,36 +81,36 @@
|
||||||
var particleBurst = Entities.addEntity({
|
var particleBurst = Entities.addEntity({
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
animationSettings: animationSettings,
|
animationSettings: animationSettings,
|
||||||
|
emitRate: 100,
|
||||||
animationIsPlaying: true,
|
animationIsPlaying: true,
|
||||||
position: position,
|
position: position,
|
||||||
lifetime: 0.1,
|
lifespan: 1,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 1,
|
x: 1,
|
||||||
y: 1,
|
y: 1,
|
||||||
z: 1
|
z: 1
|
||||||
},
|
},
|
||||||
emitVelocity: {
|
emitVelocity: {
|
||||||
x: 0.35,
|
x: 1,
|
||||||
y: 0.35,
|
y: 1,
|
||||||
z: 0.35
|
z: 1
|
||||||
},
|
},
|
||||||
velocitySpread: {
|
velocitySpread: {
|
||||||
x: 0.45,
|
x: 1,
|
||||||
y: 0.45,
|
y: 1,
|
||||||
z: 0.45
|
z: 1
|
||||||
},
|
},
|
||||||
emitAcceleration: {
|
emitAcceleration: {
|
||||||
x: 0,
|
x: 0.25,
|
||||||
y: -0.1,
|
y: 0.25,
|
||||||
z: 0
|
z: 0.25
|
||||||
},
|
},
|
||||||
particleRadius: 0.1,
|
radiusSpread: 0.01,
|
||||||
alphaStart: 0.5,
|
particleRadius: 0.02,
|
||||||
|
alphaStart: 1.0,
|
||||||
alpha: 0.5,
|
alpha: 0.5,
|
||||||
alphaFinish: 0,
|
alphaFinish: 0,
|
||||||
textures: BUBBLE_PARTICLE_TEXTURE,
|
textures: BUBBLE_PARTICLE_TEXTURE,
|
||||||
// color: BUBBLE_PARTICLE_COLOR,
|
|
||||||
lifespan: 0.1,
|
|
||||||
visible: true,
|
visible: true,
|
||||||
locked: false
|
locked: false
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,20 +4,20 @@
|
||||||
// Script Type: Entity Spawner
|
// Script Type: Entity Spawner
|
||||||
// Created by James B. Pollack @imgntn -- 09/03/2015
|
// Created by James B. Pollack @imgntn -- 09/03/2015
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Loads a wand model and attaches the bubble wand behavior.
|
// Loads a wand model and attaches the bubble wand behavior.
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// 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
|
||||||
|
|
||||||
var IN_TOYBOX = false;
|
var IN_TOYBOX = false;
|
||||||
|
|
||||||
Script.include("../../utilities.js");
|
Script.include("../../utilities.js");
|
||||||
Script.include("../../libraries/utils.js");
|
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");
|
var WAND_SCRIPT_URL = Script.resolvePath("wand.js?"+randInt(0,500));
|
||||||
//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())));
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ var tablePosition = {
|
||||||
y:495.63,
|
y:495.63,
|
||||||
z:506.25
|
z:506.25
|
||||||
}
|
}
|
||||||
print('test refresh')
|
|
||||||
var wand = Entities.addEntity({
|
var wand = Entities.addEntity({
|
||||||
name:'Bubble Wand',
|
name:'Bubble Wand',
|
||||||
type: "Model",
|
type: "Model",
|
||||||
|
@ -39,9 +39,9 @@ var wand = Entities.addEntity({
|
||||||
z: 0,
|
z: 0,
|
||||||
},
|
},
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 0.025,
|
x: 0.05,
|
||||||
y: 0.125,
|
y: 0.25,
|
||||||
z: 0.025
|
z: 0.05
|
||||||
},
|
},
|
||||||
//must be enabled to be grabbable in the physics engine
|
//must be enabled to be grabbable in the physics engine
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
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?' + randInt(0, 10000));
|
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,
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
var GROWTH_FACTOR = 0.005;
|
var GROWTH_FACTOR = 0.005;
|
||||||
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.05;
|
var WAND_TIP_OFFSET = 0.095;
|
||||||
var VELOCITY_STRENGTH_LOWER_LIMIT = 0.01;
|
var VELOCITY_STRENGTH_LOWER_LIMIT = 0.01;
|
||||||
var VELOCITY_STRENGH_MAX = 10;
|
var VELOCITY_STRENGH_MAX = 10;
|
||||||
var VELOCITY_THRESHOLD = 0.5;
|
var VELOCITY_THRESHOLD = 0.5;
|
||||||
|
@ -58,17 +58,19 @@
|
||||||
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 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();
|
||||||
|
@ -87,9 +89,8 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
} 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
|
||||||
|
@ -97,6 +98,7 @@
|
||||||
_this.currentBubble = null
|
_this.currentBubble = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
print('not grabbed')
|
||||||
|
|
||||||
},
|
},
|
||||||
getWandTipPosition: function(properties) {
|
getWandTipPosition: function(properties) {
|
||||||
|
@ -129,6 +131,7 @@
|
||||||
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)
|
||||||
|
|
||||||
|
@ -138,8 +141,7 @@
|
||||||
|
|
||||||
|
|
||||||
var velocityStrength = Vec3.length(velocity);
|
var velocityStrength = Vec3.length(velocity);
|
||||||
print('velocityStrength' + velocityStrength)
|
velocityStrength = velocityStrength;
|
||||||
|
|
||||||
// if (velocityStrength < VELOCITY_STRENGTH_LOWER_LIMIT) {
|
// if (velocityStrength < VELOCITY_STRENGTH_LOWER_LIMIT) {
|
||||||
// velocityStrength = 0
|
// velocityStrength = 0
|
||||||
// }
|
// }
|
||||||
|
@ -155,13 +157,15 @@
|
||||||
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;
|
||||||
|
|
||||||
//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);
|
||||||
|
|
||||||
|
@ -174,9 +178,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);
|
||||||
|
|
||||||
|
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
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -202,8 +206,9 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
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,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
createBubbleAtTipOfWand: function() {
|
createBubbleAtTipOfWand: function() {
|
||||||
|
|
Loading…
Reference in a new issue