@xort/cga 0.0.93 → 0.1.0

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 (369) hide show
  1. package/THIRD_PARTY_NOTICES.md +47 -0
  2. package/build/@xort_cga.js +14187 -12097
  3. package/build/cga.d.ts +2284 -1983
  4. package/build/cga.esm.js +14179 -0
  5. package/dist/THIRD_PARTY_NOTICES.md +47 -0
  6. package/dist/index.cjs +14320 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.d.cts +2358 -0
  9. package/dist/index.d.ts +2358 -38
  10. package/dist/index.js +14181 -56
  11. package/dist/index.js.map +1 -0
  12. package/package.json +59 -47
  13. package/readme.md +162 -247
  14. package/.github/FUNDING.yml +0 -12
  15. package/cga/1./347/202/271/344/270/216/347/272/277/346/200/247/345/205/203/347/264/240/347/232/204/350/267/235/347/246/273.html +0 -601
  16. package/cga/1./347/202/271/344/270/216/347/272/277/346/200/247/345/205/203/347/264/240/347/232/204/350/267/235/347/246/273.md +0 -111
  17. package/cga/2./347/202/271/344/270/216/351/235/242/346/200/247/345/205/203/347/264/240.md +0 -4
  18. package/cga/img//347/202/271/344/270/216/345/260/204/347/272/277.png +0 -0
  19. package/cga/img//347/202/271/344/270/216/347/233/264/347/272/277.png +0 -0
  20. package/cga/img//347/202/271/344/270/216/347/272/277/346/256/265.png +0 -0
  21. package/cga/img//347/233/264/347/272/277/347/232/204/350/241/250/350/276/276/345/274/217.png +0 -0
  22. package/deploy.sh +0 -39
  23. package/dist/IKanimation/Bone.d.ts +0 -7
  24. package/dist/IKanimation/Bone.js +0 -20
  25. package/dist/IKanimation/CCDSolver.d.ts +0 -37
  26. package/dist/IKanimation/CCDSolver.js +0 -93
  27. package/dist/IKanimation/Joint.d.ts +0 -3
  28. package/dist/IKanimation/Joint.js +0 -17
  29. package/dist/IKanimation/constaint/constraint.d.ts +0 -10
  30. package/dist/IKanimation/constaint/constraint.js +0 -25
  31. package/dist/IKanimation/constaint/hinge.d.ts +0 -12
  32. package/dist/IKanimation/constaint/hinge.js +0 -46
  33. package/dist/IKanimation/constaint/slider.d.ts +0 -12
  34. package/dist/IKanimation/constaint/slider.js +0 -44
  35. package/dist/IKanimation/index.d.ts +0 -0
  36. package/dist/IKanimation/index.js +0 -9
  37. package/dist/IKanimation/isolver.d.ts +0 -4
  38. package/dist/IKanimation/isolver.js +0 -10
  39. package/dist/IKanimation/skeleton.d.ts +0 -13
  40. package/dist/IKanimation/skeleton.js +0 -31
  41. package/dist/alg/common.d.ts +0 -114
  42. package/dist/alg/common.js +0 -302
  43. package/dist/alg/curve.d.ts +0 -4
  44. package/dist/alg/curve.js +0 -11
  45. package/dist/alg/delaunator.d.ts +0 -29
  46. package/dist/alg/delaunator.js +0 -442
  47. package/dist/alg/delaunay.d.ts +0 -20
  48. package/dist/alg/delaunay.js +0 -199
  49. package/dist/alg/delaunayslow.d.ts +0 -18
  50. package/dist/alg/delaunayslow.js +0 -140
  51. package/dist/alg/extrude/extrude.d.ts +0 -3
  52. package/dist/alg/extrude/extrude.js +0 -17
  53. package/dist/alg/extrude.d.ts +0 -199
  54. package/dist/alg/extrude.js +0 -728
  55. package/dist/alg/offset/index.d.ts +0 -0
  56. package/dist/alg/offset/index.js +0 -9
  57. package/dist/alg/offset.d.ts +0 -0
  58. package/dist/alg/offset.js +0 -472
  59. package/dist/alg/pointset.d.ts +0 -94
  60. package/dist/alg/pointset.js +0 -223
  61. package/dist/alg/recognition.d.ts +0 -14
  62. package/dist/alg/recognition.js +0 -37
  63. package/dist/alg/result.d.ts +0 -22
  64. package/dist/alg/result.js +0 -2
  65. package/dist/alg/segmentset.d.ts +0 -11
  66. package/dist/alg/segmentset.js +0 -45
  67. package/dist/alg/sort.d.ts +0 -2
  68. package/dist/alg/sort.js +0 -14
  69. package/dist/alg/split.d.ts +0 -8
  70. package/dist/alg/split.js +0 -10
  71. package/dist/alg/trianglution.d.ts +0 -15
  72. package/dist/alg/trianglution.js +0 -70
  73. package/dist/alg/vol.d.ts +0 -6
  74. package/dist/alg/vol.js +0 -18
  75. package/dist/alg/voronoi.d.ts +0 -31
  76. package/dist/alg/voronoi.js +0 -418
  77. package/dist/app.d.ts +0 -1
  78. package/dist/app.js +0 -248
  79. package/dist/basic/distance.d.ts +0 -12
  80. package/dist/basic/distance.js +0 -39
  81. package/dist/csg/bsp.d.ts +0 -9
  82. package/dist/csg/bsp.js +0 -22
  83. package/dist/csg/node.d.ts +0 -12
  84. package/dist/csg/node.js +0 -75
  85. package/dist/csg/polygon.d.ts +0 -43
  86. package/dist/csg/polygon.js +0 -161
  87. package/dist/diamondMaterialShader.d.ts +0 -92
  88. package/dist/diamondMaterialShader.js +0 -118
  89. package/dist/effect/breath-light.d.ts +0 -4
  90. package/dist/effect/breath-light.js +0 -39
  91. package/dist/extends/geometryaid.d.ts +0 -28
  92. package/dist/extends/geometryaid.js +0 -71
  93. package/dist/extends/split.d.ts +0 -3
  94. package/dist/extends/split.js +0 -13
  95. package/dist/glview.d.ts +0 -112
  96. package/dist/glview.js +0 -564
  97. package/dist/math/Color.d.ts +0 -33
  98. package/dist/math/Color.js +0 -235
  99. package/dist/math/Euler.d.ts +0 -46
  100. package/dist/math/Euler.js +0 -225
  101. package/dist/math/HVec3.d.ts +0 -43
  102. package/dist/math/HVec3.js +0 -176
  103. package/dist/math/Mat3.d.ts +0 -29
  104. package/dist/math/Mat3.js +0 -244
  105. package/dist/math/Mat4.d.ts +0 -85
  106. package/dist/math/Mat4.js +0 -791
  107. package/dist/math/Math.d.ts +0 -130
  108. package/dist/math/Math.js +0 -198
  109. package/dist/math/Quat.d.ts +0 -82
  110. package/dist/math/Quat.js +0 -418
  111. package/dist/math/Vec2.d.ts +0 -68
  112. package/dist/math/Vec2.js +0 -328
  113. package/dist/math/Vec3.d.ts +0 -240
  114. package/dist/math/Vec3.js +0 -1082
  115. package/dist/math/Vec4.d.ts +0 -81
  116. package/dist/math/Vec4.js +0 -475
  117. package/dist/math/vecs.d.ts +0 -134
  118. package/dist/math/vecs.js +0 -464
  119. package/dist/render/bufferAttribute.d.ts +0 -104
  120. package/dist/render/bufferAttribute.js +0 -344
  121. package/dist/render/geometry.d.ts +0 -87
  122. package/dist/render/geometry.js +0 -769
  123. package/dist/render/mesh.d.ts +0 -30
  124. package/dist/render/mesh.js +0 -87
  125. package/dist/render/types.d.ts +0 -3
  126. package/dist/render/types.js +0 -8
  127. package/dist/robust/plane.d.ts +0 -7
  128. package/dist/robust/plane.js +0 -17
  129. package/dist/robust/vec.d.ts +0 -15
  130. package/dist/robust/vec.js +0 -71
  131. package/dist/struct/3d/Box.d.ts +0 -23
  132. package/dist/struct/3d/Box.js +0 -109
  133. package/dist/struct/3d/Capsule.d.ts +0 -12
  134. package/dist/struct/3d/Capsule.js +0 -36
  135. package/dist/struct/3d/Circle.d.ts +0 -52
  136. package/dist/struct/3d/Circle.js +0 -138
  137. package/dist/struct/3d/Disk.d.ts +0 -10
  138. package/dist/struct/3d/Disk.js +0 -22
  139. package/dist/struct/3d/Frustum.d.ts +0 -35
  140. package/dist/struct/3d/Frustum.js +0 -159
  141. package/dist/struct/3d/Line.d.ts +0 -40
  142. package/dist/struct/3d/Line.js +0 -340
  143. package/dist/struct/3d/Path.d.ts +0 -75
  144. package/dist/struct/3d/Path.js +0 -308
  145. package/dist/struct/3d/Plane.d.ts +0 -74
  146. package/dist/struct/3d/Plane.js +0 -298
  147. package/dist/struct/3d/Point.d.ts +0 -4
  148. package/dist/struct/3d/Point.js +0 -30
  149. package/dist/struct/3d/Polygon.d.ts +0 -8
  150. package/dist/struct/3d/Polygon.js +0 -55
  151. package/dist/struct/3d/Polyline.d.ts +0 -34
  152. package/dist/struct/3d/Polyline.js +0 -130
  153. package/dist/struct/3d/Ray.d.ts +0 -21
  154. package/dist/struct/3d/Ray.js +0 -262
  155. package/dist/struct/3d/Rectangle.d.ts +0 -7
  156. package/dist/struct/3d/Rectangle.js +0 -35
  157. package/dist/struct/3d/Segment.d.ts +0 -32
  158. package/dist/struct/3d/Segment.js +0 -334
  159. package/dist/struct/3d/Shape.d.ts +0 -4
  160. package/dist/struct/3d/Shape.js +0 -27
  161. package/dist/struct/3d/Sphere.d.ts +0 -11
  162. package/dist/struct/3d/Sphere.js +0 -30
  163. package/dist/struct/3d/Triangle.d.ts +0 -8
  164. package/dist/struct/3d/Triangle.js +0 -53
  165. package/dist/struct/bsp.d.ts +0 -9
  166. package/dist/struct/bsp.js +0 -44
  167. package/dist/struct/btree.d.ts +0 -0
  168. package/dist/struct/btree.js +0 -1
  169. package/dist/struct/data/ArrayList.d.ts +0 -42
  170. package/dist/struct/data/ArrayList.js +0 -172
  171. package/dist/struct/data/ArrayObject.d.ts +0 -30
  172. package/dist/struct/data/ArrayObject.js +0 -131
  173. package/dist/struct/data/type.d.ts +0 -13
  174. package/dist/struct/data/type.js +0 -18
  175. package/dist/struct/kdtree.d.ts +0 -0
  176. package/dist/struct/kdtree.js +0 -1
  177. package/dist/struct/polyTree.d.ts +0 -4
  178. package/dist/struct/polyTree.js +0 -27
  179. package/dist/struct/quatTree.d.ts +0 -0
  180. package/dist/struct/quatTree.js +0 -1
  181. package/dist/struct/tree.d.ts +0 -11
  182. package/dist/struct/tree.js +0 -26
  183. package/dist/utils/array.d.ts +0 -24
  184. package/dist/utils/array.js +0 -89
  185. package/dist/utils/types.d.ts +0 -24
  186. package/dist/utils/types.js +0 -20
  187. package/docs/.vuepress/components/distance.vue +0 -125
  188. package/docs/.vuepress/components/intersect.vue +0 -0
  189. package/docs/.vuepress/components/trianglution.vue +0 -121
  190. package/docs/.vuepress/components/utils.js +0 -314
  191. package/docs/.vuepress/config.js +0 -99
  192. package/docs/.vuepress/enhanceApp.js +0 -13
  193. package/docs/.vuepress/public/delaunay.png +0 -0
  194. package/docs/.vuepress/public/logo.png +0 -0
  195. package/docs/.vuepress/public/plane-set-convex.png +0 -0
  196. package/docs/.vuepress/public/sponsor/alipay.jpg +0 -0
  197. package/docs/.vuepress/public/sponsor/wechat.png +0 -0
  198. package/docs/README.md +0 -14
  199. package/docs/demo/README.md +0 -9
  200. package/docs/guide/README.md +0 -94
  201. package/docs/guide/array.md +0 -10
  202. package/docs/guide/cy/trianglution.html +0 -2
  203. package/docs/guide/distLineAll.md +0 -85
  204. package/docs/guide/distPointAll.md +0 -137
  205. package/docs/guide/distRayAll.md +0 -69
  206. package/docs/guide/distSegmentAll.md +0 -19
  207. package/docs/guide/point.vue +0 -12
  208. package/docs/guide/vector.md +0 -10
  209. package/docs/guide//345/270/270/347/224/250.md +0 -156
  210. package/docs/sponsor/README.md +0 -15
  211. package/docs//345/274/200/345/217/221/346/227/245/345/277/227/2020/345/271/2643/346/234/21013/346/227/245.md +0 -6
  212. package/effect/common.glsl +0 -34
  213. package/effect/drawing.glsl +0 -36
  214. package/effect/shape.arc.glsl +0 -13
  215. package/effect/shape.circle.glsl +0 -13
  216. package/effect/shape.grid.glsl +0 -42
  217. package/effect/shape.line.glsl +0 -18
  218. package/effect/shape.pie.glsl +0 -18
  219. package/effect/shape.plot.glsl +0 -10
  220. package/effect/shape.poly.glsl +0 -15
  221. package/effect/shape.rect.glsl +0 -14
  222. package/effect/shape.rectround.glsl +0 -15
  223. package/effect/shape.segment.glsl +0 -10
  224. package/effect/shape.spiral.glsl +0 -12
  225. package/effect/shape.star.glsl +0 -16
  226. package/examples/index.html +0 -31
  227. package/git.sh +0 -12
  228. package/gitproxy.sh +0 -6
  229. package/image/readme/1640758500266.png +0 -0
  230. package/image/readme/1640758513361.png +0 -0
  231. package/index.html +0 -14
  232. package/linear algorithm//346/225/260/345/255/246/350/241/250/350/276/276/345/274/217.md" +0 -122
  233. package/linear algorithm//347/237/251/351/230/265.md" +0 -91
  234. package/rollup.config.js +0 -82
  235. package/scripttest.html +0 -23
  236. package/src/IKanimation/Bone.ts +0 -20
  237. package/src/IKanimation/CCDSolver.ts +0 -114
  238. package/src/IKanimation/Joint.ts +0 -13
  239. package/src/IKanimation/constaint/constraint.ts +0 -23
  240. package/src/IKanimation/constaint/hinge.ts +0 -29
  241. package/src/IKanimation/constaint/slider.ts +0 -25
  242. package/src/IKanimation/index.ts +0 -8
  243. package/src/IKanimation/isolver.ts +0 -13
  244. package/src/IKanimation/skeleton.ts +0 -30
  245. package/src/alg/common.ts +0 -304
  246. package/src/alg/curve.ts +0 -9
  247. package/src/alg/delaunator.ts +0 -519
  248. package/src/alg/delaunay.ts +0 -163
  249. package/src/alg/delaunayslow.ts +0 -183
  250. package/src/alg/extrude/extrude.ts +0 -19
  251. package/src/alg/extrude.ts +0 -941
  252. package/src/alg/offset/index.ts +0 -8
  253. package/src/alg/offset.ts +0 -501
  254. package/src/alg/pointset.ts +0 -219
  255. package/src/alg/recognition.ts +0 -43
  256. package/src/alg/result.ts +0 -24
  257. package/src/alg/segmentset.ts +0 -44
  258. package/src/alg/sort.ts +0 -11
  259. package/src/alg/split.ts +0 -15
  260. package/src/alg/trianglution.ts +0 -53
  261. package/src/alg/vol.ts +0 -18
  262. package/src/alg/voronoi.ts +0 -303
  263. package/src/app.css +0 -12
  264. package/src/app.ts +0 -285
  265. package/src/assets/color.jpg +0 -0
  266. package/src/basic/distance.ts +0 -40
  267. package/src/clipper/clipper.d.ts +0 -323
  268. package/src/clipper/clipper.js +0 -7626
  269. package/src/clipper/clipper_float.js +0 -185
  270. package/src/clipper/clipper_float_unminified.js +0 -5639
  271. package/src/clipper/clipperint.js +0 -7626
  272. package/src/csg/bsp.ts +0 -24
  273. package/src/csg/csg.js +0 -583
  274. package/src/csg/node.ts +0 -91
  275. package/src/csg/polygon.ts +0 -177
  276. package/src/diamondMaterialShader.ts +0 -93
  277. package/src/effect/breath-light.ts +0 -24
  278. package/src/extends/geometryaid.ts +0 -86
  279. package/src/extends/split.ts +0 -15
  280. package/src/glview.ts +0 -570
  281. package/src/index.ts +0 -47
  282. package/src/math/Color.ts +0 -225
  283. package/src/math/Euler.ts +0 -238
  284. package/src/math/HVec3.ts +0 -1144
  285. package/src/math/Mat3.ts +0 -365
  286. package/src/math/Mat4.ts +0 -1134
  287. package/src/math/Math.ts +0 -213
  288. package/src/math/Quat.ts +0 -536
  289. package/src/math/Vec2.ts +0 -408
  290. package/src/math/Vec3.ts +0 -1307
  291. package/src/math/Vec4.ts +0 -587
  292. package/src/math/vecs.ts +0 -486
  293. package/src/render/bufferAttribute.ts +0 -491
  294. package/src/render/geometry.ts +0 -1329
  295. package/src/render/mesh.ts +0 -82
  296. package/src/render/types.ts +0 -17
  297. package/src/robust/plane.ts +0 -12
  298. package/src/robust/readme.md +0 -1
  299. package/src/robust/vec.ts +0 -61
  300. package/src/shader/cga.glsl +0 -202
  301. package/src/shader/common.glsl +0 -87
  302. package/src/shader/noise/GLSL-Noise.md +0 -1108
  303. package/src/shader/noise/cellular2D.glsl +0 -69
  304. package/src/shader/noise/cellular2x2.glsl +0 -64
  305. package/src/shader/noise/cellular2x2x2.glsl +0 -88
  306. package/src/shader/noise/cellular3D.glsl +0 -187
  307. package/src/shader/noise/classicnoise2D.glsl +0 -113
  308. package/src/shader/noise/classicnoise3D.glsl +0 -177
  309. package/src/shader/noise/classicnoise4D.glsl +0 -302
  310. package/src/shader/noise/noise2D.glsl +0 -71
  311. package/src/shader/noise/noise3D.glsl +0 -103
  312. package/src/shader/noise/noise3Dgrad.glsl +0 -111
  313. package/src/shader/noise/noise4D.glsl +0 -129
  314. package/src/shader/noise/psrdnoise2D.glsl +0 -462
  315. package/src/struct/3d/Box.ts +0 -124
  316. package/src/struct/3d/Capsule.ts +0 -18
  317. package/src/struct/3d/Circle.ts +0 -149
  318. package/src/struct/3d/Disk.ts +0 -22
  319. package/src/struct/3d/Frustum.ts +0 -189
  320. package/src/struct/3d/Line.ts +0 -378
  321. package/src/struct/3d/Path.ts +0 -314
  322. package/src/struct/3d/Plane.ts +0 -341
  323. package/src/struct/3d/Point.ts +0 -7
  324. package/src/struct/3d/PolyLine.ts +0 -115
  325. package/src/struct/3d/Polygon.ts +0 -46
  326. package/src/struct/3d/Ray.ts +0 -285
  327. package/src/struct/3d/Rectangle.ts +0 -18
  328. package/src/struct/3d/Segment.ts +0 -330
  329. package/src/struct/3d/Shape.ts +0 -7
  330. package/src/struct/3d/Sphere.ts +0 -31
  331. package/src/struct/3d/Triangle.ts +0 -28
  332. package/src/struct/bsp.ts +0 -18
  333. package/src/struct/btree.ts +0 -0
  334. package/src/struct/data/ArrayList.ts +0 -144
  335. package/src/struct/data/ArrayObject.ts +0 -105
  336. package/src/struct/data/type.ts +0 -14
  337. package/src/struct/kdtree.ts +0 -0
  338. package/src/struct/polyTree.ts +0 -8
  339. package/src/struct/quatTree.ts +0 -0
  340. package/src/struct/tree.ts +0 -30
  341. package/src/utils/array.ts +0 -106
  342. package/src/utils/types.ts +0 -42
  343. package/src-gis/app.ts +0 -7
  344. package/src-gis/core/Cartographic.ts +0 -48
  345. package/src-gis/core/EllipsoidGeodesic.ts +0 -56
  346. package/src-gis/core/EllipsoidTerrainProvider.ts +0 -35
  347. package/src-gis/core/HeightmapTerrainData.ts +0 -5
  348. package/src-gis/core/Rectangle.ts +0 -112
  349. package/src-gis/core/TaskProcessor.ts +0 -222
  350. package/src-gis/gis.ts +0 -25
  351. package/src-gis/globe.ts +0 -54
  352. package/src-gis/math/Cartographic.ts +0 -24
  353. package/src-gis/math/GVec3.ts +0 -55
  354. package/src-gis/math/ellipsoid.ts +0 -13
  355. package/src-gis/provider/DcTerrainProvider.ts +0 -36
  356. package/src-gis/provider/TerrainProvider.ts +0 -12
  357. package/src-gis/scene/DcImageryProvider.ts +0 -36
  358. package/src-gis/scene/GeographicTilingScheme.ts +0 -65
  359. package/src-gis/scene/Globe.ts +0 -76
  360. package/src-gis/scene/GlobeSurfaceShaderSet.ts +0 -9
  361. package/src-gis/scene/GlobeSurfaceTileProvider.ts +0 -25
  362. package/src-gis/scene/ImageryLayerCollection.ts +0 -75
  363. package/src-gis/scene/ImageryProvider.ts +0 -28
  364. package/src-gis/scene/QuadtreeTile.ts +0 -162
  365. package/src-gis/scene/UrlTemplateImageryProvider.ts +0 -32
  366. package/src-gis/scene/quadtree_primitive.ts +0 -58
  367. package/tsconfig.json +0 -77
  368. package/webpack.config.js +0 -112
  369. package//350/256/241/347/256/227/345/207/240/344/275/225/351/227/256/351/242/230.md +0 -26
