Code Monkey home page Code Monkey logo

blocks's Introduction

screenshot

Create your own server in two steps:

  • Remix glitch.com/~blocks-server
  • Set this variables on the .env file:
    • NAME the server name (for the public registry)
    • SEED 16bit world generation seed. (0 - 65535)

If you want to experiment with world generation:

You can also use docker-compose if you already own a more powerful server:

version: '3'
services:
  server:
    image: danigatunes/blocks:latest
    environment:
     - NAME=Your Server Name
     - PRELOAD=10
     - PUBLIC_URL=https://yourserver.url/
     - SEED=1234
     - STORAGE=/data
    ports:
     - "80:8080"
    volumes:
     - "data:/data"
volumes:
  data:

Want your server to show up on the in-game map?

At the moment, the main server list verification is kind of a manual process. I will check the list from time to time and manually approve them after checking they work correctly. I need to write better tools to streamline the process, but there's other priorities right now. If you want to speed this up, you can always drop me a line on twitter with the url of your server.

Server configuration

  • CLIENT serve the client (boolean, defaults to false)
  • DESTINATIONS serve the destinations web ui (boolean, defaults to false)
  • GENERATOR the world generator function
  • MAX_CLIENTS the maximum concurrent players (defaults to 16)
  • NAME the server name (for the public registry)
  • PRELOAD a chunk radius around the spawn area to be preloaded
  • PUBLIC_URL public url of the server (for the public registry)
  • SEED 16bit world generation seed. (0 - 65535)
  • STORAGE directory in where to store the generated/modified chunks
# random seed, no preload, 16 clients
node server/main.js
# same, but preloading a 10 chunk radius around the spawn area
PRELOAD=10 node server/main.js
# flat world for only 4 clients with persistence
GENERATOR=flat MAX_CLIENTS=4 PRELOAD=10 SEED=1234 STORAGE=./data node server/main.js
# heightmap driven world generator
GENERATOR=heightmap COLORMAP=./island_rgb.png HEIGHTMAP=./island_height.png node server/main.js

Local development

webxr requires an https origin. to test with headsets on your local network:

# generate a self-signed cert/key:
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -out server.crt
# start the server with TLS
TLS_CERT=server.crt TLS_KEY=server.key npm start

blocks's People

Contributors

danielesteban avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blocks's Issues

Camera UX improvements

  • Position/Orientation: Change the camera to target the hand holding the camera instead of the player's head.
  • Realtime Visor: Display & update the photo texture in realtime while the X button is pressed
  • Zoom control: Adjust the camera fov with some user input

Textured player/peer heads

image

  • Render the player/peer head with a textured skin.
  • Store/Load the skin texture to/from the users localStorage
  • Broadcast the skin texture to peers over the webrtc data channel.
  • Let the user edit the texture (Spawn bust from menu + raycast painting)

User accounts service

For storing/restoring their nickname, skin, marked locations (for insant teleport), and other things to come.

A small node service with:

  • A mongoose model to store the user data and their skin
  • Email/Password registration
  • A set of endpoints to generate/refresh JWTs
  • A mongoose model to store user marked locations scoped per server

This centralization allows for a single account for every server.
It could also allow for a central friend list so you can teleport directly to your friend's location even if it's on another server.
All the data will just be downloaded once by the user and then streamed to the peers via the webrtc data channel just like it does now with what is stored on LocalStorage.
Also, when the servers need to validate the user for future features (like chunk claiming or something like that), they could validate this JWTs sent at connection by checking with the global auth service.

This would be built as a separate docker image: blocks-auth

Login/Register UI

The first version of the centralized auth service is deployed at:
https://blocks.gatunes.com/auth/

For now all the data is public and has cors fully enabled so it would work even from localhost.
Origin restrictions/validations may be added in the future.

I need to add this things to the client to start using it:

  • Register dialog UI (This will also upload the current skin)
  • Login dialog UI (This will also download and replace the current skin)
  • Restore and refresh the previous stored session when loading
  • Upload skin when saving it to localStorage after the user closes the skin editor

Destinations web UI

Display the location photos taken by players on a web UI scoped by:

  • Latest
  • User
  • Server

Photos UI on 3D menu

