Zappar Insights: All the latest industry innovations and news from the Zappar team

Simplifying Real-time Web Physics with Mattercraft

Written by George Martin | May 14, 2024 9:32:27 AM

Last week we launched support for real-time physics in Mattercraft. Leveraging the Havok physics engine you can now add lifelike physics and interactions to your projects with zero code, enhancing your immersive experiences across augmented reality, virtual reality and mixed reality.

 

What is Physics?

Physics is the simulation and manipulation of objects in a virtual environment to mimic their real-world behaviour. This includes how things move, interact, and respond to forces like gravity and collisions. 

For creators; using physics avoids painstaking animation sequences and allows them to build more immersive and interactive experiences, whether in gaming, virtual reality, mixed reality or augmented reality.

 

Saving Time with No-code Physics

Tools and libraries like Three.js have been a common way amongst developers to implement web-based physics. While powerful, we’ve found these require extensive scripting and setup, which comes with a steep learning curve for a lot of creators

However, Mattercraft's intuitive visual interface allows for simple set-up and customisation of physics within your project without any code. With the added option for developers to dive into the TypeScript IDE to create more bespoke behaviours while saving time applying: 

  • Rigid Bodies
  • Colliders (simple shapes, mesh, convex hull)
  • Constraints
  • Forces
  • Gravity
  • Mass

Mattercraft’s real-time simulation also allows you to test your physics directly in the viewport streamlining development by eliminating the need for lengthy build or local server processes.

 

How to Apply No-code Physics

Apply physics to your next Mattercraft project with zero code in 5 simple steps: 

Step 1: Importing the Object

Drag and Drop: Start by dragging a 3D model from the asset portal into your project files.

Positioning in the Hierarchy: Drag the imported model into the hierarchy.

Step 2: Scaling the Object

Adjust the Scale: Select the model in the hierarchy and scale it up so it's easily visible within your scene.

Step 3: Adding Physics

Navigate to the Behaviours Panel: With the model selected, go to the behaviours panel in the GUI.

Add Physics Behaviour: Click the plus icon and select 'Physics Behaviour' -> ‘Rigid Body’ from the menu to add physics to your chosen 3D model.

Step 4: Configure Physics Parameters:

Motion Type: Set the motion type to 'Dynamic' if you want the model to move and interact with forces, or 'Static' if it should act as an immovable object.

Material Properties: Adjust material properties like bounciness and friction based on how you want the model to interact when it comes into contact with other objects. You can add a physics material to unlock even more properties.

Mass and Gravity: Modify the mass to affect how gravity impacts the model and adjust the gravity factor if necessary.

 

Adjust the collider: You can also override the default mesh collider, with more performant shapes, or a convex hull.

Step 5: Simulating Physics

Real-Time Simulation: Click the 'Play' button at the top of the GUI to start simulating physics. You should see the model behaving according to the physics properties you've set.

 

Adjust and Test: If the model doesn’t interact as expected, stop the simulation, make adjustments, and test again until satisfied with its behaviour.

Real-time Physics Examples in Mattercraft

 

Use Physics with Augmented Reality

You can use physics with the Augmented Reality by Zappar package and utilise the various best-in-class tracking types (image, face, and world tracking) to build standout AR experiences.

 

Use Physics with the Apple Vision Pro, Meta Quests, Magic Leap, Pico & more

Create Virtual or Mixed Reality content that reacts realistically to user and environment interactions across various headsets like Apple Vision Pro, Meta Quests, Magic Leap, Pico, and more. We have an easy-to-use "Grabbable" component, perfect for Mixed and Virtual Reality content for both hands and controllers.

 

Empowering Creators Like Never Before

With a range of templates to choose from, it's never been easier to get started building rich and immersive experiences for the web. Whether you’re looking to level up your AR projects or add realism to your mixed reality or virtual reality experiences, Mattercraft offers the power and flexibility to help you get there.