Skip to content

Physics

Florian Maxim edited this page Oct 29, 2017 · 8 revisions

One of the core principles of a Meta object is that it can have various and multiple physical bodies as well as graphical shapes and different times.

The Physics of a meta object consists of two instances.

A body instance that defines the meta object's physical properties (size, rotation, friction, etc.) and a World instance that contains the body object (as well as other physical bodies that affect each other).

On default a physical body that matches the meta objects graphical shape will be assigned to the meta object which then will be assigned to a physical world with earth' conditions.

So on default:

new Cube();

is equivalent to:

new Cube({
    physics: new Physics({
        gravity:{
        x: 0,
        y: -9.81,
        z:0
    }, false)
})

Passing a null argument as a physics property will avoid to assign any physical body at all:

new Cube({physics: null})

World

A meta object's physical world can be defined directly or by it's index.

Directly:

let a = new World({
  gravity: {
    x:0,
    y:-5,
    z:0
  }
});

let b = new World({
  gravity: {
    x:0,
    y:5,
    z:0
  }
});

new Cube({physics: new Physics({
  world: a
  })
});

new Cube({physics: new Physics({
  world: b
  })
});

Index:

let a = new World({
  gravity: {
    x:0,
    y:-5,
    z:0
  }
});

let b = new World({
  gravity: {
    x:0,
    y:5,
    z:0
  }
});

new Cube({physics: new Physics({
  world: 0
  })
});

new Cube({physics: new Physics({
  world: 1
  })
});
Clone this wiki locally