mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 01:06:25 +02:00
update after updating models
This commit is contained in:
parent
9d49843114
commit
ca0aad7d3b
2 changed files with 380 additions and 283 deletions
|
@ -12,14 +12,26 @@
|
|||
|
||||
(function() {
|
||||
|
||||
var ARROW_MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/arrow.fbx";
|
||||
var ARROW_COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/arrow_collision_hull.obj";
|
||||
var ZERO_VEC = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
};
|
||||
var LINE_ENTITY_DIMENSIONS = {
|
||||
x: 1000,
|
||||
y: 1000,
|
||||
z: 1000
|
||||
};
|
||||
|
||||
|
||||
var ARROW_MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/arrow_good.fbx";
|
||||
var ARROW_COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/arrow_good_collision_hull.obj";
|
||||
var ARROW_SCRIPT_URL = Script.resolvePath('arrow.js');
|
||||
var ARROW_OFFSET = 0.25;
|
||||
var ARROW_FORCE = 1.25;
|
||||
var ARROW_DIMENSIONS = {
|
||||
x: 0.08,
|
||||
y: 0.02,
|
||||
x: 0.01,
|
||||
y: 0.01,
|
||||
z: 0.08
|
||||
};
|
||||
var ARROW_GRAVITY = {
|
||||
|
@ -39,6 +51,8 @@
|
|||
|
||||
var DRAW_STRING_THRESHOLD = 0.80;
|
||||
|
||||
var TARGET_LINE_LENGTH = 0.3;
|
||||
|
||||
var _this;
|
||||
|
||||
function Bow() {
|
||||
|
@ -145,9 +159,9 @@
|
|||
|
||||
updateStringPositions: function() {
|
||||
|
||||
var upVector = Quat.getFront(this.bowProperties.rotation);
|
||||
var upVector = Quat.getUp(this.bowProperties.rotation);
|
||||
var upOffset = Vec3.multiply(upVector, TOP_NOTCH_OFFSET);
|
||||
var downVector = Vec3.multiply(-1, Quat.getFront(this.bowProperties.rotation));
|
||||
var downVector = Vec3.multiply(-1, Quat.getUp(this.bowProperties.rotation));
|
||||
var downOffset = Vec3.multiply(downVector, BOTTOM_NOTCH_OFFSET);
|
||||
|
||||
this.topStringPosition = Vec3.sum(this.bowProperties.position, upOffset);
|
||||
|
@ -183,6 +197,7 @@
|
|||
continueNearGrab: function() {
|
||||
this.bowProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]);
|
||||
this.checkStringHand();
|
||||
this.createTargetLine();
|
||||
},
|
||||
|
||||
releaseGrab: function() {
|
||||
|
@ -262,14 +277,13 @@
|
|||
updateArrowPosition: function() {
|
||||
var arrowPosition = this.getArrowPosition();
|
||||
|
||||
var arrowRotation = Quat.getFront(this.bowProperties.rotation);
|
||||
// print('ARROW POSITION:::' + JSON.stringify(arrowPosition));
|
||||
var bowRotation = Quat.getFront(this.bowProperties.rotation);
|
||||
|
||||
Entities.editEntity(this.arrow, {
|
||||
position: arrowPosition,
|
||||
rotation: arrowRotation
|
||||
rotation: this.bowProperties.rotation
|
||||
});
|
||||
},
|
||||
|
||||
createArrow: function() {
|
||||
// print('CREATING ARROW');
|
||||
var arrowProperties = {
|
||||
|
@ -288,9 +302,92 @@
|
|||
this.arrow = Entities.addEntity(arrowProperties);
|
||||
},
|
||||
|
||||
createTargetLine: function() {
|
||||
|
||||
var bowRotation = this.bowProperties.rotation;
|
||||
|
||||
|
||||
Entities.addEntity({
|
||||
type: "Line",
|
||||
name: "Debug Line",
|
||||
dimensions: LINE_ENTITY_DIMENSIONS,
|
||||
visible: true,
|
||||
rotation: bowRotation,
|
||||
position: this.bowProperties.position,
|
||||
linePoints: [ZERO_VEC, Vec3.multiply(TARGET_LINE_LENGTH, Quat.getFront(this.bowProperties.rotation))],
|
||||
color: {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 255
|
||||
},
|
||||
lifetime: 0.1
|
||||
});
|
||||
|
||||
Entities.addEntity({
|
||||
type: "Line",
|
||||
name: "Debug Line",
|
||||
dimensions: LINE_ENTITY_DIMENSIONS,
|
||||
visible: true,
|
||||
// rotation: bowRotation,
|
||||
position: this.bowProperties.position,
|
||||
linePoints: [ZERO_VEC, Vec3.multiply(TARGET_LINE_LENGTH, {
|
||||
x: 1,
|
||||
y: 0,
|
||||
z: 0
|
||||
})],
|
||||
color: {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 0
|
||||
},
|
||||
lifetime: 0.1
|
||||
});
|
||||
|
||||
Entities.addEntity({
|
||||
type: "Line",
|
||||
name: "Debug Line",
|
||||
dimensions: LINE_ENTITY_DIMENSIONS,
|
||||
visible: true,
|
||||
// rotation: bowRotation,
|
||||
position: this.bowProperties.position,
|
||||
linePoints: [ZERO_VEC, Vec3.multiply(TARGET_LINE_LENGTH, {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
})],
|
||||
color: {
|
||||
red: 0,
|
||||
green: 255,
|
||||
blue: 0
|
||||
},
|
||||
lifetime: 0.1
|
||||
});
|
||||
|
||||
Entities.addEntity({
|
||||
type: "Line",
|
||||
name: "Debug Line",
|
||||
dimensions: LINE_ENTITY_DIMENSIONS,
|
||||
visible: true,
|
||||
// rotation:bowRotation,
|
||||
position: this.bowProperties.position,
|
||||
linePoints: [ZERO_VEC, Vec3.multiply(TARGET_LINE_LENGTH, {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 1
|
||||
})],
|
||||
color: {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 255
|
||||
},
|
||||
lifetime: 0.1
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
releaseArrow: function() {
|
||||
|
||||
var forwardVec = Quat.getRight(Quat.multiply(this.bowProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0)));
|
||||
var forwardVec = Quat.getRight(Quat.multiply(this.bowProperties.rotation, Quat.fromPitchYawRollDegrees(0, 40, 0)));
|
||||
forwardVec = Vec3.normalize(forwardVec);
|
||||
var handDistanceAtRelease = Vec3.length(this.bowProperties.position, this.stringData.handPosition);
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
var SCRIPT_URL = Script.resolvePath('bow.js');
|
||||
|
||||
var MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/bow.fbx";
|
||||
var COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/bow_collision_hull.obj";
|
||||
var MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/bow_good.fbx";
|
||||
var COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/bow_good_collision_hull.obj";
|
||||
var BOW_DIMENSIONS = {
|
||||
x: 0.1,
|
||||
y: 0.02,
|
||||
z: 1
|
||||
x: 0.02,
|
||||
y: 1,
|
||||
z: 0.1
|
||||
};
|
||||
|
||||
var BOW_GRAVITY = {
|
||||
|
@ -26,7 +26,7 @@ var BOW_GRAVITY = {
|
|||
y: 0,
|
||||
z: 0
|
||||
}
|
||||
var BOW_ROTATION = Quat.fromPitchYawRollDegrees(90, 180, 0);
|
||||
// var BOW_ROTATION = Quat.fromPitchYawRollDegrees(90, 180, 0);
|
||||
|
||||
var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
||||
x: 0,
|
||||
|
@ -39,7 +39,7 @@ var bow = Entities.addEntity({
|
|||
type: "Model",
|
||||
modelURL: MODEL_URL,
|
||||
position: center,
|
||||
rotation: BOW_ROTATION,
|
||||
// rotation: BOW_ROTATION,
|
||||
dimensions: BOW_DIMENSIONS,
|
||||
collisionsWillMove: true,
|
||||
gravity: BOW_GRAVITY,
|
||||
|
|
Loading…
Reference in a new issue