Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
IR-742: remap transform gizmo hotkeys (#10309)
Browse files Browse the repository at this point in the history
* remap transform gizmo hotkeys

* fully remove old rotation hotkeys
  • Loading branch information
dinomut1 authored Jun 4, 2024
1 parent c87de3e commit 1594a3c
Showing 1 changed file with 34 additions and 37 deletions.
71 changes: 34 additions & 37 deletions packages/editor/src/systems/EditorControlSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Ethereal Engine. All Rights Reserved.
*/

import { useEffect } from 'react'
import { Intersection, Layers, MathUtils, Object3D, Raycaster } from 'three'
import { Intersection, Layers, Object3D, Raycaster } from 'three'

import { PresentationSystemGroup, UndefinedEntity, UUIDComponent } from '@etherealengine/ecs'
import {
Expand All @@ -45,10 +45,8 @@ import { GLTFSnapshotState } from '@etherealengine/engine/src/gltf/GLTFState'
import { SourceComponent } from '@etherealengine/engine/src/scene/components/SourceComponent'
import { TransformMode } from '@etherealengine/engine/src/scene/constants/transformConstants'
import { dispatchAction, getMutableState, getState, useMutableState } from '@etherealengine/hyperflux'
import { TransformComponent } from '@etherealengine/spatial'
import { CameraOrbitComponent } from '@etherealengine/spatial/src/camera/components/CameraOrbitComponent'
import { FlyControlComponent } from '@etherealengine/spatial/src/camera/components/FlyControlComponent'
import { Vector3_Up } from '@etherealengine/spatial/src/common/constants/MathConstants'
import { InputComponent } from '@etherealengine/spatial/src/input/components/InputComponent'
import { InputSourceComponent } from '@etherealengine/spatial/src/input/components/InputSourceComponent'
import { InfiniteGridComponent } from '@etherealengine/spatial/src/renderer/components/InfiniteGridHelper'
Expand Down Expand Up @@ -92,49 +90,49 @@ const onKeyF = () => {
)
}

const onKeyQ = () => {
const nodes = SelectionState.getSelectedEntities()
const gizmo = gizmoControlledQuery()
if (gizmo.length === 0) return
const gizmoEntity = gizmo[gizmo.length - 1]
const gizmoTransform = getComponent(gizmoEntity, TransformComponent)
const editorHelperState = getState(EditorHelperState)
EditorControlFunctions.rotateAround(
nodes,
Vector3_Up,
editorHelperState.rotationSnap * MathUtils.DEG2RAD,
gizmoTransform.position
)
}

const onKeyE = () => {
const nodes = SelectionState.getSelectedEntities()
const gizmo = gizmoControlledQuery()
if (gizmo.length === 0) return
const gizmoEntity = gizmo[gizmo.length - 1]
const gizmoTransform = getComponent(gizmoEntity, TransformComponent)
const editorHelperState = getState(EditorHelperState)
EditorControlFunctions.rotateAround(
nodes,
Vector3_Up,
-editorHelperState.rotationSnap * MathUtils.DEG2RAD,
gizmoTransform.position
)
}
// const onKeyQ = () => {
// const nodes = SelectionState.getSelectedEntities()
// const gizmo = gizmoControlledQuery()
// if (gizmo.length === 0) return
// const gizmoEntity = gizmo[gizmo.length - 1]
// const gizmoTransform = getComponent(gizmoEntity, TransformComponent)
// const editorHelperState = getState(EditorHelperState)
// EditorControlFunctions.rotateAround(
// nodes,
// Vector3_Up,
// editorHelperState.rotationSnap * MathUtils.DEG2RAD,
// gizmoTransform.position
// )
// }

// const onKeyE = () => {
// const nodes = SelectionState.getSelectedEntities()
// const gizmo = gizmoControlledQuery()
// if (gizmo.length === 0) return
// const gizmoEntity = gizmo[gizmo.length - 1]
// const gizmoTransform = getComponent(gizmoEntity, TransformComponent)
// const editorHelperState = getState(EditorHelperState)
// EditorControlFunctions.rotateAround(
// nodes,
// Vector3_Up,
// -editorHelperState.rotationSnap * MathUtils.DEG2RAD,
// gizmoTransform.position
// )
// }

const onEscape = () => {
EditorControlFunctions.replaceSelection([])
}

const onKeyT = () => {
const onKeyW = () => {
setTransformMode(TransformMode.translate)
}

const onKeyR = () => {
const onKeyE = () => {
setTransformMode(TransformMode.rotate)
}

const onKeyY = () => {
const onKeyR = () => {
setTransformMode(TransformMode.scale)
}

Expand Down Expand Up @@ -257,9 +255,8 @@ const execute = () => {

if (buttons.KeyQ?.down) onKeyQ()
if (buttons.KeyE?.down) onKeyE()
if (buttons.KeyT?.down) onKeyT()
if (buttons.KeyR?.down) onKeyR()
if (buttons.KeyY?.down) onKeyY()
if (buttons.KeyW?.down) onKeyW()
if (buttons.KeyC?.down) onKeyC()
if (buttons.KeyX?.down) onKeyX()
if (buttons.KeyF?.down) onKeyF()
Expand Down

0 comments on commit 1594a3c

Please sign in to comment.