@code3d/core 0.0.1-alpha.12 → 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.
package/README.md CHANGED
@@ -4,62 +4,71 @@ The TypeScript modeling runtime used by Code3D. Compose solids, profiles, curves
4
4
  points, and editable sketches; inspect their geometry and reuse the same models
5
5
  in the App or a supported Node.js runtime.
6
6
 
7
- Model constructors define the initial origin; derived operations inherit their main
8
- input frame. `group`, `union`, and `intersect` use the first member or operand,
9
- `cut` uses the stock, `loft` uses the first section, and `revolve` and `sweep`
10
- use the profile. See the
11
- [default origin rules](docs/local-coordinates.md#default-origin-rules)
12
- for all constructors and explicit origin operations.
13
-
14
- ## Start with a model
7
+ ## Installation
15
8
 
16
9
  ```sh
17
10
  npm install @code3d/core
18
11
  ```
19
12
 
13
+ The App includes Core in its built-in modeling runtime. If a project declares
14
+ its own `@code3d/core`, the App uses that project's installed packages
15
+ and declarations instead. See [project package installation](../web/src/content/docs/docs/getting-started/files.md#install-packages-in-browser-storage).
16
+
17
+ ## Example
18
+
19
+ Place a part on a base, offset it, and rotate it around a chosen pivot.
20
+
20
21
  ```ts
21
- import {box, cylinder, group} from '@code3d/core';
22
+ import {box, group, offset, pivot} from '@code3d/core';
22
23
 
23
- const base = box(40, 4, 24).fillet(1);
24
- const post = cylinder(3, 18).relate(self => self.on(base.up));
24
+ const base = box(40, 8, 30);
25
+ const part = box(14, 20, 12).relate(self => [
26
+ self.on(base.up), // Touch the base.
27
+ offset(6, 0, 0),
28
+ pivot([0, -10, 0]).rotate(0, 0, 25),
29
+ ]);
25
30
 
26
- export default group([base, post]);
31
+ export default group([base, part]);
27
32
  ```
28
33
 
29
- Open this source in Code3D and select an expression to inspect its value. Node
30
- loads the modeling kernel through the package's Node entry automatically; normal
31
- model authors do not initialize it or manage evaluation caches themselves.
32
-
33
- The App includes Core, [Materials](../materials/README.md), and
34
- [Screws](../screws/README.md) for zero-install projects. When the active model's
35
- package scope or an ancestor `package.json` declares `@code3d/core`, the App uses that project's installed
36
- packages and declarations exclusively. Missing dependencies are errors. See
37
- [project package installation](../web/src/content/docs/docs/getting-started/files.md#install-packages-in-browser-storage)
38
- and the [agent file workflow](../../docs/agents/files.md).
39
-
40
- ## Find the modeling API
41
-
42
- | Task | Start here |
43
- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
44
- | Solids, profiles, curves, Boolean operations, extrusion, revolution, sweep and loft | [Modeling reference](docs/api.md) |
45
- | Place parts with bounds, align geometry or match coordinate frames | [Relations](docs/relations.mdx) |
46
- | Change origins and rotate parts | [Origins and rotation](docs/origins-and-rotation.mdx) |
47
- | Hollow a solid or choose openings | [Shells](docs/shells.mdx) |
48
- | Select vertices, edges and surfaces, or expose named elements | [Topology](docs/topology.md) |
49
- | Build reusable model functions | [Reusable models](../web/src/content/docs/docs/guides/reusable-models.mdx) |
50
- | Give functions editing tools and example arguments | [Model tools](../web/src/content/docs/docs/guides/model-tools.mdx) |
51
- | Customize parameter and call inspection | [Source inspection](docs/runtime.md#source-inspection) |
52
- | Extend the runtime with Replicad geometry | [Custom primitives](docs/custom-primitives.mdx) |
53
- | Known boundaries | [Current limitations](../web/src/content/docs/docs/getting-started/limitations.md) |
54
-
55
- Read finite edge `.length`, face or solid `.area`, and solid `.volume` as ordinary
56
- numbers; select the property in App to inspect the measurement. See
57
- [length and area](docs/api.md#length-and-area) and [volume](docs/api.md#volume).
58
-
59
- See also [model values and measurements](docs/values.md), [editable sketches](docs/sketches.md),
60
- [text and fonts](docs/text.md), and [runtime integration](docs/runtime.md).
34
+ ![The relation example in the App, with a rotation gizmo on the tilted part and its rotation parameter panel open.](../web/src/assets/models/core-relate-tools.png)
35
+
36
+ The part is rotated 25° around Z. In the App, select `rotate(0, 0, 25)` to show
37
+ the rotation gizmo and parameter panel. Drag a ring or edit an angle to update
38
+ the code.
39
+
40
+ Complete example: [part placement and rotation](../app/examples/constraints/relate.ts).
41
+
42
+ ## Usage notes
43
+
44
+ - Dimensions are in millimetres and angles are in degrees.
45
+ - Models have local coordinate frames. Constructors choose the initial origin;
46
+ derived operations inherit their main input frame. See [local coordinates](docs/local-coordinates.md).
47
+ - Modeling operations return new values. Measurements such as `.length`, `.area`
48
+ and `.volume` return numbers; select an expression in the App to inspect it.
49
+ - Node loads the modeling kernel automatically. Model authors do not initialize
50
+ it or manage evaluation caches. See [runtime integration](docs/runtime.md).
51
+
52
+ ## Documentation
53
+
54
+ - [Modeling API](docs/api.md): primitives, operations, materials and measurements.
55
+ - [Model values](docs/values.md): immutable values and geometry measurements.
56
+ - [Local coordinates](docs/local-coordinates.md): frames, origins and placement conventions.
57
+ - [Relations](docs/relations.mdx): position parts using bounds, geometry and frames.
58
+ - [Origins and rotation](docs/origins-and-rotation.mdx): choose a pivot and adjust a part.
59
+ - [Shells](docs/shells.mdx): hollow solids and choose openings.
60
+ - [Topology](docs/topology.md): select vertices, edges and faces and expose named elements.
61
+ - [Editable sketches](docs/sketches.md): draw and constrain planar geometry.
62
+ - [Text and fonts](docs/text.md): build geometry from text.
63
+ - [Reusable models](../web/src/content/docs/docs/guides/reusable-models.mdx): compose model functions.
64
+ - [Model tools](../web/src/content/docs/docs/guides/model-tools.mdx): add editing tools and argument presets.
65
+ - [Custom primitives](docs/custom-primitives.mdx): extend modeling with Replicad geometry.
66
+ - [Runtime integration](docs/runtime.md): resources, materials and source inspection.
67
+ - [Current limitations](../web/src/content/docs/docs/getting-started/limitations.md): supported workflows and known boundaries.
61
68
 
62
69
  ## Source and development
63
70
 
64
- Start with the [public API](src/library/index.ts), [runtime tests](test/), and
65
- [development and integration notes](docs/runtime.md#source-and-development).
71
+ - [Public API](src/library/index.ts): exported constructors and model interfaces.
72
+ - [Runtime tests](test/): geometry, value semantics and integration coverage.
73
+ - [Runtime development](docs/runtime.md#source-and-development): kernel integration and resource ownership.
74
+ - [Development guide](../../.agents/docs/development.md): repository setup and test commands.
@@ -2,7 +2,7 @@ import {
2
2
  __name,
3
3
  castOwnedShape,
4
4
  primitiveConstructor
5
- } from "./chunk-CQKOD54C.js";
5
+ } from "./chunk-VINZNODV.js";
6
6
 
7
7
  // packages/core/src/library/replicad.ts
8
8
  import * as replicadModule from "replicad";
@@ -27,4 +27,4 @@ export {
27
27
  replicad,
28
28
  definePrimitive
29
29
  };
30
- //# sourceMappingURL=chunk-L4V6X7RH.js.map
30
+ //# sourceMappingURL=chunk-776Q5P2L.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  installOpenCascade
3
- } from "./chunk-JF6QRICU.js";
3
+ } from "./chunk-VFPWXSFD.js";
4
4
  import {
5
5
  __name,
6
6
  installFontEngine,
7
7
  installModelResourceReader,
8
8
  installSketchSolver
9
- } from "./chunk-CQKOD54C.js";
9
+ } from "./chunk-VINZNODV.js";
10
10
 
11
11
  // packages/core/src/node/index.ts
12
12
  import initOpenCascade from "@code3d/opencascade";
@@ -28,4 +28,4 @@ installSketchSolver(
28
28
  ), "locateFile")
29
29
  })
