adding content to resources
304
interface/resources/assets/ACAudioSearchAndInject_tutorial.js
Normal file
|
@ -0,0 +1,304 @@
|
|||
"use strict";
|
||||
/*jslint nomen: true, plusplus: true, vars: true*/
|
||||
/*global AvatarList, Entities, EntityViewer, Script, SoundCache, Audio, print, randFloat*/
|
||||
//
|
||||
// ACAudioSearchAndInject.js
|
||||
// audio
|
||||
//
|
||||
// Created by Eric Levin and Howard Stearns 2/1/2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Keeps track of all sounds within QUERY_RADIUS of an avatar, where a "sound" is specified in entity userData.
|
||||
// Inject as many as practical into the audio mixer.
|
||||
// See acAudioSearchAndCompatibilityEntitySpawner.js.
|
||||
//
|
||||
// This implementation takes some precautions to scale well:
|
||||
// - It doesn't hastle the entity server because it issues at most one octree query every UPDATE_TIME period, regardless of the number of avatars.
|
||||
// - It does not load itself because it only gathers entities once every UPDATE_TIME period, and only
|
||||
// checks entity properties for those small number of entities that are currently playing (plus a RECHECK_TIME period examination of all entities).
|
||||
// This implementation tries to use all the available injectors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
var MSEC_PER_SEC = 1000;
|
||||
var SOUND_DATA_KEY = "io.highfidelity.soundKey"; // Sound data is specified in userData under this key.
|
||||
var old_sound_data_key = "soundKey"; // For backwards compatibility.
|
||||
var QUERY_RADIUS = 50; // meters
|
||||
var UPDATE_TIME = 100; // ms. We'll update just one thing on this period.
|
||||
var EXPIRATION_TIME = 5 * MSEC_PER_SEC; // ms. Remove sounds that have been out of range for this time.
|
||||
var RECHECK_TIME = 10 * MSEC_PER_SEC; // ms. Check for new userData properties this often when not currently playing.
|
||||
// (By not checking most of the time when not playing, we can efficiently go through all entities without getEntityProperties.)
|
||||
var UPDATES_PER_STATS_LOG = RECHECK_TIME / UPDATE_TIME; // (It's nice to smooth out the results by straddling a recheck.)
|
||||
|
||||
var DEFAULT_SOUND_DATA = {
|
||||
volume: 0.5, // userData cannot specify zero volume with our current method of defaulting.
|
||||
loop: false, // Default must be false with our current method of defaulting, else there's no way to get a false value.
|
||||
playbackGap: MSEC_PER_SEC, // in ms
|
||||
playbackGapRange: 0 // in ms
|
||||
};
|
||||
|
||||
//var AGENT_AVATAR_POSITION = { x: -1.5327, y: 0.672515, z: 5.91573 };
|
||||
var AGENT_AVATAR_POSITION = { x: -2.83785, y: 1.45243, z: -13.6042 };
|
||||
|
||||
//var isACScript = this.EntityViewer !== undefined;
|
||||
var isACScript = true;
|
||||
|
||||
Script.include("http://hifi-content.s3.amazonaws.com/ryan/development/utils_ryan.js");
|
||||
if (isACScript) {
|
||||
Agent.isAvatar = true; // This puts a robot at 0,0,0, but is currently necessary in order to use AvatarList.
|
||||
Avatar.skeletonModelURL = "http://hifi-content.s3.amazonaws.com/ozan/dev/avatars/invisible_avatar/invisible_avatar.fst";
|
||||
Avatar.position = AGENT_AVATAR_POSITION;
|
||||
Agent.isListeningToAudioStream = true;
|
||||
}
|
||||
function ignore() {}
|
||||
function debug() { // Display the arguments not just [Object object].
|
||||
//print.apply(null, [].map.call(arguments, JSON.stringify));
|
||||
}
|
||||
|
||||
if (isACScript) {
|
||||
EntityViewer.setCenterRadius(QUERY_RADIUS);
|
||||
}
|
||||
|
||||
// ENTITY DATA CACHE
|
||||
//
|
||||
var entityCache = {}; // A dictionary of unexpired EntityData objects.
|
||||
var entityInvalidUserDataCache = {}; // A cache containing the entity IDs that have
|
||||
// previously been identified as containing non-JSON userData.
|
||||
// We use a dictionary here so id lookups are constant time.
|
||||
var examinationCount = 0;
|
||||
function EntityDatum(entityIdentifier) { // Just the data of an entity that we need to know about.
|
||||
// This data is only use for our sound injection. There is no need to store such info in the replicated entity on everyone's computer.
|
||||
var that = this;
|
||||
that.lastUserDataUpdate = 0; // new entity is in need of rechecking user data
|
||||
// State Transitions:
|
||||
// no data => no data | sound data | expired
|
||||
// expired => stop => remove
|
||||
// sound data => downloading
|
||||
// downloading => downloading | waiting
|
||||
// waiting => playing | waiting (if too many already playing)
|
||||
// playing => update position etc | no data
|
||||
that.stop = function stop() {
|
||||
if (!that.sound) {
|
||||
return;
|
||||
}
|
||||
print("stopping sound", entityIdentifier, that.url);
|
||||
delete that.sound;
|
||||
delete that.url;
|
||||
if (!that.injector) {
|
||||
return;
|
||||
}
|
||||
that.injector.stop();
|
||||
delete that.injector;
|
||||
};
|
||||
this.update = function stateTransitions(expirationCutoff, userDataCutoff, now) {
|
||||
if (that.timestamp < expirationCutoff) { // EXPIRED => STOP => REMOVE
|
||||
that.stop(); // Alternatively, we could fade out and then stop...
|
||||
delete entityCache[entityIdentifier];
|
||||
return;
|
||||
}
|
||||
var properties, soundData; // Latest data, pulled from local octree.
|
||||
|
||||
// getEntityProperties locks the tree, which competes with the asynchronous processing of queryOctree results.
|
||||
// Most entity updates are fast and only a very few do getEntityProperties.
|
||||
function ensureSoundData() { // We only getEntityProperities when we need to.
|
||||
if (properties) {
|
||||
return;
|
||||
}
|
||||
properties = Entities.getEntityProperties(entityIdentifier, ['userData', 'position']);
|
||||
examinationCount++; // Collect statistics on how many getEntityProperties we do.
|
||||
debug("updating", that, properties);
|
||||
try {
|
||||
var userData = properties.userData && JSON.parse(properties.userData);
|
||||
soundData = userData && (userData[SOUND_DATA_KEY] || userData[old_sound_data_key]); // Don't store soundData yet. Let state changes compare.
|
||||
that.lastUserDataUpdate = now; // But do update these ...
|
||||
that.url = soundData && soundData.url;
|
||||
that.playAfter = that.url && now;
|
||||
} catch (err) {
|
||||
if (!(entityIdentifier in entityInvalidUserDataCache)) {
|
||||
print(err, properties.userData);
|
||||
entityInvalidUserDataCache[entityIdentifier] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stumbling on big new pile of entities will do a lot of getEntityProperties. Once.
|
||||
if (that.lastUserDataUpdate < userDataCutoff) { // NO DATA => SOUND DATA
|
||||
ensureSoundData();
|
||||
}
|
||||
|
||||
if (!that.url) { // NO DATA => NO DATA
|
||||
return that.stop();
|
||||
}
|
||||
|
||||
if (!that.sound) { // SOUND DATA => DOWNLOADING
|
||||
that.sound = SoundCache.getSound(soundData.url); // SoundCache can manage duplicates better than we can.
|
||||
}
|
||||
|
||||
if (!that.sound.downloaded) { // DOWNLOADING => DOWNLOADING
|
||||
return;
|
||||
}
|
||||
|
||||
if (that.playAfter > now) { // DOWNLOADING | WAITING => WAITING
|
||||
return;
|
||||
}
|
||||
|
||||
ensureSoundData(); // We'll try to play/setOptions and will need position, so we might as well get soundData, too.
|
||||
if (soundData.url !== that.url) { // WAITING => NO DATA (update next time around)
|
||||
return that.stop();
|
||||
}
|
||||
|
||||
var options = {
|
||||
position: properties.position,
|
||||
loop: soundData.loop || DEFAULT_SOUND_DATA.loop,
|
||||
volume: soundData.volume || DEFAULT_SOUND_DATA.volume
|
||||
};
|
||||
|
||||
function repeat() {
|
||||
return !options.loop && (soundData.playbackGap >= 0);
|
||||
}
|
||||
|
||||
function randomizedNextPlay() { // time of next play or recheck, randomized to distribute the work
|
||||
var range = soundData.playbackGapRange || DEFAULT_SOUND_DATA.playbackGapRange,
|
||||
base = repeat() ? ((that.sound.duration * MSEC_PER_SEC) + (soundData.playbackGap || DEFAULT_SOUND_DATA.playbackGap)) : RECHECK_TIME;
|
||||
return now + base + randFloat(-Math.min(base, range), range);
|
||||
}
|
||||
|
||||
if (that.injector && soundData.playing === false) {
|
||||
that.injector.stop();
|
||||
that.injector = null;
|
||||
}
|
||||
|
||||
if (!that.injector) {
|
||||
if (soundData.playing === false) { // WAITING => PLAYING | WAITING
|
||||
return;
|
||||
}
|
||||
debug("starting", that, options);
|
||||
that.injector = Audio.playSound(that.sound, options); // Might be null if at at injector limit. Will try again later.
|
||||
if (that.injector) {
|
||||
print("started", entityIdentifier, that.url);
|
||||
} else { // Don't hammer ensureSoundData or injector manager.
|
||||
that.playAfter = randomizedNextPlay();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
that.injector.setOptions(options); // PLAYING => UPDATE POSITION ETC
|
||||
if (!that.injector.playing) { // Subtle: a looping sound will not check playbackGap.
|
||||
if (repeat()) { // WAITING => PLAYING
|
||||
// Setup next play just once, now. Changes won't be looked at while we wait.
|
||||
that.playAfter = randomizedNextPlay();
|
||||
// Subtle: if the restart fails b/c we're at injector limit, we won't try again until next playAfter.
|
||||
that.injector.restart();
|
||||
} else { // PLAYING => NO DATA
|
||||
that.playAfter = Infinity; // was one-shot and we're finished
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function internEntityDatum(entityIdentifier, timestamp, avatarPosition, avatar) {
|
||||
ignore(avatarPosition, avatar); // We could use avatars and/or avatarPositions to prioritize which ones to play.
|
||||
var entitySound = entityCache[entityIdentifier];
|
||||
if (!entitySound) {
|
||||
entitySound = entityCache[entityIdentifier] = new EntityDatum(entityIdentifier);
|
||||
}
|
||||
entitySound.timestamp = timestamp; // Might be updated for multiple avatars. That's fine.
|
||||
}
|
||||
|
||||
var nUpdates = UPDATES_PER_STATS_LOG, lastStats = Date.now();
|
||||
|
||||
function updateAllEntityData() { // A fast update of all entities we know about. A few make sounds.
|
||||
var now = Date.now(),
|
||||
expirationCutoff = now - EXPIRATION_TIME,
|
||||
userDataRecheckCutoff = now - RECHECK_TIME;
|
||||
Object.keys(entityCache).forEach(function (entityIdentifier) {
|
||||
entityCache[entityIdentifier].update(expirationCutoff, userDataRecheckCutoff, now);
|
||||
});
|
||||
if (nUpdates-- <= 0) { // Report statistics.
|
||||
// For example, with:
|
||||
// injector-limit = 40 (in C++ code)
|
||||
// N_SOUNDS = 1000 (from userData in, e.g., acAudioSearchCompatibleEntitySpawner.js)
|
||||
// replay-period = 3 + 20 = 23 (seconds, ditto)
|
||||
// stats-period = UPDATES_PER_STATS_LOG * UPDATE_TIME / MSEC_PER_SEC = 10 seconds
|
||||
// The log should show between each stats report:
|
||||
// "start" lines ~= injector-limit * P(finish) = injector-limit * stats-period/replay-period = 17 ?
|
||||
// total attempts at starting ("start" lines + "could not thread" lines) ~= N_SOUNDS = 1000 ?
|
||||
// entities > N_SOUNDS * (1+ N_SILENT_ENTITIES_PER_SOUND) = 11000 + whatever was in the scene before running spawner
|
||||
// sounds = N_SOUNDS = 1000
|
||||
// getEntityPropertiesPerUpdate ~= playing + failed-starts/UPDATES_PER_STATS_LOG + other-rechecks-each-update
|
||||
// = injector-limit + (total attempts - "start" lines)/UPDATES_PER_STATS__LOG
|
||||
// + (entities - playing - failed-starts/UPDATES_PER_STATS_LOG) * P(recheck-in-update)
|
||||
// where failed-starts/UPDATES_PER_STATS_LOG = (1000-17)/100 = 10
|
||||
// = 40 + 10 + (11000 - 40 - 10)*UPDATE_TIME/RECHECK_TIME
|
||||
// = 40 + 10 + 10950*0.01 = 159 (mostly proportional to enties/RECHECK_TIME)
|
||||
// millisecondsPerUpdate ~= UPDATE_TIME = 100 (+ some timer machinery time)
|
||||
// this assignment client activity monitor < 100% cpu
|
||||
var stats = {
|
||||
entities: 0,
|
||||
sounds: 0,
|
||||
playing: 0,
|
||||
getEntityPropertiesPerUpdate: examinationCount / UPDATES_PER_STATS_LOG,
|
||||
millisecondsPerUpdate: (now - lastStats) / UPDATES_PER_STATS_LOG
|
||||
};
|
||||
nUpdates = UPDATES_PER_STATS_LOG;
|
||||
lastStats = now;
|
||||
examinationCount = 0;
|
||||
Object.keys(entityCache).forEach(function (entityIdentifier) {
|
||||
var datum = entityCache[entityIdentifier];
|
||||
stats.entities++;
|
||||
if (datum.url) {
|
||||
stats.sounds++;
|
||||
if (datum.injector && datum.injector.playing) {
|
||||
stats.playing++;
|
||||
}
|
||||
}
|
||||
});
|
||||
print(JSON.stringify(stats));
|
||||
}
|
||||
}
|
||||
|
||||
// Update the set of which EntityData we know about.
|
||||
//
|
||||
function updateEntiesForAvatar(avatarIdentifier) { // Just one piece of update work.
|
||||
// This does at most:
|
||||
// one queryOctree request of the entity server, and
|
||||
// one findEntities geometry query of our own octree, and
|
||||
// a quick internEntityDatum of each of what may be a large number of entityIdentifiers.
|
||||
// The idea is that this is a nice bounded piece of work that should not be done too frequently.
|
||||
// However, it means that we won't learn about new entities until, on average (nAvatars * UPDATE_TIME) + query round trip.
|
||||
var avatar = AvatarList.getAvatar(avatarIdentifier), avatarPosition = avatar && avatar.position;
|
||||
if (!avatarPosition) { // No longer here.
|
||||
return;
|
||||
}
|
||||
var timestamp = Date.now();
|
||||
if (isACScript) {
|
||||
EntityViewer.setPosition(avatarPosition);
|
||||
EntityViewer.queryOctree(); // Requests an update, but there's no telling when we'll actually see different results.
|
||||
}
|
||||
var entities = Entities.findEntities(avatarPosition, QUERY_RADIUS);
|
||||
debug("found", entities.length, "entities near", avatar.name || "unknown", "at", avatarPosition);
|
||||
entities.forEach(function (entityIdentifier) {
|
||||
internEntityDatum(entityIdentifier, timestamp, avatarPosition, avatar);
|
||||
});
|
||||
}
|
||||
|
||||
// Slowly update the set of data we have to work with.
|
||||
//
|
||||
var workQueue = [];
|
||||
function updateWorkQueueForAvatarsPresent() { // when nothing else to do, fill queue with individual avatar updates
|
||||
workQueue = AvatarList.getAvatarIdentifiers().map(function (avatarIdentifier) {
|
||||
return function () {
|
||||
updateEntiesForAvatar(avatarIdentifier);
|
||||
};
|
||||
});
|
||||
}
|
||||
Script.setInterval(function () {
|
||||
// There might be thousands of EntityData known to us, but only a few will require any work to update.
|
||||
updateAllEntityData(); // i.e., this better be pretty fast.
|
||||
// Each interval, we do no more than one updateEntitiesforAvatar.
|
||||
if (!workQueue.length) {
|
||||
workQueue = [updateWorkQueueForAvatarsPresent];
|
||||
}
|
||||
workQueue.pop()(); // There's always one
|
||||
}, UPDATE_TIME);
|
BIN
interface/resources/assets/alan/dev/EZ-Portal.fbx
Normal file
BIN
interface/resources/assets/alan/dev/Portal-Sign-Return.fbx
Normal file
BIN
interface/resources/assets/alan/dev/Portal-Sign-Return2.fbx
Normal file
BIN
interface/resources/assets/alan/dev/Sandbox-Intro-2.fbx
Normal file
BIN
interface/resources/assets/alan/dev/Teleport-Pad.fbx
Normal file
BIN
interface/resources/assets/arrow.fbx
Normal file
BIN
interface/resources/assets/avatar.fbx
Normal file
BIN
interface/resources/assets/bubble.fbx
Normal file
BIN
interface/resources/assets/explore.fbx
Normal file
BIN
interface/resources/assets/grabbing.fbx
Normal file
BIN
interface/resources/assets/letsgo.fbx
Normal file
BIN
interface/resources/assets/menus.fbx
Normal file
BIN
interface/resources/assets/models/Block-Display-FTUE.fbx
Normal file
BIN
interface/resources/assets/models/Block-Display-round-FTUE.fbx
Normal file
BIN
interface/resources/assets/models/Bubble-v14.fbx
Normal file
BIN
interface/resources/assets/models/Concrete-Floor.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-Table-5.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-Tables.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-Tablet-Bubble.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-Tablet-Go-To.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-Tablet-Market.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-bubble.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-controllers-2.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-controllers.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-go-to.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-mirror-sign.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-open-tablet--2.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-pick-me-sign.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-skiptutorial.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-teleport-sign--2.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-tutorial-sign.fbx
Normal file
BIN
interface/resources/assets/models/FTUE-welcome-sign.fbx
Normal file
BIN
interface/resources/assets/models/Footprints.fbx
Normal file
BIN
interface/resources/assets/models/Holographic-Plinth.fbx
Normal file
BIN
interface/resources/assets/models/Sandbox-Sign.fbx
Normal file
BIN
interface/resources/assets/models/Teleport-Pad.fbx
Normal file
BIN
interface/resources/assets/models/WELCOME-AREA.fbx
Normal file
BIN
interface/resources/assets/models/Warehouse-Hangar.fbx
Normal file
BIN
interface/resources/assets/models/Welcome-text.fbx
Normal file
BIN
interface/resources/assets/models/avatar-pedestal.fbx
Normal file
BIN
interface/resources/assets/models/bubble-explainer.fbx
Normal file
BIN
interface/resources/assets/models/catwalk-element.fbx
Normal file
BIN
interface/resources/assets/models/choose-avatar-sign.fbx
Normal file
BIN
interface/resources/assets/models/finalFrame.fbx
Normal file
BIN
interface/resources/assets/models/glow-cone.fbx
Normal file
BIN
interface/resources/assets/models/mirror-sphere.fbx
Normal file
BIN
interface/resources/assets/models/neighbor-3.fbx
Normal file
BIN
interface/resources/assets/models/sandbox-platform.fbx
Normal file
BIN
interface/resources/assets/models/teleport-controllers.fbx
Normal file
BIN
interface/resources/assets/models/teleport-decal.fbx
Normal file
BIN
interface/resources/assets/models/teleport-explainer.fbx
Normal file
BIN
interface/resources/assets/models/teleport-guy.fbx
Normal file
BIN
interface/resources/assets/models/teleport-sign.fbx
Normal file
BIN
interface/resources/assets/models/woodFloor.fbx
Normal file
22
interface/resources/assets/portal.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
(function(){
|
||||
this.enterEntity = function(entityID) {
|
||||
var properties = Entities.getEntityProperties(entityID, 'userData');
|
||||
|
||||
if (properties && properties.userData !== undefined) {
|
||||
portalDestination = properties.userData;
|
||||
|
||||
print("portal.js | enterEntity() .... The portal destination is " + portalDestination);
|
||||
|
||||
if (portalDestination.length > 0) {
|
||||
var destination;
|
||||
if (portalDestination[0] == '/') {
|
||||
destination = portalDestination;
|
||||
} else {
|
||||
destination = "hifi://" + portalDestination;
|
||||
}
|
||||
print("Teleporting to " + destination);
|
||||
Window.location = destination;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
32
interface/resources/assets/scripts/cubeScript.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Sandbox/cubeScript.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
var id;
|
||||
|
||||
var Cube = function(){
|
||||
|
||||
};
|
||||
|
||||
Cube.prototype = {
|
||||
preload: function(entityID) {
|
||||
id = entityID;
|
||||
},
|
||||
startNearGrab : function() {
|
||||
print("I've been grabbed");
|
||||
Entities.editEntity(id, {"parentID" : "{00000000-0000-0000-0000-000000000000}", script: ""});
|
||||
print(JSON.stringify(Entities.getEntityProperties(id)));
|
||||
},
|
||||
startDistanceGrab : function() {
|
||||
Entities.editEntity(id, {"parentID" : "{00000000-0000-0000-0000-000000000000}", script: ""});
|
||||
}
|
||||
};
|
||||
|
||||
return new Cube();
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
(function(){
|
||||
var TABLET = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var MARKETPLACE_PAGE = "https://highfidelity.com/marketplace?category=environments";
|
||||
var MARKETPLACES_INJECT_URL = ScriptDiscoveryService.defaultScriptsPath + "/system/html/js/marketplacesInject.js";
|
||||
function MarketplaceOpenTrigger(){
|
||||
|
||||
}
|
||||
function openMarketplaceCategory(){
|
||||
TABLET.gotoWebScreen(MARKETPLACE_PAGE, MARKETPLACES_INJECT_URL);
|
||||
}
|
||||
MarketplaceOpenTrigger.prototype = {
|
||||
mousePressOnEntity : function() {
|
||||
openMarketplaceCategory();
|
||||
},
|
||||
startFarTrigger: function() {
|
||||
openMarketplaceCategory();
|
||||
},
|
||||
startNearTrigger: function() {
|
||||
openMarketplaceCategory();
|
||||
}
|
||||
};
|
||||
return new MarketplaceOpenTrigger();
|
||||
|
||||
});
|
49
interface/resources/assets/scripts/spawnOrangeCube.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// Sandbox/spawnOrangeCube.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
var LIFETIME = 300;
|
||||
var SPAWN_POSITION = {x: 1.0047, y: -10.5956, z: 16.8437};
|
||||
var CHECK_INTERVAL = LIFETIME * 10;
|
||||
|
||||
var cubeProperties;
|
||||
var spawnCubeInterval;
|
||||
|
||||
var OrangeCubeSpawner = function(){
|
||||
|
||||
};
|
||||
|
||||
OrangeCubeSpawner.prototype = {
|
||||
preload: function(entityID) {
|
||||
cubeProperties = {
|
||||
type: "Box",
|
||||
shape: "Cube",
|
||||
color : {"red" : 240, "green" : 112, "blue" : 0},
|
||||
dimensions : {x: 0.3092, y: 0.3092, z: 0.3092},
|
||||
gravity : {x: 0, y: -2, z: 0},
|
||||
lifetime: LIFETIME,
|
||||
position: SPAWN_POSITION,
|
||||
dynamic: true,
|
||||
"parentID": entityID,
|
||||
"userData" : "{\"grabbableKey\":{\"grabbable\":true}}",
|
||||
script: "file://~/assets/scripts/cubeScript.js"
|
||||
};
|
||||
spawnCubeInterval = Script.setInterval(function() {
|
||||
if (Entities.getChildrenIDs(entityID).length === 0) {
|
||||
Entities.addEntity(cubeProperties); // add a cube if none exists
|
||||
}
|
||||
}, CHECK_INTERVAL);
|
||||
},
|
||||
unload: function() {
|
||||
Script.clearInterval(spawnCubeInterval);
|
||||
}
|
||||
};
|
||||
|
||||
return new OrangeCubeSpawner();
|
||||
});
|
59
interface/resources/assets/scripts/zoneItemBase.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// Sandbox/zoneItemBase.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
|
||||
var ZoneItem = function(){
|
||||
|
||||
};
|
||||
|
||||
var showPanelsForVR = function(deviceType) {
|
||||
switch (deviceType) {
|
||||
case "Rift" :
|
||||
if (HMD.isHandControllerAvailable()) {
|
||||
// Assume Touch Controllers
|
||||
|
||||
} else if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
// Xbox controller & Keyboard/Mouse
|
||||
} else {
|
||||
// Keyboard & mouse
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Assume hand controllers are present for OpenVR devices
|
||||
}
|
||||
};
|
||||
|
||||
var showPanelsForDesktop = function() {
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
// We have a game pad
|
||||
|
||||
} else {
|
||||
// Just show keyboard / mouse
|
||||
}
|
||||
};
|
||||
|
||||
var setDisplayType = function() {
|
||||
if (!HMD.active) {
|
||||
// Desktop mode, because not in VR
|
||||
showPanelsForDesktop();
|
||||
} else {
|
||||
var deviceType = HMD.isDeviceAvailable("Oculus Rift") ? "Rift" : "Vive";
|
||||
showPanelsForVR(deviceType);
|
||||
}
|
||||
};
|
||||
|
||||
ZoneItem.prototype = {
|
||||
preload: function(entityID) {
|
||||
|
||||
}
|
||||
};
|
||||
return new ZoneItem();
|
||||
|
||||
});
|
235
interface/resources/assets/scripts/zoneItemBubble.js
Normal file
|
@ -0,0 +1,235 @@
|
|||
//
|
||||
// Sandbox/zoneItemBubble.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
|
||||
var DESKTOP_IDENTIFIER = "-Desktop";
|
||||
var GAMEPAD_IDENTIFIER = "-Gamepad";
|
||||
var VIVE_IDENTIFIER = "-Vive";
|
||||
var RIFT_IDENTIFIER = "-Rift";
|
||||
var WEB_IDENTIFIER = "BubbleGif-Web";
|
||||
|
||||
var GIF_DESKTOP_URL = "https://giphy.com/gifs/7A4F5AroAXHiRPY9om/html5";
|
||||
var GIF_VIVE_URL = "https://giphy.com/gifs/Zd5ZVLS7eJIYEiW4tt/html5";
|
||||
var GIF_RIFT_URL = "https://giphy.com/gifs/Zd5ZVLS7eJIYEiW4tt/html5";
|
||||
var GIF_GAMEPAD_URL = "https://giphy.com/gifs/Zd5ZVLS7eJIYEiW4tt/html5";
|
||||
|
||||
var WEB_ENTITY_BASE_PROPERTIES = {
|
||||
"collidesWith" : "",
|
||||
"collisionMask" : 0,
|
||||
"dimensions" : { "x": 3.200000047683716, "y": 1.7999999523162842, "z": 0.009999999776482582 },
|
||||
"name" : WEB_IDENTIFIER,
|
||||
"position" : {"x" : -36.6215, "y" : -8.6602, "z" : 4.5753},
|
||||
"rotation" : {"w": -0.883017897605896, "x": 0.00016412297554779798, "y": -0.46934211254119873,"z": 0},
|
||||
"type": "Web",
|
||||
"userData": "{\"grabbableKey\":{\"grabbable\":false}}"
|
||||
};
|
||||
|
||||
|
||||
var HMD_SOUND_URL = 'file:///~/assets/sounds/BubbleAudio-HMD.wav';
|
||||
var DESKTOP_SOUND_URL = 'file:///~/assets/sounds/BubbleAudio-Desktop.wav';
|
||||
|
||||
var HMD_SOUND = SoundCache.getSound(HMD_SOUND_URL);
|
||||
var DESKTOP_SOUND = SoundCache.getSound(DESKTOP_SOUND_URL);
|
||||
|
||||
var position;
|
||||
var audioPlaying;
|
||||
|
||||
var desktopEntities = [];
|
||||
var gamePadEntities = [];
|
||||
var viveEntities = [];
|
||||
var riftEntities = [];
|
||||
var webGifEntity;
|
||||
|
||||
var wantDebug = false;
|
||||
|
||||
var ZoneItem = function(){
|
||||
|
||||
};
|
||||
|
||||
var makeVisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: true });
|
||||
};
|
||||
|
||||
var makeInvisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: false });
|
||||
};
|
||||
|
||||
var showPanelsForDesktop = function() {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
// We have a game pad
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing game pad entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(WEB_ENTITY_BASE_PROPERTIES);
|
||||
|
||||
} else {
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing only desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_DESKTOP_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var showPanelsForVR = function(deviceType) {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
switch (deviceType) {
|
||||
case "Rift" :
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
if (wantDebug) {
|
||||
print("Showing Gamepad entities for Rift");
|
||||
}
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
|
||||
} else {
|
||||
if (wantDebug) {
|
||||
print("Showing Rift hand controller entities");
|
||||
}
|
||||
riftEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_RIFT_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Assume hand controllers are present for OpenVR devices
|
||||
if (wantDebug) {
|
||||
print("Showing hand controller entities for Vive");
|
||||
}
|
||||
viveEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_VIVE_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var setDisplayType = function() {
|
||||
if (!HMD.active) {
|
||||
// Desktop mode, because not in VR
|
||||
showPanelsForDesktop();
|
||||
} else {
|
||||
var deviceType = HMD.isHMDAvailable("Oculus Rift") ? "Rift" : "Vive";
|
||||
showPanelsForVR(deviceType);
|
||||
}
|
||||
};
|
||||
|
||||
var hideAllElements = function() {
|
||||
desktopEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
viveEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
riftEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
Entities.deleteEntity(webGifEntity);
|
||||
webGifEntity = "";
|
||||
};
|
||||
|
||||
ZoneItem.prototype = {
|
||||
preload: function(entityID) {
|
||||
position = Entities.getEntityProperties(entityID, 'position').position;
|
||||
},
|
||||
enterEntity: function() {
|
||||
var nearbyEntities = Entities.findEntities(position, 10);
|
||||
nearbyEntities.forEach(function(element) {
|
||||
var elementName = Entities.getEntityProperties(element, 'name').name;
|
||||
if (wantDebug) {
|
||||
print ("Found entity with name: " + elementName);
|
||||
}
|
||||
if (elementName.indexOf(DESKTOP_IDENTIFIER) !== -1) {
|
||||
desktopEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to desktop");
|
||||
}
|
||||
} else if (elementName.indexOf(GAMEPAD_IDENTIFIER) !== -1) {
|
||||
gamePadEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to gamepad");
|
||||
}
|
||||
} else if (elementName.indexOf(VIVE_IDENTIFIER) !== -1) {
|
||||
viveEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to vive");
|
||||
}
|
||||
} else if (elementName.indexOf(RIFT_IDENTIFIER) !== -1) {
|
||||
riftEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to rift");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
webGifEntity = element;
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " as the web entity");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
Entities.deleteEntity(element); // clean up old web entity
|
||||
}
|
||||
});
|
||||
setDisplayType();
|
||||
if (HMD.active) {
|
||||
if (HMD_SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(HMD_SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (DESKTOP_SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(DESKTOP_SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
leaveEntity: function() {
|
||||
hideAllElements();
|
||||
if (audioPlaying) {
|
||||
audioPlaying.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
return new ZoneItem();
|
||||
|
||||
});
|
223
interface/resources/assets/scripts/zoneItemGrabbing.js
Normal file
|
@ -0,0 +1,223 @@
|
|||
//
|
||||
// Sandbox/zoneItemGrabbing.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
|
||||
var DESKTOP_IDENTIFIER = "-Desktop";
|
||||
var GAMEPAD_IDENTIFIER = "-Gamepad";
|
||||
var VIVE_IDENTIFIER = "-Vive";
|
||||
var RIFT_IDENTIFIER = "-Rift";
|
||||
var WEB_IDENTIFIER = "GrabbingGif-Web";
|
||||
|
||||
var WEB_ENTITY_BASE_PROPERTIES = {
|
||||
"collidesWith" : "",
|
||||
"collisionMask" : 0,
|
||||
"dimensions" : { "x": 3.200000047683716, "y": 1.7999999523162842, "z": 0.009999999776482582 },
|
||||
"name" : WEB_IDENTIFIER,
|
||||
"position" : {"x" : 3.1178, "y" : -8.6587, "z" : 17.8029},
|
||||
"rotation" : {"w": 0.4576631188392639, "x": 0, "y": -0.8891195058822632, "z": -0.00012345008144620806},
|
||||
"type": "Web",
|
||||
"userData": "{\"grabbableKey\":{\"grabbable\":false}}"
|
||||
};
|
||||
|
||||
|
||||
var GIF_DESKTOP_URL = "https://giphy.com/gifs/3gZfhYj4BvIKOVi0KF/html5";
|
||||
var GIF_VIVE_URL = "https://giphy.com/gifs/5bkpeKVbeKd7l6zEZd/html5";
|
||||
var GIF_RIFT_URL = "https://giphy.com/gifs/5bkpeKVbeKd7l6zEZd/html5";
|
||||
var GIF_GAMEPAD_URL = "https://giphy.com/gifs/5bkpeKVbeKd7l6zEZd/html5";
|
||||
|
||||
var SOUND_URL = 'file:///~/assets/sounds/GrabbingAudio.wav';
|
||||
var SOUND = SoundCache.getSound(SOUND_URL);
|
||||
|
||||
var position;
|
||||
var audioPlaying;
|
||||
|
||||
var desktopEntities = [];
|
||||
var gamePadEntities = [];
|
||||
var viveEntities = [];
|
||||
var riftEntities = [];
|
||||
var webGifEntity;
|
||||
|
||||
var wantDebug = false;
|
||||
|
||||
var ZoneItem = function(){
|
||||
|
||||
};
|
||||
|
||||
var makeVisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: true });
|
||||
};
|
||||
|
||||
var makeInvisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: false });
|
||||
};
|
||||
|
||||
var showPanelsForDesktop = function() {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
// We have a game pad
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing game pad entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(WEB_ENTITY_BASE_PROPERTIES);
|
||||
|
||||
} else {
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing only desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_DESKTOP_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var showPanelsForVR = function(deviceType) {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
switch (deviceType) {
|
||||
case "Rift" :
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
if (wantDebug) {
|
||||
print("Showing Gamepad entities for Rift");
|
||||
}
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
|
||||
} else {
|
||||
if (wantDebug) {
|
||||
print("Showing Rift hand controller entities");
|
||||
}
|
||||
riftEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_RIFT_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Assume hand controllers are present for OpenVR devices
|
||||
if (wantDebug) {
|
||||
print("Showing hand controller entities for Vive");
|
||||
}
|
||||
viveEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_VIVE_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var setDisplayType = function() {
|
||||
if (!HMD.active) {
|
||||
// Desktop mode, because not in VR
|
||||
showPanelsForDesktop();
|
||||
} else {
|
||||
var deviceType = HMD.isHMDAvailable("Oculus Rift") ? "Rift" : "Vive";
|
||||
showPanelsForVR(deviceType);
|
||||
}
|
||||
};
|
||||
|
||||
var hideAllElements = function() {
|
||||
desktopEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
viveEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
riftEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
Entities.deleteEntity(webGifEntity);
|
||||
webGifEntity = "";
|
||||
};
|
||||
|
||||
ZoneItem.prototype = {
|
||||
preload: function(entityID) {
|
||||
position = Entities.getEntityProperties(entityID, 'position').position;
|
||||
},
|
||||
enterEntity: function() {
|
||||
var nearbyEntities = Entities.findEntities(position, 10);
|
||||
nearbyEntities.forEach(function(element) {
|
||||
var elementName = Entities.getEntityProperties(element, 'name').name;
|
||||
if (wantDebug) {
|
||||
print ("Found entity with name: " + elementName);
|
||||
}
|
||||
if (elementName.indexOf(DESKTOP_IDENTIFIER) !== -1) {
|
||||
desktopEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to desktop");
|
||||
}
|
||||
} else if (elementName.indexOf(GAMEPAD_IDENTIFIER) !== -1) {
|
||||
gamePadEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to gamepad");
|
||||
}
|
||||
} else if (elementName.indexOf(VIVE_IDENTIFIER) !== -1) {
|
||||
viveEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to vive");
|
||||
}
|
||||
} else if (elementName.indexOf(RIFT_IDENTIFIER) !== -1) {
|
||||
riftEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to rift");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
webGifEntity = element;
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " as the web entity");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
Entities.deleteEntity(element); // clean up old web entity
|
||||
}
|
||||
});
|
||||
setDisplayType();
|
||||
if (SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
leaveEntity: function() {
|
||||
hideAllElements();
|
||||
if (audioPlaying) {
|
||||
audioPlaying.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
return new ZoneItem();
|
||||
|
||||
});
|
223
interface/resources/assets/scripts/zoneItemMarket.js
Normal file
|
@ -0,0 +1,223 @@
|
|||
//
|
||||
// Sandbox/zoneItemMarket.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
|
||||
var DESKTOP_IDENTIFIER = "-Desktop";
|
||||
var GAMEPAD_IDENTIFIER = "-Gamepad";
|
||||
var VIVE_IDENTIFIER = "-Vive";
|
||||
var RIFT_IDENTIFIER = "-Rift";
|
||||
var WEB_IDENTIFIER = "AvatarGif-Web";
|
||||
|
||||
var WEB_ENTITY_BASE_PROPERTIES = {
|
||||
"collidesWith" : "",
|
||||
"collisionMask" : 0,
|
||||
"dimensions" : { "x": 3.200000047683716, "y": 1.7999999523162842, "z": 0.009999999776482582 },
|
||||
"name" : WEB_IDENTIFIER,
|
||||
"position" : {"x" : -16.6107, "y" : -8.6588, "z" : 21.3236},
|
||||
"rotation" : { "w": -0.3051055371761322, "x": 0, "y": -0.9523110389709473,"z": 0},
|
||||
"type": "Web",
|
||||
"userData": "{\"grabbableKey\":{\"grabbable\":false}}"
|
||||
};
|
||||
|
||||
|
||||
var GIF_DESKTOP_URL = "https://giphy.com/gifs/PQR5rlLy6RmjTEHF2R/html5";
|
||||
var GIF_VIVE_URL = "https://giphy.com/gifs/5YcTj1bve3xCInv509/html5";
|
||||
var GIF_RIFT_URL = "https://giphy.com/gifs/5YcTj1bve3xCInv509/html5";
|
||||
var GIF_GAMEPAD_URL = "https://giphy.com/gifs/5YcTj1bve3xCInv509/html5";
|
||||
|
||||
var SOUND_URL = 'file:///~/assets/sounds/AvatarAudio.wav';
|
||||
var SOUND = SoundCache.getSound(SOUND_URL);
|
||||
|
||||
var position;
|
||||
var audioPlaying;
|
||||
|
||||
var desktopEntities = [];
|
||||
var gamePadEntities = [];
|
||||
var viveEntities = [];
|
||||
var riftEntities = [];
|
||||
var webGifEntity;
|
||||
|
||||
var wantDebug = false;
|
||||
|
||||
var ZoneItem = function(){
|
||||
|
||||
};
|
||||
|
||||
var makeVisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: true });
|
||||
};
|
||||
|
||||
var makeInvisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: false });
|
||||
};
|
||||
|
||||
var showPanelsForDesktop = function() {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
// We have a game pad
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing game pad entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(WEB_ENTITY_BASE_PROPERTIES);
|
||||
|
||||
} else {
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing only desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_DESKTOP_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var showPanelsForVR = function(deviceType) {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
switch (deviceType) {
|
||||
case "Rift" :
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
if (wantDebug) {
|
||||
print("Showing Gamepad entities for Rift");
|
||||
}
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
|
||||
} else {
|
||||
if (wantDebug) {
|
||||
print("Showing Rift hand controller entities");
|
||||
}
|
||||
riftEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_RIFT_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Assume hand controllers are present for OpenVR devices
|
||||
if (wantDebug) {
|
||||
print("Showing hand controller entities for Vive");
|
||||
}
|
||||
viveEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
Entities.editEntity(webGifEntity, {"sourceUrl" : GIF_VIVE_URL});
|
||||
makeVisible(webGifEntity);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var setDisplayType = function() {
|
||||
if (!HMD.active) {
|
||||
// Desktop mode, because not in VR
|
||||
showPanelsForDesktop();
|
||||
} else {
|
||||
var deviceType = HMD.isHMDAvailable("Oculus Rift") ? "Rift" : "Vive";
|
||||
showPanelsForVR(deviceType);
|
||||
}
|
||||
};
|
||||
|
||||
var hideAllElements = function() {
|
||||
desktopEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
viveEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
riftEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
Entities.deleteEntity(webGifEntity);
|
||||
webGifEntity = "";
|
||||
};
|
||||
|
||||
ZoneItem.prototype = {
|
||||
preload: function(entityID) {
|
||||
position = Entities.getEntityProperties(entityID, 'position').position;
|
||||
},
|
||||
enterEntity: function() {
|
||||
var nearbyEntities = Entities.findEntities(position, 10);
|
||||
nearbyEntities.forEach(function(element) {
|
||||
var elementName = Entities.getEntityProperties(element, 'name').name;
|
||||
if (wantDebug) {
|
||||
print ("Found entity with name: " + elementName);
|
||||
}
|
||||
if (elementName.indexOf(DESKTOP_IDENTIFIER) !== -1) {
|
||||
desktopEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to desktop");
|
||||
}
|
||||
} else if (elementName.indexOf(GAMEPAD_IDENTIFIER) !== -1) {
|
||||
gamePadEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to gamepad");
|
||||
}
|
||||
} else if (elementName.indexOf(VIVE_IDENTIFIER) !== -1) {
|
||||
viveEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to vive");
|
||||
}
|
||||
} else if (elementName.indexOf(RIFT_IDENTIFIER) !== -1) {
|
||||
riftEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to rift");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
webGifEntity = element;
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " as the web entity");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
Entities.deleteEntity(element); // clean up old web entity
|
||||
}
|
||||
});
|
||||
setDisplayType();
|
||||
if (SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
leaveEntity: function() {
|
||||
hideAllElements();
|
||||
if (audioPlaying) {
|
||||
audioPlaying.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
return new ZoneItem();
|
||||
|
||||
});
|
234
interface/resources/assets/scripts/zoneItemMenu.js
Normal file
|
@ -0,0 +1,234 @@
|
|||
//
|
||||
// Sandbox/zoneItemMenu.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
|
||||
var DESKTOP_IDENTIFIER = "-Desktop";
|
||||
var GAMEPAD_IDENTIFIER = "-Gamepad";
|
||||
var VIVE_IDENTIFIER = "-Vive";
|
||||
var RIFT_IDENTIFIER = "-Rift";
|
||||
var WEB_IDENTIFIER = "MenuGif-Web";
|
||||
|
||||
var WEB_ENTITY_BASE_PROPERTIES = {
|
||||
"collidesWith" : "",
|
||||
"collisionMask" : 0,
|
||||
"dimensions" : { "x": 3.200000047683716, "y": 1.7999999523162842, "z": 0.009999999776482582 },
|
||||
"name" : WEB_IDENTIFIER,
|
||||
"position" : {"x" : -17.1352, "y" : -8.6585, "z" : 1.6240},
|
||||
"rotation" : {"w": 0.9550813436508179, "x": 0, "y": -0.29633983969688416,"z": 0},
|
||||
"type": "Web",
|
||||
"userData": "{\"grabbableKey\":{\"grabbable\":false}}"
|
||||
};
|
||||
|
||||
var GIF_DESKTOP_URL = "https://giphy.com/gifs/25Im0Bse1k6E4BRCtg/html5";
|
||||
var GIF_VIVE_URL = "https://giphy.com/gifs/1sx4wVbZC0pSgx8ua8/html5";
|
||||
var GIF_RIFT_URL = "https://giphy.com/gifs/1sx4wVbZC0pSgx8ua8/html5";
|
||||
var GIF_GAMEPAD_URL = "https://giphy.com/gifs/1sx4wVbZC0pSgx8ua8/html5";
|
||||
|
||||
var HMD_SOUND_URL = 'file://~/assets/sounds/MenuAudio-HMD.wav';
|
||||
var DESKTOP_SOUND_URL = 'file:///~/assets/sounds/MenuAudio-Desktop.wav';
|
||||
|
||||
var HMD_SOUND = SoundCache.getSound(HMD_SOUND_URL);
|
||||
var DESKTOP_SOUND = SoundCache.getSound(DESKTOP_SOUND_URL);
|
||||
|
||||
var position;
|
||||
var audioPlaying;
|
||||
|
||||
var desktopEntities = [];
|
||||
var gamePadEntities = [];
|
||||
var viveEntities = [];
|
||||
var riftEntities = [];
|
||||
var webGifEntity;
|
||||
|
||||
var wantDebug = false;
|
||||
|
||||
var ZoneItem = function(){
|
||||
|
||||
};
|
||||
|
||||
var makeVisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: true });
|
||||
};
|
||||
|
||||
var makeInvisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: false });
|
||||
};
|
||||
|
||||
var showPanelsForDesktop = function() {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
// We have a game pad
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing game pad entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(WEB_ENTITY_BASE_PROPERTIES);
|
||||
|
||||
} else {
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing only desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_DESKTOP_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var showPanelsForVR = function(deviceType) {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
switch (deviceType) {
|
||||
case "Rift" :
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
if (wantDebug) {
|
||||
print("Showing Gamepad entities for Rift");
|
||||
}
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
|
||||
} else {
|
||||
if (wantDebug) {
|
||||
print("Showing Rift hand controller entities");
|
||||
}
|
||||
riftEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_RIFT_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Assume hand controllers are present for OpenVR devices
|
||||
if (wantDebug) {
|
||||
print("Showing hand controller entities for Vive");
|
||||
}
|
||||
viveEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_VIVE_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var setDisplayType = function() {
|
||||
if (!HMD.active) {
|
||||
// Desktop mode, because not in VR
|
||||
showPanelsForDesktop();
|
||||
} else {
|
||||
var deviceType = HMD.isHMDAvailable("Oculus Rift") ? "Rift" : "Vive";
|
||||
showPanelsForVR(deviceType);
|
||||
}
|
||||
};
|
||||
|
||||
var hideAllElements = function() {
|
||||
desktopEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
viveEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
riftEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
Entities.deleteEntity(webGifEntity);
|
||||
webGifEntity = "";
|
||||
};
|
||||
|
||||
ZoneItem.prototype = {
|
||||
preload: function(entityID) {
|
||||
position = Entities.getEntityProperties(entityID, 'position').position;
|
||||
},
|
||||
enterEntity: function() {
|
||||
var nearbyEntities = Entities.findEntities(position, 10);
|
||||
nearbyEntities.forEach(function(element) {
|
||||
var elementName = Entities.getEntityProperties(element, 'name').name;
|
||||
if (wantDebug) {
|
||||
print ("Found entity with name: " + elementName);
|
||||
}
|
||||
if (elementName.indexOf(DESKTOP_IDENTIFIER) !== -1) {
|
||||
desktopEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to desktop");
|
||||
}
|
||||
} else if (elementName.indexOf(GAMEPAD_IDENTIFIER) !== -1) {
|
||||
gamePadEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to gamepad");
|
||||
}
|
||||
} else if (elementName.indexOf(VIVE_IDENTIFIER) !== -1) {
|
||||
viveEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to vive");
|
||||
}
|
||||
} else if (elementName.indexOf(RIFT_IDENTIFIER) !== -1) {
|
||||
riftEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to rift");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
webGifEntity = element;
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " as the web entity");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
Entities.deleteEntity(element); // clean up old web entity
|
||||
}
|
||||
});
|
||||
setDisplayType();
|
||||
if (HMD.active) {
|
||||
if (HMD_SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(HMD_SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (DESKTOP_SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(DESKTOP_SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
leaveEntity: function() {
|
||||
hideAllElements();
|
||||
if (audioPlaying) {
|
||||
audioPlaying.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
return new ZoneItem();
|
||||
|
||||
});
|
213
interface/resources/assets/scripts/zoneItemMovement.js
Normal file
|
@ -0,0 +1,213 @@
|
|||
//
|
||||
// Sandbox/zoneItemMovement.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
|
||||
var DESKTOP_IDENTIFIER = "-Desktop";
|
||||
var GAMEPAD_IDENTIFIER = "-Gamepad";
|
||||
var VIVE_IDENTIFIER = "-Vive";
|
||||
var RIFT_IDENTIFIER = "-Rift";
|
||||
var WEB_IDENTIFIER = "MovementGif-Web";
|
||||
|
||||
var GIF_DESKTOP_URL = "https://giphy.com/gifs/LYJZ2YTQiY0WoSoOKj/html5";
|
||||
var GIF_VIVE_URL = "https://giphy.com/gifs/mnqTywAN88tiJarYIS/html5";
|
||||
var GIF_RIFT_URL = "https://giphy.com/gifs/mnqTywAN88tiJarYIS/html5";
|
||||
var GIF_GAMEPAD_URL = "https://giphy.com/gifs/LYJZ2YTQiY0WoSoOKj/html5";
|
||||
|
||||
|
||||
var WEB_ENTITY_BASE_PROPERTIES = {
|
||||
"collidesWith" : "",
|
||||
"collisionMask" : 0,
|
||||
"dimensions" : { "x": 3.200000047683716, "y": 1.7999999523162842, "z": 0.009999999776482582 },
|
||||
"name" : WEB_IDENTIFIER,
|
||||
"position" : {"x" : 3.3181, "y" : -8.6590, "z" : -0.2557},
|
||||
"rotation" : { "w": 0.7660241723060608, "x": -0.0002027750015258789,"y": -0.6427602767944336, "z": 0},
|
||||
"type": "Web",
|
||||
"userData": "{\"grabbableKey\":{\"grabbable\":false}}"
|
||||
};
|
||||
|
||||
var SOUND_URL = 'file:///~/assets/sounds/MovementAudio.wav';
|
||||
var SOUND = SoundCache.getSound(SOUND_URL);
|
||||
|
||||
var position;
|
||||
var audioPlaying;
|
||||
|
||||
var desktopEntities = [];
|
||||
var gamePadEntities = [];
|
||||
var viveEntities = [];
|
||||
var riftEntities = [];
|
||||
var webGifEntity;
|
||||
|
||||
var wantDebug = false;
|
||||
|
||||
var ZoneItem = function(){
|
||||
|
||||
};
|
||||
|
||||
var makeVisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: true });
|
||||
};
|
||||
|
||||
var makeInvisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: false });
|
||||
};
|
||||
|
||||
var showPanelsForDesktop = function() {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
// We have a game pad
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
gamePadEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing game pad entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(WEB_ENTITY_BASE_PROPERTIES);
|
||||
} else {
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing only desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_DESKTOP_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
}
|
||||
};
|
||||
|
||||
var showPanelsForVR = function(deviceType) {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
switch (deviceType) {
|
||||
case "Rift" :
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
if (wantDebug) {
|
||||
print("Showing Gamepad entities for Rift");
|
||||
}
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
} else {
|
||||
if (wantDebug) {
|
||||
print("Showing Rift hand controller entities");
|
||||
}
|
||||
riftEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_RIFT_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Assume hand controllers are present for OpenVR devices
|
||||
if (wantDebug) {
|
||||
print("Showing hand controller entities for Vive");
|
||||
}
|
||||
viveEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_VIVE_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var setDisplayType = function() {
|
||||
if (!HMD.active) {
|
||||
// Desktop mode, because not in VR
|
||||
showPanelsForDesktop();
|
||||
} else {
|
||||
var deviceType = HMD.isHMDAvailable("Oculus Rift") ? "Rift" : "Vive";
|
||||
showPanelsForVR(deviceType);
|
||||
}
|
||||
};
|
||||
|
||||
var hideAllElements = function() {
|
||||
desktopEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
viveEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
riftEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
Entities.deleteEntity(webGifEntity);
|
||||
webGifEntity = "";
|
||||
};
|
||||
|
||||
ZoneItem.prototype = {
|
||||
preload: function(entityID) {
|
||||
position = Entities.getEntityProperties(entityID, 'position').position;
|
||||
},
|
||||
enterEntity: function() {
|
||||
var nearbyEntities = Entities.findEntities(position, 10);
|
||||
nearbyEntities.forEach(function(element) {
|
||||
var elementName = Entities.getEntityProperties(element, 'name').name;
|
||||
if (wantDebug) {
|
||||
print ("Found entity with name: " + elementName);
|
||||
}
|
||||
if (elementName.indexOf(DESKTOP_IDENTIFIER) !== -1) {
|
||||
desktopEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to desktop");
|
||||
}
|
||||
} else if (elementName.indexOf(GAMEPAD_IDENTIFIER) !== -1) {
|
||||
gamePadEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to gamepad");
|
||||
}
|
||||
} else if (elementName.indexOf(VIVE_IDENTIFIER) !== -1) {
|
||||
viveEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to vive");
|
||||
}
|
||||
} else if (elementName.indexOf(RIFT_IDENTIFIER) !== -1) {
|
||||
riftEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to rift");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
Entities.deleteEntity(element); // clean up old web entity
|
||||
}
|
||||
});
|
||||
setDisplayType();
|
||||
if (SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
leaveEntity: function() {
|
||||
hideAllElements();
|
||||
if (audioPlaying) {
|
||||
audioPlaying.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return new ZoneItem();
|
||||
});
|
235
interface/resources/assets/scripts/zoneItemPlaces.js
Normal file
|
@ -0,0 +1,235 @@
|
|||
//
|
||||
// Sandbox/zoneItemPlaces.js
|
||||
//
|
||||
// Author: Liv Erickson
|
||||
// Copyright High Fidelity 2018
|
||||
//
|
||||
// Licensed under the Apache 2.0 License
|
||||
// See accompanying license file or http://apache.org/
|
||||
//
|
||||
(function(){
|
||||
|
||||
var DESKTOP_IDENTIFIER = "-Desktop";
|
||||
var GAMEPAD_IDENTIFIER = "-Gamepad";
|
||||
var VIVE_IDENTIFIER = "-Vive";
|
||||
var RIFT_IDENTIFIER = "-Rift";
|
||||
var WEB_IDENTIFIER = "PlacesGif-Web";
|
||||
|
||||
var WEB_ENTITY_BASE_PROPERTIES = {
|
||||
"collidesWith" : "",
|
||||
"collisionMask" : 0,
|
||||
"dimensions" : { "x": 3.200000047683716, "y": 1.7999999523162842, "z": 0.009999999776482582 },
|
||||
"name" : WEB_IDENTIFIER,
|
||||
"position" : {"x" : -30.4076, "y" : -8.6587, "z" : 23.7510},
|
||||
"rotation" : {"w": 0.4576503336429596, "x": 0,"y": -0.88913494348526,"z": -0.0001273617090191692},
|
||||
"type": "Web",
|
||||
"userData": "{\"grabbableKey\":{\"grabbable\":false}}"
|
||||
};
|
||||
|
||||
|
||||
var GIF_DESKTOP_URL = "https://giphy.com/gifs/8YBtsBiuQHnnlyaOaa/html5";
|
||||
var GIF_VIVE_URL = "https://giphy.com/gifs/uBaEMA7WDBvwvUpfab/html5";
|
||||
var GIF_RIFT_URL = "https://giphy.com/gifs/uBaEMA7WDBvwvUpfab/html5";
|
||||
var GIF_GAMEPAD_URL = "https://giphy.com/gifs/uBaEMA7WDBvwvUpfab/html5";
|
||||
|
||||
var HMD_SOUND_URL = 'file:///~/assets/sounds/PlacesAudio-HMD.wav';
|
||||
var DESKTOP_SOUND_URL = 'file:///~/assets/sounds/PlacesAudio-Desktop.wav';
|
||||
|
||||
var HMD_SOUND = SoundCache.getSound(HMD_SOUND_URL);
|
||||
var DESKTOP_SOUND = SoundCache.getSound(DESKTOP_SOUND_URL);
|
||||
|
||||
var audioPlaying;
|
||||
var position;
|
||||
|
||||
var desktopEntities = [];
|
||||
var gamePadEntities = [];
|
||||
var viveEntities = [];
|
||||
var riftEntities = [];
|
||||
var webGifEntity;
|
||||
|
||||
var wantDebug = false;
|
||||
|
||||
var ZoneItem = function(){
|
||||
|
||||
};
|
||||
|
||||
var makeVisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: true });
|
||||
};
|
||||
|
||||
var makeInvisible = function(entity) {
|
||||
Entities.editEntity(entity, { visible: false });
|
||||
};
|
||||
|
||||
var showPanelsForDesktop = function() {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
// We have a game pad
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing game pad entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(WEB_ENTITY_BASE_PROPERTIES);
|
||||
|
||||
} else {
|
||||
desktopEntities.forEach(function(element) {
|
||||
if (wantDebug) {
|
||||
print("Showing only desktop entities");
|
||||
}
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_DESKTOP_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var showPanelsForVR = function(deviceType) {
|
||||
var webEntityProperties = WEB_ENTITY_BASE_PROPERTIES;
|
||||
switch (deviceType) {
|
||||
case "Rift" :
|
||||
if (!(typeof(Controller.Hardware.GamePad) === 'undefined')) {
|
||||
if (wantDebug) {
|
||||
print("Showing Gamepad entities for Rift");
|
||||
}
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_GAMEPAD_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
|
||||
} else {
|
||||
if (wantDebug) {
|
||||
print("Showing Rift hand controller entities");
|
||||
}
|
||||
riftEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_RIFT_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Assume hand controllers are present for OpenVR devices
|
||||
if (wantDebug) {
|
||||
print("Showing hand controller entities for Vive");
|
||||
}
|
||||
viveEntities.forEach(function(element) {
|
||||
makeVisible(element);
|
||||
});
|
||||
webEntityProperties.sourceUrl = GIF_VIVE_URL;
|
||||
webGifEntity = Entities.addEntity(webEntityProperties);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var setDisplayType = function() {
|
||||
if (!HMD.active) {
|
||||
// Desktop mode, because not in VR
|
||||
showPanelsForDesktop();
|
||||
} else {
|
||||
var deviceType = HMD.isHMDAvailable("Oculus Rift") ? "Rift" : "Vive";
|
||||
showPanelsForVR(deviceType);
|
||||
}
|
||||
};
|
||||
|
||||
var hideAllElements = function() {
|
||||
desktopEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
viveEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
gamePadEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
|
||||
riftEntities.forEach(function(element) {
|
||||
makeInvisible(element);
|
||||
});
|
||||
Entities.deleteEntity(webGifEntity);
|
||||
webGifEntity = "";
|
||||
};
|
||||
|
||||
ZoneItem.prototype = {
|
||||
preload: function(entityID) {
|
||||
position = Entities.getEntityProperties(entityID, 'position').position;
|
||||
},
|
||||
enterEntity: function() {
|
||||
var nearbyEntities = Entities.findEntities(position, 10);
|
||||
nearbyEntities.forEach(function(element) {
|
||||
var elementName = Entities.getEntityProperties(element, 'name').name;
|
||||
if (wantDebug) {
|
||||
print ("Found entity with name: " + elementName);
|
||||
}
|
||||
if (elementName.indexOf(DESKTOP_IDENTIFIER) !== -1) {
|
||||
desktopEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to desktop");
|
||||
}
|
||||
} else if (elementName.indexOf(GAMEPAD_IDENTIFIER) !== -1) {
|
||||
gamePadEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to gamepad");
|
||||
}
|
||||
} else if (elementName.indexOf(VIVE_IDENTIFIER) !== -1) {
|
||||
viveEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to vive");
|
||||
}
|
||||
} else if (elementName.indexOf(RIFT_IDENTIFIER) !== -1) {
|
||||
riftEntities.push(element);
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " to rift");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
webGifEntity = element;
|
||||
if (wantDebug) {
|
||||
print("Added" + element + " as the web entity");
|
||||
}
|
||||
} else if (elementName.indexOf(WEB_IDENTIFIER) !== -1) {
|
||||
Entities.deleteEntity(element); // clean up old web entity
|
||||
}
|
||||
});
|
||||
setDisplayType();
|
||||
if (HMD.active) {
|
||||
if (HMD_SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(HMD_SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (DESKTOP_SOUND.downloaded) {
|
||||
audioPlaying = Audio.playSound(DESKTOP_SOUND, {
|
||||
position: MyAvatar.position,
|
||||
volume: 1.0,
|
||||
localOnly: true
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
leaveEntity: function() {
|
||||
hideAllElements();
|
||||
if (audioPlaying) {
|
||||
audioPlaying.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
return new ZoneItem();
|
||||
|
||||
});
|
BIN
interface/resources/assets/skyboxes/Skybox-Sun-high.png
Normal file
After Width: | Height: | Size: 4.1 MiB |
BIN
interface/resources/assets/sounds/AvatarAudio.wav
Normal file
BIN
interface/resources/assets/sounds/BubbleAudio-Desktop.wav
Normal file
BIN
interface/resources/assets/sounds/BubbleAudio-HMD.wav
Normal file
BIN
interface/resources/assets/sounds/GrabbingAudio.wav
Normal file
BIN
interface/resources/assets/sounds/MenuAudio-Desktop.wav
Normal file
BIN
interface/resources/assets/sounds/MenuAudio-HMD.wav
Normal file
BIN
interface/resources/assets/sounds/MovementAudio.wav
Normal file
BIN
interface/resources/assets/sounds/PlacesAudio-Desktop.wav
Normal file
BIN
interface/resources/assets/sounds/PlacesAudio-HMD.wav
Normal file
BIN
interface/resources/assets/textures/MovementSnapturn-Touch.png
Normal file
After Width: | Height: | Size: 148 KiB |
BIN
interface/resources/assets/textures/MovementSnapturn-Vive.png
Normal file
After Width: | Height: | Size: 206 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 39 KiB |