mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 16:43:33 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into cauterize-head-av-entities-1
This commit is contained in:
commit
482be7ba4e
29 changed files with 113 additions and 31057 deletions
|
@ -453,7 +453,7 @@ void EntityServer::domainSettingsRequestFailed() {
|
|||
void EntityServer::startDynamicDomainVerification() {
|
||||
qCDebug(entities) << "Starting Dynamic Domain Verification...";
|
||||
|
||||
QString thisDomainID = DependencyManager::get<AddressManager>()->getDomainId().remove(QRegExp("\\{|\\}"));
|
||||
QString thisDomainID = DependencyManager::get<AddressManager>()->getDomainID().remove(QRegExp("\\{|\\}"));
|
||||
|
||||
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
||||
QHash<QString, EntityItemID> localMap(tree->getEntityCertificateIDMap());
|
||||
|
|
|
@ -282,7 +282,7 @@ Menu::Menu() {
|
|||
|
||||
// Navigate > Show Address Bar
|
||||
addActionToQMenuAndActionHash(navigateMenu, MenuOption::AddressBar, Qt::CTRL | Qt::Key_L,
|
||||
dialogsManager.data(), SLOT(toggleAddressBar()));
|
||||
dialogsManager.data(), SLOT(showAddressBar()));
|
||||
|
||||
// Navigate > LocationBookmarks related menus -- Note: the LocationBookmarks class adds its own submenus here.
|
||||
auto locationBookmarks = DependencyManager::get<LocationBookmarks>();
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddressBarDialog : public OffscreenQmlDialog {
|
|||
Q_PROPERTY(bool backEnabled READ backEnabled NOTIFY backEnabledChanged)
|
||||
Q_PROPERTY(bool forwardEnabled READ forwardEnabled NOTIFY forwardEnabledChanged)
|
||||
Q_PROPERTY(bool useFeed READ useFeed WRITE setUseFeed NOTIFY useFeedChanged)
|
||||
Q_PROPERTY(QString metaverseServerUrl READ metaverseServerUrl CONSTANT)
|
||||
Q_PROPERTY(QString metaverseServerUrl READ metaverseServerUrl)
|
||||
|
||||
public:
|
||||
AddressBarDialog(QQuickItem* parent = nullptr);
|
||||
|
|
|
@ -58,7 +58,7 @@ void DialogsManager::showAddressBar() {
|
|||
hmd->openTablet();
|
||||
}
|
||||
qApp->setKeyboardFocusOverlay(hmd->getCurrentTabletScreenID());
|
||||
setAddressBarVisible(true);
|
||||
emit addressBarShown(true);
|
||||
}
|
||||
|
||||
void DialogsManager::hideAddressBar() {
|
||||
|
@ -71,7 +71,7 @@ void DialogsManager::hideAddressBar() {
|
|||
hmd->closeTablet();
|
||||
}
|
||||
qApp->setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
|
||||
setAddressBarVisible(false);
|
||||
emit addressBarShown(false);
|
||||
}
|
||||
|
||||
void DialogsManager::showFeed() {
|
||||
|
@ -157,24 +157,6 @@ void DialogsManager::hmdToolsClosed() {
|
|||
}
|
||||
}
|
||||
|
||||
void DialogsManager::toggleAddressBar() {
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
|
||||
const bool addressBarLoaded = tablet->isPathLoaded(TABLET_ADDRESS_DIALOG);
|
||||
|
||||
if (_addressBarVisible || addressBarLoaded) {
|
||||
hideAddressBar();
|
||||
} else {
|
||||
showAddressBar();
|
||||
}
|
||||
}
|
||||
|
||||
void DialogsManager::setAddressBarVisible(bool addressBarVisible) {
|
||||
_addressBarVisible = addressBarVisible;
|
||||
emit addressBarShown(_addressBarVisible);
|
||||
}
|
||||
|
||||
void DialogsManager::showTestingResults() {
|
||||
if (!_testingDialog) {
|
||||
_testingDialog = new TestingDialog(qApp->getWindow());
|
||||
|
|
|
@ -39,7 +39,6 @@ public:
|
|||
QPointer<OctreeStatsDialog> getOctreeStatsDialog() const { return _octreeStatsDialog; }
|
||||
QPointer<TestingDialog> getTestingDialog() const { return _testingDialog; }
|
||||
void emitAddressBarShown(bool visible) { emit addressBarShown(visible); }
|
||||
void setAddressBarVisible(bool addressBarVisible);
|
||||
|
||||
public slots:
|
||||
void showAddressBar();
|
||||
|
@ -53,7 +52,6 @@ public slots:
|
|||
void hmdTools(bool showTools);
|
||||
void showDomainConnectionDialog();
|
||||
void showTestingResults();
|
||||
void toggleAddressBar();
|
||||
|
||||
// Application Update
|
||||
void showUpdateDialog();
|
||||
|
@ -80,7 +78,7 @@ private:
|
|||
QPointer<OctreeStatsDialog> _octreeStatsDialog;
|
||||
QPointer<TestingDialog> _testingDialog;
|
||||
QPointer<DomainConnectionDialog> _domainConnectionDialog;
|
||||
bool _addressBarVisible { false };
|
||||
bool _closeAddressBar { false };
|
||||
};
|
||||
|
||||
#endif // hifi_DialogsManager_h
|
||||
|
|
|
@ -72,13 +72,6 @@ Web3DOverlay::Web3DOverlay() {
|
|||
connect(this, &Web3DOverlay::requestWebSurface, this, &Web3DOverlay::buildWebSurface);
|
||||
connect(this, &Web3DOverlay::releaseWebSurface, this, &Web3DOverlay::destroyWebSurface);
|
||||
connect(this, &Web3DOverlay::resizeWebSurface, this, &Web3DOverlay::onResizeWebSurface);
|
||||
|
||||
//need to be intialized before Tablet 1st open
|
||||
_webSurface = DependencyManager::get<OffscreenQmlSurfaceCache>()->acquire(_url);
|
||||
_webSurface->getSurfaceContext()->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Account", GlobalServicesScriptingInterface::getInstance());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data());
|
||||
|
||||
}
|
||||
|
||||
Web3DOverlay::Web3DOverlay(const Web3DOverlay* Web3DOverlay) :
|
||||
|
|
|
@ -192,7 +192,11 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<FBXJoint>& joints)
|
|||
_nonMirroredIndices.clear();
|
||||
_mirrorMap.reserve(_jointsSize);
|
||||
for (int i = 0; i < _jointsSize; i++) {
|
||||
if (_joints[i].name.endsWith("tEye")) {
|
||||
if (_joints[i].name != "Hips" && _joints[i].name != "Spine" &&
|
||||
_joints[i].name != "Spine1" && _joints[i].name != "Spine2" &&
|
||||
_joints[i].name != "Neck" && _joints[i].name != "Head" &&
|
||||
!((_joints[i].name.startsWith("Left") || _joints[i].name.startsWith("Right")) &&
|
||||
_joints[i].name != "LeftEye" && _joints[i].name != "RightEye")) {
|
||||
// HACK: we don't want to mirror some joints so we remember their indices
|
||||
// so we can restore them after a future mirror operation
|
||||
_nonMirroredIndices.push_back(i);
|
||||
|
|
|
@ -23,25 +23,31 @@
|
|||
#include <shared/GlobalAppProperties.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include "GLLogging.h"
|
||||
#include "Config.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
#if defined(DEBUG) || defined(USE_GLES)
|
||||
static bool enableDebugLogger = true;
|
||||
#else
|
||||
static const QString DEBUG_FLAG("HIFI_DEBUG_OPENGL");
|
||||
static bool enableDebugLogger = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "Config.h"
|
||||
#include "GLHelpers.h"
|
||||
|
||||
using namespace gl;
|
||||
|
||||
|
||||
bool Context::enableDebugLogger() {
|
||||
#if defined(DEBUG) || defined(USE_GLES)
|
||||
static bool enableDebugLogger = true;
|
||||
#else
|
||||
static const QString DEBUG_FLAG("HIFI_DEBUG_OPENGL");
|
||||
static bool enableDebugLogger = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
|
||||
#endif
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&] {
|
||||
// If the previous run crashed, force GL debug logging on
|
||||
if (qApp->property(hifi::properties::CRASHED).toBool()) {
|
||||
enableDebugLogger = true;
|
||||
}
|
||||
});
|
||||
return enableDebugLogger;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::atomic<size_t> Context::_totalSwapchainMemoryUsage { 0 };
|
||||
|
||||
size_t Context::getSwapchainMemoryUsage() { return _totalSwapchainMemoryUsage.load(); }
|
||||
|
@ -245,10 +251,6 @@ void Context::create() {
|
|||
// Create a temporary context to initialize glew
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&] {
|
||||
// If the previous run crashed, force GL debug logging on
|
||||
if (qApp->property(hifi::properties::CRASHED).toBool()) {
|
||||
enableDebugLogger = true;
|
||||
}
|
||||
auto hdc = GetDC(hwnd);
|
||||
setupPixelFormatSimple(hdc);
|
||||
auto glrc = wglCreateContext(hdc);
|
||||
|
@ -328,7 +330,7 @@ void Context::create() {
|
|||
contextAttribs.push_back(WGL_CONTEXT_CORE_PROFILE_BIT_ARB);
|
||||
#endif
|
||||
contextAttribs.push_back(WGL_CONTEXT_FLAGS_ARB);
|
||||
if (enableDebugLogger) {
|
||||
if (enableDebugLogger()) {
|
||||
contextAttribs.push_back(WGL_CONTEXT_DEBUG_BIT_ARB);
|
||||
} else {
|
||||
contextAttribs.push_back(0);
|
||||
|
@ -350,7 +352,7 @@ void Context::create() {
|
|||
if (!makeCurrent()) {
|
||||
throw std::runtime_error("Could not make context current");
|
||||
}
|
||||
if (enableDebugLogger) {
|
||||
if (enableDebugLogger()) {
|
||||
glDebugMessageCallback(debugMessageCallback, NULL);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace gl {
|
|||
Context(const Context& other);
|
||||
|
||||
public:
|
||||
static bool enableDebugLogger();
|
||||
Context();
|
||||
Context(QWindow* window);
|
||||
void release();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QOffscreenSurface>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtGui/QOpenGLDebugLogger>
|
||||
|
||||
#include "Context.h"
|
||||
#include "GLHelpers.h"
|
||||
|
@ -68,9 +69,32 @@ bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
|
|||
}
|
||||
#endif
|
||||
|
||||
if (gl::Context::enableDebugLogger()) {
|
||||
_context->makeCurrent(_offscreenSurface);
|
||||
QOpenGLDebugLogger *logger = new QOpenGLDebugLogger(this);
|
||||
connect(logger, &QOpenGLDebugLogger::messageLogged, this, &OffscreenGLCanvas::onMessageLogged);
|
||||
logger->initialize();
|
||||
logger->enableMessages();
|
||||
logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
|
||||
_context->doneCurrent();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OffscreenGLCanvas::onMessageLogged(const QOpenGLDebugMessage& debugMessage) {
|
||||
auto severity = debugMessage.severity();
|
||||
switch (severity) {
|
||||
case QOpenGLDebugMessage::NotificationSeverity:
|
||||
case QOpenGLDebugMessage::LowSeverity:
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
qDebug(glLogging) << debugMessage;
|
||||
return;
|
||||
}
|
||||
|
||||
bool OffscreenGLCanvas::makeCurrent() {
|
||||
bool result = _context->makeCurrent(_offscreenSurface);
|
||||
std::call_once(_reportOnce, []{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
class QOpenGLContext;
|
||||
class QOffscreenSurface;
|
||||
class QOpenGLDebugLogger;
|
||||
class QOpenGLDebugMessage;
|
||||
|
||||
class OffscreenGLCanvas : public QObject {
|
||||
public:
|
||||
|
@ -32,6 +32,9 @@ public:
|
|||
}
|
||||
QObject* getContextObject();
|
||||
|
||||
private slots:
|
||||
void onMessageLogged(const QOpenGLDebugMessage &debugMessage);
|
||||
|
||||
protected:
|
||||
std::once_flag _reportOnce;
|
||||
QOpenGLContext* _context{ nullptr };
|
||||
|
|
|
@ -776,7 +776,7 @@ void AddressManager::copyPath() {
|
|||
QApplication::clipboard()->setText(currentPath());
|
||||
}
|
||||
|
||||
QString AddressManager::getDomainId() const {
|
||||
QString AddressManager::getDomainID() const {
|
||||
return DependencyManager::get<NodeList>()->getDomainHandler().getUUID().toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,11 @@ const QString GET_PLACE = "/api/v1/places/%1";
|
|||
* The location API provides facilities related to your current location in the metaverse.
|
||||
*
|
||||
* @namespace location
|
||||
* @property {Uuid} domainId - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid|Uuid.NULL} if you're not
|
||||
* @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid|Uuid.NULL} if you're not
|
||||
* connected to the domain.
|
||||
* <em>Read-only.</em>
|
||||
* @property {Uuid} domainId - Synonym for <code>domainId</code>. <em>Read-only.</em> <strong>Deprecated:</strong> This property
|
||||
* is deprecated and will soon be removed.
|
||||
* @property {string} hostname - The name of the domain for your current metaverse address (e.g., <code>"AvatarIsland"</code>,
|
||||
* <code>localhost</code>, or an IP address).
|
||||
* <em>Read-only.</em>
|
||||
|
@ -66,7 +68,8 @@ class AddressManager : public QObject, public Dependency {
|
|||
Q_PROPERTY(QString hostname READ getHost)
|
||||
Q_PROPERTY(QString pathname READ currentPath)
|
||||
Q_PROPERTY(QString placename READ getPlaceName)
|
||||
Q_PROPERTY(QString domainId READ getDomainId)
|
||||
Q_PROPERTY(QString domainID READ getDomainID)
|
||||
Q_PROPERTY(QString domainId READ getDomainID)
|
||||
public:
|
||||
|
||||
/**jsdoc
|
||||
|
@ -164,7 +167,7 @@ public:
|
|||
|
||||
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
||||
const QString& getPlaceName() const { return _shareablePlaceName.isEmpty() ? _placeName : _shareablePlaceName; }
|
||||
QString getDomainId() const;
|
||||
QString getDomainID() const;
|
||||
|
||||
const QString& getHost() const { return _host; }
|
||||
|
||||
|
|
|
@ -99,7 +99,9 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambie
|
|||
|
||||
// Diffuse from ambient
|
||||
diffuse = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), lowNormalCurvature.xyz).xyz;
|
||||
specular = vec3(0.0);
|
||||
|
||||
// Scattering ambient specular is the same as non scattering for now
|
||||
// TODO: we should use the same specular answer as for direct lighting
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
|
|
|
@ -543,6 +543,7 @@ void OffscreenQmlSurface::cleanup() {
|
|||
|
||||
void OffscreenQmlSurface::render() {
|
||||
#if !defined(DISABLE_QML)
|
||||
|
||||
if (nsightActive()) {
|
||||
return;
|
||||
}
|
||||
|
@ -569,14 +570,18 @@ void OffscreenQmlSurface::render() {
|
|||
|
||||
{
|
||||
// If the most recent texture was unused, we can directly recycle it
|
||||
if (_latestTextureAndFence.first) {
|
||||
offscreenTextures.releaseTexture(_latestTextureAndFence);
|
||||
_latestTextureAndFence = { 0, 0 };
|
||||
}
|
||||
|
||||
_latestTextureAndFence = { texture, glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0) };
|
||||
auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
// Fence will be used in another thread / context, so a flush is required
|
||||
glFlush();
|
||||
|
||||
{
|
||||
Lock lock(_latestTextureAndFenceMutex);
|
||||
if (_latestTextureAndFence.first) {
|
||||
offscreenTextures.releaseTexture(_latestTextureAndFence);
|
||||
_latestTextureAndFence = { 0, 0 };
|
||||
}
|
||||
_latestTextureAndFence = { texture, fence};
|
||||
}
|
||||
}
|
||||
|
||||
_quickWindow->resetOpenGLState();
|
||||
|
@ -588,13 +593,21 @@ void OffscreenQmlSurface::render() {
|
|||
bool OffscreenQmlSurface::fetchTexture(TextureAndFence& textureAndFence) {
|
||||
textureAndFence = { 0, 0 };
|
||||
|
||||
// Lock free early check
|
||||
if (0 == _latestTextureAndFence.first) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure writes to the latest texture are complete before before returning it for reading
|
||||
textureAndFence = _latestTextureAndFence;
|
||||
_latestTextureAndFence = { 0, 0 };
|
||||
{
|
||||
Lock lock(_latestTextureAndFenceMutex);
|
||||
// Double check inside the lock
|
||||
if (0 == _latestTextureAndFence.first) {
|
||||
return false;
|
||||
}
|
||||
textureAndFence = _latestTextureAndFence;
|
||||
_latestTextureAndFence = { 0, 0 };
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -813,10 +826,13 @@ void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) {
|
|||
|
||||
// Release hold on the textures of the old size
|
||||
if (uvec2() != _size) {
|
||||
// If the most recent texture was unused, we can directly recycle it
|
||||
if (_latestTextureAndFence.first) {
|
||||
offscreenTextures.releaseTexture(_latestTextureAndFence);
|
||||
_latestTextureAndFence = { 0, 0 };
|
||||
{
|
||||
Lock lock(_latestTextureAndFenceMutex);
|
||||
// If the most recent texture was unused, we can directly recycle it
|
||||
if (_latestTextureAndFence.first) {
|
||||
offscreenTextures.releaseTexture(_latestTextureAndFence);
|
||||
_latestTextureAndFence = { 0, 0 };
|
||||
}
|
||||
}
|
||||
offscreenTextures.releaseSize(_size);
|
||||
}
|
||||
|
|
|
@ -167,6 +167,9 @@ public slots:
|
|||
bool handlePointerEvent(const PointerEvent& event, class QTouchDevice& device, bool release = false);
|
||||
|
||||
private:
|
||||
using Mutex = std::mutex;
|
||||
using Lock = std::unique_lock<std::mutex>;
|
||||
|
||||
QQuickWindow* _quickWindow { nullptr };
|
||||
QQmlContext* _qmlContext { nullptr };
|
||||
QQuickItem* _rootItem { nullptr };
|
||||
|
@ -188,6 +191,7 @@ private:
|
|||
#endif
|
||||
|
||||
// Texture management
|
||||
Mutex _latestTextureAndFenceMutex;
|
||||
TextureAndFence _latestTextureAndFence { 0, 0 };
|
||||
|
||||
bool _render { false };
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
/node_modules
|
|
@ -1 +0,0 @@
|
|||
web: node app.js
|
|
@ -1,5 +0,0 @@
|
|||
This gameserver sets up a server with websockets that listen for messages from interface regarding when users shoot rats, and updates a real-time game board with that information. This is just a first pass, and the plan is to abstract this to work with any kind of game content creators wish to make with High Fidelity.
|
||||
|
||||
To enter the game: Run pistol.js and shoot at rats.
|
||||
For every rat you kill, you get a point.
|
||||
You're score will be displayed at https://desolate-bastion-1742.herokuapp.com/
|
|
@ -1,76 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var express = require('express');
|
||||
var http = require('http');
|
||||
var _ = require('underscore');
|
||||
var shortid = require('shortid');
|
||||
|
||||
|
||||
var app = express();
|
||||
var server = http.createServer(app);
|
||||
|
||||
var WebSocketServer = require('websocket').server;
|
||||
var wsServer = new WebSocketServer({
|
||||
httpServer: server
|
||||
});
|
||||
|
||||
var users = [];
|
||||
var connections = [];
|
||||
wsServer.on('request', function(request) {
|
||||
console.log("SOMEONE JOINED");
|
||||
var connection = request.accept(null, request.origin);
|
||||
connections.push(connection);
|
||||
connection.on('message', function(data) {
|
||||
var userData = JSON.parse(data.utf8Data);
|
||||
var user = _.find(users, function(user) {
|
||||
return user.username === userData.username;
|
||||
});
|
||||
if (user) {
|
||||
// This user already exists, so just update score
|
||||
users[users.indexOf(user)].score = userData.score;
|
||||
} else {
|
||||
users.push({
|
||||
id: shortid.generate(),
|
||||
username: userData.username,
|
||||
score: userData.score
|
||||
});
|
||||
}
|
||||
connections.forEach(function(aConnection) {
|
||||
aConnection.sendUTF(JSON.stringify({
|
||||
users: users
|
||||
}));
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/users', function(req, res) {
|
||||
res.send({
|
||||
users: users
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* Configuration */
|
||||
app.set('views', __dirname + '/views');
|
||||
app.use(express.static(__dirname + '/public'));
|
||||
app.set('port', (process.env.PORT || 5000));
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
app.use(express.errorHandler({
|
||||
dumpExceptions: true,
|
||||
showStack: true
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
/* Start server */
|
||||
server.listen(app.get('port'), function() {
|
||||
console.log('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
|
||||
});
|
||||
|
||||
module.exports = app;
|
|
@ -1,87 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var _ = require('underscore')
|
||||
var $ = require('jquery');
|
||||
|
||||
var UserList = React.createClass({
|
||||
render: function(){
|
||||
var sortedUsers = _.sortBy(this.props.data.users, function(users){
|
||||
//Show higher scorers at top of board
|
||||
return 1 - users.score;
|
||||
});
|
||||
var users = sortedUsers.map(function(user) {
|
||||
|
||||
return (
|
||||
<User username = {user.username} score = {user.score} key = {user.id}></User>
|
||||
)
|
||||
});
|
||||
return (
|
||||
<div>{users}</div>
|
||||
)
|
||||
}
|
||||
});
|
||||
|
||||
var GameBoard = React.createClass({
|
||||
loadDataFromServer: function(data) {
|
||||
$.ajax({
|
||||
url: this.props.url,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
this.setState({data: data});
|
||||
}.bind(this),
|
||||
error: function(xhr, status, err) {
|
||||
console.error(this.props.url, status, err.toString());
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
getInitialState: function() {
|
||||
return {data: {users: []}};
|
||||
},
|
||||
componentDidMount: function() {
|
||||
this.loadDataFromServer();
|
||||
//set up web socket
|
||||
var path = window.location.hostname + ":" + window.location.port;
|
||||
console.log("LOCATION ", path)
|
||||
var socketClient = new WebSocket("wss://" + path);
|
||||
var self = this;
|
||||
socketClient.onopen = function() {
|
||||
console.log("CONNECTED");
|
||||
socketClient.onmessage = function(data) {
|
||||
console.log("ON MESSAGE");
|
||||
self.setState({data: JSON.parse(data.data)});
|
||||
};
|
||||
};
|
||||
|
||||
},
|
||||
render: function() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className = "gameTitle">Kill All The Rats!</div>
|
||||
<div className = "boardHeader">
|
||||
<div className="username">PLAYER</div>
|
||||
<div className="score" > SCORE </div>
|
||||
</div>
|
||||
<UserList data ={this.state.data}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var User = React.createClass({
|
||||
render: function() {
|
||||
return (
|
||||
<div className = "entry">
|
||||
<div className="username"> {this.props.username} </div>
|
||||
<div className="score" > {this.props.score} </div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
})
|
||||
|
||||
React.render(
|
||||
<GameBoard url = "/users" />,
|
||||
document.getElementById('app')
|
||||
);
|
|
@ -1,15 +0,0 @@
|
|||
var gulp = require('gulp');
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
gulp.task('build', function() {
|
||||
exec('npm run build', function(msg){
|
||||
console.log(msg);
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch('client/*.jsx', ['build']);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('default', ['build', 'watch'])
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"name": "KillAllTheRats",
|
||||
"version": "0.6.9",
|
||||
"scripts": {
|
||||
"build": "browserify ./client/app.jsx -t babelify --outfile ./public/js/app.js",
|
||||
"start": "node app.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.13.1",
|
||||
"gulp": "^3.9.0",
|
||||
"jquery": "^2.1.4",
|
||||
"react": "^0.13.3",
|
||||
"shortid": "^2.2.4",
|
||||
"underscore": "^1.8.3",
|
||||
"websocket": "^1.0.22"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babelify": "^6.1.3",
|
||||
"browserify": "^10.2.6"
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
body {
|
||||
font-family: Impact;
|
||||
background-color: #009DC0 ;
|
||||
font-size: 60px;
|
||||
}
|
||||
|
||||
.gameTitle {
|
||||
color: #D61010;
|
||||
}
|
||||
|
||||
.entry{
|
||||
width:100%;
|
||||
height:50px;
|
||||
border:1px solid #A9D1E1;
|
||||
color: white;
|
||||
margin-right:10px;
|
||||
padding: 10px;
|
||||
float:left;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.boardHeader{
|
||||
width:100%;
|
||||
height:50px;
|
||||
border:5px solid #A9D1E1;
|
||||
color: white;
|
||||
margin-right:10px;
|
||||
padding: 10px;
|
||||
float:left;
|
||||
font-size: 40px;
|
||||
}
|
||||
.username{
|
||||
font-weight: bold;
|
||||
float: left;
|
||||
margin-right: 50%;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<title>Kill The Rats!</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load diff
|
@ -1,31 +0,0 @@
|
|||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation())));
|
||||
var scriptURL = Script.resolvePath("pistolScriptSpawner.js");
|
||||
var modelURL = "http://s3.amazonaws.com/hifi-public/cozza13/gun/m1911-handgun+1.fbx";
|
||||
var pistolSpawnerEntity = Entities.addEntity({
|
||||
type: 'Box',
|
||||
position: center,
|
||||
dimensions: {x: 0.38, y: 1.9, z: 3.02},
|
||||
script: scriptURL,
|
||||
visible: false,
|
||||
collisionless: true
|
||||
});
|
||||
|
||||
var pistol = Entities.addEntity({
|
||||
type: 'Model',
|
||||
modelURL: modelURL,
|
||||
position: center,
|
||||
dimensions: {x: 0.38, y: 1.9, z: 3.02},
|
||||
script: scriptURL,
|
||||
color: {red: 200, green: 0, blue: 20},
|
||||
collisionless: true
|
||||
});
|
||||
|
||||
|
||||
|
||||
function cleanup() {
|
||||
Entities.deleteEntity(pistolSpawnerEntity);
|
||||
Entities.deleteEntity(pistol);
|
||||
}
|
||||
|
||||
// Script.update.connect(update);
|
||||
Script.scriptEnding.connect(cleanup);
|
|
@ -493,7 +493,7 @@ function populateNearbyUserList(selectData, oldAudioData) {
|
|||
data.push(avatarPalDatum);
|
||||
print('PAL data:', JSON.stringify(avatarPalDatum));
|
||||
});
|
||||
getConnectionData(false, location.domainId); // Even admins don't get relationship data in requestUsernameFromID (which is still needed for admin status, which comes from domain).
|
||||
getConnectionData(false, location.domainID); // Even admins don't get relationship data in requestUsernameFromID (which is still needed for admin status, which comes from domain).
|
||||
conserveResources = Object.keys(avatarsOfInterest).length > 20;
|
||||
sendToQml({ method: 'nearbyUsers', params: data });
|
||||
if (selectData) {
|
||||
|
|
|
@ -337,7 +337,7 @@ function fillImageDataFromPrevious() {
|
|||
containsGif: previousAnimatedSnapPath !== "",
|
||||
processingGif: false,
|
||||
shouldUpload: false,
|
||||
canBlast: location.domainId === Settings.getValue("previousSnapshotDomainID"),
|
||||
canBlast: location.domainID === Settings.getValue("previousSnapshotDomainID"),
|
||||
isLoggedIn: isLoggedIn
|
||||
};
|
||||
imageData = [];
|
||||
|
@ -416,7 +416,7 @@ function snapshotUploaded(isError, reply) {
|
|||
}
|
||||
isUploadingPrintableStill = false;
|
||||
}
|
||||
var href, domainId;
|
||||
var href, domainID;
|
||||
function takeSnapshot() {
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
type: "snapshot",
|
||||
|
@ -443,11 +443,11 @@ function takeSnapshot() {
|
|||
MyAvatar.setClearOverlayWhenMoving(false);
|
||||
|
||||
// We will record snapshots based on the starting location. That could change, e.g., when recording a .gif.
|
||||
// Even the domainId could change (e.g., if the user falls into a teleporter while recording).
|
||||
// Even the domainID could change (e.g., if the user falls into a teleporter while recording).
|
||||
href = location.href;
|
||||
Settings.setValue("previousSnapshotHref", href);
|
||||
domainId = location.domainId;
|
||||
Settings.setValue("previousSnapshotDomainID", domainId);
|
||||
domainID = location.domainID;
|
||||
Settings.setValue("previousSnapshotDomainID", domainID);
|
||||
|
||||
maybeDeleteSnapshotStories();
|
||||
|
||||
|
@ -548,7 +548,7 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
|
|||
}
|
||||
HMD.openTablet();
|
||||
|
||||
isDomainOpen(domainId, function (canShare) {
|
||||
isDomainOpen(domainID, function (canShare) {
|
||||
snapshotOptions = {
|
||||
containsGif: false,
|
||||
processingGif: false,
|
||||
|
@ -594,7 +594,7 @@ function processingGifStarted(pathStillSnapshot) {
|
|||
}
|
||||
HMD.openTablet();
|
||||
|
||||
isDomainOpen(domainId, function (canShare) {
|
||||
isDomainOpen(domainID, function (canShare) {
|
||||
snapshotOptions = {
|
||||
containsGif: true,
|
||||
processingGif: true,
|
||||
|
@ -622,13 +622,13 @@ function processingGifCompleted(pathAnimatedSnapshot) {
|
|||
|
||||
Settings.setValue("previousAnimatedSnapPath", pathAnimatedSnapshot);
|
||||
|
||||
isDomainOpen(domainId, function (canShare) {
|
||||
isDomainOpen(domainID, function (canShare) {
|
||||
snapshotOptions = {
|
||||
containsGif: true,
|
||||
processingGif: false,
|
||||
canShare: canShare,
|
||||
isLoggedIn: isLoggedIn,
|
||||
canBlast: location.domainId === Settings.getValue("previousSnapshotDomainID"),
|
||||
canBlast: location.domainID === Settings.getValue("previousSnapshotDomainID"),
|
||||
};
|
||||
imageData = [{ localPath: pathAnimatedSnapshot, href: href }];
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
|
|
Loading…
Reference in a new issue