Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh #8

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172,636 changes: 47,884 additions & 124,752 deletions assets/bundles/browser.js

Large diffs are not rendered by default.

435 changes: 218 additions & 217 deletions assets/index.html

Large diffs are not rendered by default.

2,928 changes: 2,345 additions & 583 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"homepage": "https://github.com/FabricLabs/verse#readme",
"dependencies": {
"@fabric/core": "FabricLabs/fabric#feature/v0.1.0-RC1",
"@fabric/http": "FabricLabs/fabric-http#feature/graphql",
"@fabric/http": "FabricLabs/fabric-http#feature/v0.1.0-RC1",
"@webcomponents/custom-elements": "1.6.0",
"aframe": "^1.4.2",
"canvas": "2.11.0",
"fast-json-patch": "3.1.1",
"is-my-json-valid": "2.20.6",
"querystring-es3": "0.2.1",
"three": "0.151.2"
"querystring-es3": "0.2.1"
},
"devDependencies": {
"babel-loader": "8.2.5",
Expand Down
9 changes: 6 additions & 3 deletions reports/install.log
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
$ npm i

added 870 packages, and audited 871 packages in 3m
added 1048 packages, and audited 1049 packages in 2m

76 packages are looking for funding
87 packages are looking for funding
run `npm fund` for details

14 vulnerabilities (2 moderate, 10 high, 2 critical)
25 vulnerabilities (8 moderate, 15 high, 2 critical)

To address issues that do not require attention, run:
npm audit fix

To address all issues possible (including breaking changes), run:
npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Expand Down
55 changes: 49 additions & 6 deletions scripts/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ const {
STARTING_POSITION
} = require('../constants');

const THREE = require('three');
// const dat = require('dat.gui');
const settings = require('../settings/local');

// 3D Frameworks
const AFRAME = require('aframe');
const THREE = AFRAME.THREE;

// const { OrbitControls } = require('three/examples/jsm/controls/OrbitControls');
// const { ImprovedNoise } = require('three/examples/jsm/math/ImprovedNoise');
Expand All @@ -21,7 +24,7 @@ const Message = require('@fabric/core/types/message');
const Player = require('../types/player');
const Universe = require('../types/universe');

const Sheet = require('../types/sheet');
// const Sheet = require('../types/sheet');
// const Place = require('../types/place');

const maybeEncounter = require('../functions/maybeEncounter');
Expand All @@ -39,6 +42,21 @@ async function _loadWASM () {
}

async function main (input) {
console.log('[VERSE:SPA]', 'main()', '...');

customElements.define('fabric-chat-bar', FabricChatBar);

/* const actor = new Actor({
settings: input
});

console.log('Actor:', actor);
console.log('Actor preimage:', actor.preimage);
console.log('Actor ID:', actor.id); */

// const engine = new Verse(input);
// document.write(engine.toHTML());

const site = document.getElementById('site');
const universe = new Universe();

Expand Down Expand Up @@ -95,6 +113,13 @@ async function main (input) {
air: null
};

// const logo = new Sheet({ size: 256 });
// const chunk = logo.getChunk();

// console.log('chunk:', chunk);
// const values = getPixelValues(chunk);
// console.log('values:', values);

// ### Player Instance
// Keep track of the current client's player object.
const player = new Player();
Expand Down Expand Up @@ -161,6 +186,12 @@ async function main (input) {
renderer.render(scene, camera);
}

function assumeCharacterView (character) {
console.log('assuming character view:', character);
$('#character-selection').fadeOut();
isViewingOverlay = false;
universe._syncPlaceID(character.location);
}

function createPlaneMesh () {
const group = new THREE.Group();
Expand Down Expand Up @@ -208,6 +239,7 @@ async function main (input) {

function createGhostMesh () {
const ghost = new THREE.Mesh(vehicleGeometry, ghostMaterial);
// const vehicleMixer = new THREE.AnimationMixer(vehicle);
return ghost;
}

Expand All @@ -231,9 +263,19 @@ async function main (input) {
$(`#${id}`).slideDown();
}

function createPreviewSprite (url = '/images/fabric-labs.png') {
const map = new THREE.TextureLoader().load(url);
const material = new THREE.SpriteMaterial({ map: map });
const sprite = new THREE.Sprite(material);
sprite.renderOrder = 10;
// sprite.scale.set(1, 1, 1);
return sprite;
}

function createVehicleMesh () {
const vehicle = new THREE.Mesh(vehicleGeometry, vehicleMaterial);
vehicle.add(vehicleGlow);
// const vehicleMixer = new THREE.AnimationMixer(vehicle);
return vehicle;
}

Expand Down Expand Up @@ -309,8 +351,7 @@ async function main (input) {

async function onDocumentKeyDown (event) {
if (event.code === 'Escape') {
$('#chat-input').fadeOut();
$('#console').slideUp();
$('#chat-input').blur();
isChatting = false;
}

Expand Down Expand Up @@ -368,6 +409,8 @@ async function main (input) {

$('#overlay').fadeOut();
$('#chat-input').fadeIn();

// $('#chat-input').fadeToggle();
$('#console').slideToggle();
$('#console').animate({
bottom: 0
Expand Down Expand Up @@ -738,7 +781,7 @@ async function main (input) {
};
}

main().catch((exception) => {
main(settings).catch((exception) => {
console.log('[VERSE] Error:', exception);
}).then((output) => {
window.verse = output;
Expand Down
5 changes: 2 additions & 3 deletions settings/local.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"hostname": "localhost",
"port": 9998
},
"networking": false,
"peers": [
"localhost:7778",
"hub.fabric.pub:7777",
"hub.roleplaygateway.com:9999"
"localhost:7778"
],
"resources": {
"Place": {
Expand Down
11 changes: 11 additions & 0 deletions types/place.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ class Place extends Actor {
return this.state.name;
}

get _RPGExitDestinationIDs () {
return [];
}

isSurroundedByRPGPlaceID (target) {
if (!target) return false;
if (!this._RPGExitDestinationIDs.includes(target)) return false;
// all normal exits lead to target
return true;
}

toHTML () {
return `
<verse-place class="ui card">
Expand Down
5 changes: 5 additions & 0 deletions types/site.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict';

const Peer = require('@fabric/core/types/peer');

// Fabric HTTP Types
const FabricSite = require('@fabric/http/types/site');
const SPA = require('@fabric/http/types/spa');

class Site extends FabricSite {
constructor (settings = {}) {
Expand All @@ -27,6 +30,8 @@ class Site extends FabricSite {
};

// Fabric Components
this.peer = new Peer(this.settings.fabric);
this.spa = new SPA(this.settings);
// this.bridge = new Bridge();

// Ensure chainability
Expand Down
5 changes: 3 additions & 2 deletions types/universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class RPGUniverse extends Actor {
}

registerPlayer (player) {
console.log('registering player:', player);
const actor = new Actor(player);
if (!this._state.content.players) this._state.content.players = {};
if (this.state.players[actor.id]) return actor.id;
Expand Down Expand Up @@ -196,7 +197,7 @@ class RPGUniverse extends Actor {
this.remote._GET(`/places/${_id}`).catch((exception) => {
this.emit('debug', `Could not sync place: ${exception}`);
reject(exception);
}).then((entity) => {
}).then(async (entity) => {
// console.log('entity:', entity);
if (!entity) return reject(new Error(`Place ID # ${_id} did not return a result: ${entity}`));

Expand All @@ -219,7 +220,7 @@ class RPGUniverse extends Actor {
from: _id,
to: exit.destination
});
// await this._syncPlaceID(exit.destination);
await this._syncPlaceID(exit.destination);
}

this.remote._GET(`/places/${_id}/characters`).then((characters) => {
Expand Down