mirror of
https://github.com/overte-org/overte.git
synced 2025-08-14 00:30:22 +02:00
end of day
This commit is contained in:
parent
24a5cdc19e
commit
8695963dd1
3 changed files with 73 additions and 64 deletions
|
@ -613,9 +613,6 @@ function MyController(hand, triggerAction) {
|
|||
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
||||
}
|
||||
Entities.callEntityMethod(this.grabbedEntity, "startNearGrab");
|
||||
setEntityCustomData('hifiHoldActionKey', this.grabbedEntity, {
|
||||
holdActionID: this.actionID
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
@ -625,6 +622,7 @@ function MyController(hand, triggerAction) {
|
|||
};
|
||||
|
||||
this.continueNearGrabbing = function() {
|
||||
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
return;
|
||||
|
@ -647,6 +645,17 @@ function MyController(hand, triggerAction) {
|
|||
this.currentHandControllerTipPosition = handControllerPosition;
|
||||
this.currentObjectTime = now;
|
||||
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrab");
|
||||
var properties = Entities.getEntityProperties(this.grabbedEntity, ["userData","name"]);
|
||||
var userData = JSON.parse(properties.userData);
|
||||
var shouldRelease;
|
||||
if (userData.hasOwnProperty('hifiBowKey')) {
|
||||
var shouldRelease;
|
||||
if (userData.hifiBowKey.shouldRelease === true) {
|
||||
this.setState(STATE_RELEASE);
|
||||
shouldRelease=true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.actionTimeout - now < ACTION_LIFETIME_REFRESH * MSEC_PER_SEC) {
|
||||
// if less than a 5 seconds left, refresh the actions lifetime
|
||||
|
@ -824,6 +833,7 @@ function MyController(hand, triggerAction) {
|
|||
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||
}
|
||||
|
||||
|
||||
// the action will tend to quickly bring an object's velocity to zero. now that
|
||||
// the action is gone, set the objects velocity to something the holder might expect.
|
||||
Entities.editEntity(this.grabbedEntity, {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
glow: false,
|
||||
glowBox: null,
|
||||
isBurning: false,
|
||||
notched: false,
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
|
||||
|
@ -59,19 +60,19 @@
|
|||
// }
|
||||
|
||||
},
|
||||
startNearGrab: function() {
|
||||
print('STARTING GRAB ON ARROW!!')
|
||||
},
|
||||
|
||||
continueNearGrab: function() {
|
||||
this.currentProperties = Entities.getEntityProperties(this.entityID, "position");
|
||||
this.searchForNotchDetectors();
|
||||
if (this.notched !== true) {
|
||||
this.searchForNotchDetectors();
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
searchForNotchDetectors: function() {
|
||||
if (this.notched === true) {
|
||||
return
|
||||
};
|
||||
print('SEARCHING FOR NOTCH DETECTOR');
|
||||
|
||||
var ids = Entities.findEntities(this.currentProperties.position, NOTCH_DETECTOR_SEARCH_RADIUS);
|
||||
var i, properties;
|
||||
|
@ -82,7 +83,6 @@
|
|||
print('NEAR THE NOTCH!!!')
|
||||
this.notched = true;
|
||||
this.tellBowArrowIsNotched(this.getBowID(id));
|
||||
this.disableGrab();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,20 +103,18 @@
|
|||
},
|
||||
|
||||
tellBowArrowIsNotched: function(bowID) {
|
||||
setEntityCustomData('hifiBowKey', bowID, {
|
||||
arrowNotched: true,
|
||||
arrowID: this.entityID
|
||||
setEntityCustomData('hifiBowKey', this.entityID, {
|
||||
shouldRelease: true
|
||||
});
|
||||
},
|
||||
|
||||
disableGrab: function() {
|
||||
print('ACTION ID IS::: ' + this.getActionID());
|
||||
Entities.deleteAction(this.entityID, this.getActionID());
|
||||
|
||||
setEntityCustomData('grabbableKey', this.entityID, {
|
||||
grabbable: false
|
||||
});
|
||||
|
||||
setEntityCustomData('hifiBowKey', bowID, {
|
||||
hasArrowNotched: true,
|
||||
arrowID: this.entityID
|
||||
});
|
||||
},
|
||||
|
||||
checkIfBurning: function() {
|
||||
|
@ -202,6 +200,5 @@
|
|||
|
||||
Entities.deletingEntity.connect(deleteEntity);
|
||||
|
||||
|
||||
return new Arrow;
|
||||
})
|
|
@ -68,9 +68,9 @@
|
|||
};
|
||||
|
||||
var NOTCH_DETECTOR_DIMENSIONS = {
|
||||
x: 0.25,
|
||||
y: 0.25,
|
||||
z: 0.25
|
||||
x: 0.15,
|
||||
y: 0.15,
|
||||
z: 0.15
|
||||
};
|
||||
|
||||
var NOTCH_DETECTOR_DISTANCE = 0.1;
|
||||
|
@ -142,16 +142,27 @@
|
|||
|
||||
continueNearGrab: function() {
|
||||
this.bowProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation", "userData"]);
|
||||
this.updateNotchDetectorPosition();
|
||||
|
||||
//check to see if an arrow has notched itself in our notch detector
|
||||
var userData = JSON.parse(this.bowProperties.userData);
|
||||
if (userData.hasOwnProperty('hifiBowKey')) {
|
||||
if (this.hasArrowNotched === false) {
|
||||
this.hasArrowNotched = userData.hifiBowKey.hasArrowNotched;
|
||||
|
||||
|
||||
this.arrow = userData.hifiBowKey.arrowID;
|
||||
|
||||
setEntityCustomData('grabbableKey', this.entityID, {
|
||||
turnOffOtherHand: true,
|
||||
turnOffOppositeBeam: false,
|
||||
invertSolidWhileHeld: true
|
||||
});
|
||||
}
|
||||
this.arrow = userData.hifiBowKey.arrowID;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//create a string across the bow when we pick it up
|
||||
if (this.preNotchString === null) {
|
||||
this.createPreNotchString();
|
||||
|
@ -168,13 +179,15 @@
|
|||
|
||||
//if we have an arrow notched, then draw some new strings
|
||||
if (this.hasArrowNotched === true) {
|
||||
Entities.deleteEntity(this.preNotchString);
|
||||
if (this.preNotchString !== null) {
|
||||
Entities.deleteEntity(this.preNotchString);
|
||||
}
|
||||
|
||||
//only test for strings now that an arrow is notched
|
||||
this.checkStringHand();
|
||||
|
||||
} else {
|
||||
//otherwise, just update the notch detector position
|
||||
this.updateNotchDetectorPosition();
|
||||
|
||||
}
|
||||
},
|
||||
|
@ -350,12 +363,12 @@
|
|||
|
||||
if (this.triggerValue < DRAW_STRING_THRESHOLD && this.stringDrawn === true) {
|
||||
|
||||
|
||||
//firing the arrow
|
||||
this.stringDrawn = false;
|
||||
this.deleteStrings();
|
||||
this.hasArrow = false;
|
||||
this.preNotchString = null;
|
||||
this.releaseArrow();
|
||||
// this.stringDrawn = false;
|
||||
// this.deleteStrings();
|
||||
// this.hasArrow = false;
|
||||
// this.releaseArrow();
|
||||
|
||||
} else if (this.triggerValue >= DRAW_STRING_THRESHOLD && this.stringDrawn === true) {
|
||||
//continuing to aim the arrow
|
||||
|
@ -364,7 +377,7 @@
|
|||
this.initialHand === 'right' ? this.stringData.grabHandPosition = Controller.getSpatialControlPosition(RIGHT_TIP) : this.stringData.grabHandPosition = Controller.getSpatialControlPosition(LEFT_TIP);
|
||||
this.stringData.grabHandRotation = this.getGrabHandRotation();
|
||||
this.drawStrings();
|
||||
this.updateArrowPosition();
|
||||
this.updateArrowPositionInNotch();
|
||||
|
||||
} else if (this.triggerValue >= DRAW_STRING_THRESHOLD && this.stringDrawn === false) {
|
||||
//the first time aiming the arrow
|
||||
|
@ -376,7 +389,7 @@
|
|||
this.stringData.grabHandRotation = this.getGrabHandRotation();
|
||||
|
||||
this.drawStrings();
|
||||
this.updateArrowPosition();
|
||||
this.updateArrowPositionInNotch();
|
||||
|
||||
}
|
||||
},
|
||||
|
@ -411,45 +424,32 @@
|
|||
return Quat.multiply(yaw, pitch);
|
||||
},
|
||||
|
||||
updateArrowPosition: function() {
|
||||
var arrowPosition = this.getArrowPosition();
|
||||
|
||||
var handToHand = Vec3.subtract(this.stringData.handPosition, this.stringData.grabHandPosition);
|
||||
|
||||
var arrowRotation = this.orientationOf(handToHand);
|
||||
updateArrowPositionInNotch: function() {
|
||||
|
||||
var arrowRotation = {
|
||||
x:0,
|
||||
y:0,
|
||||
z:0,
|
||||
w:1
|
||||
}
|
||||
|
||||
var arrowOffset = Vec3.multiply(Quat.getFront(this.bowProperties.rotation),ARROW_OFFSET);
|
||||
var arrowPosition = Vec3.sum(this.notchDetectorPosition,arrowOffset)
|
||||
|
||||
var handToNotch = Vec3.subtract(this.stringData.handPosition, this.notchDetectorPosition);
|
||||
|
||||
var rotation1 = Entities.getEntityProperties(this.arrow,"rotation").rotation;
|
||||
|
||||
//var arrowRotation = this.orientationOf(handToNotch);
|
||||
Entities.editEntity(this.arrow, {
|
||||
position: arrowPosition,
|
||||
rotation: arrowRotation
|
||||
});
|
||||
|
||||
if (this.arrowIsBurning === true) {
|
||||
Entities.editEntity(this.fire, {
|
||||
position: this.arrow.position
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
updateArrowPositionPreNotch: function() {
|
||||
Entities.editEntity(this.arrow, {
|
||||
position: this.getArrowHandPosition(),
|
||||
rotatin: this.getArrowHandRotation()
|
||||
});
|
||||
|
||||
if (this.arrowIsBurning === true) {
|
||||
Entities.editEntity(this.fire, {
|
||||
position: arrowHandPosition
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
updateArrowPositionInNotch: function() {
|
||||
var notchPosition = this.notchDetectorPosition;
|
||||
|
||||
Entities.editEntityProperties(this.arrow, {
|
||||
position: notchPosition
|
||||
})
|
||||
|
||||
var rotation2 = Entities.getEntityProperties(this.arrow,"rotation").rotation;
|
||||
|
||||
if (this.arrowIsBurning === true) {
|
||||
Entities.editEntity(this.fire, {
|
||||
position: arrowTipPosition
|
||||
|
@ -459,6 +459,8 @@
|
|||
},
|
||||
|
||||
releaseArrow: function() {
|
||||
|
||||
print('RELEASE ARROW!!!')
|
||||
var handToHand = Vec3.subtract(this.stringData.grabHandPosition, this.stringData.handPosition);
|
||||
|
||||
var arrowRotation = this.orientationOf(handToHand);
|
||||
|
@ -474,8 +476,7 @@
|
|||
ignoreForCollisions: false,
|
||||
collisionsWillMove: true,
|
||||
gravity: ARROW_GRAVITY,
|
||||
velocity: forwardVec,
|
||||
lifetime: 20
|
||||
velocity: forwardVec
|
||||
};
|
||||
|
||||
Entities.editEntity(this.arrow, arrowProperties);
|
||||
|
@ -504,6 +505,7 @@
|
|||
name: 'Hifi-NotchDetector',
|
||||
type: 'Box',
|
||||
visible: false,
|
||||
collisionsWillMove:false,
|
||||
ignoreForCollisions: true,
|
||||
dimensions: NOTCH_DETECTOR_DIMENSIONS,
|
||||
position: detectorPosition,
|
||||
|
|
Loading…
Reference in a new issue