Added glow effect to ravestick

This commit is contained in:
ericrius1 2015-12-28 17:32:10 -08:00
parent 890b39f04b
commit cc35eaf4be
3 changed files with 206 additions and 15 deletions

View file

@ -24,6 +24,9 @@ RaveStick = function(spawnPosition) {
green: 10,
blue: 40
}];
var stick = Entities.addEntity({
type: "Model",
name: "raveStick",
@ -40,23 +43,25 @@ RaveStick = function(spawnPosition) {
userData: JSON.stringify({
grabbableKey: {
spatialKey: {
rightRelativePosition: {
x: 0.02,
y: 0,
z: 0
},
leftRelativePosition: {
x: -0.02,
y: 0,
z: 0
},
relativeRotation: Quat.fromPitchYawRollDegrees(90, 90, 0)
rightRelativePosition: {
x: 0.02,
y: 0,
z: 0
},
leftRelativePosition: {
x: -0.02,
y: 0,
z: 0
},
relativeRotation: Quat.fromPitchYawRollDegrees(90, 90, 0)
},
invertSolidWhileHeld: true
}
})
});
var glowEmitter = createGlowEmitter();
var light = Entities.addEntity({
type: 'Light',
name: "raveLight",
@ -82,14 +87,76 @@ RaveStick = function(spawnPosition) {
green: 200,
blue: 40
};
function cleanup() {
Entities.deleteEntity(stick);
Entities.deleteEntity(light);
Entities.deleteEntity(glowEmitter);
}
this.cleanup = cleanup;
function createGlowEmitter() {
var props = Entities.getEntityProperties(stick, ["position", "rotation"]);
var forwardVec = Quat.getFront(props.rotation);
var forwardQuat = Quat.rotationBetween(Vec3.UNIT_Z, forwardVec);
var position = props.position;
var color = {
red: 150,
green: 20,
blue: 100
}
var props = {
type: "ParticleEffect",
name: "Rave Stick Glow Emitter",
position: position,
parentID: stick,
isEmitting: true,
colorStart: color,
color: {
red: 200,
green: 200,
blue: 255
},
colorFinish: color,
maxParticles: 100000,
lifespan: 0.8,
emitRate: 1000,
emitOrientation: forwardQuat,
emitSpeed: 0.2,
speedSpread: 0.0,
emitDimensions: {
x: 0,
y: 0,
z: 0
},
polarStart: 0,
polarFinish: 0,
azimuthStart: 0.1,
azimuthFinish: 0.01,
emitAcceleration: {
x: 0,
y: 0,
z: 0
},
accelerationSpread: {
x: .00,
y: .00,
z: .00
},
radiusStart: 0.01,
radiusFinish: 0.005,
alpha: 0.7,
alphaSpread: 0.1,
alphaStart: 0.1,
alphaFinish: 0.1,
textures: "https://s3.amazonaws.com/hifi-public/eric/textures/particleSprites/beamParticle.png",
emitterShouldTrail: false
}
var glowEmitter = Entities.addEntity(props);
return glowEmitter;
}
}

View file

@ -170,10 +170,12 @@
function createRaveStick(position) {
var modelURL = "http://hifi-content.s3.amazonaws.com/eric/models/raveStick.fbx";
var rotation = Quat.fromPitchYawRollDegrees(0, 0, 0);
var stick = Entities.addEntity({
type: "Model",
name: "raveStick",
modelURL: modelURL,
rotation: rotation,
position: position,
shapeType: 'box',
collisionsWillMove: true,
@ -206,6 +208,66 @@
})
});
var forwardVec = Quat.getFront(rotation);
var forwardQuat = Quat.rotationBetween(Vec3.UNIT_Z, forwardVec);
var color = {
red: 150,
green: 20,
blue: 100
}
var raveGlowEmitter = Entities.addEntity({
type: "ParticleEffect",
name: "Rave Stick Glow Emitter",
position: position,
parentID: stick,
isEmitting: true,
colorStart: color,
color: {
red: 200,
green: 200,
blue: 255
},
colorFinish: color,
maxParticles: 100000,
lifespan: 0.8,
emitRate: 1000,
emitOrientation: forwardQuat,
emitSpeed: 0.2,
speedSpread: 0.0,
emitDimensions: {
x: 0,
y: 0,
z: 0
},
polarStart: 0,
polarFinish: 0,
azimuthStart: 0.1,
azimuthFinish: 0.01,
emitAcceleration: {
x: 0,
y: 0,
z: 0
},
accelerationSpread: {
x: .00,
y: .00,
z: .00
},
radiusStart: 0.01,
radiusFinish: 0.005,
alpha: 0.7,
alphaSpread: 0.1,
alphaStart: 0.1,
alphaFinish: 0.1,
textures: "https://s3.amazonaws.com/hifi-public/eric/textures/particleSprites/beamParticle.png",
emitterShouldTrail: false,
userData: JSON.stringify({
resetMe: {
resetMe: true
}
})
});
}
function createGun(position) {
@ -1447,4 +1509,4 @@
};
// entity scripts always need to return a newly constructed object of our type
return new ResetSwitch();
});
});

View file

@ -149,10 +149,12 @@ MasterReset = function() {
function createRaveStick(position) {
var modelURL = "http://hifi-content.s3.amazonaws.com/eric/models/raveStick.fbx";
var rotation = Quat.fromPitchYawRollDegrees(0, 0, 0);
var stick = Entities.addEntity({
type: "Model",
name: "raveStick",
modelURL: modelURL,
rotation: rotation,
position: position,
shapeType: 'box',
collisionsWillMove: true,
@ -189,6 +191,66 @@ MasterReset = function() {
}
})
});
var forwardVec = Quat.getFront(rotation);
var forwardQuat = Quat.rotationBetween(Vec3.UNIT_Z, forwardVec);
var color = {
red: 150,
green: 20,
blue: 100
}
var raveGlowEmitter = Entities.addEntity({
type: "ParticleEffect",
name: "Rave Stick Glow Emitter",
position: position,
parentID: stick,
isEmitting: true,
colorStart: color,
color: {
red: 200,
green: 200,
blue: 255
},
colorFinish: color,
maxParticles: 100000,
lifespan: 0.8,
emitRate: 1000,
emitOrientation: forwardQuat,
emitSpeed: 0.2,
speedSpread: 0.0,
emitDimensions: {
x: 0,
y: 0,
z: 0
},
polarStart: 0,
polarFinish: 0,
azimuthStart: 0.1,
azimuthFinish: 0.01,
emitAcceleration: {
x: 0,
y: 0,
z: 0
},
accelerationSpread: {
x: .00,
y: .00,
z: .00
},
radiusStart: 0.01,
radiusFinish: 0.005,
alpha: 0.7,
alphaSpread: 0.1,
alphaStart: 0.1,
alphaFinish: 0.1,
textures: "https://s3.amazonaws.com/hifi-public/eric/textures/particleSprites/beamParticle.png",
emitterShouldTrail: false,
userData: JSON.stringify({
resetMe: {
resetMe: true
}
})
});
}
function createGun(position) {
@ -1084,7 +1146,7 @@ MasterReset = function() {
y: 0,
z: 0.06
},
relativeRotation: Quat.fromPitchYawRollDegrees(0,-90, -90)
relativeRotation: Quat.fromPitchYawRollDegrees(0, -90, -90)
},
invertSolidWhileHeld: true
}
@ -1432,4 +1494,4 @@ MasterReset = function() {
Script.scriptEnding.connect(cleanup);
}
};
};