From 82fab132f1a5267ed0fdde19dc942691f33a8304 Mon Sep 17 00:00:00 2001 From: Rinith R Date: Thu, 30 Mar 2023 10:59:44 +0530 Subject: [PATCH] Updated widget.dart to enable/disable zoom feature Option to disable zoom while 3d model is interactive --- lib/src/widget.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/src/widget.dart b/lib/src/widget.dart index ab56541..85c6395 100755 --- a/lib/src/widget.dart +++ b/lib/src/widget.dart @@ -9,11 +9,13 @@ class Cube extends StatefulWidget { Cube({ Key? key, this.interactive = true, + this.zoom = true, this.onSceneCreated, this.onObjectCreated, }) : super(key: key); final bool interactive; + final bool zoom; final SceneCreatedCallback? onSceneCreated; final ObjectCreatedCallback? onObjectCreated; @@ -34,10 +36,12 @@ class _CubeState extends State { void _handleScaleUpdate(ScaleUpdateDetails details) { scene.camera.trackBall(toVector2(_lastFocalPoint), toVector2(details.localFocalPoint), 1.5); _lastFocalPoint = details.localFocalPoint; - if (_lastZoom == null) { - _lastZoom = scene.camera.zoom; - } else { - scene.camera.zoom = _lastZoom! * details.scale; + if (widget.zoom) { + if (_lastZoom == null) { + _lastZoom = scene.camera.zoom; + } else { + scene.camera.zoom = _lastZoom! * details.scale; + } } setState(() {}); }