SlideShare a Scribd company logo
1 of 15
© 2018 Solteq. All rights reserved.
Easy 3d drawing with three.js
TampereJS June 2018
© 2018 Solteq. All rights reserved.
Jere Kuusela
• Software Developer at Solteq
• jere.kuusela@iki.fi
• jere.kuusela@solteq.com
• First talk ever!
© 2018 Solteq. All rights reserved.
WebGL
• JavaScript API to implement 3d graphics in modern browsers
• Wide support
• Uses HTML <canvas> element
• Uses hardware-acceleration
• Low level -> 
• Multiple higher level libraries
• three.js
• PhiloGL
• GLGE
• J3D
• …
© 2018 Solteq. All rights reserved.© 2018 Solteq. All rights reserved.
Demo 1
© 2018 Solteq. All rights reserved.
Recap of Demo 1
• Scene: Container for objects which you want to draw
• Objects: Actual objects which usually need both geometry and material
• Camera: Location and direction where you are looking at the scene
• Renderer: Uses WebGL to draw pixels based on the scene and the camera
© 2018 Solteq. All rights reserved.
Closer look at objects
• Base class for points, lines, meshes, cameras, scenes, lights …
• Every object can have children
• For example a camera can be attached to a geometry
• Most objects should have a parent
• You can only render one object (usually the scene) and its children
• Object’s location is relative to its parent <- IMPORTANT!
• Allows easily moving complex objects
© 2018 Solteq. All rights reserved.© 2018 Solteq. All rights reserved.
Demo 2
© 2018 Solteq. All rights reserved.
Recap of Demo 2
• A car built from a cone, 4 cylinders (tires) and a camera
• Cars were attached to a proxy object which was used to move them around
• No need to update locations of cars and tires manually
• An image was added as a floor for visual purposes
• The scene only directly included the floor and the proxy object!
• Camera can be toggled by simply changing which camera is used in render function
© 2018 Solteq. All rights reserved.
Controlling camera manually?
• No first class support for moving a camera with mouse
• But lots of examples which contain reusable code: https://threejs.org/examples/
• https://threejs.org/examples/#misc_controls_orbit
• https://threejs.org/examples/#misc_controls_trackball
• Have to download the required JS file manually
• But only a few lines of codes required to get it working
© 2018 Solteq. All rights reserved.
Lights and shadows
• Multiple choices: ambient, directional, spotlight, point, …
• This is where the easy ends
• Lots of things which can go wrong -> nothing appears on the screen 
• Use helpers to visualize lights and shadows when debugging
© 2018 Solteq. All rights reserved.© 2018 Solteq. All rights reserved.
Demo 3
© 2018 Solteq. All rights reserved.
Recap of Demo 3
• Imported camera controls JS-file
• One line of code to get it working properly
• Added a light to cars (copypaste from three.js documentation)
• But no light shows up
• Helper objects appear so can see that the light is there
© 2018 Solteq. All rights reserved.
Lights and shadows, again
• Lights require:
• Proper material (MeshStandardMaterial instead of MeshBasicMaterial)
• Ambient light unless you want the world be pitch black
• Spotlight must have the target location set and added to scene
• Shadows require:
• Light must be set to cast shadow
• Light shadow camera must have proper near and far
• Renderer must have shadowmap enabled
• Floor must be set to receive shadow
• Any other objects must be set to cast shadow
© 2018 Solteq. All rights reserved.© 2018 Solteq. All rights reserved.
Demo 4
© 2018 Solteq. All rights reserved.
Recap of Demo 4
• Changed floor material
• Added ambient light
• Fixed location of lights, added target location
• Also added another light to cars with help of clone()
• Fixed shadow near and far settings
• Added shadowmap to renderer
• Added receive shadows to floor
• Added static towers to cast shadows

More Related Content

Similar to TampereJS June 2018 - Easy 3d drawing with three.js

20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash content20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash contentElad Elrom
 
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...DevGAMM Conference
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
[Unity Forum 2019] Mobile Graphics Optimization Guides
[Unity Forum 2019] Mobile Graphics Optimization Guides[Unity Forum 2019] Mobile Graphics Optimization Guides
[Unity Forum 2019] Mobile Graphics Optimization GuidesOwen Wu
 
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...Kobkrit Viriyayudhakorn
 
