Talks - Łukasz Langa: Build in-browser 3D experiences with WebGL and PyScript

Learn how to create interactive 3D web experiences using PyScript and WebGL. Discover shader programming, Three.js integration, and browser-native deployment for Python developers.

Key takeaways
  • PyScript enables writing Python code that runs directly in web browsers, using WebGL and 3D libraries like Three.js

  • WebGL is a low-level 2D rasterization engine that forms the foundation for 3D graphics in browsers - it works by converting 3D geometry into 2D pixels

  • Triangles are fundamental building blocks for 3D graphics because they are always planar and can approximate any 3D shape when combined

  • Shaders are GPU programs that come in pairs:

    • Vertex shaders determine position of vertices in 3D space
    • Fragment shaders calculate pixel colors and lighting effects
  • Three.js provides a high-level JavaScript API that simplifies 3D development compared to raw WebGL:

    • Scene management
    • Camera controls
    • Lighting
    • Materials and textures
    • 3D model loading
  • PyScript handles JavaScript interop through proxies and async/await support, allowing Python to control browser animations smoothly

  • Browser-based 3D experiences can be deployed without installation - users just need a URL

  • Performance is good enough for interactive 3D applications, though there are some storage limits and download size considerations

  • The technology stack combines:

    • PyScript for Python-to-JavaScript bridge
    • PyOdide for Python runtime in browser
    • WebGL/Three.js for 3D graphics
    • HTML5 Canvas for rendering
  • Code examples and demos are available at PyScript.com, making it easy to experiment with browser-based 3D Python development