package/package.json CHANGED
@@ -1,25 +1,27 @@
1
1
  {
2
2
  "name": "@xort/cga",
3
- "version": "0.0.93",
4
- "description": "Xtor Compute Geometry Algorithm Libary 计算几何算法库",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "0.1.0",
4
+ "description": "Computational geometry algorithms for JavaScript and TypeScript",
5
+ "main": "./dist/index.cjs",
6
+ "types": "./dist/index.d.ts",
7
7
  "scripts": {
8
- "pxy": "hpts -s 127.0.0.1:5006 -p 8002",
9
- "release": "tsc && npm publish && git.sh",
10
- "dev": "webpack-dev-server",
11
- "build:dev": "webpack --mode development",
12
- "build:prod": "webpack --mode production",
13
- "build": "tsc && rollup -c",
14
- "rollup": "rollup -c",
15
- "docs:dev": "vuepress dev docs",
16
- "docs:build": "vuepress build docs",
17
- "deploy": "tsc && deploy.sh"
8
+ "build": "node scripts/build.mjs",
9
+ "typecheck": "tsc --noEmit",
10
+ "test": "npm run build && node --test",
11
+ "test:coverage": "npm run build && node --experimental-test-coverage --test",
12
+ "dev": "vite --host 127.0.0.1",
13
+ "build:demo": "vite build",
14
+ "docs:dev": "vitepress dev docs",
15
+ "docs:build": "vitepress build docs",
16
+ "docs:preview": "vitepress preview docs",
17
+ "format": "node scripts/format.mjs --write",
18
+ "format:check": "node scripts/format.mjs",
19
+ "prepublishOnly": "npm run typecheck && npm test"
18
20
  },
19
21
  "private": false,
20
22
  "repository": {
21
23
  "type": "git",
22
- "url": "https://github.com/yszhao91/cga.js"
24
+ "url": "git+https://github.com/yszhao91/cga.js.git"
23
25
  },
24
26
  "author": "Zhao YS",
25
27
  "keywords": [
@@ -36,39 +38,49 @@
36
38
  ],
37
39
  "license": "MIT",
38
40
  "dependencies": {
39
- "decimal.js": "^10.3.1",
40
- "earcut": "^2.2.3"
41
+ "decimal.js": "^10.6.0",
42
+ "earcut": "^3.0.2"
41
43
  },
42
44
  "devDependencies": {
43
- "@babel/core": "^7.10.2",
44
- "@types/earcut": "^2.1.1",
45
- "@types/uuid": "^7.0.3",
46
- "bignumber.js": "^9.0.1",
47
- "clean-webpack-plugin": "^3.0.0",
48
- "copy-webpack-plugin": "^5.1.1",
49
- "core-js": "^2.6.12",
50
- "css-loader": "^3.5.3",
51
- "element-ui": "^2.15.8",
52
- "extract-text-webpack-plugin": "^4.0.0-beta.0",
53
- "html-loader": "^1.1.0",
54
- "html-webpack-plugin": "^4.2.0",
55
- "rollup": "^1.27.14",
56
- "rollup-plugin-babel": "^4.3.3",
57
- "rollup-plugin-commonjs": "^10.1.0",
58
- "rollup-plugin-dts": "^5.0.0",
59
- "rollup-plugin-gzip": "^2.2.0",
60
- "rollup-plugin-node-resolve": "^5.0.1",
61
- "rollup-plugin-uglify": "^6.0.4",
62
- "rollup-watch": "^4.3.1",
63
- "style-loader": "^1.2.1",
64
- "three": "^0.125.2",
65
- "ts-loader": "^7.0.4",
66
- "tsconfig-paths": "^3.9.0",
67
- "tsconfig-paths-webpack-plugin": "3.2.0",
68
- "typescript": "^4.9.4",
69
- "vuepress": "^1.9.7",
70
- "webpack": "^4.43.0",
71
- "webpack-cli": "^3.3.11",
72
- "webpack-dev-server": "^3.11.0"
45
+ "@types/node": "^24.10.0",
46
+ "@types/earcut": "^3.0.0",
47
+ "prettier": "3.10.1",
48
+ "rollup": "4.69.2",
49
+ "rollup-plugin-dts": "6.5.1",
50
+ "typescript": "6.0.3",
51
+ "vite": "8.4.1",
52
+ "vitepress": "2.0.0-alpha.21",
53
+ "vue": "3.5.46"
54
+ },
55
+ "module": "./dist/index.js",
56
+ "unpkg": "./build/@xort_cga.js",
57
+ "files": [
58
+ "dist",
59
+ "build",
60
+ "readme.md",
61
+ "LICENSE",
62
+ "THIRD_PARTY_NOTICES.md"
63
+ ],
64
+ "engines": {
65
+ "node": ">=22.12"
66
+ },
67
+ "type": "module",
68
+ "exports": {
69
+ ".": {
70
+ "import": {
71
+ "types": "./dist/index.d.ts",
72
+ "default": "./dist/index.js"
73
+ },
74
+ "require": {
75
+ "types": "./dist/index.d.cts",
76
+ "default": "./dist/index.cjs"
77
+ }
78
+ },
79
+ "./package.json": "./package.json"
80
+ },
81
+ "sideEffects": false,
82
+ "publishConfig": {
83
+ "access": "public",
84
+ "registry": "https://registry.npmjs.org/"
73
85
  }
74
86
  }
