@threlte/extras

<TransformControls>

This component can be used to transform objects in 3D space by adapting a similar interaction model of DCC tools like Blender. Unlike other controls, it is not intended to transform the scenes camera.

The component <TransformControls> needs to be the parent of the component to be transformed.

To accommodate <OrbitControls> or <TrackballControls> as well as a <TransformControls> component in the same scene, the <TransformControls> component is able automatically pause the currently active <OrbitControls> or <TrackballControls> component when the user is interacting with the <TransformControls> component. You can opt out of this behaviour by setting the property autoPauseOrbitControls or autoPauseTrackballControls to false.

Examples

Scene.svelte
<script>
  import { T } from '@threlte/core'
  import { TransformControls } from '@threlte/extras'
  import { MeshStandardMaterial, BoxBufferGeometry } from 'three'
</script>

<TransformControls>
  <T.Mesh
    geometry={new BoxBufferGeometry(1, 1, 1)}
    material={new MeshStandardMaterial()}
  />
</TransformControls>

The <TransformControls> component can also be used to transform an object passed to it:

Scene.svelte
<script>
  import { T } from '@threlte/core'
  import { TransformControls } from '@threlte/extras'
  import { MeshStandardMaterial, BoxBufferGeometry } from 'three'
</script>

<T.Mesh
  geometry={new BoxBufferGeometry(1, 1, 1)}
  material={new MeshStandardMaterial()}
>
  {#snippet children({ ref })}
    <TransformControls object={ref} />
  {/snippet}
</T.Mesh>

<TransformControls object={someObject} />

Component Signature

The component <TransformControls> extends both <T.TransformControls> and <T.Group>. You may pass any property of either of these components to the component <TransformControls>.

Props

name
type
required

autoPauseOrbitControls
boolean
no

autoPauseTrackballControls
boolean
no

object
THREE.Object3D
no

Bindings

name
type

controls
THREE.TransformControls

group
THREE.Group