30
30
  );
31
- //# sourceMappingURL=chunk-QJVTVAYM.js.map
31
+ //# sourceMappingURL=chunk-N7JJWNVL.js.map
@@ -2,7 +2,7 @@ import {
2
2
  __name,
3
3
  clearKernelOperationCache,
4
4
  setKernelNativeMemoryCounter
5
- } from "./chunk-CQKOD54C.js";
5
+ } from "./chunk-VINZNODV.js";
6
6
 
7
7
  // packages/core/src/library/open-cascade.ts
8
8
  import { setOC } from "replicad";
@@ -16,4 +16,4 @@ __name(installOpenCascade, "installOpenCascade");
16
16
  export {
17
17
  installOpenCascade
18
18
  };
19
- //# sourceMappingURL=chunk-JF6QRICU.js.map
19
+ //# sourceMappingURL=chunk-VFPWXSFD.js.map
@@ -21171,6 +21171,26 @@ var referenceBounds = /* @__PURE__ */ Symbol("referenceBounds");
21171
21171
  var referenceBoundsParts = /* @__PURE__ */ Symbol("referenceBoundsParts");
21172
21172
  var modelSnapshotQueries = /* @__PURE__ */ Symbol("modelSnapshotQueries");
21173
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");
21174
21194
  var RelationObject = class _RelationObject {
21175
21195
  static {
21176
21196
  __name(this, "RelationObject");
@@ -23798,7 +23818,7 @@ var ModelObject = class _ModelObject extends RelationObject {
23798
23818
  }
23799
23819
  }
23800
23820
  copy(overrides, operation) {
23801
- return _ModelObject.create({
23821
+ const result = _ModelObject.create({
23802
23822
  kind: this.kind,
23803
23823
  geometry: this.geometry,
23804
23824
  geometryAnchor: this.geometryAnchor,
@@ -23814,6 +23834,11 @@ var ModelObject = class _ModelObject extends RelationObject {
23814
23834
  operation,
23815
23835
  ...overrides
23816
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;
23817
23842
  }
23818
23843
  };
23819
23844
  function circle(radius = 5) {
@@ -24290,6 +24315,14 @@ __name(group, "group");
24290
24315
  group2.inspectChildren = inspectChildren;
24291
24316
  __name(inspectChildren, "inspectChildren");
24292
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");
24293
24326
  function distance2(a, b, axis) {
24294
24327
  return ModelObject.distance(a, b, axis);
24295
24328
  }
@@ -26944,6 +26977,8 @@ export {
26944
26977
  pivotPoint,
26945
26978
  axisEdge,
26946
26979
  axisLine,
26980
+ setModelData,
26981
+ getModelData,
26947
26982
  circle,
26948
26983
  ellipse,
26949
26984
  rectangle,
@@ -26963,6 +26998,7 @@ export {
26963
26998
  regularPrism,
26964
26999
  primitiveConstructor,
26965
27000
  group,
27001
+ inspectGroupMembers,
26966
27002
  distance2 as distance,
26967
27003
  relate,
26968
27004
  inspectLength,
@@ -26998,4 +27034,4 @@ export {
26998
27034
  retainModelGeometry,
26999
27035
  authoringApi
27000
27036
  };
27001
- //# sourceMappingURL=chunk-CQKOD54C.js.map
27037
+ //# sourceMappingURL=chunk-VINZNODV.js.map