From aa2450d755c9dcb8fd05e4ddedf3545c281297fb Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 23 Nov 2015 11:15:36 -0800 Subject: [PATCH] cleanup, debugging script --- examples/toybox/bow/arrowTest.js | 74 ++++++++++++++++++++++++++++++++ examples/toybox/bow/bow.js | 6 +-- 2 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 examples/toybox/bow/arrowTest.js diff --git a/examples/toybox/bow/arrowTest.js b/examples/toybox/bow/arrowTest.js new file mode 100644 index 0000000000..98b30e9572 --- /dev/null +++ b/examples/toybox/bow/arrowTest.js @@ -0,0 +1,74 @@ + var ARROW_HIT_SOUND_URL = 'http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/sounds/Arrow_impact1.L.wav' + + var ARROW_DIMENSIONS = { + x: 0.02, + y: 0.02, + z: 0.64 + }; + + var ARROW_OFFSET = -0.36; + var ARROW_TIP_OFFSET = 0.32; + var ARROW_GRAVITY = { + x: 0, + y: -4.8, + z: 0 + }; + + var ARROW_MODEL_URL = "http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/models/newarrow_textured.fbx"; + var ARROW_COLLISION_HULL_URL = "http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/models/newarrow_collision_hull.obj"; + + var ARROW_DIMENSIONS = { + x: 0.02, + y: 0.02, + z: 0.64 + }; + + var center = Vec3.sum(Vec3.sum(MyAvatar.position, { + x: 0, + y: 0.5, + z: 0 + }), Vec3.multiply(1.5, Quat.getFront(Camera.getOrientation()))); + + var arrow; + createArrow = function() { + + arrow = Entities.addEntity({ + name: 'Hifi-Arrow', + type: 'Model', + modelURL: ARROW_MODEL_URL, + shapeType: 'compound', + compoundShapeURL: ARROW_COLLISION_HULL_URL, + dimensions: ARROW_DIMENSIONS, + position: center, + collisionsWillMove: false, + ignoreForCollisions: true, + + }); + + return arrow + } + + + createArrow(); + var yRotation = 0; + var rotateInterval = Script.setInterval(function() { + Entities.editEntity(arrow, { + rotation: Quat.fromPitchYawRollDegrees(0, yRotation, 0) + }) + yRotation += 1 + print('changing rotation') + }, 17) + + Script.setTimeout(function() { + Script.clearInterval(rotateInterval) + print('interval cleared') + Entities.editEntity(arrow, { + velocity: { + x: 0.5, + y: 0.25, + z: 1 + }, + collisionsWillMove: true, + }) + print('entity edited') + }, 2000) \ No newline at end of file diff --git a/examples/toybox/bow/bow.js b/examples/toybox/bow/bow.js index 9783dafb6e..7971b27466 100644 --- a/examples/toybox/bow/bow.js +++ b/examples/toybox/bow/bow.js @@ -537,7 +537,7 @@ //shoot the arrow if (shouldReleaseArrow === true) { - var arrowProperties = Entities.getEntityProperties(this.arrow); + var arrowProps = Entities.getEntityProperties(this.arrow); //scale the shot strength by the distance you've pulled the arrow back and set its release velocity to be in the direction of the v var arrowForce = this.scaleArrowShotStrength(pullBackDistance); @@ -552,8 +552,8 @@ velocity: releaseVelocity, gravity: ARROW_GRAVITY, lifetime: 10, - position: arrowProperties.position, - rotation: arrowProperties.rotation + // position: arrowProps.position, + // rotation: arrowProps.rotation }; //actually shoot the arrow and play its sound