some fixups to spray paint script

This commit is contained in:
ericrius1 2015-09-15 15:48:21 -07:00
parent 0a46db60ac
commit 9648f56062
2 changed files with 9 additions and 16 deletions

View file

@ -1,6 +1,7 @@
(function() {
// Script.include("../libraries/utils.js");
//Need absolute path for now, for testing before PR merge and s3 cloning. Will change post-merge
Script.include("https://hifi-public.s3.amazonaws.com/scripts/libraries/utils.js");
GRAB_FRAME_USER_DATA_KEY = "grabFrame";
this.userData = {};
@ -60,22 +61,16 @@
if (self.activated !== true) {
//We were just grabbed, so create a particle system
self.grab();
Entities.editEntity(self.paintStream, {
animationSettings: startSetting
});
}
//Move emitter to where entity is always when its activated
self.sprayStream();
} else if (self.userData.grabKey && self.userData.grabKey.activated === false && self.activated) {
Entities.editEntity(self.paintStream, {
animationSettings: stopSetting
});
self.activated = false;
self.letGo();
}
}
this.grab = function() {
self.activated = true;
this.activated = true;
var animationSettings = JSON.stringify({
fps: 30,
loop: true,
@ -109,7 +104,7 @@
}
this.letGo = function() {
self.activated = false;
this.activated = false;
Entities.deleteEntity(this.paintStream);
}
@ -123,8 +118,7 @@
}
this.sprayStream = function() {
var forwardVec = Quat.getFront(self.properties.rotation);
forwardVec = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, 90, 0), forwardVec);
var forwardVec = Quat.getFront(Quat.multiply(self.properties.rotation , Quat.fromPitchYawRollDegrees(0, 90, 0)));
forwardVec = Vec3.normalize(forwardVec);
var upVec = Quat.getUp(self.properties.rotation);
@ -132,11 +126,10 @@
position = Vec3.sum(position, Vec3.multiply(upVec, TIP_OFFSET_Y))
Entities.editEntity(self.paintStream, {
position: position,
emitVelocity: Vec3.multiply(forwardVec, 4)
emitVelocity: Vec3.multiply(5, forwardVec)
});
//Now check for an intersection with an entity
//move forward so ray doesnt intersect with gun
var origin = Vec3.sum(position, forwardVec);
var pickRay = {
@ -244,6 +237,7 @@
});
function randFloat(min, max) {
return Math.random() * (max - min) + min;
}

View file

@ -11,7 +11,6 @@
//Just temporarily using my own bucket here so others can test the entity. Once PR is tested and merged, then the entity script will appear in its proper place in S3, and I wil switch it
var scriptURL = "https://hifi-public.s3.amazonaws.com/eric/scripts/sprayPaintCan.js?=v1";
var modelURL = "https://hifi-public.s3.amazonaws.com/eric/models/paintcan.fbx";
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
var sprayCan = Entities.addEntity({
type: "Model",
@ -27,8 +26,8 @@ var sprayCan = Entities.addEntity({
collisionsWillMove: true,
shapeType: 'box',
script: scriptURL,
gravity: {x: 0, y: -0.5, z: 0},
velocity: {x: 0, y: -1, z: 0}
// gravity: {x: 0, y: -0.5, z: 0},
// velocity: {x: 0, y: -1, z: 0}
});
function cleanup() {