1 of 26

VCE: Assignment 3

Build your own VCE

2 of 26

Goals

This is the list of competencies expected to develop with the assignment 3:

  • That you know how to apply technology to connect people
  • To prove that you know how to code a full-stack application
  • That you understand the complexities of developing a VCE
  • That you know how to use a database
  • That you understand how to enrich user interaction through an intelligent use of the interface
  • That you try to mix technologies to enhance human communications

3 of 26

Objective

  • Build a 3D Virtual Communications Environment
  • Users should be able to:
    • Register
    • Configure his appearance
    • Move inside a 3D space
    • Communicate with other people
    • Interact with other people or the environment in meaningful ways
  • The 3D space should be perfectly synched (what I see is what you see)
  • The interaction should have a purpose (besides entertainment or chatting)

It can't be a videogame, it must be a communications platform!

4 of 26

Evaluation

This are the evaluation criteria:

  • +1 Clear Idea: If the app fills a clear PAIN of the users
  • +1 Login: If your app has login/register (internal or using oauth)
  • +1 Navigation: if the movement, camera and 3D world interaction is well done
  • +1 UX: If the design uses the screen space intelligently (no dead space on the screen, text is easy to read, responsive, etc).
  • +1 Space: If the 3D space seems interesting, engaging, as the avatars
  • +2 Tech: If it contains a piece of technology nobody else's have. Like using the Audio API, or the WebCam, or an Editor, or uses an existing API.
  • +1 Completion: All the features displayed work, it looks finished, no bugs.
  • +1 Presentation: If the presentation showcases correctly your idea
  • +1 Extras: Anything that is custom from you (nice assets, etc)

5 of 26

Clear Idea

Your final VCE should have a clear use case in mind and a clear target audience.

It is more than "a 3D chat", it should contain some functionality available to everybody using your VCE.

It can't be a videogame, it must be a communications platform!

Everything should reflect that idea:

  • The app name
  • The design
  • The 3D space
  • The avatars
  • The interaction

6 of 26

Login

Users should be able to register and login with a password to the system.

The system should check if there is already a user with the same username when registering a new one.

When a user logins using login/pass, the server should send him a session token (a unique random string generated for him). The server will store that token along the user info. The user can store the token locally (using localStorage) to avoid having to login using the username/password everytime.

The user can login in the future using his username/password or just by passing the session token.

7 of 26

Database

The backend should connect to a database to store information (users, rooms, messages) permanently.

It should use the database in an intelligent way, not just using a redis to store user/pass and nothing else.

Features to prove database connection:

  • login/password
  • session token
  • direct messages
  • room customization

8 of 26

Navigation

Navigating through the 3D space should feel natural. Actions like:

  • Walking
  • Looking around
  • Interacting with objects on the scene

Also the camera movement should feel if helps see the space around you.

Having different camera modes may help:

  • First person
  • Third person
  • Fixed room camera

9 of 26

UX

Besides the 3D space, the web will have other panels.

It is important that the interface seems easy to use.

  • The web space should be used intelligently
  • The buttons should be clear (with icons)
  • The interface should not be crowded with panels that are not relevant
  • It should be intuitive to do actions in the interface

It is important to do a good use of CSS

10 of 26

Technology

Beside the basics of 3D walking chat you should try to develop some piece of technology that enriches the experience, something that nobody else have, like:

  • Using the Audio API to allow people to create musical experiences
  • Using a library to allow people to talk to each other (PeerJS)
  • Using Canvas2D to allow people to draw together on the 3D space.
  • Using existing APIs to fetch info from other platforms
  • Using the mobile phone to enrich the experience (using the GPS, the Camera, the microphone)
  • Using WebGL or Rendeer to enrich the 3D environments (construct 3D spaces collaboratively)

11 of 26

Completion

It is important that the web looks polished, finished.

You should pay attention to details like:

  • Readability
  • Informative messages
  • No bugs

12 of 26

Security

You should be sure the sensitive data of users is secure:

  • Passwords salted and hashed
  • Avoid SQL injection
  • Sensitive files are not available through HTTP

13 of 26

Presentation

For the presentation, remember to rehearse your pitch, try to explain it as if you are trying to find investors.

Show all the features of your app that are more interesting.

Focus in what makes your app different from others.

Do not show the app as it is, but sell it as what it could become.

Add info about your customer target, present and future features, etc.

14 of 26

Delivery

The presentation and delivery will be the last friday of exams.

Students must send it through AulaGlobal and have a working version in the ECV server.

Careful when creating the ZIP file, avoid sending .git or node_modules.

It must contain a README.txt with all the important information about the features developed.

