it works!

This commit is contained in:
James B. Pollack 2015-11-11 17:32:03 -08:00
parent ffe9036755
commit 595c628c39
5 changed files with 26 additions and 33 deletions

View file

@ -758,7 +758,7 @@ function MyController(hand) {
if (this.actionTimeout - now < ACTION_TTL_REFRESH * MSEC_PER_SEC) {
// if less than a 5 seconds left, refresh the actions ttl
var success = Entities.updateAction(this.grabbedEntity, this.actionID, {
Entities.updateAction(this.grabbedEntity, this.actionID, {
hand: this.hand === RIGHT_HAND ? "right" : "left",
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
relativePosition: this.offsetPosition,
@ -767,8 +767,6 @@ function MyController(hand) {
kinematic: NEAR_GRABBING_KINEMATIC,
kinematicSetVelocity: true
});
print('Action update success:::'+success);
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
}
};

View file

@ -108,15 +108,12 @@
var actionID = this.getActionID();
print('actionID' + actionID)
Entities.deleteAction(this.entityID, actionID);
var success = Entities.deleteAction(this.entityID, actionID);
print('ACTION DELETE SUCCESS:::'+success)
},
tellBowArrowIsNotched: function(bowID) {
this.disableGrab();
setEntityCustomData('releaseGrabKey', this.entityID, {
shouldRelease: true,
didRelease: false
});
setEntityCustomData('grabbableKey', this.entityID, {
grabbable: false,

View file

@ -106,6 +106,7 @@
preload: function(entityID) {
this.entityID = entityID;
this.bowID = entityID;
},
setLeftHand: function() {
@ -440,40 +441,36 @@
updateArrowPositionInNotch: function() {
//move it backwards
var handToNotch = Vec3.subtract(this.stringData.handPosition, this.notchDetectorPosition);
var handToNotch = Vec3.subtract(this.notchDetectorPosition,this.stringData.handPosition);
print('h2n:::'+JSON.stringify(handToNotch))
var pullBackDistance = Vec3.length(handToNotch);
if (pullBackDistance >= 0.6) {
pullBackDistance = 0.6;
}
var pullBackOffset = Vec3.multiply(handToNotch, pullBackDistance);
var pullBackOffset = Vec3.multiply(handToNotch, -pullBackDistance);
var arrowPosition = Vec3.sum(this.notchDetectorPosition, pullBackOffset);
var pushForwardOffset = Vec3.multiply(handToNotch, ARROW_OFFSET);
var pushForwardOffset = Vec3.multiply(handToNotch, -ARROW_OFFSET);
var finalArrowPosition = Vec3.sum(arrowPosition, pushForwardOffset);
var arrowRotation = this.orientationOf(handToNotch);
// print('ARROW ROTATION:: ' + JSON.stringify(arrowRotation));
var arrowRotation = Quat.rotationBetween(Vec3.FRONT, handToNotch);
print('ARROW ROTATION:: ' + JSON.stringify(arrowRotation));
Entities.editEntity(this.arrow, {
position: this.notchDetectorPosition,
rotation: arrowRotation,
velocity: {
x: 0,
y: 0,
z: 0
},
angularVelocity: {
x: 0,
y: 0,
z: 0
}
position: finalArrowPosition,
rotation: arrowRotation
})
var currentRotation = Entities.getEntityProperties(this.arrow, "rotation").rotation
// print('ACTUAL ARROW ROTATION::' +JSON.stringify(currentRotation));
var currentRotation = Entities.getEntityProperties(this.arrow, "rotation").rotation
// print('ACTUAL ARROW ROTATION::' +JSON.stringify(currentRotation));
print('DIFFERENCE::: ' + (1 - Quat.dot(arrowRotation, currentRotation)));
// print('DIFFERENCE::: ' + (1 - Quat.dot(arrowRotation, currentRotation)));
// if (this.arrowIsBurning === true) {
// Entities.editEntity(this.fire, {
// position: arrowTipPosition
@ -541,7 +538,7 @@
var detectorProperties = {
name: 'Hifi-NotchDetector',
type: 'Box',
visible: false,
visible: true,
collisionsWillMove: false,
ignoreForCollisions: true,
dimensions: NOTCH_DETECTOR_DIMENSIONS,
@ -574,7 +571,8 @@
this.notchDetectorPosition = detectorPosition;
Entities.editEntity(this.notchDetector, {
position: this.notchDetectorPosition
position: this.notchDetectorPosition,
rotation:this.bowProperties.rotation
});
},

View file

@ -12,7 +12,7 @@
var ARROW_MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/arrow.fbx";
var ARROW_COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/arrow_collision_hull.obj";
var ARROW_SCRIPT_URL = Script.resolvePath('arrow.js');
var ARROW_SCRIPT_URL = Script.resolvePath('arrow.js?123');
var ARROW_DIMENSIONS = {
x: 0.02,

View file

@ -1,2 +1,2 @@
Script.include("createBow.js");
Script.include("createArrow.js");
Script.include("createBow.js?123");
Script.include("createArrow.js?123");