package/readme.md CHANGED
@@ -1,247 +1,162 @@
1
- # 3D 计算几何算法库(3D Computional Geometry Algorithm)
2
-
3
- inspire by Wild Magic
4
- threejs/cga.js 开发交流群:284389784
5
- 2020 年 12 月 10 日 开发很久 typescript 全新版本更新 可以根据自己的需要编译成 js 版
6
-
7
- ## 概要
8
-
9
- Computional Geometry Algorithm implement JavaScript,javascript 实现计算机几何算法库,实现比如像距离,相交,包含,偏移,平行垂直判断,正负位置等算法
10
-
11
- > **如果你需要计算几何类的算法还没实现,可以 issue 提出,获取 Q 群联系我,优先实现**
12
-
13
- ## 演示地址
14
-
15
- 案例:
16
-
17
- [ 国内镜像 ](https://gitee.com/yszhao91/cga.js)
18
-
19
- [文档与演示(github)](https://yszhao91.github.io/cga.js/)
20
-
21
- - [点与其他元素的距离 https://yszhao91.github.io/cga.js/guide/distPointAll.html](https://yszhao91.github.io/cga.js/guide/distPointAll.html)
22
- - [线与其他元素的距离 https://yszhao91.github.io/cga.js/guide/distLineAll.html](https://yszhao91.github.io/cga.js/guide/distLineAll.html)
23
- - [射线与其他元素的距离 https://yszhao91.github.io/cga.js/guide/distRayAll.html](https://yszhao91.github.io/cga.js/guide/distRayAll.html)
24
- - [线段与其他元素的距离 https://yszhao91.github.io/cga.js/guide/distSegmentAll.html](https://yszhao91.github.io/cga.js/guide/distSegmentAll.html)
25
- - [常用 https://yszhao91.github.io/cga.js/guide/%E5%B8%B8%E7%94%A8.html](https://yszhao91.github.io/cga.js/guide/%E5%B8%B8%E7%94%A8.html)
26
-
27
- ## 安装
28
-
29
- ```
30
- npm i @xort/cga
31
- 国内
32
- cnpm i @xort/cga
33
- ```
34
-
35
- ## 使用
36
-
37
- - 全部引用;:
38
-
39
- ```javascript
40
- import * as cga from "@xort/cga";
41
- function randomV3() {
42
- return cga.v3(
43
- Math.random() * 100 - 50,
44
- Math.random() * 100,
45
- Math.random() * 100 - 50
46
- );
47
- }
48
-
49
- var point = new cga.Point().copy(randomV3());
50
- var seg = new cga.Segment(randomV3(), randomV3());
51
- var result = point.distanceSegment(seg);
52
- ```
53
-
54
- - 按需求引用:
55
-
56
- ```javascript
57
- import { v3, Point, Segment } from "@xort/cga";
58
- function randomV3() {
59
- return v3(
60
- Math.random() * 100 - 50,
61
- Math.random() * 100,
62
- Math.random() * 100 - 50
63
- );
64
- }
65
-
66
- var point = new Point().copy(randomV3());
67
- var seg = new Segment(randomV3(), randomV3());
68
- var result = point.distanceSegment(seg);
69
- ```
70
-
71
- - 网页嵌入:直接下载使用 build 目录下面的 @xort/cga,包含到项目中
72
-
73
- ```html
74
- <script src="@xort/@xort_cga.js" />
75
- 或者
76
- <script src="https://raw.githack.com/yszhao91/@xort/cga/master/build/@xort_cga.js" />
77
- <script>
78
- var point = new cga.Point(1, 2, 3);
79
- var line = new cga.Line(
80
- new cga.Vector3(10, 10, 20),
81
- new cga.Vector3(20, 15, 10)
82
- );
83
- var result = point.distanceLine(line);
84
- </script>
85
- ```
86
-
87
- ## 项目编译
88
-
89
- ```shell
90
- npm run build //js 编译到build目录下生成@xort/cga dist目录下生成每个文件的js和.d.ts
91
- npm run dev //运行项目,自己更改源码测试
92
- ```
93
-
94
- ## 对象的类名
95
-
96
- 1. 点:**Point**
97
- 2. 直线:**Line**
98
- 3. 射线:**Ray**
99
- 4. 线段:**Segment**
100
- 5. 圆圈:**Circle**
101
- 6. 平面:**Plane**
102
- 7. 三角形:**Triangle**
103
- 8. 矩形:**Rectangle**
104
- 9. 圆盘:**Disk**
105
- 10. 球体:**Sphere**
106
- 11. 胶囊体: **Capsule**
107
- 12. 包围盒:**Box**
108
-
109
- ## 已经实现算法
110
-
111
- ### 在同一平面点集的凸包
112
-
113
- [](./cga/img/点与射线.png)
114
-
115
- > 已完成
116
- >
117
- > ![凸包](./docs/.vuepress/public/plane-set-convex.png)
118
- >
119
- > ```js
120
- > var convexHull = new ConvexHull(points, { planeNormal: cga.Vector3.UnitZ });
121
- > var hull = convexHull.hull;
122
- > ```
123
-
124
- ### delauny 三角网构建
125
-
126
- > ```js
127
- > var vs = [];
128
- > var data = [];
129
- > for (let i = 0; i < 10000; i++) {
130
- > var x = Math.random() * 1000 - 500;
131
- > var y = Math.random() * 1000 - 500;
132
- > vs.push(new Vec3(x, y, 0));
133
- > data.push(x, y);
134
- > }
135
- >
136
- > var delaunator = Delaunator.from(data);
137
- > // 或者
138
- > var delaunator = Delaunator.fromVecs(vs);
139
- > var index = delaunator.triangles; //三角形索引
140
- > ```
141
-
142
- ### voronoi 图构建
143
-
144
- > 完成
145
-
146
- ### 最近点对问题
147
-
148
- 点集合中最近找出距离最近的一对点 算法时间 O(nlogn)
149
-
150
- > 完成
151
-
152
- <!-- **分治法求解**
153
-
154
- - 分解
155
- > 对所有的点按照 x 坐标(或者 y)从小到大排序(排序方法时间复杂度 O(nlogn)O(nlogn)O(nlogn))。
156
- > 根据下标进行分割,使得点集分为两个集合。
157
- - 解决
158
- > 递归的寻找两个集合中的最近点对。
159
- > 取两个集合最近点对中的最小值 min(disleft,disright) min(dis*{left}, dis*{right}) min(disleft ,disright)。
160
- - 合并
161
- > 最近距离不一定存在于两个集合中,可能一个点在集合 A,一个点在集合 B,而这两点间距离小于 dis。 -->
162
-
163
- ### 折线或者路径简化
164
-
165
- ```js
166
- 折线或者路径中过密或者过直的点去除;
167
- (2020 年 1 月 17 增加)
168
- /**
169
- * 简化点集数组,折线,路径
170
- * @param {*} points 点集数组,折线,路径 ,继承Array
171
- * @param {*} maxDistance 简化最大距离 默认值0.1
172
- * @param {*} maxAngle 简化最大角度 弧度 默认值 Math.PI / 180 * 5
173
- */
174
- simplifyPointList(points, maxDistance, maxAngle);
175
- ```
176
-
177
- ### 距离
178
-
179
- 一级目录与二级目录存在相应距离算法关系
180
-
181
- - Point
182
- - Point
183
- - Line
184
- - Ray
185
- - Segment
186
- - Circle
187
- - Plane
188
- - Triangle
189
- - Rectangle
190
- - Disk
191
- - Sphere
192
- - Capsule
193
- - Line
194
- - Line
195
- - Ray
196
- - Segment
197
- - Triangle (2020 年 1 月 17 增加)
198
- - Ray
199
- - Ray
200
- - Segment
201
- - Triangle (2020 年 1 月 17 增加)
202
- - Segment
203
- - Segment
204
-
205
- ### 相交
206
-
207
- > 相交可以使用距离算法来实现,准确的说距离中的 closets 最近点在 distance 为 0(小于 1e-4,精度可以自定义)的时候也就是交点,parameters 表为 0 或 1 可以判断为端点相交
208
-
209
- ### 偏移
210
-
211
- - Segment
212
-
213
- ### 切割
214
-
215
- - Segment
216
- - Segment
217
- - Plane
218
- - Segment
219
- - Triangle
220
-
221
- ## 参考文章
222
-
223
- [计算机几何算法(CGA)专栏 https://zhuanlan.zhihu.com/c_1196384168014368768](https://zhuanlan.zhihu.com/c_1196384168014368768)
224
-
225
- ## 展望
226
-
227
- 项目将会不断完善,如果你有好的想好可以提交你的想法。欢迎 star,让项目更进一步
228
-
229
- ## 讨论
230
-
231
- > QQ 群:284389784 by: 贵阳赵耀圣
232
-
233
- > 本人 2013 接触从事 webgl/threejs 工作,开发经验 7 年左右,一直以来都想着开源,结交更多志同道合的朋友,可接 threejs 项目
234
-
235
- > 其他开源项目 看我的 github 主页 地址:[https://github.com/yszhao91](https://github.com/yszhao91) 欢迎大家 follow star,希望开源能帮到大家
236
-
237
- ## 吃包子
238
-
239
- 如果觉得这个项目对你有帮助,可以请我吃个包子
240
-
241
- 支付宝:
242
-
243
- ![1640758500266.png](image/readme/1640758500266.png)
244
-
245
- 微信:
246
-
247
- ![1640758513361.png](image/readme/1640758513361.png)
1
+ # cga.js
2
+
3
+ JavaScript / TypeScript 计算几何库,面向 Web 图形、三维编辑器和几何数据处理。自带向量、矩阵与四元数;核心计算不依赖 Three.js、DOM 或 WebGL。
4
+
5
+ Computational geometry for JavaScript and TypeScript: distances with closest points, intersections, clipping, triangulation and point clouds.
6
+
7
+ [文档与示例](https://yszhao91.github.io/cga.js/) · [算法与接口说明](docs/guide/api.md) · [迁移说明](docs/guide/migration.md) · [审核记录](docs/guide/audit.md) · [Issues](https://github.com/yszhao91/cga.js/issues)
8
+
9
+ ## 安装
10
+
11
+ ```sh
12
+ npm install @xort/cga
13
+ ```
14
+
15
+ 包名是 **`@xort/cga`**。本指南对应 `0.1.0`;从旧版升级前请阅读[迁移说明](docs/guide/migration.md)。
16
+
17
+ ## 快速开始
18
+
19
+ ```ts
20
+ import { v3, Segment, Plane, distance, intersects } from '@xort/cga';
21
+
22
+ const point = v3(1, 2, 0);
23
+ const segment = new Segment(v3(0, 0, 0), v3(4, 0, 0));
24
+ const result = distance(point, segment);
25
+
26
+ console.log(result.distance); // 2
27
+ console.log(result.distanceSqr); // 4
28
+ console.log(result.closests[0]); // (1, 2, 0),属于 point
29
+ console.log(result.closests[1]); // (1, 0, 0),属于 segment
30
+ console.log(result.parameters); // [0, 0.25]
31
+
32
+ // 直接调用几何体方法也返回相同的距离结果结构
33
+ point.distanceSegment(segment);
34
+ segment.distancePoint(point);
35
+
36
+ // 平面方程:normal.dot(p) + w = 0,此处为 y = 1
37
+ const plane = new Plane(v3(0, 1, 0), -1);
38
+ console.log(intersects(segment, plane)); // false
39
+ console.log(plane.signedDistanceToPoint(point)); // 1
40
+ ```
41
+
42
+ CommonJS:
43
+
44
+ ```js
45
+ const { v3, Segment, distance } = require('@xort/cga');
46
+ console.log(distance(v3(1, 2, 0), new Segment(v3(), v3(4, 0, 0))).distance);
47
+ ```
48
+
49
+ 浏览器直接引用:构建后复制 `build/@xort_cga.js`,通过全局对象 `cga` 使用。
50
+
51
+ ```html
52
+ <script src="./build/@xort_cga.js"></script>
53
+ <script>
54
+ const result = cga.distance(cga.v3(1, 2, 0), new cga.Segment(cga.v3(), cga.v3(4, 0, 0)));
55
+ console.log(result.distance); // 2
56
+ </script>
57
+ ```
58
+
59
+ ## 统一接口与约定
60
+
61
+ 基础几何体实现 `GeometryQuery<T>`:稳定的 `kind` 标识、`copy(source)`、`clone()`、`distancePoint(point)` 和 `toJSON()`。各类 `set(...)` 和 `copy(...)` 修改自身并返回自身;构造器和 `clone()` 拥有独立坐标。线段、三角形、矩形采用固定顶点集合,不继承 Array,保留索引、迭代与 map 访问。`Point` / `Vec3` 可直接作为点使用。
62
+
63
+ 所有距离查询返回完整的 `DistanceResult`:
64
+
65
+ ```ts
66
+ interface DistanceResult {
67
+ distance: number; // 非负
68
+ distanceSqr: number; // distance 的平方
69
+ closests: Vec3[]; // [调用者上的点, 参数对象上的点]
70
+ parameters: Array<number | number[]>; // 与最近点同序
71
+ signedDistance?: number;
72
+ interior?: boolean;
73
+ // 另有 triangleParameters、rectangleParameters、segmentIndex 等补充字段
74
+ }
75
+ ```
76
+
77
+ - `Line(origin, end)` 的第二个参数是另一个点;`Ray(origin, direction)` 的第二个参数是方向。
78
+ - 直线参数无界,射线参数非负,线段参数统一为 `[0, 1]`。三角形使用重心坐标。
79
+ - `Plane` 统一使用 `n·p + w = 0`,允许非单位法线;数字形式的有符号距离使用 `signedDistanceToPoint`。
80
+ - 球体、胶囊体和包围盒按闭合实体计算。内部或重叠距离为 `0`;球体与胶囊体的轴线间隙保存在 `signedDistance`。
81
+ - 圆圈是整条圆周,圆盘是填充圆面。`Circle` 的距离查询目前针对完整圆周,不按弧度字段裁剪。
82
+ - 距离查询不修改输入。线段和矩形的派生属性随顶点实时推导,不保留容易失效的缓存。
83
+
84
+ 接口变化与旧调用迁移见[迁移说明](docs/guide/migration.md)。
85
+
86
+ ## 算法覆盖
87
+
88
+ 下面的核心集合支持任意两者之间的 `distance(a, b)` 和 `intersects(a, b)`,包含正反查询:
89
+
90
+ **点、直线、射线、线段、平面、三角形、矩形、球体、胶囊体、轴对齐包围盒。**
91
+
92
+ | 类别 | 入口 | 范围 |
93
+ | ------------------ | ------------------------------------------------------------------------- | -------------------------------------------------------- |
94
+ | 最近距离与最近点 | `distance(a, b)` / `a.distanceX(b)` | 核心集合全部组合;零长度线段、退化三角形、平行和共面情形 |
95
+ | 圆圈、圆盘距离 | `point.distanceCircle / distanceDisk` | 任意平面上的点到完整圆圈、圆盘 |
96
+ | 求交 | `intersects`、`intersectPlane`、`intersectSegment` | 容差判断、直线/射线与平面、线段交点与共线重叠端点 |
97
+ | 平面切割 | `splitSegment / splitTriangle / splitConvexPolygon / Plane.splitGeometry` | 有序顶点;网格属性插值;切口不封盖 |
98
+ | 多边形包含 | `Polygon.containsPoint` | 共面简单多边形,边界包含在内 |
99
+ | 多边形布尔 | `clipPolygons` | 交、并、差、异或;支持共面轮廓与孔洞,偶奇填充 |
100
+ | 清理与偏移 | `cleanPolygon / simplifyPolygon / offsetPaths` | Clipper,整数缩放;支持多轮廓输出 |
101
+ | 三角剖分 | `triangulation` | Earcut,支持孔洞、XY/XZ/YZ 和法线投影 |
102
+ | Delaunay / Voronoi | `Delaunator`、`Delaunay`、`delaunay.voronoi` | 二维平面点集,裁剪单元多边形 |
103
+ | 凸包 | `convexHull`、`ConvexHull` | 共面三维点集,单调链 `O(n log n)` |
104
+ | 最近点对 | `closestPair` | 精确三维距离,扫描剪枝,最坏 `O(n²)` |
105
+ | 点集操作 | `projectOnPlane / reverseOnPlane / simplifyPointList` | 投影、镜像、折线简化 |
106
+ | 网格与数学 | `extrude` 相关函数、`calculateVolume`、`Vec* / Mat* / Quat` | 挤出、闭合定向三角网格体积、基础数学 |
107
+
108
+ 圆圈/圆盘与其他面体之间的全部距离组合尚未提供;不支持的统一查询会抛出 `RangeError`。BTree 提供比较器索引,KdTree 提供三维最近邻/范围查询,QuadTree 提供二维空间查询;BSP/PolyTree 保留为通用容器。源码中的 GIS、IK、高精度 CSG 草稿不属于已验证的核心算法,详见[审核记录](docs/guide/audit.md)。
109
+
110
+ ## 更多示例
111
+
112
+ ```ts
113
+ import { v3, convexHull, closestPair, triangulation, Delaunay, clipPolygons } from '@xort/cga';
114
+
115
+ const boundary = [v3(), v3(4, 0, 0), v3(4, 4, 0), v3(0, 4, 0)];
116
+ const hole = [v3(1, 1, 0), v3(1, 2, 0), v3(2, 2, 0), v3(2, 1, 0)];
117
+ const indices = triangulation(boundary, [hole], { normal: v3(0, 0, 1) });
118
+ // 索引对应 [...boundary, ...hole],原始坐标不会被修改
119
+
120
+ const hull = convexHull([...boundary, v3(2, 2, 0)], v3(0, 0, 1));
121
+ const pair = closestPair(boundary); // parameters 是原始点数组中的两个索引
122
+ const contours = clipPolygons([boundary], [hole], 'difference');
123
+
124
+ // 输入是扁平的 [x0, y0, x1, y1, ...]
125
+ const delaunay = Delaunay.from([0, 0, 4, 0, 4, 4, 0, 4, 2, 2]);
126
+ const cells = [...delaunay.voronoi([-1, -1, 5, 5]).cellPolygons()];
127
+ ```
128
+
129
+ ## 开发与验证
130
+
131
+ 最低 Node.js 22.12,建议 Node.js 24。依赖通过 `package-lock.json` 锁定。
132
+
133
+ ```sh
134
+ npm ci
135
+ npm run typecheck
136
+ npm test
137
+ npm run test:coverage
138
+ npm run docs:build
139
+ npm pack --dry-run
140
+ ```
141
+
142
+ `npm run build` 生成:
143
+
144
+ | 路径 | 用途 |
145
+ | -------------------------------------- | ------------------------------------------ |
146
+ | `dist/index.js` / `dist/index.cjs` | 原生 ESM / CommonJS,通过 exports 自动选择 |
147
+ | `build/@xort_cga.js` | UMD,浏览器全局 `cga` |
148
+ | `build/cga.esm.js` | ES module,供打包工具使用 |
149
+ | `dist/index.d.ts` / `dist/index.d.cts` | ESM / CJS 对应类型声明 |
150
+ | `build/cga.d.ts` | 汇总声明 |
151
+
152
+ CI 在 Linux / Windows、Node.js 22 / 24 上执行类型检查、测试与包检查。测试包含已知解、参数重建、输入不变性、双向查询、退化案例和固定种子的随机对照。
153
+
154
+ 工具链已升级为 Vite 8、TypeScript 6、Vue 3 和固定版本的 VitePress 2 alpha;旧 Webpack/VuePress 构建已移除。架构、依赖选择及研究模块边界见[架构说明](docs/guide/architecture.md)。
155
+
156
+ ## 贡献与许可
157
+
158
+ 欢迎通过 [Issues](https://github.com/yszhao91/cga.js/issues) 提交算法需求和最小复现,或提交附带边界测试的 PR。新增算法请同步更新覆盖说明,并保持距离结果和最近点顺序一致。
159
+
160
+ 本项目采用 [MIT License](LICENSE)。集成的 Clipper 采用 Boost Software License,见 [第三方声明](THIRD_PARTY_NOTICES.md)。算法设计受到 Wild Magic / Geometric Tools 的启发。
161
+
162
+ [计算几何专栏](https://zhuanlan.zhihu.com/c_1196384168014368768) · QQ 交流群:284389784 · [作者主页](https://github.com/yszhao91)
@@ -1,12 +0,0 @@
1
- # These are supported funding model platforms
2
-
3
- github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
- patreon: # Replace with a single Patreon username
5
- open_collective: # Replace with a single Open Collective username
6
- ko_fi: # Replace with a single Ko-fi username
7
- tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
- community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
- liberapay: # Replace with a single Liberapay username
10
- issuehunt: # Replace with a single IssueHunt username
11
- otechie: # Replace with a single Otechie username
12
- custom: https://yszhao91.github.io/xtorcga/sponsor/