From 5b854857c19d54488d5dc01f372c6729fee67660 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Sat, 7 Mar 2015 18:02:41 -0800 Subject: [PATCH] fix JS scripts to use radians per second in entity properties --- examples/controllers/hydra/toyball.js | 2 -- examples/dice.js | 6 ++-- examples/example/entities/spotlightExample.js | 4 ++- examples/html/entityProperties.html | 30 +++++++++++++++---- examples/libraries/entityPropertyDialogBox.js | 17 +++++++---- examples/planets.js | 6 ++-- examples/popcorn.js | 7 +++-- examples/walk.js | 2 +- 8 files changed, 53 insertions(+), 21 deletions(-) diff --git a/examples/controllers/hydra/toyball.js b/examples/controllers/hydra/toyball.js index 5306769e95..89085fad19 100644 --- a/examples/controllers/hydra/toyball.js +++ b/examples/controllers/hydra/toyball.js @@ -92,7 +92,6 @@ function checkControllerSide(whichSide) { Vec3.multiply(1.0 - AVERAGE_FACTOR, averageLinearVelocity[0])); linearVelocity = averageLinearVelocity[0]; angularVelocity = Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getSpatialControlRawAngularVelocity(LEFT_TIP)); - angularVelocity = Vec3.multiply(180.0 / Math.PI, angularVelocity); } else { BUTTON_FWD = RIGHT_BUTTON_FWD; BUTTON_3 = RIGHT_BUTTON_3; @@ -104,7 +103,6 @@ function checkControllerSide(whichSide) { Vec3.multiply(1.0 - AVERAGE_FACTOR, averageLinearVelocity[1])); linearVelocity = averageLinearVelocity[1]; angularVelocity = Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getSpatialControlRawAngularVelocity(RIGHT_TIP)); - angularVelocity = Vec3.multiply(180.0 / Math.PI, angularVelocity); handMessage = "RIGHT"; } diff --git a/examples/dice.js b/examples/dice.js index 1205f38ee1..b0021ecebb 100644 --- a/examples/dice.js +++ b/examples/dice.js @@ -53,7 +53,9 @@ function shootDice(position, velocity) { position: position, velocity: velocity, rotation: Quat.fromPitchYawRollDegrees(Math.random() * 360, Math.random() * 360, Math.random() * 360), - angularVelocity: { x: Math.random() * 100, y: Math.random() * 100, z: Math.random() * 100 }, + // NOTE: angularVelocity is in radians/sec + var maxAngularSpeed = Math.PI; + angularVelocity: { x: Math.random() * maxAngularSpeed, y: Math.random() * maxAngularSpeed, z: Math.random() * maxAngularSpeed }, lifetime: LIFETIME, gravity: { x: 0, y: GRAVITY, z: 0 }, shapeType: "box", @@ -108,4 +110,4 @@ function scriptEnding() { Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity); Controller.mousePressEvent.connect(mousePressEvent); -Script.scriptEnding.connect(scriptEnding); \ No newline at end of file +Script.scriptEnding.connect(scriptEnding); diff --git a/examples/example/entities/spotlightExample.js b/examples/example/entities/spotlightExample.js index 5eb5432f3f..80c89926a3 100644 --- a/examples/example/entities/spotlightExample.js +++ b/examples/example/entities/spotlightExample.js @@ -11,11 +11,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +var DEGREES_TO_RADIANS = Math.PI / 180.0; + var lightProperties = { type: "Light", position: { x: 0, y: 0, z: 0 }, dimensions: { x: 1000, y: 1000, z: 1000 }, - angularVelocity: { x: 0, y: 10, z: 0 }, + angularVelocity: { x: 0, y: 10 * DEGREES_TO_RADIANS, z: 0 }, angularDamping: 0, isSpotlight: true, diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index fd1a4e3821..cb49b86975 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -2,6 +2,10 @@