@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xort/cga",
3
- "version": "0.1.2",
4
- "description": "Computational geometry algorithms for JavaScript and TypeScript",
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
- "cga",
37
- "cgajs",
38
- "cga.js",
39
- "计算几何库",
40
- "webgl",
41
- "threejs",
42
- "compute geometry algorithm",
43
- "MIT",
44
- "开源",
45
- "gis"
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
- JavaScript / TypeScript 计算几何库:统一几何查询、最近点与参数、平面和实体布尔、剖分、点云、路径、网格、GIS 和逆运动学。核心计算可在 Node.js 和浏览器运行,不要求 DOM、Three.js 或 WebGL。
4
+ [English](readme.md) · [简体中文](readme.zh-CN.md)
4
5
 
5
- [文档](https://yszhao91.github.io/cga.js/) · [API](docs/guide/api.md) · [模块指南](docs/guide/experimental.md) · [0.1.2 迁移](docs/guide/migration-0.1.2.md) · [缺口验收](docs/guide/gaps.md) · [贡献](CONTRIBUTING.md)
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
+ [![npm](https://img.shields.io/npm/v/%40xort%2Fcga)](https://www.npmjs.com/package/@xort/cga) [![CI](https://github.com/yszhao91/cga.js/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/yszhao91/cga.js/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](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
- 本轮发行版本为 **0.1.2**:升级工具链,移除 Earcut / 旧 Clipper,使用自有 TypeScript 内核,并修复线上文档部署。npm latest 与线上部署的实际回执以版本状态页为准。进度见[缺口清单](docs/guide/gaps.md)与[版本状态](docs/release-status.md)。
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
+ | [![Capsule and triangle distance](https://yszhao91.github.io/cga.js/images/demos/geometry-distance.jpg)](https://yszhao91.github.io/cga.js/guide/playground.html#geometry-distance?a=Capsule&b=Triangle&ax=0.5&ay=3&az=1) | [![Concave polygon triangulation](https://yszhao91.github.io/cga.js/images/demos/triangulation-multiple-holes.jpg)](https://yszhao91.github.io/cga.js/guide/playground.html#triangulation-multiple-holes) |
23
+ | **Hollow profiles and path sweeps** | **High-precision solid booleans** |
24
+ | [![Hollow closed-path sweep](https://yszhao91.github.io/cga.js/images/demos/extrude-holes-closed.jpg)](https://yszhao91.github.io/cga.js/guide/playground.html#extrude-holes-closed?width=0.65) | [![CSG difference](https://yszhao91.github.io/cga.js/images/demos/csg-subtract.jpg)](https://yszhao91.github.io/cga.js/guide/playground.html#csg-subtract?x=0.5) |
25
+ | **Constrained inverse kinematics** | **GIS globe tiles** |
26
+ | [![Hinge-constrained IK](https://yszhao91.github.io/cga.js/images/demos/ik-hinge.jpg)](https://yszhao91.github.io/cga.js/guide/playground.html#ik-hinge?x=1.5&y=2) | [![Globe terrain tiles](https://yszhao91.github.io/cga.js/images/demos/gis-globe.jpg)](https://yszhao91.github.io/cga.js/guide/playground.html#gis-globe?level=2) |
12
27
 
13
- [进入示例库](https://yszhao91.github.io/cga.js/guide/playground.html) · [完整覆盖清单](docs/guide/demo-coverage.md) · [自有内核说明](docs/guide/polygon-kernels.md) · [升级记录](docs/guide/upgrades-0.1.2.md)
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
- 88 个案例覆盖几何查询、平面布尔、带孔剖分、点云、曲线、网格、空间树、高精度 CSG、IK、GIS 和 GLSL。展示代码与实际执行代码相同;参数修改、画面像素变化和全部 225 个几何组合均纳入浏览器回归。覆盖统计按公开入口和算法族计数,类型、常量及全部重载不单独计数。
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
- ```ts
24
- import { v3, Segment, Circle, distance, intersects } from '@xort/cga';
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 segment = new Segment(v3(), v3(4, 0, 0));
28
- const result = distance(point, segment);
29
- console.log(result.distance); // 2
30
- console.log(result.closests); // [(1,2,0), (1,0,0)]
31
- console.log(result.parameters); // [0, 0.25]
32
- point.queryDistance(segment); // 各几何体共有的方法,与 distance 返回相同结构
33
-
34
- const arc = new Circle(v3(), 1, 0, Math.PI / 2, v3(0, 0, 1));
35
- console.log(distance(arc, v3(-1, 0, 0)).distance); // √2,受圆弧范围限制
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
- CommonJS 使用 `const { v3, distance } = require('@xort/cga')`。浏览器直接引入 `build/@xort_cga.js` 后使用全局 `cga`;原生 ESM 文件为 `build/cga.esm.js`。
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
- `Point / Vec3`、直线、射线、线段、平面、三角形、矩形、圆弧、圆盘、球体、胶囊体、包围盒、折线、多边形和带孔 `Shape` 共享:
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
- - `kind`、`copy(source)`、`clone()`、`distancePoint(point)`、`queryDistance(other, options?)`、`toJSON()`。
46
- - `distance / distanceSqr / closests / parameters` 是必填字段;最近点和参数始终按操作数 `[a, b]` 排列。
47
- - 构造器与克隆拥有坐标;查询不修改输入。固定顶点几何体支持索引和迭代,顶点数量不可被数组操作改变。
48
- - `geometryFromJSON` 校验并恢复统一数据;`Shape` 的孔洞一起序列化。
67
+ ### Independent copies and serialization
49
68
 
50
- `Vec3.distanceTo` 继续返回点间数值距离;几何查询统一使用 `queryDistance`。`Line(origin, end)` 第二项是另一个点,`Ray(origin, direction)` 第二项是方向。线段参数为 `[0,1]`;平面方程为 `n·p + w = 0`。
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
- | 距离与最近点 | `distance / queryDistance / intersects`;线性、退化、平行、共面、圆弧和圆盘组合 |
59
- | 曲线求解 | 线性对象到圆弧的四次多项式候选;弧段自适应界;圆盘凸距离 GJK;迭代结果附 `errorBound` |
60
- | 切割网格 | `Plane.splitGeometry(..., { cap: true })`、`splitPlaneGeometry`;属性插值、多轮廓与孔洞封口 |
61
- | 平面多边形 | 包含、清理、偏移、交/并/差/异或;自有 TypeScript 内核,局部量化精度可配置 |
62
- | 剖分与点云 | 自有带孔耳切剖分、Delaunay/Voronoi、共面凸包、`convexHull3D`、三维最近点对 `O(n log n)` |
63
- | 路径与挤压 | 路径里程/采样/变换刷新、Catmull–Rom、平行移动标架、转角、端盖、孔洞、UV 与法线 |
64
- | 空间结构 | BTree、KdTree、QuadTree、BSP 平面划分、PolyTree 外轮廓/孔洞/岛屿层次 |
65
- | 高精度与实体布尔 | `HVec3`、`Robust.Vec / Plane`、`CSG.BSP` 的并/交/差 |
66
- | 逆运动学 | `IK` 骨链、关节、CCD、铰链角度及滑块位移约束 |
67
- | GIS | `GIS` ECEF/WGS84、椭球正反算、Karney 测地线、瓦片、影像/地形、任务和 Globe 数据层 |
68
- | 渲染适配与着色器 | 可选 `@xort/cga/three` 和 `@xort/cga/shaders`;独立于主包渲染环境 |
69
-
70
- 圆类迭代查询可传 `{ tolerance, maximumIterations }`。达到迭代预算仍无法满足误差要求时抛错;普通数值几何使用浮点运算,不能把容差判断当作精确算术谓词。高精度向量使用 Decimal,字符串输入可保留 JS number 无法表达的有效位数。
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
- console.log(new HVec3('0.1', '0.2', '0.3').add(new HVec3('0.2', 0, 0)).x.toString()); // 0.3
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 chain = IK.Skeleton.fromPoints([v3(), v3(1,0,0), v3(2,0,0)]);
80
- const solved = new IK.CCDSolver().solve(chain, v3(1,1,0));
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 coordinate = GIS.GVec3.fromDegrees(116.4, 39.9, 50);
84
- console.log(coordinate.toCartographic()); // 弧度、米;ECEF 的 Z 轴朝北
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
- ```ts
92
- import { GLView, BreathLight, ThreeBSP } from '@xort/cga/three';
93
- import { shaders } from '@xort/cga/shaders';
94
- const view = new GLView({ container: document.querySelector('#view')! });
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
- // 页面卸载时 view.dispose(); light.dispose();
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
- GIS 影像与地形可通过 fetch/解码器适配真实服务。Globe 管理几何和瓦片数据,由宿主渲染器消费网格;`pick` 针对参考椭球,`getHeight` 读取已加载地形。详见[模块指南](docs/guide/experimental.md)和[网格指南](docs/guide/meshes.md)。
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
- 最低 Node.js 22.12,建议 Node.js 24。先 `npm ci`,浏览器测试环境执行 `npx playwright install chromium`(Windows 也可使用已安装的 Edge)。
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 run verify # 版本、全仓源文件、类型、格式、测试、文档、示例、浏览器、依赖及打包
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
- 每轮发布先规划版本、更新包和相关文档,然后实现、验收,最后提交、推送和发布。末位每次加 1,满 100 向前进位:`0.1.99 → 0.2.0`、`0.99.99 → 1.0.0`。同一轮的修复和授权重试不重复升版。
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
- 缺口清单全部验收、计划状态为 `ready` 后,提交脚本和发布钩子才放行。[版本规则](docs/guide/releasing.md) · [架构](docs/guide/architecture.md) · [审核记录](docs/guide/audit.md)
240
+ ## License
116
241
 
117
- MIT License;第三方组件和着色器声明见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
242
+ MIT. Ported algorithms and shaders retain their [third-party notices](THIRD_PARTY_NOTICES.md).