From 14603bccbd3955a8c9ab180c9ae386960952a206 Mon Sep 17 00:00:00 2001 From: Andrew Prifer <2991360+AndrewPrifer@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:15:37 +0200 Subject: [PATCH] Make transform controls only update the props that are being manipulated in the current mode of the transform controls (#279) Only update the transform that is being manipulated in the current mode --- .../src/extension/components/ProxyManager.tsx | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/r3f/src/extension/components/ProxyManager.tsx b/packages/r3f/src/extension/components/ProxyManager.tsx index 11b3c74..ffc239c 100644 --- a/packages/r3f/src/extension/components/ProxyManager.tsx +++ b/packages/r3f/src/extension/components/ProxyManager.tsx @@ -201,25 +201,31 @@ const ProxyManager: VFC = ({orbitControlsRef}) => { const sheetObject = editableProxyOfSelected.editable.sheetObject const obj = editableProxyOfSelected.object + // interestingly, for some reason, only updating a transform when it actually changes breaks it scrub.current.capture(({set}) => { - set(sheetObject.props, { - ...sheetObject.value, - position: { + if (transformControlsMode === 'translate') { + set(sheetObject.props.position, { + ...sheetObject.value.position, x: obj.position.x, y: obj.position.y, z: obj.position.z, - }, - rotation: { + }) + } + if (transformControlsMode === 'rotate') { + set(sheetObject.props.rotation, { + ...sheetObject.value.rotation, x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z, - }, - scale: { + }) + } + if (transformControlsMode === 'scale') { + set(sheetObject.props.scale, { x: obj.scale.x, y: obj.scale.y, z: obj.scale.z, - }, - }) + }) + } }) }} onDraggingChange={(event) => {