Physics

Physics

This docs page is under construction. Expect more information coming to this page soon!
If you have questions, please ask them in our Discord server and we'll answer them promptly! 😊
💡

Dreamlab uses Matter.js under the hood for its 2D physics engine.

Detecting Collisions

Importing from Matter.js

If you want to import a specific class from Matter, you cannot use the normal import syntax:

// wrong
import { Body } from 'matter-js'

Because matter is a cjs module, you must use this less convenient syntax:

import Matter from 'matter-js'
const { Body } = Matter

If you simply want to access the Vector class, you can import it like this:

import { Vec } from '@dreamlab.gg/core/math'