@tscircuit/3d-viewer 0.0.509 → 0.0.511

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -122,6 +122,7 @@ Props:
122
122
 
123
123
  - `circuit-json`: (optional) An array of AnyCircuitElement objects representing the PCB layout.
124
124
  - `children`: (optional) React children elements describing the PCB layout (alternative to using `circuit-json`).
125
+ - `resolveStaticAsset`: (optional) Function that receives each component model URL (`obj`, `wrl`, `stl`, `gltf`, `glb`, `step`) and returns the resolved URL to load.
125
126
 
126
127
  ### `<board>`
127
128
 
package/dist/index.js CHANGED
@@ -28263,6 +28263,12 @@ var StepModel = ({
28263
28263
  );
28264
28264
  };
28265
28265
 
28266
+ // src/utils/resolve-model-url.ts
28267
+ var resolveModelUrl = (modelUrl, resolveStaticAsset) => {
28268
+ if (!modelUrl) return void 0;
28269
+ return resolveStaticAsset ? resolveStaticAsset(modelUrl) : modelUrl;
28270
+ };
28271
+
28266
28272
  // src/utils/tuple.ts
28267
28273
  var tuple = (...args) => args;
28268
28274
 
@@ -28270,7 +28276,8 @@ var tuple = (...args) => args;
28270
28276
  import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
28271
28277
  var AnyCadComponent = ({
28272
28278
  cad_component,
28273
- circuitJson
28279
+ circuitJson,
28280
+ resolveStaticAsset
28274
28281
  }) => {
28275
28282
  const pcbThickness = usePcbThickness(circuitJson);
28276
28283
  const [isHovered, setIsHovered] = useState7(false);
@@ -28300,9 +28307,19 @@ var AnyCadComponent = ({
28300
28307
  );
28301
28308
  return platedHoles.length > 0;
28302
28309
  }, [circuitJson, cad_component.pcb_component_id]);
28303
- const url = cad_component.model_obj_url ?? cad_component.model_wrl_url ?? cad_component.model_stl_url;
28304
- const gltfUrl = cad_component.model_glb_url ?? cad_component.model_gltf_url;
28305
- const stepUrl = cad_component.model_step_url;
28310
+ const resolveModelUrlWithStaticResolver = useCallback3(
28311
+ (modelUrl) => resolveModelUrl(modelUrl, resolveStaticAsset),
28312
+ [resolveStaticAsset]
28313
+ );
28314
+ const url = resolveModelUrlWithStaticResolver(
28315
+ cad_component.model_obj_url ?? cad_component.model_wrl_url ?? cad_component.model_stl_url
28316
+ );
28317
+ const gltfUrl = resolveModelUrlWithStaticResolver(
28318
+ cad_component.model_glb_url ?? cad_component.model_gltf_url
28319
+ );
28320
+ const stepUrl = resolveModelUrlWithStaticResolver(
28321
+ cad_component.model_step_url
28322
+ );
28306
28323
  const pcbComponent = circuitJson.find(
28307
28324
  (elm) => elm.type === "pcb_component" && elm.source_component_id === cad_component.source_component_id
28308
28325
  );
@@ -28447,7 +28464,7 @@ import * as THREE16 from "three";
28447
28464
  // package.json
28448
28465
  var package_default = {
28449
28466
  name: "@tscircuit/3d-viewer",
28450
- version: "0.0.508",
28467
+ version: "0.0.510",
28451
28468
  main: "./dist/index.js",
28452
28469
  module: "./dist/index.js",
28453
28470
  type: "module",
@@ -34184,7 +34201,8 @@ var CadViewerJscad = forwardRef3(
34184
34201
  autoRotateDisabled,
34185
34202
  clickToInteractEnabled,
34186
34203
  onUserInteraction,
34187
- onCameraControllerReady
34204
+ onCameraControllerReady,
34205
+ resolveStaticAsset
34188
34206
  }, ref) => {
34189
34207
  const childrenSoup = useConvertChildrenToCircuitJson(children);
34190
34208
  const internalCircuitJson = useMemo20(() => {
@@ -34291,7 +34309,8 @@ var CadViewerJscad = forwardRef3(
34291
34309
  AnyCadComponent,
34292
34310
  {
34293
34311
  cad_component,
34294
- circuitJson: internalCircuitJson
34312
+ circuitJson: internalCircuitJson,
34313
+ resolveStaticAsset
34295
34314
  },
34296
34315
  cad_component.cad_component_id
34297
34316
  )
@@ -36097,7 +36116,8 @@ var CadViewerManifold = ({
36097
36116
  clickToInteractEnabled,
36098
36117
  onUserInteraction,
36099
36118
  children,
36100
- onCameraControllerReady
36119
+ onCameraControllerReady,
36120
+ resolveStaticAsset
36101
36121
  }) => {
36102
36122
  const childrenCircuitJson = useConvertChildrenToCircuitJson(children);
36103
36123
  const circuitJson = useMemo22(() => {
@@ -36278,7 +36298,8 @@ try {
36278
36298
  AnyCadComponent,
36279
36299
  {
36280
36300
  cad_component,
36281
- circuitJson
36301
+ circuitJson,
36302
+ resolveStaticAsset
36282
36303
  }
36283
36304
  )
36284
36305
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.509",
3
+ "version": "0.0.511",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",