From eb48342d07da948743c91626a9d0e98ba640dcd5 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 18 Nov 2015 09:10:04 -0800 Subject: [PATCH 1/5] add inversiona nd spatialkey --- examples/toybox/bubblewand/createWand.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/toybox/bubblewand/createWand.js b/examples/toybox/bubblewand/createWand.js index 4f4bc39e2c..a0e6ce5918 100644 --- a/examples/toybox/bubblewand/createWand.js +++ b/examples/toybox/bubblewand/createWand.js @@ -43,5 +43,14 @@ var wand = Entities.addEntity({ //must be enabled to be grabbable in the physics engine collisionsWillMove: true, compoundShapeURL: WAND_COLLISION_SHAPE, - script: WAND_SCRIPT_URL + script: WAND_SCRIPT_URL, + userData:JSON.stringify({ + grabbableKey:{ + invertSolidWhileHeld:true, + spatialKey:{ + relativePosition:{x:0,y:1,z:0}, + relativeRotation:Quat.fromPitchYawRollDegrees(0,90,0) + } + } + }) }); \ No newline at end of file From de953ce14d4da3bbad14e151b1e5317456c62edb Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 18 Nov 2015 10:41:53 -0800 Subject: [PATCH 2/5] better spatialkey --- examples/toybox/bubblewand/createWand.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/toybox/bubblewand/createWand.js b/examples/toybox/bubblewand/createWand.js index a0e6ce5918..faea908c81 100644 --- a/examples/toybox/bubblewand/createWand.js +++ b/examples/toybox/bubblewand/createWand.js @@ -12,8 +12,8 @@ Script.include("../../libraries/utils.js"); -var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/models/bubblewand/wand.fbx'; -var WAND_COLLISION_SHAPE = 'http://hifi-public.s3.amazonaws.com/models/bubblewand/actual_no_top_collision_hull.obj'; +var WAND_MODEL = 'http://hifi-content.s3.amazonaws.com/james/bubblewand/wand.fbx'; +var WAND_COLLISION_SHAPE = 'http://hifi-content.s3.amazonaws.com/james/bubblewand/wand_collision_hull.obj'; var WAND_SCRIPT_URL = Script.resolvePath("wand.js"); @@ -48,8 +48,8 @@ var wand = Entities.addEntity({ grabbableKey:{ invertSolidWhileHeld:true, spatialKey:{ - relativePosition:{x:0,y:1,z:0}, - relativeRotation:Quat.fromPitchYawRollDegrees(0,90,0) + relativePosition:{x:0,y:0.1,z:0}, + relativeRotation:Quat.fromPitchYawRollDegrees(0,0,90) } } }) From d3ee0d4998e19a2368177b363cee6e52641b43f1 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 18 Nov 2015 10:44:24 -0800 Subject: [PATCH 3/5] handle bubble solidity --- examples/toybox/bubblewand/wand.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/toybox/bubblewand/wand.js b/examples/toybox/bubblewand/wand.js index 8036d9ead6..354a88c43f 100644 --- a/examples/toybox/bubblewand/wand.js +++ b/examples/toybox/bubblewand/wand.js @@ -113,6 +113,7 @@ Entities.editEntity(this.currentBubble, { velocity: velocity, lifetime: lifetime, + ignoreForCollisions:false, gravity: this.randomizeBubbleGravity() }); @@ -162,7 +163,7 @@ position: this.getWandTipPosition(properties), dimensions: BUBBLE_INITIAL_DIMENSIONS, collisionsWillMove: false, - ignoreForCollisions: false, + ignoreForCollisions: true, linearDamping: BUBBLE_LINEAR_DAMPING, shapeType: "sphere" }); From 5f3e3ed9d1c760c9489fa0befe1a730151ced109 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 18 Nov 2015 11:06:48 -0800 Subject: [PATCH 4/5] cleanup --- examples/toybox/bubblewand/createWand.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/toybox/bubblewand/createWand.js b/examples/toybox/bubblewand/createWand.js index faea908c81..6b4f9717ec 100644 --- a/examples/toybox/bubblewand/createWand.js +++ b/examples/toybox/bubblewand/createWand.js @@ -44,12 +44,16 @@ var wand = Entities.addEntity({ collisionsWillMove: true, compoundShapeURL: WAND_COLLISION_SHAPE, script: WAND_SCRIPT_URL, - userData:JSON.stringify({ - grabbableKey:{ - invertSolidWhileHeld:true, - spatialKey:{ - relativePosition:{x:0,y:0.1,z:0}, - relativeRotation:Quat.fromPitchYawRollDegrees(0,0,90) + userData: JSON.stringify({ + grabbableKey: { + invertSolidWhileHeld: true, + spatialKey: { + relativePosition: { + x: 0, + y: 0.1, + z: 0 + }, + relativeRotation: Quat.fromPitchYawRollDegrees(0, 0, 90) } } }) From 12e2178dd3f2deabba02dc5ce57d70184cc9726b Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 18 Nov 2015 11:28:07 -0800 Subject: [PATCH 5/5] cleanup --- examples/toybox/bubblewand/wand.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/toybox/bubblewand/wand.js b/examples/toybox/bubblewand/wand.js index 354a88c43f..f429ef6d55 100644 --- a/examples/toybox/bubblewand/wand.js +++ b/examples/toybox/bubblewand/wand.js @@ -12,7 +12,7 @@ /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, 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"); @@ -58,23 +58,23 @@ BubbleWand.prototype = { timePassed: null, currentBubble: null, - preload: function (entityID) { + preload: function(entityID) { this.entityID = entityID; }, - getWandTipPosition: function (properties) { + getWandTipPosition: function(properties) { //the tip of the wand is going to be in a different place than the center, so we move in space relative to the model to find that position var upVector = Quat.getUp(properties.rotation); var upOffset = Vec3.multiply(upVector, WAND_TIP_OFFSET); var wandTipPosition = Vec3.sum(properties.position, upOffset); return wandTipPosition; }, - addCollisionsToBubbleAfterCreation: function (bubble) { + addCollisionsToBubbleAfterCreation: function(bubble) { //if the bubble collide immediately, we get weird effects. so we add collisions after release Entities.editEntity(bubble, { collisionsWillMove: true }); }, - randomizeBubbleGravity: function () { + randomizeBubbleGravity: function() { //change up the gravity a little bit for variation in floating effects var randomNumber = randFloat(BUBBLE_GRAVITY_MIN, BUBBLE_GRAVITY_MAX); var gravity = { @@ -84,7 +84,7 @@ }; return gravity; }, - growBubbleWithWandVelocity: function (properties, deltaTime) { + growBubbleWithWandVelocity: function(properties, deltaTime) { //get the wand and tip position for calculations var wandPosition = properties.position; this.getWandTipPosition(properties); @@ -113,7 +113,6 @@ Entities.editEntity(this.currentBubble, { velocity: velocity, lifetime: lifetime, - ignoreForCollisions:false, gravity: this.randomizeBubbleGravity() }); @@ -146,7 +145,7 @@ dimensions: dimensions }); }, - createBubbleAtTipOfWand: function () { + createBubbleAtTipOfWand: function() { //create a new bubble at the tip of the wand var properties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]); @@ -169,18 +168,17 @@ }); }, - startNearGrab: function () { + startNearGrab: function() { //create a bubble to grow at the start of the grab if (this.currentBubble === null) { this.createBubbleAtTipOfWand(); } }, - continueNearGrab: function () { + continueNearGrab: function() { var deltaTime = checkInterval(); //only get the properties that we need var properties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]); - var wandTipPosition = this.getWandTipPosition(properties); //update the bubble to stay with the wand tip @@ -190,7 +188,7 @@ this.growBubbleWithWandVelocity(properties, deltaTime); }, - releaseGrab: function () { + releaseGrab: function() { //delete the current buble and reset state when the wand is released Entities.deleteEntity(this.currentBubble); this.currentBubble = null;