feature!:

This is a breaking change needed to fully implement instancing and stencil highlighting.

Previously, users would work directly with entities (on the Dart side, ThermionEntity), e.g.

final entity = await viewer.loadGlb("some.glb");

However, Filament "entities" are a lower-level abstraction.

Loading a glTF file, for example, inserts multiple entities into the scene.

For example, each mesh, light, and camera within a glTF asset will be assigned an entity. A top-level (non-renderable) entity will also be created for the glTF asset, which can be used to transform the entire hierarchy.

"Asset" is a better representation for loading/inserting objects into the scene; think of this as a bundle of entities.

Unless you need to work directly with transforms, instancing, materials and renderables, you can work directly with ThermionAsset.
This commit is contained in:
Nick Fisher
2024-11-21 15:04:10 +08:00
parent 9ada6aae64
commit ed444b0615
195 changed files with 18061 additions and 12628 deletions

View File

@@ -35,6 +35,8 @@ class ThermionFlutterPlugin {
_viewer =
await ThermionFlutterPlatform.instance.createViewer(options: options);
await _viewer!.initialized;
var camera = await _viewer!.getActiveCamera();
await camera.setLensProjection();

View File

@@ -82,9 +82,11 @@ class _ThermionListenerWidgetState extends State<ThermionListenerWidget> {
Widget _desktop(double pixelRatio) {
return Listener(
onPointerHover: (event) => widget.inputHandler.onPointerHover(
event.localPosition.toVector2() * pixelRatio,
event.delta.toVector2() * pixelRatio),
onPointerHover: (event) {
widget.inputHandler.onPointerHover(
event.localPosition.toVector2() * pixelRatio,
event.delta.toVector2() * pixelRatio);
},
onPointerSignal: (PointerSignalEvent pointerSignal) {
if (pointerSignal is PointerScrollEvent) {
widget.inputHandler.onPointerScroll(
@@ -95,22 +97,26 @@ class _ThermionListenerWidgetState extends State<ThermionListenerWidget> {
onPointerPanZoomStart: (pzs) {
throw Exception("TODO - is this a pinch zoom on laptop trackpad?");
},
onPointerDown: (d) => widget.inputHandler.onPointerDown(
d.localPosition.toVector2() * pixelRatio,
d.buttons & kMiddleMouseButton != 0),
onPointerMove: (d) => widget.inputHandler.onPointerMove(
onPointerDown: (d) {
widget.inputHandler.onPointerDown(
d.localPosition.toVector2() * pixelRatio,
d.buttons & kMiddleMouseButton != 0);
},
onPointerMove: (PointerMoveEvent d) => widget.inputHandler.onPointerMove(
d.localPosition.toVector2() * pixelRatio,
d.delta.toVector2() * pixelRatio,
d.buttons & kMiddleMouseButton != 0),
onPointerUp: (d) => widget.inputHandler
.onPointerUp(d.buttons & kMiddleMouseButton != 0),
onPointerUp: (d) =>
widget.inputHandler.onPointerUp(d.buttons & kMiddleMouseButton != 0),
child: widget.child,
);
}
Widget _mobile(double pixelRatio) {
return _MobileListenerWidget(
inputHandler: widget.inputHandler, pixelRatio: pixelRatio, child:widget.child);
inputHandler: widget.inputHandler,
pixelRatio: pixelRatio,
child: widget.child);
}
@override
@@ -138,7 +144,10 @@ class _MobileListenerWidget extends StatefulWidget {
final Widget? child;
const _MobileListenerWidget(
{Key? key, required this.inputHandler, required this.pixelRatio, this.child})
{Key? key,
required this.inputHandler,
required this.pixelRatio,
this.child})
: super(key: key);
@override
@@ -165,7 +174,9 @@ class _MobileListenerWidgetState extends State<_MobileListenerWidget> {
},
onScaleStart: (details) async {
await widget.inputHandler.onScaleStart(
details.localFocalPoint.toVector2() * widget.pixelRatio, details.pointerCount, details.sourceTimeStamp);
details.localFocalPoint.toVector2() * widget.pixelRatio,
details.pointerCount,
details.sourceTimeStamp);
},
onScaleUpdate: (ScaleUpdateDetails details) async {
await widget.inputHandler.onScaleUpdate(
@@ -179,7 +190,8 @@ class _MobileListenerWidgetState extends State<_MobileListenerWidget> {
details.sourceTimeStamp);
},
onScaleEnd: (details) async {
await widget.inputHandler.onScaleEnd(details.pointerCount, details.scaleVelocity);
await widget.inputHandler
.onScaleEnd(details.pointerCount, details.scaleVelocity);
},
child: widget.child);
}