diff --git a/examples/example/botProceduralWayPoints.js b/examples/acScripts/botProceduralWayPoints.js similarity index 100% rename from examples/example/botProceduralWayPoints.js rename to examples/acScripts/botProceduralWayPoints.js diff --git a/examples/example/bot_procedural.js b/examples/acScripts/bot_procedural.js similarity index 99% rename from examples/example/bot_procedural.js rename to examples/acScripts/bot_procedural.js index 5ab867e150..8b96ed36c2 100644 --- a/examples/example/bot_procedural.js +++ b/examples/acScripts/bot_procedural.js @@ -12,7 +12,7 @@ //For procedural walk animation Script.include("../libraries/globals.js"); -Script.include(HIFI_PUBLIC_BUCKET + "scripts/proceduralAnimationAPI.js"); +Script.include("proceduralAnimationAPI.js"); var procAnimAPI = new ProcAnimAPI(); diff --git a/examples/example/bot_randomExpression.js b/examples/acScripts/bot_randomExpression.js similarity index 100% rename from examples/example/bot_randomExpression.js rename to examples/acScripts/bot_randomExpression.js diff --git a/examples/proceduralAnimationAPI.js b/examples/acScripts/proceduralAnimationAPI.js similarity index 100% rename from examples/proceduralAnimationAPI.js rename to examples/acScripts/proceduralAnimationAPI.js diff --git a/examples/avatarCollision.js b/examples/avatarCollision.js deleted file mode 100644 index ce13daa50d..0000000000 --- a/examples/avatarCollision.js +++ /dev/null @@ -1,72 +0,0 @@ -// -// avatarCollision.js -// examples -// -// Created by Andrew Meadows on 2014-04-09 -// Copyright 2014 High Fidelity, Inc. -// -// Play a sound on collisions with your avatar -// -// 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 SOUND_TRIGGER_CLEAR = 1000; // milliseconds -var SOUND_TRIGGER_DELAY = 200; // milliseconds -var soundExpiry = 0; -var DateObj = new Date(); - -var audioOptions = { - volume: 0.5, - position: { x: 0, y: 0, z: 0 } -} - -var hitSounds = new Array(); -hitSounds[0] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit1.raw"); -hitSounds[1] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit2.raw"); -hitSounds[2] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit3.raw"); -hitSounds[3] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit4.raw"); -hitSounds[4] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit5.raw"); -hitSounds[5] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit6.raw"); -hitSounds[6] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit7.raw"); -hitSounds[7] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit8.raw"); -hitSounds[8] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit9.raw"); -hitSounds[9] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit10.raw"); -hitSounds[10] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit11.raw"); -hitSounds[11] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit12.raw"); -hitSounds[12] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit13.raw"); -hitSounds[13] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit14.raw"); -hitSounds[14] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit15.raw"); -hitSounds[15] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit16.raw"); -hitSounds[16] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit17.raw"); -hitSounds[17] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit18.raw"); -hitSounds[18] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit19.raw"); -hitSounds[19] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit20.raw"); -hitSounds[20] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit21.raw"); -hitSounds[21] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit22.raw"); - -function playHitSound(mySessionID, theirSessionID, collision) { - var now = new Date(); - var msec = now.getTime(); - if (msec > soundExpiry) { - // this is a new contact --> play a new sound - var soundIndex = Math.floor((Math.random() * hitSounds.length) % hitSounds.length); - audioOptions.position = collision.contactPoint; - Audio.playSound(hitSounds[soundIndex], audioOptions); - - // bump the expiry - soundExpiry = msec + SOUND_TRIGGER_CLEAR; - - // log the collision info - Uuid.print("my sessionID = ", mySessionID); - Uuid.print(" their sessionID = ", theirSessionID); - Vec3.print(" penetration = ", collision.penetration); - Vec3.print(" contactPoint = ", collision.contactPoint); - } else { - // this is a recurring contact --> continue to delay sound trigger - soundExpiry = msec + SOUND_TRIGGER_DELAY; - } -} -MyAvatar.collisionWithAvatar.connect(playHitSound); diff --git a/examples/laserPointer.js b/examples/controllers/hydra/laserPointer.js similarity index 100% rename from examples/laserPointer.js rename to examples/controllers/hydra/laserPointer.js diff --git a/examples/toyball.js b/examples/controllers/hydra/toyball.js similarity index 99% rename from examples/toyball.js rename to examples/controllers/hydra/toyball.js index 2cda1fa82a..4dc65703b7 100644 --- a/examples/toyball.js +++ b/examples/controllers/hydra/toyball.js @@ -15,7 +15,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("libraries/globals.js"); +Script.include("../../libraries/globals.js"); // maybe we should make these constants... var LEFT_PALM = 0; diff --git a/examples/controllers/leap/laserPointer.js b/examples/controllers/leap/laserPointer.js new file mode 100644 index 0000000000..156e9ba298 --- /dev/null +++ b/examples/controllers/leap/laserPointer.js @@ -0,0 +1,93 @@ +// +// laserPointer.js +// examples +// +// Created by Clément Brisset on 7/18/14. +// Copyright 2014 High Fidelity, Inc. +// +// If using Hydra controllers, pulling the triggers makes laser pointers emanate from the respective hands. +// If using a Leap Motion or similar to control your avatar's hands and fingers, pointing with your index fingers makes +// laser pointers emanate from the respective index fingers. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var laserPointer = (function () { + + var NUM_FINGERs = 4, // Excluding thumb + fingers = [ + [ "LeftHandIndex", "LeftHandMiddle", "LeftHandRing", "LeftHandPinky" ], + [ "RightHandIndex", "RightHandMiddle", "RightHandRing", "RightHandPinky" ] + ]; + + function isHandPointing(hand) { + var MINIMUM_TRIGGER_PULL = 0.9; + return Controller.getTriggerValue(hand) > MINIMUM_TRIGGER_PULL; + } + + function isFingerPointing(hand) { + // Index finger is pointing if final two bones of middle, ring, and pinky fingers are > 90 degrees w.r.t. index finger + + var pointing, + indexDirection, + otherDirection, + f; + + pointing = true; + + indexDirection = Vec3.subtract( + MyAvatar.getJointPosition(fingers[hand][0] + "4"), + MyAvatar.getJointPosition(fingers[hand][0] + "2") + ); + + for (f = 1; f < NUM_FINGERs; f += 1) { + otherDirection = Vec3.subtract( + MyAvatar.getJointPosition(fingers[hand][f] + "4"), + MyAvatar.getJointPosition(fingers[hand][f] + "2") + ); + pointing = pointing && Vec3.dot(indexDirection, otherDirection) < 0; + } + + return pointing; + } + + function update() { + var LEFT_HAND = 0, + RIGHT_HAND = 1, + LEFT_HAND_POINTING_FLAG = 1, + RIGHT_HAND_POINTING_FLAG = 2, + FINGER_POINTING_FLAG = 4, + handState; + + handState = 0; + + if (isHandPointing(LEFT_HAND)) { + handState += LEFT_HAND_POINTING_FLAG; + } + if (isHandPointing(RIGHT_HAND)) { + handState += RIGHT_HAND_POINTING_FLAG; + } + + if (handState === 0) { + if (isFingerPointing(LEFT_HAND)) { + handState += LEFT_HAND_POINTING_FLAG; + } + if (isFingerPointing(RIGHT_HAND)) { + handState += RIGHT_HAND_POINTING_FLAG; + } + if (handState !== 0) { + handState += FINGER_POINTING_FLAG; + } + } + + MyAvatar.setHandState(handState); + } + + return { + update: update + }; + +}()); + +Script.update.connect(laserPointer.update); diff --git a/examples/example/audioBall.js b/examples/example/audio/audioBall.js similarity index 98% rename from examples/example/audioBall.js rename to examples/example/audio/audioBall.js index c4b245fbf1..91ef7c0759 100644 --- a/examples/example/audioBall.js +++ b/examples/example/audio/audioBall.js @@ -13,7 +13,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("../libraries/globals.js"); +Script.include("../../libraries/globals.js"); var sound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Animals/mexicanWhipoorwill.raw"); var CHANCE_OF_PLAYING_SOUND = 0.01; diff --git a/examples/example/audioDeviceExample.js b/examples/example/audio/audioDeviceExample.js similarity index 100% rename from examples/example/audioDeviceExample.js rename to examples/example/audio/audioDeviceExample.js diff --git a/examples/example/audioMuteExample.js b/examples/example/audio/audioMuteExample.js similarity index 100% rename from examples/example/audioMuteExample.js rename to examples/example/audio/audioMuteExample.js diff --git a/examples/example/audioReverbOn.js b/examples/example/audio/audioReverbOn.js similarity index 100% rename from examples/example/audioReverbOn.js rename to examples/example/audio/audioReverbOn.js diff --git a/examples/example/birdSongs.js b/examples/example/audio/birdSongs.js similarity index 100% rename from examples/example/birdSongs.js rename to examples/example/audio/birdSongs.js diff --git a/examples/example/radio.js b/examples/example/audio/radio.js similarity index 100% rename from examples/example/radio.js rename to examples/example/audio/radio.js diff --git a/examples/speechControl.js b/examples/example/audio/speechControl.js similarity index 100% rename from examples/speechControl.js rename to examples/example/audio/speechControl.js diff --git a/examples/example/cameraExample.js b/examples/example/avatarcontrol/cameraExample.js similarity index 100% rename from examples/example/cameraExample.js rename to examples/example/avatarcontrol/cameraExample.js diff --git a/examples/example/controllerExample.js b/examples/example/avatarcontrol/controllerExample.js similarity index 100% rename from examples/example/controllerExample.js rename to examples/example/avatarcontrol/controllerExample.js diff --git a/examples/example/guidedTour.js b/examples/example/avatarcontrol/guidedTour.js similarity index 100% rename from examples/example/guidedTour.js rename to examples/example/avatarcontrol/guidedTour.js diff --git a/examples/example/hideAvatarExample.js b/examples/example/avatarcontrol/hideAvatarExample.js similarity index 96% rename from examples/example/hideAvatarExample.js rename to examples/example/avatarcontrol/hideAvatarExample.js index 66d85becf1..856a8b3c69 100644 --- a/examples/example/hideAvatarExample.js +++ b/examples/example/avatarcontrol/hideAvatarExample.js @@ -12,7 +12,7 @@ // function keyReleaseEvent(event) { - if (event.text == "F2") { + if (event.text == "r") { MyAvatar.shouldRenderLocally = !MyAvatar.shouldRenderLocally; } } diff --git a/examples/example/lookAtExample.js b/examples/example/avatarcontrol/lookAtExample.js similarity index 89% rename from examples/example/lookAtExample.js rename to examples/example/avatarcontrol/lookAtExample.js index 7e3010eb8a..3beb22e7ec 100644 --- a/examples/example/lookAtExample.js +++ b/examples/example/avatarcontrol/lookAtExample.js @@ -8,8 +8,8 @@ // This is an example script that demonstrates use of the Camera class's lookAt(), keepLookingAt(), and stopLookingAt() // features. // -// To use the script, click on a voxel, and the camera will switch into independent mode and fix it's lookAt on the point -// on the face of the voxel that you clicked. Click again and it will stop looking at that point. While in this fixed mode +// To use the script, click on a entity, and the camera will switch into independent mode and fix it's lookAt on the point +// on the face of the entity that you clicked. Click again and it will stop looking at that point. While in this fixed mode // you can use the arrow keys to change the position of the camera. // // Distributed under the Apache License, Version 2.0. @@ -22,7 +22,6 @@ var oldMode = Camera.mode; function cancelLookAt() { if (lookingAtSomething) { lookingAtSomething = false; - Camera.stopLooking(); Camera.mode = oldMode; releaseMovementKeys(); } @@ -73,9 +72,6 @@ function mousePressEvent(event) { // switch to independent mode Camera.mode = "independent"; - // tell the camera to fix it's look at on the point we clicked - Camera.keepLookingAt(intersection.intersection); - // keep track of the fact that we're in this looking at mode lookingAtSomething = true; diff --git a/examples/example/multipleCursorsExample.js b/examples/example/avatarcontrol/multipleCursorsExample.js similarity index 100% rename from examples/example/multipleCursorsExample.js rename to examples/example/avatarcontrol/multipleCursorsExample.js diff --git a/examples/example/multitouchExample.js b/examples/example/avatarcontrol/multitouchExample.js similarity index 100% rename from examples/example/multitouchExample.js rename to examples/example/avatarcontrol/multitouchExample.js diff --git a/examples/example/bot.js b/examples/example/bot.js deleted file mode 100644 index fae6647ff3..0000000000 --- a/examples/example/bot.js +++ /dev/null @@ -1,233 +0,0 @@ -// -// bot.js -// examples -// -// Created by Stephen Birarda on 2/20/14. -// Modified by Philip on 3/3/14 -// Copyright 2014 High Fidelity, Inc. -// -// This is an example script that demonstrates an NPC avatar. -// -// 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"); - -function getRandomFloat(min, max) { - return Math.random() * (max - min) + min; -} - -function getRandomInt (min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; -} - -function printVector(string, vector) { - print(string + " " + vector.x + ", " + vector.y + ", " + vector.z); -} - -var CHANCE_OF_MOVING = 0.005; -var CHANCE_OF_SOUND = 0.005; -var CHANCE_OF_HEAD_TURNING = 0.05; -var CHANCE_OF_BIG_MOVE = 0.1; -var CHANCE_OF_WAVING = 0.009; - -var shouldReceiveVoxels = true; -var VOXEL_FPS = 60.0; -var lastVoxelQueryTime = 0.0; - -var isMoving = false; -var isTurningHead = false; -var isPlayingAudio = false; -var isWaving = false; -var waveFrequency = 0.0; -var waveAmplitude = 0.0; - -var X_MIN = 5.0; -var X_MAX = 15.0; -var Z_MIN = 5.0; -var Z_MAX = 15.0; -var Y_PELVIS = 1.0; -var SPINE_JOINT_NUMBER = 13; -var SHOULDER_JOINT_NUMBER = 17; -var ELBOW_JOINT_NUMBER = 18; -var JOINT_R_HIP = 1; -var JOINT_R_KNEE = 2; - -var MOVE_RANGE_SMALL = 0.5; -var MOVE_RANGE_BIG = Math.max(X_MAX - X_MIN, Z_MAX - Z_MIN) / 2.0; -var TURN_RANGE = 70.0; -var STOP_TOLERANCE = 0.05; -var MOVE_RATE = 0.05; -var TURN_RATE = 0.15; -var PITCH_RATE = 0.20; -var PITCH_RANGE = 30.0; - -var firstPosition = { x: getRandomFloat(X_MIN, X_MAX), y: Y_PELVIS, z: getRandomFloat(Z_MIN, Z_MAX) }; -var targetPosition = { x: 0, y: 0, z: 0 }; -var targetDirection = { x: 0, y: 0, z: 0, w: 0 }; -var currentDirection = { x: 0, y: 0, z: 0, w: 0 }; -var targetHeadPitch = 0.0; - -var walkFrequency = 5.0; -var walkAmplitude = 45.0; - -var cumulativeTime = 0.0; - -var sounds = []; -loadSounds(); - -function clamp(val, min, max){ - return Math.max(min, Math.min(max, val)) -} - -// Play a random sound from a list of conversational audio clips -var AVERAGE_AUDIO_LENGTH = 8000; -function playRandomSound() { - if (!Agent.isPlayingAvatarSound) { - var whichSound = Math.floor((Math.random() * sounds.length) % sounds.length); - Agent.playAvatarSound(sounds[whichSound]); - } -} - -// pick an integer between 1 and 20 for the face model for this bot -botNumber = getRandomInt(1, 100); - -if (botNumber <= 20) { - newFaceFilePrefix = "bot" + botNumber; - newBodyFilePrefix = "defaultAvatar_body" -} else { - if (botNumber <= 40) { - newFaceFilePrefix = "superhero"; - } else if (botNumber <= 60) { - newFaceFilePrefix = "amber"; - } else if (botNumber <= 80) { - newFaceFilePrefix = "ron"; - } else { - newFaceFilePrefix = "angie"; - } - - newBodyFilePrefix = "bot" + botNumber; -} - -// set the face model fst using the bot number -// there is no need to change the body model - we're using the default -Avatar.faceModelURL = HIFI_PUBLIC_BUCKET + "meshes/" + newFaceFilePrefix + ".fst"; -Avatar.skeletonModelURL = HIFI_PUBLIC_BUCKET + "meshes/" + newBodyFilePrefix + ".fst"; -Avatar.billboardURL = HIFI_PUBLIC_BUCKET + "meshes/billboards/bot" + botNumber + ".png"; - -Agent.isAvatar = true; -Agent.isListeningToAudioStream = true; - -// change the avatar's position to the random one -Avatar.position = firstPosition; -printVector("New bot, position = ", Avatar.position); - -function stopWaving() { - isWaving = false; - Avatar.clearJointData(SHOULDER_JOINT_NUMBER); - Avatar.clearJointData(ELBOW_JOINT_NUMBER); - Avatar.clearJointData(SPINE_JOINT_NUMBER); -} - -function keepWalking() { - Avatar.setJointData(JOINT_R_HIP, Quat.fromPitchYawRollDegrees(walkAmplitude * Math.sin(cumulativeTime * walkFrequency), 0.0, 0.0)); - Avatar.setJointData(JOINT_R_KNEE, Quat.fromPitchYawRollDegrees(walkAmplitude * Math.sin(cumulativeTime * walkFrequency), 0.0, 0.0)); -} - -function stopWalking() { - Avatar.clearJointData(JOINT_R_HIP); - Avatar.clearJointData(JOINT_R_KNEE); -} - -function updateBehavior(deltaTime) { - - cumulativeTime += deltaTime; - - // Hack - right now you need to set the avatar position a bit after the avatar is made to make sure it's there. - - if (CHANCE_OF_MOVING == 0.000) { - Avatar.position = firstPosition; - } - - if (shouldReceiveVoxels && ((cumulativeTime - lastVoxelQueryTime) > (1.0 / VOXEL_FPS))) { - VoxelViewer.setPosition(Avatar.position); - VoxelViewer.setOrientation(Avatar.orientation); - VoxelViewer.queryOctree(); - lastVoxelQueryTime = cumulativeTime; - /* - if (Math.random() < (1.0 / VOXEL_FPS)) { - print("Voxels in view = " + VoxelViewer.getOctreeElementsCount()); - }*/ - } - - if (!isWaving && (Math.random() < CHANCE_OF_WAVING)) { - isWaving = true; - waveFrequency = 3.0 + Math.random() * 5.0; - waveAmplitude = 5.0 + Math.random() * 60.0; - Script.setTimeout(stopWaving, 1000 + Math.random() * 2000); - Avatar.setJointData(ELBOW_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 45, 0.0)); // Initially turn the palm outward - } else if (isWaving) { - Avatar.setJointData(SHOULDER_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 60 + waveAmplitude * Math.sin((cumulativeTime - 0.25) * waveFrequency))); - Avatar.setJointData(ELBOW_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 25 + waveAmplitude/2.0 * Math.sin(cumulativeTime * 1.2 * waveFrequency))); - Avatar.setJointData(SPINE_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 60 + waveAmplitude/4.0 * Math.sin(cumulativeTime * waveFrequency))); - - } - - - if (Math.random() < CHANCE_OF_SOUND) { - playRandomSound(); - } - - if (!isTurningHead && (Math.random() < CHANCE_OF_HEAD_TURNING)) { - targetHeadPitch = getRandomFloat(-PITCH_RANGE, PITCH_RANGE); - isTurningHead = true; - } else { - Avatar.headPitch = Avatar.headPitch + (targetHeadPitch - Avatar.headPitch) * PITCH_RATE; - if (Math.abs(Avatar.headPitch - targetHeadPitch) < STOP_TOLERANCE) { - isTurningHead = false; - } - } - if (!isMoving && (Math.random() < CHANCE_OF_MOVING)) { - // Set new target location - targetDirection = Quat.multiply(Avatar.orientation, Quat.angleAxis(getRandomFloat(-TURN_RANGE, TURN_RANGE), { x:0, y:1, z:0 })); - var front = Quat.getFront(targetDirection); - if (Math.random() < CHANCE_OF_BIG_MOVE) { - targetPosition = Vec3.sum(Avatar.position, Vec3.multiply(front, getRandomFloat(0.0, MOVE_RANGE_BIG))); - } else { - targetPosition = Vec3.sum(Avatar.position, Vec3.multiply(front, getRandomFloat(0.0, MOVE_RANGE_SMALL))); - } - targetPosition.x = clamp(targetPosition.x, X_MIN, X_MAX); - targetPosition.z = clamp(targetPosition.z, Z_MIN, Z_MAX); - targetPosition.y = Y_PELVIS; - - isMoving = true; - } else if (isMoving) { - keepWalking(); - Avatar.position = Vec3.sum(Avatar.position, Vec3.multiply(Vec3.subtract(targetPosition, Avatar.position), MOVE_RATE)); - Avatar.orientation = Quat.mix(Avatar.orientation, targetDirection, TURN_RATE); - if (Vec3.length(Vec3.subtract(Avatar.position, targetPosition)) < STOP_TOLERANCE) { - isMoving = false; - stopWalking(); - } - } -} - -Script.update.connect(updateBehavior); - -function loadSounds() { - var sound_filenames = ["AB1.raw", "Anchorman2.raw", "B1.raw", "B1.raw", "Bale1.raw", "Bandcamp.raw", - "Big1.raw", "Big2.raw", "Brian1.raw", "Buster1.raw", "CES1.raw", "CES2.raw", "CES3.raw", "CES4.raw", - "Carrie1.raw", "Carrie3.raw", "Charlotte1.raw", "EN1.raw", "EN2.raw", "EN3.raw", "Eugene1.raw", "Francesco1.raw", - "Italian1.raw", "Japanese1.raw", "Leigh1.raw", "Lucille1.raw", "Lucille2.raw", "MeanGirls.raw", "Murray2.raw", - "Nigel1.raw", "PennyLane.raw", "Pitt1.raw", "Ricardo.raw", "SN.raw", "Sake1.raw", "Samantha1.raw", "Samantha2.raw", - "Spicoli1.raw", "Supernatural.raw", "Swearengen1.raw", "TheDude.raw", "Tony.raw", "Triumph1.raw", "Uma1.raw", - "Walken1.raw", "Walken2.raw", "Z1.raw", "Z2.raw" - ]; - - var SOUND_BASE_URL = HIFI_PUBLIC_BUCKET + "sounds/Cocktail+Party+Snippets/Raws/"; - - for (var i = 0; i < sound_filenames.length; i++) { - sounds.push(SoundCache.getSound(SOUND_BASE_URL + sound_filenames[i])); - } -} diff --git a/examples/example/animationStateExample.js b/examples/example/entities/ZZZ-MOVE-TO_DOCS-animationStateExample.js similarity index 100% rename from examples/example/animationStateExample.js rename to examples/example/entities/ZZZ-MOVE-TO_DOCS-animationStateExample.js diff --git a/examples/example/animatedModelExample.js b/examples/example/entities/animatedModelExample.js similarity index 91% rename from examples/example/animatedModelExample.js rename to examples/example/entities/animatedModelExample.js index 3fffdc88d2..00790fecc8 100644 --- a/examples/example/animatedModelExample.js +++ b/examples/example/entities/animatedModelExample.js @@ -12,7 +12,7 @@ // var count = 0; -var moveUntil = 6000; +var moveUntil = 1000; var stopAfter = moveUntil + 100; var pitch = 0.0; @@ -25,16 +25,19 @@ var originalProperties = { position: { x: MyAvatar.position.x, y: MyAvatar.position.y, z: MyAvatar.position.z }, - - radius : 1, + dimensions: { + x: 1.62, + y: 0.41, + z: 1.13 + }, color: { red: 0, green: 255, blue: 0 }, - modelURL: "http://www.fungibleinsight.com/faces/beta.fst", + modelURL: "http://public.highfidelity.io/cozza13/club/dragon/dragon.fbx", rotation: rotation, - animationURL: "http://www.fungibleinsight.com/faces/gangnam_style_2.fbx", + animationURL: "http://public.highfidelity.io/cozza13/club/dragon/flying.fbx", animationIsPlaying: true, }; diff --git a/examples/example/butterflies.js b/examples/example/entities/butterflies.js similarity index 100% rename from examples/example/butterflies.js rename to examples/example/entities/butterflies.js diff --git a/examples/example/collidingEntities.js b/examples/example/entities/collidingEntities.js similarity index 96% rename from examples/example/collidingEntities.js rename to examples/example/entities/collidingEntities.js index 233626df23..37c35e971d 100644 --- a/examples/example/collidingEntities.js +++ b/examples/example/entities/collidingEntities.js @@ -64,7 +64,7 @@ function draw(deltaTime) { y: 1, z: 0 }; - var entitySize = 0.1; + var entitySize = 1.1; print("number of entitys=" + numberEntitiesAdded +"\n"); @@ -99,7 +99,7 @@ function draw(deltaTime) { Script.stop(); } - print("Particles Stats: " + Entities.getLifetimeInSeconds() + " seconds," + + print("Entity Stats: " + Entities.getLifetimeInSeconds() + " seconds," + " Queued packets:" + Entities.getLifetimePacketsQueued() + "," + " PPS:" + Entities.getLifetimePPSQueued() + "," + " BPS:" + Entities.getLifetimeBPSQueued() + "," + diff --git a/examples/example/editEntityExample.js b/examples/example/entities/editEntityExample.js similarity index 91% rename from examples/example/editEntityExample.js rename to examples/example/entities/editEntityExample.js index 422e50b1eb..d6d0a83521 100644 --- a/examples/example/editEntityExample.js +++ b/examples/example/entities/editEntityExample.js @@ -5,7 +5,7 @@ // Created by Brad Hefta-Gaub on 12/31/13. // Copyright 2014 High Fidelity, Inc. // -// This is an example script that demonstrates creating and editing a particle +// This is an example script that demonstrates creating and editing a particle. Go to the origin of the domain to see the results (0,0,0). // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -29,6 +29,11 @@ var originalProperties = { gravity: { x: 0, y: 0, z: 0 }, + dimensions: { + x: 1, + y: 1, + z: 1 + }, color: { red: 0, @@ -74,7 +79,7 @@ function moveEntity(deltaTime) { y: originalProperties.position.y + (count * positionDelta.y), z: originalProperties.position.z + (count * positionDelta.z) }, - radius : 0.25, + //radius : 0.05, }; diff --git a/examples/example/editModelExample.js b/examples/example/entities/editModelExample.js similarity index 78% rename from examples/example/editModelExample.js rename to examples/example/entities/editModelExample.js index f56edfdf3b..474d9afe26 100644 --- a/examples/example/editModelExample.js +++ b/examples/example/entities/editModelExample.js @@ -11,7 +11,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("../libraries/globals.js"); +Script.include("../../libraries/globals.js"); var count = 0; var moveUntil = 2000; @@ -23,22 +23,22 @@ var roll = 180.0; var rotation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll) var originalProperties = { +type: "Model", position: { x: 2.0, y: 2.0, z: 0.5 }, - radius : 0.25, - - color: { red: 0, + dimensions: { + x: 2.16, + y: 3.34, + z: 0.54 + }, + color: { red: 0, green: 255, blue: 0 }, modelURL: HIFI_PUBLIC_BUCKET + "meshes/Feisar_Ship.FBX", - //modelURL: HIFI_PUBLIC_BUCKET + "meshes/birarda/birarda_head.fbx", - //modelURL: HIFI_PUBLIC_BUCKET + "meshes/pug.fbx", - //modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-large-purple.svo", - //modelURL: HIFI_PUBLIC_BUCKET + "meshes/minotaur/mino_full.fbx", - //modelURL: HIFI_PUBLIC_BUCKET + "meshes/Combat_tank_V01.FBX", + rotation: rotation }; @@ -67,10 +67,10 @@ function moveEntity(deltaTime) { return; // break early } - //print("count =" + count); + print("count =" + count); count++; - //print("entityID.creatorTokenID = " + entityID.creatorTokenID); + print("entityID.creatorTokenID = " + entityID.creatorTokenID); var newProperties = { position: { diff --git a/examples/example/entityModelExample.js b/examples/example/entities/entityModelExample.js similarity index 75% rename from examples/example/entityModelExample.js rename to examples/example/entities/entityModelExample.js index 067032fc6b..d09a349cb0 100644 --- a/examples/example/entityModelExample.js +++ b/examples/example/entities/entityModelExample.js @@ -11,30 +11,25 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("libraries/globals.js"); +Script.include("../libraries/globals.js"); var count = 0; -var stopAfter = 100; +var stopAfter = 1000; var modelPropertiesA = { type: "Model", position: { x: 1, y: 1, z: 1 }, velocity: { x: 0.5, y: 0, z: 0.5 }, damping: 0, - dimensions: { x: 0.5, y: 0.5, z: 0.5 }, + dimensions: { + x: 2.16, + y: 3.34, + z: 0.54 + }, modelURL: HIFI_PUBLIC_BUCKET + "meshes/Feisar_Ship.FBX", lifetime: 20 }; -var modelPropertiesB = { - type: "Model", - position: { x: 1, y: 1.5, z: 1 }, - velocity: { x: 0.5, y: 0, z: 0.5 }, - damping: 0, - dimensions: { x: 0.5, y: 0.5, z: 0.5 }, - modelURL: HIFI_PUBLIC_BUCKET + "meshes/orc.fbx", - lifetime: 20 -}; var ballProperties = { type: "Sphere", @@ -47,7 +42,6 @@ var ballProperties = { }; var modelAEntityID = Entities.addEntity(modelPropertiesA); -var modelBEntityID = Entities.addEntity(modelPropertiesB); var ballEntityID = Entities.addEntity(ballProperties); function endAfterAWhile(deltaTime) { diff --git a/examples/example/findEntitiesExample.js b/examples/example/entities/findEntitiesExample.js similarity index 100% rename from examples/example/findEntitiesExample.js rename to examples/example/entities/findEntitiesExample.js diff --git a/examples/example/flockingBirds.js b/examples/example/entities/flockingBirds.js similarity index 99% rename from examples/example/flockingBirds.js rename to examples/example/entities/flockingBirds.js index fd59b20c48..b07e7cf4bd 100644 --- a/examples/example/flockingBirds.js +++ b/examples/example/entities/flockingBirds.js @@ -5,7 +5,7 @@ // Created by Brad Hefta-Gaub on 3/4/14. // Copyright 2014 High Fidelity, Inc. // -// This is an example script that generates particles that act like flocking birds +// This is an example script that generates entities that act like flocking birds // // All birds, even flying solo... // birds don't like to fall too fast diff --git a/examples/example/lightExample.js b/examples/example/entities/lightExample.js similarity index 98% rename from examples/example/lightExample.js rename to examples/example/entities/lightExample.js index 7a90eb8714..58495a02f4 100644 --- a/examples/example/lightExample.js +++ b/examples/example/entities/lightExample.js @@ -27,7 +27,7 @@ var lightID = Entities.addEntity({ angularVelocity: { x: 0, y: 0, z: 0 }, angularDamping: 0, - isSpotlight: false, + isSpotlight: true, diffuseColor: { red: 255, green: 255, blue: 0 }, ambientColor: { red: 0, green: 0, blue: 0 }, specularColor: { red: 255, green: 255, blue: 255 }, diff --git a/examples/example/rideAlongWithAnEntityExample.js b/examples/example/entities/rideAlongWithAnEntityExample.js similarity index 100% rename from examples/example/rideAlongWithAnEntityExample.js rename to examples/example/entities/rideAlongWithAnEntityExample.js diff --git a/examples/example/spotlightExample.js b/examples/example/entities/spotlightExample.js similarity index 100% rename from examples/example/spotlightExample.js rename to examples/example/entities/spotlightExample.js diff --git a/examples/example/cleanupChessboards.js b/examples/example/games/cleanupChessboards.js similarity index 100% rename from examples/example/cleanupChessboards.js rename to examples/example/games/cleanupChessboards.js diff --git a/examples/example/clonedOverlaysExample.js b/examples/example/games/clonedOverlaysExample.js similarity index 97% rename from examples/example/clonedOverlaysExample.js rename to examples/example/games/clonedOverlaysExample.js index 7aea048175..aa475ee518 100644 --- a/examples/example/clonedOverlaysExample.js +++ b/examples/example/games/clonedOverlaysExample.js @@ -15,10 +15,10 @@ const NUM_OF_TREES = 40; const NUM_OF_SANTAS = 20; // Image source: https://openclipart.org/detail/447/christmas-tree-by-theresaknott (heavily edited by Maximillian Merlin) -const CHRISTMAS_TREE_SPRITES_URL = "http://test.thoys.nl/hifi/images/santa/christmas-tree.svg"; +const CHRISTMAS_TREE_SPRITES_URL = "https://s3.amazonaws.com/hifi-public/models/props/xmas/christmas-tree.svg"; // Image source: http://opengameart.org/content/santa-claus (CC-BY 3.0) -const SANTA_SPRITES_URL = "http://test.thoys.nl/hifi/images/santa/Santa.png"; +const SANTA_SPRITES_URL = "https://s3.amazonaws.com/hifi-public/models/props/xmas/Santa.png"; Array.prototype.contains = function(obj) { var i = this.length; diff --git a/examples/example/playChess.js b/examples/example/games/playChess.js similarity index 100% rename from examples/example/playChess.js rename to examples/example/games/playChess.js diff --git a/examples/example/spaceInvadersExample.js b/examples/example/games/spaceInvadersExample.js similarity index 97% rename from examples/example/spaceInvadersExample.js rename to examples/example/games/spaceInvadersExample.js index 6216c709c2..5ad8bbe4f6 100644 --- a/examples/example/spaceInvadersExample.js +++ b/examples/example/games/spaceInvadersExample.js @@ -11,7 +11,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("../libraries/globals.js"); +Script.include("../../libraries/globals.js"); var iteration = 0; @@ -106,22 +106,22 @@ invaderModels[0] = { modelTranslation: { x: -1.3, y: -1.3, z: -1.3 }, }; invaderModels[1] = { - modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-large-cyan.svo", + modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx", modelScale: 450, modelTranslation: { x: -1.3, y: -1.3, z: -1.3 }, }; invaderModels[2] = { - modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-medium-cyan.svo", + modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx", modelScale: 450, modelTranslation: { x: -1.3, y: -1.3, z: -1.3 }, }; invaderModels[3] = { - modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-medium-green.svo", + modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx", modelScale: 450, modelTranslation: { x: -1.3, y: -1.3, z: -1.3 }, }; invaderModels[4] = { - modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-small-green.svo", + modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx", modelScale: 450, modelTranslation: { x: -1.3, y: -1.3, z: -1.3 }, }; diff --git a/examples/example/globalCollisionsExample.js b/examples/example/globalCollisionsExample.js index 426aebd5d9..5813cb2472 100644 --- a/examples/example/globalCollisionsExample.js +++ b/examples/example/globalCollisionsExample.js @@ -14,13 +14,6 @@ print("hello..."); -function entityCollisionWithVoxel(entity, voxel, collision) { - print("entityCollisionWithVoxel().."); - print(" entity.getID()=" + entity.id); - print(" voxel color...=" + voxel.red + ", " + voxel.green + ", " + voxel.blue); - Vec3.print('penetration=', collision.penetration); - Vec3.print('contactPoint=', collision.contactPoint); -} function entityCollisionWithEntity(entityA, entityB, collision) { print("entityCollisionWithParticle().."); @@ -30,7 +23,6 @@ function entityCollisionWithEntity(entityA, entityB, collision) { Vec3.print('contactPoint=', collision.contactPoint); } -Entities.entityCollisionWithVoxel.connect(entityCollisionWithVoxel); Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity); print("here... hello..."); diff --git a/examples/example/localVoxelsExample.js b/examples/example/localVoxelsExample.js deleted file mode 100644 index d64138b214..0000000000 --- a/examples/example/localVoxelsExample.js +++ /dev/null @@ -1,63 +0,0 @@ -// -// localVoxelsExample.js -// examples -// -// 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 TREE_SCALE = 16384; -var tree = LocalVoxels("tree"); -tree.setVoxel(0, 0, 0, - 0.5 * TREE_SCALE, - 255, 0, 0); -tree.setVoxel(0.5 * TREE_SCALE, - 0.5 * TREE_SCALE, - 0.5 * TREE_SCALE, - 0.5 * TREE_SCALE, - 0, 255, 0); - -var copy = LocalVoxels("copy"); -tree.pasteFrom(0, 0, 0, TREE_SCALE, "copy"); -tree.pasteFrom(0, 0, 0, TREE_SCALE, "clipboard"); - -var overlay1 = Overlays.addOverlay("localvoxels", { - position: {x: 1, y: 1, z: 1}, - size: 1, - name: "tree" - }); -var overlay2 = Overlays.addOverlay("localvoxels", { - position: {x: 1, y: 2, z: 1}, - size: 1, - name: "tree" - }); -var overlay3 = Overlays.addOverlay("localvoxels", { - position: {x: 1, y: 3, z: 1}, - size: 1, - name: "tree" - }); -var overlay4 = Overlays.addOverlay("localvoxels", { - position: {x: 1, y: 4, z: 1}, - size: 1, - name: "copy" - }); - -var clipboard = Overlays.addOverlay("localvoxels", { - position: {x: 1, y: 5, z: 1}, - size: 1, - name: "clipboard" - }); - - - -// When our script shuts down, we should clean up all of our overlays -function scriptEnding() { - Overlays.deleteOverlay(overlay1); - Overlays.deleteOverlay(overlay2); - Overlays.deleteOverlay(overlay3); - Overlays.deleteOverlay(overlay4); - Overlays.deleteOverlay(clipboard); -} -Script.scriptEnding.connect(scriptEnding); \ No newline at end of file diff --git a/examples/example/metavoxels.js b/examples/example/metavoxels/metavoxels.js similarity index 100% rename from examples/example/metavoxels.js rename to examples/example/metavoxels/metavoxels.js diff --git a/examples/example/globalServicesExample.js b/examples/example/misc/globalServicesExample.js similarity index 100% rename from examples/example/globalServicesExample.js rename to examples/example/misc/globalServicesExample.js diff --git a/examples/example/includeExample.js b/examples/example/scripts/includeExample.js similarity index 84% rename from examples/example/includeExample.js rename to examples/example/scripts/includeExample.js index 50a1234772..c9c882156e 100644 --- a/examples/example/includeExample.js +++ b/examples/example/scripts/includeExample.js @@ -15,5 +15,5 @@ Script.include("http://public.highfidelity.io/scripts/lookWithTouch.js"); // You can also include scripts that are relative to the current script -Script.include("editVoxels.js"); -Script.include("../examples/selectAudioDevice.js"); +//Script.include("../../editEntities.js"); +//Script.include("../../examples/selectAudioDevice.js"); diff --git a/examples/loadScriptFromMessage.js b/examples/example/scripts/loadScriptFromMessage.js similarity index 100% rename from examples/loadScriptFromMessage.js rename to examples/example/scripts/loadScriptFromMessage.js diff --git a/examples/example/locationExample.js b/examples/example/scripts/locationExample.js similarity index 100% rename from examples/example/locationExample.js rename to examples/example/scripts/locationExample.js diff --git a/examples/example/rayPickExample.js b/examples/example/scripts/rayPickExample.js similarity index 100% rename from examples/example/rayPickExample.js rename to examples/example/scripts/rayPickExample.js diff --git a/examples/example/settingsExample.js b/examples/example/scripts/settingsExample.js similarity index 96% rename from examples/example/settingsExample.js rename to examples/example/scripts/settingsExample.js index bef347ff07..f8364ff91b 100644 --- a/examples/example/settingsExample.js +++ b/examples/example/scripts/settingsExample.js @@ -15,4 +15,4 @@ print("mySetting: " + Settings.getValue("mySetting")); Settings.setValue("mySetting", "spam"); print("mySetting: " + Settings.getValue("mySetting")); -Script.stop(); \ No newline at end of file +//Script.stop(); \ No newline at end of file diff --git a/examples/example/streetAreaExample.js b/examples/example/scripts/streetAreaExample.js similarity index 100% rename from examples/example/streetAreaExample.js rename to examples/example/scripts/streetAreaExample.js diff --git a/examples/timer.js b/examples/example/scripts/timer.js similarity index 100% rename from examples/timer.js rename to examples/example/scripts/timer.js diff --git a/examples/example/dialogExample.js b/examples/example/ui/dialogExample.js similarity index 100% rename from examples/example/dialogExample.js rename to examples/example/ui/dialogExample.js diff --git a/examples/example/fileBrowserExample.js b/examples/example/ui/fileBrowserExample.js similarity index 100% rename from examples/example/fileBrowserExample.js rename to examples/example/ui/fileBrowserExample.js diff --git a/examples/example/menuExample.js b/examples/example/ui/menuExample.js similarity index 100% rename from examples/example/menuExample.js rename to examples/example/ui/menuExample.js diff --git a/examples/example/overlaysExample.js b/examples/example/ui/overlaysExample.js similarity index 99% rename from examples/example/overlaysExample.js rename to examples/example/ui/overlaysExample.js index c72619a042..4e85512545 100644 --- a/examples/example/overlaysExample.js +++ b/examples/example/ui/overlaysExample.js @@ -11,7 +11,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("../libraries/globals.js"); +Script.include("../../libraries/globals.js"); // The "Swatches" example of this script will create 9 different image overlays, that use the color feature to // display different colors as color swatches. The overlays can be clicked on, to change the "selectedSwatch" variable diff --git a/examples/example/textInputOverlayExample.js b/examples/example/ui/textInputOverlayExample.js similarity index 100% rename from examples/example/textInputOverlayExample.js rename to examples/example/ui/textInputOverlayExample.js diff --git a/examples/example/windowExample.js b/examples/example/ui/windowExample.js similarity index 100% rename from examples/example/windowExample.js rename to examples/example/ui/windowExample.js diff --git a/examples/locationsMenu.js b/examples/locationsMenu.js deleted file mode 100644 index 30fa377a6f..0000000000 --- a/examples/locationsMenu.js +++ /dev/null @@ -1,304 +0,0 @@ -// -// locationsMenu.js -// examples -// -// Created by Ryan Huffman on 5/28/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 -// - -Script.include("libraries/globals.js"); - -var scriptUrl = "https://script.google.com/macros/s/AKfycbwIo4lmF-qUwX1Z-9eA_P-g2gse9oFhNcjVyyksGukyDDEFXgU/exec?action=listOwners&domain=alpha.highfidelity.io"; - -var LocationMenu = function(opts) { - var self = this; - - var pageSize = opts.pageSize || 10; - var menuWidth = opts.menuWidth || 150; - var menuHeight = opts.menuItemHeight || 24; - - var inactiveColor = { red: 51, green: 102, blue: 102 }; - var activeColor = { red: 18, green: 66, blue: 66 }; - var prevNextColor = { red: 192, green: 192, blue: 192 }; - var disabledColor = { red: 64, green: 64, blue: 64}; - var position = { x: 0, y: 0 }; - - var locationIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/location.svg"; - var toolHeight = 50; - var toolWidth = 50; - var visible = false; - var menuItemOffset = { - x: 55, - y: 0, - }; - var menuItemPadding = 5; - var margin = 7; - var fullMenuHeight = (2 * menuItemOffset.y) + (menuHeight * (pageSize + 1)); - var menuOffset = -fullMenuHeight + toolHeight; - - var windowDimensions = Controller.getViewportDimensions(); - - this.locations = []; - this.numPages = 1; - this.page = 0; - - this.menuToggleButton = Overlays.addOverlay("image", { - x: position.x, - y: position.y, - width: toolWidth, height: toolHeight, - subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, - imageURL: locationIconUrl, - alpha: 0.9 - }); - - this.background = Overlays.addOverlay("text", { - x: 0, - y: 0, - width: menuWidth + 10, - height: (menuHeight * (pageSize + 1)) + 10, - backgroundColor: { red: 0, green: 0, blue: 0}, - topMargin: 4, - leftMargin: 4, - text: "", - visible: visible, - }); - - this.menuItems = []; - for (var i = 0; i < pageSize; i++) { - var menuItem = Overlays.addOverlay("text", { - x: 0, - y: 0, - width: menuWidth, - height: menuHeight, - backgroundColor: inactiveColor, - topMargin: margin, - leftMargin: margin, - text: (i == 0) ? "Loading..." : "", - visible: visible, - }); - this.menuItems.push({ overlay: menuItem, location: null }); - } - - this.previousButton = Overlays.addOverlay("text", { - x: 0, - y: 0, - width: menuWidth / 2, - height: menuHeight, - backgroundColor: disabledColor, - topMargin: margin, - leftMargin: margin, - text: "Previous", - visible: visible, - }); - - this.nextButton = Overlays.addOverlay("text", { - x: 0, - y: 0, - width: menuWidth / 2, - height: menuHeight, - backgroundColor: disabledColor, - topMargin: margin, - leftMargin: margin, - text: "Next", - visible: visible, - }); - - this.reposition = function(force) { - var newWindowDimensions = Controller.getViewportDimensions(); - if (force || newWindowDimensions.y != windowDimensions.y) { - windowDimensions = newWindowDimensions; - - position.x = 8; - position.y = Math.floor(windowDimensions.y / 2) + 25 + 50 + 8; - - Overlays.editOverlay(self.menuToggleButton, { - x: position.x, - y: position.y, - }); - Overlays.editOverlay(self.background, { - x: position.x + menuItemOffset.x, - y: position.y + menuItemOffset.y - 2 * menuItemPadding + menuOffset, - }); - for (var i = 0; i < pageSize; i++) { - Overlays.editOverlay(self.menuItems[i].overlay, { - x: position.x + menuItemOffset.x + menuItemPadding, - y: position.y + menuItemOffset.y - menuItemPadding + (i * menuHeight) + menuOffset, - }); - } - Overlays.editOverlay(self.previousButton, { - x: position.x + menuItemOffset.x + menuItemPadding, - y: position.y + menuItemOffset.y - menuItemPadding + (pageSize * menuHeight) + menuOffset, - }); - Overlays.editOverlay(self.nextButton, { - x: position.x + menuItemOffset.x + menuItemPadding + (menuWidth / 2), - y: position.y + menuItemOffset.y - menuItemPadding + (pageSize * menuHeight) + menuOffset, - }); - } - } - - this.updateLocations = function(locations) { - this.locations = locations; - this.numPages = Math.ceil(locations.length / pageSize); - this.goToPage(0); - } - - this.setError = function() { - Overlays.editOverlay(this.menuItems[0].overlay, { text: "Error loading data" }); - } - - this.toggleMenu = function() { - visible = !visible; - for (var i = 0; i < this.menuItems.length; i++) { - Overlays.editOverlay(this.menuItems[i].overlay, { visible: visible}); - } - Overlays.editOverlay(this.previousButton, { visible: visible}); - Overlays.editOverlay(this.nextButton, { visible: visible}); - Overlays.editOverlay(this.background, { visible: visible}); - if (visible) { - Overlays.editOverlay(this.menuToggleButton, { subImage: { x: 0, y: 0, width: toolWidth, height: toolHeight } }), - } else { - Overlays.editOverlay(this.menuToggleButton, { subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight } }), - } - } - - this.goToPage = function(pageNumber) { - if (pageNumber < 0 || pageNumber >= this.numPages) { - return; - } - - this.page = pageNumber; - var start = pageNumber * pageSize; - for (var i = 0; i < pageSize; i++) { - var update = {}; - var location = null; - if (start + i < this.locations.length) { - location = this.locations[start + i]; - update.text = (start + i + 1) + ". " + location.username; - update.backgroundColor = inactiveColor; - } else { - update.text = ""; - update.backgroundColor = disabledColor; - } - Overlays.editOverlay(this.menuItems[i].overlay, update); - this.menuItems[i].location = location; - } - - this.previousEnabled = pageNumber > 0; - this.nextEnabled = pageNumber < (this.numPages - 1); - - Overlays.editOverlay(this.previousButton, { backgroundColor: this.previousEnabled ? prevNextColor : disabledColor}); - Overlays.editOverlay(this.nextButton, { backgroundColor: this.nextEnabled ? prevNextColor : disabledColor }); - } - - this.mousePressEvent = function(event) { - var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); - - if (clickedOverlay == self.menuToggleButton) { - self.toggleMenu(); - } else if (clickedOverlay == self.previousButton) { - if (self.previousEnabled) { - Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor }); - } - } else if (clickedOverlay == self.nextButton) { - if (self.nextEnabled) { - Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor }); - } - } else { - for (var i = 0; i < self.menuItems.length; i++) { - if (clickedOverlay == self.menuItems[i].overlay) { - if (self.menuItems[i].location != null) { - Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor }); - } - break; - } - } - } - } - - this.mouseReleaseEvent = function(event) { - var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); - - if (clickedOverlay == self.previousButton) { - if (self.previousEnabled) { - Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor }); - self.goToPage(self.page - 1); - } - } else if (clickedOverlay == self.nextButton) { - if (self.nextEnabled) { - Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor }); - self.goToPage(self.page + 1); - } - } else { - for (var i = 0; i < self.menuItems.length; i++) { - if (clickedOverlay == self.menuItems[i].overlay) { - if (self.menuItems[i].location != null) { - Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor }); - var location = self.menuItems[i].location; - Window.location = "hifi://" + location.domain + "/" - + location.x + "," + location.y + "," + location.z; - } - break; - } - } - } - } - - this.cleanup = function() { - for (var i = 0; i < self.menuItems.length; i++) { - Overlays.deleteOverlay(self.menuItems[i].overlay); - } - Overlays.deleteOverlay(self.menuToggleButton); - Overlays.deleteOverlay(self.previousButton); - Overlays.deleteOverlay(self.nextButton); - Overlays.deleteOverlay(self.background); - } - - Controller.mousePressEvent.connect(this.mousePressEvent); - Controller.mouseReleaseEvent.connect(this.mouseReleaseEvent); - Script.update.connect(this.reposition); - Script.scriptEnding.connect(this.cleanup); - - this.reposition(true); -}; - -var locationMenu = new LocationMenu({ pageSize: 8 }); - -print("Loading strip data from " + scriptUrl); - -var req = new XMLHttpRequest(); -req.responseType = 'json'; - -req.onreadystatechange = function() { - if (req.readyState == req.DONE) { - if (req.status == 200 && req.response != null) { - for (var domain in req.response) { - var locations = req.response[domain]; - var users = []; - for (var i = 0; i < locations.length; i++) { - var loc = locations[i]; - var x1 = loc[1], - x2 = loc[2], - y1 = loc[3], - y2 = loc[4]; - users.push({ - domain: domain, - username: loc[0], - x: x1, - y: 300, - z: y1, - }); - } - locationMenu.updateLocations(users); - } - } else { - print("Error loading data: " + req.status + " " + req.statusText + ", " + req.errorCode + ": " + req.responseText); - locationMenu.setError(); - } - } -} - -req.open("GET", scriptUrl); -req.send(); diff --git a/examples/sit.js b/examples/sit.js index c3abe9a908..71d909d1e7 100644 --- a/examples/sit.js +++ b/examples/sit.js @@ -10,7 +10,7 @@ // -var buttonImageUrl = "https://worklist-prod.s3.amazonaws.com/attachment/0aca88e1-9bd8-5c1d.svg"; +var buttonImageUrl = "https://public.highfidelity.io/images/tools/sit.svg"; var windowDimensions = Controller.getViewportDimensions(); diff --git a/examples/testModelOverlaySubMeshes.js b/examples/testModelOverlaySubMeshes.js deleted file mode 100644 index 20ec10ef7c..0000000000 --- a/examples/testModelOverlaySubMeshes.js +++ /dev/null @@ -1,88 +0,0 @@ -var position = Vec3.sum(MyAvatar.position, { x: 0, y: -1, z: 0}); - -var scalingFactor = 0.01; - -var sphereNaturalExtentsMin = { x: -1230, y: -1223, z: -1210 }; -var sphereNaturalExtentsMax = { x: 1230, y: 1229, z: 1223 }; -var panelsNaturalExtentsMin = { x: -1181, y: -326, z: 56 }; -var panelsNaturalExtentsMax = { x: 1181, y: 576, z: 1183 }; - -var sphereNaturalDimensions = Vec3.subtract(sphereNaturalExtentsMax, sphereNaturalExtentsMin); -var panelsNaturalDimensions = Vec3.subtract(panelsNaturalExtentsMax, panelsNaturalExtentsMin); -Vec3.print("sphereNaturalDimensions:", sphereNaturalDimensions); -Vec3.print("panelsNaturalDimensions:", panelsNaturalDimensions); - -var sphereNaturalCenter = Vec3.sum(sphereNaturalExtentsMin, Vec3.multiply(sphereNaturalDimensions, 0.5)); -var panelsNaturalCenter = Vec3.sum(panelsNaturalExtentsMin, Vec3.multiply(panelsNaturalDimensions, 0.5)); -Vec3.print("sphereNaturalCenter:", sphereNaturalCenter); -Vec3.print("panelsNaturalCenter:", panelsNaturalCenter); - -var sphereDimensions = Vec3.multiply(sphereNaturalDimensions, scalingFactor); -var panelsDimensions = Vec3.multiply(panelsNaturalDimensions, scalingFactor); -Vec3.print("sphereDimensions:", sphereDimensions); -Vec3.print("panelsDimensions:", panelsDimensions); - -var sphereCenter = Vec3.multiply(sphereNaturalCenter, scalingFactor); -var panelsCenter = Vec3.multiply(panelsNaturalCenter, scalingFactor); -Vec3.print("sphereCenter:", sphereCenter); -Vec3.print("panelsCenter:", panelsCenter); - -var centerShift = Vec3.subtract(panelsCenter, sphereCenter); -Vec3.print("centerShift:", centerShift); - -var spherePosition = position; -Vec3.print("spherePosition:", spherePosition); -var panelsPosition = Vec3.sum(spherePosition, centerShift); -Vec3.print("panelsPosition:", panelsPosition); - - -var screensOverlay = Overlays.addOverlay("model", { - position: panelsPosition, - dimensions: panelsDimensions, - url: "https://s3.amazonaws.com/hifi-public/models/sets/Lobby/LobbyConcepts/Lobby5_IsolatedPanelsFreezeTransforms.fbx" - }); - - -var structureOverlay = Overlays.addOverlay("model", { - position: spherePosition, - dimensions: sphereDimensions, - url: "https://s3.amazonaws.com/hifi-public/models/sets/Lobby/LobbyConcepts/Lobby5_OrbShellOnly.fbx", - ignoreRayIntersection: true, // we don't want to ray pick against any of this - }); - -var statusText = Overlays.addOverlay("text", { - x: 200, - y: 100, - width: 200, - height: 20, - backgroundColor: { red: 0, green: 0, blue: 0}, - alpha: 1.0, - backgroundAlpha: 1.0, - color: { red: 255, green: 255, blue: 255}, - topMargin: 4, - leftMargin: 4, - text: "", - }); - - -Controller.mouseMoveEvent.connect(function(event){ - var pickRay = Camera.computePickRay(event.x, event.y); - var result = Overlays.findRayIntersection(pickRay); - - if (result.intersects) { - if (result.overlayID == screensOverlay) { - Overlays.editOverlay(statusText, { text: "You are pointing at: " + result.extraInfo }); - } else { - Overlays.editOverlay(statusText, { text: "You are not pointing at a panel..." }); - } - } else { - Overlays.editOverlay(statusText, { text: "You are not pointing at a panel..." }); - } -}); - - -Script.scriptEnding.connect(function(){ - Overlays.deleteOverlay(screensOverlay); - Overlays.deleteOverlay(structureOverlay); - Overlays.deleteOverlay(statusText); -}); diff --git a/examples/twoFallingEntities.js b/examples/twoFallingEntities.js deleted file mode 100644 index 2d71344e2c..0000000000 --- a/examples/twoFallingEntities.js +++ /dev/null @@ -1,25 +0,0 @@ -// -// twoFallingEntities.js -// -// Creates a red 0.2 meter diameter ball right in front of your avatar that lives for 60 seconds -// - -var diameter = 0.2; -var position = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation)); -var properties = { - type: "Sphere", - position: position, - velocity: { x: 0, y: 0, z: 0}, - gravity: { x: 0, y: -0.05, z: 0}, - dimensions: { x: diameter, y: diameter, z: diameter }; - damping: 0.00001, - color: { red: 200, green: 0, blue: 0 }, - lifetime: 60 - }; - -var newEntity = Entities.addEntity(properties); -position.x -= 0.5 * diameter; -properties.position = position; -var newEntityTwo = Entities.addEntity(properties); - -Script.stop(); // no need to run anymore diff --git a/examples/orbitingSound.js b/examples/utilities/diagnostics/orbitingSound.js similarity index 100% rename from examples/orbitingSound.js rename to examples/utilities/diagnostics/orbitingSound.js diff --git a/examples/utilities/diagnostics/playSoundOrbit.js b/examples/utilities/diagnostics/playSoundOrbit.js deleted file mode 100644 index d9885b7f34..0000000000 --- a/examples/utilities/diagnostics/playSoundOrbit.js +++ /dev/null @@ -1,43 +0,0 @@ -// -// playSoundPath.js -// examples -// -// Created by Craig Hansen-Sturm on 05/27/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 -// - -Script.include("../../libraries/globals.js"); - -var soundClip = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Guitars/Guitar+-+Nylon+A.raw"); - -var currentTime = 1.570079; // pi/2 -var deltaTime = 0.05; -var distance = 1; -var debug = 0; - -function playSound() { - currentTime += deltaTime; - - var s = distance * Math.sin(currentTime); - var c = distance * Math.cos(currentTime); - - var soundOffset = { x:s, y:0, z:c }; - - if (debug) { - print("t=" + currentTime + "offset=" + soundOffset.x + "," + soundOffset.y + "," + soundOffset.z); - } - - var avatarPosition = MyAvatar.position; - var soundPosition = Vec3.sum(avatarPosition,soundOffset); - - Audio.playSound(soundClip, { - position: soundPosition - }); -} - -Script.setInterval(playSound, 850); - - diff --git a/examples/playSoundWave.js b/examples/utilities/diagnostics/playSoundWave.js similarity index 100% rename from examples/playSoundWave.js rename to examples/utilities/diagnostics/playSoundWave.js diff --git a/examples/typedArraysUnitTest.js b/examples/utilities/diagnostics/typedArraysUnitTest.js similarity index 99% rename from examples/typedArraysUnitTest.js rename to examples/utilities/diagnostics/typedArraysUnitTest.js index e86a07289d..0688667cc4 100644 --- a/examples/typedArraysUnitTest.js +++ b/examples/utilities/diagnostics/typedArraysUnitTest.js @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("Test.js"); +Script.include("../../libraries/unitTest.js"); // e.g. extractbits([0xff, 0x80, 0x00, 0x00], 23, 30); inclusive function extractbits(bytes, lo, hi) { diff --git a/examples/Recorder.js b/examples/utilities/record/recorder.js similarity index 100% rename from examples/Recorder.js rename to examples/utilities/record/recorder.js diff --git a/examples/crazylegs.js b/examples/utilities/tools/crazylegs.js similarity index 93% rename from examples/crazylegs.js rename to examples/utilities/tools/crazylegs.js index 7a6fb68520..38ecaba7c0 100644 --- a/examples/crazylegs.js +++ b/examples/utilities/tools/crazylegs.js @@ -4,6 +4,8 @@ // // Created by Andrzej Kapolka on 3/6/14. // Copyright 2014 High Fidelity, Inc. +// +// Outputs the joint index of an avatar, this is useful for avatar procedural animations // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/examples/currentAPI.js b/examples/utilities/tools/currentAPI.js similarity index 100% rename from examples/currentAPI.js rename to examples/utilities/tools/currentAPI.js diff --git a/examples/developerMenuItems.js b/examples/utilities/tools/developerMenuItems.js similarity index 100% rename from examples/developerMenuItems.js rename to examples/utilities/tools/developerMenuItems.js