From 58587a5780aa6eba447af94f987690aed3c6165b Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 3 Nov 2015 13:26:39 -0800 Subject: [PATCH] spotlight --- examples/helicopter/helicopter.js | 70 ++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js index 7631f166f9..22df9e56b7 100644 --- a/examples/helicopter/helicopter.js +++ b/examples/helicopter/helicopter.js @@ -1,16 +1,16 @@ -var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx"; -var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation()))); +var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx?v3"; +var center = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(Camera.getOrientation()))); // These constants define the Spotlight position and orientation relative to the model var MODEL_LIGHT_POSITION = { - x: -2, + x: 2, y: 0, - z: 0 + z: -5 }; -var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { +var MODEL_LIGHT_ROTATION = Quat.angleAxis(0, { x: 0, - y: 1, - z: 0 + y: 0, + z: 1 }); // Evaluate the world light entity positions and orientations from the model ones @@ -27,31 +27,46 @@ var helicopter = Entities.addEntity({ type: "Model", name: "Helicopter", modelURL: modelURL, - position: center + dimensions: {x: 12.13, y: 3.14, z: 9.92}, + // rotation: Quat.fromPitchYawRollDegrees(0, -90, 0), + position: center, + collisionsWillMove: true }); -var modelProperties = Entities.getEntityProperties(helicopter, ['position', 'rotation']); -var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); var spotlight = Entities.addEntity({ type: "Light", name: "helicopter light", - position: lightTransform.p, - rotation: lightTransform.q, intensity: 2, - color: {red: 200, green: 200, blue: 255}, - intensity: 2, - exponent: 0.3, - cutoff: 20 + color: { + red: 200, + green: 200, + blue: 255 + }, + intensity: 10, + dimensions: { + x: 2, + y: 2, + z: 200 + }, + exponent: .1, + cutoff: 10, + isSpotlight: true }); var debugLight = Entities.addEntity({ type: "Box", - position: lightTransform.p, - rotation: lightTransform.q, - dimensions: {x: 4, y: 1, z: 1}, - color: {red: 200, green: 200, blue: 0} + dimensions: { + x: .1, + y: .1, + z: .3 + }, + color: { + red: 200, + green: 200, + blue: 0 + } }); function cleanup() { @@ -61,4 +76,19 @@ function cleanup() { } +function update() { + var modelProperties = Entities.getEntityProperties(helicopter, ['position', 'rotation']); + var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); + Entities.editEntity(spotlight, { + position: lightTransform.p, + // rotation: lightTransform.q + }); + Entities.editEntity(debugLight, { + position: lightTransform.p, + rotation: lightTransform.q + }); +} + + +Script.update.connect(update); Script.scriptEnding.connect(cleanup); \ No newline at end of file