Add a new tab to the menu with a photos UI.
If not logged in, it will propmt the user to log in. (and teach how to do photos?)
If logged in and not have any photos, it will teach you how to do photos.
if logged in and have photos, it will show a UI with:

  • the photo
  • a teleport button that takes you to the server/location where the current photo was taken
  • prev/next buttons to navigate to other photos

Tall grass

This is all mostly server side in the Chunk class.

  • Add tall grass block type
  • Add grass geometry to the mesher (ground plane + 4-5 fibers)
  • Modify world generators to spawn tall grass at the heightmap level and within altitude range.
  • Double check the raycasting on the client also works for removing tall grass blocks

Enter VR button does not work from Quest Browser

Repro:

  1. Open Browser on the Meta Quest
  2. Navigate to blocks.gatunes.com
  3. Try to enter VR
com.oculus.vrshell-20231211-191556.mp4

The button is visible, and the debug info on the bottom left says that WebXR should be available, but clicking Enter VR does nothing.

Opening the console, there is an error message:
Uncaught (in promise) DOMException: If you see this error we have a bug. Please report this bug to chromium.

However this seems to be an anonymous error message (there's no way to view where in the code it originated) without any stack trace attached, so it seems less than helpful.

Let me know if there's anything I can do to retrieve more helpful debug information.

Export world volumes

  • Endpoint to export arbitrary world volumes into a raw format for #11 Structures
  • Mesh and export to gltf (This will require decoupling/refactoring the mesher)

Moon doesn't look like the moon

I assume the green round thing I've seen in the sky is the Moon, it really got me thinking before I realised what it is ! Maybe just make it grey ?

Shareable locations

  • Permalink on the auth service that serves the opengraph meta and redirects to the client
  • Client support to load a location from the auth service and connect to that server at the photo location
  • Web UI to display the location photo and meta on the client on top of the current world render

Custom block texture atlas per server

Once "Add UVs to mesh generator #35" is done:

  • Add an optional env to the server to pass a .png texture atlas.
  • Create an endpoint to download the atlas from the client
  • On the client onInit load the server atlas and update the voxels material.

Server-side user authentication

The servers need to be able to identify a logged-in user for future server-side features.
In order not to send the whole session token to a third party server this will require:

  • An endpoint for a user to get a session token scoped by server
  • An endpoint for the severs to verify a scoped session token signature
  • Implement support on the servers for this auth workflow and the storage of their session token and status
  • Implement fetching a scoped token and sending it while while conecting to a server on the client.

Configurable render distance

Add an option to the menu to configure the render distance.
This should also update the fog density accordingly.

Optimize server memory layout

Benchmark if using a single Uint8Array and accesing it by index is faster than the current approach of using a 3D array of objects.

To mantain the clarity of the code I would like to have a class that stores the offset with methods to access and modify the raw data directly.

Mesher refactor + blocktypes improvements

The mesher has gone to far too many patches and iterations.. it needs to be rewritten/refactored.
It should pre-allocate the memory for the 9 neighbours and fetch them at once regardless.
It should also support for blocks with multiple faces.
it should end up having way less duplicity.
I should be able to fix all culling/meshing errors once its more manageable

This should have prolly been done in #38... but it looked too cool not to push it and it was alredy an 800lines patch.
I really needed to push that and start again without the distraction of all the other parts.

Help/Controls

Spawn a UI plane on the player room with the controls/help at start.

Structures

  • Import and store arbitrary structures
  • Spawn them on the map on the propagation stage

Server List + Connect to server UI

  • Master server list in github pages or something that people can PR into.
  • Fetch & merge server list with the client's host and show it on a paginated menu panel (prolly as a subpage of the map UI)
  • Let the client connect to another server by selecting from the server list UI

By default, it will always connect to the client host first. Then you can connect to somewhere else from the server list UI.

Improve/scale block type selection UX

Once #38 is done.. The current block selection UX is not gonna cut it.
I'm thinking to display the selected block type on the left hand instead of the word "Menu" and using the left-right stick to change between block types. Have to do some testing.. but I think something like that could scale to a larger number of block types.

  • Send blocktypes from servers to the clients on the INIT event.
  • Move atlas loading out of voxels class into the world class so it can be also used by this UI
  • Implement block selection UI in the client

user interface

Again, nice project, this is promising !
The teleportation is very nicely done.

I think it would be a good thing to let the player pick a cube type, and a tool type (eraser, brush for painting existing block.. etc.. ). Also you might want an in-game menu to look for a game server for instance, or basic game parameters like sound.

I actually made a tool for VR user interfaces, check out the examples : https://three-mesh-ui.herokuapp.com/#keyboard
It's got some cool features like MSDF text, CSS-like syntax, a virtual keyboard...
If you're interested, I'm willing to help you code the user interface using this tool. (if you take contributions)

Chunk claiming

Implement a feature that let's the users claim ownership of a set of chunks for a time period.
There should be a limit on the radius of chunks a claim can have (prolly like 4).
There should also be a limit of claims a user can do per server (prolly 3).

This requires #29 to be done first.

It will need to implement:

  • server storage/loading of claimed chunks
  • server-side claiming (and renewal) of a set of chunks
  • server world editing should enforce chunk claims and only allow editing to the owner.
  • client UI for claiming a set of chunks
  • client Mesh/UI to give feedback of the readonly status of already claimed chunks

Custom block types per server

Instead of hardcoded block types. Let each server define it's own block types and textures.
This will require to rethink the meshing, the atlas packing and prolly extending the client upscaler to chunk it onto multiple textures.

Trees

This is all mostly server side in the Chunk class.

  • Add tree sapling block type
  • Add tree growth algorithm similar to flood lighting
  • Run tree growth algorithm on the light propagation stage

Maybe rename the stage just to "propagation".
When growing a tree, it should replace the sapling block for the tree root. and start growing from there.
Trees will only be generated at the world generation stage for now.
Tree planting will be disabled since I don't have a way to render the saplings until I modify the mesher and this feature will prolly come when I implement the tall grass.
So.. Once Tall grass #6 is in, I will revisit tree planting.

Ambient sound

  • Ambient sounds preloader
  • Ambient sound player/mixer. Mix ambient loops by player height.
  • Allow extra channels/tracks for weather ambient (like rain)

Rain

  • Create a heightmap in the client. After vertexNormals computation, get and max the height of the top faces.
  • Trigger rain based on date offset (so all clients are sync) just like the daylight but less frequent
  • Instance rain particles on the sky on a radius around the player, deswpawn them when they hit the heigtmap so they don't appear on interiors or caves.

Add UVs to mesh generator

  • Generate UVs on the mesher
  • Adapt the network protocol

Use block type as horizontal offset:

block:         glass:
1,0 - 2,0      2,0 - 3,0
1,1 - 2,1      2,1 - 3,1

This will allow the client to detect the block type by just sampling the UVs on the raycasting phase.

Moving the head with joystick

I'm a fan of playing seated, and I know some people prefer it as well.
Can I suggest using the joystick for moving the camera manually ? As an option of course.
This way you can U-turn... Otherwise you're stuck in the forward direction !

Map (Server-side) Teleport

On the server:

  • Implement teleport request that receives X and Z and responds back with a teleport event with the world height at that block.

On the client:

  • When the user taps on the map: Project the position and send a teleport request to the server.
  • React to the teleport event and move the player into position

"Enter VR" button

Add a fake "Enter VR" button on the bottom center of the page like they do on other threejs and webxr experiences to avoid confusion about how to enter immersive mode.

Birds

Two triangles. Instanced.

  • Spawn birds on a radius around the player
  • Animate the birds

Pointcloud world generator (PLY/OBJ/CSV)

I have many many worlds created from scans available as quantized point clouds as well as in CSV based SVOs. Any thought s on how we might create a loader for non-image type worlds?

Custom JS code world generator

Allow passing an absolute path to a js file to the GENERATOR server env and use that code as the world generator.
This will allow for quick and easy worldgen experimentation on the glitch servers and such.

Photo Camera

Once #19 is done.. I want to implement the location saving/recalling with some sort of photo camera mode.

  • Tapping X, the user can take a photo. This gets rendered to a texture the user can see in it's hand.
  • Save and cancel buttons on top of the photo frame. If the user taps save, it uploads the photo to the auth service with the server id and the X-Y-Z location.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.