How to use Cannon.js physics in Spark AR

Image for post
Image for post

I’ve recently been playing with physics in Spark AR, and I thought I would share the journey so far. I’ve also made a project and an npm package that might help kickstart your physics exploration.

This is by no means a complete guide to physics engines, but it should be enough to get you started. For my experiments so far, I’ve been using Cannon.js.

The concept

The way I think about physics engines, is that there’s a visual world and a physics world. …


Image for post
Image for post

If you’ve spent some time scripting in Spark AR, you’ve probably come across the limitation of one script file per project. This limitation creates a walled environment away from using all the great JavaScript packages that already exist. Using Webpack, we can get around this limitation.

https://gph.is/2xjnab9

Webpack to the rescue

If you haven’t come across it before, Webpack is a module bundler primarily for JavaScript, but you can also use it for CSS, images and a whole bunch of things.

The part we’re interested in is bundling multiple JavaScript modules into one file. …

ashley fletcher

Developer at Byte working on Augmented Reality and Creative Tech

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store