From 602275a0f788876c5282bd5637071dce2b56d580 Mon Sep 17 00:00:00 2001 From: Chris Collins Date: Tue, 6 Jan 2015 11:16:40 -0800 Subject: [PATCH] First pass moving scripts into an example folder. This is just a quick first pass to move some of the scripts into an examples folder. There are also a couple of obvious deletions. --- examples/{ => acScripts}/ControlACs.js | 0 examples/count.js | 30 - .../{ => example}/animatedModelExample.js | 0 .../{ => example}/animationStateExample.js | 0 examples/{ => example}/audioDeviceExample.js | 0 examples/{ => example}/audioMuteExample.js | 0 examples/{ => example}/cameraExample.js | 0 examples/{ => example}/cleanupChessboards.js | 0 .../{ => example}/clonedOverlaysExample.js | 0 examples/{ => example}/collidingEntities.js | 0 examples/{ => example}/controllerExample.js | 0 examples/{ => example}/dialogExample.js | 0 examples/{ => example}/editEntityExample.js | 0 examples/{ => example}/editModelExample.js | 0 examples/{ => example}/entityModelExample.js | 0 examples/{ => example}/fileBrowserExample.js | 0 examples/{ => example}/findEntitiesExample.js | 0 .../{ => example}/globalCollisionsExample.js | 0 .../{ => example}/globalServicesExample.js | 0 examples/{ => example}/hideAvatarExample.js | 0 examples/{ => example}/includeExample.js | 0 examples/{ => example}/lightExample.js | 0 examples/{ => example}/localVoxelsExample.js | 0 examples/{ => example}/locationExample.js | 0 examples/{ => example}/lookAtExample.js | 0 examples/{ => example}/menuExample.js | 0 .../{ => example}/multipleCursorsExample.js | 0 examples/{ => example}/multitouchExample.js | 0 examples/{ => example}/overlaysExample.js | 0 examples/{ => example}/playChess.js | 0 examples/{ => example}/radio.js | 0 examples/{ => example}/rayPickExample.js | 0 .../rideAlongWithAnEntityExample.js | 0 examples/{ => example}/settingsExample.js | 0 .../{ => example}/spaceInvadersExample.js | 0 examples/{ => example}/spotlightExample.js | 0 examples/{ => example}/streetAreaExample.js | 0 examples/{ => example}/windowExample.js | 0 examples/followThroughOverlappingAction.js | 986 ------------------ examples/myBalance.js | 121 --- examples/seeingVoxelsExample.js | 85 -- examples/testingVoxelViewerRestart.js | 94 -- 42 files changed, 1316 deletions(-) rename examples/{ => acScripts}/ControlACs.js (100%) delete mode 100644 examples/count.js rename examples/{ => example}/animatedModelExample.js (100%) rename examples/{ => example}/animationStateExample.js (100%) rename examples/{ => example}/audioDeviceExample.js (100%) rename examples/{ => example}/audioMuteExample.js (100%) rename examples/{ => example}/cameraExample.js (100%) rename examples/{ => example}/cleanupChessboards.js (100%) rename examples/{ => example}/clonedOverlaysExample.js (100%) rename examples/{ => example}/collidingEntities.js (100%) rename examples/{ => example}/controllerExample.js (100%) rename examples/{ => example}/dialogExample.js (100%) rename examples/{ => example}/editEntityExample.js (100%) rename examples/{ => example}/editModelExample.js (100%) rename examples/{ => example}/entityModelExample.js (100%) rename examples/{ => example}/fileBrowserExample.js (100%) rename examples/{ => example}/findEntitiesExample.js (100%) rename examples/{ => example}/globalCollisionsExample.js (100%) rename examples/{ => example}/globalServicesExample.js (100%) rename examples/{ => example}/hideAvatarExample.js (100%) rename examples/{ => example}/includeExample.js (100%) rename examples/{ => example}/lightExample.js (100%) rename examples/{ => example}/localVoxelsExample.js (100%) rename examples/{ => example}/locationExample.js (100%) rename examples/{ => example}/lookAtExample.js (100%) rename examples/{ => example}/menuExample.js (100%) rename examples/{ => example}/multipleCursorsExample.js (100%) rename examples/{ => example}/multitouchExample.js (100%) rename examples/{ => example}/overlaysExample.js (100%) rename examples/{ => example}/playChess.js (100%) rename examples/{ => example}/radio.js (100%) rename examples/{ => example}/rayPickExample.js (100%) rename examples/{ => example}/rideAlongWithAnEntityExample.js (100%) rename examples/{ => example}/settingsExample.js (100%) rename examples/{ => example}/spaceInvadersExample.js (100%) rename examples/{ => example}/spotlightExample.js (100%) rename examples/{ => example}/streetAreaExample.js (100%) rename examples/{ => example}/windowExample.js (100%) delete mode 100644 examples/followThroughOverlappingAction.js delete mode 100644 examples/myBalance.js delete mode 100644 examples/seeingVoxelsExample.js delete mode 100644 examples/testingVoxelViewerRestart.js diff --git a/examples/ControlACs.js b/examples/acScripts/ControlACs.js similarity index 100% rename from examples/ControlACs.js rename to examples/acScripts/ControlACs.js diff --git a/examples/count.js b/examples/count.js deleted file mode 100644 index 2a8699ac55..0000000000 --- a/examples/count.js +++ /dev/null @@ -1,30 +0,0 @@ -// -// count.js -// examples -// -// Created by Brad Hefta-Gaub on 12/31/13. -// Copyright 2013 High Fidelity, Inc. -// -// This is an example script that runs in a loop and displays a counter to the log -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -// - -var count = 0; - -function displayCount(deltaTime) { - print("count =" + count + " deltaTime=" + deltaTime); - count++; -} - -function scriptEnding() { - print("SCRIPT ENDNG!!!\n"); -} - -// register the call back so it fires before each data send -Script.update.connect(displayCount); - -// register our scriptEnding callback -Script.scriptEnding.connect(scriptEnding); diff --git a/examples/animatedModelExample.js b/examples/example/animatedModelExample.js similarity index 100% rename from examples/animatedModelExample.js rename to examples/example/animatedModelExample.js diff --git a/examples/animationStateExample.js b/examples/example/animationStateExample.js similarity index 100% rename from examples/animationStateExample.js rename to examples/example/animationStateExample.js diff --git a/examples/audioDeviceExample.js b/examples/example/audioDeviceExample.js similarity index 100% rename from examples/audioDeviceExample.js rename to examples/example/audioDeviceExample.js diff --git a/examples/audioMuteExample.js b/examples/example/audioMuteExample.js similarity index 100% rename from examples/audioMuteExample.js rename to examples/example/audioMuteExample.js diff --git a/examples/cameraExample.js b/examples/example/cameraExample.js similarity index 100% rename from examples/cameraExample.js rename to examples/example/cameraExample.js diff --git a/examples/cleanupChessboards.js b/examples/example/cleanupChessboards.js similarity index 100% rename from examples/cleanupChessboards.js rename to examples/example/cleanupChessboards.js diff --git a/examples/clonedOverlaysExample.js b/examples/example/clonedOverlaysExample.js similarity index 100% rename from examples/clonedOverlaysExample.js rename to examples/example/clonedOverlaysExample.js diff --git a/examples/collidingEntities.js b/examples/example/collidingEntities.js similarity index 100% rename from examples/collidingEntities.js rename to examples/example/collidingEntities.js diff --git a/examples/controllerExample.js b/examples/example/controllerExample.js similarity index 100% rename from examples/controllerExample.js rename to examples/example/controllerExample.js diff --git a/examples/dialogExample.js b/examples/example/dialogExample.js similarity index 100% rename from examples/dialogExample.js rename to examples/example/dialogExample.js diff --git a/examples/editEntityExample.js b/examples/example/editEntityExample.js similarity index 100% rename from examples/editEntityExample.js rename to examples/example/editEntityExample.js diff --git a/examples/editModelExample.js b/examples/example/editModelExample.js similarity index 100% rename from examples/editModelExample.js rename to examples/example/editModelExample.js diff --git a/examples/entityModelExample.js b/examples/example/entityModelExample.js similarity index 100% rename from examples/entityModelExample.js rename to examples/example/entityModelExample.js diff --git a/examples/fileBrowserExample.js b/examples/example/fileBrowserExample.js similarity index 100% rename from examples/fileBrowserExample.js rename to examples/example/fileBrowserExample.js diff --git a/examples/findEntitiesExample.js b/examples/example/findEntitiesExample.js similarity index 100% rename from examples/findEntitiesExample.js rename to examples/example/findEntitiesExample.js diff --git a/examples/globalCollisionsExample.js b/examples/example/globalCollisionsExample.js similarity index 100% rename from examples/globalCollisionsExample.js rename to examples/example/globalCollisionsExample.js diff --git a/examples/globalServicesExample.js b/examples/example/globalServicesExample.js similarity index 100% rename from examples/globalServicesExample.js rename to examples/example/globalServicesExample.js diff --git a/examples/hideAvatarExample.js b/examples/example/hideAvatarExample.js similarity index 100% rename from examples/hideAvatarExample.js rename to examples/example/hideAvatarExample.js diff --git a/examples/includeExample.js b/examples/example/includeExample.js similarity index 100% rename from examples/includeExample.js rename to examples/example/includeExample.js diff --git a/examples/lightExample.js b/examples/example/lightExample.js similarity index 100% rename from examples/lightExample.js rename to examples/example/lightExample.js diff --git a/examples/localVoxelsExample.js b/examples/example/localVoxelsExample.js similarity index 100% rename from examples/localVoxelsExample.js rename to examples/example/localVoxelsExample.js diff --git a/examples/locationExample.js b/examples/example/locationExample.js similarity index 100% rename from examples/locationExample.js rename to examples/example/locationExample.js diff --git a/examples/lookAtExample.js b/examples/example/lookAtExample.js similarity index 100% rename from examples/lookAtExample.js rename to examples/example/lookAtExample.js diff --git a/examples/menuExample.js b/examples/example/menuExample.js similarity index 100% rename from examples/menuExample.js rename to examples/example/menuExample.js diff --git a/examples/multipleCursorsExample.js b/examples/example/multipleCursorsExample.js similarity index 100% rename from examples/multipleCursorsExample.js rename to examples/example/multipleCursorsExample.js diff --git a/examples/multitouchExample.js b/examples/example/multitouchExample.js similarity index 100% rename from examples/multitouchExample.js rename to examples/example/multitouchExample.js diff --git a/examples/overlaysExample.js b/examples/example/overlaysExample.js similarity index 100% rename from examples/overlaysExample.js rename to examples/example/overlaysExample.js diff --git a/examples/playChess.js b/examples/example/playChess.js similarity index 100% rename from examples/playChess.js rename to examples/example/playChess.js diff --git a/examples/radio.js b/examples/example/radio.js similarity index 100% rename from examples/radio.js rename to examples/example/radio.js diff --git a/examples/rayPickExample.js b/examples/example/rayPickExample.js similarity index 100% rename from examples/rayPickExample.js rename to examples/example/rayPickExample.js diff --git a/examples/rideAlongWithAnEntityExample.js b/examples/example/rideAlongWithAnEntityExample.js similarity index 100% rename from examples/rideAlongWithAnEntityExample.js rename to examples/example/rideAlongWithAnEntityExample.js diff --git a/examples/settingsExample.js b/examples/example/settingsExample.js similarity index 100% rename from examples/settingsExample.js rename to examples/example/settingsExample.js diff --git a/examples/spaceInvadersExample.js b/examples/example/spaceInvadersExample.js similarity index 100% rename from examples/spaceInvadersExample.js rename to examples/example/spaceInvadersExample.js diff --git a/examples/spotlightExample.js b/examples/example/spotlightExample.js similarity index 100% rename from examples/spotlightExample.js rename to examples/example/spotlightExample.js diff --git a/examples/streetAreaExample.js b/examples/example/streetAreaExample.js similarity index 100% rename from examples/streetAreaExample.js rename to examples/example/streetAreaExample.js diff --git a/examples/windowExample.js b/examples/example/windowExample.js similarity index 100% rename from examples/windowExample.js rename to examples/example/windowExample.js diff --git a/examples/followThroughOverlappingAction.js b/examples/followThroughOverlappingAction.js deleted file mode 100644 index fdbd5e5550..0000000000 --- a/examples/followThroughOverlappingAction.js +++ /dev/null @@ -1,986 +0,0 @@ -// -// follow-through-and-overlapping-action.js -// -// Simple demonstration showing the visual effect of adding the Disney -// follow through and overlapping action animation technique to avatar movement. -// -// Designed and created by David Wooldridge and Ozan Serim, August 2014 -// -// Version 1.001 -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// location of overlay images -var pathToOverlays = "https://s3.amazonaws.com/hifi-public/ArmSwingScript/ArmSwingOverlays/"; - -// animation -var LEFT = 1; -var RIGHT = 2; -var DIRECTION = 0; - -// min max -var weightMin = 1; -var weightMax = 20; -var jointEffectMax = 5; - -// animation effect variables -var handEffect = 3.4; // 0 to jointEffectMax -var forearmEffect = 2.5; // 0 to jointEffectMax -var limbWeight = 8; // will only use nearest integer, as defines an array length -var effectStrength = 1; // 0 to 1 - overall effect strength -// Overshoot: false uses upper arm as driver for forearm and hand -// true uses upper arm for forearm and lower arm as driver for hand. -var overShoot = false; - -// animate self (tap the 'r' key) -var animateSelf = false; -var selfAnimateFrequency = 7.5; - -// overlay values -var handleValue = 0; -var controlPosX = Window.innerWidth / 2 - 500; -var controlPosY = 0; -var minSliderX = controlPosX + 18; -var sliderRangeX = 190; -var minHandleX = controlPosX - 50; -var handleRangeX = 350 / 2; -var handlePosition = 0; - -// background overlay -var controllerBackground = Overlays.addOverlay("image", { - bounds: {x: controlPosX, y: controlPosY, width: 250, height: 380}, - imageURL: pathToOverlays + "flourish-augmentation-control-overlay.png", - color: {red: 255, green: 255, blue: 255}, - alpha: 1 - }); -var controllerRadioSelectedBackground = Overlays.addOverlay("image", { - bounds: {x: controlPosX, y: controlPosY, width: 250, height: 380}, - imageURL: pathToOverlays + "flourish-augmentation-control-radio-selected-overlay.png", - color: {red: 255, green: 255, blue: 255}, - alpha: 1, - visible: false - }); -// handle overlay -var applyMotionHandle = Overlays.addOverlay("image", { - bounds: {x: minHandleX+handleRangeX-39, y: controlPosY+232, - width: 79, height: 100}, - imageURL: pathToOverlays + "flourish-augmentation-handle-overlay.png", - color: {red: 255, green: 255, blue: 255}, - alpha: 1 - }); -// slider overlays -var handEffectSlider = Overlays.addOverlay("image", { - bounds: {x: minSliderX + (handEffect / jointEffectMax * sliderRangeX), - y: controlPosY + 46, width: 25, height: 25}, - imageURL: pathToOverlays + "ddao-slider-handle.png", - color: {red: 255, green: 255, blue: 255}, - alpha: 1 - }); -var forearmEffectSlider = Overlays.addOverlay("image", { - bounds: {x: minSliderX + (forearmEffect / jointEffectMax * sliderRangeX), y: controlPosY + 86, - width: 25, height: 25}, - imageURL: pathToOverlays + "ddao-slider-handle.png", - color: {red: 255, green: 255, blue: 255}, - alpha: 1 - }); -var limbWeightSlider = Overlays.addOverlay("image", { - bounds: {x: minSliderX + (limbWeight / weightMax * sliderRangeX), y: controlPosY+126, - width: 25, height: 25}, - imageURL: pathToOverlays + "ddao-slider-handle.png", - color: {red: 255, green: 255, blue: 255}, - alpha: 1 - }); -var effectStrengthSlider = Overlays.addOverlay("image", { - bounds: {x: minSliderX + (effectStrength * sliderRangeX), y: controlPosY+206, - width: 25, height: 25}, - imageURL: pathToOverlays + "ddao-slider-handle.png", - color: {red: 255, green: 255, blue: 255}, - alpha: 1 - }); - - -// main loop - using averaging filters to add limb element follow-through -var upperArmPDampingFilter = []; -upperArmPDampingFilter.length = parseInt(limbWeight); // sets amount of damping for upper arm pitch -var forearmPDampingFilter = []; -forearmPDampingFilter.length = parseInt(limbWeight) + 2; // sets amount of damping for lower arm pitch - -var cumulativeTime = 0; - -Script.update.connect(function(deltaTime) { - - // used for self animating (press r to invoke) - cumulativeTime += deltaTime; - - // blend three keyframes using handle position to determine progress between keyframes - var animationProgress = handleValue; - - if(animateSelf) { - animationProgress = Math.sin(cumulativeTime * selfAnimateFrequency); - animationProgress++; - animationProgress /= 2; - } - - var keyframeOneWeight = 0; - var keyframeTwoWeight = 0; - var keyframeThreeWeight = 0; - - if(movingHandle || animateSelf) { - keyframeOneWeight = 0; - keyframeTwoWeight = animationProgress; - keyframeThreeWeight = 1 - animationProgress; - } - else if(!movingHandle) { - // idle - keyframeOneWeight = 1; - keyframeTwoWeight = 0; - keyframeThreeWeight = 0; - } - - var shoulderPitch = - keyframeOneWeight * keyFrameOne.joints[8].pitchOffset + - keyframeTwoWeight * keyFrameTwo.joints[8].pitchOffset + - keyframeThreeWeight * keyFrameThree.joints[8].pitchOffset; - - var upperArmPitch = - keyframeOneWeight * keyFrameOne.joints[9].pitchOffset + - keyframeTwoWeight * keyFrameTwo.joints[9].pitchOffset + - keyframeThreeWeight * keyFrameThree.joints[9].pitchOffset; - - // get the change in upper arm pitch and use to add weight effect to forearm (always) and hand (only for overShoot) - var deltaUpperArmPitch = effectStrength * - (upperArmPDampingFilter[upperArmPDampingFilter.length - 1] - - upperArmPDampingFilter[0]); - - var forearmPitch = - keyframeOneWeight * keyFrameOne.joints[10].pitchOffset + - keyframeTwoWeight * keyFrameTwo.joints[10].pitchOffset + - keyframeThreeWeight * keyFrameThree.joints[10].pitchOffset - - (deltaUpperArmPitch/(jointEffectMax - forearmEffect)); - - // there are two methods for calculating the hand follow through - var handPitch = 0; - if(overShoot) { - - // get the change in forearm pitch and use to add weight effect to hand - var deltaForearmPitch = effectStrength * - (forearmPDampingFilter[forearmPDampingFilter.length - 1] - - forearmPDampingFilter[0]); - handPitch = - keyframeOneWeight * keyFrameOne.joints[11].pitchOffset + - keyframeTwoWeight * keyFrameTwo.joints[11].pitchOffset + - keyframeThreeWeight * keyFrameThree.joints[11].pitchOffset + - (deltaForearmPitch /(jointEffectMax - handEffect)); // hand driven by forearm - - } else { - - handPitch = - keyframeOneWeight * keyFrameOne.joints[11].pitchOffset + - keyframeTwoWeight * keyFrameTwo.joints[11].pitchOffset + - keyframeThreeWeight * keyFrameThree.joints[11].pitchOffset - - (deltaUpperArmPitch /(jointEffectMax - handEffect)); // hand driven by upper arm - } - - var shoulderYaw = - keyframeOneWeight * keyFrameOne.joints[8].yawOffset + - keyframeTwoWeight * keyFrameTwo.joints[8].yawOffset + - keyframeThreeWeight * keyFrameThree.joints[8].yawOffset; - - var upperArmYaw = - keyframeOneWeight * keyFrameOne.joints[9].yawOffset + - keyframeTwoWeight * keyFrameTwo.joints[9].yawOffset + - keyframeThreeWeight * keyFrameThree.joints[9].yawOffset; - - var lowerArmYaw = - keyframeOneWeight * keyFrameOne.joints[10].yawOffset + - keyframeTwoWeight * keyFrameTwo.joints[10].yawOffset + - keyframeThreeWeight * keyFrameThree.joints[10].yawOffset; - - var handYaw = - keyframeOneWeight * keyFrameOne.joints[11].yawOffset + - keyframeTwoWeight * keyFrameTwo.joints[11].yawOffset + - keyframeThreeWeight * keyFrameThree.joints[11].yawOffset; - - var shoulderRoll = - keyframeOneWeight * keyFrameOne.joints[8].rollOffset + - keyframeTwoWeight * keyFrameTwo.joints[8].rollOffset + - keyframeThreeWeight * keyFrameThree.joints[8].rollOffset; - - var upperArmRoll = - keyframeOneWeight * keyFrameOne.joints[9].rollOffset + - keyframeTwoWeight * keyFrameTwo.joints[9].rollOffset + - keyframeThreeWeight * keyFrameThree.joints[9].rollOffset; - - var lowerArmRoll = - keyframeOneWeight * keyFrameOne.joints[10].rollOffset + - keyframeTwoWeight * keyFrameTwo.joints[10].rollOffset + - keyframeThreeWeight * keyFrameThree.joints[10].rollOffset; - - var handRoll = - keyframeOneWeight * keyFrameOne.joints[11].rollOffset + - keyframeTwoWeight * keyFrameTwo.joints[11].rollOffset + - keyframeThreeWeight * keyFrameThree.joints[11].rollOffset; - - // filter upper arm pitch - upperArmPDampingFilter.push(upperArmPitch); - upperArmPDampingFilter.shift(); - var upperArmPitchFiltered = 0; - for(ea in upperArmPDampingFilter) upperArmPitchFiltered += upperArmPDampingFilter[ea]; - upperArmPitchFiltered /= upperArmPDampingFilter.length; - upperArmPitch = (effectStrength * upperArmPitchFiltered) + ((1 - effectStrength) * upperArmPitch); - - // filter forearm pitch only if using for hand follow-though - if(overShoot) { - - forearmPDampingFilter.push(forearmPitch); - forearmPDampingFilter.shift(); - var forearmPitchFiltered = 0; - for(ea in forearmPDampingFilter) forearmPitchFiltered += forearmPDampingFilter[ea]; - forearmPitchFiltered /= forearmPDampingFilter.length; - forearmPitch = (effectStrength*forearmPitchFiltered) + ((1-effectStrength) * forearmPitch); - } - - // apply the new rotation data to the joints - MyAvatar.setJointData("RightShoulder", Quat.fromPitchYawRollDegrees(shoulderPitch, shoulderYaw, shoulderRoll)); - MyAvatar.setJointData("RightArm", Quat.fromPitchYawRollDegrees(upperArmPitch, -upperArmYaw, upperArmRoll)); - MyAvatar.setJointData("RightForeArm", Quat.fromPitchYawRollDegrees(forearmPitch, lowerArmYaw, lowerArmRoll)); - MyAvatar.setJointData("RightHand", Quat.fromPitchYawRollDegrees(handPitch, handYaw, handRoll)); -}); - - -// mouse handling -var movingHandEffectSlider = false; -var movingForearmEffectSlider = false; -var movingLimbWeightSlider = false; -var movingDampingSlider = false; -var movingEffectStrengthSlider = false; -var movingHandle = false; - -function mousePressEvent(event) { - - var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); - - if(clickedOverlay === applyMotionHandle) movingHandle = true; - else if(clickedOverlay === handEffectSlider) movingHandEffectSlider = true; - else if(clickedOverlay === forearmEffectSlider) movingForearmEffectSlider = true; - else if(clickedOverlay === limbWeightSlider) movingLimbWeightSlider = true; - else if(clickedOverlay === effectStrengthSlider) movingEffectStrengthSlider = true; - else if(clickedOverlay === controllerRadioSelectedBackground && - event.x > 477 && event.x < 497 && event.y > 338 && event.y < 360) { - - overShoot = false; - Overlays.editOverlay(controllerBackground, {visible: true}); - Overlays.editOverlay(controllerRadioSelectedBackground, {visible: false}); - } - else if(clickedOverlay === controllerBackground && - event.x > 477 && event.x < 497 && event.y > 338 && event.y < 360){ - - overShoot = true; - Overlays.editOverlay(controllerBackground, {visible: false}); - Overlays.editOverlay(controllerRadioSelectedBackground, {visible: true}); - } -} -function mouseMoveEvent(event) { - - if(movingHandle) { - - var thumbClickOffsetX = event.x - minHandleX; - var thumbPositionNormalised = (thumbClickOffsetX - handleRangeX) / handleRangeX; - if(thumbPositionNormalised <= -1) thumbPositionNormalised = -1; - else if(thumbPositionNormalised > 1) thumbPositionNormalised = 1; - - if(thumbPositionNormalised < 0) DIRECTION = LEFT; - else DIRECTION = RIGHT; - - handleValue = (thumbPositionNormalised + 1) / 2; - var handleX = (thumbPositionNormalised * handleRangeX) + handleRangeX - 39; - Overlays.editOverlay(applyMotionHandle, {x: handleX + minHandleX}); - return; - } - else if(movingHandEffectSlider) { - - var thumbClickOffsetX = event.x - minSliderX; - var thumbPositionNormalised = thumbClickOffsetX / sliderRangeX; - if(thumbPositionNormalised < 0) thumbPositionNormalised = 0; - if(thumbPositionNormalised > 1) thumbPositionNormalised = 1; - handEffect = (thumbPositionNormalised - 0.08) * jointEffectMax; - var sliderX = thumbPositionNormalised * sliderRangeX ; - Overlays.editOverlay(handEffectSlider, {x: sliderX + minSliderX}); - } - else if(movingForearmEffectSlider) { - - var thumbClickOffsetX = event.x - minSliderX; - var thumbPositionNormalised = thumbClickOffsetX / sliderRangeX; - if(thumbPositionNormalised < 0) thumbPositionNormalised = 0; - if(thumbPositionNormalised > 1) thumbPositionNormalised = 1; - forearmEffect = (thumbPositionNormalised - 0.1) * jointEffectMax; - var sliderX = thumbPositionNormalised * sliderRangeX ; - Overlays.editOverlay(forearmEffectSlider, {x: sliderX + minSliderX}); - } - else if(movingLimbWeightSlider) { - - var thumbClickOffsetX = event.x - minSliderX; - var thumbPositionNormalised = thumbClickOffsetX / sliderRangeX; - if(thumbPositionNormalised<0) thumbPositionNormalised = 0; - if(thumbPositionNormalised>1) thumbPositionNormalised = 1; - limbWeight = thumbPositionNormalised * weightMax; - if(limbWeight < weightMin) limbWeight = weightMin; - upperArmPDampingFilter.length = parseInt(limbWeight); - var sliderX = thumbPositionNormalised * sliderRangeX ; - Overlays.editOverlay(limbWeightSlider, {x: sliderX + minSliderX}); - } - else if(movingEffectStrengthSlider) { - - var thumbClickOffsetX = event.x - minSliderX; - var thumbPositionNormalised = thumbClickOffsetX / sliderRangeX; - if(thumbPositionNormalised < 0) thumbPositionNormalised = 0; - if(thumbPositionNormalised > 1) thumbPositionNormalised = 1; - effectStrength = thumbPositionNormalised; - var sliderX = thumbPositionNormalised * sliderRangeX ; - Overlays.editOverlay(effectStrengthSlider, {x: sliderX + minSliderX}); - return; - } -} -function mouseReleaseEvent(event) { - - if(movingHandle) { - - movingHandle = false; - handleValue = 0; - Overlays.editOverlay(applyMotionHandle, {x: minHandleX+handleRangeX - 39}); - } - else if(movingHandEffectSlider) movingHandEffectSlider = false; - else if(movingForearmEffectSlider) movingForearmEffectSlider = false; - else if(movingLimbWeightSlider) movingLimbWeightSlider = false; - else if(movingEffectStrengthSlider) movingEffectStrengthSlider = false; - else if(movingDampingSlider) movingDampingSlider = false; -} - -// set up mouse and keyboard callbacks -Controller.mouseMoveEvent.connect(mouseMoveEvent); -Controller.mousePressEvent.connect(mousePressEvent); -Controller.mouseReleaseEvent.connect(mouseReleaseEvent); -Controller.keyPressEvent.connect(keyPressEvent); - -// keyboard command -function keyPressEvent(event) { - - if (event.text == "q") { - print('hand effect = ' + handEffect + '\n'); - print('forearmEffect = ' + forearmEffect + '\n'); - print('limbWeight = ' + limbWeight + '\n'); - print('effectStrength = ' + effectStrength + '\n'); - } - else if (event.text == "r") { - animateSelf = !animateSelf; - } - else if (event.text == "[") { - selfAnimateFrequency += 0.5; - print('selfAnimateFrequency = '+selfAnimateFrequency); - } - else if (event.text == "]") { - selfAnimateFrequency -= 0.5; - print('selfAnimateFrequency = '+selfAnimateFrequency); - } -} - - -// zero out all joints -function resetJoints() { - - var avatarJointNames = MyAvatar.getJointNames(); - for (var i = 0; i < avatarJointNames.length; i++) - MyAvatar.clearJointData(avatarJointNames[i]); -} - -// Script ending -Script.scriptEnding.connect(function() { - - // delete the overlays - Overlays.deleteOverlay(controllerBackground); - Overlays.deleteOverlay(controllerRadioSelectedBackground); - Overlays.deleteOverlay(handEffectSlider); - Overlays.deleteOverlay(forearmEffectSlider); - Overlays.deleteOverlay(limbWeightSlider); - Overlays.deleteOverlay(effectStrengthSlider); - Overlays.deleteOverlay(applyMotionHandle); - - // leave the avi in zeroed out stance - resetJoints(); -}); - - -// animation data. animation keyframes produced using walk.js -MyAvatar.setJointData("LeftArm", Quat.fromPitchYawRollDegrees(80,0,0)); -var keyFrameOne = -{ - "name":"FemaleStandingOne", - "settings":{ - "baseFrequency":70, - "flyingHipsPitch":60, - "takeFlightVelocity":40, - "maxBankingAngle":40 - }, - "adjusters":{ - "legsSeparation":{ - "strength":-0.03679245283018867, - "separationAngle":50 - }, - "stride":{ - "strength":0, - "upperLegsPitch":30, - "lowerLegsPitch":15, - "upperLegsPitchOffset":0.2, - "lowerLegsPitchOffset":1.5 - } - }, - "joints":[ - { - "name":"hips", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0, - "thrust":0, - "bob":0, - "sway":0, - "thrustPhase":180, - "bobPhase":0, - "swayPhase":-90, - "thrustOffset":0, - "bobOffset":0, - "swayOffset":0 - }, - { - "name":"upperLegs", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"lowerLegs", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"feet", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"toes", - "pitch":2.0377358490566038, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":4.415094339622641, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine", - "pitch":1.660377358490566, - "yaw":0, - "roll":0, - "pitchPhase":-180, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine1", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine2", - "pitch":2.1132075471698113, - "yaw":0, - "roll":0, - "pitchPhase":-0.6792452830188722, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"shoulders", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0.6792452830188678, - "yawOffset":-5.20754716981132, - "rollOffset":-2.9433962264150937 - }, - { - "name":"upperArms", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":77.77358490566039, - "yawOffset":9.169811320754715, - "rollOffset":0 - }, - { - "name":"lowerArms", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"hands", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":1.6981132075471694, - "yawOffset":-1.0188679245283017, - "rollOffset":1.0188679245283017 - }, - { - "name":"head", - "pitch":0, - "yaw":1.7358490566037734, - "roll":1.5094339622641508, - "pitchPhase":-90.33962264150944, - "yawPhase":94.41509433962267, - "rollPhase":0, - "pitchOffset":1.6981132075471694, - "yawOffset":0, - "rollOffset":0 - } - ] -}; -var keyFrameTwo = -{ - "name":"FemaleStandingOne", - "settings":{ - "baseFrequency":70, - "flyingHipsPitch":60, - "takeFlightVelocity":40, - "maxBankingAngle":40 - }, - "adjusters":{ - "legsSeparation":{ - "strength":-0.03679245283018867, - "separationAngle":50 - }, - "stride":{ - "strength":0, - "upperLegsPitch":30, - "lowerLegsPitch":15, - "upperLegsPitchOffset":0.2, - "lowerLegsPitchOffset":1.5 - } - }, - "joints":[ - { - "name":"hips", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0, - "thrust":0, - "bob":0, - "sway":0, - "thrustPhase":180, - "bobPhase":0, - "swayPhase":-90, - "thrustOffset":0, - "bobOffset":0, - "swayOffset":0 - }, - { - "name":"upperLegs", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"lowerLegs", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"feet", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"toes", - "pitch":2.0377358490566038, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":4.415094339622641, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine", - "pitch":1.660377358490566, - "yaw":0, - "roll":0, - "pitchPhase":-180, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine1", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine2", - "pitch":2.1132075471698113, - "yaw":0, - "roll":0, - "pitchPhase":-0.6792452830188722, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"shoulders", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0.6792452830188678, - "yawOffset":-5.20754716981132, - "rollOffset":-2.9433962264150937 - }, - { - "name":"upperArms", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":49.584905660377345, - "yawOffset":9.169811320754715, - "rollOffset":0 - }, - { - "name":"lowerArms", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"hands", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":-13, - "yawOffset":-1.0188679245283017, - "rollOffset":1.0188679245283017 - }, - { - "name":"head", - "pitch":0, - "yaw":1.7358490566037734, - "roll":1.5094339622641508, - "pitchPhase":-90.33962264150944, - "yawPhase":94.41509433962267, - "rollPhase":0, - "pitchOffset":1.6981132075471694, - "yawOffset":0, - "rollOffset":0 - } - ] -}; -var keyFrameThree = -{ - "name":"FemaleStandingOne", - "settings":{ - "baseFrequency":70, - "flyingHipsPitch":60, - "takeFlightVelocity":40, - "maxBankingAngle":40 - }, - "adjusters":{ - "legsSeparation":{ - "strength":-0.03679245283018867, - "separationAngle":50 - }, - "stride":{ - "strength":0, - "upperLegsPitch":30, - "lowerLegsPitch":15, - "upperLegsPitchOffset":0.2, - "lowerLegsPitchOffset":1.5 - } - }, - "joints":[ - { - "name":"hips", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0, - "thrust":0, - "bob":0, - "sway":0, - "thrustPhase":180, - "bobPhase":0, - "swayPhase":-90, - "thrustOffset":0, - "bobOffset":0, - "swayOffset":0 - }, - { - "name":"upperLegs", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"lowerLegs", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"feet", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"toes", - "pitch":2.0377358490566038, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":4.415094339622641, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine", - "pitch":1.660377358490566, - "yaw":0, - "roll":0, - "pitchPhase":-180, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine1", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"spine2", - "pitch":2.1132075471698113, - "yaw":0, - "roll":0, - "pitchPhase":-0.6792452830188722, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"shoulders", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":-21.0566037735849, - "yawOffset":-5.20754716981132, - "rollOffset":-2.9433962264150937 - }, - { - "name":"upperArms", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":-33.28301886792452, - "yawOffset":9.169811320754715, - "rollOffset":0 - }, - { - "name":"lowerArms", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":0, - "yawOffset":0, - "rollOffset":0 - }, - { - "name":"hands", - "pitch":0, - "yaw":0, - "roll":0, - "pitchPhase":0, - "yawPhase":0, - "rollPhase":0, - "pitchOffset":-13, - "yawOffset":-1.0188679245283017, - "rollOffset":1.0188679245283017 - }, - { - "name":"head", - "pitch":0, - "yaw":1.7358490566037734, - "roll":1.5094339622641508, - "pitchPhase":-90.33962264150944, - "yawPhase":94.41509433962267, - "rollPhase":0, - "pitchOffset":1.6981132075471694, - "yawOffset":0, - "rollOffset":0 - } - ] -}; \ No newline at end of file diff --git a/examples/myBalance.js b/examples/myBalance.js deleted file mode 100644 index 43f1f40eae..0000000000 --- a/examples/myBalance.js +++ /dev/null @@ -1,121 +0,0 @@ -// -// myBalance.js -// examples -// -// Created by Stojce Slavkovski on June 5, 2014 -// Copyright 2014 High Fidelity, Inc. -// -// Show wallet ₵ balance -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -Script.include("libraries/globals.js"); - -var Controller = Controller || {}; -var Overlays = Overlays || {}; -var Script = Script || {}; -var Account = Account || {}; - -(function () { - "use strict"; - var iconUrl = HIFI_PUBLIC_BUCKET + 'images/tools/', - overlayWidth = 150, - overlayHeight = 50, - overlayTopOffset = 15, - overlayRightOffset = 140, - textRightOffset = 105, - maxIntegers = 5, - downColor = { - red: 0, - green: 0, - blue: 255 - }, - upColor = { - red: 0, - green: 255, - blue: 0 - }, - normalColor = { - red: 204, - green: 204, - blue: 204 - }, - balance = -1, - walletBox = Overlays.addOverlay("image", { - x: 0, - y: overlayTopOffset, - width: 122, - height: 32, - imageURL: iconUrl + "wallet.svg", - alpha: 1 - }), - textOverlay = Overlays.addOverlay("text", { - x: 0, - y: overlayTopOffset, - topMargin: 10, - font: { - size: 16 - }, - color: normalColor - }); - - function scriptEnding() { - Overlays.deleteOverlay(walletBox); - Overlays.deleteOverlay(textOverlay); - } - - function update(deltaTime) { - var xPos = Controller.getViewportDimensions().x; - Overlays.editOverlay(walletBox, { - x: xPos - overlayRightOffset, - visible: Account.isLoggedIn() - }); - - Overlays.editOverlay(textOverlay, { - x: xPos - textRightOffset, - visible: Account.isLoggedIn() - }); - } - - function formatedBalance() { - var integers = balance.toFixed(0).length, - decimals = Math.abs(maxIntegers - integers) + 2; - - var x = balance.toFixed(decimals).split('.'), - x1 = x[0], - x2 = x.length > 1 ? '.' + x[1] : ''; - var rgx = /(\d+)(\d{3})/; - while (rgx.test(x1)) { - x1 = x1.replace(rgx, '$1' + ',' + '$2'); - } - return x1 + x2; - } - - function updateBalance(newBalance) { - if (balance === newBalance) { - return; - } - - var change = newBalance - balance, - textColor = change < 0 ? downColor : upColor; - - balance = newBalance; - Overlays.editOverlay(textOverlay, { - text: formatedBalance(), - color: textColor - }); - - Script.setTimeout(function () { - Overlays.editOverlay(textOverlay, { - color: normalColor - }); - }, 1000); - } - - updateBalance(Account.getBalance()); - Account.balanceChanged.connect(updateBalance); - Script.scriptEnding.connect(scriptEnding); - Script.update.connect(update); -}()); \ No newline at end of file diff --git a/examples/seeingVoxelsExample.js b/examples/seeingVoxelsExample.js deleted file mode 100644 index 35e2f95dd7..0000000000 --- a/examples/seeingVoxelsExample.js +++ /dev/null @@ -1,85 +0,0 @@ -// -// seeingVoxelsExample.js -// examples -// -// Created by Brad Hefta-Gaub on 2/26/14 -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var count = 0; -var yawDirection = -1; -var yaw = 45; -var yawMax = 70; -var yawMin = 20; -var vantagePoint = {x: 5000, y: 500, z: 5000}; - -var isLocal = false; - -// set up our VoxelViewer with a position and orientation -var orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0); - -function getRandomInt(min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; -} - -function init() { - if (isLocal) { - MyAvatar.position = vantagePoint; - MyAvatar.orientation = orientation; - } else { - VoxelViewer.setPosition(vantagePoint); - VoxelViewer.setOrientation(orientation); - VoxelViewer.queryOctree(); - Agent.isAvatar = true; - } -} - -function keepLooking(deltaTime) { - //print("count =" + count); - - if (count == 0) { - init(); - } - count++; - if (count % getRandomInt(5, 15) == 0) { - yaw += yawDirection; - orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0); - if (yaw > yawMax || yaw < yawMin) { - yawDirection = yawDirection * -1; - } - - if (count % 10000 == 0) { - print("calling VoxelViewer.queryOctree()... count=" + count + " yaw=" + yaw); - } - - if (isLocal) { - MyAvatar.orientation = orientation; - } else { - VoxelViewer.setOrientation(orientation); - VoxelViewer.queryOctree(); - - if (count % 10000 == 0) { - print("VoxelViewer.getOctreeElementsCount()=" + VoxelViewer.getOctreeElementsCount()); - } - } - - } -} - -function scriptEnding() { - print("SCRIPT ENDNG!!!\n"); -} - -// register the call back so it fires before each data send -Script.update.connect(keepLooking); - -// register our scriptEnding callback -Script.scriptEnding.connect(scriptEnding); - - -// test for local... -Menu.isOptionChecked("Voxels"); -isLocal = true; // will only get here on local client diff --git a/examples/testingVoxelViewerRestart.js b/examples/testingVoxelViewerRestart.js deleted file mode 100644 index c4ab67e8ba..0000000000 --- a/examples/testingVoxelViewerRestart.js +++ /dev/null @@ -1,94 +0,0 @@ -// -// testingVoxelSeeingRestart.js -// hifi -// -// Created by Brad Hefta-Gaub on 2/26/14 -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var count = 0; -var yawDirection = -1; -var yaw = 45; -var yawMax = 70; -var yawMin = 20; -var vantagePoint = {x: 5000, y: 500, z: 5000}; - -var isLocal = false; - -// set up our VoxelViewer with a position and orientation -var orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0); - -function getRandomInt(min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; -} - -function init() { - if (isLocal) { - MyAvatar.position = vantagePoint; - MyAvatar.orientation = orientation; - } else { - VoxelViewer.setPosition(vantagePoint); - VoxelViewer.setOrientation(orientation); - VoxelViewer.queryOctree(); - Agent.isAvatar = true; - } -} - -function keepLooking(deltaTime) { - //print("count =" + count); - - if (count == 0) { - init(); - } - count++; - if (count % getRandomInt(5, 15) == 0) { - yaw += yawDirection; - orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0); - if (yaw > yawMax || yaw < yawMin) { - yawDirection = yawDirection * -1; - } - - //if (count % 10000 == 0) { - // print("calling VoxelViewer.queryOctree()... count=" + count + " yaw=" + yaw); - //} - - if (isLocal) { - MyAvatar.orientation = orientation; - } else { - VoxelViewer.setOrientation(orientation); - VoxelViewer.queryOctree(); - - //if (count % 10000 == 0) { - // print("VoxelViewer.getOctreeElementsCount()=" + VoxelViewer.getOctreeElementsCount()); - //} - } - } - - // approximately every second, consider stopping - if (count % 60 == 0) { - print("considering stop.... elementCount:" + VoxelViewer.getOctreeElementsCount()); - var stopProbability = 0.05; // 5% chance of stopping - if (Math.random() < stopProbability) { - print("stopping.... elementCount:" + VoxelViewer.getOctreeElementsCount()); - Script.stop(); - } - } -} - -function scriptEnding() { - print("SCRIPT ENDNG!!!\n"); -} - -// register the call back so it fires before each data send -Script.update.connect(keepLooking); - -// register our scriptEnding callback -Script.scriptEnding.connect(scriptEnding); - - -// test for local... -Menu.isOptionChecked("Voxels"); -isLocal = true; // will only get here on local client