It must contain a link to a video in youtube with a presentation of your work.

Max size is 200MBs.

15 of 26

Steps

16 of 26

Framework

Download the 3D framework

Keep in mind that this framework requires to use an HTTP server to use it as it loads files from the folder, which is blocked when opening in chrome by double-clicking the index.html.

I recommend setting up the node module http-server which is very easy to setup.

17 of 26

Steps

  1. Idea: Define your idea based on some user PAIN and some technology that could help fix it. Check the creativity slides, and plan your MVP.
  2. Virtual Space: take the template and play with it to understand the 3D engine.
  3. Userbase: Implement the backend register/login system using a database.
  4. Interface: Create the client HTML interface to enter user/pass or register.
  5. Persistence: Once authentified, the user should load his previous state (his avatar, which room was he connected, his previous position) and restore it.
  6. Synch: Every client should send his state to the server (its position, orientation or its model matrix) so the server can broadcast it to the people in the same room, so the world is synchronized.
  7. Tech: Add a technology layer (use existing libraries) to improve interaction between users.
  8. Presentation: make it look professional, clear interface, readable texts, etc

18 of 26

3D Space

You will need to use the 3D library Rendeer.

Check the guides to know how to use it:

  • Tutorial
  • Picking
  • Animations

Also remember to export from Blender in GLB format to import easily your 3D content to the engine.

19 of 26

Synchronization

Keep the same structure as in the Assignment 2, that means, send only the relevant info to the server and let the server broadcast it to the rest of the users.

Create a method to extract only the relevant info from the user character:

  • position
  • rotation
  • animation_name

and send it to the server (if possible not every frame, at could overcharge the server).

20 of 26

Useful Code

21 of 26

Dragging Files

This function allows you to set up easily a callback that will be called when a file is dragged on top of an element of the DOM.

The callback will receive the drop event, to get the file go to drop event parameter and search for:

evt.dataTransfer.files

function createDropArea( element, callback_drop, callback_enter, callback_exit )

{

element.addEventListener("dragenter", onDragEvent);

function onDragEvent(evt)

{

element.addEventListener("dragexit", onDragEvent);

element.addEventListener("dragover", onDragEvent);

element.addEventListener("drop", onDrop);

evt.stopPropagation();

evt.preventDefault();

if(evt.type == "dragenter" && callback_enter)

callback_enter(evt, this);

if(evt.type == "dragexit" && callback_exit)

callback_exit(evt, this);

}

function onDrop(evt)

{

evt.stopPropagation();

evt.preventDefault();

element.removeEventListener("dragexit", onDragEvent);

element.removeEventListener("dragover", onDragEvent);

element.removeEventListener("drop", onDrop);

var r = undefined;

if(callback_drop)

r = callback_drop(evt,evt.dataTransfer.files[0]);

if(r)

{

evt.stopPropagation();

evt.stopImmediatePropagation();

return true;

}

}

}

22 of 26

Reading files

To read the content of a file (as text or binary) you need to use the FileReader class.

Depending on what you want to obtain you should call the appropriate function.

//create a file reader

var reader = new FileReader();

//define the callback

reader.onload = function(evt) {

//use the file content...

console.log(evt.target.result);

};

//to read as ArrayBuffer

reader.readAsArrayBuffer(file);

//to read as Text

reader.readAsText(file);

//to read as Base64URL

reader.readAsDataURL(file)

23 of 26

File to URL

Some objects (like Image or Video) require to pass the URL to the Image, not the File.

In that case you can transform any file to an URL using the URL class.

//create a file reader

var url = URL.createObjectURL(file);

//pass to the element

img.src = url;

24 of 26

Read WebCam

You can access the video and audio stream of the user.

//request access

navigator.mediaDevices.getUserMedia({video: true, audio: false})

.then( function(stream) {

//if user allows access

var video = document.querySelector("video");

video.srcObject = stream;

}, function(err) {

console.log('Failed to get local stream' ,err);

});

25 of 26

Upload file

To send a file in a HTTP Request you can use fetch and pass the file as the body of the request.

From the other side you must read the body to extract the file.

// This will upload the file after having read it

const upload = (file) => {

fetch('http://www.example.net', { // Your POST endpoint

method: 'POST',

headers: {

// Content-Type may need to be completely **omitted**

// or you may need something

"Content-Type": "You will perhaps need to define a content-type here" //optional

},

body: file // This is your file object

}).then(

response => response.json() // if the response is a JSON

).then(

success => console.log(success) // Handle the success

).catch(

error => console.log(error) // Handle the error

);

};

26 of 26