SlideShare a Scribd company logo
WebGL And Three.js
EIA - 2014/ 07/ 16
http://about.me/eia
About
WIKI
WebGL是一項利用JavaScript API呈現3D電腦圖形的技術,有別於過往需加裝瀏覽
器外掛程式,透過WebGL的技術,只需要編寫網頁代碼即可實現3D圖像的展示。
WebGL的規格尚在發展中,由非營利的Khronos Group管理。
WebGL基於OpenGL ES 2.0,提供了3D影像的程式介面。它使用HTML5 Canvas並
允許利用文件物件模型介面。可利用部分Javascript實作自動記憶體管理。
http://zh.wikipedia.org/wiki/WebGL
http://en.wikipedia.org/wiki/WebGL
WebGL API
WebGL™ is an immediate mode 3D rendering API designed for the web. It is derived from OpenGL® ES 2.0, and provides similar
rendering functionality, but in an HTML context. WebGL is designed as a rendering context for the HTML Canvas element. The
HTML Canvas provides a destination for programmatic rendering in web pages, and allows for performing that rendering using
different rendering APIs. The only such interface described as part of the Canvas specification is the 2D canvas rendering context,
CanvasRenderingContext2D. This document describes another such interface, WebGLRenderingContext, which presents the
WebGL API.
The immediate mode nature of the API is a divergence from most web APIs. Given the many use cases of 3D graphics, WebGL
chooses the approach of providing flexible primitives that can be applied to any use case. Libraries can provide an API on top of
WebGL that is more tailored to specific areas, thus adding a convenience layer to WebGL that can accelerate and simplify
development. However, because of its OpenGL ES 2.0 heritage, it should be straightforward for developers familiar with modern
desktop OpenGL or OpenGL ES 2.0 development to transition to WebGL development.
http://www.khronos.org/registry/webgl/specs/latest/1.0/
Browser Support
caniuse- 14 / 06 / 06
http://caniuse.com/#feat=webgl
Parent feature: Canvas (basic support)
http://webglsamples.googlecode.com/hg/aquarium/aquarium.html
IE11
fps: 13
Chrome
fps: 59
IE8 IE11 http://onemillionreasons.audi.de/
Chrome
http://activetheory.net/
Chrome IE11 IE8
WebGL in Safari
Apple WWDC 2014
http://learningwebgl.com/blog/?p=6368
Mobile : THREE.CanvasRenderer();
Sony Z1 (2013)
HTC Desire HD (2010)
iPhone 4 (2010)
Frameworks
http://www.khronos.org/webgl/wiki/User_Contributions
Debug
Debug
WebGL Inspector
http://www.khronos.org/webgl/wiki/Debugging
http://benvanik.github.io/WebGL-Inspector/
140716 : 同業前端聚會分享 - webgl 與 three.js
140716 : 同業前端聚會分享 - webgl 與 three.js
140716 : 同業前端聚會分享 - webgl 與 three.js
The popup is extensive and first shows
a mesh of the element drawn that can
be zoomed in
and out with the mouse wheel and
rotated while holding down a mouse
button.
BeginningWebGL for HTML5
Three.JS
three.js - JavaScript 3D library
http://threejs.org/
20 Impressive Examples for Learning WebGL with Three.js
http://tutorialzine.com/2013/09/20-impressive-examples-for-learning-webgl-with-three-js/
http://threejs.org/examples/
Coding
scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0xDDDDDD, 0.00001);
renderer = new THREE.WebGLRenderer({antialias:true});
renderer.setClearColor(scene.fog.color,1);
renderer.setSize( window.innerWidth, window.innerHeight );
var mapUrl = "../images/molumen_small_funny_angry_monster.jpg";
var map = THREE.ImageUtils.loadTexture(mapUrl);
// Now, create a Phong material to show shading; pass in the map
var material = new THREE.MeshPhongMaterial({ map: map });
// Create the cube geometry
var geometry = new THREE.CubeGeometry(1, 1, 1);
// And put the geometry and material together into a mesh
cube = new THREE.Mesh(geometry, material);
// Turn it toward the scene, or we won't see the cube shape!
cube.rotation.x = Math.PI / 5;
cube.rotation.y = Math.PI / 5;
// Add the cube to our scene
scene.add( cube );
Away3d 4.x ?
1. Renderer
> webgl vs canvas (performance)
> CSS3DRenderer, SoftwareRenderer
2. Geometry
3. Material
4. Camera
5. 3d Model
6. Interactive
7. Particles
My ThreeJS Learning Experience
Renderer
WebGL / CANVAS
http://threejs.org/examples/#canvas_interactive_cubes
http://threejs.org/examples/#webgl_interactive_cubes
canvas webgl
http://threejs.org/examples/#css3d_molecules
CSS3DRenderer
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer = new THREE.CanvasRenderer();
** THREE.Particle(material); // CanvasRenderer
** THREE.ParticleSystem(geom, material); // WebGLRenderer
Geometry
http://threejs.org/examples/#webgl_geometries
http://threejs.org/examples/#webgl_geometry_nurbs
http://threejs.org/examples/#canvas_geometry_terrain
http://threejs.org/examples/#canvas_geometry_birds
VertexNormals();
http://threejs.org/examples/#webgl_morphnormals
140716 : 同業前端聚會分享 - webgl 與 three.js
140716 : 同業前端聚會分享 - webgl 與 three.js
http://threejs.org/examples/#webgl_geometry_normals
Materials
http://threejs.org/examples/#canvas_materials
http://threejs.org/examples/#canvas_materials_depth
THREE.MeshDepthMaterial
Dynamic Textures
http://threejs.org/examples/#canvas_materials_video
https://github.com/tparisi/WebGLBook/blob/master/Chapter%206/integration-canvas.html
http://threejs.org/examples/#webgl_materials_lightmap
ShaderMaterial
Camera
Orthographic | Perspective
https://github.com/josdirksen/learning-threejs
https://github.com/josdirksen/learning-threejs/blob/master/chapter-02/07-both-cameras.html
3d Model
http://v.hxsd.com/
140716 : 同業前端聚會分享 - webgl 與 three.js
140716 : 同業前端聚會分享 - webgl 與 three.js
https://github.com/tparisi/WebGLBook/blob/master/Chapter%204/keyframe-robot.html
No keyframes in 3D model
.dae .js
.dae
http://stackoverflow.com/questions/110426/how-to-serve-files-from-iis-6-on-windows-server-2003
cache!
140716 : 同業前端聚會分享 - webgl 與 three.js
Particles
http://threejs.org/examples/#canvas_particles_sprites
Sprites
http://threejs.org/examples/#webgl_particles_shapes
Sparks
http://threejs.org/examples/#webgl_particles_shapes
- addInitializer();
- addAction();
Spark.js
https://github.com/zz85/sparks.js
Spark.js
MIT license
Spark.js
Interaction
Interaction
WebGL is only a drawing system and, as such, has no
built-in support for hit detection. You need to build that
yourself. Thankfully, Three.js gives us the support we need
so that we can tell when the mouse is over an object.
WebGL: Up and Running
Books
BeginningWebGL for HTML5
https://www.apress.com/9781430239963
WebGL: Up and Running
Learning Three.js:
The JavaScript 3D Library for WebGL
http://shop.oreilly.com/product/0636920024729.do?cmp=af-prog-books-
video-product-cj_auwidget217_0636920024729_4047008
http://www.packtpub.com/learning-three-js-javascript-3d-library-for-webgl/book
http://www.amazon.com/Learning-Three-js-JavaScript-Library-WebGL/dp/1782166289
Reference
http://learningwebgl.com/blog/
Sample
http://threejs.org/examples/
https://code.google.com/p/webglsamples/
http://tutorialzine.com/2013/09/20-impressive-examples-for-learning-webgl-with-three-js/
This is a list of all the WebGL related activities happening on the web. If you know of anything missing
or out of date on this list, we invite you to add it or update it.
http://www.khronos.org/webgl/wiki/User_Contributions
Reference
Phong reflection model
http://en.wikipedia.org/wiki/Phong_reflection_model
Lambertian reflectance
http://en.wikipedia.org/wiki/Lambertian_reflectance
Mandelbrot set
http://en.wikipedia.org/wiki/Mandelbrot_set
Julia set
http://en.wikipedia.org/wiki/Julia_set
Thanks!

