abse/smartwatch-flex-top-only
Three-panel flex smartwatch with two parallel R3.9 bends, all components flat-top, low-profile JST connector harnesses, split heartbeat optical windows and screw-retained PCB mounting. Modeled 39 × 50.5 × 14.5mm prototype; 100% routing, zero native DRC and shorts. Hardware qualification pending.
- Version
- 0.2.20
- License
- unset
- Stars
- 0
components/AssemblyCable.tsx
import React from 'react'
import {assembly} from 'tscircuit'
type CableDefinition={name:string;from:string;to:string;modelUrl:string;pose?:{positionOffset:{x:number;y:number;z:number};rotationOffset:{x:number;y:number;z:number}}}
/**
* Project-local CAD adapter for the native assembly.cable host element.
* Core's current cable renderer knows SH/PH only and cannot route inside a
* watch. This supplies explicitly measured ACH plugs and clearance-checked
* paths and PicoBlade motor termination without changing core or PCB checks.
* Endpoint identities remain real assembly parts. The emitted geometry is
* cad_component (imported GLB), not a falsely labelled SH cad_cable record.
*/
export function AssemblyCable({name,from,to,modelUrl,pose}:CableDefinition){
return React.createElement(assembly.cable as any,{
name,from,to,model:'jst_ach_pins2',
ref:(instance:any)=>{
if(!instance||instance.__achCadAdapter)return
instance.__achCadAdapter=true
let sourceId:string|undefined,cadId:string|undefined
const render=()=>{
const root=instance.root
if(!root||root.pcbDisabled)return
const all=root.db.source_component.list()
for(const selector of [from,to]){
if(!selector.startsWith('.'))throw Error('ACH cable endpoint must be a named assembly part: '+selector)
const matches=all.filter((e:any)=>e.name===selector.slice(1))
if(matches.length!==1)throw Error(`Cable ${name}: ${selector} matched ${matches.length} identities`)
}
if(!sourceId)sourceId=root.db.source_component.insert({ftype:'subassembly',name}).source_component_id
const model={source_component_id:sourceId,model_glb_url:modelUrl,
position:pose?.positionOffset??{x:0,y:0,z:0},rotation:pose?.rotationOffset??{x:0,y:0,z:0},layer:'top',
model_origin_position:{x:0,y:0,z:0},model_unit_to_mm_scale_factor:1,
model_object_fit:'contain_within_bounds',anchor_alignment:'center',show_as_translucent_model:false}
if(cadId)root.db.cad_component.update(cadId,model)
else cadId=root.db.cad_component.insert(model).cad_component_id
}
instance.doInitialCadModelRender=render
instance.updateCadModelRender=render
},
})
}