imrishabh18/nema-23-stepper-controller

A tscircuit package created by imrishabh18.

Version
1.3.13
License
unset
Stars
1

nema23-model.ts

import { AssemblyMotor } from "tscircuit"

const modelUrl = "https://models.tscircuit.com/nema23_wirestubs.glb"
const prototype = AssemblyMotor.prototype as any
const marker = Symbol.for("nema23.current-motor-model")

// This core version has no assembly.motor model URL override. Keep its native
// mounting references, replacing only the old CDN mesh after CAD rendering.
if (!prototype[marker]) {
  const render = prototype.doInitialCadModelRender
  prototype.doInitialCadModelRender = function () {
    render.call(this)
    if (this.name !== "MOTOR" || this.motorModelString !== "nema23_wirestubs" || !this.cad_component_id) return
    this.root.db.cad_component.update(this.cad_component_id, {
      model_glb_url: modelUrl,
      // The new export uses standard glTF Y-up coordinates measured in meters.
      model_unit_to_mm_scale_factor: 1000,
      model_board_normal_direction: "y+",
    })
  }
  prototype[marker] = true
}