More Related Content

PPTX
Developing Web Graphics with WebGL
PDF
Mini-Training: JS Graphical Libraries
PDF
Jak tvořit hry na webu?
PDF
Processing.js vs. three.js
PDF
Web3D - Semantic standards, WebGL, HCI
PDF
WebGL and three.js
PDF
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
PPSX
A terra, planeta do sistema solar
Developing Web Graphics with WebGL
Mini-Training: JS Graphical Libraries
Jak tvořit hry na webu?
Processing.js vs. three.js
Web3D - Semantic standards, WebGL, HCI
WebGL and three.js
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
A terra, planeta do sistema solar

Viewers also liked (6)

PDF
JSFL share
PPT
AIR 開發應用程式實務
PPSX
O renacemento espanol
PPT
London 2012
PDF
Jacek Yerka
PPSX
O traballo dun ferreiro
JSFL share
AIR 開發應用程式實務
O renacemento espanol
London 2012
Jacek Yerka
O traballo dun ferreiro
Ad

Similar to 140716 : 同業前端聚會分享 - webgl 與 three.js (20)

PPTX
WebGL - 3D programming
PDF
Creating Applications with WebGL and Three.js
PDF
PPTX
HTML5DevConf 2013 (October): WebGL is a game changer!
PPTX
Interactive 3D graphics for web with three.js, Andrey Vedilin, DataArt
PDF
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
PDF
ENEI16 - WebGL with Three.js
PDF
WebGL
PDF
Augmented reality in web rtc browser
PDF
Leaving Flatland: Getting Started with WebGL- SXSW 2012
KEY
Leaving Flatland: getting started with WebGL
KEY
WebGL Awesomeness
PDF
Three.js basics
PDF
Power of WebGL (FSTO 2014)
PDF
Introducao ao Curso Anselmo Cardoso de Paiva Ufma
ODP
Introduction to threejs
PPTX
WebGL: Yesterday, Today, Tomorrow
PPTX
WebGL Crash Course
PDF
The Power of WebGL - Hackeando sua GPU com JavaScript
PDF
Webgl para JavaScripters
WebGL - 3D programming
Creating Applications with WebGL and Three.js
HTML5DevConf 2013 (October): WebGL is a game changer!
Interactive 3D graphics for web with three.js, Andrey Vedilin, DataArt
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
ENEI16 - WebGL with Three.js
WebGL
Augmented reality in web rtc browser
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: getting started with WebGL
WebGL Awesomeness
Three.js basics
Power of WebGL (FSTO 2014)
Introducao ao Curso Anselmo Cardoso de Paiva Ufma
Introduction to threejs
WebGL: Yesterday, Today, Tomorrow
WebGL Crash Course
The Power of WebGL - Hackeando sua GPU com JavaScript
Webgl para JavaScripters
Ad

Recently uploaded (20)

PPTX
Machine Learning_overview_presentation.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Machine Learning_overview_presentation.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
MYSQL Presentation for SQL database connectivity
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
A comparative analysis of optical character recognition models for extracting...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Encapsulation theory and applications.pdf
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx
Network Security Unit 5.pdf for BCA BBA.
Dropbox Q2 2025 Financial Results & Investor Presentation
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx

140716 : 同業前端聚會分享 - webgl 與 three.js