flutter_scene_net 0.2.1
flutter_scene_net: ^0.2.1 copied to clipboard
dashwire multiplayer for flutter_scene. Replica-to-node binding, interpolated transform sync, and in-app hosting.
flutter_scene_net example #
A full host-and-join demo lives in the flutter_scene repository as the "Multiplayer" example. The core wiring:
import 'package:dashwire/dashwire.dart';
import 'package:dashwire_replication/dashwire_replication.dart';
import 'package:flutter_scene/scene.dart';
import 'package:flutter_scene_net/flutter_scene_net.dart';
// A replicated pawn whose pose drives a scene node.
final class Pawn extends TransformReplica {
@override
String get typeKey => 'pawn';
}
Future<void> connectAndRender(WireConnection connection, Node sceneRoot) async {
final registry = ReplicaRegistry()..register(Pawn.new);
final session = await connectSession(
connection,
schemaHash: registry.schemaHash,
);
// Replicas spawned by the server become nodes under [sceneRoot]; those
// backed by TransformReplica interpolate their poses automatically.
SceneReplication(
registry: registry,
session: session,
root: sceneRoot,
builders: {'pawn': (replica) => Node()},
);
}
To host from inside the app instead of connecting to a server, use SceneHost.