Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions docs/gizmos/pivot-controls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ type PivotControlsProps = {
autoTransform?: boolean
/** Allows you to switch individual axes off */
activeAxes?: [boolean, boolean, boolean]
/** Allows you to disable translation via axes arrows */
disableAxes?: boolean
/** Allows you to disable translation via axes planes */
disableSliders?: boolean
/** Allows you to disable rotation */
disableRotations?: boolean
/** Allows you to disable scaling */
disableScaling?: boolean
/** Allows you to disable translation via axes arrows either for all axes or for individual ones */
disableAxes?: boolean | [boolean, boolean, boolean]
/** Allows you to disable translation via axes planes either for all axes or for individual ones */
disableSliders?: boolean | [boolean, boolean, boolean]
/** Allows you to disable rotation either for all axes or for individual ones */
disableRotations?: boolean | [boolean, boolean, boolean]
/** Allows you to disable scaling either for all axes or for individual ones */
disableScaling?: boolean | [boolean, boolean, boolean]
/** RGB colors */
axisColors?: [string | number, string | number, string | number]
/** Color of the hovered item */
Expand Down Expand Up @@ -84,4 +84,6 @@ return (
matrix={matrix}
autoTransform={false}
onDrag={({ matrix: matrix_ }) => matrix.copy(matrix_)}
/>
)
```
49 changes: 32 additions & 17 deletions src/core/Gizmos/PivotControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ export type PivotControlsProps = {
/** Allows you to switch individual axes off */
activeAxes?: [boolean, boolean, boolean]

/** Allows you to switch individual transformations off */
disableAxes?: boolean
disableSliders?: boolean
disableRotations?: boolean
disableScaling?: boolean
/** Allows you to switch individual transformations off. Either across all axes, or individually. */
disableAxes?: boolean | [boolean, boolean, boolean]
disableSliders?: boolean | [boolean, boolean, boolean]
disableRotations?: boolean | [boolean, boolean, boolean]
disableScaling?: boolean | [boolean, boolean, boolean]

/** Limits */
translationLimits?: [[number, number] | undefined, [number, number] | undefined, [number, number] | undefined]
Expand Down Expand Up @@ -341,37 +341,52 @@ export const PivotControls: ForwardRefComponent<PivotControlsProps, THREE.Group>

React.useImperativeHandle(fRef, () => ref.current, [])

const disableTranslationAxes = Array.isArray(disableAxes) ? disableAxes : [disableAxes, disableAxes, disableAxes]

const disablePlaneSliderAxes = Array.isArray(disableSliders)
? disableSliders
: [disableSliders, disableSliders, disableSliders]

const disableRotationAxes = Array.isArray(disableRotations)
? disableRotations
: [disableRotations, disableRotations, disableRotations]

const disableScalingAxes = Array.isArray(disableScaling)
? disableScaling
: [disableScaling, disableScaling, disableScaling]

return (
<context.Provider value={config}>
<group ref={parentRef}>
<group ref={ref} matrix={matrix} matrixAutoUpdate={false} {...props}>
<group visible={visible} ref={gizmoRef} position={offset} rotation={rotation}>
{enabled && (
<>
{!disableAxes && activeAxes[0] && <AxisArrow axis={0} direction={xDir} />}
{!disableAxes && activeAxes[1] && <AxisArrow axis={1} direction={yDir} />}
{!disableAxes && activeAxes[2] && <AxisArrow axis={2} direction={zDir} />}
{!disableSliders && activeAxes[0] && activeAxes[1] && (
{!disableTranslationAxes[0] && activeAxes[0] && <AxisArrow axis={0} direction={xDir} />}
{!disableTranslationAxes[1] && activeAxes[1] && <AxisArrow axis={1} direction={yDir} />}
{!disableTranslationAxes[2] && activeAxes[2] && <AxisArrow axis={2} direction={zDir} />}
{!disablePlaneSliderAxes[2] && activeAxes[0] && activeAxes[1] && (
<PlaneSlider axis={2} dir1={xDir} dir2={yDir} />
)}
{!disableSliders && activeAxes[0] && activeAxes[2] && (
{!disablePlaneSliderAxes[1] && activeAxes[0] && activeAxes[2] && (
<PlaneSlider axis={1} dir1={zDir} dir2={xDir} />
)}
{!disableSliders && activeAxes[2] && activeAxes[1] && (
{!disablePlaneSliderAxes[0] && activeAxes[2] && activeAxes[1] && (
<PlaneSlider axis={0} dir1={yDir} dir2={zDir} />
)}
{!disableRotations && activeAxes[0] && activeAxes[1] && (

{!disableRotationAxes[2] && activeAxes[0] && activeAxes[1] && (
<AxisRotator axis={2} dir1={xDir} dir2={yDir} />
)}
{!disableRotations && activeAxes[0] && activeAxes[2] && (
{!disableRotationAxes[1] && activeAxes[0] && activeAxes[2] && (
<AxisRotator axis={1} dir1={zDir} dir2={xDir} />
)}
{!disableRotations && activeAxes[2] && activeAxes[1] && (
{!disableRotationAxes[0] && activeAxes[2] && activeAxes[1] && (
<AxisRotator axis={0} dir1={yDir} dir2={zDir} />
)}
{!disableScaling && activeAxes[0] && <ScalingSphere axis={0} direction={xDir} />}
{!disableScaling && activeAxes[1] && <ScalingSphere axis={1} direction={yDir} />}
{!disableScaling && activeAxes[2] && <ScalingSphere axis={2} direction={zDir} />}
{!disableScalingAxes[0] && activeAxes[0] && <ScalingSphere axis={0} direction={xDir} />}
{!disableScalingAxes[1] && activeAxes[1] && <ScalingSphere axis={1} direction={yDir} />}
{!disableScalingAxes[2] && activeAxes[2] && <ScalingSphere axis={2} direction={zDir} />}
</>
)}
</group>
Expand Down
Loading