Skip to content

Commit

Permalink
More reliable row add, transformcontrols stuff that went nowhere
Browse files Browse the repository at this point in the history
  • Loading branch information
rianadon committed Oct 10, 2024
1 parent 8a91b04 commit fe70a53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/3d/TransformControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
transformationCenter,
} from '../../routes/beta/lib/viewers/viewer3dHelpers'
import type { CosmosKeyboard } from '$lib/worker/config.cosmos'
import { TransformControls as TC } from 'three/examples/jsm/controls/TransformControls.js'
export let visible = true
export let snap: boolean
let controls: TC
const dispatch = createEventDispatcher()
const pos = new Vector3()
Expand Down Expand Up @@ -42,6 +44,13 @@
position = pos.toArray()
quaternion = quat.toArray() as Vector4Tuple
}
// const dispatchSnap = (_snap: boolean) => {
// // Force the controls to update themselves, therefore updating the controlled object
// // This causes the key to move when snap is enabled/disabled
// setTimeout(() => controls.dragging && controls.pointerMove(null), 5)
// }
// $: dispatchSnap(snap)
</script>

{#if ($transformMode == 'rotate' || $transformMode == 'translate') && $clickedKey != null && visible}
Expand All @@ -52,6 +61,7 @@
space={$transformMode == 'translate' && $selectMode == 'cluster' ? 'world' : 'local'}
mode={$transformMode}
rotationSnap={snap ? Math.PI / 2 : undefined}
bind:controls
on:objectChange={() => {
ref.updateMatrix()
dispatch('move', conditionalFlip(ref.matrix, $view, $clickedKey, $protoConfig))
Expand Down
1 change: 1 addition & 0 deletions src/routes/beta/lib/editor/visualEditorHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export function addRow(kbd: CosmosKeyboard, fn: (side: 'left' | 'right', alphas:
const alphas = alphaColumns(kbd, cluster)
return mapClusters(cluster, (col, i) => {
const firstKey = col.keys.filter(a => !!a.row).sort((a, b) => a.row! - b.row!)[0]
if (!firstKey) return col
if (!PART_INFO[firstKey.partType.type || col.partType.type || kbd.partType.type!].keycap) return col // Skip if first key not a keycap
const oldRow = firstKey?.profile.row
const row = (firstKey?.row || 0) - 1
Expand Down

0 comments on commit fe70a53

Please sign in to comment.