From cc35eaf4be5cf306fb7a1627c7c269e18d78caaf Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Mon, 28 Dec 2015 17:32:10 -0800 Subject: [PATCH] Added glow effect to ravestick --- examples/flowArts/raveStick/raveStick.js | 91 ++++++++++++++++++++---- unpublishedScripts/hiddenEntityReset.js | 64 ++++++++++++++++- unpublishedScripts/masterReset.js | 66 ++++++++++++++++- 3 files changed, 206 insertions(+), 15 deletions(-) diff --git a/examples/flowArts/raveStick/raveStick.js b/examples/flowArts/raveStick/raveStick.js index 5fb019bf97..5021559824 100644 --- a/examples/flowArts/raveStick/raveStick.js +++ b/examples/flowArts/raveStick/raveStick.js @@ -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; + + } } \ No newline at end of file diff --git a/unpublishedScripts/hiddenEntityReset.js b/unpublishedScripts/hiddenEntityReset.js index a53d6e721f..6d29858fb9 100644 --- a/unpublishedScripts/hiddenEntityReset.js +++ b/unpublishedScripts/hiddenEntityReset.js @@ -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(); -}); +}); \ No newline at end of file diff --git a/unpublishedScripts/masterReset.js b/unpublishedScripts/masterReset.js index 2d6d9a0d01..3f1025eb5e 100644 --- a/unpublishedScripts/masterReset.js +++ b/unpublishedScripts/masterReset.js @@ -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); } -}; +}; \ No newline at end of file