From 4a1672957e994e771e13a60acd95a53f39cd1ea0 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 8 May 2014 23:23:44 -0700 Subject: [PATCH] guitar is now auto-attached --- examples/airGuitar.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/airGuitar.js b/examples/airGuitar.js index d7028b8ad7..b7c4b72948 100644 --- a/examples/airGuitar.js +++ b/examples/airGuitar.js @@ -25,6 +25,9 @@ function vMinus(a, b) { return rval; } +// The model file to be used for the guitar +var guitarModel = "https://s3-us-west-1.amazonaws.com/highfidelity-public/models/attachments/guitar.fst"; + // Load sounds that will be played var chords = new Array(); @@ -57,6 +60,8 @@ var lastPosition = { x: 0.0, var soundPlaying = false; var selectorPressed = false; +MyAvatar.attach(guitarModel, "Hips", {x: -0.0, y: -0.0, z: 0.0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.0); + function checkHands(deltaTime) { for (var palm = 0; palm < 2; palm++) { var palmVelocity = Controller.getSpatialControlVelocity(palm * 2 + 1); @@ -117,5 +122,9 @@ function checkHands(deltaTime) { } } +function scriptEnding() { + MyAvatar.detachOne(guitarModel); +} // Connect a call back that happens every frame -Script.update.connect(checkHands); \ No newline at end of file +Script.update.connect(checkHands); +Script.scriptEnding.connect(scriptEnding);