@code3d/core 0.0.1-alpha.11 → 0.0.1-alpha.13

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 (36) hide show
  1. package/README.md +55 -41
  2. package/bld/chunks/{chunk-HZRQUHM2.js → chunk-776Q5P2L.js} +2 -2
  3. package/bld/chunks/{chunk-QK6ZET47.js → chunk-N7JJWNVL.js} +3 -3
  4. package/bld/chunks/{chunk-CL3E2DE4.js → chunk-VFPWXSFD.js} +2 -2
  5. package/bld/chunks/{chunk-JBVIAMJ6.js → chunk-VINZNODV.js} +589 -26
  6. package/bld/chunks/chunk-VINZNODV.js.map +7 -0
  7. package/bld/library/extrude.d.ts +5 -0
  8. package/bld/library/extrude.d.ts.map +1 -1
  9. package/bld/library/index.d.ts +2 -2
  10. package/bld/library/index.d.ts.map +1 -1
  11. package/bld/library/index.js +17 -1
  12. package/bld/library/inspect.d.ts +3 -1
  13. package/bld/library/inspect.d.ts.map +1 -1
  14. package/bld/library/loft.d.ts +7 -1
  15. package/bld/library/loft.d.ts.map +1 -1
  16. package/bld/library/replicad.js +2 -2
  17. package/bld/library/runtime.d.ts +75 -8
  18. package/bld/library/runtime.d.ts.map +1 -1
  19. package/bld/node/index.js +19 -3
  20. package/bld/node/replicad.js +4 -4
  21. package/bld/tooling/index.js +2 -2
  22. package/docs/api.md +143 -13
  23. package/docs/local-coordinates.md +2 -0
  24. package/docs/runtime.md +52 -2
  25. package/docs/topology.md +6 -0
  26. package/docs/values.md +34 -31
  27. package/package.json +1 -1
  28. package/src/library/extrude.ts +129 -2
  29. package/src/library/index.ts +9 -0
  30. package/src/library/inspect.ts +4 -2
  31. package/src/library/loft.ts +67 -2
  32. package/src/library/runtime.ts +646 -8
  33. package/bld/chunks/chunk-JBVIAMJ6.js.map +0 -7
  34. /package/bld/chunks/{chunk-HZRQUHM2.js.map → chunk-776Q5P2L.js.map} +0 -0
  35. /package/bld/chunks/{chunk-QK6ZET47.js.map → chunk-N7JJWNVL.js.map} +0 -0
  36. /package/bld/chunks/{chunk-CL3E2DE4.js.map → chunk-VFPWXSFD.js.map} +0 -0
@@ -1115,10 +1115,10 @@ function sketchCurveClosestParameter(curve, position2) {
1115
1115
  position2[0] - curve.center[0]
1116
1116
  );
1117
1117
  if (curve.kind === "circle") return sketchPositiveAngle(angle) / tau;
1118
- const sign3 = Math.sign(curve.sweep), sweep = Math.abs(curve.sweep);
1118
+ const sign3 = Math.sign(curve.sweep), sweep2 = Math.abs(curve.sweep);
1119
1119
  const distance4 = sketchPositiveAngle(sign3 * (angle - curve.start));
1120
- if (distance4 <= sweep) return sweep ? distance4 / sweep : 0;
1121
- return distance4 - sweep < tau - distance4 ? 1 : 0;
1120
+ if (distance4 <= sweep2) return sweep2 ? distance4 / sweep2 : 0;
1121
+ return distance4 - sweep2 < tau - distance4 ? 1 : 0;
1122
1122
  }
1123
1123
  __name(sketchCurveClosestParameter, "sketchCurveClosestParameter");
