From bc7d7a3dae12a09816a8d285afeb97dd249370f5 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 1 Mar 2016 12:43:06 -0800 Subject: [PATCH] adding chapters --- .../fireworksLaunchButtonEntityScript.js | 21 +++++++++++++ .../chapter1/fireworksLaunchButtonSpawner.js | 30 +++++++++++++++++++ .../fireworksLaunchButtonEntityScript.js | 21 +++++++++++++ .../chapter2/fireworksLaunchButtonSpawner.js | 30 +++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 examples/tutorials/fireworks/chapter1/fireworksLaunchButtonEntityScript.js create mode 100644 examples/tutorials/fireworks/chapter1/fireworksLaunchButtonSpawner.js create mode 100644 examples/tutorials/fireworks/chapter2/fireworksLaunchButtonEntityScript.js create mode 100644 examples/tutorials/fireworks/chapter2/fireworksLaunchButtonSpawner.js diff --git a/examples/tutorials/fireworks/chapter1/fireworksLaunchButtonEntityScript.js b/examples/tutorials/fireworks/chapter1/fireworksLaunchButtonEntityScript.js new file mode 100644 index 0000000000..1f361656f1 --- /dev/null +++ b/examples/tutorials/fireworks/chapter1/fireworksLaunchButtonEntityScript.js @@ -0,0 +1,21 @@ +// Chapter 1: fireworksLaunchButtonEntityScript.js + + (function() { + Script.include("../../libraries/utils.js"); + var _this; + Fireworks = function() { + _this = this; + }; + + Fireworks.prototype = { + + preload: function(entityID) { + _this.entityID = entityID; + + } + + }; + + // entity scripts always need to return a newly constructed object of our type + return new Fireworks(); + }); diff --git a/examples/tutorials/fireworks/chapter1/fireworksLaunchButtonSpawner.js b/examples/tutorials/fireworks/chapter1/fireworksLaunchButtonSpawner.js new file mode 100644 index 0000000000..a4969aa8ed --- /dev/null +++ b/examples/tutorials/fireworks/chapter1/fireworksLaunchButtonSpawner.js @@ -0,0 +1,30 @@ + + // Chapter1 : fireworksLaumchButtonSpawner.js + + var orientation = Camera.getOrientation(); + orientation = Quat.safeEulerAngles(orientation); + orientation.x = 0; + orientation = Quat.fromVec3Degrees(orientation); + var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); + + var SCRIPT_URL = Script.resolvePath("fireworksLaunchButtonEntityScript.js"); + var MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Launch-Button.fbx"; + var launchButton = Entities.addEntity({ + type: "Model", + name: "hifi-launch-button", + modelURL: MODEL_URL, + position: center, + dimensions: { + x: 0.98, + y: 1.16, + z: 0.98 + }, + script: SCRIPT_URL, + }) + + + function cleanup() { + Entities.deleteEntity(launchButton); + } + + Script.scriptEnding.connect(cleanup); \ No newline at end of file diff --git a/examples/tutorials/fireworks/chapter2/fireworksLaunchButtonEntityScript.js b/examples/tutorials/fireworks/chapter2/fireworksLaunchButtonEntityScript.js new file mode 100644 index 0000000000..1f361656f1 --- /dev/null +++ b/examples/tutorials/fireworks/chapter2/fireworksLaunchButtonEntityScript.js @@ -0,0 +1,21 @@ +// Chapter 1: fireworksLaunchButtonEntityScript.js + + (function() { + Script.include("../../libraries/utils.js"); + var _this; + Fireworks = function() { + _this = this; + }; + + Fireworks.prototype = { + + preload: function(entityID) { + _this.entityID = entityID; + + } + + }; + + // entity scripts always need to return a newly constructed object of our type + return new Fireworks(); + }); diff --git a/examples/tutorials/fireworks/chapter2/fireworksLaunchButtonSpawner.js b/examples/tutorials/fireworks/chapter2/fireworksLaunchButtonSpawner.js new file mode 100644 index 0000000000..a4969aa8ed --- /dev/null +++ b/examples/tutorials/fireworks/chapter2/fireworksLaunchButtonSpawner.js @@ -0,0 +1,30 @@ + + // Chapter1 : fireworksLaumchButtonSpawner.js + + var orientation = Camera.getOrientation(); + orientation = Quat.safeEulerAngles(orientation); + orientation.x = 0; + orientation = Quat.fromVec3Degrees(orientation); + var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); + + var SCRIPT_URL = Script.resolvePath("fireworksLaunchButtonEntityScript.js"); + var MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Launch-Button.fbx"; + var launchButton = Entities.addEntity({ + type: "Model", + name: "hifi-launch-button", + modelURL: MODEL_URL, + position: center, + dimensions: { + x: 0.98, + y: 1.16, + z: 0.98 + }, + script: SCRIPT_URL, + }) + + + function cleanup() { + Entities.deleteEntity(launchButton); + } + + Script.scriptEnding.connect(cleanup); \ No newline at end of file