@xort/cga 0.0.92 → 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.
- package/THIRD_PARTY_NOTICES.md +47 -0
- package/build/@xort_cga.js +14209 -14318
- package/build/cga.d.ts +2284 -1958
- package/build/cga.esm.js +14179 -0
- package/dist/THIRD_PARTY_NOTICES.md +47 -0
- package/dist/index.cjs +14320 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2358 -0
- package/dist/index.d.ts +2358 -38
- package/dist/index.js +14181 -56
- package/dist/index.js.map +1 -0
- package/package.json +59 -47
- package/readme.md +162 -247
- package/.github/FUNDING.yml +0 -12
- 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
- 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
- package/cga/2./347/202/271/344/270/216/351/235/242/346/200/247/345/205/203/347/264/240.md +0 -4
- package/cga/img//347/202/271/344/270/216/345/260/204/347/272/277.png +0 -0
- package/cga/img//347/202/271/344/270/216/347/233/264/347/272/277.png +0 -0
- package/cga/img//347/202/271/344/270/216/347/272/277/346/256/265.png +0 -0
- package/cga/img//347/233/264/347/272/277/347/232/204/350/241/250/350/276/276/345/274/217.png +0 -0
- package/deploy.sh +0 -39
- package/dist/IKanimation/Bone.d.ts +0 -7
- package/dist/IKanimation/Bone.js +0 -20
- package/dist/IKanimation/CCDSolver.d.ts +0 -37
- package/dist/IKanimation/CCDSolver.js +0 -93
- package/dist/IKanimation/Joint.d.ts +0 -3
- package/dist/IKanimation/Joint.js +0 -17
- package/dist/IKanimation/constaint/constraint.d.ts +0 -10
- package/dist/IKanimation/constaint/constraint.js +0 -25
- package/dist/IKanimation/constaint/hinge.d.ts +0 -12
- package/dist/IKanimation/constaint/hinge.js +0 -46
- package/dist/IKanimation/constaint/slider.d.ts +0 -12
- package/dist/IKanimation/constaint/slider.js +0 -44
- package/dist/IKanimation/index.d.ts +0 -0
- package/dist/IKanimation/index.js +0 -9
- package/dist/IKanimation/isolver.d.ts +0 -4
- package/dist/IKanimation/isolver.js +0 -10
- package/dist/IKanimation/skeleton.d.ts +0 -13
- package/dist/IKanimation/skeleton.js +0 -31
- package/dist/alg/common.d.ts +0 -114
- package/dist/alg/common.js +0 -302
- package/dist/alg/curve.d.ts +0 -4
- package/dist/alg/curve.js +0 -11
- package/dist/alg/delaunator.d.ts +0 -29
- package/dist/alg/delaunator.js +0 -442
- package/dist/alg/delaunay.d.ts +0 -20
- package/dist/alg/delaunay.js +0 -199
- package/dist/alg/delaunayslow.d.ts +0 -18
- package/dist/alg/delaunayslow.js +0 -140
- package/dist/alg/extrude/extrude.d.ts +0 -3
- package/dist/alg/extrude/extrude.js +0 -17
- package/dist/alg/extrude.d.ts +0 -199
- package/dist/alg/extrude.js +0 -728
- package/dist/alg/offset/index.d.ts +0 -0
- package/dist/alg/offset/index.js +0 -9
- package/dist/alg/offset.d.ts +0 -0
- package/dist/alg/offset.js +0 -472
- package/dist/alg/pointset.d.ts +0 -94
- package/dist/alg/pointset.js +0 -223
- package/dist/alg/recognition.d.ts +0 -14
- package/dist/alg/recognition.js +0 -37
- package/dist/alg/result.d.ts +0 -22
- package/dist/alg/result.js +0 -2
- package/dist/alg/segmentset.d.ts +0 -11
- package/dist/alg/segmentset.js +0 -45
- package/dist/alg/sort.d.ts +0 -2
- package/dist/alg/sort.js +0 -14
- package/dist/alg/split.d.ts +0 -8
- package/dist/alg/split.js +0 -10
- package/dist/alg/trianglution.d.ts +0 -15
- package/dist/alg/trianglution.js +0 -70
- package/dist/alg/vol.d.ts +0 -6
- package/dist/alg/vol.js +0 -18
- package/dist/alg/voronoi.d.ts +0 -31
- package/dist/alg/voronoi.js +0 -418
- package/dist/app.d.ts +0 -1
- package/dist/app.js +0 -248
- package/dist/basic/distance.d.ts +0 -12
- package/dist/basic/distance.js +0 -39
- package/dist/csg/bsp.d.ts +0 -9
- package/dist/csg/bsp.js +0 -22
- package/dist/csg/node.d.ts +0 -12
- package/dist/csg/node.js +0 -75
- package/dist/csg/polygon.d.ts +0 -43
- package/dist/csg/polygon.js +0 -161
- package/dist/diamondMaterialShader.d.ts +0 -92
- package/dist/diamondMaterialShader.js +0 -118
- package/dist/effect/breath-light.d.ts +0 -4
- package/dist/effect/breath-light.js +0 -39
- package/dist/extends/geometryaid.d.ts +0 -28
- package/dist/extends/geometryaid.js +0 -71
- package/dist/extends/split.d.ts +0 -3
- package/dist/extends/split.js +0 -13
- package/dist/glview.d.ts +0 -112
- package/dist/glview.js +0 -564
- package/dist/math/Color.d.ts +0 -33
- package/dist/math/Color.js +0 -235
- package/dist/math/Euler.d.ts +0 -46
- package/dist/math/Euler.js +0 -225
- package/dist/math/HVec3.d.ts +0 -43
- package/dist/math/HVec3.js +0 -176
- package/dist/math/Mat3.d.ts +0 -29
- package/dist/math/Mat3.js +0 -244
- package/dist/math/Mat4.d.ts +0 -85
- package/dist/math/Mat4.js +0 -791
- package/dist/math/Math.d.ts +0 -130
- package/dist/math/Math.js +0 -198
- package/dist/math/Quat.d.ts +0 -82
- package/dist/math/Quat.js +0 -418
- package/dist/math/Vec2.d.ts +0 -68
- package/dist/math/Vec2.js +0 -328
- package/dist/math/Vec3.d.ts +0 -240
- package/dist/math/Vec3.js +0 -1082
- package/dist/math/Vec4.d.ts +0 -81
- package/dist/math/Vec4.js +0 -475
- package/dist/math/vecs.d.ts +0 -134
- package/dist/math/vecs.js +0 -464
- package/dist/render/bufferAttribute.d.ts +0 -104
- package/dist/render/bufferAttribute.js +0 -344
- package/dist/render/geometry.d.ts +0 -87
- package/dist/render/geometry.js +0 -769
- package/dist/render/mesh.d.ts +0 -30
- package/dist/render/mesh.js +0 -87
- package/dist/render/types.d.ts +0 -3
- package/dist/render/types.js +0 -8
- package/dist/robust/plane.d.ts +0 -7
- package/dist/robust/plane.js +0 -17
- package/dist/robust/vec.d.ts +0 -15
- package/dist/robust/vec.js +0 -71
- package/dist/struct/3d/Box.d.ts +0 -23
- package/dist/struct/3d/Box.js +0 -109
- package/dist/struct/3d/Capsule.d.ts +0 -12
- package/dist/struct/3d/Capsule.js +0 -36
- package/dist/struct/3d/Circle.d.ts +0 -52
- package/dist/struct/3d/Circle.js +0 -138
- package/dist/struct/3d/Disk.d.ts +0 -10
- package/dist/struct/3d/Disk.js +0 -22
- package/dist/struct/3d/Frustum.d.ts +0 -35
- package/dist/struct/3d/Frustum.js +0 -159
- package/dist/struct/3d/Line.d.ts +0 -40
- package/dist/struct/3d/Line.js +0 -340
- package/dist/struct/3d/Path.d.ts +0 -75
- package/dist/struct/3d/Path.js +0 -308
- package/dist/struct/3d/Plane.d.ts +0 -74
- package/dist/struct/3d/Plane.js +0 -298
- package/dist/struct/3d/Point.d.ts +0 -4
- package/dist/struct/3d/Point.js +0 -30
- package/dist/struct/3d/Polygon.d.ts +0 -8
- package/dist/struct/3d/Polygon.js +0 -55
- package/dist/struct/3d/Polyline.d.ts +0 -34
- package/dist/struct/3d/Polyline.js +0 -130
- package/dist/struct/3d/Ray.d.ts +0 -21
- package/dist/struct/3d/Ray.js +0 -262
- package/dist/struct/3d/Rectangle.d.ts +0 -7
- package/dist/struct/3d/Rectangle.js +0 -35
- package/dist/struct/3d/Segment.d.ts +0 -32
- package/dist/struct/3d/Segment.js +0 -334
- package/dist/struct/3d/Shape.d.ts +0 -4
- package/dist/struct/3d/Shape.js +0 -27
- package/dist/struct/3d/Sphere.d.ts +0 -11
- package/dist/struct/3d/Sphere.js +0 -30
- package/dist/struct/3d/Triangle.d.ts +0 -8
- package/dist/struct/3d/Triangle.js +0 -53
- package/dist/struct/bsp.d.ts +0 -9
- package/dist/struct/bsp.js +0 -44
- package/dist/struct/btree.d.ts +0 -0
- package/dist/struct/btree.js +0 -1
- package/dist/struct/data/ArrayList.d.ts +0 -42
- package/dist/struct/data/ArrayList.js +0 -172
- package/dist/struct/data/ArrayObject.d.ts +0 -30
- package/dist/struct/data/ArrayObject.js +0 -131
- package/dist/struct/data/type.d.ts +0 -13
- package/dist/struct/data/type.js +0 -18
- package/dist/struct/kdtree.d.ts +0 -0
- package/dist/struct/kdtree.js +0 -1
- package/dist/struct/polyTree.d.ts +0 -4
- package/dist/struct/polyTree.js +0 -27
- package/dist/struct/quatTree.d.ts +0 -0
- package/dist/struct/quatTree.js +0 -1
- package/dist/struct/tree.d.ts +0 -11
- package/dist/struct/tree.js +0 -26
- package/dist/utils/array.d.ts +0 -24
- package/dist/utils/array.js +0 -89
- package/dist/utils/types.d.ts +0 -24
- package/dist/utils/types.js +0 -20
- package/docs/.vuepress/components/distance.vue +0 -125
- package/docs/.vuepress/components/intersect.vue +0 -0
- package/docs/.vuepress/components/trianglution.vue +0 -121
- package/docs/.vuepress/components/utils.js +0 -314
- package/docs/.vuepress/config.js +0 -99
- package/docs/.vuepress/enhanceApp.js +0 -13
- package/docs/.vuepress/public/delaunay.png +0 -0
- package/docs/.vuepress/public/logo.png +0 -0
- package/docs/.vuepress/public/plane-set-convex.png +0 -0
- package/docs/.vuepress/public/sponsor/alipay.jpg +0 -0
- package/docs/.vuepress/public/sponsor/wechat.png +0 -0
- package/docs/README.md +0 -14
- package/docs/demo/README.md +0 -9
- package/docs/guide/README.md +0 -94
- package/docs/guide/array.md +0 -10
- package/docs/guide/cy/trianglution.html +0 -2
- package/docs/guide/distLineAll.md +0 -85
- package/docs/guide/distPointAll.md +0 -137
- package/docs/guide/distRayAll.md +0 -69
- package/docs/guide/distSegmentAll.md +0 -19
- package/docs/guide/point.vue +0 -12
- package/docs/guide/vector.md +0 -10
- package/docs/guide//345/270/270/347/224/250.md +0 -156
- package/docs/sponsor/README.md +0 -15
- 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
- package/effect/common.glsl +0 -34
- package/effect/drawing.glsl +0 -36
- package/effect/shape.arc.glsl +0 -13
- package/effect/shape.circle.glsl +0 -13
- package/effect/shape.grid.glsl +0 -42
- package/effect/shape.line.glsl +0 -18
- package/effect/shape.pie.glsl +0 -18
- package/effect/shape.plot.glsl +0 -10
- package/effect/shape.poly.glsl +0 -15
- package/effect/shape.rect.glsl +0 -14
- package/effect/shape.rectround.glsl +0 -15
- package/effect/shape.segment.glsl +0 -10
- package/effect/shape.spiral.glsl +0 -12
- package/effect/shape.star.glsl +0 -16
- package/examples/index.html +0 -31
- package/git.sh +0 -12
- package/gitproxy.sh +0 -6
- package/image/readme/1640758500266.png +0 -0
- package/image/readme/1640758513361.png +0 -0
- package/index.html +0 -14
- package/linear algorithm//346/225/260/345/255/246/350/241/250/350/276/276/345/274/217.md" +0 -122
- package/linear algorithm//347/237/251/351/230/265.md" +0 -91
- package/rollup.config.js +0 -79
- package/scripttest.html +0 -23
- package/src/IKanimation/Bone.ts +0 -20
- package/src/IKanimation/CCDSolver.ts +0 -114
- package/src/IKanimation/Joint.ts +0 -13
- package/src/IKanimation/constaint/constraint.ts +0 -23
- package/src/IKanimation/constaint/hinge.ts +0 -29
- package/src/IKanimation/constaint/slider.ts +0 -25
- package/src/IKanimation/index.ts +0 -8
- package/src/IKanimation/isolver.ts +0 -13
- package/src/IKanimation/skeleton.ts +0 -30
- package/src/alg/common.ts +0 -304
- package/src/alg/curve.ts +0 -9
- package/src/alg/delaunator.ts +0 -519
- package/src/alg/delaunay.ts +0 -163
- package/src/alg/delaunayslow.ts +0 -183
- package/src/alg/extrude/extrude.ts +0 -19
- package/src/alg/extrude.ts +0 -941
- package/src/alg/offset/index.ts +0 -8
- package/src/alg/offset.ts +0 -501
- package/src/alg/pointset.ts +0 -219
- package/src/alg/recognition.ts +0 -43
- package/src/alg/result.ts +0 -24
- package/src/alg/segmentset.ts +0 -44
- package/src/alg/sort.ts +0 -11
- package/src/alg/split.ts +0 -15
- package/src/alg/trianglution.ts +0 -53
- package/src/alg/vol.ts +0 -18
- package/src/alg/voronoi.ts +0 -303
- package/src/app.css +0 -12
- package/src/app.ts +0 -285
- package/src/assets/color.jpg +0 -0
- package/src/basic/distance.ts +0 -40
- package/src/clipper/clipper.d.ts +0 -323
- package/src/clipper/clipper.js +0 -7626
- package/src/clipper/clipper_float.js +0 -185
- package/src/clipper/clipper_float_unminified.js +0 -5639
- package/src/clipper/clipperint.js +0 -7626
- package/src/csg/bsp.ts +0 -24
- package/src/csg/csg.js +0 -583
- package/src/csg/node.ts +0 -91
- package/src/csg/polygon.ts +0 -177
- package/src/diamondMaterialShader.ts +0 -93
- package/src/effect/breath-light.ts +0 -24
- package/src/extends/geometryaid.ts +0 -86
- package/src/extends/split.ts +0 -15
- package/src/glview.ts +0 -570
- package/src/index.ts +0 -47
- package/src/math/Color.ts +0 -225
- package/src/math/Euler.ts +0 -238
- package/src/math/HVec3.ts +0 -1144
- package/src/math/Mat3.ts +0 -365
- package/src/math/Mat4.ts +0 -1134
- package/src/math/Math.ts +0 -213
- package/src/math/Quat.ts +0 -536
- package/src/math/Vec2.ts +0 -408
- package/src/math/Vec3.ts +0 -1307
- package/src/math/Vec4.ts +0 -587
- package/src/math/vecs.ts +0 -486
- package/src/render/bufferAttribute.ts +0 -491
- package/src/render/geometry.ts +0 -1329
- package/src/render/mesh.ts +0 -82
- package/src/render/types.ts +0 -17
- package/src/robust/plane.ts +0 -12
- package/src/robust/readme.md +0 -1
- package/src/robust/vec.ts +0 -61
- package/src/shader/cga.glsl +0 -202
- package/src/shader/common.glsl +0 -87
- package/src/shader/noise/GLSL-Noise.md +0 -1108
- package/src/shader/noise/cellular2D.glsl +0 -69
- package/src/shader/noise/cellular2x2.glsl +0 -64
- package/src/shader/noise/cellular2x2x2.glsl +0 -88
- package/src/shader/noise/cellular3D.glsl +0 -187
- package/src/shader/noise/classicnoise2D.glsl +0 -113
- package/src/shader/noise/classicnoise3D.glsl +0 -177
- package/src/shader/noise/classicnoise4D.glsl +0 -302
- package/src/shader/noise/noise2D.glsl +0 -71
- package/src/shader/noise/noise3D.glsl +0 -103
- package/src/shader/noise/noise3Dgrad.glsl +0 -111
- package/src/shader/noise/noise4D.glsl +0 -129
- package/src/shader/noise/psrdnoise2D.glsl +0 -462
- package/src/struct/3d/Box.ts +0 -124
- package/src/struct/3d/Capsule.ts +0 -18
- package/src/struct/3d/Circle.ts +0 -149
- package/src/struct/3d/Disk.ts +0 -22
- package/src/struct/3d/Frustum.ts +0 -189
- package/src/struct/3d/Line.ts +0 -378
- package/src/struct/3d/Path.ts +0 -314
- package/src/struct/3d/Plane.ts +0 -341
- package/src/struct/3d/Point.ts +0 -7
- package/src/struct/3d/PolyLine.ts +0 -115
- package/src/struct/3d/Polygon.ts +0 -46
- package/src/struct/3d/Ray.ts +0 -285
- package/src/struct/3d/Rectangle.ts +0 -18
- package/src/struct/3d/Segment.ts +0 -330
- package/src/struct/3d/Shape.ts +0 -7
- package/src/struct/3d/Sphere.ts +0 -31
- package/src/struct/3d/Triangle.ts +0 -28
- package/src/struct/bsp.ts +0 -18
- package/src/struct/btree.ts +0 -0
- package/src/struct/data/ArrayList.ts +0 -144
- package/src/struct/data/ArrayObject.ts +0 -105
- package/src/struct/data/type.ts +0 -14
- package/src/struct/kdtree.ts +0 -0
- package/src/struct/polyTree.ts +0 -8
- package/src/struct/quatTree.ts +0 -0
- package/src/struct/tree.ts +0 -30
- package/src/utils/array.ts +0 -106
- package/src/utils/types.ts +0 -42
- package/src-gis/app.ts +0 -7
- package/src-gis/core/Cartographic.ts +0 -48
- package/src-gis/core/EllipsoidGeodesic.ts +0 -56
- package/src-gis/core/EllipsoidTerrainProvider.ts +0 -35
- package/src-gis/core/HeightmapTerrainData.ts +0 -5
- package/src-gis/core/Rectangle.ts +0 -112
- package/src-gis/core/TaskProcessor.ts +0 -222
- package/src-gis/gis.ts +0 -25
- package/src-gis/globe.ts +0 -54
- package/src-gis/math/Cartographic.ts +0 -24
- package/src-gis/math/GVec3.ts +0 -55
- package/src-gis/math/ellipsoid.ts +0 -13
- package/src-gis/provider/DcTerrainProvider.ts +0 -36
- package/src-gis/provider/TerrainProvider.ts +0 -12
- package/src-gis/scene/DcImageryProvider.ts +0 -36
- package/src-gis/scene/GeographicTilingScheme.ts +0 -65
- package/src-gis/scene/Globe.ts +0 -76
- package/src-gis/scene/GlobeSurfaceShaderSet.ts +0 -9
- package/src-gis/scene/GlobeSurfaceTileProvider.ts +0 -25
- package/src-gis/scene/ImageryLayerCollection.ts +0 -75
- package/src-gis/scene/ImageryProvider.ts +0 -28
- package/src-gis/scene/QuadtreeTile.ts +0 -162
- package/src-gis/scene/UrlTemplateImageryProvider.ts +0 -32
- package/src-gis/scene/quadtree_primitive.ts +0 -58
- package/tsconfig.json +0 -77
- package/webpack.config.js +0 -112
- package//350/256/241/347/256/227/345/207/240/344/275/225/351/227/256/351/242/230.md +0 -26
package/src/render/mesh.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Description :
|
|
3
|
-
* @Author : 赵耀圣
|
|
4
|
-
* @Q群 : 632839661
|
|
5
|
-
* @Date : 2020-12-10 15:01:42
|
|
6
|
-
* @LastEditTime : 2021-03-11 09:09:57
|
|
7
|
-
* @FilePath : \cga.js\src\render\mesh.ts
|
|
8
|
-
*/
|
|
9
|
-
import { Vec3 } from "../math/Vec3";
|
|
10
|
-
import { Vec2 } from "../math/Vec2";
|
|
11
|
-
import { flat, forall } from '../utils/array';
|
|
12
|
-
import { BufferGeometry } from "./geometry";
|
|
13
|
-
import { BufferAttribute } from "./bufferAttribute";
|
|
14
|
-
import { Vec4 } from "../math/Vec4";
|
|
15
|
-
import { TypedArray } from "./types";
|
|
16
|
-
import { triangulation } from "../alg/trianglution";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 网格工具
|
|
20
|
-
*/
|
|
21
|
-
export class MeshTool {
|
|
22
|
-
|
|
23
|
-
static indexable(obj: any[] | any, refIndexInfo = { index: 0 }, force = false) {
|
|
24
|
-
if (obj instanceof Array) {
|
|
25
|
-
for (var i = 0; i < obj.length; i++)
|
|
26
|
-
MeshTool.indexable(obj[i], refIndexInfo);
|
|
27
|
-
}
|
|
28
|
-
else if (obj instanceof Object) {
|
|
29
|
-
if (obj.index === undefined)
|
|
30
|
-
obj.index = refIndexInfo.index++;
|
|
31
|
-
else if (force)
|
|
32
|
-
obj.index = refIndexInfo.index++;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static triangListToBuffer(vertices: Vec3[], triangleList: Vec3[]) {
|
|
38
|
-
MeshTool.indexable(triangleList);
|
|
39
|
-
const indices: number[] = [];
|
|
40
|
-
forall(triangleList, (v: Vec3 | any) => {
|
|
41
|
-
indices.push(v.index);
|
|
42
|
-
})
|
|
43
|
-
return MeshTool.toGeoBuffer(vertices, indices);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 顶点纹理坐标所以转化为buffer数据
|
|
49
|
-
* @param {Array<Verctor3|Number>} vertices
|
|
50
|
-
* @param {Array<Number>} indices
|
|
51
|
-
* @param {Array<Verctor2|Number>} uvs
|
|
52
|
-
*/
|
|
53
|
-
static toGeoBuffer(vertices: BufferAttribute | Array<number | Vec2 | Vec3 | Vec4> | TypedArray, indices: number[] | Uint32Array | Uint16Array, uvs?: BufferAttribute | TypedArray | Array<Vec2 | number>): BufferGeometry {
|
|
54
|
-
const geometry = new BufferGeometry();
|
|
55
|
-
geometry.addAttribute('position', vertices, 3)
|
|
56
|
-
geometry.addAttribute('uv', uvs || new Float32Array(geometry.getAttribute('position').array.length / 3 * 2), 2)
|
|
57
|
-
geometry.setIndex(indices)
|
|
58
|
-
return geometry;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 三角剖分后转成几何体
|
|
65
|
-
* 只考虑XY平面
|
|
66
|
-
* @param {*} boundary
|
|
67
|
-
* @param {*} hole
|
|
68
|
-
* @param {*} options
|
|
69
|
-
*/
|
|
70
|
-
static trianglutionToGeometryBuffer(boundary: any, holes: any[] = [], options: any = { normal: Vec3.UnitZ }): BufferGeometry {
|
|
71
|
-
var triangles = triangulation(boundary, holes, options)
|
|
72
|
-
var vertices = [...boundary, ...flat(holes)]
|
|
73
|
-
var uvs: any = [];
|
|
74
|
-
|
|
75
|
-
vertices.forEach(v => {
|
|
76
|
-
uvs.push(v.x, v.z);
|
|
77
|
-
})
|
|
78
|
-
var geometry = MeshTool.toGeoBuffer(vertices, triangles, uvs);
|
|
79
|
-
|
|
80
|
-
return geometry;
|
|
81
|
-
}
|
|
82
|
-
}
|
package/src/render/types.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type TypedArray =
|
|
2
|
-
Int8Array
|
|
3
|
-
| Uint8Array
|
|
4
|
-
| Uint8ClampedArray
|
|
5
|
-
| Int16Array
|
|
6
|
-
| Uint16Array
|
|
7
|
-
| Int32Array
|
|
8
|
-
| Uint32Array
|
|
9
|
-
| Float32Array
|
|
10
|
-
| Float64Array;
|
|
11
|
-
|
|
12
|
-
export const isBufferArray = (obj: any) => {
|
|
13
|
-
var types = ['Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array']
|
|
14
|
-
return types.indexOf(obj.constructor.name) > -1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type TypedArrayLike = number[] | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array
|
package/src/robust/plane.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Vec } from './vec';
|
|
2
|
-
import Decimal from 'decimal.js';
|
|
3
|
-
export class Plane {
|
|
4
|
-
normal: Vec = new Vec(new Decimal(0), new Decimal(0), new Decimal(0));
|
|
5
|
-
w: Decimal;
|
|
6
|
-
constructor(point: Vec, normal: Vec) {
|
|
7
|
-
this.normal.copy(normal)
|
|
8
|
-
this.w = point.dot(normal).negated();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
package/src/robust/readme.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
## roubust algorithm 精确算法库
|
package/src/robust/vec.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import Decimal from 'decimal.js'
|
|
2
|
-
|
|
3
|
-
export class Vec {
|
|
4
|
-
|
|
5
|
-
_data: Array<Decimal> = []
|
|
6
|
-
constructor(..._vs: Decimal[]) {
|
|
7
|
-
for (let i = 0; i < _vs.length; i++) {
|
|
8
|
-
this._data[i] = _vs[i];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
copy(normal: Vec) {
|
|
12
|
-
for (let i = 0; i < normal.dim; i++)
|
|
13
|
-
this._data[i] = new Decimal(normal._data[i]);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get dim(): number {
|
|
17
|
-
return this._data.length;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
check(v: Vec) {
|
|
21
|
-
return this.dim === v.dim;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
cross(v: Vec) {
|
|
25
|
-
if (!this.check(v))
|
|
26
|
-
return;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get extentSq(): Decimal {
|
|
32
|
-
let res = new Decimal(0);
|
|
33
|
-
for (let i = 0; i < this._data.length; i++)
|
|
34
|
-
res = res.add(this._data[i].mul(this._data[i]))
|
|
35
|
-
|
|
36
|
-
return res;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 长度
|
|
41
|
-
*/
|
|
42
|
-
get extent(): Decimal {
|
|
43
|
-
let res = this.extentSq;
|
|
44
|
-
return res.squareRoot()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
dot(v: Vec): Decimal {
|
|
48
|
-
if (!this.check(v))
|
|
49
|
-
console.error('dim not equal')
|
|
50
|
-
|
|
51
|
-
let res = new Decimal(0);
|
|
52
|
-
for (let i = 0; i < this._data.length; i++) {
|
|
53
|
-
const ti = this._data[i];
|
|
54
|
-
const vi = v._data[i];
|
|
55
|
-
|
|
56
|
-
res = res.add(ti.mul(vi));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return res;
|
|
60
|
-
}
|
|
61
|
-
}
|
package/src/shader/cga.glsl
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/* Pixel unit conversion function */
|
|
2
|
-
vec2 pos(in float x, in float y) { return st + vec2(x * rx, y * rx); }
|
|
3
|
-
vec2 pos(in float x) { return pos(x, x); }
|
|
4
|
-
vec2 pos(in vec2 p) { return pos(p.x, p.y); }
|
|
5
|
-
float size(in float x) { return x * rx; }
|
|
6
|
-
vec2 size(in float x, in float y) { return vec2(x * rx, y * rx); }
|
|
7
|
-
|
|
8
|
-
/* Staggered animation */
|
|
9
|
-
struct Animation { float time; float pow; };
|
|
10
|
-
Animation animation = Animation(0.0, 0.0);
|
|
11
|
-
void totalTime(in float t, in float offset) { animation.time = mod(u_time + offset, t); }
|
|
12
|
-
void totalTime(in float t) { totalTime(t, 0.0); }
|
|
13
|
-
bool between(in float duration, in float offset) {
|
|
14
|
-
float p = (animation.time - offset) / duration;
|
|
15
|
-
animation.pow = p;
|
|
16
|
-
animation.time -= (duration + offset);
|
|
17
|
-
return (p >= 0.0 && p <= 1.0);
|
|
18
|
-
}
|
|
19
|
-
bool between(in float duration) { return between(duration, 0.0); }
|
|
20
|
-
|
|
21
|
-
/* Color palette */
|
|
22
|
-
#define BLACK vec3(0.0, 0.0, 0.0)
|
|
23
|
-
#define WHITE vec3(1.0, 1.0, 1.0)
|
|
24
|
-
#define RED vec3(1.0, 0.0, 0.0)
|
|
25
|
-
#define GREEN vec3(0.0, 1.0, 0.0)
|
|
26
|
-
#define BLUE vec3(0.0, 0.0, 1.0)
|
|
27
|
-
#define YELLOW vec3(1.0, 1.0, 0.0)
|
|
28
|
-
#define CYAN vec3(0.0, 1.0, 1.0)
|
|
29
|
-
#define MAGENTA vec3(1.0, 0.0, 1.0)
|
|
30
|
-
#define ORANGE vec3(1.0, 0.5, 0.0)
|
|
31
|
-
#define PURPLE vec3(1.0, 0.0, 0.5)
|
|
32
|
-
#define LIME vec3(0.5, 1.0, 0.0)
|
|
33
|
-
#define ACQUA vec3(0.0, 1.0, 0.5)
|
|
34
|
-
#define VIOLET vec3(0.5, 0.0, 1.0)
|
|
35
|
-
#define AZUR vec3(0.0, 0.5, 1.0)
|
|
36
|
-
|
|
37
|
-
/* Coordinate and unit utils */
|
|
38
|
-
vec2 coord(in vec2 p) {
|
|
39
|
-
p = p / u_resolution.xy;
|
|
40
|
-
// correct aspect ratio
|
|
41
|
-
if (u_resolution.x > u_resolution.y) {
|
|
42
|
-
p.x *= u_resolution.x / u_resolution.y;
|
|
43
|
-
p.x += (u_resolution.y - u_resolution.x) / u_resolution.y / 2.0;
|
|
44
|
-
} else {
|
|
45
|
-
p.y *= u_resolution.y / u_resolution.x;
|
|
46
|
-
p.y += (u_resolution.x - u_resolution.y) / u_resolution.x / 2.0;
|
|
47
|
-
}
|
|
48
|
-
// centering
|
|
49
|
-
p -= 0.5;
|
|
50
|
-
p *= vec2(-1.0, 1.0);
|
|
51
|
-
return p;
|
|
52
|
-
}
|
|
53
|
-
#define rx 1.0 / min(u_resolution.x, u_resolution.y)
|
|
54
|
-
#define uv gl_FragCoord.xy / u_resolution.xy
|
|
55
|
-
#define st coord(gl_FragCoord.xy)
|
|
56
|
-
#define mx coord(u_mouse)
|
|
57
|
-
|
|
58
|
-
/* Signed distance drawing methods */
|
|
59
|
-
float fill(in float d) { return 1.0 - smoothstep(0.0, rx * 2.0, d); }
|
|
60
|
-
float stroke(in float d, in float t) { return 1.0 - smoothstep(t - rx * 1.5, t + rx * 1.5, abs(d)); }
|
|
61
|
-
vec3 draw(in sampler2D t, in vec2 pos, in vec2 w) { vec2 s = w / 1.0; s.x *= -1.0; return texture2D(t, pos / s + 0.5).rgb; }
|
|
62
|
-
/* Field Adapted from https://www.shadertoy.com/view/XsyGRW */
|
|
63
|
-
vec3 field(float d) {
|
|
64
|
-
const vec3 c1 = mix(WHITE, YELLOW, 0.4);
|
|
65
|
-
const vec3 c2 = mix(WHITE, AZUR, 0.7);
|
|
66
|
-
const vec3 c3 = mix(WHITE, ORANGE, 0.9);
|
|
67
|
-
const vec3 c4 = BLACK;
|
|
68
|
-
float d0 = abs(stroke(mod(d + 0.1, 0.2) - 0.1, 0.004));
|
|
69
|
-
float d1 = abs(stroke(mod(d + 0.025, 0.05) - 0.025, 0.004));
|
|
70
|
-
float d2 = abs(stroke(d, 0.004));
|
|
71
|
-
float f = clamp(d * 0.85, 0.0, 1.0);
|
|
72
|
-
vec3 gradient = mix(c1, c2, f);
|
|
73
|
-
gradient = mix(gradient, c4, 1.0 - clamp(1.25 - d * 0.25, 0.0, 1.0));
|
|
74
|
-
gradient = mix(gradient, c3, fill(d));
|
|
75
|
-
gradient = mix(gradient, c4, max(d2 * 0.85, max(d0 * 0.25, d1 * 0.06125)) * clamp(1.25 - d, 0.0, 1.0));
|
|
76
|
-
return gradient;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* Shape 2D arc */
|
|
80
|
-
float sArc(in vec2 p,in float w,in float s,in float e){
|
|
81
|
-
float a=distance(p,w*.5*vec2(cos(s),sin(s)));
|
|
82
|
-
float x=-PI;
|
|
83
|
-
p*=mat2(cos(x-s),-sin(x-s),sin(x-s),cos(x-s));
|
|
84
|
-
float b=clamp(atan(p.y,p.x),x,x+e);
|
|
85
|
-
b=distance(p,w*.5*vec2(cos(b),sin(b)));
|
|
86
|
-
return min(a,b)*2.;
|
|
87
|
-
}
|
|
88
|
-
float arc(in vec2 p,in float w,in float s,in float e,in float t){
|
|
89
|
-
float d=sArc(p,w,s,e);
|
|
90
|
-
return stroke(d,t);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* Shape 2D poly */
|
|
94
|
-
float sPoly(in vec2 p, in float w, in int sides) {
|
|
95
|
-
float a = atan(p.x, p.y) + PI;
|
|
96
|
-
float r = TWO_PI / float(sides);
|
|
97
|
-
float side =
|
|
98
|
-
float d = cos(floor(0.5 + a / r) * r - a) * length(max(abs(p) * 1.0, 0.0));
|
|
99
|
-
return d * 2.0 - w;
|
|
100
|
-
}
|
|
101
|
-
float poly(in vec2 p, in float w, in int sides) {
|
|
102
|
-
float d = sPoly(p, w, sides);
|
|
103
|
-
return fill(d);
|
|
104
|
-
}
|
|
105
|
-
float poly(in vec2 p, in float w, in int sides, in float t) {
|
|
106
|
-
float d = sPoly(p, w, sides);
|
|
107
|
-
return stroke(d, t);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* Tiling function */
|
|
111
|
-
vec2 tile(in vec2 p, vec2 w) { return fract(mod(p + w / 2.0, w)) - (w / 2.0); }
|
|
112
|
-
vec2 tile(in vec2 p, float w) { return tile(p, vec2(w)); }
|
|
113
|
-
|
|
114
|
-
/* Boolean functions */
|
|
115
|
-
float sUnion(float a, float b) {
|
|
116
|
-
return min(a, b);
|
|
117
|
-
}
|
|
118
|
-
float sIntersect(float a, float b) {
|
|
119
|
-
return max(a, b);
|
|
120
|
-
}
|
|
121
|
-
float sDifference(float a, float b) {
|
|
122
|
-
return max(a, -b);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/* Math 2D Transformations */
|
|
126
|
-
mat2 rotate2d(in float angle){
|
|
127
|
-
return mat2(cos(angle),-sin(angle), sin(angle), cos(angle));
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/* Math 3D Transformations */
|
|
131
|
-
|
|
132
|
-
const mat4 projection = mat4(
|
|
133
|
-
vec4(3.0 / 4.0, 0.0, 0.0, 0.0),
|
|
134
|
-
vec4( 0.0, 1.0, 0.0, 0.0),
|
|
135
|
-
vec4( 0.0, 0.0, 0.5, 0.5),
|
|
136
|
-
vec4( 0.0, 0.0, 0.0, 1.0)
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
mat4 scale = mat4(
|
|
140
|
-
vec4(4.0 / 3.0, 0.0, 0.0, 0.0),
|
|
141
|
-
vec4( 0.0, 1.0, 0.0, 0.0),
|
|
142
|
-
vec4( 0.0, 0.0, 1.0, 0.0),
|
|
143
|
-
vec4( 0.0, 0.0, 0.0, 1.0)
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
mat4 rotation = mat4(
|
|
147
|
-
vec4(1.0, 0.0, 0.0, 0.0),
|
|
148
|
-
vec4(0.0, cos(u_time), sin(u_time), 0.0),
|
|
149
|
-
vec4(0.0, -sin(u_time), cos(u_time), 0.0),
|
|
150
|
-
vec4(0.0, 0.0, 0.0, 1.0)
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
mat4 rotationAxis(float angle, vec3 axis) {
|
|
154
|
-
axis = normalize(axis);
|
|
155
|
-
float s = sin(angle);
|
|
156
|
-
float c = cos(angle);
|
|
157
|
-
float oc = 1.0 - c;
|
|
158
|
-
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
|
|
159
|
-
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
|
|
160
|
-
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
|
|
161
|
-
0.0, 0.0, 0.0, 1.0);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
vec3 rotateX(vec3 p, float angle) {
|
|
165
|
-
mat4 rmy = rotationAxis(angle, vec3(1.0, 0.0, 0.0));
|
|
166
|
-
return (vec4(p, 1.0) * rmy).xyz;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
vec3 rotateY_(vec3 p, float angle) {
|
|
170
|
-
mat4 rmy = rotationAxis(angle, vec3(0.0, 1.0, 0.0));
|
|
171
|
-
return (vec4(p, 1.0) * rmy).xyz;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
vec3 rotateZ(vec3 p, float angle) {
|
|
175
|
-
mat4 rmy = rotationAxis(angle, vec3(0.0, 0.0, 1.0));
|
|
176
|
-
return (vec4(p, 1.0) * rmy).xyz;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
vec3 rotateY(vec3 p, float angle) {
|
|
180
|
-
float c = cos(angle);
|
|
181
|
-
float s = sin(angle);
|
|
182
|
-
mat4 r = mat4(
|
|
183
|
-
vec4(c, 0, s, 0),
|
|
184
|
-
vec4(0, 1, 0, 0),
|
|
185
|
-
vec4(-s, 0, c, 0),
|
|
186
|
-
vec4(0, 0, 0, 1)
|
|
187
|
-
);
|
|
188
|
-
return (vec4(p, 1.0) * r).xyz;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/* Object struct */
|
|
192
|
-
struct Object { float distance; vec3 color; };
|
|
193
|
-
Object object = Object(0.0, vec3(0.0));
|
|
194
|
-
|
|
195
|
-
/* Pixel unit conversion function */
|
|
196
|
-
vec2 pos(in float x,in float y){return st+vec2(x*rx,y*rx);}
|
|
197
|
-
vec2 pos(in float x){return pos(x,x);}
|
|
198
|
-
vec2 pos(in vec2 p){return pos(p.x,p.y);}
|
|
199
|
-
float size(in float x){return x*rx;}
|
|
200
|
-
vec2 size(in float x,in float y){return vec2(x*rx,y*rx);}
|
|
201
|
-
|
|
202
|
-
|
package/src/shader/common.glsl
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//点到点的距离
|
|
3
|
-
float dss(vec3 p0,vec3 p1){
|
|
4
|
-
vec3 d=p1-p0;
|
|
5
|
-
return d.x*d.x+d.y*d.y+d.z*d.z;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
//点到线段的距离
|
|
9
|
-
float dssps(vec3 p,vec3 sp0,vec3 sp1,out int isdawn){
|
|
10
|
-
vec3 diff=p-sp1;
|
|
11
|
-
vec3 extDir=sp1-sp0;
|
|
12
|
-
float t=dot(extDir,diff);
|
|
13
|
-
vec3 c;
|
|
14
|
-
if(t>=0.){
|
|
15
|
-
isdawn=1;
|
|
16
|
-
c=sp1;
|
|
17
|
-
}else{
|
|
18
|
-
diff=p-sp0;
|
|
19
|
-
t=dot(extDir,diff);
|
|
20
|
-
if(t<=0.){
|
|
21
|
-
isdawn=0;
|
|
22
|
-
c=sp0;
|
|
23
|
-
}
|
|
24
|
-
else{
|
|
25
|
-
isdawn=2;
|
|
26
|
-
float sqrLength=dss(sp0,sp1);
|
|
27
|
-
if(sqrLength<=0.)
|
|
28
|
-
sqrLength=0.;
|
|
29
|
-
|
|
30
|
-
t/=sqrLength;
|
|
31
|
-
c=extDir*t+sp0;
|
|
32
|
-
diff=p-c;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return length(diff);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
//点到路径的距离
|
|
40
|
-
float dsspss(vec3 p,in vec3 segs[100],out bool isdawn){
|
|
41
|
-
float threshold=-99.;
|
|
42
|
-
float u=100.;
|
|
43
|
-
if(segs[1].y<threshold)
|
|
44
|
-
return u;
|
|
45
|
-
|
|
46
|
-
int ipos;
|
|
47
|
-
for(int i=0;i<100;i++){
|
|
48
|
-
vec3 pti=segs[i];
|
|
49
|
-
if(pti.y<threshold)
|
|
50
|
-
break;
|
|
51
|
-
|
|
52
|
-
vec3 ptj=segs[i+1];
|
|
53
|
-
|
|
54
|
-
if(abs(pti.x-p.x)>u&&abs(ptj.x-p.x)>u&&(pti.x-p.x)*(ptj.x-p.x)>0.)
|
|
55
|
-
continue;
|
|
56
|
-
if(abs(pti.y-p.y)>u&&abs(ptj.y-p.y)>u&&(pti.y-p.y)*(ptj.y-p.y)>0.)
|
|
57
|
-
continue;
|
|
58
|
-
if(abs(pti.z-p.z)>u&&abs(ptj.z-p.z)>u&&(pti.z-p.z)*(ptj.z-p.z)>0.)
|
|
59
|
-
continue;
|
|
60
|
-
|
|
61
|
-
int onedawn=2;//非端点 0是前端点,1是后端点
|
|
62
|
-
float distance=dssps(p,pti,ptj,onedawn);
|
|
63
|
-
bool end=false;
|
|
64
|
-
if(segs[i+1].y<threshold)
|
|
65
|
-
end=true;
|
|
66
|
-
//if((i == 0 && onedawn ==0)||(i ==0 && onedawn == 1))
|
|
67
|
-
if((i==0&&onedawn==0)||(end&&onedawn==1))
|
|
68
|
-
isdawn=true;
|
|
69
|
-
if(distance<u){
|
|
70
|
-
u=distance;
|
|
71
|
-
ipos=i;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return u;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/* Boolean functions */
|
|
79
|
-
float sUnion(float a,float b){
|
|
80
|
-
return min(a,b);
|
|
81
|
-
}
|
|
82
|
-
float sIntersect(float a,float b){
|
|
83
|
-
return max(a,b);
|
|
84
|
-
}
|
|
85
|
-
float sDifference(float a,float b){
|
|
86
|
-
return max(a,-b);
|
|
87
|
-
}
|