Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rianadon committed Jul 14, 2024
1 parent 8abfee4 commit 5030094
Show file tree
Hide file tree
Showing 12 changed files with 637 additions and 652 deletions.
1,173 changes: 542 additions & 631 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"three": "^0.164.1"
},
"devDependencies": {
"@gltf-transform/core": "^3.9.0",
"@gltf-transform/functions": "^3.9.0",
"@gltf-transform/core": "^4.0.4",
"@gltf-transform/functions": "^4.0.4",
"@protobuf-ts/plugin": "^2.8.2",
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/adapter-static": "^3.0.2",
Expand Down
8 changes: 4 additions & 4 deletions src/lib/worker/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,14 @@ async function getModel(conf: Cuttleform, name: string, stitchWalls: boolean, fl
assembly = assembly.transform(new Trsf().translate(0, 0, -geo.floorZ))
return assembly
} else if (name == 'plate' || name == 'platetop') {
return makePlate(conf, geometry, true, true).top()
return makePlate(conf, geometry, true, true).top().translateZ(-geometry.floorZ)
} else if (name == 'platebottom') {
const bot = makePlate(conf, geometry, true, true).bottom
return bot ? bot() : undefined
return bot ? bot().translateZ(-geometry.floorZ) : undefined
} else if (name == 'holder') {
return boardHolder(conf, geometry)
return boardHolder(conf, geometry).translateZ(-geometry.floorZ)
} else if (name == 'wristrest') {
return wristRest(conf, geometry)
return wristRest(conf, geometry).translateZ(-geometry.floorZ)
} else {
throw new Error("I don't know what model you want")
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/worker/cachedGeometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ export class BlockGeometry extends BaseGeometry<SpecificCuttleform<BlockShell>>
}

export class TiltGeometry extends BaseGeometry<SpecificCuttleform<TiltShell>> {
@Memoize()
get worldZ() {
console.log(this.keyHolesTrsfs.map(t => t.xyz()))
if (Array.isArray(this.c.shell.tilt)) return new Vector(...this.c.shell.tilt).normalize()
const angle = this.c.shell.tilt / 180 * Math.PI
return new Vector(Math.sin(angle), 0, Math.cos(angle))
Expand Down
2 changes: 1 addition & 1 deletion src/lib/worker/config.cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export function toCosmosConfig(conf: Cuttleform, side: 'left' | 'right' | 'unibo
screwCountersink: conf.screwCountersink,
clearScrews: conf.clearScrews,
microcontroller: conf.microcontroller,
microcontrollerAngle: conf.microcontrollerAngle,
microcontrollerAngle: conf.microcontrollerAngle || 0,
fastenMicrocontroller: conf.fastenMicrocontroller,
verticalClearance: conf.verticalClearance,
rounded: conf.rounded,
Expand Down
5 changes: 3 additions & 2 deletions src/lib/worker/config.serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export function decodeShell(shell: Keyboard['shell']): Cuttleform['shell'] {
tilt: opts.tiltVector ? tupletoRotOnly(opts.tiltVector) : opts.tilt / 45,
}
}
throw new Error('Shell type not supported')
throw new Error(`Decoding shell type ${shell.oneofKind} not supported`)
}

export function encodeShell(shell: Cuttleform['shell']): Keyboard['shell'] {
Expand Down Expand Up @@ -223,8 +223,9 @@ export function encodeShell(shell: Cuttleform['shell']): Keyboard['shell'] {
for (const key of objKeys(opts.tiltShell)) {
if (opts.tiltShell[key] == TILT_DEFAULTS[key]) delete opts.tiltShell[key]
}
return opts
}
throw new Error(`Shell type ${shell.type} not supported`)
throw new Error(`Encoding shell type ${shell.type} not supported`)
}

interface FullKeyboard extends Required<Keyboard> {
Expand Down
2 changes: 1 addition & 1 deletion src/model_gen/parametric/display-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { drawRoundedRectangle, makeBaseBox } from 'replicad'
const DISP_TOL = 0.05

export interface DisplayProps {
/** Lengtho f the long side of the PCB */
/** Length of the long side of the PCB */
pcbLongSideWidth: number
/** Length of the short side of the PCB */
pcbShortSideWidth: number
Expand Down
19 changes: 14 additions & 5 deletions src/routes/beta/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import { notNull, objEntriesNotNull, objKeys } from '$lib/worker/util'
import { T } from '@threlte/core'
import Checkbox from '$lib/presentation/Checkbox.svelte'
import type { unibody } from '$lib/worker/modeling/transformation-ext'
const DEF_CENTER = [-35.510501861572266, -17.58449935913086, 35.66889877319336] as [
number,
Expand Down Expand Up @@ -215,6 +216,14 @@
let meshes: FullKeyboardMeshes = {}
function cloneConfig(c: FullCuttleform) {
return {
left: c.left ? { ...c.left, shell: { ...c.left.shell } } : undefined,
right: c.right ? { ...c.right, shell: { ...c.right.shell } } : undefined,
unibody: c.unibody ? { ...c.unibody, shell: { ...c.unibody.shell } } : undefined,
}
}
function areDifferent(c1: any, c2: any) {
if (c1 == undefined && c2 == undefined) return []
if (c1 == undefined && c2 != undefined) return ['everything']
Expand Down Expand Up @@ -272,8 +281,8 @@
const differences = areDifferent2(oldConfig, conf)
console.log('differences', differences)
if (differences.length == 0) return
oldConfig = conf
oldTempConfig = conf
oldConfig = cloneConfig(conf)
oldTempConfig = cloneConfig(conf)
if (
differences.length == 1 &&
Expand Down Expand Up @@ -315,14 +324,14 @@
return
}
} else if (full) {
oldConfig = conf
oldTempConfig = conf
oldConfig = cloneConfig(conf)
oldTempConfig = cloneConfig(conf)
} else {
if (oldTempConfig) {
const differences = areDifferent2(oldTempConfig, conf)
if (differences.length == 0) return
}
oldTempConfig = conf
oldTempConfig = cloneConfig(conf)
}
let originalErr: ConfError | undefined
Expand Down
2 changes: 1 addition & 1 deletion src/routes/beta/lib/editor/AngleInput.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
export let value: any
export let value: number
export let small = false
export let divisor = 45
Expand Down
57 changes: 54 additions & 3 deletions src/routes/beta/lib/editor/VisualEditor2.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
else if (type == 'tilt')
$protoConfig.shell = {
type: 'tilt',
tilt: $rotationY / 2,
raiseBy: 10,
tilt: $rotationY * 0.4,
raiseBy: 3,
pattern: [10, 5],
}
else if (type == 'stilts')
Expand Down Expand Up @@ -246,6 +246,26 @@
}
}
function setTiltPillarsEnabled(e: Event) {
if ($protoConfig.shell.type != 'tilt') return
if ((e.target as HTMLInputElement).checked) $protoConfig.shell.pattern = [10, 5]
else $protoConfig.shell.pattern = null
}
function enterPattern() {
if ($protoConfig.shell.type != 'tilt') return
const ind = $protoConfig.shell.pattern?.join(',')
const newInd = prompt(
'Enter the lengths of pillars and gaps in the pattern separated by commas. For example: 10, 5.',
ind
)
if (newInd) {
const splitInd = newInd.split(',').map(Number)
if (splitInd.some(isNaN)) return
$protoConfig.shell.pattern = splitInd
}
}
function setThumb(
type: 'carbonfet' | 'manuform' | 'orbyl' | 'curved',
side: 'left' | 'right',
Expand Down Expand Up @@ -768,11 +788,42 @@
>Tilting Base</Preset
>
</div>
{#if $protoConfig.shell.type == 'tilt'}
{#if $protoConfig.shell.type == 'basic'}
{#if !basic}
<Field name="Add Lip" help="Add a lip to the bottom plate to hide warping defects">
<Checkbox bind:value={$protoConfig.shell.lip} />
</Field>
{/if}
{:else if $protoConfig.shell.type == 'stilts'}
<Field name="Tuck in Bottom Plate">
<Checkbox bind:value={$protoConfig.shell.inside} />
</Field>
{:else if $protoConfig.shell.type == 'tilt'}
<InfoBox>
The Tilting Base helps you achieve high tenting angles without needing to print as much support.
Make sure to print the plate in two parts so that the bottom can be removed for access.
</InfoBox>
<Field name="Case Tenting Angle" icon="angle">
{#if typeof $protoConfig.shell.tilt == 'number'}
<AngleInput bind:value={$protoConfig.shell.tilt} />
{:else}
<InfoBox>
The tilt angle is currently configured as a vector, which can only be edited in Expert Mode.
</InfoBox>
{/if}
</Field>
{#if !basic}<div class="relative">
<div class="absolute right-48 top--1.5">
<button class="button" on:click={enterPattern}><Icon path={mdiCodeJson} /></button>
</div>
<Field name="Use Pillars">
<Checkbox value={$protoConfig.shell.pattern != null} on:change={setTiltPillarsEnabled} />
</Field>
</div>
<Field name="Raise Case By" icon="expand-vertical">
<DecimalInput bind:value={$protoConfig.shell.raiseBy} units="mm" />
</Field>
{/if}
{/if}
{#if !basic}
<Field name="Connectivity" icon="usb-port">
Expand Down
2 changes: 1 addition & 1 deletion src/routes/embed/recover/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<div>
{#if recovered.length && recovered.startsWith('http')}
<p class="inline-block bg-pink-100 rounded-1 px-8 py-2">
Your recovered link is <a href={recovered}>{formatURL(recovered)}</a>.
Your recovered link is <a target="_parent" href={recovered}>{formatURL(recovered)}</a>.
</p>
{:else if recovered.length}
<p class="mb-2">The embedded data in the {filetype} file isn't a URL. Instead, it's:</p>
Expand Down
13 changes: 12 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
},
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in

// To maybe avoid https://github.com/sveltejs/language-tools/issues/2171
// "Svelte language sever detected a large amount of files" on Svelte build
"exclude": [
"./node_modules/**",
"./dist/**",
"./build/**",
"./.svelte/**",
"./coverage/**",
"**/_/**"
]
}

0 comments on commit 5030094

Please sign in to comment.