Swizec Teller - a geek with a hatswizec.com

    Livecoding Recap #46: 3D is hard, WebAR defeats me

    This is a Livecoding Recap – an almost-weekly post about interesting things discovered while livecoding. Usually shorter than 500 words. Often with pictures. Livecoding happens almost every Sunday at 2pm PDT on multiple channels. You should follow My Youtube channel to catch me live.

    You know what? This 3D stuff is way too hard. None of this makes any sense to me anymore.

    All I wanted to do today was make a nice little hurricane travel across an augmented reality marker. In theory, all you need for that is a nice particle system and some parameter tweaking. Instead of particles flying around randomly, you want them to twirl around in a cone shape of some sort.

    But noooo…

    We tried with aframe-particle-system-component.

    That did not quite work.

    Then we searched for three.js examples that looked close enough that they could be a hurricane with some param tweaking. The closest we could find was the GPU Particle System example.

    It's got everything we need:

    1. Many particles
    2. Particles follow some sort of wind pattern
    3. Parameters to tweak

    Turning it into an aframe component for our setup should be easy. Aframe is an abstraction on top of Three.js, after all.

    In theory, all you have to do is to register a new Aframe component, put your example initiation into init(), and your animation stuff into tick(). Instead of rendering with the Three.js renderer, you setObject3D on the Aframe object.

    AFRAME.registerComponent("hurricane", {
    scheme: {},
    init: function () {
    // initiation code
    tick: function (now, delta) {
    // animation code

    Then you could use it like this: <Entity hurricane />, or without JSX, like this: <a-entity hurricane />.

    It didn't work. We tried fiddling with it and changing things here and there and nothing worked. No matter what, nothing showed up on screen.

    In a final act of defiance, we found this cool aframe-environment-component and put a giant mushroom forest around our Minecraft guy.

    Swizec Teller published ServerlessHandbook.dev avatarSwizec Teller published ServerlessHandbook.dev@Swizec
    But this is cool too
    Tweet media

    I guess that's cool, too. I dunno, I'm kinda disappointed. I was hoping we could build something cool, but this whole 3D-on-the-web business is almost as big a mess as all the D3 examples you find out there.

    What is it with everybody who writes these examples and relying on global variables for everything? Use function arguments, damn it! That's what they're there for 😖

    And what's with all the imperative code? Everything is just add this and this and this and then change this and that. How am I supposed to understand what's going on?

    Ugh ... we'll play with something new next week. Any suggestions?

    Did you enjoy this article?

    Published on September 11th, 2017 in Livecoding, Technical

    Learned something new?
    Want to become an expert?

    Here's how it works 👇

    Leave your email and I'll send you thoughtfully written emails every week about React, JavaScript, and your career. Lessons learned over 20 years in the industry working with companies ranging from tiny startups to Fortune5 behemoths.

    Join Swizec's Newsletter

    And get thoughtful letters 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.

    "Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"

    ~ Ashish Kumar

    Join over 14,000 engineers just like you already improving their careers with my letters, workshops, courses, and talks. ✌️

    Have a burning question that you think I can answer? I don't have all of the answers, but I have some! Hit me up on twitter or book a 30min ama for in-depth help.

    Ready to Stop copy pasting D3 examples and create data visualizations of your own?  Learn how to build scalable dataviz components your whole team can understand with React for Data Visualization

    Curious about Serverless and the modern backend? Check out Serverless Handbook, modern backend for the frontend engineer.

    Ready to learn how it all fits together and build a modern webapp from scratch? Learn how to launch a webapp and make your first 💰 on the side with ServerlessReact.Dev

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️

    Created bySwizecwith ❤️