flutter_scene_rapier 0.5.2 copy "flutter_scene_rapier: ^0.5.2" to clipboard
flutter_scene_rapier: ^0.5.2 copied to clipboard

Rapier 3D physics backend for flutter_scene. Implements the scene package's physics simulation contract against Rapier via FFI.

example/example.dart

// Drop a box onto a floor with the Rapier backend.
import 'package:flutter_scene/physics.dart';
import 'package:flutter_scene/scene.dart';
import 'package:flutter_scene_rapier/flutter_scene_rapier.dart';
import 'package:vector_math/vector_math.dart';

Future<void> main() async {
  await RapierWorld.ensureInitialized();

  final scene = Scene();
  final world = PhysicsWorld(RapierWorld(gravity: Vector3(0, -9.81, 0)));
  scene.root.addComponent(world);

  // A static floor.
  final floor = Node(localTransform: Matrix4.translation(Vector3(0, -0.5, 0)));
  floor.addComponent(RigidBody(type: BodyType.fixed));
  floor.addComponent(
    Collider(shape: BoxShape(halfExtents: Vector3(10, 0.5, 10))),
  );
  scene.add(floor);

  // A falling dynamic box. The body goes on before the collider.
  final box = Node(localTransform: Matrix4.translation(Vector3(0, 5, 0)));
  box.addComponent(RigidBody(type: BodyType.dynamic_, mass: 1));
  box.addComponent(Collider(shape: BoxShape(halfExtents: Vector3.all(0.5))));
  scene.add(box);

  world.collisions.listen((event) {
    // CollisionBegan, CollisionEnded, TriggerEntered, or TriggerExited.
  });

  // Each frame, scene.update(deltaSeconds) steps physics on a fixed
  // timestep and interpolates node transforms before rendering.
}
9
likes
160
points
1.01k
downloads

Documentation

API reference

Publisher

verified publisherbdero.dev

Weekly Downloads

Rapier 3D physics backend for flutter_scene. Implements the scene package's physics simulation contract against Rapier via FFI.

Repository (GitHub)
View/report issues

Topics

#physics #rapier #gamedev #collision

License

MIT (license)

Dependencies

code_assets, crypto, ffi, flutter, hooks, scene, vector_math

More

Packages that depend on flutter_scene_rapier