This commit is contained in:
James B. Pollack 2016-01-25 14:32:52 -08:00
parent be15227bf7
commit 9a49504c56
2 changed files with 122 additions and 122 deletions

View file

@ -322,139 +322,138 @@
}); });
} }
function createBow() { function createBow() {
var startPosition = { var startPosition = {
x: 546.41, x: 546.41,
y: 495.33, y: 495.33,
z: 506.46 z: 506.46
}; };
var SCRIPT_URL = Script.resolvePath('bow.js'); var SCRIPT_URL = Script.resolvePath('bow.js');
var BOW_ROTATION = Quat.fromPitchYawRollDegrees(-103.05, -178.60, -87.27); var BOW_ROTATION = Quat.fromPitchYawRollDegrees(-103.05, -178.60, -87.27);
var MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow-deadly.fbx"; var MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow-deadly.fbx";
var COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow_collision_hull.obj"; var COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow_collision_hull.obj";
var BOW_DIMENSIONS = { var BOW_DIMENSIONS = {
x: 0.04, x: 0.04,
y: 1.3, y: 1.3,
z: 0.21 z: 0.21
}; };
var BOW_GRAVITY = { var BOW_GRAVITY = {
x: 0, x: 0,
y: -9.8, y: -9.8,
z: 0 z: 0
}; };
var TOP_NOTCH_OFFSET = 0.6; var TOP_NOTCH_OFFSET = 0.6;
var BOTTOM_NOTCH_OFFSET = 0.6; var BOTTOM_NOTCH_OFFSET = 0.6;
var LINE_DIMENSIONS = { var LINE_DIMENSIONS = {
x: 5, x: 5,
y: 5, y: 5,
z: 5 z: 5
}; };
var bow; var bow;
function makeBow() { function makeBow() {
var bowProperties = { var bowProperties = {
name: 'Hifi-Bow', name: 'Hifi-Bow',
type: "Model", type: "Model",
modelURL: MODEL_URL, modelURL: MODEL_URL,
position: startPosition, position: startPosition,
dimensions: BOW_DIMENSIONS, dimensions: BOW_DIMENSIONS,
dynamic: true, dynamic: true,
gravity: BOW_GRAVITY, gravity: BOW_GRAVITY,
rotation: BOW_ROTATION, rotation: BOW_ROTATION,
shapeType: 'compound', shapeType: 'compound',
compoundShapeURL: COLLISION_HULL_URL, compoundShapeURL: COLLISION_HULL_URL,
script: bowScriptURL, script: bowScriptURL,
userData: JSON.stringify({ userData: JSON.stringify({
resetMe: { resetMe: {
resetMe: true resetMe: true
}, },
grabbableKey: { grabbableKey: {
invertSolidWhileHeld: true, invertSolidWhileHeld: true,
spatialKey: { spatialKey: {
rightRelativePosition: { rightRelativePosition: {
x: 0.03, x: 0.03,
y: 0.08, y: 0.08,
z: 0.11 z: 0.11
}, },
leftRelativePosition: { leftRelativePosition: {
x: -0.03, x: -0.03,
y: 0.08, y: 0.08,
z: 0.11 z: 0.11
}, },
relativeRotation: Quat.fromPitchYawRollDegrees(180, 90, 90) relativeRotation: Quat.fromPitchYawRollDegrees(180, 90, 90)
}
} }
} })
}) }
bow = Entities.addEntity(bowProperties);
createPreNotchString();
} }
bow = Entities.addEntity(bowProperties); var preNotchString;
createPreNotchString();
function createPreNotchString() {
var bowProperties = Entities.getEntityProperties(bow, ["position", "rotation", "userData"]);
var downVector = Vec3.multiply(-1, Quat.getUp(bowProperties.rotation));
var downOffset = Vec3.multiply(downVector, BOTTOM_NOTCH_OFFSET * 2);
var upVector = Quat.getUp(bowProperties.rotation);
var upOffset = Vec3.multiply(upVector, TOP_NOTCH_OFFSET);
var backOffset = Vec3.multiply(-0.1, Quat.getFront(bowProperties.rotation));
var topStringPosition = Vec3.sum(bowProperties.position, upOffset);
topStringPosition = Vec3.sum(topStringPosition, backOffset);
var stringProperties = {
name: 'Hifi-Bow-Pre-Notch-String',
type: 'Line',
position: topStringPosition,
rotation: Quat.fromPitchYawRollDegrees(164.6, 164.5, -72),
linePoints: [{
x: 0,
y: 0,
z: 0
}, Vec3.sum({
x: 0,
y: 0,
z: 0
}, downOffset)],
lineWidth: 5,
color: {
red: 255,
green: 255,
blue: 255
},
dimensions: LINE_DIMENSIONS,
visible: true,
dynamic: false,
collisionless: true,
parentID: bow,
userData: JSON.stringify({
grabbableKey: {
grabbable: false
}
})
};
preNotchString = Entities.addEntity(stringProperties);
var data = {
preNotchString: preNotchString
};
setEntityCustomData('bowKey', bow, data);
}
makeBow();
} }
var preNotchString;
function createPreNotchString() {
var bowProperties = Entities.getEntityProperties(bow, ["position", "rotation", "userData"]);
var downVector = Vec3.multiply(-1, Quat.getUp(bowProperties.rotation));
var downOffset = Vec3.multiply(downVector, BOTTOM_NOTCH_OFFSET * 2);
var upVector = Quat.getUp(bowProperties.rotation);
var upOffset = Vec3.multiply(upVector, TOP_NOTCH_OFFSET);
var backOffset = Vec3.multiply(-0.1, Quat.getFront(bowProperties.rotation));
var topStringPosition = Vec3.sum(bowProperties.position, upOffset);
topStringPosition = Vec3.sum(topStringPosition, backOffset);
var stringProperties = {
name: 'Hifi-Bow-Pre-Notch-String',
type: 'Line',
position: topStringPosition,
rotation:bowProperties.rotation,
linePoints: [{
x: 0,
y: 0,
z: 0
}, Vec3.sum({
x: 0,
y: 0,
z: 0
}, downOffset)],
lineWidth: 5,
color: {
red: 255,
green: 255,
blue: 255
},
dimensions: LINE_DIMENSIONS,
visible: true,
dynamic: false,
collisionless: true,
parentID: bow,
userData: JSON.stringify({
grabbableKey: {
grabbable: false
}
})
};
preNotchString = Entities.addEntity(stringProperties);
var data = {
preNotchString: preNotchString
};
setEntityCustomData('bowKey', bow, data);
}
makeBow();
}
function createFire() { function createFire() {

View file

@ -399,7 +399,7 @@ MasterReset = function() {
name: 'Hifi-Bow-Pre-Notch-String', name: 'Hifi-Bow-Pre-Notch-String',
type: 'Line', type: 'Line',
position: topStringPosition, position: topStringPosition,
rotation:bowProperties.rotation, rotation: Quat.fromPitchYawRollDegrees(164.6, 164.5, -72),
linePoints: [{ linePoints: [{
x: 0, x: 0,
y: 0, y: 0,
@ -438,6 +438,7 @@ MasterReset = function() {
makeBow(); makeBow();
} }
function createFire() { function createFire() {