@code3d/core 0.0.1-alpha.6 → 0.0.1-alpha.8

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 (37) hide show
  1. package/README.md +53 -3
  2. package/bld/chunks/{chunk-3RIMOCPP.js → chunk-EWPRWRLV.js} +2 -2
  3. package/bld/chunks/{chunk-T6COR2SG.js → chunk-HSU2FH3L.js} +3 -3
  4. package/bld/chunks/{chunk-T3RAUNSF.js → chunk-MICNLFBF.js} +452 -107
  5. package/bld/chunks/chunk-MICNLFBF.js.map +7 -0
  6. package/bld/chunks/{chunk-KYW4AWKO.js → chunk-OAVABPL5.js} +2 -2
  7. package/bld/library/cached.d.ts +5 -3
  8. package/bld/library/cached.d.ts.map +1 -1
  9. package/bld/library/index.d.ts +4 -4
  10. package/bld/library/index.d.ts.map +1 -1
  11. package/bld/library/index.js +5 -3
  12. package/bld/library/kernel-cache.d.ts +5 -3
  13. package/bld/library/kernel-cache.d.ts.map +1 -1
  14. package/bld/library/loft.d.ts.map +1 -1
  15. package/bld/library/replicad.js +2 -2
  16. package/bld/library/runtime.d.ts +61 -6
  17. package/bld/library/runtime.d.ts.map +1 -1
  18. package/bld/library/topology.d.ts +4 -2
  19. package/bld/library/topology.d.ts.map +1 -1
  20. package/bld/node/index.js +7 -5
  21. package/bld/node/replicad.js +4 -4
  22. package/bld/tooling/index.d.ts +2 -2
  23. package/bld/tooling/index.d.ts.map +1 -1
  24. package/bld/tooling/index.js +4 -2
  25. package/package.json +1 -1
  26. package/src/library/cached.ts +29 -8
  27. package/src/library/index.ts +5 -2
  28. package/src/library/kernel-cache.ts +29 -5
  29. package/src/library/loft.ts +5 -1
  30. package/src/library/runtime.ts +508 -43
  31. package/src/library/shell.ts +3 -3
  32. package/src/library/topology.ts +24 -15
  33. package/src/tooling/index.ts +2 -0
  34. package/bld/chunks/chunk-T3RAUNSF.js.map +0 -7
  35. /package/bld/chunks/{chunk-3RIMOCPP.js.map → chunk-EWPRWRLV.js.map} +0 -0
  36. /package/bld/chunks/{chunk-T6COR2SG.js.map → chunk-HSU2FH3L.js.map} +0 -0
  37. /package/bld/chunks/{chunk-KYW4AWKO.js.map → chunk-OAVABPL5.js.map} +0 -0
package/README.md CHANGED
@@ -75,6 +75,19 @@ Build readable models from named intermediate values and public operations. A
75
75
  profile followed by extrusion, or solids combined with Boolean operations,
76
76
  keeps the construction understandable and editable by both people and agents.
77
77
 