【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.
 
Computer Vision based Automated Spare Part Finder App.pptx
Computer Vision based  Automated Spare Part Finder App.pptxComputer Vision based  Automated Spare Part Finder App.pptx
Computer Vision based Automated Spare Part Finder App.pptxssusercd48d1
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)mfrancis
 
Unity - Internals: memory and performance
Unity - Internals: memory and performanceUnity - Internals: memory and performance
Unity - Internals: memory and performanceCodemotion
 
Steganography: a tool for community driven development in TerraTech
Steganography: a tool for community driven development in TerraTechSteganography: a tool for community driven development in TerraTech
Steganography: a tool for community driven development in TerraTechRuss Clarke
 
Point Clouds from Rolling Shutter Cameras
Point Clouds from Rolling Shutter CamerasPoint Clouds from Rolling Shutter Cameras
Point Clouds from Rolling Shutter CamerasChristoph Strecha
 
[TGDF 2020] Mobile Graphics Best Practices for Artist
[TGDF 2020] Mobile Graphics Best Practices for Artist[TGDF 2020] Mobile Graphics Best Practices for Artist
[TGDF 2020] Mobile Graphics Best Practices for ArtistOwen Wu
 
Developing VR Experiences with Unity
Developing VR Experiences with UnityDeveloping VR Experiences with Unity
Developing VR Experiences with UnityMark Billinghurst
 
Building CI from scratch
Building CI from scratchBuilding CI from scratch
Building CI from scratchArtem Nikitin
 
Ng Sydney Dynamic Templates Talk - 18 April 2018
Ng Sydney Dynamic Templates Talk - 18 April 2018Ng Sydney Dynamic Templates Talk - 18 April 2018
Ng Sydney Dynamic Templates Talk - 18 April 2018Roger Kermode
 

Similar to TampereJS June 2018 - Easy 3d drawing with three.js (20)

20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash content20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash content
 
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
[Unity Forum 2019] Mobile Graphics Optimization Guides
[Unity Forum 2019] Mobile Graphics Optimization Guides[Unity Forum 2019] Mobile Graphics Optimization Guides
[Unity Forum 2019] Mobile Graphics Optimization Guides
 
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
 
Compliant S1000D illustrations 2018 - Part 1
Compliant S1000D illustrations 2018 - Part 1Compliant S1000D illustrations 2018 - Part 1
Compliant S1000D illustrations 2018 - Part 1
 
Computer Vision based Automated Spare Part Finder App.pptx
Computer Vision based  Automated Spare Part Finder App.pptxComputer Vision based  Automated Spare Part Finder App.pptx
Computer Vision based Automated Spare Part Finder App.pptx
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
 
Manasa
ManasaManasa
Manasa
 
Unity - Internals: memory and performance
Unity - Internals: memory and performanceUnity - Internals: memory and performance
Unity - Internals: memory and performance
 
Steganography: a tool for community driven development in TerraTech
Steganography: a tool for community driven development in TerraTechSteganography: a tool for community driven development in TerraTech
Steganography: a tool for community driven development in TerraTech
 
Engineering Portfolio
Engineering PortfolioEngineering Portfolio
Engineering Portfolio
 
Point Clouds from Rolling Shutter Cameras
Point Clouds from Rolling Shutter CamerasPoint Clouds from Rolling Shutter Cameras
Point Clouds from Rolling Shutter Cameras
 
[TGDF 2020] Mobile Graphics Best Practices for Artist
[TGDF 2020] Mobile Graphics Best Practices for Artist[TGDF 2020] Mobile Graphics Best Practices for Artist
[TGDF 2020] Mobile Graphics Best Practices for Artist
 
Developing VR Experiences with Unity
Developing VR Experiences with UnityDeveloping VR Experiences with Unity
Developing VR Experiences with Unity
 
Advanced angular
Advanced angularAdvanced angular
Advanced angular
 
Building CI from scratch
Building CI from scratchBuilding CI from scratch
Building CI from scratch
 
