mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 07:22:43 +02:00
More Script updates
More Script updates
This commit is contained in:
parent
3ed5b0e9be
commit
816e369c08
68 changed files with 151 additions and 894 deletions
|
@ -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();
|
||||
|
|
@ -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);
|
|
@ -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;
|
93
examples/controllers/leap/laserPointer.js
Normal file
93
examples/controllers/leap/laserPointer.js
Normal file
|
@ -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);
|
|
@ -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;
|
|
@ -12,7 +12,7 @@
|
|||
//
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
if (event.text == "F2") {
|
||||
if (event.text == "r") {
|
||||
MyAvatar.shouldRenderLocally = !MyAvatar.shouldRenderLocally;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
@ -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]));
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -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() + "," +
|
|
@ -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,
|
||||
|
||||
};
|
||||
|
|
@ -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: {
|
|
@ -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) {
|
|
@ -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
|
|
@ -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 },
|
|
@ -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;
|
|
@ -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 },
|
||||
};
|
|
@ -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...");
|
||||
|
|
|
@ -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);
|
|
@ -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");
|
|
@ -15,4 +15,4 @@ print("mySetting: " + Settings.getValue("mySetting"));
|
|||
Settings.setValue("mySetting", "spam");
|
||||
print("mySetting: " + Settings.getValue("mySetting"));
|
||||
|
||||
Script.stop();
|
||||
//Script.stop();
|
|
@ -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
|
|
@ -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();
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
|
@ -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
|
|
@ -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);
|
||||
|
||||
|
|
@ -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) {
|
|
@ -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
|
Loading…
Reference in a new issue