@xort/cga 0.1.2 → 0.1.4
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/THIRD_PARTY_NOTICES.md +23 -2
- package/build/@xort_cga.js +1509 -3388
- package/build/cga.d.ts +79 -15
- package/build/cga.esm.js +1509 -3389
- package/dist/THIRD_PARTY_NOTICES.md +23 -2
- package/dist/index.cjs +1509 -3388
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -15
- package/dist/index.d.ts +79 -15
- package/dist/index.js +1509 -3389
- package/dist/index.js.map +1 -1
- package/dist/three.cjs +209 -1962
- package/dist/three.cjs.map +1 -1
- package/dist/three.d.cts +74 -9
- package/dist/three.d.ts +74 -9
- package/dist/three.js +209 -1962
- package/dist/three.js.map +1 -1
- package/package.json +21 -18
- package/readme.md +189 -64
- package/readme.zh-CN.md +241 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xort/cga",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "TypeScript computational geometry for Web3D editors. Unified queries, mesh tools, and zero runtime dependencies.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -18,13 +18,19 @@
|
|
|
18
18
|
"format:check": "node scripts/format.mjs",
|
|
19
19
|
"prepublishOnly": "npm run release:check -- --complete && npm run verify",
|
|
20
20
|
"release:check": "node scripts/release-check.mjs",
|
|
21
|
-
"verify": "npm run release:check && npm run source:check && npm run typecheck && npm run docs:typecheck && npm run format:check && npm test && npm run demos:check && npm run docs:build && npm run build:demo && npm run browser:check && npm audit && npm pack --dry-run && npm run package:check",
|
|
21
|
+
"verify": "npm run release:check && npm run source:check && npm run algorithms:check && npm run typecheck && npm run docs:typecheck && npm run format:check && npm test && npm run readme:check && npm run demos:check && npm run api:check && npm run docs:check && npm run media:check && npm run docs:build && npm run build:demo && npm run browser:check && npm audit && npm pack --dry-run && npm run package:check",
|
|
22
22
|
"source:check": "node scripts/source-check.mjs",
|
|
23
23
|
"browser:check": "node scripts/browser-check.mjs",
|
|
24
24
|
"package:check": "node scripts/package-check.mjs",
|
|
25
25
|
"docs:typecheck": "vue-tsc --noEmit -p docs/tsconfig.json",
|
|
26
26
|
"demos:check": "node scripts/demo-coverage.mjs",
|
|
27
|
-
"docs:deploy": "node scripts/deploy-docs.mjs"
|
|
27
|
+
"docs:deploy": "node scripts/deploy-docs.mjs",
|
|
28
|
+
"docs:screenshots": "npm run docs:build && node scripts/capture-demos.mjs && npm run docs:build",
|
|
29
|
+
"media:check": "node scripts/media-check.mjs",
|
|
30
|
+
"api:check": "node scripts/api-methods.mjs",
|
|
31
|
+
"readme:check": "node scripts/readme-check.mjs",
|
|
32
|
+
"algorithms:check": "node scripts/algorithm-check.mjs",
|
|
33
|
+
"docs:check": "node scripts/docs-check.mjs"
|
|
28
34
|
},
|
|
29
35
|
"private": false,
|
|
30
36
|
"repository": {
|
|
@@ -33,22 +39,18 @@
|
|
|
33
39
|
},
|
|
34
40
|
"author": "Zhao YS",
|
|
35
41
|
"keywords": [
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
42
|
+
"computational-geometry",
|
|
43
|
+
"typescript",
|
|
44
|
+
"web3d",
|
|
45
|
+
"geometry",
|
|
46
|
+
"distance",
|
|
47
|
+
"intersection",
|
|
48
|
+
"triangulation",
|
|
49
|
+
"polygon-clipping",
|
|
50
|
+
"mesh",
|
|
51
|
+
"threejs"
|
|
46
52
|
],
|
|
47
53
|
"license": "MIT",
|
|
48
|
-
"dependencies": {
|
|
49
|
-
"decimal.js": "^10.6.0",
|
|
50
|
-
"geographiclib-geodesic": "2.2.0"
|
|
51
|
-
},
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@types/node": "26.6.11",
|
|
54
56
|
"@types/three": "0.187.0",
|
|
@@ -70,6 +72,7 @@
|
|
|
70
72
|
"dist",
|
|
71
73
|
"build",
|
|
72
74
|
"readme.md",
|
|
75
|
+
"readme.zh-CN.md",
|
|
73
76
|
"LICENSE",
|
|
74
77
|
"THIRD_PARTY_NOTICES.md"
|
|
75
78
|
],
|
package/readme.md
CHANGED
|
@@ -1,117 +1,242 @@
|
|
|
1
|
+
@@file readme.md
|
|
1
2
|
# cga.js
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
[English](readme.md) · [简体中文](readme.zh-CN.md)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**Computational geometry for JavaScript and TypeScript.** Unified data structures for distances, closest points, intersections, polygon booleans, triangulation, point clouds and path meshes, plus decimal CSG, IK, GIS and optional Three.js / GLSL adapters.
|
|
7
|
+
|
|
8
|
+
[](https://www.npmjs.com/package/@xort/cga) [](https://github.com/yszhao91/cga.js/actions/workflows/ci.yml) [](LICENSE)
|
|
9
|
+
|
|
10
|
+
[Quick start](#installation-and-quick-start) · [Playground](https://yszhao91.github.io/cga.js/guide/playground.html) · [Gallery](https://yszhao91.github.io/cga.js/guide/gallery.html) · [API](https://yszhao91.github.io/cga.js/guide/api.html) · [Roadmap](docs/guide/architecture.md) · [Contributing](CONTRIBUTING.md)
|
|
6
11
|
|
|
7
12
|
<!-- release-status:start -->
|
|
8
|
-
|
|
13
|
+
**0.1.4** introduces English-first project presentation and bilingual documentation. All computation kernels are internal TypeScript with zero core runtime dependencies. The [release status](https://yszhao91.github.io/cga.js/release-status.html) records published versions, tags and deployment receipts.
|
|
9
14
|
<!-- release-status:end -->
|
|
10
15
|
|
|
11
|
-
##
|
|
16
|
+
## See it in action
|
|
17
|
+
|
|
18
|
+
These images are captured from the actual running examples. Open a scene to reproduce its parameters; the gallery also includes full screenshots with controls, legends and computed results.
|
|
19
|
+
|
|
20
|
+
| Distances and closest points | Concave polygons with multiple holes |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| [](https://yszhao91.github.io/cga.js/guide/playground.html#geometry-distance?a=Capsule&b=Triangle&ax=0.5&ay=3&az=1) | [](https://yszhao91.github.io/cga.js/guide/playground.html#triangulation-multiple-holes) |
|
|
23
|
+
| **Hollow profiles and path sweeps** | **High-precision solid booleans** |
|
|
24
|
+
| [](https://yszhao91.github.io/cga.js/guide/playground.html#extrude-holes-closed?width=0.65) | [](https://yszhao91.github.io/cga.js/guide/playground.html#csg-subtract?x=0.5) |
|
|
25
|
+
| **Constrained inverse kinematics** | **GIS globe tiles** |
|
|
26
|
+
| [](https://yszhao91.github.io/cga.js/guide/playground.html#ik-hinge?x=1.5&y=2) | [](https://yszhao91.github.io/cga.js/guide/playground.html#gis-globe?level=2) |
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
**94 interactive cases · 184 public entry mappings · 225 ordered pairs across 15 geometry types.** These figures describe examples and entry coverage; [method-level coverage](docs/guide/method-coverage.md) is tracked separately. Analytical, reference and degeneracy tests check numerical behavior.
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
[All 14 illustrated scenes](https://yszhao91.github.io/cga.js/guide/gallery.html) · [Example coverage](docs/guide/demo-coverage.md) · [Reproduce screenshots](#development-and-verification)
|
|
16
31
|
|
|
17
|
-
##
|
|
32
|
+
## Installation and quick start
|
|
18
33
|
|
|
19
34
|
```sh
|
|
20
35
|
npm install @xort/cga
|
|
21
36
|
```
|
|
22
37
|
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
### Distance, closest points and parameters
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
// example:distance
|
|
42
|
+
import { v3, segment, distance, intersects } from '@xort/cga';
|
|
25
43
|
|
|
26
44
|
const point = v3(1, 2, 0);
|
|
27
|
-
const
|
|
28
|
-
const result = distance(point,
|
|
29
|
-
|
|
30
|
-
console.log(result.
|
|
31
|
-
console.log(result.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.log(
|
|
36
|
-
console.log(intersects(segment, arc)); // true
|
|
45
|
+
const edge = segment(v3(0, 0, 0), v3(4, 0, 0));
|
|
46
|
+
const result = distance(point, edge);
|
|
47
|
+
|
|
48
|
+
console.log(result.distance); // 2
|
|
49
|
+
console.log(result.distanceSqr); // 4
|
|
50
|
+
console.log(result.closests.map(p => p.toArray())); // [[1, 2, 0], [1, 0, 0]]
|
|
51
|
+
console.log(result.parameters); // [0, 0.25]
|
|
52
|
+
console.log(intersects(point, edge)); // false
|
|
53
|
+
console.log(point.queryDistance(edge).distance); // 2
|
|
37
54
|
```
|
|
38
55
|
|
|
39
|
-
|
|
56
|
+
`distance(a, b)` and `a.queryDistance(b)` return the same result contract. `Vec3.distanceTo(otherPoint)` returns a numeric point-to-point distance.
|
|
40
57
|
|
|
41
|
-
|
|
58
|
+
### CommonJS
|
|
42
59
|
|
|
43
|
-
|
|
60
|
+
```js
|
|
61
|
+
// example:commonjs
|
|
62
|
+
const { v3, segment, distance } = require('@xort/cga');
|
|
63
|
+
const result = distance(v3(1, 2, 0), segment(v3(), v3(4, 0, 0)));
|
|
64
|
+
console.log(result.distance); // 2
|
|
65
|
+
```
|
|
44
66
|
|
|
45
|
-
|
|
46
|
-
- `distance / distanceSqr / closests / parameters` 是必填字段;最近点和参数始终按操作数 `[a, b]` 排列。
|
|
47
|
-
- 构造器与克隆拥有坐标;查询不修改输入。固定顶点几何体支持索引和迭代,顶点数量不可被数组操作改变。
|
|
48
|
-
- `geometryFromJSON` 校验并恢复统一数据;`Shape` 的孔洞一起序列化。
|
|
67
|
+
### Independent copies and serialization
|
|
49
68
|
|
|
50
|
-
|
|
69
|
+
```js
|
|
70
|
+
// example:serialization
|
|
71
|
+
import { Triangle, geometryFromJSON, v3 } from '@xort/cga';
|
|
51
72
|
|
|
52
|
-
|
|
73
|
+
const original = new Triangle(v3(), v3(2, 0, 0), v3(0, 2, 0));
|
|
74
|
+
const clone = original.clone();
|
|
75
|
+
const restored = geometryFromJSON(JSON.parse(JSON.stringify(original)));
|
|
76
|
+
original[0].x = 3;
|
|
77
|
+
console.log(clone[0].x, restored[0].x); // 0, 0; coordinates are independent
|
|
78
|
+
```
|
|
53
79
|
|
|
54
|
-
|
|
80
|
+
### Internal TypeScript polygon kernels
|
|
55
81
|
|
|
56
|
-
|
|
82
|
+
```js
|
|
83
|
+
// example:polygon
|
|
84
|
+
import { v3, triangulation, clipPolygons } from '@xort/cga';
|
|
85
|
+
|
|
86
|
+
const outer = [v3(-2,-2,0), v3(2,-2,0), v3(2,2,0), v3(-2,2,0)];
|
|
87
|
+
const hole = [v3(-.5,-.5,0), v3(.5,-.5,0), v3(.5,.5,0), v3(-.5,.5,0)];
|
|
88
|
+
const vertices = [...outer, ...hole];
|
|
89
|
+
const indices = triangulation(outer, [hole]);
|
|
90
|
+
console.log(vertices.length, indices.length / 3); // 8 vertices, 8 triangles
|
|
91
|
+
|
|
92
|
+
const contours = clipPolygons([outer], [hole], 'difference', v3(0,0,1));
|
|
93
|
+
console.log(contours.length); // 2; boundary and hole have opposite winding
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Triangulation, clipping, offsetting and cleanup use maintained internal TypeScript kernels. See [polygon kernels](docs/guide/polygon-kernels.md) for input restrictions, precision and complexity.
|
|
97
|
+
|
|
98
|
+
## Algorithms and runnable examples
|
|
99
|
+
|
|
100
|
+
| Area | Examples | Capabilities |
|
|
101
|
+
| --- | --- | --- |
|
|
102
|
+
| Geometry queries | [Distance and intersection](https://yszhao91.github.io/cga.js/guide/playground.html#geometry-distance) | Closest points, parameters, reciprocal queries, tolerance-based intersection |
|
|
103
|
+
| Arcs and disks | [Directed arcs](https://yszhao91.github.io/cga.js/guide/playground.html#circle-arc) | Angular bounds, endpoint constraints, numerical error bounds |
|
|
104
|
+
| Polygon booleans | [Topology changes](https://yszhao91.github.io/cga.js/guide/playground.html#polygon-topology) | Intersection, union, difference, XOR, holes and shared edges |
|
|
105
|
+
| Offsets and strokes | [Diagonal caps](https://yszhao91.github.io/cga.js/guide/playground.html#offset-open-caps) | Miter/round/square joins and butt/round/square caps |
|
|
106
|
+
| Triangulation | [Concave boundary with holes](https://yszhao91.github.io/cga.js/guide/playground.html#triangulation-multiple-holes) | 3D plane projection, original vertex indices, multiple holes |
|
|
107
|
+
| Delaunay / Voronoi | [Triangles](https://yszhao91.github.io/cga.js/guide/playground.html#delaunay-delaunay) · [Cells and neighbors](https://yszhao91.github.io/cga.js/guide/playground.html#voronoi) | Planar triangulation, clipped cells and adjacency |
|
|
108
|
+
| Point clouds | [3D hull](https://yszhao91.github.io/cga.js/guide/playground.html#hull-degeneracy) · [Closest pair](https://yszhao91.github.io/cga.js/guide/playground.html#closest-pair) | Affine degeneracy, outward faces and exact closest pairs |
|
|
109
|
+
| Curves and paths | [Catmull–Rom](https://yszhao91.github.io/cga.js/guide/playground.html#curve-catmull) · [Path distance](https://yszhao91.github.io/cga.js/guide/playground.html#path-mileage) | Parameterization, accumulated distance, slicing and sampling |
|
|
110
|
+
| Extrusion and meshes | [Hollow sweeps](https://yszhao91.github.io/cga.js/guide/playground.html#extrude-holes-closed) | Transported frames, joins, caps, UVs and normals |
|
|
111
|
+
| Plane cutting | [Volume conservation](https://yszhao91.github.io/cga.js/guide/playground.html#mesh-split-volume) | Separate halves, interpolated attributes and multi-ring caps |
|
|
112
|
+
| Spatial structures | [KdTree](https://yszhao91.github.io/cga.js/guide/playground.html#tree-kdtree) · [QuadTree](https://yszhao91.github.io/cga.js/guide/playground.html#tree-quadtree) · [Frustum](https://yszhao91.github.io/cga.js/guide/playground.html#frustum) | Neighbors, ranges, partitions, culling and clipping |
|
|
113
|
+
| Precision and CSG | [Projection](https://yszhao91.github.io/cga.js/guide/playground.html#precision-projection) · [Solid difference](https://yszhao91.github.io/cga.js/guide/playground.html#csg-subtract) | Decimal vectors, planes and BSP booleans |
|
|
114
|
+
| IK | [CCD](https://yszhao91.github.io/cga.js/guide/playground.html#ik-free) · [Hinge](https://yszhao91.github.io/cga.js/guide/playground.html#ik-hinge) · [Slider](https://yszhao91.github.io/cga.js/guide/playground.html#ik-slider) | Target solving, accumulated limits, convergence and bone lengths |
|
|
115
|
+
| GIS | [Coordinates](https://yszhao91.github.io/cga.js/guide/playground.html#gis-coordinates) · [Geodesics](https://yszhao91.github.io/cga.js/guide/playground.html#gis-geodesic) · [Terrain](https://yszhao91.github.io/cga.js/guide/playground.html#gis-heightmap) | ECEF/WGS84, tiles, imagery, terrain and tasks |
|
|
116
|
+
| Rendering and GLSL | [Viewer](https://yszhao91.github.io/cga.js/guide/playground.html#glview) · [Noise](https://yszhao91.github.io/cga.js/guide/playground.html#shader-classicnoise3d) | Optional Three.js, materials, noise and distance fields |
|
|
117
|
+
|
|
118
|
+
## Unified data structures and interfaces
|
|
119
|
+
|
|
120
|
+
The 15 geometry types are `Point / Vec3`, `Line`, `Ray`, `Segment`, `Plane`, `Triangle`, `Rectangle`, `Circle`, `Disk`, `Sphere`, `Capsule`, `Box`, `Polyline`, `Polygon` and `Shape`.
|
|
121
|
+
|
|
122
|
+
- Geometries share `kind`, `copy`, `clone`, `distancePoint`, `queryDistance` and `toJSON`. `geometryFromJSON` validates and restores data.
|
|
123
|
+
- Distance results always include `distance / distanceSqr / closests / parameters`, ordered as `[a, b]`. Iterative curved queries can report `errorBound`.
|
|
124
|
+
- Constructors and clones own their coordinates; queries preserve inputs. Fixed-arity objects support indexing and iteration without resizing.
|
|
125
|
+
- Mesh algorithms use `IGeometry`: `position:number[]`, optional `index / normal / uv / uv2 / tangent`. Indices are local to the returned vertex array.
|
|
126
|
+
- `Shape` retains holes for queries, triangulation and serialization.
|
|
127
|
+
|
|
128
|
+
### Conventions
|
|
129
|
+
|
|
130
|
+
| Item | Contract |
|
|
57
131
|
| --- | --- |
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
## 领域模块
|
|
73
|
-
|
|
74
|
-
```ts
|
|
132
|
+
| Line | `Line(origin, end)` takes two points |
|
|
133
|
+
| Ray | `Ray(origin, direction)` takes an origin and a direction |
|
|
134
|
+
| Segment | Parameter interval is `[0, 1]` |
|
|
135
|
+
| Plane | `normal · point + w = 0`; numeric signed distance has its own method |
|
|
136
|
+
| Circle / Disk | `Circle` is a circumference or directed arc; `Disk` is a filled surface |
|
|
137
|
+
| Polygon | Filled planar region; clean self-intersections first, and keep triangulation holes separate |
|
|
138
|
+
| Units | Caller-defined model units; GIS uses radians internally and WGS84 heights in meters |
|
|
139
|
+
| Resources | Dispose viewers and effects explicitly; the host owns its model geometry and materials |
|
|
140
|
+
|
|
141
|
+
## Precision, IK and GIS
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
// example:domains
|
|
75
145
|
import { HVec3, IK, GIS, v3 } from '@xort/cga';
|
|
76
146
|
|
|
77
|
-
|
|
147
|
+
const precise = new HVec3('0.1', '0.2', '0.3').add(new HVec3('0.2', 0, 0));
|
|
148
|
+
console.log(precise.x.toString()); // 0.3; strings preserve decimal input
|
|
78
149
|
|
|
79
|
-
const
|
|
80
|
-
const solved = new IK.CCDSolver().solve(
|
|
150
|
+
const skeleton = IK.Skeleton.fromPoints([v3(), v3(1,0,0), v3(2,0,0)]);
|
|
151
|
+
const solved = new IK.CCDSolver().solve(skeleton, v3(1,1,0));
|
|
81
152
|
console.log(solved.converged, solved.distance);
|
|
82
153
|
|
|
83
|
-
const
|
|
84
|
-
console.log(
|
|
154
|
+
const ecef = GIS.GVec3.fromDegrees(116.4, 39.9, 50);
|
|
155
|
+
console.log(ecef.toCartographic()); // longitude/latitude in radians, height in meters
|
|
85
156
|
```
|
|
86
157
|
|
|
158
|
+
CSG accepts closed, consistently oriented solids made of convex polygon faces. GIS `Globe` supplies tile and mesh data for a host renderer; `pick` queries the reference ellipsoid, while `getHeight` reads loaded terrain. Fetch/decode adapters integrate imagery and terrain services; examples inject local data. See [domain modules](docs/guide/experimental.md).
|
|
159
|
+
|
|
160
|
+
## Browsers and optional Three.js
|
|
161
|
+
|
|
162
|
+
Core calculations need no DOM, Three.js or GPU. Install the display dependency when needed:
|
|
163
|
+
|
|
87
164
|
```sh
|
|
88
165
|
npm install three
|
|
89
166
|
```
|
|
90
167
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
168
|
+
For a browser project using a bundler such as Vite, provide a container with an explicit height:
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<div id="view" style="height:420px;width:100%"></div>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
// example:browser
|
|
176
|
+
import { GLView, BreathLight } from '@xort/cga/three';
|
|
177
|
+
|
|
178
|
+
const view = new GLView({ container: document.querySelector('#view') });
|
|
95
179
|
const light = new BreathLight();
|
|
96
180
|
view.add(light);
|
|
97
181
|
view.addUpdates(time => light.update(time));
|
|
98
182
|
view.run();
|
|
99
|
-
|
|
183
|
+
|
|
184
|
+
// Call on unmount; dispose host model resources according to ownership.
|
|
185
|
+
const dispose = () => { light.dispose(); view.dispose(); };
|
|
186
|
+
window.addEventListener('pagehide', dispose, { once: true });
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Additional entries include `@xort/cga/shaders`, `ThreeBSP` and `DiamondShader`. Without a bundler, use the global `cga` from `build/@xort_cga.js` or the ESM `build/cga.esm.js`; these core files do not include the Three.js viewer.
|
|
190
|
+
|
|
191
|
+
## Internal algorithms and dependencies
|
|
192
|
+
|
|
193
|
+
Geometry, triangulation, booleans, CSG, IK, ellipsoid geodesics and decimal arithmetic are implemented inside the repository in TypeScript. The core has **zero runtime dependencies**. Decimal uses a BigInt kernel; geodesics use an internal Karney port with antipodal support and retained MIT attribution. Build tools stay out of the runtime package, Three.js is optional, and GPU shaders use GLSL.
|
|
194
|
+
|
|
195
|
+
```js
|
|
196
|
+
// example:decimal
|
|
197
|
+
import { Decimal, HVec3 } from '@xort/cga';
|
|
198
|
+
const previous = { precision: Decimal.precision, rounding: Decimal.rounding };
|
|
199
|
+
try {
|
|
200
|
+
Decimal.set({ precision: 50, rounding: Decimal.ROUND_HALF_EVEN });
|
|
201
|
+
console.log(new Decimal(2).sqrt().toString());
|
|
202
|
+
console.log(new HVec3('0.1').add(new HVec3('0.2')).toJSON());
|
|
203
|
+
} finally { Decimal.set(previous); }
|
|
100
204
|
```
|
|
101
205
|
|
|
102
|
-
|
|
206
|
+
Internal Decimal supplies arithmetic, comparison, square roots and formatting for vectors and CSG. It does not implement the complete decimal.js API, including trigonometry and clone configurations. Constructors retain input digits; arithmetic rounds to 1–1000 significant digits, with 20 by default. Non-finite values and out-of-range exponents throw. See [implementation and migration](docs/guide/internal-algorithms.md).
|
|
207
|
+
|
|
208
|
+
## Limits and remaining work
|
|
103
209
|
|
|
104
|
-
|
|
210
|
+
- Floating-point queries use tolerances. Exhausting an iteration budget throws; zero distance between intersecting solids does not provide a general contact manifold or penetration depth.
|
|
211
|
+
- Hole triangulation uses visible bridges and ear clipping, with worst-case O(n³) behavior. Polygon intersection enumeration is O(E²), with additional edge scans for classification; use it for small or medium contours.
|
|
212
|
+
- Planar booleans default to roughly `1e-6` model-unit quantization, configurable through `scale`. Smaller features can merge. Decimal vectors do not turn floating-point boolean operations into exact predicates.
|
|
213
|
+
- Round joins and caps use sampled curves. Large contours, extreme aspect ratios and nearly coincident edges still need dedicated performance/error benchmarks and stronger predicates.
|
|
214
|
+
- Public entries have examples; **dedicated method-level examples remain incomplete**, especially matrix projection, transforms and buffer attributes. The [method inventory](docs/guide/method-coverage.md) separates dedicated tags from shared queries.
|
|
215
|
+
- Constrained Delaunay, BVH, incremental updates, additional curves/surfaces and GIS protocols remain future capabilities. See the [roadmap](docs/guide/architecture.md).
|
|
105
216
|
|
|
106
|
-
|
|
217
|
+
## Development and verification
|
|
218
|
+
|
|
219
|
+
Minimum Node.js **22.12**; **Node 26** from `.nvmrc` is recommended. CI covers Linux / Windows with Node 22 / 24 / 26.
|
|
107
220
|
|
|
108
221
|
```sh
|
|
109
|
-
npm
|
|
222
|
+
npm ci
|
|
223
|
+
npx playwright install chromium # Windows can use installed Edge
|
|
224
|
+
npm run docs:dev # Local guides and examples
|
|
225
|
+
npm run verify # Complete checks
|
|
226
|
+
npm run algorithms:check # Internal TS and dependency boundary
|
|
227
|
+
npm run docs:screenshots # Capture 14 scenes / 28 images
|
|
228
|
+
npm run media:check # Image hashes, dimensions and source fingerprint
|
|
229
|
+
npm run api:check # Method-level inventory
|
|
230
|
+
npm run readme:check # Execute README snippets
|
|
110
231
|
npm run release:check -- --complete
|
|
111
232
|
```
|
|
112
233
|
|
|
113
|
-
|
|
234
|
+
See [architecture](docs/guide/architecture.md) for module boundaries and `.release/screenshots.json` for screenshot parameters and hashes. New public entries need runnable examples; behavior changes need analytical or independent reference checks.
|
|
235
|
+
|
|
236
|
+
Plan the version and documentation before implementation, verification, commits, deployment and npm publication. Increment once per release, carrying at 100: `0.1.99 → 0.2.0`, `0.99.99 → 1.0.0`. Commits and authentication retries keep the same planned version.
|
|
237
|
+
|
|
238
|
+
[0.1.4 release notes](docs/guide/migration-0.1.4.md) · [Delivery checklist](docs/guide/gaps.md) · [Contributing](CONTRIBUTING.md) · [Release status](docs/release-status.md)
|
|
114
239
|
|
|
115
|
-
|
|
240
|
+
## License
|
|
116
241
|
|
|
117
|
-
MIT
|
|
242
|
+
MIT. Ported algorithms and shaders retain their [third-party notices](THIRD_PARTY_NOTICES.md).
|