Skip to content

Commit ba527ae

Browse files
committed
feat: pivotcontrols, enabled
1 parent c9a680c commit ba527ae

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,8 @@ Controls for rotating and translating objects. These controls will stick to the
911911

912912
```tsx
913913
type PivotControlsProps = {
914+
/** Enables/disables the control, true */
915+
enabled?: boolean
914916
/** Scale of the gizmo, 1 */
915917
scale?: number
916918
/** Width of the gizmo lines, this is a THREE.Line2 prop, 2.5 */

src/web/pivotControls/index.tsx

+25-14
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const yDir = /* @__PURE__ */ new THREE.Vector3(0, 1, 0)
3333
const zDir = /* @__PURE__ */ new THREE.Vector3(0, 0, 1)
3434

3535
type PivotControlsProps = {
36+
/** Enables/disables the control, true */
37+
enabled?: boolean
3638
/** Scale of the gizmo, 1 */
3739
scale?: number
3840
/** Width of the gizmo lines, this is a THREE.Line2 prop, 2.5 */
@@ -92,6 +94,7 @@ export const PivotControls: ForwardRefComponent<PivotControlsProps, THREE.Group>
9294
>(
9395
(
9496
{
97+
enabled = true,
9598
matrix,
9699
onDragStart,
97100
onDrag,
@@ -256,20 +259,28 @@ export const PivotControls: ForwardRefComponent<PivotControlsProps, THREE.Group>
256259
<context.Provider value={config}>
257260
<group ref={parentRef}>
258261
<group ref={ref} matrix={matrix} matrixAutoUpdate={false} {...props}>
259-
<group visible={visible} ref={gizmoRef} position={offset} rotation={rotation}>
260-
{!disableAxes && activeAxes[0] && <AxisArrow axis={0} direction={xDir} />}
261-
{!disableAxes && activeAxes[1] && <AxisArrow axis={1} direction={yDir} />}
262-
{!disableAxes && activeAxes[2] && <AxisArrow axis={2} direction={zDir} />}
263-
{!disableSliders && activeAxes[0] && activeAxes[1] && <PlaneSlider axis={2} dir1={xDir} dir2={yDir} />}
264-
{!disableSliders && activeAxes[0] && activeAxes[2] && <PlaneSlider axis={1} dir1={zDir} dir2={xDir} />}
265-
{!disableSliders && activeAxes[2] && activeAxes[1] && <PlaneSlider axis={0} dir1={yDir} dir2={zDir} />}
266-
{!disableRotations && activeAxes[0] && activeAxes[1] && <AxisRotator axis={2} dir1={xDir} dir2={yDir} />}
267-
{!disableRotations && activeAxes[0] && activeAxes[2] && <AxisRotator axis={1} dir1={zDir} dir2={xDir} />}
268-
{!disableRotations && activeAxes[2] && activeAxes[1] && <AxisRotator axis={0} dir1={yDir} dir2={zDir} />}
269-
{!disableScaling && activeAxes[0] && <ScalingSphere axis={0} direction={xDir} />}
270-
{!disableScaling && activeAxes[1] && <ScalingSphere axis={1} direction={yDir} />}
271-
{!disableScaling && activeAxes[2] && <ScalingSphere axis={2} direction={zDir} />}
272-
</group>
262+
{enabled && (
263+
<group visible={visible} ref={gizmoRef} position={offset} rotation={rotation}>
264+
{!disableAxes && activeAxes[0] && <AxisArrow axis={0} direction={xDir} />}
265+
{!disableAxes && activeAxes[1] && <AxisArrow axis={1} direction={yDir} />}
266+
{!disableAxes && activeAxes[2] && <AxisArrow axis={2} direction={zDir} />}
267+
{!disableSliders && activeAxes[0] && activeAxes[1] && <PlaneSlider axis={2} dir1={xDir} dir2={yDir} />}
268+
{!disableSliders && activeAxes[0] && activeAxes[2] && <PlaneSlider axis={1} dir1={zDir} dir2={xDir} />}
269+
{!disableSliders && activeAxes[2] && activeAxes[1] && <PlaneSlider axis={0} dir1={yDir} dir2={zDir} />}
270+
{!disableRotations && activeAxes[0] && activeAxes[1] && (
271+
<AxisRotator axis={2} dir1={xDir} dir2={yDir} />
272+
)}
273+
{!disableRotations && activeAxes[0] && activeAxes[2] && (
274+
<AxisRotator axis={1} dir1={zDir} dir2={xDir} />
275+
)}
276+
{!disableRotations && activeAxes[2] && activeAxes[1] && (
277+
<AxisRotator axis={0} dir1={yDir} dir2={zDir} />
278+
)}
279+
{!disableScaling && activeAxes[0] && <ScalingSphere axis={0} direction={xDir} />}
280+
{!disableScaling && activeAxes[1] && <ScalingSphere axis={1} direction={yDir} />}
281+
{!disableScaling && activeAxes[2] && <ScalingSphere axis={2} direction={zDir} />}
282+
</group>
283+
)}
273284
<group ref={childrenRef}>{children}</group>
274285
</group>
275286
</group>

0 commit comments

Comments
 (0)