SlideShare a Scribd company logo
1 of 28
Download to read offline
three.js
& leap motion
An introduction & overview of 3D graphics in the browser
• 3D primer
• What is three.js
• First steps with three.js
• What is a Leap Motion Controller
• Leap demo
• Washington Post special project review
Overview
This is not a tutorial.3D graphics in and of itself is a very complicated subject. This presentation is not a tutorial
but does attempt to cover (very briefly) the basics and help you understand where to get
started with three.js & how things fit together. With that said- the documentation around
three.js is very good and it’s fairly easy to find tutorials online.
A simple scene
consisting of a
light, cube, plane
and camera.
An Example
3D Scene
3D Primer
• The lights, cameras & objects are collectively called
a scene. In three.js it is a hierarchy & the scene is
the root of the tree.
• Objects or geometry such as cubes and planes (also
called primitives) are created by points in space
called vertices.
• A group of vertices and their edges create polygons.
• A group of polygons (objects) along with a material
create a mesh.
• The camera captures the picture and in the example
to the left we are looking through the camera.
• Lights allow us to cast shadows and render
highlights.
First Steps
with
three.js
• Follow the three.js “Getting Started” section in the docs.

https://threejs.org/docs/index.html#Manual/Introduction/Creating_a_scene
• Load a custom model instead of using geometry.
• Add a light & cast shadows.
three.js
example
.
├── index.html
├── js
│ ├── ext
│ │ ├── three.js
│ │ └── three.modules.js
│ └── main.js
└── run.py
directory structure
1 console.info("main.js loaded");
2
3 var scene = new THREE.Scene();
4 var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
5 console.info("scene & camera created");
6
7 var renderer = new THREE.WebGLRenderer();
8 renderer.setSize(window.innerWidth, window.innerHeight);
9 console.info("renderer created");
10
11 document.body.appendChild(renderer.domElement);
12 console.info("DOM modified");
13
14 var geometry = new THREE.BoxGeometry(1, 1, 1);
15 var material = new THREE.MeshBasicMaterial({color: 0x00ff00});
16 var cube = new THREE.Mesh(geometry, material);
17 scene.add(cube);
18 console.info("Cube created");
19
20 camera.position.z = 5;
21 console.info("Camera repositioned");
22
23 function render() {
24 // Animate the cube
25 cube.rotation.x += 0.01;
26 cube.rotation.y += 0.01;
27 requestAnimationFrame(render);
28 renderer.render(scene, camera);
29 }
30 console.info("Starting render")
31 render();
demo
Free “digger” model from
TurboSquid.
loading
custom
models
Model geometry must be
triangulated.
Note how there are now
diagonal lines and all of
the surfaces have
triangles.
Sidebar:
Use a 3D graphics program to
adjust your model’s geometry.
Any 3D program can adjust geometry. Blender
is free and can easily do this for us.
Loading
JSON
• Use the free utility from the three.js project to convert from
OBJ to JSON.

