Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/lib/3d/Keyboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import KeyboardMaterial from './KeyboardMaterial.svelte'
import KeyboardPartGeo from './KeyboardPartGeo.svelte'
import KeyboardKeycapGeo from './KeyboardKeycapGeo.svelte'
import type { CuttleKey, Geometry } from '$lib/worker/config'
import type { CuttleKey, Geometry, KeyboardSide } from '$lib/worker/config'
import * as flags from '$lib/flags'
import { keyBrightness, type KeyStatus } from './keyboardKey'
import { hasKeyGeometry, keyUrl } from '$lib/loaders/keycaps'
Expand All @@ -23,15 +23,15 @@
import { T } from '@threlte/core'
import { variantURL, PART_INFO } from '$lib/geometry/socketsParts'
import { DefaultMap } from '$lib/worker/util'
import { MeshStandardMaterial, Quaternion, Vector3, type Vector3Tuple, type Vector4Tuple } from 'three'
import { Quaternion, Vector3, type Vector3Tuple, type Vector4Tuple } from 'three'

export let geometry: Geometry | null
export let transparency: number = 100
export let pressedLetter: string | null = null
export let translation: number = 0
export let flip = true
export let reachability: boolean[] | undefined = undefined
export let side: 'left' | 'right' | 'unibody'
export let side: KeyboardSide
export let keyColor: [any, number] | undefined = undefined
export let trackballColor: any | undefined = undefined
export let switchColor: [any, number] | undefined = undefined
Expand Down
2 changes: 1 addition & 1 deletion src/lib/3d/KeyboardKey.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { interactivity } from '@threlte/extras'

export let index: number | null
export let side: 'left' | 'right' | 'unibody' = 'right'
export let side: 'left' | 'right' | 'unibody' | 'center' = 'right'

type InteractivityContext = ReturnType<typeof interactivity>
const context: InteractivityContext = getContext('interactivity')
Expand Down
4 changes: 2 additions & 2 deletions src/lib/3d/KeyboardModel.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { view, noBase, noWall } from '$lib/store'
import type { Geometry } from '$lib/worker/config'
import type { Geometry, KeyboardSide } from '$lib/worker/config'
import GroupMatrix from './GroupMatrix.svelte'
import Microcontroller from './Microcontroller.svelte'
import KMesh from '$lib/3d/KeyboardMeshBetter.svelte'
Expand All @@ -10,7 +10,7 @@
export let keebGeometry: Geometry | undefined = undefined
export let meshes: KeyboardMeshes
export let transparency: number = 100
export let side: 'left' | 'right' | 'unibody'
export let side: KeyboardSide

export let noWeb = false

Expand Down
2 changes: 1 addition & 1 deletion src/lib/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const openSelect = writable<symbol | null>(null)

export const hoveredKey = writable<number | null>(null)
export const clickedKey = writable<number | null>(null)
export const clickedSide = writable<'left' | 'right' | 'unibody' | null>(null)
export const clickedSide = writable<'left' | 'right' | 'unibody' | 'center' | null>(null)
export const lastKeycap = writable<number>(0)

// --- Alerts -----------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions src/lib/worker/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { BufferAttribute, BufferGeometry, Mesh } from 'three'
import { getUser } from '../../routes/beta/lib/login'
import { ITriangle } from '../loaders/simplekeys'
import { type ConfError, type ConfErrors, isPro, keycapIntersections, partIntersections, socketIntersections } from './check'
import { type Cuttleform, type CuttleKey, type Geometry, newGeometry } from './config'
import { type Cuttleform, type CuttleKey, type Geometry, type KeyboardSide, newGeometry } from './config'
import { boardHolder, cutWithConnector, keyHoles, makePlate, makePlateMesh, makerScrewInserts, makeWalls, type ScrewInsertTypes, webSolid } from './model'
import { Assembly } from './modeling/assembly'
import { blobSTL, combine, type ShapeMesh } from './modeling/index'
Expand Down Expand Up @@ -306,7 +306,7 @@ async function getModel(conf: Cuttleform, name: string, stitchWalls: boolean, fl
}
}

