@xort/cga 0.0.83 → 0.0.85
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/@xort_cga.js +871 -1010
- package/deploy.sh +13 -1
- package/dist/IKanimation/Bone.d.ts +1 -3
- package/dist/IKanimation/Bone.js +4 -22
- package/dist/alg/extrude.js +4 -4
- package/dist/extends/geometryaid.js +7 -15
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/math/Color.d.ts +2 -2
- package/dist/math/Color.js +24 -31
- package/dist/math/Euler.d.ts +4 -5
- package/dist/math/Euler.js +16 -34
- package/dist/math/HVec3.d.ts +1 -2
- package/dist/math/HVec3.js +13 -30
- package/dist/math/Quat.d.ts +1 -2
- package/dist/math/Quat.js +23 -43
- package/dist/math/Vec2.d.ts +4 -4
- package/dist/math/Vec2.js +7 -24
- package/dist/math/Vec3.d.ts +5 -9
- package/dist/math/Vec3.js +35 -52
- package/dist/math/Vec4.d.ts +4 -4
- package/dist/math/Vec4.js +11 -28
- package/dist/math/vecs.d.ts +19 -6
- package/dist/math/vecs.js +31 -1
- package/dist/render/{buffer-attribute.d.ts → bufferAttribute.d.ts} +8 -4
- package/dist/render/{buffer-attribute.js → bufferAttribute.js} +4 -0
- package/dist/render/geometry.d.ts +7 -9
- package/dist/render/geometry.js +22 -25
- package/dist/render/mesh.d.ts +23 -18
- package/dist/render/mesh.js +62 -57
- package/dist/render/types.d.ts +1 -0
- package/dist/struct/3d/Box.d.ts +1 -1
- package/dist/struct/3d/Plane.js +1 -1
- package/package.json +73 -73
- package/rollup.config.js +1 -1
- package/src/IKanimation/Bone.ts +1 -5
- package/src/alg/extrude.ts +6 -6
- package/src/app.ts +2 -10
- package/src/extends/geometryaid.ts +10 -13
- package/src/index.ts +2 -4
- package/src/math/Color.ts +18 -7
- package/src/math/Euler.ts +11 -12
- package/src/math/HVec3.ts +3 -5
- package/src/math/Quat.ts +18 -23
- package/src/math/Vec2.ts +7 -7
- package/src/math/Vec3.ts +37 -36
- package/src/math/Vec4.ts +9 -9
- package/src/math/vecs.ts +50 -8
- package/src/render/{buffer-attribute.ts → bufferAttribute.ts} +11 -4
- package/src/render/geometry.ts +18 -15
- package/src/render/mesh.ts +56 -54
- package/src/render/types.ts +2 -0
- package/src/struct/3d/Box.ts +1 -1
- package/src/struct/3d/Plane.ts +2 -4
- package/dist/math/Vec.d.ts +0 -7
- package/dist/math/Vec.js +0 -41
- package/dist/math/vector.d.ts +0 -114
- package/dist/math/vector.js +0 -371
- package/dist/render/eventhandler.d.ts +0 -78
- package/dist/render/eventhandler.js +0 -191
- package/dist/render/thing.d.ts +0 -34
- package/dist/render/thing.js +0 -194
- package/src/math/Vec.ts +0 -26
- package/src/render/eventhandler.ts +0 -196
- package/src/render/thing.ts +0 -204
package/package.json
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@xort/cga",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Xtor Compute Geometry Algorithm Libary 计算几何算法库",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
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"
|
|
18
|
-
},
|
|
19
|
-
"private": false,
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "https://github.com/yszhao91/cga.js"
|
|
23
|
-
},
|
|
24
|
-
"author": "Zhao YS",
|
|
25
|
-
"keywords": [
|
|
26
|
-
"cga",
|
|
27
|
-
"cgajs",
|
|
28
|
-
"cga.js",
|
|
29
|
-
"计算几何库",
|
|
30
|
-
"webgl",
|
|
31
|
-
"threejs",
|
|
32
|
-
"compute geometry algorithm",
|
|
33
|
-
"MIT",
|
|
34
|
-
"开源",
|
|
35
|
-
"gis"
|
|
36
|
-
],
|
|
37
|
-
"license": "MIT",
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
},
|
|
42
|
-
"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-gzip": "^2.2.0",
|
|
59
|
-
"rollup-plugin-node-resolve": "^5.0.1",
|
|
60
|
-
"rollup-plugin-uglify": "^6.0.4",
|
|
61
|
-
"rollup-watch": "^4.3.1",
|
|
62
|
-
"style-loader": "^1.2.1",
|
|
63
|
-
"three": "^0.125.2",
|
|
64
|
-
"ts-loader": "^7.0.4",
|
|
65
|
-
"tsconfig-paths": "^3.9.0",
|
|
66
|
-
"tsconfig-paths-webpack-plugin": "3.2.0",
|
|
67
|
-
"typescript": "^3.9.2",
|
|
68
|
-
"vuepress": "^1.9.7",
|
|
69
|
-
"webpack": "^4.43.0",
|
|
70
|
-
"webpack-cli": "^3.3.11",
|
|
71
|
-
"webpack-dev-server": "^3.11.0"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@xort/cga",
|
|
3
|
+
"version": "0.0.85",
|
|
4
|
+
"description": "Xtor Compute Geometry Algorithm Libary 计算几何算法库",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
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"
|
|
18
|
+
},
|
|
19
|
+
"private": false,
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/yszhao91/cga.js"
|
|
23
|
+
},
|
|
24
|
+
"author": "Zhao YS",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"cga",
|
|
27
|
+
"cgajs",
|
|
28
|
+
"cga.js",
|
|
29
|
+
"计算几何库",
|
|
30
|
+
"webgl",
|
|
31
|
+
"threejs",
|
|
32
|
+
"compute geometry algorithm",
|
|
33
|
+
"MIT",
|
|
34
|
+
"开源",
|
|
35
|
+
"gis"
|
|
36
|
+
],
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"decimal.js": "^10.3.1",
|
|
40
|
+
"earcut": "^2.2.3"
|
|
41
|
+
},
|
|
42
|
+
"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-gzip": "^2.2.0",
|
|
59
|
+
"rollup-plugin-node-resolve": "^5.0.1",
|
|
60
|
+
"rollup-plugin-uglify": "^6.0.4",
|
|
61
|
+
"rollup-watch": "^4.3.1",
|
|
62
|
+
"style-loader": "^1.2.1",
|
|
63
|
+
"three": "^0.125.2",
|
|
64
|
+
"ts-loader": "^7.0.4",
|
|
65
|
+
"tsconfig-paths": "^3.9.0",
|
|
66
|
+
"tsconfig-paths-webpack-plugin": "3.2.0",
|
|
67
|
+
"typescript": "^3.9.2",
|
|
68
|
+
"vuepress": "^1.9.7",
|
|
69
|
+
"webpack": "^4.43.0",
|
|
70
|
+
"webpack-cli": "^3.3.11",
|
|
71
|
+
"webpack-dev-server": "^3.11.0"
|
|
72
|
+
}
|
|
73
|
+
}
|
package/rollup.config.js
CHANGED
package/src/IKanimation/Bone.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Mat4 } from "src/math/Mat4";
|
|
2
|
-
import { Vec3 } from "src/math/Vec3";
|
|
3
|
-
import { Thing } from "src/render/thing";
|
|
4
2
|
import { TypedConstraint } from "./constaint/constraint";
|
|
5
3
|
|
|
6
4
|
/*
|
|
@@ -11,13 +9,11 @@ import { TypedConstraint } from "./constaint/constraint";
|
|
|
11
9
|
* @LastEditTime : 2021-03-23 16:19:09
|
|
12
10
|
* @FilePath : \cga.js\src\IKanimation\Bone.ts
|
|
13
11
|
*/
|
|
14
|
-
export class Bone
|
|
15
|
-
children: Bone[] = [];
|
|
12
|
+
export class Bone {
|
|
16
13
|
contraints: TypedConstraint[] = []
|
|
17
14
|
matrix: Mat4 = Mat4.Identity;
|
|
18
15
|
|
|
19
16
|
constructor() {
|
|
20
|
-
super();
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
|
package/src/alg/extrude.ts
CHANGED
|
@@ -13,14 +13,14 @@ import { quat, Quat } from '../math/Quat';
|
|
|
13
13
|
import { Path } from '../struct/3d/Path';
|
|
14
14
|
import { clone, rotateByUnitVectors, angle } from './common';
|
|
15
15
|
import { applyMat4, translate } from './pointset';
|
|
16
|
-
import {
|
|
16
|
+
import { MeshTool } from '../render/mesh';
|
|
17
17
|
import { AxisPlane, triangulation } from './trianglution';
|
|
18
18
|
import { flat, unique } from '../utils/array';
|
|
19
19
|
import { isDefined, isUndefined } from '../utils/types';
|
|
20
20
|
import { m4 } from '../math/Mat4';
|
|
21
21
|
import { IGeometry } from '../render/geometry';
|
|
22
22
|
import { RADIANS_PER_DEGREE } from '../math/Math';
|
|
23
|
-
import {vecs} from '../math/vecs';
|
|
23
|
+
import { vecs } from '../math/vecs';
|
|
24
24
|
import { ArrayList } from '../struct/data/ArrayList';
|
|
25
25
|
import { Distance } from '../basic/distance';
|
|
26
26
|
|
|
@@ -193,7 +193,7 @@ export function linkSides(options: ILinkSideOptions): IGeometry {
|
|
|
193
193
|
var orgHoles = options.orgHoles || (holess && holess[0]);
|
|
194
194
|
|
|
195
195
|
if (index)
|
|
196
|
-
indexable(allVertics, index);
|
|
196
|
+
MeshTool.indexable(allVertics, index);
|
|
197
197
|
|
|
198
198
|
for (var i = 0; i < length; i++) {
|
|
199
199
|
if (holess)
|
|
@@ -595,7 +595,7 @@ export function extrude_obsolete<T extends Vec3>(shape: ArrayList<T>, arg_path:
|
|
|
595
595
|
|
|
596
596
|
const gindex = { index: 0 };
|
|
597
597
|
var vertices = flat(shapeArray);
|
|
598
|
-
indexable(vertices, gindex);
|
|
598
|
+
MeshTool.indexable(vertices, gindex);
|
|
599
599
|
var { index } = linkSides({ shapes: shapeArray, shapeClosed: options.shapeClosed, pathClosed: options.isClosed2, orgShape: shape as any });
|
|
600
600
|
shapepath = new Path(shape as any);
|
|
601
601
|
var uvs = [];
|
|
@@ -635,9 +635,9 @@ export function extrude_obsolete<T extends Vec3>(shape: ArrayList<T>, arg_path:
|
|
|
635
635
|
sealStartTris.reverse();
|
|
636
636
|
|
|
637
637
|
if (options.sealStart)
|
|
638
|
-
indexable(startSeal, gindex);
|
|
638
|
+
MeshTool.indexable(startSeal, gindex);
|
|
639
639
|
if (options.sealEnd)
|
|
640
|
-
indexable(endSeal, gindex);
|
|
640
|
+
MeshTool.indexable(endSeal, gindex);
|
|
641
641
|
var sealEndTris = []
|
|
642
642
|
var hasVLen = vertices.length;
|
|
643
643
|
if (options.sealStart)
|
package/src/app.ts
CHANGED
|
@@ -92,16 +92,9 @@
|
|
|
92
92
|
import * as cga from "./index"
|
|
93
93
|
import { Vec3, v3 } from './math/Vec3';
|
|
94
94
|
import { GLView } from './glview';
|
|
95
|
-
import { Mesh, PlaneBufferGeometry, MeshBasicMaterial, DoubleSide,
|
|
95
|
+
import { Mesh, PlaneBufferGeometry, MeshBasicMaterial, DoubleSide, FrontSide, WebGLRenderTarget, MeshNormalMaterial, DepthTexture, MeshPhongMaterial, CanvasTexture, ShaderMaterial, } from 'three';
|
|
96
96
|
|
|
97
|
-
import {
|
|
98
|
-
import Delaunay from './alg/delaunay';
|
|
99
|
-
import { extrude, linkSides } from './alg/extrude';
|
|
100
|
-
import { Polyline } from './struct/3d/Polyline';
|
|
101
|
-
import { PI, PI_OVER_TWO, PI_TWO } from "./math/Math";
|
|
102
|
-
import { clone, scale, translate } from "./alg/common";
|
|
103
|
-
import { BufferGeometry } from "./render/geometry";
|
|
104
|
-
import { toGeoBuffer } from "./render/mesh";
|
|
97
|
+
import { extrude } from './alg/extrude';
|
|
105
98
|
|
|
106
99
|
|
|
107
100
|
// var a = Vec3.fromDegrees(-75.62898254394531, 40.02804946899414, 0.0);
|
|
@@ -211,7 +204,6 @@ var geometry = cga.toGeometryBuffer(geo);
|
|
|
211
204
|
geometry.computeVertexNormals();
|
|
212
205
|
|
|
213
206
|
import * as THREE from "three"
|
|
214
|
-
import { diamondMaterial } from "./diamondMaterialShader";
|
|
215
207
|
import { BreathLight } from "./effect/breath-light";
|
|
216
208
|
import { Mat4 } from "./math/Mat4";
|
|
217
209
|
import { Color } from "./index";
|
|
@@ -6,20 +6,17 @@
|
|
|
6
6
|
* @LastEditTime : 2021-03-11 10:54:11
|
|
7
7
|
* @FilePath : \cga.js\src\extends\geometryaid.ts
|
|
8
8
|
*/
|
|
9
|
-
import { toGeoBuffer, indexable } from '../render/mesh';
|
|
10
9
|
import { Vec3 } from '../math/Vec3';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { Polyline } from '../struct/3d/Polyline';
|
|
14
|
-
import { Polygon } from '../struct/3d/Polygon';
|
|
15
|
-
import { AxisPlane, triangulation } from '../alg/trianglution';
|
|
10
|
+
import { extrude_obsolete, IExtrudeOptions, linkSides } from '../alg/extrude';
|
|
11
|
+
import { AxisPlane } from '../alg/trianglution';
|
|
16
12
|
import { flat } from '../utils/array';
|
|
17
|
-
import { BufferGeometry,
|
|
13
|
+
import { BufferGeometry, IGeometry } from '../render/geometry';
|
|
18
14
|
import { ArrayList } from '../struct/data/ArrayList';
|
|
15
|
+
import { MeshTool } from '../render/mesh';
|
|
19
16
|
|
|
20
17
|
export function toGeometryBuffer(geo: IGeometry) {
|
|
21
18
|
|
|
22
|
-
var buffer: BufferGeometry = toGeoBuffer(geo.position, geo.index!, geo.uv)
|
|
19
|
+
var buffer: BufferGeometry = MeshTool.toGeoBuffer(geo.position, geo.index!, geo.uv)
|
|
23
20
|
|
|
24
21
|
return buffer
|
|
25
22
|
}
|
|
@@ -32,7 +29,7 @@ export function toGeometryBuffer(geo: IGeometry) {
|
|
|
32
29
|
*/
|
|
33
30
|
export function extrudeToGeometryBuffer(shape: ArrayList<Vec3>, arg_path: Array<Vec3>, options: IExtrudeOptions) {
|
|
34
31
|
var extrudeRes = extrude_obsolete(shape, arg_path, options);
|
|
35
|
-
return toGeoBuffer(extrudeRes.vertices, extrudeRes.index!, extrudeRes.uvs);
|
|
32
|
+
return MeshTool.toGeoBuffer(extrudeRes.vertices, extrudeRes.index!, extrudeRes.uvs);
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
|
|
@@ -59,7 +56,7 @@ export function linkToGeometry(shape: Array<Vec3>, shape1: | Array<Vec3>, axisPl
|
|
|
59
56
|
*/
|
|
60
57
|
export function linksToGeometry(shapes: Array<Vec3>[], pathClosed: boolean = true, shapeClosed: boolean = true) {
|
|
61
58
|
const vertices = flat(shapes);
|
|
62
|
-
indexable(vertices)
|
|
59
|
+
MeshTool.indexable(vertices)
|
|
63
60
|
const geo = linkSides({ shapes, shapeClosed: pathClosed, orgShape: shapes[0] });
|
|
64
61
|
|
|
65
62
|
const geometry = toGeometryBuffer(geo)
|
|
@@ -70,9 +67,9 @@ export function linksToGeometry(shapes: Array<Vec3>[], pathClosed: boolean = tru
|
|
|
70
67
|
// /**
|
|
71
68
|
// * 三角剖分后转成几何体
|
|
72
69
|
// * 只考虑XY平面
|
|
73
|
-
// * @param {*} boundary
|
|
74
|
-
// * @param {*} hole
|
|
75
|
-
// * @param {*} options
|
|
70
|
+
// * @param {*} boundary
|
|
71
|
+
// * @param {*} hole
|
|
72
|
+
// * @param {*} options
|
|
76
73
|
// */
|
|
77
74
|
// export function trianglutionToGeometryBuffer(boundary: any, holes: any[] = [], options: any = { normal: Vec3.UnitZ }) {
|
|
78
75
|
// var triangles = triangulation(boundary, holes, options)
|
package/src/index.ts
CHANGED
|
@@ -36,13 +36,11 @@ export * from "./struct/3d/Frustum"
|
|
|
36
36
|
export * from "./struct/3d/Sphere"
|
|
37
37
|
|
|
38
38
|
export * from "./alg/delaunator"
|
|
39
|
-
export * from "./alg/voronoi"
|
|
40
|
-
|
|
41
|
-
export * from "./render/eventhandler"
|
|
39
|
+
export * from "./alg/voronoi"
|
|
42
40
|
|
|
43
41
|
export * from "./extends/geometryaid"
|
|
44
42
|
|
|
45
43
|
//Geometry
|
|
46
|
-
export * from "./render/
|
|
44
|
+
export * from "./render/bufferAttribute"
|
|
47
45
|
export * from "./render/geometry"
|
|
48
46
|
export * from "./render/mesh"
|
package/src/math/Color.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { EventHandler } from "../render/eventhandler";
|
|
2
1
|
|
|
3
|
-
export class Color
|
|
2
|
+
export class Color {
|
|
4
3
|
_r: number = 0.0;
|
|
5
4
|
_g: number = 0.0;
|
|
6
5
|
_b: number = 0.0;
|
|
7
6
|
_a: number = 1.0;
|
|
8
7
|
|
|
9
8
|
constructor(r: number = 0, g: number = 0, b: number = 0, a: number = 1) {
|
|
10
|
-
super();
|
|
11
9
|
this._r = r;
|
|
12
10
|
this._g = g;
|
|
13
11
|
this._b = b;
|
|
@@ -25,7 +23,7 @@ export class Color extends EventHandler {
|
|
|
25
23
|
set r(value) {
|
|
26
24
|
if (this._r !== value) {
|
|
27
25
|
this._r = value;
|
|
28
|
-
this.fire('change', 'r', this._r, value)
|
|
26
|
+
// this.fire('change', 'r', this._r, value)
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
|
|
@@ -36,7 +34,7 @@ export class Color extends EventHandler {
|
|
|
36
34
|
set g(value) {
|
|
37
35
|
if (this._g !== value) {
|
|
38
36
|
this._g = value;
|
|
39
|
-
this.fire('change', 'g', this._g, value)
|
|
37
|
+
// this.fire('change', 'g', this._g, value)
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -47,7 +45,7 @@ export class Color extends EventHandler {
|
|
|
47
45
|
set b(value) {
|
|
48
46
|
if (this._b !== value) {
|
|
49
47
|
this._b = value;
|
|
50
|
-
this.fire('change', 'b', this._b, value)
|
|
48
|
+
// this.fire('change', 'b', this._b, value)
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
|
|
@@ -58,7 +56,7 @@ export class Color extends EventHandler {
|
|
|
58
56
|
set a(value) {
|
|
59
57
|
if (this._a !== value) {
|
|
60
58
|
this._a = value;
|
|
61
|
-
this.fire('change', 'a', this._a, value)
|
|
59
|
+
// this.fire('change', 'a', this._a, value)
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
|
|
@@ -170,6 +168,19 @@ export class Color extends EventHandler {
|
|
|
170
168
|
|
|
171
169
|
return array;
|
|
172
170
|
}
|
|
171
|
+
|
|
172
|
+
fromArray(array: number[] = [], offset = 0) {
|
|
173
|
+
|
|
174
|
+
this.r = array[offset];
|
|
175
|
+
this.g = array[offset + 1];
|
|
176
|
+
this.b = array[offset + 2];
|
|
177
|
+
|
|
178
|
+
if (array.length >= 4 + offset)
|
|
179
|
+
this.a = array[offset + 3];
|
|
180
|
+
|
|
181
|
+
return array;
|
|
182
|
+
}
|
|
183
|
+
|
|
173
184
|
private byteToFloat(val: number) {
|
|
174
185
|
return val / 255.0;
|
|
175
186
|
};
|
package/src/math/Euler.ts
CHANGED
|
@@ -2,17 +2,16 @@ import { v3 } from "./Vec3";
|
|
|
2
2
|
import { clamp } from "./Math";
|
|
3
3
|
import { m4, Mat4 } from "./Mat4";
|
|
4
4
|
import { quat, Quat } from './Quat';
|
|
5
|
-
import { EventHandler } from "../render/eventhandler";
|
|
6
5
|
|
|
7
6
|
var _matrix = m4();
|
|
8
7
|
var _Quat = quat();
|
|
9
8
|
|
|
10
9
|
const RotationOrders = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
|
|
11
10
|
const DefaultOrder = "XYZ";
|
|
12
|
-
export class Euler
|
|
11
|
+
export class Euler {
|
|
13
12
|
isEuler: boolean = true;
|
|
14
13
|
constructor(public _x: number = 0, public _y: number = 0, public _z: number = 0, public _order = DefaultOrder) {
|
|
15
|
-
|
|
14
|
+
|
|
16
15
|
}
|
|
17
16
|
get x() {
|
|
18
17
|
return this._x;
|
|
@@ -21,7 +20,7 @@ export class Euler extends EventHandler {
|
|
|
21
20
|
set x(value) {
|
|
22
21
|
if (this._x !== value) {
|
|
23
22
|
this._x = value;
|
|
24
|
-
this.fire('change', 'x', this._x, value)
|
|
23
|
+
// this.fire('change', 'x', this._x, value)
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
|
|
@@ -32,7 +31,7 @@ export class Euler extends EventHandler {
|
|
|
32
31
|
set y(value) {
|
|
33
32
|
if (this._y !== value) {
|
|
34
33
|
this._y = value;
|
|
35
|
-
this.fire('change', 'y', this._y, value)
|
|
34
|
+
// this.fire('change', 'y', this._y, value)
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -43,7 +42,7 @@ export class Euler extends EventHandler {
|
|
|
43
42
|
set z(value) {
|
|
44
43
|
if (this._z !== value) {
|
|
45
44
|
this._z = value;
|
|
46
|
-
this.fire('change', 'z', this._z, value)
|
|
45
|
+
// this.fire('change', 'z', this._z, value)
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -54,7 +53,7 @@ export class Euler extends EventHandler {
|
|
|
54
53
|
|
|
55
54
|
set order(value) {
|
|
56
55
|
if (this._order !== value) {
|
|
57
|
-
this.fire('change', 'order', this._order, value)
|
|
56
|
+
// this.fire('change', 'order', this._order, value)
|
|
58
57
|
this._order = value;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
@@ -65,7 +64,7 @@ export class Euler extends EventHandler {
|
|
|
65
64
|
this._z = z;
|
|
66
65
|
this._order = order || this._order;
|
|
67
66
|
|
|
68
|
-
this.fire('change')
|
|
67
|
+
// this.fire('change')
|
|
69
68
|
|
|
70
69
|
|
|
71
70
|
return this;
|
|
@@ -81,7 +80,7 @@ export class Euler extends EventHandler {
|
|
|
81
80
|
this._z = Euler._z;
|
|
82
81
|
this._order = Euler._order;
|
|
83
82
|
|
|
84
|
-
this.fire('change')
|
|
83
|
+
// this.fire('change')
|
|
85
84
|
|
|
86
85
|
return this;
|
|
87
86
|
}
|
|
@@ -170,9 +169,9 @@ export class Euler extends EventHandler {
|
|
|
170
169
|
|
|
171
170
|
this._order = order;
|
|
172
171
|
|
|
173
|
-
if (update !== false) this.fire('change')
|
|
172
|
+
if (update !== false)// this.fire('change')
|
|
174
173
|
|
|
175
|
-
|
|
174
|
+
return this;
|
|
176
175
|
}
|
|
177
176
|
|
|
178
177
|
setFromQuat(q: Quat, order?: any, update?: boolean) {
|
|
@@ -208,7 +207,7 @@ export class Euler extends EventHandler {
|
|
|
208
207
|
this._z = array[2];
|
|
209
208
|
if (array[3] !== undefined) this._order = array[3];
|
|
210
209
|
|
|
211
|
-
this.fire('change')
|
|
210
|
+
// this.fire('change')
|
|
212
211
|
|
|
213
212
|
return this;
|
|
214
213
|
}
|
package/src/math/HVec3.ts
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* @Date : 2021-08-02 16:24:03
|
|
6
6
|
* @LastEditTime : 2021-08-03 11:32:10
|
|
7
7
|
* @FilePath : \cga.js\src\math\HVec3.ts
|
|
8
|
-
*/
|
|
9
|
-
import { EventHandler } from '../render/eventhandler';
|
|
8
|
+
*/
|
|
10
9
|
|
|
11
10
|
import Decimal from 'decimal.js';
|
|
12
11
|
// import { wgs84RadiiSquared } from '../gis/gis';
|
|
@@ -21,12 +20,11 @@ export interface IHVec4 extends IHVec3 {
|
|
|
21
20
|
w: Decimal;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export class HVec3
|
|
23
|
+
export class HVec3 implements IHVec3 {
|
|
25
24
|
x: Decimal;
|
|
26
25
|
y: Decimal;
|
|
27
26
|
z: Decimal;
|
|
28
|
-
constructor(private _x: any = 0, private _y: any = 0, private _z: any = 0) {
|
|
29
|
-
super();
|
|
27
|
+
constructor(private _x: any = 0, private _y: any = 0, private _z: any = 0) {
|
|
30
28
|
this.x = new Decimal(_x);
|
|
31
29
|
this.y = new Decimal(_x);
|
|
32
30
|
this.z = new Decimal(_x);
|
package/src/math/Quat.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { clamp } from "./Math";
|
|
2
2
|
import { Euler } from './Euler';
|
|
3
|
-
import { EventHandler } from '../render/eventhandler';
|
|
4
3
|
|
|
5
|
-
export class Quat
|
|
4
|
+
export class Quat {
|
|
6
5
|
isQuat: boolean = true;
|
|
7
6
|
constructor(public _x: number = 0, public _y: number = 0, public _z: number = 0, public _w: number = 1) {
|
|
8
|
-
|
|
7
|
+
|
|
9
8
|
}
|
|
10
9
|
get x() {
|
|
11
10
|
return this._x;
|
|
@@ -14,7 +13,7 @@ export class Quat extends EventHandler {
|
|
|
14
13
|
set x(value) {
|
|
15
14
|
if (this._x !== value) {
|
|
16
15
|
this._x = value;
|
|
17
|
-
this.fire('change', 'x', this._x, value)
|
|
16
|
+
// this.fire('change', 'x', this._x, value)
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -25,7 +24,7 @@ export class Quat extends EventHandler {
|
|
|
25
24
|
set y(value) {
|
|
26
25
|
if (this._y !== value) {
|
|
27
26
|
this._y = value;
|
|
28
|
-
this.fire('change', 'y', this._y, value)
|
|
27
|
+
// this.fire('change', 'y', this._y, value)
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
|
|
@@ -36,7 +35,7 @@ export class Quat extends EventHandler {
|
|
|
36
35
|
set z(value) {
|
|
37
36
|
if (this._z !== value) {
|
|
38
37
|
this._z = value;
|
|
39
|
-
this.fire('change', 'z', this._z, value)
|
|
38
|
+
// this.fire('change', 'z', this._z, value)
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -47,7 +46,7 @@ export class Quat extends EventHandler {
|
|
|
47
46
|
set w(value) {
|
|
48
47
|
if (this._w !== value) {
|
|
49
48
|
this._w = value;
|
|
50
|
-
this.fire('change', 'w', this._w, value)
|
|
49
|
+
// this.fire('change', 'w', this._w, value)
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -134,7 +133,7 @@ export class Quat extends EventHandler {
|
|
|
134
133
|
this._z = z;
|
|
135
134
|
this._w = w;
|
|
136
135
|
|
|
137
|
-
this.fire("change", this);
|
|
136
|
+
// this.fire("change", this);
|
|
138
137
|
|
|
139
138
|
return this;
|
|
140
139
|
}
|
|
@@ -149,17 +148,12 @@ export class Quat extends EventHandler {
|
|
|
149
148
|
this._z = quat.z;
|
|
150
149
|
this._w = quat.w;
|
|
151
150
|
|
|
152
|
-
this.fire("change", this);
|
|
151
|
+
// this.fire("change", this);
|
|
153
152
|
|
|
154
153
|
return this;
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
setFromEuler(euler: Euler, update?: boolean) {
|
|
158
|
-
if (!(euler && euler.isEuler)) {
|
|
159
|
-
throw new Error(
|
|
160
|
-
"Quat: .setFromEuler() now expects an Euler rotation rather than a Vec3 and order."
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
157
|
|
|
164
158
|
var x = euler._x,
|
|
165
159
|
y = euler._y,
|
|
@@ -213,7 +207,8 @@ export class Quat extends EventHandler {
|
|
|
213
207
|
this._w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
214
208
|
}
|
|
215
209
|
|
|
216
|
-
if (update !== false)
|
|
210
|
+
// if (update !== false)
|
|
211
|
+
// this.fire("change", this);
|
|
217
212
|
|
|
218
213
|
return this;
|
|
219
214
|
}
|
|
@@ -231,7 +226,7 @@ export class Quat extends EventHandler {
|
|
|
231
226
|
this._z = axis.z * s;
|
|
232
227
|
this._w = Math.cos(halfAngle);
|
|
233
228
|
|
|
234
|
-
this.fire("change", this);
|
|
229
|
+
// this.fire("change", this);
|
|
235
230
|
|
|
236
231
|
return this;
|
|
237
232
|
}
|
|
@@ -284,7 +279,7 @@ export class Quat extends EventHandler {
|
|
|
284
279
|
this._z = 0.25 * s;
|
|
285
280
|
}
|
|
286
281
|
|
|
287
|
-
this.fire("change", this);
|
|
282
|
+
// this.fire("change", this);
|
|
288
283
|
|
|
289
284
|
return this;
|
|
290
285
|
}
|
|
@@ -357,7 +352,7 @@ export class Quat extends EventHandler {
|
|
|
357
352
|
this._y *= -1;
|
|
358
353
|
this._z *= -1;
|
|
359
354
|
|
|
360
|
-
this.fire("change", this);
|
|
355
|
+
// this.fire("change", this);
|
|
361
356
|
|
|
362
357
|
return this;
|
|
363
358
|
}
|
|
@@ -401,7 +396,7 @@ export class Quat extends EventHandler {
|
|
|
401
396
|
this._w = this._w * l;
|
|
402
397
|
}
|
|
403
398
|
|
|
404
|
-
this.fire("change", this);
|
|
399
|
+
// this.fire("change", this);
|
|
405
400
|
|
|
406
401
|
return this;
|
|
407
402
|
}
|
|
@@ -435,7 +430,7 @@ export class Quat extends EventHandler {
|
|
|
435
430
|
this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
|
|
436
431
|
this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
|
|
437
432
|
|
|
438
|
-
this.fire("change", this);
|
|
433
|
+
// this.fire("change", this);
|
|
439
434
|
|
|
440
435
|
return this;
|
|
441
436
|
}
|
|
@@ -483,7 +478,7 @@ export class Quat extends EventHandler {
|
|
|
483
478
|
this._z = s * z + t * this._z;
|
|
484
479
|
|
|
485
480
|
this.normalize();
|
|
486
|
-
this.fire("change", this);
|
|
481
|
+
// this.fire("change", this);
|
|
487
482
|
|
|
488
483
|
return this;
|
|
489
484
|
}
|
|
@@ -498,7 +493,7 @@ export class Quat extends EventHandler {
|
|
|
498
493
|
this._y = y * ratioA + this._y * ratioB;
|
|
499
494
|
this._z = z * ratioA + this._z * ratioB;
|
|
500
495
|
|
|
501
|
-
this.fire("change", this);
|
|
496
|
+
// this.fire("change", this);
|
|
502
497
|
|
|
503
498
|
return this;
|
|
504
499
|
}
|
|
@@ -519,7 +514,7 @@ export class Quat extends EventHandler {
|
|
|
519
514
|
this._z = array[offset + 2];
|
|
520
515
|
this._w = array[offset + 3];
|
|
521
516
|
|
|
522
|
-
this.fire("change", this);
|
|
517
|
+
// this.fire("change", this);
|
|
523
518
|
|
|
524
519
|
return this;
|
|
525
520
|
}
|