https://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
• Use the built-in JSONLoader to load the object.
• Watch file sizes! If you are using a “real” web server
enable gzip compression!
1 var greenMat = new THREE.MeshBasicMaterial({color: 0x00ff00});
2
3 // Create a JSON loader
4 var loader = new THREE.JSONLoader();
5
6 // Load triangulated model as JSON
7 loader.load(
8 'models/digger_scaled_tri.json',
9 // onLoad callback
10 function (geometry) {
11 // Add geometry to a new mesh combining a material
12 var object = new THREE.Mesh(geometry, greenMat);
13 // Add our object to the scene
14 scene.add(object);
15 }
16 );
demo
lighting &
shadows
three.js has many types of
lights but we’ll focus on the
directional light.
• Directional lights shine from a specific direction
not a specific location.
• The documentation describes this as a light that
acts like the sun.
• Shadows are only calculated for objects that
exist within the light’s shadow camera’s field of
view.
• The shadow camera for a directional light is
orthographic (think 2D, e.g. top down).
• In the picture to the left the orange lines denote
the shadow camera’s field of view.
three.js uses shadow
mapping with the WebGL
renderer.
• Shadow mapping was introduced by Lance
Williams in 1978.
• Computation takes place on the GPU with
WebGL.
• Think of a shadow map like a texture map. They
are applied (mapped) to the surface of the
geometry during rendering.
• The size of the map directly affects the shadow
detail because the size of the map is the size of
the buffer and a larger map/buffer can hold more
information about the shadow.
• Shadows aren’t necessarily hard but they
require some tweaking and experimenting to get
right.
demo
The Leap Motion Controller lets you use your computer in a whole new way.
Reach out and swipe, grab, pinch, or punch your way through the digital world.
• Uses two wide angle IR cameras to detect hands in 3D space above the device.
• Tracks hands, fingers and wrists / arms and translates motion from real world
space to 3D environment coordinates.
• For developers it is plug & play and very accessible.
• It is a bit finicky and detecting / supporting custom gestures can be laborious.
Leap Motion Controller
demo
In 2015 I was contracted to help build a 3D interactive
experience exploring the restoration of the U.S. Capitol
Dome.
The interactive experience took place at the White House
Correspondents Dinner. The scope was narrowed down to
build a kiosk where visitors could approach one of two large
displays and interact with a 3D model of the dome using a
Leap Motion controller.
Washington Post
Special Project
3D
Model
three.js enabled the rapid
development & delivery of
the experience within a
browser.
Many issues could be ignored because we were operating as a kiosk
in a known environment:
• Device hardware specs were known (fast enough to ignore
optimizations)
• No external bandwidth requirements (all files are hosted & served
locally)
• Human explanations & help to explain how to interact with the
demo.
• No need to open up “heavier” tooling such as Unity.
Leap
Motion
Web
Browser
three.js
early prototype
Things didn’t go as planned
3 Weeks to Deliver
Interaction

Spent the majority of the time
figuring out gestures and hand
controls. Tried “gimbal” controls.
Settled on “joystick” controls.
“Hot Spots” & Polishing

Used ray casting for “fast enough”
collision detection between hands
and “hot spots”. Added dynamic
“demo” mode to pique interest.
Rendering & Lighting

Lost a good chunk of time to loading
a model of the entire capital.
Reverted to just the dome. Had
trouble with shadows & model size.
demo
THANK YOU!
@leetrout

More Related Content

What's hot

Creating Applications with WebGL and Three.js
Creating Applications with WebGL and Three.jsCreating Applications with WebGL and Three.js
Creating Applications with WebGL and Three.jsFuture Insights
 
HTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGLHTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGLThibaut Despoulain
 
ENEI16 - WebGL with Three.js
ENEI16 - WebGL with Three.jsENEI16 - WebGL with Three.js
ENEI16 - WebGL with Three.jsJosé Ferrão
 
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...Ontico
 
WebGL - 3D programming
WebGL - 3D programmingWebGL - 3D programming
WebGL - 3D programmingMinh Ng
 
