From 3d1c77d04796b19a55bea4a9394a8521f872b553 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 20 Sep 2013 14:47:36 -0700 Subject: [PATCH] expose the TREE_SCALE to JS --- assignment-client/src/Agent.cpp | 4 ++++ .../resources/web/assignment/placeholder.js | 19 ++----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 7ace955ccd..cfdb34208c 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -11,6 +11,7 @@ #include #include +#include #include "Agent.h" #include "voxels/VoxelScriptingInterface.h" @@ -52,6 +53,9 @@ void Agent::run() { QScriptValue voxelScripterValue = engine.newQObject(&voxelScripter); engine.globalObject().setProperty("Voxels", voxelScripterValue); + QScriptValue treeScaleValue = engine.newVariant(QVariant(TREE_SCALE)); + engine.globalObject().setProperty("TREE_SCALE", treeScaleValue); + qDebug() << "Downloaded script:" << scriptString << "\n"; qDebug() << "Evaluated script:" << engine.evaluate(scriptString).toString() << "\n"; diff --git a/domain-server/resources/web/assignment/placeholder.js b/domain-server/resources/web/assignment/placeholder.js index f106fbc9ba..93f90b7b30 100644 --- a/domain-server/resources/web/assignment/placeholder.js +++ b/domain-server/resources/web/assignment/placeholder.js @@ -1,20 +1,5 @@ -/* Add your JavaScript for assignment below this line */ +// Add your JavaScript for assignment below this line -// here are some examples of things you can call -Avatar.position = {x: 0, y: 0.565925, z: 10}; -Avatar.chatMessage = "I am not a robot!"; -Avatar.handPosition = {x: 0, y: 4.5, z: 0}; +// The following is an example of Conway's Game of Life (http://en.wikipedia.org/wiki/Conway's_Game_of_Life) -// here I'm creating a function to fire before each data send -function dance() { - // switch the body yaw from 1 to 90 - var randomAngle = Math.floor(Math.random() * 90); - if (Math.random() < 0.5) { - randomAngle * -1; - } - - Avatar.bodyYaw = randomAngle; -} -// register the call back so it fires before each data send -Agent.preSendCallback.connect(dance); \ No newline at end of file