@tscircuit/core 0.0.741 → 0.0.742

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.
Files changed (2) hide show
  1. package/dist/index.js +11 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -81,6 +81,7 @@ import {
81
81
  rotation as rotation2,
82
82
  schematic_manual_edit_conflict_warning
83
83
  } from "circuit-json";
84
+ import { decomposeTSR as decomposeTSR4 } from "transformation-matrix";
84
85
  import Debug4 from "debug";
85
86
 
86
87
  // lib/fiber/create-instance-from-react-element.ts
@@ -4231,6 +4232,7 @@ var Footprint = class extends PrimitiveComponent2 {
4231
4232
  // lib/components/primitive-components/CadModel.ts
4232
4233
  import { cadmodelProps, point3 } from "@tscircuit/props";
4233
4234
  import { z as z7 } from "zod";
4235
+ import { decomposeTSR as decomposeTSR3 } from "transformation-matrix";
4234
4236
  var rotation = z7.union([z7.number(), z7.string()]);
4235
4237
  var rotation3 = z7.object({ x: rotation, y: rotation, z: rotation });
4236
4238
  var CadModel = class extends PrimitiveComponent2 {
@@ -4250,6 +4252,9 @@ var CadModel = class extends PrimitiveComponent2 {
4250
4252
  const pcb_component = db.pcb_component.get(parent.pcb_component_id);
4251
4253
  const props = this._parsedProps;
4252
4254
  if (!props || typeof props.modelUrl !== "string") return;
4255
+ const parentTransform = parent._computePcbGlobalTransformBeforeLayout();
4256
+ const decomposedTransform = decomposeTSR3(parentTransform);
4257
+ const accumulatedRotation = decomposedTransform.rotation.angle * 180 / Math.PI;
4253
4258
  const rotationOffset = rotation3.parse({ x: 0, y: 0, z: 0 });
4254
4259
  if (typeof props.rotationOffset === "number") {
4255
4260
  rotationOffset.z = Number(props.rotationOffset);
@@ -4290,7 +4295,7 @@ var CadModel = class extends PrimitiveComponent2 {
4290
4295
  rotation: {
4291
4296
  x: Number(rotationOffset.x),
4292
4297
  y: (layer === "top" ? 0 : 180) + Number(rotationOffset.y),
4293
- z: layer === "bottom" ? -((pcb_component?.rotation ?? 0) + Number(rotationOffset.z)) + 180 : (pcb_component?.rotation ?? 0) + Number(rotationOffset.z)
4298
+ z: layer === "bottom" ? -(accumulatedRotation + Number(rotationOffset.z)) + 180 : accumulatedRotation + Number(rotationOffset.z)
4294
4299
  },
4295
4300
  pcb_component_id: parent.pcb_component_id,
4296
4301
  source_component_id: parent.source_component_id,
@@ -8026,6 +8031,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
8026
8031
  ...typeof cadModel?.positionOffset === "object" ? cadModel.positionOffset : {}
8027
8032
  });
8028
8033
  const computedLayer = this.props.layer === "bottom" ? "bottom" : "top";
8034
+ const globalTransform = this._computePcbGlobalTransformBeforeLayout();
8035
+ const decomposedTransform = decomposeTSR4(globalTransform);
8036
+ const accumulatedRotation = decomposedTransform.rotation.angle * 180 / Math.PI;
8029
8037
  const cad_model = db.cad_component.insert({
8030
8038
  // TODO z maybe depends on layer
8031
8039
  position: {
@@ -8036,7 +8044,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
8036
8044
  rotation: {
8037
8045
  x: rotationOffset.x,
8038
8046
  y: (computedLayer === "top" ? 0 : 180) + rotationOffset.y,
8039
- z: computedLayer === "bottom" ? -((pcb_component?.rotation ?? 0) + rotationOffset.z) + 180 : (pcb_component?.rotation ?? 0) + rotationOffset.z
8047
+ z: computedLayer === "bottom" ? -(accumulatedRotation + rotationOffset.z) + 180 : accumulatedRotation + rotationOffset.z
8040
8048
  },
8041
8049
  pcb_component_id: this.pcb_component_id,
8042
8050
  source_component_id: this.source_component_id,
@@ -15691,7 +15699,7 @@ import { identity as identity6 } from "transformation-matrix";
15691
15699
  var package_default = {
15692
15700
  name: "@tscircuit/core",
15693
15701
  type: "module",
15694
- version: "0.0.740",
15702
+ version: "0.0.741",
15695
15703
  types: "dist/index.d.ts",
15696
15704
  main: "dist/index.js",
15697
15705
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.741",
4
+ "version": "0.0.742",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",