@xort/cga 0.0.85 → 0.0.87
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/build/cga.d.ts +2032 -0
- package/dist/IKanimation/CCDSolver.js +2 -2
- package/dist/IKanimation/constaint/hinge.js +3 -1
- package/dist/IKanimation/constaint/slider.js +3 -1
- package/dist/alg/common.js +2 -2
- package/dist/alg/delaunay.js +1 -1
- package/dist/alg/extrude.js +52 -50
- package/dist/alg/pointset.js +5 -5
- package/dist/alg/trianglution.js +12 -10
- package/dist/alg/voronoi.js +1 -1
- package/dist/app.js +14 -10
- package/dist/diamondMaterialShader.js +6 -2
- package/dist/effect/breath-light.js +3 -1
- package/dist/extends/geometryaid.js +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -2
- package/dist/math/Color.d.ts +4 -0
- package/dist/math/Color.js +30 -6
- package/dist/math/Euler.js +9 -9
- package/dist/math/Mat3.js +1 -1
- package/dist/math/Mat4.js +6 -6
- package/dist/math/Quat.js +1 -1
- package/dist/math/Vec3.js +4 -4
- package/dist/math/vecs.js +9 -7
- package/dist/render/bufferAttribute.js +12 -28
- package/dist/render/geometry.js +2 -2
- package/dist/render/mesh.js +11 -9
- package/dist/render/types.d.ts +2 -2
- package/dist/render/types.js +2 -1
- package/dist/struct/3d/Box.js +3 -3
- package/dist/struct/3d/Capsule.js +3 -1
- package/dist/struct/3d/Circle.d.ts +12 -3
- package/dist/struct/3d/Circle.js +34 -6
- package/dist/struct/3d/Disk.js +1 -1
- package/dist/struct/3d/Line.js +4 -4
- package/dist/struct/3d/Path.js +13 -11
- package/dist/struct/3d/Plane.d.ts +3 -3
- package/dist/struct/3d/Plane.js +23 -18
- package/dist/struct/3d/Point.js +3 -1
- package/dist/struct/3d/Polygon.js +3 -1
- package/dist/struct/3d/Polyline.d.ts +9 -0
- package/dist/struct/3d/Polyline.js +25 -2
- package/dist/struct/3d/Rectangle.js +3 -1
- package/dist/struct/3d/Segment.js +9 -7
- package/dist/struct/3d/Shape.js +3 -1
- package/dist/struct/3d/Sphere.js +1 -1
- package/dist/struct/3d/Triangle.js +3 -1
- package/dist/struct/bsp.d.ts +0 -0
- package/dist/struct/bsp.js +1 -0
- package/dist/struct/btree.d.ts +0 -0
- package/dist/struct/btree.js +1 -0
- package/dist/struct/data/ArrayList.js +11 -9
- package/dist/struct/data/ArrayObject.js +3 -1
- package/dist/struct/kdtree.d.ts +0 -0
- package/dist/struct/kdtree.js +1 -0
- package/dist/struct/polyTree.d.ts +4 -0
- package/dist/struct/polyTree.js +27 -0
- package/dist/struct/quatTree.d.ts +0 -0
- package/dist/struct/quatTree.js +1 -0
- package/dist/struct/tree.d.ts +11 -0
- package/dist/struct/tree.js +26 -0
- package/dist/utils/types.d.ts +2 -2
- package/package.json +4 -3
- package/rollup.config.js +22 -14
- package/src/index.ts +1 -0
- package/src/math/Color.ts +6 -0
- package/src/struct/3d/Circle.ts +37 -8
- package/src/struct/3d/Plane.ts +15 -11
- package/src/struct/3d/PolyLine.ts +18 -1
- package/src/struct/3d/Polygon.ts +2 -0
- package/src/struct/bsp.ts +0 -0
- package/src/struct/btree.ts +0 -0
- package/src/struct/kdtree.ts +0 -0
- package/src/struct/polyTree.ts +8 -0
- package/src/struct/quatTree.ts +0 -0
- package/src/struct/tree.ts +30 -0
- package/tsconfig.json +2 -0
- package/dist/shape/arc.d.ts +0 -2
- package/dist/shape/arc.js +0 -14
- package/src/shape/arc.ts +0 -14
package/src/struct/3d/Circle.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Vec3, v3 } from '../../math/Vec3';
|
|
2
|
-
import { angle, pointsCollinear } from '../../alg/common';
|
|
2
|
+
import { angle, pointsCollinear, rotate } from '../../alg/common';
|
|
3
3
|
import { Line } from './Line';
|
|
4
4
|
|
|
5
5
|
export class Circle {
|
|
6
6
|
startAngle: number = 0;
|
|
7
|
-
|
|
7
|
+
lengthAngle: number = Math.PI * 2;
|
|
8
8
|
radiusSqr: number = 0;
|
|
9
9
|
/**
|
|
10
10
|
* 圆圈
|
|
@@ -12,7 +12,9 @@ export class Circle {
|
|
|
12
12
|
* @param {Vec3} normal 法线
|
|
13
13
|
* @param {Number} radius 半径
|
|
14
14
|
*/
|
|
15
|
-
constructor(public center: Vec3 = new Vec3(), public radius: number = 0, public normal: Vec3 = Vec3.UnitY) {
|
|
15
|
+
constructor(public center: Vec3 = new Vec3(), public radius: number = 0, startAngle = 0, lengthAngle = Math.PI * 2, public normal: Vec3 = Vec3.UnitY) {
|
|
16
|
+
this.startAngle = startAngle;
|
|
17
|
+
this.lengthAngle = lengthAngle;
|
|
16
18
|
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -30,7 +32,7 @@ export class Circle {
|
|
|
30
32
|
arc1(fixp0: Vec3, fixp1: Vec3, movep: Vec3, normal?: Vec3) {
|
|
31
33
|
this.setFrom3Points(fixp0, fixp1, movep);
|
|
32
34
|
this.startAngle = 0
|
|
33
|
-
this.
|
|
35
|
+
this.lengthAngle = angle(fixp0.clone().sub(this.center).normalize(), fixp1.clone().sub(this.center).normalize(), this.normal || normal)
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* 全两个点确定半径,后面点确定 弧度 ,只需要检测鼠标移动时鼠标是否跨过第一条半径即可确定顺逆时针
|
|
@@ -47,8 +49,6 @@ export class Circle {
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
52
|
setFrom3Points(p0: Vec3, p1: Vec3, p2: Vec3, normal?: Vec3) {
|
|
53
53
|
// if (pointsCollinear(p0, p1, p2))
|
|
54
54
|
// throw ("calcCircleFromThreePoint:三点共线或者距离太近");
|
|
@@ -71,8 +71,37 @@ export class Circle {
|
|
|
71
71
|
this.normal = normal;
|
|
72
72
|
return this;
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 将圆环或者圆弧转化为路径点,生成XY平面上得三维点
|
|
78
|
+
* @param center 中心点
|
|
79
|
+
* @param radius 半径
|
|
80
|
+
* @param startAngle 起始角 右手坐标系 以X正坐标轴为起点 单位弧度
|
|
81
|
+
* @param lengthAngle 弧度长度 单位弧度
|
|
82
|
+
* @param segment 分段
|
|
83
|
+
*/
|
|
84
|
+
static toVertices(center: Vec3, radius: number, startAngle: number = 0, lengthAngle: number = Math.PI * 2, segment: number = 16) {
|
|
85
|
+
const Xvec: Vec3 = Vec3.UnitX;
|
|
86
|
+
Xvec.multiplyScalar(radius);
|
|
87
|
+
|
|
88
|
+
const result:Vec3[]=[]
|
|
89
|
+
|
|
90
|
+
const up: Vec3 = Vec3.UnitY;
|
|
91
|
+
const perAngle = lengthAngle / segment;
|
|
92
|
+
for (let i = 0; i <= segment; i++) {
|
|
93
|
+
const langlei = perAngle * i + startAngle;
|
|
94
|
+
|
|
95
|
+
const vi = Xvec.clone().applyAxisAngle(up, langlei).add(center);
|
|
96
|
+
|
|
97
|
+
result.push(vi);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
|
|
74
103
|
}
|
|
75
104
|
|
|
76
|
-
export function circle(center?: Vec3, radius?: number
|
|
77
|
-
return new Circle(center, radius
|
|
105
|
+
export function circle(center?: Vec3, radius?: number) {
|
|
106
|
+
return new Circle(center, radius);
|
|
78
107
|
}
|
package/src/struct/3d/Plane.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { IGeometry } from '../../render/geometry';
|
|
|
15
15
|
import { ISplitResult } from '../../alg/split';
|
|
16
16
|
import { Line } from './Line';
|
|
17
17
|
import { MeshTool } from '../../render/mesh';
|
|
18
|
+
import { Polygon } from './Polygon';
|
|
18
19
|
|
|
19
20
|
class Plane {
|
|
20
21
|
|
|
@@ -253,23 +254,26 @@ class Plane {
|
|
|
253
254
|
|
|
254
255
|
/**
|
|
255
256
|
* 平面切割线段
|
|
256
|
-
* @param
|
|
257
|
+
* @param polygon
|
|
257
258
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
MeshTool.indexable(
|
|
259
|
+
splitConvexPolygon(polygon: Vec3[]) {
|
|
260
|
+
polygon = [...polygon];
|
|
261
|
+
MeshTool.indexable(polygon);
|
|
261
262
|
|
|
262
263
|
let jd0 = -1;//找出第一个交点
|
|
263
264
|
let jdp0: any;//找出第一个交点
|
|
264
|
-
let lastOriention = this.orientationPoint(
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
let lastOriention = this.orientationPoint(polygon[0]);
|
|
266
|
+
const plen = polygon.length;
|
|
267
|
+
//分割点
|
|
268
|
+
const splitPoints = [];
|
|
269
|
+
const pVs = [];
|
|
270
|
+
const nVs = [];
|
|
271
|
+
for (let i = 1; i <= plen; i++) {
|
|
272
|
+
const v = polygon[i % plen];
|
|
267
273
|
const oriention = this.orientationPoint(v);
|
|
268
|
-
if (oriention === Orientation.Common
|
|
274
|
+
if (oriention === Orientation.Common ) {
|
|
269
275
|
jd0 = i;
|
|
270
|
-
jdp0 = v.clone();
|
|
271
|
-
lastOriention = oriention;
|
|
272
|
-
break;
|
|
276
|
+
jdp0 = v.clone();
|
|
273
277
|
}
|
|
274
278
|
lastOriention = oriention;
|
|
275
279
|
//TODO
|
|
@@ -6,7 +6,12 @@ import { Segment } from "./Segment";
|
|
|
6
6
|
import { ArrayList } from '../data/ArrayList';
|
|
7
7
|
import { Polygon } from "./Polygon";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export enum ClipType {
|
|
10
|
+
Intersection = 0,
|
|
11
|
+
Union = 1,
|
|
12
|
+
Difference = 2,
|
|
13
|
+
Xor = 3
|
|
14
|
+
};
|
|
10
15
|
/**
|
|
11
16
|
* 线段正反原则:右手坐标系中,所在平面为XZ平面,把指向方向看着负Z轴,x正为正方向,x负为负方向
|
|
12
17
|
*/
|
|
@@ -20,6 +25,18 @@ export class Polyline<T> extends ArrayList<T> {
|
|
|
20
25
|
this.isCoPlanar = true;
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
static CleanPolygon(polys: any, delta: number, jointype: JoinType = JoinType.Square, endtype: EndType = EndType.etClosedPolygon, limit: number) {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
static OffsetPaths(polys: any, delta: number, jointype: JoinType = JoinType.Square, endtype: EndType = EndType.etClosedPolygon, limit: number) {
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//转化为简单多边形 (无重复点,无相交的边 )不自交多边形
|
|
36
|
+
static SimplifyPolygon(polys: any, delta: number, jointype: JoinType = JoinType.Square, endtype: EndType = EndType.etClosedPolygon, limit: number) {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
23
40
|
/**
|
|
24
41
|
* 偏移
|
|
25
42
|
* @param {Number} distance 偏移距离
|
package/src/struct/3d/Polygon.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class Tree {
|
|
2
|
+
N: number = 2;//数量决定是N叉树;
|
|
3
|
+
children!: this[];
|
|
4
|
+
findFn!: Function;
|
|
5
|
+
objects: any[] = [];
|
|
6
|
+
|
|
7
|
+
constructor(N: number = -1) {
|
|
8
|
+
this.N = N;
|
|
9
|
+
if (N !== -1)
|
|
10
|
+
this.children = new Array(N)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
setObject(obj: any, generateFn: Function, findFn: Function) {
|
|
14
|
+
generateFn(this, obj);
|
|
15
|
+
this.findFn = findFn;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
add(obj: any) {
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
remove(obj: any) {
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
find(condition: any) {
|
|
27
|
+
|
|
28
|
+
this.findFn(this, condition);
|
|
29
|
+
}
|
|
30
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
// "checkJs": true, /* Report errors in .js files. */
|
|
16
16
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
17
17
|
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
18
|
+
// "declarationDir": "dist/types",
|
|
19
|
+
// "emitDeclarationOnly": true,
|
|
18
20
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
19
21
|
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
20
22
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
package/dist/shape/arc.d.ts
DELETED
package/dist/shape/arc.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @Description :
|
|
4
|
-
* @Author : 赵耀圣
|
|
5
|
-
* @QQ : 549184003
|
|
6
|
-
* @Date : 2021-03-15 09:40:01
|
|
7
|
-
* @LastEditTime : 2021-03-15 09:42:14
|
|
8
|
-
* @FilePath : \cga.js\src\shape\arc.ts
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.Circle = void 0;
|
|
12
|
-
function Circle(center, radius, segment, startAngle, lenAngle) {
|
|
13
|
-
}
|
|
14
|
-
exports.Circle = Circle;
|
package/src/shape/arc.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Description :
|
|
3
|
-
* @Author : 赵耀圣
|
|
4
|
-
* @QQ : 549184003
|
|
5
|
-
* @Date : 2021-03-15 09:40:01
|
|
6
|
-
* @LastEditTime : 2021-03-15 09:42:14
|
|
7
|
-
* @FilePath : \cga.js\src\shape\arc.ts
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { Vec3 } from "../math/Vec3";
|
|
11
|
-
|
|
12
|
-
export function Circle(center: Vec3, radius: number, segment: number, startAngle: number, lenAngle: number) {
|
|
13
|
-
|
|
14
|
-
}
|