78
+ ## Measure geometry for another part
79
+
80
+ `distance(a, b, axis?)` measures models, finite topology, bounds or point anchors
81
+ in their solved placement and returns a normal non-negative number. Omit the axis
82
+ for shortest geometric distance; supply `x`, `y`, `z`, a direction vector or a
83
+ straight edge/axis reference for the gap between projected intervals. Overlap
84
+ returns zero. Existing relations are resolved on demand, before any group is
85
+ needed; subsequent relations do not update the number.
86
+
87
+ See the [measurement reference](../web/src/content/docs/docs/reference/core.md#measurements)
88
+ and the [fitted beam example](../app/examples/operations/distance.ts). They cover
89
+ finite geometry, nested occurrences, axis frames and source-order dependencies.
90
+
78
91
  ## Find the modeling API
79
92
 
80
93
  | Task | Start here |
@@ -114,7 +127,9 @@ including in mixed `Model[]` collections. Nesting preserves each group's hierarc
114
127
  `expose()` adds named references when callers need to address members.
115
128
 
116
129
  A topology ID belongs to its owning model and element kind. It is a number or a
117
- flat numeric path, such as `.edge([1, 3])`. Operations track unambiguous ancestry;
130
+ flat numeric path, such as `.edge([1, 3])`. Local edits (`fillet`, `chamfer`, `shell`)
131
+ preserve one-to-one IDs and allocate fresh IDs for new elements without reusing
132
+ retired numbers. Loft, extrusion and Booleans prefix inherited IDs by input;
118
133
  transforms preserve complete paths. Inspect the result after topology changes
119
134
  instead of assuming IDs from a different model still apply.
120
135
 
@@ -194,10 +209,19 @@ Try [mounting-plate.ts](../app/examples/sketches/mounting-plate.ts).
194
209
 
195
210
  ## Cached computations and custom primitives
196
211
 
197
- `cached(fn, options?)` memoizes synchronous, deterministic data computations.
212
+ `cache(fn)` memoizes synchronous, deterministic data computations;
213
+ `cache(fn, args)` immediately returns the cached result for an argument tuple.
214
+ Both forms share the same function identity and argument keys. Supply custom
215
+ codecs in the third argument: `cache(fn, undefined, options)` for a function or
216
+ `cache(fn, args, options)` for a value.
198
217
  Pass changing captured state as arguments and treat returned data as immutable.
199
218
  Memory hits reuse the retained result; optional `encoder` / `decoder` pairs only
200
- run when saving to disk or restoring it. The App fingerprints static definitions
219
+ run when saving to disk or restoring it. Newly computed entries are eligible
220
+ for disk storage when computation reaches the configured threshold (1 ms by
221
+ default). Faster results remain in memory and are not encoded or written on later
222
+ memory hits. Change the threshold in **Settings → Cache** in the App; it applies
223
+ to new computations and preserves existing cache entries. Existing
224
+ disk records can still be restored. The App fingerprints static definitions
201
225
  and their dependencies for persistent reuse; dynamic closures and ordinary Node
202
226
  calls use function identity for memory reuse. No author cache IDs are needed.
203
227
 
@@ -287,3 +311,29 @@ npm test --workspace @code3d/core
287
311
 
288
312
  Use the [agent entry](../../docs/agents.md) to work on a project through the CLI,
289
313
  or the [App README](../app/README.md) to develop the editor and visualization.
314
+
315
+ ## Geometry measurements
316
+
317
+ `model.bounds(relativeTo?)` returns readonly `minimum`, `maximum` and `size`
318
+ XYZ vectors for tight finite geometry bounds. By default it uses the model's
319
+ own local frame. An explicit reference includes solved placement and nested
320
+ member occurrences in that reference's frame. Empty groups have no finite
321
+ bounds; a source occurring more than once in the reference is ambiguous.
322
+
323
+ `model.position(relativeTo)` returns the model origin in the explicit reference's
324
+ local frame. A model's origin in its own frame is always `[0, 0, 0]`, including
325
+ point models whose geometry may be offset from that origin. Neither query
326
+ changes the model or its placement. These methods are available on every model
327
+ kind, including groups. As model members, `bounds` and `position` are reserved
328
+ names and cannot be used as exposed element names.
329
+
330
+ ```ts
331
+ import {box, group, offset} from '@code3d/core';
332
+
333
+ const base = box(20, 4, 20);
334
+ const part = box(8, 12, 4).relate(self => [self.on(base.up), offset(20, 0, 0)]);
335
+ const size = part.bounds().size; // [8, 12, 4]
336
+ const origin = part.position(base); // [20, 8, 0]
337
+ const minimum = part.bounds(base).minimum; // [16, 2, -2]
338
+ export default group([base, part]);
339
+ ```
@@ -2,7 +2,7 @@ import {
2
2
  __name,
3
3
  clearKernelOperationCache,
4
4
  setKernelNativeMemoryCounter
5
- } from "./chunk-T3RAUNSF.js";
5
+ } from "./chunk-MICNLFBF.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-3RIMOCPP.js.map
19
+ //# sourceMappingURL=chunk-EWPRWRLV.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  installOpenCascade
3
- } from "./chunk-3RIMOCPP.js";
3
+ } from "./chunk-EWPRWRLV.js";
4
4
  import {
5
5
  __name,
6
6
  installFontEngine,
7
7
  installModelResourceReader,
8
8
  installSketchSolver
9
- } from "./chunk-T3RAUNSF.js";
9
+ } from "./chunk-MICNLFBF.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-T6COR2SG.js.map
31
+ //# sourceMappingURL=chunk-HSU2FH3L.js.map