<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by David Lindkvist on Medium]]></title>
        <description><![CDATA[Stories by David Lindkvist on Medium]]></description>
        <link>https://medium.com/@DavidLindkvist?source=rss-70c877f57669------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ekduvfD7y6r5Lvrd77j49g.jpeg</url>
            <title>Stories by David Lindkvist on Medium</title>
            <link>https://medium.com/@DavidLindkvist?source=rss-70c877f57669------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 04:12:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@DavidLindkvist/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Progressive Enhancement with WebGL and React]]></title>
            <link>https://medium.com/14islands/progressive-enhancement-with-webgl-and-react-71cd19e66d4?source=rss-70c877f57669------2</link>
            <guid isPermaLink="false">https://medium.com/p/71cd19e66d4</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[webgl]]></category>
            <dc:creator><![CDATA[David Lindkvist]]></dc:creator>
            <pubDate>Thu, 10 Sep 2020 12:12:53 GMT</pubDate>
            <atom:updated>2020-09-10T12:12:53.525Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hMSKanV8xqhLALwx2rg5og.png" /></figure><p>These days, it’s very common to mix creative technologies like WebGL with traditional HTML/CSS when building websites. In this post, I will try to outline how we at 14islands approach this trend to ensure the content is still available to as many visitors as possible. All of these techniques were used on our new company website <a href="http://14islands.com/">14islands.com</a>.</p><h3>Thoughts on accessibility</h3><p>Go back just a few years and responsive web design, progressive enhancement and mobile-first were all the rage. Here’s the thing — they are still valid practices, and just because we have access to new shiny toys doesn’t mean we get a free pass to only build websites for desktop screens and the latest browser technology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*_tK9kp9ty-TllTDI" /></figure><h3>Assumptions made by most WebGL websites</h3><p><strong>Everybody loves a cool loading animation </strong>— Having a preloader allows the browser to download all assets before showing the website. Large images are known to cause lag as they are uploaded to the GPU for the first time. For this reason, it’s common for WebGL apps to preload and pre-render textures before showing the website.</p><p><strong>Everybody loves to scroll</strong> — Having only one long page means the WebGL canvas can create all objects for the whole website on page load (during the preloader animation), and there are no requests to load new pages or new assets to worry about.</p><p><strong>Everybody has a modern browser</strong> — Building for advanced browsers and adding polyfills for missing features. Some websites even lock the user out if the browser lacks support for a modern feature.</p><p>Because of these assumptions, it’s common to create and position all content using Javascript (e.g. <a href="https://github.com/react-spring/react-three-flex">https://github.com/react-spring/react-three-flex</a>). Sometimes, text content is rendered only as WebGL textures, which makes the content essentially images.</p><h3>In reality, it depends™️</h3><p>If you’re doing a cool campaign site or interactive experience, many of these assumptions might be correct. However, for many projects, having quick access to the content, a high level of accessibility and SEO are equally important to delivering a memorable creative experience.</p><p>Not all websites can afford a long loading animation. Visitors have short attention spans, and it can impact conversion rates and sales.</p><h3>A progressively enhanced experience</h3><p>We usually use Gatsby.js on our projects. It’s fast, has a good ecosystem of plugins to speed up common tasks, and offers server-side rendering out of the box.</p><p>As any fan of static websites knows, server-side rendering is great for SEO and accessibility since the content can be accessed without executing a bunch of Javascript. We also want to make sure text content is available even if WebGL isn’t supported.</p><p>In fact, our javascript heavy React and WebGL website even renders <strong>without Javascript</strong> support: 😲</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TsfgwD0hKHwiEQs-" /></figure><p>With Javascript enabled but no WebGL support, you get some fancier hover states and the ability to play our showreel in a cool dark cinema mode: 😎🍿</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P-7ZnfGwkD9FadJ7" /></figure><p>And if the browser supports WebGL, you get all the gooey blob magic: 🎩🐇</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AvXzDBlqeniAOGxm" /></figure><h3>When feature detection falls short</h3><p>Unfortunately, some browsers will gladly say that they support WebGL, but they are simply too weak to run the code with good performance.</p><p>There’s no good way to feature-detect powerful devices. Some try to measure the frame rate over time or use a combination of other features, but none of them are very robust. In our case, we simply base it on screen size and assume that a larger screen corresponds to a more powerful device (which may or may not be true).</p><h3>React &amp; Three.js</h3><p>We like to use the <a href="https://threejs.org/">Three.js</a> WebGL library. The pace at which it updates and introduces breaking changes is mind-blowing. Any third-party react library that tries to provide a 1:1 mapping of Three.js objects to React components will probably not be maintained for long.</p><p><a href="https://github.com/react-spring/react-three-fiber">react-three-fiber</a> takes a different approach by hooking into the <a href="https://github.com/facebook/react/tree/master/packages/react-reconciler">React reconciler</a> and proxies JSX tags to Three.js objects. It doesn&#39;t even care what version of Three we are using, which makes it future proof. Having said that, there are definitely pitfalls and enough performance gotchas for a future blog post. 😬</p><h3>Enhancing with WebGL</h3><p>We created a framework on top of react-three-fiber that enables us to add WebGL functionality to any existing React component on the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rsobXELxg__vHQxRI7aC-Q.jpeg" /></figure><p>At the core we have one global shared WebGL canvas that stays in between page loads:</p><pre>export const wrapRootElement = ({ element }) =&gt; (<br>  &lt;&gt;<br>    {element}<br>    &lt;GlobalCanvas/&gt;<br>  &lt;/&gt;<br>)</pre><p>Each UI component can opt-in to use this global canvas using a custom useCanvas() hook:</p><pre>const Image = () =&gt; {<br>	const ref = useRef()<br>	<br>	// add webgl component to global canvas while mounted<br>	useCanvas(&lt;WebGlImage image={ref} /&gt;)</pre><pre>	return &lt;img ref={ref} src={...} /&gt;<br>}</pre><p>When the &lt;Image&gt; component mounts, it tells the global canvas to render &lt;WebGlImage&gt;. It will also automatically remove the WebGL mesh and clean up resources when it unmounts.</p><p>This keeps our code modular and hides the details of the WebGL implementation from regular UI components.</p><p>The &lt;WebGlImage&gt; is responsible for hiding the normal image element and draw a WebGL mesh in its place.</p><h3>Syncing DOM content with WebGL canvas 🔮</h3><p>A big challenge is to sync the fixed canvas elements with the scrollable HTML content. The technique we use largely follows <a href="https://threejsfundamentals.org/threejs/lessons/threejs-multiple-scenes.html">an approach that tracks “proxy” elements in the normal page flow</a> and updates the WebGL scene positions to match them.</p><p>Since Javascript is inevitably slower than native scrolling, this can make the WebGL scene feel laggy. The most common way to fix this is to have some easing on the WebGL position update.</p><p>Here’s an example of a WebGL image with easing next to some normal content. Notice how the image all of a sudden feels more smooth than the DOM content because of the easing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*hqxvVn1X7JYTyMXJ" /></figure><p>To fix this, most websites also introduce a virtual scroll on the HTML content with a matching easing function. This makes the whole page move with the same feeling, and while it’s for sure less performant than a native scroll, it still perceived as being smoother when all items move at the same speed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*uNysJwRJWypCn4ax" /></figure><p>A virtual scroll means that we move all HTML content with Javascript, and it’s a known source of many accessibility issues. For some projects, it’s worth the trade-off, while other projects might require a higher level of accessibility.</p><p>There are many libraries for virtual/smooth scrolling available. We suggest you pick one which at least retains the browser’s native scrollbar.</p><h3>Closing thoughts 💡</h3><p>To be honest, if load time and maximum device support is your highest priority, you shouldn’t use WebGL at all. But for some websites (like ours), there is a good middle ground.</p><p>By adding WebGL to existing HTML elements on the page, we can split up the work better. Some developers can focus on building a solid responsive website layout, and the WebGL can be added on top in a second iteration. Of course, everything needs to be thoroughly tested together, as there are many performance pitfalls when using this technique.</p><p>There are downsides to this approach. Loading large images might cause scroll jank, and it becomes harder to achieve smooth page transitions when everything isn’t preloaded. Accessibility also takes a hit due to having virtual scrolling of the DOM.</p><p>Let us know if you have ideas on how to improve this even further, we’d love to hear more how others approach this!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71cd19e66d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/14islands/progressive-enhancement-with-webgl-and-react-71cd19e66d4">Progressive Enhancement with WebGL and React</a> was originally published in <a href="https://medium.com/14islands">14islands</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sneaky Santa — behind the scenes]]></title>
            <link>https://medium.com/14islands/sneaky-santa-behind-the-scenes-8d4ea106043e?source=rss-70c877f57669------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d4ea106043e</guid>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[3d]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[David Lindkvist]]></dc:creator>
            <pubDate>Thu, 27 Jun 2019 11:23:27 GMT</pubDate>
            <atom:updated>2019-06-27T11:23:27.540Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sneaky Santa — behind the scenes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BrtWBb3xne_jlxWgS1Z47Q.png" /></figure><p>This is the second year in a row that we made an interactive Xmas card to share with our clients and friends.</p><p>Last year, we created a <a href="https://2017.14islands.com/">WebVR globe</a> full of seasonal goodies. This year, we gave you <a href="https://2018.14islands.com/">Sneaky Santa</a> — a fun little 3D toy built using physics simulation and fuzzy meshes.</p><p>This post shares some of the design process and the techniques used to create this year’s experience.</p><h3>Inspiration</h3><p>What started as a technical <a href="https://medium.com/14islands/why-fridays-are-hack-days-at-14islands-b6b4d1da6878">Friday hack</a> was turned into a playful experience by the 14islands team. The initial idea came from a Christmas decoration I found in a drawer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vyMVUN_Q8BZO4FMAc5L5gw.jpeg" /></figure><p>I had recently looked at <a href="http://schteppe.github.io/cannon.js/">cannon.js</a> for another project and got inspired to combine a couple of their demos to achieve something similar:</p><ul><li><a href="http://schteppe.github.io/cannon.js/demos/ragdoll.html">http://schteppe.github.io/cannon.js/demos/ragdoll.html</a></li><li><a href="http://schteppe.github.io/cannon.js/examples/threejs_mousepick.html">http://schteppe.github.io/cannon.js/examples/threejs_mousepick.html</a></li><li><a href="http://schteppe.github.io/cannon.js/demos/spring.html">http://schteppe.github.io/cannon.js/demos/spring.html</a></li></ul><p>By chance, I remembered the awesome <a href="https://medium.com/@Zadvorsky/fuzzy-meshes-4c7fd3910d6f">Fuzzy Mesh</a> created by Szenia Zadvornykh that I had bookmarked a year earlier and added it to the mix. After a lot of tweaking (because <a href="https://threejs.org/">Three.js</a> changes with every version 😩) I managed to pull this together as a first version:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fglitch.com%2Fembed%2F%23%21%2Fembed%2F14islands-ragdoll%3Fpath%3DREADME.md%26previewSize%3D100%26attributionHidden%3Dtrue%26previewFirst%3Dfalse%26sidebarCollapsed%3Dfalse&amp;dntp=1&amp;url=https%3A%2F%2Fglitch.com%2Fembed%2F%23%21%2Fembed%2F14islands-ragdoll&amp;image=https%3A%2F%2Fglitch.com%2Fedit%2Fimages%2Flogos%2Fglitch%2Fsocial-card%402x.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=glitch" width="600" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b5c2e6149870b7cebc1aa52c32ebe06/href">https://medium.com/media/4b5c2e6149870b7cebc1aa52c32ebe06/href</a></iframe><p>The team wasted no time and managed to break it immediately…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rZRkA4ygD8cTRJQL" /></figure><h3>Storyline &amp; concept design</h3><p>We got together as a team to brainstorm a few concepts. To make it more fun and addictive, we played around with the possibility of shaking gifts from his beard, and that’s how we came up with the Sneaky Santa storyline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7b80A_FChyUMpFZcOay8g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qGONO-dPx_y4tXz-iTkypw.png" /><figcaption>Santa iterations</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D5GSog3GKYuLosfE.png" /><figcaption>Early sketches of the flow</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_EIxQWZf_SpZZvSF.png" /><figcaption>Color theme explorations</figcaption></figure><h3>Under the hood</h3><p>After deciding on how our Santa should look, we got down to business and did some 3D sculpting in <a href="https://www.maxon.net/en/products/cinema-4d/overview/">Cinema 4D</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vOfQ-jmciAXDmacR.png" /><figcaption>3D modeling in Cinema 4D</figcaption></figure><p>This model was later split into individual meshes for each body part and mapped to the cannon.js skeleton. The fuzzy mesh was customized and used to replace the solid beard from the 3D model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VN5lG3dTKa872bEi.png" /><figcaption>Physics debugging and body part mapping.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nwizya4TZzCkn22feajpFQ.gif" /><figcaption>Shaking the Santa — final scene.</figcaption></figure><h3>Sound Effects</h3><p>Good sound adds a whole new dimension for interactive experiences. However, it’s a bit of a balancing act to not make visitors turn off the sound as soon as the page loads. We decided to skip the background music this year and only focus on sound FX during gameplay.</p><p>Unfortunately, we didn’t have time to record our own sounds. We used some good free samples and post-processed the sounds a bit to even out the volume and pitch.</p><p>Searching for free sounds online is an art in itself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9MDFudROV9sNtTgS" /></figure><h3>A team effort</h3><p>Even simple ideas take a lot of time to execute well. To make it in time for Christmas, the whole team pitched in to make it awesome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y9RxI0PHPWkmo95st9PS7g.jpeg" /></figure><p>We used After Effects and the <a href="https://github.com/airbnb/lottie-web">Lottie</a> plugin to export SVG animations for the UI. The loading animation was one of the project’s highlights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UoOtJvbYGPdXqfHj.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZoWO44li4NKHpD5Z.gif" /><figcaption>SVG animations</figcaption></figure><p>Most transitions and the light snowfall on the final screen were done using <a href="https://greensock.com/gsap">GSAP</a> and CSS Animations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ib93tSknrcqoJOUznT_K0w.gif" /></figure><h3>Jamais deux sans trois</h3><p>Time will tell if we make this into a tradition. As the French saying goes, if it happened twice, it will probably happen again.</p><p>We had the pleasure of receiving a few awards for this project:</p><ul><li><a href="https://thefwa.com/cases/sneaky-santa">FWA of the day— 26 Dec 2018</a></li><li><a href="https://www.cssdesignawards.com/sites/sneaky-santa/34294/">CSS Design Awards — Website of the day 2018 Dec 24</a></li><li><a href="https://www.cssdesignawards.com/sites/sneaky-santa/34294/">CSS Design Awards — Best UI Design, Best UX Design and Best Innovation</a></li><li><a href="https://www.awwwards.com/sites/sneaky-santa">Awwwards — Honorable Mention</a></li><li><a href="https://www.awwwards.com/sites/sneaky-santa/mobile-excellence-report">Awwwards — Mobile Excellence</a></li></ul><p>Thanks for reading!</p><p><strong>Do you like this post?</strong> <a href="https://mailchi.mp/ab249ce8deab/14islands">Sign up to our newsletter</a> about creative designs and cutting edge technologies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d4ea106043e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/14islands/sneaky-santa-behind-the-scenes-8d4ea106043e">Sneaky Santa — behind the scenes</a> was originally published in <a href="https://medium.com/14islands">14islands</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>