diff --git a/README.md b/README.md index 46c8cad76..97879b8f5 100644 --- a/README.md +++ b/README.md @@ -911,6 +911,8 @@ Controls for rotating and translating objects. These controls will stick to the ```tsx type PivotControlsProps = { + /** Enables/disables the control, true */ + enabled?: boolean /** Scale of the gizmo, 1 */ scale?: number /** Width of the gizmo lines, this is a THREE.Line2 prop, 2.5 */ diff --git a/src/web/pivotControls/index.tsx b/src/web/pivotControls/index.tsx index 0899cfb44..411e028a0 100644 --- a/src/web/pivotControls/index.tsx +++ b/src/web/pivotControls/index.tsx @@ -33,6 +33,8 @@ const yDir = /* @__PURE__ */ new THREE.Vector3(0, 1, 0) const zDir = /* @__PURE__ */ new THREE.Vector3(0, 0, 1) type PivotControlsProps = { + /** Enables/disables the control, true */ + enabled?: boolean /** Scale of the gizmo, 1 */ scale?: number /** Width of the gizmo lines, this is a THREE.Line2 prop, 2.5 */ @@ -92,6 +94,7 @@ export const PivotControls: ForwardRefComponent >( ( { + enabled = true, matrix, onDragStart, onDrag, @@ -256,20 +259,28 @@ export const PivotControls: ForwardRefComponent - - {!disableAxes && activeAxes[0] && } - {!disableAxes && activeAxes[1] && } - {!disableAxes && activeAxes[2] && } - {!disableSliders && activeAxes[0] && activeAxes[1] && } - {!disableSliders && activeAxes[0] && activeAxes[2] && } - {!disableSliders && activeAxes[2] && activeAxes[1] && } - {!disableRotations && activeAxes[0] && activeAxes[1] && } - {!disableRotations && activeAxes[0] && activeAxes[2] && } - {!disableRotations && activeAxes[2] && activeAxes[1] && } - {!disableScaling && activeAxes[0] && } - {!disableScaling && activeAxes[1] && } - {!disableScaling && activeAxes[2] && } - + {enabled && ( + + {!disableAxes && activeAxes[0] && } + {!disableAxes && activeAxes[1] && } + {!disableAxes && activeAxes[2] && } + {!disableSliders && activeAxes[0] && activeAxes[1] && } + {!disableSliders && activeAxes[0] && activeAxes[2] && } + {!disableSliders && activeAxes[2] && activeAxes[1] && } + {!disableRotations && activeAxes[0] && activeAxes[1] && ( + + )} + {!disableRotations && activeAxes[0] && activeAxes[2] && ( + + )} + {!disableRotations && activeAxes[2] && activeAxes[1] && ( + + )} + {!disableScaling && activeAxes[0] && } + {!disableScaling && activeAxes[1] && } + {!disableScaling && activeAxes[2] && } + + )} {children}