[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...
[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...
[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...iMasters
 
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]JavaScript Meetup HCMC
 
Thomson Tom design_engineer_portfolio
Thomson Tom design_engineer_portfolioThomson Tom design_engineer_portfolio
Thomson Tom design_engineer_portfolioThomsonTom3
 
Developing Web Graphics with WebGL
Developing Web Graphics with WebGLDeveloping Web Graphics with WebGL
Developing Web Graphics with WebGLTony Parisi
 
Real-time collaborative drawing
Real-time collaborative drawingReal-time collaborative drawing
Real-time collaborative drawingRichard Powell
 
Draw stuff at @jsnortheast
Draw stuff at @jsnortheastDraw stuff at @jsnortheast
Draw stuff at @jsnortheastRichard Powell
 
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012philogb
 
Augmented Reality in JavaScript
Augmented Reality in JavaScriptAugmented Reality in JavaScript
Augmented Reality in JavaScriptZeno Rocha
 
ITNetwork - 3D na webu
ITNetwork - 3D na webuITNetwork - 3D na webu
ITNetwork - 3D na webuPavol Hejný
 
Ro 786 preview _tech art_
Ro 786  preview _tech art_Ro 786  preview _tech art_
Ro 786 preview _tech art_SADISOFT
 
An Impromptu Introduction to HTML5 Canvas
An Impromptu Introduction to HTML5 CanvasAn Impromptu Introduction to HTML5 Canvas
An Impromptu Introduction to HTML5 CanvasBen Hodgson
 
OpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualizationOpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualizationphilogb
 
Introduction to open gl in android droidcon - slides
Introduction to open gl in android   droidcon - slidesIntroduction to open gl in android   droidcon - slides
Introduction to open gl in android droidcon - slidestamillarasan
 
OL3-Cesium: 3D for OpenLayers maps
OL3-Cesium: 3D for OpenLayers mapsOL3-Cesium: 3D for OpenLayers maps
OL3-Cesium: 3D for OpenLayers mapsAndreas Hocevar
 

What's hot (20)

Creating Applications with WebGL and Three.js
Creating Applications with WebGL and Three.jsCreating Applications with WebGL and Three.js
Creating Applications with WebGL and Three.js
 
HTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGLHTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGL
 
ENEI16 - WebGL with Three.js
ENEI16 - WebGL with Three.jsENEI16 - WebGL with Three.js
ENEI16 - WebGL with Three.js
 
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
 
WebGL - 3D programming
WebGL - 3D programmingWebGL - 3D programming
WebGL - 3D programming
 
[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...
[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...
[JS EXPERIENCE 2018] Jogos em JavaScript com WebGL - Juliana Negreiros, Codem...
 
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
 
WebGL 3D player
WebGL 3D playerWebGL 3D player
WebGL 3D player
 
Thomson Tom design_engineer_portfolio
Thomson Tom design_engineer_portfolioThomson Tom design_engineer_portfolio
Thomson Tom design_engineer_portfolio
 
Developing Web Graphics with WebGL
Developing Web Graphics with WebGLDeveloping Web Graphics with WebGL
Developing Web Graphics with WebGL
 
Real-time collaborative drawing
Real-time collaborative drawingReal-time collaborative drawing
Real-time collaborative drawing
 
Draw stuff at @jsnortheast
Draw stuff at @jsnortheastDraw stuff at @jsnortheast
Draw stuff at @jsnortheast
 
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012
 
Augmented Reality in JavaScript
Augmented Reality in JavaScriptAugmented Reality in JavaScript
Augmented Reality in JavaScript
 
ITNetwork - 3D na webu
ITNetwork - 3D na webuITNetwork - 3D na webu
ITNetwork - 3D na webu
 
Ro 786 preview _tech art_
Ro 786  preview _tech art_Ro 786  preview _tech art_
Ro 786 preview _tech art_
 
An Impromptu Introduction to HTML5 Canvas
An Impromptu Introduction to HTML5 CanvasAn Impromptu Introduction to HTML5 Canvas
An Impromptu Introduction to HTML5 Canvas
 
OpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualizationOpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualization
 
Introduction to open gl in android droidcon - slides
Introduction to open gl in android   droidcon - slidesIntroduction to open gl in android   droidcon - slides
Introduction to open gl in android droidcon - slides
 
OL3-Cesium: 3D for OpenLayers maps
OL3-Cesium: 3D for OpenLayers mapsOL3-Cesium: 3D for OpenLayers maps
OL3-Cesium: 3D for OpenLayers maps
 

Viewers also liked

老成之CreateJS與Flash
老成之CreateJS與Flash老成之CreateJS與Flash
老成之CreateJS與Flash智遠 成
 
Three.js 一場從2D變成3D的冒險
Three.js  一場從2D變成3D的冒險Three.js  一場從2D變成3D的冒險
Three.js 一場從2D變成3D的冒險智遠 成
 
Build the Virtual Reality Web with A-Frame
Build the Virtual Reality Web with A-FrameBuild the Virtual Reality Web with A-Frame
Build the Virtual Reality Web with A-FrameMozilla VR
 
WebVR - MobileTechCon Berlin 2016
WebVR - MobileTechCon Berlin 2016WebVR - MobileTechCon Berlin 2016
WebVR - MobileTechCon Berlin 2016Carsten Sandtner
 
An Introduction to WebVR – or How to make your user sick in 60 seconds
An Introduction to WebVR – or How to make your user sick in 60 secondsAn Introduction to WebVR – or How to make your user sick in 60 seconds
An Introduction to WebVR – or How to make your user sick in 60 secondsGeilDanke
 
My adventure with Elm
My adventure with ElmMy adventure with Elm
My adventure with ElmYan Cui
 
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!FITC
 
WebVR Ecosystem and API Update
WebVR Ecosystem and API UpdateWebVR Ecosystem and API Update
WebVR Ecosystem and API UpdateTony Parisi
 

Viewers also liked (9)

老成之CreateJS與Flash
老成之CreateJS與Flash老成之CreateJS與Flash
老成之CreateJS與Flash
 
Three.js 一場從2D變成3D的冒險
Three.js  一場從2D變成3D的冒險Three.js  一場從2D變成3D的冒險
Three.js 一場從2D變成3D的冒險
 
Build the Virtual Reality Web with A-Frame
Build the Virtual Reality Web with A-FrameBuild the Virtual Reality Web with A-Frame
Build the Virtual Reality Web with A-Frame
 
WebVR
WebVRWebVR
WebVR
 
WebVR - MobileTechCon Berlin 2016
WebVR - MobileTechCon Berlin 2016WebVR - MobileTechCon Berlin 2016
WebVR - MobileTechCon Berlin 2016
 
An Introduction to WebVR – or How to make your user sick in 60 seconds
An Introduction to WebVR – or How to make your user sick in 60 secondsAn Introduction to WebVR – or How to make your user sick in 60 seconds
An Introduction to WebVR – or How to make your user sick in 60 seconds
 
My adventure with Elm
My adventure with ElmMy adventure with Elm
My adventure with Elm
 
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
 
WebVR Ecosystem and API Update
WebVR Ecosystem and API UpdateWebVR Ecosystem and API Update
WebVR Ecosystem and API Update
 

Similar to Introduction to three.js & Leap Motion

Web3D - Semantic standards, WebGL, HCI
Web3D - Semantic standards, WebGL, HCIWeb3D - Semantic standards, WebGL, HCI
Web3D - Semantic standards, WebGL, HCIVictor Porof
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法Unite2017Tokyo
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法Unity Technologies Japan K.K.
 
Speeding up mobile web apps
Speeding up mobile web appsSpeeding up mobile web apps
Speeding up mobile web appsIvano Malavolta
 
Advanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics APIAdvanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics APITomi Aarnio
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
Chapter ii(coding)
Chapter ii(coding)Chapter ii(coding)
Chapter ii(coding)Chhom Karath
 
Augmented reality in web rtc browser
Augmented reality in web rtc browserAugmented reality in web rtc browser
Augmented reality in web rtc browserALTANAI BISHT
 
Intro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate JavascriptIntro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate JavascriptAndrew Lovett-Barron
 
World wind java sdk in progess
World wind java sdk in progessWorld wind java sdk in progess
World wind java sdk in progessRaffaele de Amicis
 
Chap2 Overview of 3D Animation .pptx
Chap2 Overview of 3D Animation .pptxChap2 Overview of 3D Animation .pptx
Chap2 Overview of 3D Animation .pptxellyviethra
 
Game Engine Overview
Game Engine OverviewGame Engine Overview
Game Engine OverviewSharad Mitra
 
Mirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image ProcessingMirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image ProcessingMeetupDataScienceRoma
 
jQuery Conference Toronto
jQuery Conference TorontojQuery Conference Toronto
jQuery Conference Torontodmethvin
 
Writing 3D Applications Using ruby-processing
Writing 3D Applications Using ruby-processingWriting 3D Applications Using ruby-processing
Writing 3D Applications Using ruby-processingPreston Lee
 
Using Deep Learning to Derive 3D Cities from Satellite Imagery
Using Deep Learning to Derive 3D Cities from Satellite ImageryUsing Deep Learning to Derive 3D Cities from Satellite Imagery
Using Deep Learning to Derive 3D Cities from Satellite ImageryAstraea, Inc.
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsclimboid
 

Similar to Introduction to three.js & Leap Motion (20)

Web3D - Semantic standards, WebGL, HCI
Web3D - Semantic standards, WebGL, HCIWeb3D - Semantic standards, WebGL, HCI
Web3D - Semantic standards, WebGL, HCI
 
COMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptxCOMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptx
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
 
reviewpaper
reviewpaperreviewpaper
reviewpaper
 
Speeding up mobile web apps
Speeding up mobile web appsSpeeding up mobile web apps
Speeding up mobile web apps
 
Advanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics APIAdvanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics API
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
Chapter ii(coding)
Chapter ii(coding)Chapter ii(coding)
Chapter ii(coding)
 
Augmented reality in web rtc browser
Augmented reality in web rtc browserAugmented reality in web rtc browser
Augmented reality in web rtc browser
 
Intro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate JavascriptIntro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate Javascript
 
World wind java sdk in progess
World wind java sdk in progessWorld wind java sdk in progess
World wind java sdk in progess
 
Chap2 Overview of 3D Animation .pptx
Chap2 Overview of 3D Animation .pptxChap2 Overview of 3D Animation .pptx
Chap2 Overview of 3D Animation .pptx
 
Game Engine Overview
Game Engine OverviewGame Engine Overview
Game Engine Overview
 
Mirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image ProcessingMirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image Processing
 
Surge2012
Surge2012Surge2012
Surge2012
 
jQuery Conference Toronto
jQuery Conference TorontojQuery Conference Toronto
jQuery Conference Toronto
 
Writing 3D Applications Using ruby-processing
Writing 3D Applications Using ruby-processingWriting 3D Applications Using ruby-processing
Writing 3D Applications Using ruby-processing
 
Using Deep Learning to Derive 3D Cities from Satellite Imagery
Using Deep Learning to Derive 3D Cities from Satellite ImageryUsing Deep Learning to Derive 3D Cities from Satellite Imagery
Using Deep Learning to Derive 3D Cities from Satellite Imagery
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
 

Recently uploaded

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Recently uploaded (20)

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

Introduction to three.js & Leap Motion

  • 1. three.js & leap motion An introduction & overview of 3D graphics in the browser
  • 2. • 3D primer • What is three.js • First steps with three.js • What is a Leap Motion Controller • Leap demo • Washington Post special project review Overview
  • 3. This is not a tutorial.3D graphics in and of itself is a very complicated subject. This presentation is not a tutorial but does attempt to cover (very briefly) the basics and help you understand where to get started with three.js & how things fit together. With that said- the documentation around three.js is very good and it’s fairly easy to find tutorials online.
  • 4. A simple scene consisting of a light, cube, plane and camera. An Example 3D Scene 3D Primer • The lights, cameras & objects are collectively called a scene. In three.js it is a hierarchy & the scene is the root of the tree. • Objects or geometry such as cubes and planes (also called primitives) are created by points in space called vertices. • A group of vertices and their edges create polygons. • A group of polygons (objects) along with a material create a mesh. • The camera captures the picture and in the example to the left we are looking through the camera. • Lights allow us to cast shadows and render highlights.
  • 5. First Steps with three.js • Follow the three.js “Getting Started” section in the docs.
 https://threejs.org/docs/index.html#Manual/Introduction/Creating_a_scene • Load a custom model instead of using geometry. • Add a light & cast shadows.
  • 7. . ├── index.html ├── js │ ├── ext │ │ ├── three.js │ │ └── three.modules.js │ └── main.js └── run.py directory structure
  • 8. 1 console.info("main.js loaded"); 2 3 var scene = new THREE.Scene(); 4 var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); 5 console.info("scene & camera created"); 6 7 var renderer = new THREE.WebGLRenderer(); 8 renderer.setSize(window.innerWidth, window.innerHeight); 9 console.info("renderer created"); 10 11 document.body.appendChild(renderer.domElement); 12 console.info("DOM modified"); 13 14 var geometry = new THREE.BoxGeometry(1, 1, 1); 15 var material = new THREE.MeshBasicMaterial({color: 0x00ff00}); 16 var cube = new THREE.Mesh(geometry, material); 17 scene.add(cube); 18 console.info("Cube created"); 19 20 camera.position.z = 5; 21 console.info("Camera repositioned"); 22 23 function render() { 24 // Animate the cube 25 cube.rotation.x += 0.01; 26 cube.rotation.y += 0.01; 27 requestAnimationFrame(render); 28 renderer.render(scene, camera); 29 } 30 console.info("Starting render") 31 render();
  • 10. Free “digger” model from TurboSquid. loading custom models
  • 11. Model geometry must be triangulated. Note how there are now diagonal lines and all of the surfaces have triangles.
  • 12. Sidebar: Use a 3D graphics program to adjust your model’s geometry. Any 3D program can adjust geometry. Blender is free and can easily do this for us.
  • 13. Loading JSON • Use the free utility from the three.js project to convert from OBJ to JSON.
 https://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py • Use the built-in JSONLoader to load the object. • Watch file sizes! If you are using a “real” web server enable gzip compression!
  • 14. 1 var greenMat = new THREE.MeshBasicMaterial({color: 0x00ff00}); 2 3 // Create a JSON loader 4 var loader = new THREE.JSONLoader(); 5 6 // Load triangulated model as JSON 7 loader.load( 8 'models/digger_scaled_tri.json', 9 // onLoad callback 10 function (geometry) { 11 // Add geometry to a new mesh combining a material 12 var object = new THREE.Mesh(geometry, greenMat); 13 // Add our object to the scene 14 scene.add(object); 15 } 16 );
  • 15. demo
  • 17. three.js has many types of lights but we’ll focus on the directional light. • Directional lights shine from a specific direction not a specific location. • The documentation describes this as a light that acts like the sun. • Shadows are only calculated for objects that exist within the light’s shadow camera’s field of view. • The shadow camera for a directional light is orthographic (think 2D, e.g. top down). • In the picture to the left the orange lines denote the shadow camera’s field of view.
  • 18. three.js uses shadow mapping with the WebGL renderer. • Shadow mapping was introduced by Lance Williams in 1978. • Computation takes place on the GPU with WebGL. • Think of a shadow map like a texture map. They are applied (mapped) to the surface of the geometry during rendering. • The size of the map directly affects the shadow detail because the size of the map is the size of the buffer and a larger map/buffer can hold more information about the shadow. • Shadows aren’t necessarily hard but they require some tweaking and experimenting to get right.
  • 19. demo
  • 20. The Leap Motion Controller lets you use your computer in a whole new way. Reach out and swipe, grab, pinch, or punch your way through the digital world. • Uses two wide angle IR cameras to detect hands in 3D space above the device. • Tracks hands, fingers and wrists / arms and translates motion from real world space to 3D environment coordinates. • For developers it is plug & play and very accessible. • It is a bit finicky and detecting / supporting custom gestures can be laborious. Leap Motion Controller
  • 21. demo
  • 22. In 2015 I was contracted to help build a 3D interactive experience exploring the restoration of the U.S. Capitol Dome. The interactive experience took place at the White House Correspondents Dinner. The scope was narrowed down to build a kiosk where visitors could approach one of two large displays and interact with a 3D model of the dome using a Leap Motion controller. Washington Post Special Project
  • 23. 3D Model three.js enabled the rapid development & delivery of the experience within a browser. Many issues could be ignored because we were operating as a kiosk in a known environment: • Device hardware specs were known (fast enough to ignore optimizations) • No external bandwidth requirements (all files are hosted & served locally) • Human explanations & help to explain how to interact with the demo. • No need to open up “heavier” tooling such as Unity. Leap Motion Web Browser three.js
  • 25. Things didn’t go as planned
  • 26. 3 Weeks to Deliver Interaction
 Spent the majority of the time figuring out gestures and hand controls. Tried “gimbal” controls. Settled on “joystick” controls. “Hot Spots” & Polishing
 Used ray casting for “fast enough” collision detection between hands and “hot spots”. Added dynamic “demo” mode to pique interest. Rendering & Lighting
 Lost a good chunk of time to loading a model of the entire capital. Reverted to just the dome. Had trouble with shadows & model size.
  • 27. demo