1124
1124
  function sketchCurveBounds(curve) {
@@ -3944,14 +3944,14 @@ function pointSession(context, policies) {
3944
3944
  );
3945
3945
  if (radius === 0) continue;
3946
3946
  radii.set(index, radius);
3947
- const sweep = reference.constraints.some(
3947
+ const sweep2 = reference.constraints.some(
3948
3948
  (c) => c.kind === "sweep" && c.index === index
3949
3949
  );
3950
3950
  const direction = target.position.every((v, axis) => v === center[axis]) ? current.points[target.point].position : target.position;
3951
3951
  const turn = Math.atan2(direction[1] - center[1], direction[0] - center[0]) - Math.atan2(from[1] - center[1], from[0] - center[0]);
3952
3952
  for (const point3 of arc2.points) {
3953
3953
  let position2 = point3 === target.point ? direction : reference.points[point3].position;
3954
- if (sweep && point3 !== target.point) {
3954
+ if (sweep2 && point3 !== target.point) {
3955
3955
  const [x, y] = [position2[0] - center[0], position2[1] - center[1]];
3956
3956
  position2 = [
3957
3957
  center[0] + x * Math.cos(turn) - y * Math.sin(turn),
@@ -4172,7 +4172,7 @@ __name(averagePosition, "averagePosition");
4172
4172
 
4173
4173
  // packages/core/src/library/runtime.ts
4174
4174
  import {
4175
- assembleWire,
4175
+ assembleWire as assembleWire3,
4176
4176
  basicFaceExtrusion,
4177
4177
  BoundingBox as BoundingBox2,
4178
4178
  genericSweep,
@@ -4182,11 +4182,14 @@ import {
4182
4182
  makeCircle as makeCircle2,
4183
4183
  makeCylinder,
4184
4184
  makeFace,
4185
- makeHelix,
4186
- makeLine as makeLine2,
4185
+ makeHelix as makeHelix2,
4186
+ makeLine as makeLine3,
4187
4187
  makeSphere,
4188
4188
  makeThreePointArc as makeThreePointArc2,
4189
4189
  makeVertex,
4190
+ measureShapeLinearProperties as measureShapeLinearProperties2,
4191
+ measureShapeSurfaceProperties as measureShapeSurfaceProperties2,
4192
+ measureShapeVolumeProperties,
4190
4193
  sketchCircle,
4191
4194
  sketchEllipse,
4192
4195
  sketchPolysides,
@@ -4538,7 +4541,14 @@ function nearestPoint(point3, geometry) {
4538
4541
  __name(nearestPoint, "nearestPoint");
4539
4542
 
4540
4543
  // packages/core/src/library/extrude.ts
4541
- import { getOC as getOC6, Vector } from "replicad";
4544
+ import {
4545
+ assembleWire,
4546
+ getOC as getOC6,
4547
+ makeHelix,
4548
+ makeLine,
4549
+ measureVolume,
4550
+ Vector
4551
+ } from "replicad";
4542
4552
 
4543
4553
  // packages/core/src/library/topology.ts
4544
4554
  import {
@@ -5102,12 +5112,169 @@ function extrudeWithTopology(source, direction) {
5102
5112
  }
5103
5113
  }
5104
5114
  __name(extrudeWithTopology, "extrudeWithTopology");
5115
+ function revolveWithTopology(source, center, direction, angle, advance) {
5116
+ const oc = getOC6();
5117
+ if (advance === 0) {
5118
+ const point3 = new oc.gp_Pnt(...center);
5119
+ let dir;
5120
+ let axis;
5121
+ let shape2;
5122
+ try {
5123
+ dir = new oc.gp_Dir(...direction);
5124
+ axis = new oc.gp_Ax1(point3, dir);
5125
+ const builder = new oc.BRepPrimAPI_MakeRevol(
5126
+ source.shape.wrapped,
5127
+ axis,
5128
+ angle * (Math.PI / 180),
5129
+ false
5130
+ );
5131
+ try {
5132
+ if (!builder.IsDone()) throw new Error("Could not revolve the face.");
5133
+ shape2 = castOwnedShape3D(builder.Shape());
5134
+ requireRevolvedVolume(shape2);
5135
+ return {
5136
+ shape: shape2,
5137
+ topology: transferShapeTopology([source], shape2, builder)
5138
+ };
5139
+ } finally {
5140
+ builder.delete();
5141
+ }
5142
+ } catch (error) {
5143
+ shape2?.delete();
5144
+ throw error;
5145
+ } finally {
5146
+ axis?.delete();
5147
+ dir?.delete();
5148
+ point3.delete();
5149
+ }
5150
+ }
5151
+ const boundaries = shapeSubshapes(source.shape, "wire");
5152
+ try {
5153
+ if (boundaries.length !== 1)
5154
+ throw new Error("Helical revolution requires a face without holes.");
5155
+ } finally {
5156
+ boundaries.forEach((boundary) => boundary.delete());
5157
+ }
5158
+ const end = [
5159
+ center[0] + direction[0] * advance,
5160
+ center[1] + direction[1] * advance,
5161
+ center[2] + direction[2] * advance
5162
+ ];
5163
+ let startVector;
5164
+ let endVector;
5165
+ let line2;
5166
+ let spine;
5167
+ let guide;
5168
+ let wire;
5169
+ let shape;
5170
+ try {
5171
+ startVector = new Vector([...center]);
5172
+ endVector = new Vector([...end]);
5173
+ line2 = makeLine(startVector, endVector);
5174
+ spine = assembleWire([line2]);
5175
+ guide = makeHelix(
5176
+ advance * 360 / angle,
5177
+ advance,
5178
+ 1,
5179
+ [...center],
5180
+ [...direction]
5181
+ );
5182
+ wire = source.shape.clone().outerWire();
5183
+ const builder = new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped);
5184
+ try {
5185
+ builder.SetMode(
5186
+ guide.wrapped,
5187
+ false,
5188
+ oc.BRepFill_TypeOfContact.BRepFill_NoContact
5189
+ );
5190
+ builder.Add(wire.wrapped, false, false);
5191
+ if (!builder.IsReady())
5192
+ throw new Error(
5193
+ "Could not associate the profile with the rotation axis."
5194
+ );
5195
+ builder.Build();
5196
+ if (!builder.IsDone() || !builder.MakeSolid())
5197
+ throw new Error("Could not construct a solid helical revolution.");
5198
+ shape = castOwnedShape3D(builder.Shape());
5199
+ requireRevolvedVolume(shape);
5200
+ return { shape };
5201
+ } finally {
5202
+ builder.delete();
5203
+ }
5204
+ } catch (error) {
5205
+ shape?.delete();
5206
+ throw error;
5207
+ } finally {
5208
+ wire?.delete();
5209
+ guide?.delete();
5210
+ spine?.delete();
5211
+ line2?.delete();
5212
+ endVector?.delete();
5213
+ startVector?.delete();
5214
+ }
5215
+ }
5216
+ __name(revolveWithTopology, "revolveWithTopology");
5217
+ function requireRevolvedVolume(shape) {
5218
+ if (!(Math.abs(measureVolume(shape)) > 0))
5219
+ throw new Error("Revolution did not produce a non-degenerate solid.");
5220
+ }
5221
+ __name(requireRevolvedVolume, "requireRevolvedVolume");
5105
5222
 
5106
5223
  // packages/core/src/library/loft.ts
5107
5224
  import {
5225
+ assembleWire as assembleWire2,
5108
5226
  cast as cast2,
5109
- getOC as getOC7
5227
+ getOC as getOC7,
5228
+ measureVolume as measureVolume2
5110
5229
  } from "replicad";
5230
+ function sweepWithTopology(profile, path, normal) {
5231
+ if (path.isClosed || !(path.length > 1e-9))
5232
+ throw new Error("Sweep spine must be a non-degenerate open curve.");
5233
+ const start = path.pointAt(0);
5234
+ let tangent2;
5235
+ try {
5236
+ tangent2 = path.tangentAt(0);
5237
+ const position2 = start.toTuple();
5238
+ const direction = tangent2.toTuple();
5239
+ const magnitude = Math.hypot(...direction);
5240
+ if (!(magnitude > 1e-9))
5241
+ throw new Error("Sweep spine must have a non-zero starting tangent.");
5242
+ if (Math.hypot(...position2) > 1e-6)
5243
+ throw new Error(
5244
+ "Sweep profile origin must coincide with the spine start."
5245
+ );
5246
+ if ((normal[0] * direction[0] + normal[1] * direction[1] + normal[2] * direction[2]) / magnitude < 1 - 1e-6)
5247
+ throw new Error(
5248
+ "Sweep profile normal must point along the spine start tangent."
5249
+ );
5250
+ } finally {
5251
+ tangent2?.delete();
5252
+ start.delete();
5253
+ }
5254
+ const spine = assembleWire2([path]);
5255
+ let result;
5256
+ try {
5257
+ result = loftWithTopology([profile], spine, false);
5258
+ if (!(Math.abs(measureVolume2(result.shape)) > 0))
5259
+ throw new Error("Sweep did not produce a non-degenerate solid.");
5260
+ const validation = new (getOC7()).BRepCheck_Analyzer(result.shape.wrapped);
5261
+ try {
5262
+ if (!validation.IsValid())
5263
+ throw new Error(
5264
+ "Sweep produced an invalid solid. Adjust the profile or path to avoid tight bends and intersections."
5265
+ );
5266
+ } finally {
5267
+ validation.delete();
5268
+ }
5269
+ return result;
5270
+ } catch (error) {
5271
+ result?.shape.delete();
5272
+ throw error;
5273
+ } finally {
5274
+ spine.delete();
5275
+ }
5276
+ }
5277
+ __name(sweepWithTopology, "sweepWithTopology");
5111
5278
  function loftWithTopology(sections, spine, ruled) {
5112
5279
  const holes = [];
5113
5280
  let outer;
@@ -5132,7 +5299,7 @@ function loftWithTopology(sections, spine, ruled) {
5132
5299
  throw new Error("Loft sections must have matching hole counts.");
5133
5300
  if (holes[0].length > 1)
5134
5301
  throw new Error(
5135
- "Loft currently supports at most one hole per section; multiple holes need explicit correspondence."
5302
+ "A swept or lofted profile currently supports at most one hole; multiple holes need explicit correspondence."
5136
5303
  );
5137
5304
  outer = loftContoursWithTopology(sections, spine, ruled);
5138
5305
  if (!holes[0].length) {
@@ -5190,7 +5357,8 @@ function loftContoursWithTopology(sections, spine, ruled, holes) {
5190
5357
  }
5191
5358
  result = castOwnedShape3D(builder.Shape());
5192
5359
  caps[0] = castOwnedShape(builder.FirstShape());
5193
- caps[sections.length - 1] = castOwnedShape(builder.LastShape());
5360
+ if (sections.length > 1)
5361
+ caps[sections.length - 1] = castOwnedShape(builder.LastShape());
5194
5362
  const topology = transferShapeTopology(
5195
5363
  sections,
5196
5364
  result,
@@ -6284,13 +6452,13 @@ __name(validVolume, "validVolume");
6284
6452
  import {
6285
6453
  getOC as getOC9,
6286
6454
  makeCircle,
6287
- makeLine,
6455
+ makeLine as makeLine2,
6288
6456
  makeThreePointArc
6289
6457
  } from "replicad";
6290
6458
  var position = /* @__PURE__ */ __name((p) => [p[0], 0, -p[1]], "position");
6291
6459
  function boundaryEdge(curve) {
6292
6460
  if (curve.kind === "line")
6293
- return makeLine(position(curve.points[0]), position(curve.points[1]));
6461
+ return makeLine2(position(curve.points[0]), position(curve.points[1]));
6294
6462
  if (curve.kind === "circle" || Math.abs(curve.sweep) === 2 * Math.PI)
6295
6463
  return makeCircle(curve.radius, position(curve.center), [
6296
6464
  0,
@@ -20541,6 +20709,18 @@ var ModelTopologyElement = class extends ModelAnchor {
20541
20709
  topologyCenter(geometry, this.#topology.selection)
20542
20710
  );
20543
20711
  }
20712
+ /** @code3d.inspect inspectLength */
20713
+ get length() {
20714
+ return measureFiniteGeometry(this, "length");
20715
+ }
20716
+ /** @code3d.inspect inspectArea */
20717
+ get area() {
20718
+ return measureFiniteGeometry(this, "area");
20719
+ }
20720
+ /** @code3d.inspect inspectVolume */
20721
+ get volume() {
20722
+ return measureFiniteGeometry(this, "volume");
20723
+ }
20544
20724
  get start() {
20545
20725
  return this.#curvePoint("start", 0);
20546
20726
  }
@@ -20991,6 +21171,26 @@ var referenceBounds = /* @__PURE__ */ Symbol("referenceBounds");
20991
21171
  var referenceBoundsParts = /* @__PURE__ */ Symbol("referenceBoundsParts");
20992
21172
  var modelSnapshotQueries = /* @__PURE__ */ Symbol("modelSnapshotQueries");
20993
21173
  var previewRelation = /* @__PURE__ */ Symbol("previewRelation");
21174
+ var modelData = /* @__PURE__ */ new WeakMap();
21175
+ function setModelData(model, key, value) {
21176
+ const object = requireModelObject(
21177
+ model,
21178
+ "Model data requires a model value."
21179
+ );
21180
+ modelData.set(
21181
+ object,
21182
+ new Map([...modelData.get(object) ?? [], [key, value]])
21183
+ );
21184
+ }
21185
+ __name(setModelData, "setModelData");
21186
+ function getModelData(model, key) {
21187
+ const object = requireModelObject(
21188
+ model,
21189
+ "Model data requires a model value."
21190
+ );
21191
+ return modelData.get(object)?.get(key);
21192
+ }
21193
+ __name(getModelData, "getModelData");
20994
21194
  var RelationObject = class _RelationObject {
20995
21195
  static {
20996
21196
  __name(this, "RelationObject");
@@ -21871,6 +22071,18 @@ var ModelObject = class _ModelObject extends RelationObject {
21871
22071
  static create(init) {
21872
22072
  return new _ModelObject(init);
21873
22073
  }
22074
+ /** @code3d.inspect inspectLength */
22075
+ get length() {
22076
+ return measureFiniteGeometry(this, "length");
22077
+ }
22078
+ /** @code3d.inspect inspectArea */
22079
+ get area() {
22080
+ return measureFiniteGeometry(this, "area");
22081
+ }
22082
+ /** @code3d.inspect inspectVolume */
22083
+ get volume() {
22084
+ return measureFiniteGeometry(this, "volume");
22085
+ }
21874
22086
  get origin() {
21875
22087
  return this.frame.origin;
21876
22088
  }
@@ -22318,6 +22530,134 @@ var ModelObject = class _ModelObject extends RelationObject {
22318
22530
  _ModelObject.recordExtrusions([this], [result]);
22319
22531
  return result;
22320
22532
  }
22533
+ revolve(axis, config = { angle: 360 }) {
22534
+ if (this.kind !== "face")
22535
+ throw new Error("revolve requires a single face model.");
22536
+ const { angle = 360, advance = 0 } = config;
22537
+ if (!Number.isFinite(angle) || angle === 0)
22538
+ throw new Error("Revolution angle must be finite and non-zero.");
22539
+ if (!Number.isFinite(advance))
22540
+ throw new Error("Revolution advance must be finite.");
22541
+ if (advance === 0 && Math.abs(angle) > 360)
22542
+ throw new Error("A revolution without advance cannot exceed one turn.");
22543
+ const axisReference = straightAxisReference(axis, "revolve() axis");
22544
+ const context = _ModelObject.createSolveContext([this, axisReference.model]);
22545
+ const facePose = this.solvePose(context);
22546
+ const axisFrame = relativeTransform(
22547
+ composeTransforms(
22548
+ axisReference.model.solvePose(context),
22549
+ axisReference.transform
22550
+ ),
22551
+ facePose
22552
+ );
22553
+ const direction = rotateVector(
22554
+ [0, axisReference.direction ?? 1, 0],
22555
+ axisFrame.quaternion
22556
+ );
22557
+ const source = this.requireGeometry();
22558
+ const axisModel = isModelObject(axisReference.model) ? axisReference.model : void 0;
22559
+ _ModelObject.recordCompositionInspection(context, []);
22560
+ const geometry = evaluateSolidGeometry(
22561
+ "revolve",
22562
+ [axisFrame.position, direction, angle, advance],
22563
+ [source],
22564
+ () => revolveWithTopology(
22565
+ {
22566
+ shape: source.value.shape,
22567
+ topology: source.value.topology,
22568
+ namespace: 1
22569
+ },
22570
+ axisFrame.position,
22571
+ direction,
22572
+ angle,
22573
+ advance
22574
+ )
22575
+ );
22576
+ const result = _ModelObject.create({
22577
+ kind: "solid",
22578
+ name: "Revolve",
22579
+ geometry,
22580
+ material: this.materialSnapshot,
22581
+ placements: this.placements,
22582
+ sourceRefs: [...this.sourceRefs, ...axisModel?.sourceRefs ?? []],
22583
+ parameters: uniqueParameters([
22584
+ ...this.allParameters(),
22585
+ ...axisModel?.allParameters() ?? []
22586
+ ]),
22587
+ meshTolerance: this.meshTolerance,
22588
+ operation: storedOperation("revolve", [
22589
+ { model: this, role: "receiver", index: 0 },
22590
+ ...axisModel ? [{ model: axisModel, role: "reference", index: 1 }] : []
22591
+ ])
22592
+ });
22593
+ _ModelObject.recordCompositionInspection(context, [[result, this]]);
22594
+ return result;
22595
+ }
22596
+ sweep(spine) {
22597
+ if (this.kind !== "face")
22598
+ throw new Error("sweep requires a single face model.");
22599
+ const path = requireModelKind(
22600
+ spine,
22601
+ "edge",
22602
+ "sweep requires an edge model as its spine."
22603
+ );
22604
+ const context = _ModelObject.createSolveContext([this, path]);
22605
+ const profilePose = this.solvePose(context);
22606
+ const pathTransform = relativeTransform(
22607
+ path.solvePose(context),
22608
+ profilePose
22609
+ );
22610
+ const source = this.requireGeometry();
22611
+ const pathGeometry = path.requireGeometry();
22612
+ const normal = rotateVector(
22613
+ [0, 1, 0],
22614
+ this.geometryAnchor.transform.quaternion
22615
+ );
22616
+ _ModelObject.recordCompositionInspection(context, []);
22617
+ const geometry = evaluateSolidGeometry(
22618
+ "sweep",
22619
+ [pathTransform.position, pathTransform.quaternion, normal],
22620
+ [source, pathGeometry],
22621
+ () => {
22622
+ const positionedPath = shapeWithTransform(
22623
+ pathGeometry.value.shape,
22624
+ pathTransform
22625
+ );
22626
+ try {
22627
+ return sweepWithTopology(
22628
+ {
22629
+ shape: source.value.shape,
22630
+ topology: source.value.topology,
22631
+ namespace: 1
22632
+ },
22633
+ positionedPath,
22634
+ normal
22635
+ );
22636
+ } finally {
22637
+ positionedPath.delete();
22638
+ }
22639
+ }
22640
+ );
22641
+ const result = _ModelObject.create({
22642
+ kind: "solid",
22643
+ name: "Sweep",
22644
+ geometry,
22645
+ material: this.materialSnapshot,
22646
+ placements: this.placements,
22647
+ sourceRefs: [...this.sourceRefs, ...path.sourceRefs],
22648
+ parameters: uniqueParameters([
22649
+ ...this.allParameters(),
22650
+ ...path.allParameters()
22651
+ ]),
22652
+ meshTolerance: Math.min(this.meshTolerance, path.meshTolerance),
22653
+ operation: storedOperation("sweep", [
22654
+ { model: this, role: "receiver", index: 0 },
22655
+ { model: path, role: "spine", index: 1 }
22656
+ ])
22657
+ });
22658
+ _ModelObject.recordCompositionInspection(context, [[result, this]]);
22659
+ return result;
22660
+ }
22321
22661
  cut(tools) {
22322
22662
  return cut(this, tools);
22323
22663
  }
@@ -23070,6 +23410,32 @@ var ModelObject = class _ModelObject extends RelationObject {
23070
23410
  target: target.map((value) => frame.positioned(value))
23071
23411
  };
23072
23412
  }
23413
+ /** @internal */
23414
+ static recordRevolve(profile, axis, result) {
23415
+ if (!isRecordingInspection()) return;
23416
+ const reference = straightAxisReference(axis, "revolve() axis");
23417
+ const context = this.createSolveContext([profile, reference.model]);
23418
+ this.recordCompositionInspection(
23419
+ context,
23420
+ result ? [[result, profile]] : []
23421
+ );
23422
+ }
23423
+ /** @internal */
23424
+ static inspectRevolve(profile, axis, result, data, focus) {
23425
+ const frame = this.inspectionFrame(data.poses);
23426
+ const shownProfile = frame.positioned(profile);
23427
+ const shownAxis = anchorAnnotation(frame.positioned(axis), {
23428
+ direction: "forward"
23429
+ });
23430
+ const shownResult = result ? frame.positioned(result) : void 0;
23431
+ return focus === "axis" ? {
23432
+ ambient: [shownProfile, ...shownResult ? [shownResult] : []],
23433
+ target: [shownAxis]
23434
+ } : {
23435
+ ambient: [shownAxis, ...shownResult ? [shownResult] : []],
23436
+ target: [shownProfile]
23437
+ };
23438
+ }
23073
23439
  /** @internal Derive the focused cut volume using the original solved operands. */
23074
23440
  static inspectCutTools(stock, tools, focused, data) {
23075
23441
  const selected = new Set(focused);
@@ -23452,7 +23818,7 @@ var ModelObject = class _ModelObject extends RelationObject {
23452
23818
  }
23453
23819
  }
23454
23820
  copy(overrides, operation) {
23455
- return _ModelObject.create({
23821
+ const result = _ModelObject.create({
23456
23822
  kind: this.kind,
23457
23823
  geometry: this.geometry,
23458
23824
  geometryAnchor: this.geometryAnchor,
@@ -23468,6 +23834,11 @@ var ModelObject = class _ModelObject extends RelationObject {
23468
23834
  operation,
23469
23835
  ...overrides
23470
23836
  });
23837
+ if (operation.kind === "relate" || operation.kind === "material") {
23838
+ const data = modelData.get(this);
23839
+ if (data) modelData.set(result, data);
23840
+ }
23841
+ return result;
23471
23842
  }
23472
23843
  };
23473
23844
  function circle(radius = 5) {
@@ -23542,7 +23913,7 @@ function line(startOrEnd, end) {
23542
23913
  "line",
23543
23914
  "Line",
23544
23915
  [start, end],
23545
- () => makeLine2(toPoint(start), toPoint(end))
23916
+ () => makeLine3(toPoint(start), toPoint(end))
23546
23917
  );
23547
23918
  }
23548
23919
  __name(line, "line");
@@ -23696,11 +24067,11 @@ function coil(coilRadius = 5, wireRadius = 1, pitch = 3, turns = 3) {
23696
24067
  [coilRadius, wireRadius, pitch, turns],
23697
24068
  [],
23698
24069
  () => {
23699
- const spine = makeHelix(pitch, y, coilRadius, [0, -y / 2, 0], [0, 1, 0]);
24070
+ const spine = makeHelix2(pitch, y, coilRadius, [0, -y / 2, 0], [0, 1, 0]);
23700
24071
  const start = spine.pointAt(0);
23701
24072
  const tangent2 = spine.tangentAt(0);
23702
24073
  const circle2 = makeCircle2(wireRadius, start, tangent2);
23703
- const section = assembleWire([circle2]);
24074
+ const section = assembleWire3([circle2]);
23704
24075
  try {
23705
24076
  return { shape: genericSweep(section, spine, { frenet: true }) };
23706
24077
  } finally {
@@ -23944,6 +24315,14 @@ __name(group, "group");
23944
24315
  group2.inspectChildren = inspectChildren;
23945
24316
  __name(inspectChildren, "inspectChildren");
23946
24317
  })(group || (group = {}));
24318
+ function inspectGroupMembers(children, inputs) {
24319
+ const result = ModelObject.inspectGroup(group(children));
24320
+ result.target?.forEach((member, index) => {
24321
+ retainInspectionIdentity(member, inputs[index]);
24322
+ });
24323
+ return result;
24324
+ }
24325
+ __name(inspectGroupMembers, "inspectGroupMembers");
23947
24326
  function distance2(a, b, axis) {
23948
24327
  return ModelObject.distance(a, b, axis);
23949
24328
  }
@@ -24070,6 +24449,75 @@ var relate;
24070
24449
  relate3.inspectBody = inspectBody;
24071
24450
  __name(inspectBody, "inspectBody");
24072
24451
  })(relate || (relate = {}));
24452
+ function measureFiniteGeometry(value, measure) {
24453
+ const topology = value instanceof ModelTopologyElement ? value[anchorReferenceValue].topology : void 0;
24454
+ const owner = value instanceof ModelObject ? value : value[anchorReferenceValue].model;
24455
+ const geometry = (topology?.source ?? value)[modelGeometry]().value;
24456
+ const scale3 = topology?.scale ?? 1;
24457
+ const position2 = /* @__PURE__ */ __name((point3) => topology ? topologyTransform(topology, translation(point3)).position : point3, "position");
24458
+ const read = /* @__PURE__ */ __name((shape) => {
24459
+ const properties = measure === "length" ? measureShapeLinearProperties2(shape) : measure === "area" ? measureShapeSurfaceProperties2(shape) : measureShapeVolumeProperties(shape);
24460
+ try {
24461
+ const magnitude = "length" in properties ? properties.length : "area" in properties ? properties.area : properties.volume;
24462
+ const power = measure === "length" ? 1 : measure === "area" ? 2 : 3;
24463
+ const result = magnitude * scale3 ** power;
24464
+ if (isRecordingInspection()) {
24465
+ const edge = shape;
24466
+ const edgePoint = /* @__PURE__ */ __name((parameter) => {
24467
+ const point3 = edge.pointAt(parameter);
24468
+ try {
24469
+ return position2(point3.toTuple());
24470
+ } finally {
24471
+ point3.delete();
24472
+ }
24473
+ }, "edgePoint");
24474
+ const placement = measure === "length" && edge.geomType === "LINE" ? { start: edgePoint(0), end: edgePoint(1) } : {
24475
+ at: measure === "length" ? edgePoint(0.5) : position2(properties.centerOfMass)
24476
+ };
24477
+ const target = value instanceof ModelObject ? value.kind === "edge" ? value.edges()[0] : value.kind === "face" ? value.surfaces()[0] : value : value;
24478
+ captureInspectData({ owner, target, placement });
24479
+ }
24480
+ return result;
24481
+ } finally {
24482
+ properties.delete();
24483
+ }
24484
+ }, "read");
24485
+ return topology ? withTopologyShape(
24486
+ geometry.shape,
24487
+ geometry.topology,
24488
+ topology.selection,
24489
+ read
24490
+ ) : read(geometry.shape);
24491
+ }
24492
+ __name(measureFiniteGeometry, "measureFiniteGeometry");
24493
+ function inspectLength(_args, context) {
24494
+ return inspectMeasurement(context, "length");
24495
+ }
24496
+ __name(inspectLength, "inspectLength");
24497
+ function inspectArea(_args, context) {
24498
+ return inspectMeasurement(context, "area");
24499
+ }
24500
+ __name(inspectArea, "inspectArea");
24501
+ function inspectVolume(_args, context) {
24502
+ return inspectMeasurement(context, "volume");
24503
+ }
24504
+ __name(inspectVolume, "inspectVolume");
24505
+ function inspectMeasurement(context, kind) {
24506
+ if (context.return === void 0 || !context.data) return;
24507
+ const { owner, target, placement } = context.data;
24508
+ return {
24509
+ target: [
24510
+ target,
24511
+ dimension({
24512
+ owner,
24513
+ value: context.return,
24514
+ ...placement,
24515
+ axisLabel: kind === "length" ? "at" in placement ? "arc length" : void 0 : kind
24516
+ })
24517
+ ]
24518
+ };
24519
+ }
24520
+ __name(inspectMeasurement, "inspectMeasurement");
24073
24521
  function inspectTopologyReference(_args, context) {
24074
24522
  if (context.return !== void 0 && (!Array.isArray(context.return) || context.return.length > 0))
24075
24523
  return void 0;
@@ -24128,6 +24576,33 @@ function extrude(face, distance4 = 10) {
24128
24576
  }
24129
24577
  }
24130
24578
  __name(extrude, "extrude");
24579
+ function revolve(profile, axis, config = { angle: 360 }) {
24580
+ const runtimeProfile = requireModelKind(
24581
+ profile,
24582
+ "face",
24583
+ "revolve requires a face model."
24584
+ );
24585
+ let result;
24586
+ try {
24587
+ result = runtimeProfile.revolve(axis, config);
24588
+ return result;
24589
+ } finally {
24590
+ ModelObject.recordRevolve(
24591
+ runtimeProfile,
24592
+ axis,
24593
+ result
24594
+ );
24595
+ }
24596
+ }
24597
+ __name(revolve, "revolve");
24598
+ function sweep(profile, spine) {
24599
+ return requireModelKind(
24600
+ profile,
24601
+ "face",
24602
+ "sweep requires a face model."
24603
+ ).sweep(spine);
24604
+ }
24605
+ __name(sweep, "sweep");
24131
24606
  function text(content, font2, size, options) {
24132
24607
  return textGlyphs(content, font2, size, options).flatMap(
24133
24608
  ({ regions, x, y }) => regions.value.map((region, index) => {
@@ -24234,7 +24709,7 @@ function withDistanceShape(part, visit) {
24234
24709
  return withTransformedGeometry(part.geometry.value, part, visit);
24235
24710
  const points = part.points;
24236
24711
  if (points.length <= 2) {
24237
- const shape = points.length === 1 ? makeVertex(toPoint(points[0])) : makeLine2(toPoint(points[0]), toPoint(points[1]));
24712
+ const shape = points.length === 1 ? makeVertex(toPoint(points[0])) : makeLine3(toPoint(points[0]), toPoint(points[1]));
24238
24713
  try {
24239
24714
  return visit(shape);
24240
24715
  } finally {
@@ -24247,10 +24722,10 @@ function withDistanceShape(part, visit) {
24247
24722
  try {
24248
24723
  points.forEach(
24249
24724
  (point3, index) => edges.push(
24250
- makeLine2(toPoint(point3), toPoint(points[(index + 1) % points.length]))
24725
+ makeLine3(toPoint(point3), toPoint(points[(index + 1) % points.length]))
24251
24726
  )
24252
24727
  );
24253
- wire = assembleWire(edges);
24728
+ wire = assembleWire3(edges);
24254
24729
  face = makeFace(wire);
24255
24730
  return visit(face);
24256
24731
  } finally {
@@ -24523,6 +24998,8 @@ var authoringApi = Object.freeze({
24523
24998
  bezier,
24524
24999
  spline,
24525
25000
  loft,
25001
+ revolve,
25002
+ sweep,
24526
25003
  box,
24527
25004
  cylinder,
24528
25005
  tube,
@@ -24837,7 +25314,7 @@ function buildLoftGeometry(sections, spine, ruled) {
24837
25314
  spine.transform
24838
25315
  );
24839
25316
  try {
24840
- spineWire = assembleWire([edge]);
25317
+ spineWire = assembleWire3([edge]);
24841
25318
  } finally {
24842
25319
  edge.delete();
24843
25320
  }
@@ -25297,6 +25774,84 @@ __name(requireModelKind, "requireModelKind");
25297
25774
  extrude2.inspectMethod = inspectMethod;
25298
25775
  __name(inspectMethod, "inspectMethod");
25299
25776
  })(extrude || (extrude = {}));
25777
+ ((revolve2) => {
25778
+ function inspectProfile([profile, axis], context) {
25779
+ return context.data && ModelObject.inspectRevolve(
25780
+ profile,
25781
+ axis,
25782
+ context.return,
25783
+ context.data,
25784
+ "profile"
25785
+ );
25786
+ }
25787
+ revolve2.inspectProfile = inspectProfile;
25788
+ __name(inspectProfile, "inspectProfile");
25789
+ function inspectAxis([profile, axis], context) {
25790
+ return context.data && ModelObject.inspectRevolve(
25791
+ profile,
25792
+ axis,
25793
+ context.return,
25794
+ context.data,
25795
+ "axis"
25796
+ );
25797
+ }
25798
+ revolve2.inspectAxis = inspectAxis;
25799
+ __name(inspectAxis, "inspectAxis");
25800
+ function inspectMethodProfile([axis], context) {
25801
+ return context.data && ModelObject.inspectRevolve(
25802
+ context.receiver,
25803
+ axis,
25804
+ context.return,
25805
+ context.data,
25806
+ "profile"
25807
+ );
25808
+ }
25809
+ revolve2.inspectMethodProfile = inspectMethodProfile;
25810
+ __name(inspectMethodProfile, "inspectMethodProfile");
25811
+ function inspectMethodAxis([axis], context) {
25812
+ return context.data && ModelObject.inspectRevolve(
25813
+ context.receiver,
25814
+ axis,
25815
+ context.return,
25816
+ context.data,
25817
+ "axis"
25818
+ );
25819
+ }
25820
+ revolve2.inspectMethodAxis = inspectMethodAxis;
25821
+ __name(inspectMethodAxis, "inspectMethodAxis");
25822
+ })(revolve || (revolve = {}));
25823
+ ((sweep2) => {
25824
+ function inspectProfile([profile, spine], context) {
25825
+ if (!context.data) return void 0;
25826
+ return ModelObject.inspectComposition(
25827
+ context.data,
25828
+ [spine, ...context.return ? [context.return] : []],
25829
+ [profile]
25830
+ );
25831
+ }
25832
+ sweep2.inspectProfile = inspectProfile;
25833
+ __name(inspectProfile, "inspectProfile");
25834
+ function inspectSpine([profile, spine], context) {
25835
+ if (!context.data) return void 0;
25836
+ return ModelObject.inspectComposition(
25837
+ context.data,
25838
+ [profile, ...context.return ? [context.return] : []],
25839
+ [spine]
25840
+ );
25841
+ }
25842
+ sweep2.inspectSpine = inspectSpine;
25843
+ __name(inspectSpine, "inspectSpine");
25844
+ function inspectMethodProfile([spine], context) {
25845
+ return inspectProfile([context.receiver, spine], context);
25846
+ }
25847
+ sweep2.inspectMethodProfile = inspectMethodProfile;
25848
+ __name(inspectMethodProfile, "inspectMethodProfile");
25849
+ function inspectMethodSpine([spine], context) {
25850
+ return inspectSpine([context.receiver, spine], context);
25851
+ }
25852
+ sweep2.inspectMethodSpine = inspectMethodSpine;
25853
+ __name(inspectMethodSpine, "inspectMethodSpine");
25854
+ })(sweep || (sweep = {}));
25300
25855
  ((union2) => {
25301
25856
  function inspectOperands([operands], context) {
25302
25857
  if (!context.data) return void 0;
@@ -26323,19 +26878,19 @@ function contourContains(curves, point3) {
26323
26878
  continue;
26324
26879
  }
26325
26880
  const start = curve.kind === "circle" ? 0 : curve.start;
26326
- const sweep = curve.kind === "circle" ? tau2 : curve.sweep;
26881
+ const sweep2 = curve.kind === "circle" ? tau2 : curve.sweep;
26327
26882
  const cuts = [
26328
26883
  0,
26329
26884
  1,
26330
26885
  ...[Math.PI / 2, 3 * Math.PI / 2].map(
26331
- (a) => sketchPositiveAngle(Math.sign(sweep) * (a - start)) / Math.abs(sweep)
26886
+ (a) => sketchPositiveAngle(Math.sign(sweep2) * (a - start)) / Math.abs(sweep2)
26332
26887
  ).filter((t) => t > 0 && t < 1)
26333
26888
  ].sort((a, b) => a - b);
26334
26889
  for (let i = 1; i < cuts.length; i++) {
26335
26890
  const a = sketchCurvePosition(curve, cuts[i - 1]), b = sketchCurvePosition(curve, cuts[i]);
26336
26891
  if (a[1] > point3[1] === b[1] > point3[1]) continue;
26337
26892
  const dy = point3[1] - curve.center[1];
26338
- const x = curve.center[0] + Math.sign(Math.cos(start + sweep * (cuts[i - 1] + cuts[i]) / 2)) * Math.sqrt(Math.max(0, (curve.radius - dy) * (curve.radius + dy)));
26893
+ const x = curve.center[0] + Math.sign(Math.cos(start + sweep2 * (cuts[i - 1] + cuts[i]) / 2)) * Math.sqrt(Math.max(0, (curve.radius - dy) * (curve.radius + dy)));
26339
26894
  if (x > point3[0]) crossings++;
26340
26895
  }
26341
26896
  }
@@ -26422,6 +26977,8 @@ export {
26422
26977
  pivotPoint,
26423
26978
  axisEdge,
26424
26979
  axisLine,
26980
+ setModelData,
26981
+ getModelData,
26425
26982
  circle,
26426
26983
  ellipse,
26427
26984
  rectangle,
@@ -26441,14 +26998,20 @@ export {
26441
26998
  regularPrism,
26442
26999
  primitiveConstructor,
26443
27000
  group,
27001
+ inspectGroupMembers,
26444
27002
  distance2 as distance,
26445
27003
  relate,
27004
+ inspectLength,
27005
+ inspectArea,
27006
+ inspectVolume,
26446
27007
  inspectTopologyReference,
26447
27008
  expose,
26448
27009
  on,
26449
27010
  align,
26450
27011
  union,
26451
27012
  extrude,
27013
+ revolve,
27014
+ sweep,
26452
27015
  text,
26453
27016
  cut,
26454
27017
  intersect,
@@ -26471,4 +27034,4 @@ export {
26471
27034
  retainModelGeometry,
26472
27035
  authoringApi
26473
27036
  };
26474
- //# sourceMappingURL=chunk-JBVIAMJ6.js.map
27037
+ //# sourceMappingURL=chunk-VINZNODV.js.map