overte-HifiExperiments/examples/weapons/pistol/pistolSpawner.js
2015-11-18 16:34:39 -08:00

30 lines
No EOL
845 B
JavaScript

var center = Vec3.sum(MyAvatar.position, Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation())));
var scriptURL = Script.resolvePath('pistol.js');
var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/gun.fbx";
print("SJDJDJ")
var pistol = Entities.addEntity({
type: 'Model',
modelURL: modelURL,
position: center,
dimensions: {x: 0.08, y: .38, z: .6},
script: scriptURL,
color: {red: 200, green: 0, blue: 20},
shapeType: 'box',
collisionsWillMove: true,
userData: JSON.stringify({
grabbableKey: {
spatialKey: {
relativePosition: {x: 0, y: 0, z: 0},
relativeRotation: Quat.fromPitchYawRollDegrees(45, 90 , 0)
}
}
})
});
function cleanup() {
Entities.deleteEntity(pistol);
}
Script.scriptEnding.connect(cleanup);