• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WebXR AR occlusion, lighting, interaction and physics with three.js

Enva-XR - Environment Aware Augmented Reality

  • Web-based framework for environment-aware rendering and interaction in augmented reality based on WebXR using three.js
  • The framework handles geometry occlusions, matches the lighting of the environment, casts shadows, and provides physics interaction with real-world objects.
  • Material from three.js can be reused the shader code required for AR occlusion is injected into the existing shaders using the onBeforeCompile callback.
  • Capable of obtaining over 20 frames per second even on middle-range devices.
  • WebXR AR features supported by the framework

Getting Started

  • Download the repository from git gh repo clone tentone/enva-xr
  • Install Node and NPM.
  • Ensure that your browser is compatible with WebXR and check features support (e.g. depth-estimation, hit-test, lighting).
  • Install dependencies from NPM by running npm install and start the code running npm run start
  • To allow easier debugging in mobile devices eruda can be used as a development tools alternative.

Usage Example

  • Bellow is a simple usage example of the library the ARRenderer is responsible for most of the work required to setup the AR scene.
  • The ARRenderer receives a configuration object that indicates wich WebXR features should be enabled.
  • To enable AR rendering on existing three.js materials the AugmentedMaterial.transform() method should be used to transform regular materials into AR materials.
  • The example bellow demonstrates how to create a simple AR scene with occlusion and lighting enabled.
  • LightProbe object replicates the envornment lighting and position main light source position and direction. Internaly contains a three.js LightProbe and DirectionalLight with shadow casting enabled by default.
const renderer = new ARRenderer({
  depthSensing: true,
  depthTexture: true,
  lightProbe: true
});

let material: any = new MeshPhysicalMaterial({color: (Math.random() * 0xFFFFFF)});
material = AugmentedMaterial.transform(material);

let box = new Mesh(new BoxGeometry(), material);
box.receiveShadow = true;
box.castShadow = true;
renderer.scene.add(box);

const probe = new LightProbe();
renderer.scene.add(probe);

const floor = new FloorPlane();
renderer.scene.add(floor);

renderer.onFrame = function(time: number, renderer: ARRenderer) {
  box.rotation.x += 0.01;
};

renderer.start();

Rendering

  • Depth data provided by WebXR can be used for occlusion in the 3D scene.
  • Occlusion is calculated in the shader code injected using the AugmentedMaterial.transform() method.
  • To enable realistic rendering of the scene the MeshPhysicalMaterial material should be used alonside PBR assets.

Physics

  • cannon.js can be used for physics interaction between objects.
  • The VoxelEnvironment provides a probabilistic voxel based model that maps the environment from depth data that is updated every frame.
  • Alternativelly physics can rely on plane detection using the FloorPlane or Planes objects.
  • Currently performance is limited might be improved using WebXR Real World Geometry API

License

  • The code from the project is MIT licensed. The license is available on the project repository,

More Repositories

1

nunuStudio

Web powered cross-platform 3D, WebXR game engine.
JavaScript
2,116
star
2

geo-three

Tile based geographic world map visualization library for threejs
TypeScript
700
star
3

potree-core

Potree point cloud viewer library core components for easier integration in a three.js project.
JavaScript
178
star
4

tello-ros2

ROS2 node for DJI Tello and Visual SLAM for mapping of indoor environments.
C++
139
star
5

aruco

Aruco marker detector and pose estimation for AR and Robotics with ROS support
C++
130
star
6

vkCraft

Minecraft clone written with C++ and Vulkan, node structure for infinite world chunks.
C++
52
star
7

monodepth

Python ROS depth estimation from RGB image based on code from the paper "High Quality Monocular Depth Estimation via Transfer Learning"
Python
52
star
8

dartboy

Game boy color emulator written in Dart using Flutter for cross platform (Desktop, Mobile) user interface.
Dart
39
star
9

IDKwGL

WebGL 3D rendering framework w/ support for file loaders, multiple material types and basic AABB physics.
JavaScript
20
star
10

syncinput

Synchronous keyboard and mouse input for web applications. Useful for games and canvas / webgl synchronous content in web applications.
TypeScript
20
star
11

escher.js

2D graphics canvas framework for easier interactive web graphics.
JavaScript
19
star
12

constellations

Particle collision with quad-tree experiment inspired by games like Eufloria and Auralux.
Java
13
star
13

car-tracker-flutter

Car tracker GPS flutter based mobile application for A11, ST-901, GT01, and GT09 SMS based trackers.
Dart
10
star
14

gotracer

Multi-threaded software raytracer written in golang.
Go
8
star
15

car-tracker-ionic

Mobile web based application to track car GPS position for A11, ST-901, GT01, and GT09 SMS based trackers.
TypeScript
7
star
16

max-clique

Graph theory experiments for the maximum clique problem using python.
Python
7
star
17

checkers

Checkers board recognition computer vision system using OpenCV
C++
4
star
18

semeionNet

A set of machine learning experiments with the semeion and MNIST handwritten digit dataset using tensorflow
Python
3
star
19

wallrunner

Wallrunner is meat boy like platform game. Mobile and desktop crossplatform game source code.
Java
3
star
20

covisim

COVID-19 virus data dashboard and statistical simulation of the virus spread
JavaScript
3
star
21

street-monitor

Road vehicle and pedestrians tracker to monitor street activity.
C++
3
star
22

tentone

Public profile special repository, no code to see here!
Brainfuck
2
star
23

webkinect

Provides access to Microsoft kinect sensor data (skeleton, color camera and depth camera) from HTTP using WebSockets..
C#
2
star
24

ganimator

2D animation system designed to produce content for games. Only supports LibGDX for now.
Java
2
star
25

xenoparticles

Real-time fluid-like particle simulation using the xenomai framework.
C++
2
star
26

depthset

Depth image dataset generator from 3D models for machine learning experiments.
JavaScript
2
star
27

crosstabtalk

Browser tab/window local message communication library for cross-tab data exchange and syncronization.
JavaScript
2
star
28

image-geometry

Triangulated image geometry generator from transparent images for three.js
JavaScript
2
star
29

rubix-solver

Rubix cube detector and solver using computer vision.
C++
2
star
30

heist

Heist to the museum, project for the Distributed Systems course, in the University of Aveiro
Java
1
star
31

mssql-uuid

Go implementation of MS SQL Server Uniqueidentifier type.
Go
1
star
32

cork

Cork stopper quality analysis and comparison vision system using RGB shadow decomposition for industrial application.
C++
1
star
33

bomberguy

Bomberman like game.
C#
1
star
34

retris

Tetris game written in rust w/ macroquad.
Rust
1
star