export async function getSTL(conf: Cuttleform, name: string, side: 'left' | 'right' | 'unibody' | 'test', stitchWalls: boolean) {
export async function getSTL(conf: Cuttleform, name: string, side: KeyboardSide | 'test', stitchWalls: boolean) {
const flip = side == 'left'
let model = await getModel(conf, name, stitchWalls, flip)
if (name == 'wristrest' && side == 'unibody' && conf.wristRestRight && model) {
Expand Down Expand Up @@ -385,7 +385,7 @@ function meshWithVolumeAndSupport(solid: Solid, minZ: number) {
// return props.Mass()
// }

export async function intersections(conf: Cuttleform, side: 'left' | 'right' | 'unibody'): Promise<ConfErrors> {
export async function intersections(conf: Cuttleform, side: KeyboardSide): Promise<ConfErrors> {
const intersections: ConfErrors = []
try {
const geometry = newGeometry(conf)
Expand Down
18 changes: 8 additions & 10 deletions src/lib/worker/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Triangle } from 'three'
import { Octree } from 'three/examples/jsm/math/Octree.js'
import { Vector2 } from 'three/src/math/Vector2.js'
import { calcTravel, ITriangle, simpleKey, simpleKeyPosition } from '../loaders/simplekeys'
import type { Cuttleform, CuttleKey, Geometry } from './config'
import type { Cuttleform, CuttleKey, Geometry, KeyboardSide } from './config'
import { type CriticalPoints, keyHolesTrsfs2D } from './geometry'
import { intersectPolyPoly } from './geometry.intersections'
import Trsf, { Vector } from './modeling/transformation'
Expand Down Expand Up @@ -78,9 +78,7 @@ const PROPERTIES = ['aspect', 'type', 'position']

export type ConfError =
& (IntersectionError | MissingError | WrongError | OobError | InvalidError | ExceptionError | NanError | NoKeysError | WallBoundsError | WrongFormatError | SamePositionError | NotEnoughPinsError)
& {
side: 'left' | 'right' | 'unibody'
}
& { side: KeyboardSide }
export type ConfErrors = ConfError[]

export function isRenderableError(e: ConfError | undefined) {
Expand All @@ -98,7 +96,7 @@ export function salientError(e: ConfErrors): ConfError {
return e[0]
}

export function checkConfig(conf: Cuttleform, geometry: Geometry | undefined, check3d = true, side: 'left' | 'right' | 'unibody'): ConfErrors {
export function checkConfig(conf: Cuttleform, geometry: Geometry | undefined, check3d = true, side: KeyboardSide): ConfErrors {
if (!conf.keys) return [{ type: 'wrongformat', side }]
if (!conf.keys.length) return [{ type: 'nokeys', side }]

Expand Down Expand Up @@ -270,7 +268,7 @@ function prismTriangles(facePoints: Trsf[], center: Trsf, depth: number, index:
})
}

export function* keycapIntersections(conf: Cuttleform, trsfs: Trsf[], web: ITriangle[], side: 'left' | 'right' | 'unibody') {
export function* keycapIntersections(conf: Cuttleform, trsfs: Trsf[], web: ITriangle[], side: KeyboardSide) {
const tree = new Octree()
for (const tri of web) {
tree.addTriangle(tri)
Expand All @@ -288,7 +286,7 @@ export function* keycapIntersections(conf: Cuttleform, trsfs: Trsf[], web: ITria
yield* treeIntersections(conf, tree, 'keycap', side)
}

export function* partIntersections(conf: Cuttleform, trsfs: Trsf[], side: 'left' | 'right' | 'unibody') {
export function* partIntersections(conf: Cuttleform, trsfs: Trsf[], side: KeyboardSide) {
const tree = new Octree()
for (let i = 0; i < trsfs.length; i++) {
const key = conf.keys[i]
Expand All @@ -302,7 +300,7 @@ export function* partIntersections(conf: Cuttleform, trsfs: Trsf[], side: 'left'
yield* treeIntersections(conf, tree, 'part', side)
}

export function* unsortedSocketIntersections(conf: Cuttleform, trsfs: Trsf[], critPts: CriticalPoints[], web: ITriangle[], side: 'left' | 'right' | 'unibody') {
export function* unsortedSocketIntersections(conf: Cuttleform, trsfs: Trsf[], critPts: CriticalPoints[], web: ITriangle[], side: KeyboardSide) {
const tree = new Octree()
for (const tri of web) {
tree.addTriangle(tri)
Expand All @@ -324,7 +322,7 @@ export function* unsortedSocketIntersections(conf: Cuttleform, trsfs: Trsf[], cr
* Every socket-socket intersection will generate a socket->wall intersection as well,
* but the socket-socket intersections are easier to debug so they should get priority.
*/
export function* socketIntersections(conf: Cuttleform, trsfs: Trsf[], critPts: CriticalPoints[], web: ITriangle[], side: 'left' | 'right' | 'unibody') {
export function* socketIntersections(conf: Cuttleform, trsfs: Trsf[], critPts: CriticalPoints[], web: ITriangle[], side: KeyboardSide) {
const socketSocketIntersections: ConfError[] = []
const socketWallIntersections: ConfError[] = []
for (const intersection of unsortedSocketIntersections(conf, trsfs, critPts, web, side)) {
Expand All @@ -343,7 +341,7 @@ function* treeIntersections(
conf: Cuttleform,
tree: Octree,
what: 'keycap' | 'socket' | 'part',
side: 'left' | 'right' | 'unibody',
side: KeyboardSide,
ignoreTouching = false,
intersected?: DefaultMap<number, Map<number, boolean>> | undefined,
): Generator<ConfError> {
Expand Down
Loading
Loading