@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 +55 -46
- package/bld/chunks/{chunk-L4V6X7RH.js → chunk-776Q5P2L.js} +2 -2
- package/bld/chunks/{chunk-QJVTVAYM.js → chunk-N7JJWNVL.js} +3 -3
- package/bld/chunks/{chunk-JF6QRICU.js → chunk-VFPWXSFD.js} +2 -2
- package/bld/chunks/{chunk-CQKOD54C.js → chunk-VINZNODV.js} +38 -2
- package/bld/chunks/chunk-VINZNODV.js.map +7 -0
- package/bld/library/index.d.ts +1 -1
- package/bld/library/index.d.ts.map +1 -1
- package/bld/library/index.js +7 -1
- package/bld/library/replicad.js +2 -2
- package/bld/library/runtime.d.ts +7 -1
- package/bld/library/runtime.d.ts.map +1 -1
- package/bld/node/index.js +9 -3
- package/bld/node/replicad.js +4 -4
- package/bld/tooling/index.js +2 -2
- package/docs/api.md +9 -0
- package/docs/runtime.md +10 -0
- package/docs/values.md +25 -31
- package/package.json +1 -1
- package/src/library/index.ts +3 -0
- package/src/library/runtime.ts +47 -1
- package/bld/chunks/chunk-CQKOD54C.js.map +0 -7
- /package/bld/chunks/{chunk-L4V6X7RH.js.map → chunk-776Q5P2L.js.map} +0 -0
- /package/bld/chunks/{chunk-QJVTVAYM.js.map → chunk-N7JJWNVL.js.map} +0 -0
- /package/bld/chunks/{chunk-JF6QRICU.js.map → chunk-VFPWXSFD.js.map} +0 -0
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
|
-
|
|
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,
|
|
22
|
+
import {box, group, offset, pivot} from '@code3d/core';
|
|
22
23
|
|
|
23
|
-
const base = box(40,
|
|
24
|
-
const
|
|
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,
|
|
31
|
+
export default group([base, part]);
|
|
27
32
|
```
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
[
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
[
|
|
34
|
+

|
|
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
|
-
|
|
65
|
-
[
|
|
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-
|
|
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-
|
|
30
|
+
//# sourceMappingURL=chunk-776Q5P2L.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
installOpenCascade
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VFPWXSFD.js";
|
|
4
4
|
import {
|
|
5
5
|
__name,
|
|
6
6
|
installFontEngine,
|
|
7
7
|
installModelResourceReader,
|
|
8
8
|
installSketchSolver
|
|
9
|
-
} from "./chunk-
|
|
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-
|
|
31
|
+
//# sourceMappingURL=chunk-N7JJWNVL.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
__name,
|
|
3
3
|
clearKernelOperationCache,
|
|
4
4
|
setKernelNativeMemoryCounter
|
|
5
|
-
} from "./chunk-
|
|
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-
|
|
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
|
-
|
|
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-
|
|
27037
|
+
//# sourceMappingURL=chunk-VINZNODV.js.map
|