Ng Sydney Dynamic Templates Talk - 18 April 2018
Ng Sydney Dynamic Templates Talk - 18 April 2018Ng Sydney Dynamic Templates Talk - 18 April 2018
Ng Sydney Dynamic Templates Talk - 18 April 2018
 

Recently uploaded

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
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.
 
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.
 
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
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
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
 
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
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 

Recently uploaded (20)

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
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...
 
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 ...
 
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...
 
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
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
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...
 
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
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 

TampereJS June 2018 - Easy 3d drawing with three.js

  • 1. © 2018 Solteq. All rights reserved. Easy 3d drawing with three.js TampereJS June 2018
  • 2. © 2018 Solteq. All rights reserved. Jere Kuusela • Software Developer at Solteq • jere.kuusela@iki.fi • jere.kuusela@solteq.com • First talk ever!
  • 3. © 2018 Solteq. All rights reserved. WebGL • JavaScript API to implement 3d graphics in modern browsers • Wide support • Uses HTML <canvas> element • Uses hardware-acceleration • Low level ->  • Multiple higher level libraries • three.js • PhiloGL • GLGE • J3D • …
  • 4. © 2018 Solteq. All rights reserved.© 2018 Solteq. All rights reserved. Demo 1
  • 5. © 2018 Solteq. All rights reserved. Recap of Demo 1 • Scene: Container for objects which you want to draw • Objects: Actual objects which usually need both geometry and material • Camera: Location and direction where you are looking at the scene • Renderer: Uses WebGL to draw pixels based on the scene and the camera
  • 6. © 2018 Solteq. All rights reserved. Closer look at objects • Base class for points, lines, meshes, cameras, scenes, lights … • Every object can have children • For example a camera can be attached to a geometry • Most objects should have a parent • You can only render one object (usually the scene) and its children • Object’s location is relative to its parent <- IMPORTANT! • Allows easily moving complex objects
  • 7. © 2018 Solteq. All rights reserved.© 2018 Solteq. All rights reserved. Demo 2
  • 8. © 2018 Solteq. All rights reserved. Recap of Demo 2 • A car built from a cone, 4 cylinders (tires) and a camera • Cars were attached to a proxy object which was used to move them around • No need to update locations of cars and tires manually • An image was added as a floor for visual purposes • The scene only directly included the floor and the proxy object! • Camera can be toggled by simply changing which camera is used in render function
  • 9. © 2018 Solteq. All rights reserved. Controlling camera manually? • No first class support for moving a camera with mouse • But lots of examples which contain reusable code: https://threejs.org/examples/ • https://threejs.org/examples/#misc_controls_orbit • https://threejs.org/examples/#misc_controls_trackball • Have to download the required JS file manually • But only a few lines of codes required to get it working
  • 10. © 2018 Solteq. All rights reserved. Lights and shadows • Multiple choices: ambient, directional, spotlight, point, … • This is where the easy ends • Lots of things which can go wrong -> nothing appears on the screen  • Use helpers to visualize lights and shadows when debugging
  • 11. © 2018 Solteq. All rights reserved.© 2018 Solteq. All rights reserved. Demo 3
  • 12. © 2018 Solteq. All rights reserved. Recap of Demo 3 • Imported camera controls JS-file • One line of code to get it working properly • Added a light to cars (copypaste from three.js documentation) • But no light shows up • Helper objects appear so can see that the light is there
  • 13. © 2018 Solteq. All rights reserved. Lights and shadows, again • Lights require: • Proper material (MeshStandardMaterial instead of MeshBasicMaterial) • Ambient light unless you want the world be pitch black • Spotlight must have the target location set and added to scene • Shadows require: • Light must be set to cast shadow • Light shadow camera must have proper near and far • Renderer must have shadowmap enabled • Floor must be set to receive shadow • Any other objects must be set to cast shadow
  • 14. © 2018 Solteq. All rights reserved.© 2018 Solteq. All rights reserved. Demo 4
  • 15. © 2018 Solteq. All rights reserved. Recap of Demo 4 • Changed floor material • Added ambient light • Fixed location of lights, added target location • Also added another light to cars with help of clone() • Fixed shadow near and far settings • Added shadowmap to renderer • Added receive shadows to floor • Added static towers to cast shadows