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
This commit is contained in:
Andrew Prifer 2022-08-15 17:15:37 +02:00 committed by GitHub
parent 766c55f9e7
commit 14603bccbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,25 +201,31 @@ const ProxyManager: VFC<ProxyManagerProps> = ({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) => {