mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
end of day
This commit is contained in:
parent
37778286da
commit
8b78278a79
1 changed files with 76 additions and 27 deletions
|
@ -11,16 +11,20 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// make it so you can shoot without blocking your view with your hand
|
// [x] make it so you can shoot without blocking your view with your hand
|
||||||
// notching system
|
// [x] notching system
|
||||||
// make arrows more visible
|
// make arrows more visible
|
||||||
// make arrow rotate toward ground as it flies
|
// make arrow rotate toward ground as it flies
|
||||||
// different model? compound bow will look better in the HMD, and be easier to aim. http://www.turbosquid.com/3d-models/3d-model-bow-arrow/773106
|
// [x] different model? compound bow will look better in the HMD, and be easier to aim. http://www.turbosquid.com/3d-models/3d-model-bow-arrow/773106
|
||||||
// add noise when you release arrow -> add the sound to the arrow and keep it with position so you hear it whizz by
|
// add noise when you release arrow -> add the sound to the arrow and keep it with position so you hear it whizz by
|
||||||
// add noise when you draw string
|
// add noise when you draw string
|
||||||
// re-enable arrows sticking when they hit
|
// re-enable arrows sticking when they hit
|
||||||
// prepare for haptics
|
// prepare for haptics
|
||||||
|
|
||||||
|
// from chat w/ ryan
|
||||||
|
// 5 arrows on table
|
||||||
|
// pick up arrow entity
|
||||||
|
// notch it
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var ZERO_VEC = {
|
var ZERO_VEC = {
|
||||||
|
@ -163,7 +167,11 @@
|
||||||
}
|
}
|
||||||
this.isGrabbed = true;
|
this.isGrabbed = true;
|
||||||
this.initialHand = this.hand;
|
this.initialHand = this.hand;
|
||||||
this.createReloadDetector();
|
|
||||||
|
if (this.useNotching === true) {
|
||||||
|
this.createReloadDetector();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Entities.editEntity(this.entityID, {
|
Entities.editEntity(this.entityID, {
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
|
@ -178,31 +186,31 @@
|
||||||
|
|
||||||
continueNearGrab: function() {
|
continueNearGrab: function() {
|
||||||
this.bowProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]);
|
this.bowProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]);
|
||||||
if (this.notchDetector === null) {
|
|
||||||
this.createNotchDetector();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateNotchDetectorPosition();
|
|
||||||
this.updateReloadDetectorPosition();
|
|
||||||
|
|
||||||
this.checkStringHand();
|
this.checkStringHand();
|
||||||
|
|
||||||
if (this.useNotching === true) {
|
if (this.useNotching === true) {
|
||||||
this.checkArrowHand();
|
if (this.notchDetector === null) {
|
||||||
|
this.createNotchDetector();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.hasArrowLoaded === false) {
|
this.updateNotchDetectorPosition();
|
||||||
this.updateArrowPositionPreNotch();
|
this.updateReloadDetectorPosition();
|
||||||
|
|
||||||
|
this.checkArrowHand();
|
||||||
|
|
||||||
|
if (this.hasArrowLoaded === true && this.hasArrowNotched === false) {
|
||||||
|
updateArrowPositionPreNotch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasArrowLoaded === true) {
|
if (this.hasArrowLoaded === true) {
|
||||||
this.updateNotchDetectorPosition();
|
this.updateNotchDetectorPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.hasArrowNotched === true) {
|
if (this.hasArrowNotched === true) {
|
||||||
//only test for strings now that an arrow is notched
|
//only test for strings now that an arrow is notched
|
||||||
// this.checkStringHand();
|
// this.checkStringHand();
|
||||||
//should probably draw a string straight across the bow until its notched
|
//should probably draw a string straight across the bow until its notched
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,7 +295,6 @@
|
||||||
position: this.topStringPosition
|
position: this.topStringPosition
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
drawStrings: function() {
|
drawStrings: function() {
|
||||||
|
@ -318,6 +325,14 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
getLocalLineVectors: function() {
|
||||||
|
var topVector = Vec3.subtract(this.stringData.handPosition, this.topStringPosition);
|
||||||
|
var bottomVector = Vec3.subtract(this.stringData.handPosition, this.bottomStringPosition);
|
||||||
|
return [topVector, bottomVector];
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
createPreNotchString: function() {
|
createPreNotchString: function() {
|
||||||
var stringProperties = {
|
var stringProperties = {
|
||||||
type: 'Line',
|
type: 'Line',
|
||||||
|
@ -332,6 +347,10 @@
|
||||||
|
|
||||||
this.updateStringPositions();
|
this.updateStringPositions();
|
||||||
|
|
||||||
|
var downVector = Vec3.multiply(-1, Quat.getUp(this.bowProperties.rotation));
|
||||||
|
var downOffset = Vec3.multiply(downVector, BOTTOM_NOTCH_OFFSET * 2);
|
||||||
|
|
||||||
|
|
||||||
Entities.editEntity(this.preNotchString, {
|
Entities.editEntity(this.preNotchString, {
|
||||||
linePoints: [{
|
linePoints: [{
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -341,7 +360,7 @@
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
z: 0
|
z: 0
|
||||||
}, BOTTOM_NOTCH_OFFSET * 2)],
|
}, downOffset)],
|
||||||
lineWidth: 5,
|
lineWidth: 5,
|
||||||
color: this.stringData.currentColor
|
color: this.stringData.currentColor
|
||||||
});
|
});
|
||||||
|
@ -374,13 +393,41 @@
|
||||||
var reloadDetectorPosition = Entities.getEntityProperties(this.reloadDetector, "position");
|
var reloadDetectorPosition = Entities.getEntityProperties(this.reloadDetector, "position");
|
||||||
var fromArrowHandToReloadDetector = Vec3.subtract(arrowHandPosition, reloadDetectorPosition);
|
var fromArrowHandToReloadDetector = Vec3.subtract(arrowHandPosition, reloadDetectorPosition);
|
||||||
var distance = Vec3.length(fromArrowHandToReloadDetector);
|
var distance = Vec3.length(fromArrowHandToReloadDetector);
|
||||||
print('fromArrowHandToReloadDetector distance :: '+distance);
|
print('fromArrowHandToReloadDetector distance :: ' + distance);
|
||||||
if (fromArrowHandToReloadDetector < RELOAD_DETECTOR_DISTANCE) {
|
if (fromArrowHandToReloadDetector < RELOAD_DETECTOR_DISTANCE) {
|
||||||
print('ARROW LOADED');
|
print('ARROW LOADED');
|
||||||
this.hasArrowLoaded = true;
|
if (this.hasArrowLoaded === false) {
|
||||||
|
this.hasArrowLoaded = true;
|
||||||
|
this.loadArrow()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadArrow: function() {
|
||||||
|
var arrowProperties = {
|
||||||
|
name: 'Hifi-Arrow',
|
||||||
|
type: 'Model',
|
||||||
|
shapeType: 'box',
|
||||||
|
modelURL: ARROW_MODEL_URL,
|
||||||
|
dimensions: ARROW_DIMENSIONS,
|
||||||
|
position: this.getArrowHandPosition(),
|
||||||
|
rotation: this.getArrowHandRotation(),
|
||||||
|
collisionsWillMove: false,
|
||||||
|
ignoreForCollisions: true,
|
||||||
|
gravity: ARROW_GRAVITY,
|
||||||
|
// script: ARROW_SCRIPT_URL,
|
||||||
|
lifetime: 40,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false,
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
this.arrow = Entities.addEntity(arrowProperties);
|
||||||
|
},
|
||||||
|
|
||||||
testForHandInNotchDetector: function() {
|
testForHandInNotchDetector: function() {
|
||||||
var arrowHandPosition = this.getArrowHandPosition();
|
var arrowHandPosition = this.getArrowHandPosition();
|
||||||
var notchDetectorPosition = Entities.getEntityProperties(this.notchDetector, "position");
|
var notchDetectorPosition = Entities.getEntityProperties(this.notchDetector, "position");
|
||||||
|
@ -388,11 +435,19 @@
|
||||||
var distance = Vec3.length(fromArrowHandToNotchDetector);
|
var distance = Vec3.length(fromArrowHandToNotchDetector);
|
||||||
if (distance < NOTCH_DETECTOR_DISTANCE) {
|
if (distance < NOTCH_DETECTOR_DISTANCE) {
|
||||||
print('ARROW NOTCHED');
|
print('ARROW NOTCHED');
|
||||||
this.hasArrowNotched = true;
|
if (this.hasArrowNotched === false) {
|
||||||
this.notchArrow();
|
this.hasArrowNotched = true;
|
||||||
|
this.notchArrow();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
notchArrow: function() {
|
||||||
|
|
||||||
|
//put the arrow in the notch
|
||||||
|
},
|
||||||
|
|
||||||
checkStringHand: function() {
|
checkStringHand: function() {
|
||||||
//invert the hands because our string will be held with the opposite hand of the first one we pick up the bow with
|
//invert the hands because our string will be held with the opposite hand of the first one we pick up the bow with
|
||||||
if (this.initialHand === 'left') {
|
if (this.initialHand === 'left') {
|
||||||
|
@ -592,12 +647,6 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getLocalLineVectors: function() {
|
|
||||||
var topVector = Vec3.subtract(this.stringData.handPosition, this.topStringPosition);
|
|
||||||
var bottomVector = Vec3.subtract(this.stringData.handPosition, this.bottomStringPosition);
|
|
||||||
return [topVector, bottomVector];
|
|
||||||
},
|
|
||||||
|
|
||||||
scaleArrowShotStrength: function(value, min1, max1, min2, max2) {
|
scaleArrowShotStrength: function(value, min1, max1, min2, max2) {
|
||||||
return min2 + (max2 - min2) * ((value - min1) / (max1 - min1));
|
return min2 + (max2 - min2) * ((value - min1) / (max1 - min1));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue