SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
BEGIN THREE.JS
Yi-Fan Liao
Special thanks to 3D modelers @shrimp & @yushen
http://mrdoob.github.com/three.js/
DEMO LINK
http://begeeben.github.io/begin-threejs/
SOURCE CODE
https://github.com/begeeben/begin-threejs
A SIMPLE EXAMPLE
RENDERER
var	
  renderer	
  =	
  new	
  THREE.WebGLRenderer();
renderer.setSize(	
  window.innerWidth,	
  window.innerHeight	
  );
document.body.appendChild(	
  renderer.domElement	
  );
SCENE
var	
  scene	
  =	
  new	
  THREE.Scene();
CAMERA
//	
  new	
  THREE.PerspectiveCamera(fov,	
  aspect,	
  near,	
  far)
var	
  camera	
  =	
  new	
  THREE.PerspectiveCamera(75,	
  
	
  	
  window.innerWidth/window.innerHeight,	
  0.1,	
  1000);
camera.position.set(0,	
  0,	
  5);
PERSPECTIVE	
  CAMERA
鏡頭與焦距與視⾓角
fov
far
near
aspect = width/height
OBJECT
var	
  geometry	
  =	
  new	
  THREE.CubeGeometry(1,1,1);
var	
  material	
  =	
  new	
  THREE.MeshBasicMaterial({
	
  	
  color:	
  0x199509
});
var	
  mesh	
  =	
  new	
  THREE.Mesh(geometry,	
  material);
scene.add(mesh);
RENDER()
function	
  render()	
  {
	
  	
  requestAnimationFrame(render);
	
  	
  mesh.rotation.x	
  +=	
  0.01;
	
  	
  mesh.rotation.y	
  +=	
  0.01;
	
  	
  renderer.render(scene,	
  camera);
}
render();
requestAnimationFrame for Smart Animating
Better JavaScript animations with requestAnimationFrame
CAMERAS
Cameras on OpenGL ES 2.x – The ModelViewProjection Matrix
ADD TEXTURE
TEXTURE	
  MAP
var	
  geometry	
  =	
  new	
  THREE.CubeGeometry(1,1,1);
//	
  Load	
  image	
  and	
  create	
  texture.
var	
  imgUrl	
  =	
  'images/jumper.jpg';
var	
  map	
  =	
  THREE.ImageUtils.loadTexture(imgUrl);
//	
  For	
  shiny	
  surfaces.
var	
  material	
  =	
  new	
  THREE.MeshPhongMaterial({	
  map:	
  map	
  });
var	
  mesh	
  =	
  new	
  THREE.Mesh(geometry,	
  material);
scene.add(mesh);
LIGHT
//	
  Directional	
  light	
  affects	
  objects	
  using	
  
MeshLambertMaterial	
  or	
  MeshPhongMaterial.
var	
  light	
  =	
  new	
  THREE.DirectionalLight(	
  0xffffff,	
  1	
  );
light.position.set(	
  0,	
  0,	
  1	
  );
scene.add(light);
LIGHTS
MATERIALS
Lights and Materials inThree.js
http://threejs.org/examples/webgl_materials.html
MeshBasicMaterial
MeshLambertMaterial
MeshPhongMaterial
LOAD A 3D MODEL
3D	
  MODEL
//	
  Load	
  ufo	
  image.
var	
  ufoMap	
  =	
  THREE.ImageUtils.loadTexture(
'models/ufo/textures/ufo.png');
var	
  ufoMaterial	
  =	
  new	
  THREE.MeshPhongMaterial({map:ufoMap});
//	
  Load	
  ufo	
  3D	
  JSON	
  model.
var	
  ufo;
var	
  loader	
  =	
  new	
  THREE.JSONLoader();
loader.load('models/ufo/ufo.js',	
  function(geometry)	
  {
	
  	
  ufo	
  =	
  new	
  THREE.Mesh(geometry,	
  ufoMaterial);
	
  	
  scene.add(ufo);
});
LOADER
ColladaLoader	
  for	
  Collada(.dae):	
  An	
  XML-­‐based	
  schema	
  to	
  make	
  it	
  
easy	
  to	
  transport	
  3D	
  assets	
  be-­‐tween	
  applications.
JSONLoader	
  for	
  JSON	
  Model	
  Format:	
  More	
  concise	
  and	
  loading	
  is	
  
faster	
  than	
  using	
  COLLADA	
  because	
  browsers	
  can	
  load	
  it	
  directly	
  
into	
  JavaScript	
  data	
  structures.
BinaryLoader	
  for	
  Binary	
  Model	
  Format:	
  The	
  binary	
  equivalent	
  to	
  
text-­‐based	
  JSON	
  format	
  but	
  smaller	
  in	
  size.
UTF8Loader	
  for	
  UTF-­‐8	
  Encoded	
  Format:	
  An	
  even	
  more	
  economical	
  
data	
  format.
SceneLoader	
  for	
  JSON	
  Scene	
  Format:	
  The	
  format	
  able	
  to	
  store	
  
multiple	
  models	
  or	
  an	
  entire	
  scene,	
  including	
  lights,	
  camera...	
  
etc.
MODEL CONVERSION
EXPORTERS
	
  Blender
	
  3DS	
  MAX
	
  Maya
CONVERTERS
To	
  JSON	
  format
	
  ctm
	
  Autodesk	
  Maya	
  .fbx
	
  Wavefront	
  .obj
To	
  utf8	
  format
	
  utf8
ANIMATE A 3D MODEL
MORPH	
  EXAMPLE
//	
  Load	
  3D	
  model.
var	
  loadCounter	
  =	
  2;
function	
  checkLoadingComplete()	
  {
	
  	
  loadCounter	
  -­‐=	
  1;
	
  	
  if(loadCounter	
  ===	
  0)	
  scene.add(boyMesh);
};
//	
  Textures.
//	
  How	
  the	
  image	
  is	
  applied	
  to	
  the	
  object.
var	
  mapping	
  =	
  new	
  THREE.UVMapping();
var	
  boyMap	
  =	
  THREE.ImageUtils.loadTexture(
'models/boy/textures/boy.png',	
  
mapping,	
  checkLoadingComplete());
MORPH	
  EXAMPLE
//	
  Body.
var	
  boyMesh;
var	
  loader	
  =	
  new	
  THREE.JSONLoader();
loader.load('models/boy/boy.js',	
  function(geometry)	
  {
	
  	
  geometry.computeMorphNormals();
	
  	
  var	
  materialBoy	
  =	
  new	
  THREE.MeshPhongMaterial({
	
  	
  	
  	
  color:	
  0xffffff,
	
  	
  	
  	
  specular:	
  0x111111,
	
  	
  	
  	
  shininess:	
  50,
	
  	
  	
  	
  map:	
  boyMap,
	
  	
  	
  	
  morphTargets:	
  true,
	
  	
  	
  	
  morphNormals:	
  true,
	
  	
  	
  	
  wrapAround:	
  true
	
  	
  });
	
  	
  boyMesh	
  =	
  new	
  THREE.MorphAnimMesh(geometry,	
  materialBoy);
	
  	
  boyMesh.castShadow	
  =	
  true;
	
  	
  boyMesh.receiveShadow	
  =	
  true;
	
  	
  //	
  Parse	
  animations	
  in	
  the	
  model	
  file.
	
  	
  boyMesh.parseAnimations();
	
  	
  boyMesh.playAnimation(	
  geometry.firstAnimation,	
  30	
  );
	
  	
  checkLoadingComplete();
});
ANIMATIONS
MORPH
Morph animation example on three.js website
SKELETAL	
  ANIMATION
Skinned animation example on three.js website
BUILD A 3D MENU
TEXT
<script	
  src="fonts/optimer_regular.typeface.js"></script>
var	
  textGeometry	
  =	
  new	
  THREE.TextGeometry(	
  text,	
  {	
  ...
MOUSE	
  EVENT
var	
  projector	
  =	
  new	
  THREE.Projector();
var	
  mouse	
  =	
  new	
  THREE.Vector2();
mouse.x	
  =	
  (	
  event.clientX	
  /	
  container.clientWidth	
  )	
  *	
  2	
  -­‐	
  1;
mouse.y	
  =	
  -­‐	
  (	
  event.clientY	
  /	
  container.clientHeight	
  )	
  *	
  2	
  +	
  1;
//	
  Unproject	
  the	
  screen	
  space	
  mouse	
  point	
  to	
  3D	
  world	
  space.
var	
  vector	
  =	
  new	
  THREE.Vector3(	
  mouse.x,	
  mouse.y,	
  0.5	
  );
//	
  Cast	
  a	
  ray	
  from	
  the	
  camera	
  according	
  to	
  the	
  vector.
var	
  raycaster	
  =	
  projector.pickingRay(	
  vector.clone(),	
  camera	
  );
//	
  Get	
  objects	
  that	
  intersects	
  the	
  ray.
var	
  intersects	
  =	
  raycaster.intersectObjects(	
  items,	
  true	
  );
if	
  (	
  intersects.length	
  >	
  0	
  )	
  {	
  ...
BLEND 3D CONTENT IN HTML
SAMPLE SLOT GAME
RESOURCES
	
  WebGL:	
  Up	
  and	
  Running	
  
Tools
	
  https://github.com/sole/tween.js
	
  three.js	
  boilerplate
	
  THREECONVERT	
  OSX	
  BATCH	
  EXPORTER	
  UTILITY	
  FOR	
  THREE.JS
	
  MD2	
  to	
  JSON	
  Converter
Show	
  Cases
	
  Verold	
  STUDIO
	
  Simple	
  facial	
  rigging	
  utilizing	
  morph	
  targets
	
  WebGL	
  -­‐	
  Three.js	
  +	
  impactJS
Tutorials
	
  Building	
  the	
  Game:	
  Part	
  3	
  -­‐	
  Skinning	
  &	
  Animation
	
  Verification	
  of	
  using	
  multiple	
  textures	
  with	
  three.js	
  
cubes
ABOUT
廖一帆
Front End Engineer
begeeben@gmail.com
github.com/begeeben
Yi-Fan Liao
begeeben.wordpress.com/
www.facebook.com/yifan.liao

Weitere ähnliche Inhalte

Was ist angesagt?

The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202Mahmoud Samir Fayed
 
WebGL and three.js - Web 3D Graphics
WebGL and three.js - Web 3D Graphics WebGL and three.js - Web 3D Graphics
WebGL and three.js - Web 3D Graphics PSTechSerbia
 
5 tips for your HTML5 games
5 tips for your HTML5 games5 tips for your HTML5 games
5 tips for your HTML5 gamesErnesto Jiménez
 
The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189Mahmoud Samir Fayed
 
Rotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billyRotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billynimbleltd
 
Introduction to threejs
Introduction to threejsIntroduction to threejs
Introduction to threejsGareth Marland
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricksdeanhudson
 
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートIIopenFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートIIAtsushi Tadokoro
 

Was ist angesagt? (8)

The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202
 
WebGL and three.js - Web 3D Graphics
WebGL and three.js - Web 3D Graphics WebGL and three.js - Web 3D Graphics
WebGL and three.js - Web 3D Graphics
 
5 tips for your HTML5 games
5 tips for your HTML5 games5 tips for your HTML5 games
5 tips for your HTML5 games
 
The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189
 
Rotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billyRotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billy
 
Introduction to threejs
Introduction to threejsIntroduction to threejs
Introduction to threejs
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricks
 
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートIIopenFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
 

Ähnlich wie Begin three.js.key

WebGL - 3D programming
WebGL - 3D programmingWebGL - 3D programming
WebGL - 3D programmingMinh Ng
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLgerbille
 
Migrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityMigrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityDenis Radin
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 
WebGL - It's GO Time
WebGL - It's GO TimeWebGL - It's GO Time
WebGL - It's GO TimeTony Parisi
 
Getting Started in VR with JS
Getting Started in VR with JSGetting Started in VR with JS
Getting Started in VR with JSRudy Jahchan
 
Integrating Angular js & three.js
Integrating Angular js & three.jsIntegrating Angular js & three.js
Integrating Angular js & three.jsJosh Staples
 
Augmented reality in web rtc browser
Augmented reality in web rtc browserAugmented reality in web rtc browser
Augmented reality in web rtc browserALTANAI BISHT
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScriptersgerbille
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGLChihoon Byun
 
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014Verold
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSphilogb
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datosphilogb
 
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
 
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
 
Using babylon js to create apps & games for all web gl devices
Using babylon js to create apps & games for all web gl devicesUsing babylon js to create apps & games for all web gl devices
Using babylon js to create apps & games for all web gl devicesDavid Catuhe
 
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceViktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceLviv Startup Club
 
Developing Web Graphics with WebGL
Developing Web Graphics with WebGLDeveloping Web Graphics with WebGL
Developing Web Graphics with WebGLTony Parisi
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todaygerbille
 

Ähnlich wie Begin three.js.key (20)

WebGL - 3D programming
WebGL - 3D programmingWebGL - 3D programming
WebGL - 3D programming
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
 
Migrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityMigrating your Web app to Virtual Reality
Migrating your Web app to Virtual Reality
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 
WebGL - It's GO Time
WebGL - It's GO TimeWebGL - It's GO Time
WebGL - It's GO Time
 
Getting Started in VR with JS
Getting Started in VR with JSGetting Started in VR with JS
Getting Started in VR with JS
 
Integrating Angular js & three.js
Integrating Angular js & three.jsIntegrating Angular js & three.js
Integrating Angular js & three.js
 
Augmented reality in web rtc browser
Augmented reality in web rtc browserAugmented reality in web rtc browser
Augmented reality in web rtc browser
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScripters
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGL
 
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
 
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
 
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 ]
 
COMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptxCOMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptx
 
Using babylon js to create apps & games for all web gl devices
Using babylon js to create apps & games for all web gl devicesUsing babylon js to create apps & games for all web gl devices
Using babylon js to create apps & games for all web gl devices
 
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceViktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning Service
 
Developing Web Graphics with WebGL
Developing Web Graphics with WebGLDeveloping Web Graphics with WebGL
Developing Web Graphics with WebGL
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
 

Kürzlich hochgeladen

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Kürzlich hochgeladen (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Begin three.js.key

  • 1. BEGIN THREE.JS Yi-Fan Liao Special thanks to 3D modelers @shrimp & @yushen
  • 6. RENDERER var  renderer  =  new  THREE.WebGLRenderer(); renderer.setSize(  window.innerWidth,  window.innerHeight  ); document.body.appendChild(  renderer.domElement  );
  • 7. SCENE var  scene  =  new  THREE.Scene();
  • 8. CAMERA //  new  THREE.PerspectiveCamera(fov,  aspect,  near,  far) var  camera  =  new  THREE.PerspectiveCamera(75,      window.innerWidth/window.innerHeight,  0.1,  1000); camera.position.set(0,  0,  5);
  • 10. OBJECT var  geometry  =  new  THREE.CubeGeometry(1,1,1); var  material  =  new  THREE.MeshBasicMaterial({    color:  0x199509 }); var  mesh  =  new  THREE.Mesh(geometry,  material); scene.add(mesh);
  • 11. RENDER() function  render()  {    requestAnimationFrame(render);    mesh.rotation.x  +=  0.01;    mesh.rotation.y  +=  0.01;    renderer.render(scene,  camera); } render(); requestAnimationFrame for Smart Animating Better JavaScript animations with requestAnimationFrame
  • 12. CAMERAS Cameras on OpenGL ES 2.x – The ModelViewProjection Matrix
  • 14. TEXTURE  MAP var  geometry  =  new  THREE.CubeGeometry(1,1,1); //  Load  image  and  create  texture. var  imgUrl  =  'images/jumper.jpg'; var  map  =  THREE.ImageUtils.loadTexture(imgUrl); //  For  shiny  surfaces. var  material  =  new  THREE.MeshPhongMaterial({  map:  map  }); var  mesh  =  new  THREE.Mesh(geometry,  material); scene.add(mesh);
  • 15. LIGHT //  Directional  light  affects  objects  using   MeshLambertMaterial  or  MeshPhongMaterial. var  light  =  new  THREE.DirectionalLight(  0xffffff,  1  ); light.position.set(  0,  0,  1  ); scene.add(light);
  • 17. MATERIALS Lights and Materials inThree.js http://threejs.org/examples/webgl_materials.html MeshBasicMaterial MeshLambertMaterial MeshPhongMaterial
  • 18. LOAD A 3D MODEL
  • 19. 3D  MODEL //  Load  ufo  image. var  ufoMap  =  THREE.ImageUtils.loadTexture( 'models/ufo/textures/ufo.png'); var  ufoMaterial  =  new  THREE.MeshPhongMaterial({map:ufoMap}); //  Load  ufo  3D  JSON  model. var  ufo; var  loader  =  new  THREE.JSONLoader(); loader.load('models/ufo/ufo.js',  function(geometry)  {    ufo  =  new  THREE.Mesh(geometry,  ufoMaterial);    scene.add(ufo); });
  • 20. LOADER ColladaLoader  for  Collada(.dae):  An  XML-­‐based  schema  to  make  it   easy  to  transport  3D  assets  be-­‐tween  applications. JSONLoader  for  JSON  Model  Format:  More  concise  and  loading  is   faster  than  using  COLLADA  because  browsers  can  load  it  directly   into  JavaScript  data  structures. BinaryLoader  for  Binary  Model  Format:  The  binary  equivalent  to   text-­‐based  JSON  format  but  smaller  in  size. UTF8Loader  for  UTF-­‐8  Encoded  Format:  An  even  more  economical   data  format. SceneLoader  for  JSON  Scene  Format:  The  format  able  to  store   multiple  models  or  an  entire  scene,  including  lights,  camera...   etc.
  • 21. MODEL CONVERSION EXPORTERS  Blender  3DS  MAX  Maya CONVERTERS To  JSON  format  ctm  Autodesk  Maya  .fbx  Wavefront  .obj To  utf8  format  utf8
  • 22. ANIMATE A 3D MODEL
  • 23. MORPH  EXAMPLE //  Load  3D  model. var  loadCounter  =  2; function  checkLoadingComplete()  {    loadCounter  -­‐=  1;    if(loadCounter  ===  0)  scene.add(boyMesh); }; //  Textures. //  How  the  image  is  applied  to  the  object. var  mapping  =  new  THREE.UVMapping(); var  boyMap  =  THREE.ImageUtils.loadTexture( 'models/boy/textures/boy.png',   mapping,  checkLoadingComplete());
  • 24. MORPH  EXAMPLE //  Body. var  boyMesh; var  loader  =  new  THREE.JSONLoader(); loader.load('models/boy/boy.js',  function(geometry)  {    geometry.computeMorphNormals();    var  materialBoy  =  new  THREE.MeshPhongMaterial({        color:  0xffffff,        specular:  0x111111,        shininess:  50,        map:  boyMap,        morphTargets:  true,        morphNormals:  true,        wrapAround:  true    });    boyMesh  =  new  THREE.MorphAnimMesh(geometry,  materialBoy);    boyMesh.castShadow  =  true;    boyMesh.receiveShadow  =  true;    //  Parse  animations  in  the  model  file.    boyMesh.parseAnimations();    boyMesh.playAnimation(  geometry.firstAnimation,  30  );    checkLoadingComplete(); });
  • 26. MORPH Morph animation example on three.js website
  • 27. SKELETAL  ANIMATION Skinned animation example on three.js website
  • 28. BUILD A 3D MENU
  • 30. MOUSE  EVENT var  projector  =  new  THREE.Projector(); var  mouse  =  new  THREE.Vector2(); mouse.x  =  (  event.clientX  /  container.clientWidth  )  *  2  -­‐  1; mouse.y  =  -­‐  (  event.clientY  /  container.clientHeight  )  *  2  +  1; //  Unproject  the  screen  space  mouse  point  to  3D  world  space. var  vector  =  new  THREE.Vector3(  mouse.x,  mouse.y,  0.5  ); //  Cast  a  ray  from  the  camera  according  to  the  vector. var  raycaster  =  projector.pickingRay(  vector.clone(),  camera  ); //  Get  objects  that  intersects  the  ray. var  intersects  =  raycaster.intersectObjects(  items,  true  ); if  (  intersects.length  >  0  )  {  ...
  • 31. BLEND 3D CONTENT IN HTML
  • 33. RESOURCES  WebGL:  Up  and  Running   Tools  https://github.com/sole/tween.js  three.js  boilerplate  THREECONVERT  OSX  BATCH  EXPORTER  UTILITY  FOR  THREE.JS  MD2  to  JSON  Converter Show  Cases  Verold  STUDIO  Simple  facial  rigging  utilizing  morph  targets  WebGL  -­‐  Three.js  +  impactJS Tutorials  Building  the  Game:  Part  3  -­‐  Skinning  &  Animation  Verification  of  using  multiple  textures  with  three.js   cubes
  • 34. ABOUT 廖一帆 Front End Engineer begeeben@gmail.com github.com/begeeben Yi-Fan Liao begeeben.wordpress.com/ www.facebook.com/yifan.liao