@xort/cga 0.0.77 → 0.0.80
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/dist/app.js +4 -1
- package/dist/math/Color.d.ts +10 -7
- package/dist/math/Color.js +83 -23
- package/package.json +1 -1
- package/src/app.ts +4 -1
- package/src/index.ts +1 -0
- package/src/math/Color.ts +92 -22
- package/dist/src/IKanimation/Bone.d.ts +0 -9
- package/dist/src/IKanimation/Bone.js +0 -40
- package/dist/src/IKanimation/CCDSolver.d.ts +0 -37
- package/dist/src/IKanimation/CCDSolver.js +0 -93
- package/dist/src/IKanimation/Joint.d.ts +0 -3
- package/dist/src/IKanimation/Joint.js +0 -17
- package/dist/src/IKanimation/constaint/constraint.d.ts +0 -10
- package/dist/src/IKanimation/constaint/constraint.js +0 -25
- package/dist/src/IKanimation/constaint/hinge.d.ts +0 -12
- package/dist/src/IKanimation/constaint/hinge.js +0 -46
- package/dist/src/IKanimation/constaint/slider.d.ts +0 -12
- package/dist/src/IKanimation/constaint/slider.js +0 -44
- package/dist/src/IKanimation/index.d.ts +0 -0
- package/dist/src/IKanimation/index.js +0 -9
- package/dist/src/IKanimation/isolver.d.ts +0 -4
- package/dist/src/IKanimation/isolver.js +0 -10
- package/dist/src/IKanimation/skeleton.d.ts +0 -13
- package/dist/src/IKanimation/skeleton.js +0 -31
- package/dist/src/alg/common.d.ts +0 -114
- package/dist/src/alg/common.js +0 -302
- package/dist/src/alg/curve.d.ts +0 -4
- package/dist/src/alg/curve.js +0 -11
- package/dist/src/alg/delaunator.d.ts +0 -29
- package/dist/src/alg/delaunator.js +0 -442
- package/dist/src/alg/delaunay.d.ts +0 -20
- package/dist/src/alg/delaunay.js +0 -199
- package/dist/src/alg/delaunayslow.d.ts +0 -18
- package/dist/src/alg/delaunayslow.js +0 -140
- package/dist/src/alg/extrude/extrude.d.ts +0 -3
- package/dist/src/alg/extrude/extrude.js +0 -17
- package/dist/src/alg/extrude.d.ts +0 -199
- package/dist/src/alg/extrude.js +0 -731
- package/dist/src/alg/offset/index.d.ts +0 -0
- package/dist/src/alg/offset/index.js +0 -9
- package/dist/src/alg/offset.d.ts +0 -0
- package/dist/src/alg/offset.js +0 -472
- package/dist/src/alg/pointset.d.ts +0 -94
- package/dist/src/alg/pointset.js +0 -223
- package/dist/src/alg/recognition.d.ts +0 -14
- package/dist/src/alg/recognition.js +0 -37
- package/dist/src/alg/result.d.ts +0 -22
- package/dist/src/alg/result.js +0 -2
- package/dist/src/alg/segmentset.d.ts +0 -11
- package/dist/src/alg/segmentset.js +0 -45
- package/dist/src/alg/sort.d.ts +0 -2
- package/dist/src/alg/sort.js +0 -14
- package/dist/src/alg/split.d.ts +0 -8
- package/dist/src/alg/split.js +0 -10
- package/dist/src/alg/trianglution.d.ts +0 -20
- package/dist/src/alg/trianglution.js +0 -77
- package/dist/src/alg/vol.d.ts +0 -6
- package/dist/src/alg/vol.js +0 -18
- package/dist/src/alg/voronoi.d.ts +0 -31
- package/dist/src/alg/voronoi.js +0 -418
- package/dist/src/app.d.ts +0 -1
- package/dist/src/app.js +0 -245
- package/dist/src/basic/distance.d.ts +0 -12
- package/dist/src/basic/distance.js +0 -42
- package/dist/src/csg/bsp.d.ts +0 -9
- package/dist/src/csg/bsp.js +0 -22
- package/dist/src/csg/node.d.ts +0 -12
- package/dist/src/csg/node.js +0 -75
- package/dist/src/csg/polygon.d.ts +0 -43
- package/dist/src/csg/polygon.js +0 -161
- package/dist/src/diamondMaterialShader.d.ts +0 -92
- package/dist/src/diamondMaterialShader.js +0 -118
- package/dist/src/effect/breath-light.d.ts +0 -4
- package/dist/src/effect/breath-light.js +0 -39
- package/dist/src/extends/geometryaid.d.ts +0 -28
- package/dist/src/extends/geometryaid.js +0 -80
- package/dist/src/extends/split.d.ts +0 -3
- package/dist/src/extends/split.js +0 -13
- package/dist/src/glview.d.ts +0 -112
- package/dist/src/glview.js +0 -564
- package/dist/src/index.d.ts +0 -36
- package/dist/src/index.js +0 -54
- package/dist/src/math/Euler.d.ts +0 -47
- package/dist/src/math/Euler.js +0 -245
- package/dist/src/math/HVec3.d.ts +0 -44
- package/dist/src/math/HVec3.js +0 -195
- package/dist/src/math/Mat3.d.ts +0 -29
- package/dist/src/math/Mat3.js +0 -244
- package/dist/src/math/Mat4.d.ts +0 -85
- package/dist/src/math/Mat4.js +0 -791
- package/dist/src/math/Math.d.ts +0 -130
- package/dist/src/math/Math.js +0 -198
- package/dist/src/math/Quat.d.ts +0 -83
- package/dist/src/math/Quat.js +0 -440
- package/dist/src/math/Vec.d.ts +0 -7
- package/dist/src/math/Vec.js +0 -43
- package/dist/src/math/Vec2.d.ts +0 -68
- package/dist/src/math/Vec2.js +0 -347
- package/dist/src/math/Vec3.d.ts +0 -232
- package/dist/src/math/Vec3.js +0 -1089
- package/dist/src/math/Vec4.d.ts +0 -81
- package/dist/src/math/Vec4.js +0 -494
- package/dist/src/math/vector.d.ts +0 -114
- package/dist/src/math/vector.js +0 -373
- package/dist/src/render/buffer-attribute.d.ts +0 -100
- package/dist/src/render/buffer-attribute.js +0 -340
- package/dist/src/render/eventhandler.d.ts +0 -78
- package/dist/src/render/eventhandler.js +0 -189
- package/dist/src/render/geometry.d.ts +0 -89
- package/dist/src/render/geometry.js +0 -775
- package/dist/src/render/mesh.d.ts +0 -25
- package/dist/src/render/mesh.js +0 -82
- package/dist/src/render/thing.d.ts +0 -34
- package/dist/src/render/thing.js +0 -196
- package/dist/src/render/types.d.ts +0 -2
- package/dist/src/render/types.js +0 -8
- package/dist/src/robust/plane.d.ts +0 -7
- package/dist/src/robust/plane.js +0 -17
- package/dist/src/robust/vec.d.ts +0 -15
- package/dist/src/robust/vec.js +0 -71
- package/dist/src/shape/arc.d.ts +0 -2
- package/dist/src/shape/arc.js +0 -14
- package/dist/src/struct/3d/Box.d.ts +0 -23
- package/dist/src/struct/3d/Box.js +0 -109
- package/dist/src/struct/3d/Capsule.d.ts +0 -12
- package/dist/src/struct/3d/Capsule.js +0 -36
- package/dist/src/struct/3d/Circle.d.ts +0 -34
- package/dist/src/struct/3d/Circle.js +0 -80
- package/dist/src/struct/3d/Disk.d.ts +0 -10
- package/dist/src/struct/3d/Disk.js +0 -22
- package/dist/src/struct/3d/Frustum.d.ts +0 -35
- package/dist/src/struct/3d/Frustum.js +0 -159
- package/dist/src/struct/3d/Line.d.ts +0 -40
- package/dist/src/struct/3d/Line.js +0 -339
- package/dist/src/struct/3d/Path.d.ts +0 -75
- package/dist/src/struct/3d/Path.js +0 -308
- package/dist/src/struct/3d/Plane.d.ts +0 -74
- package/dist/src/struct/3d/Plane.js +0 -295
- package/dist/src/struct/3d/Point.d.ts +0 -4
- package/dist/src/struct/3d/Point.js +0 -30
- package/dist/src/struct/3d/Polygon.d.ts +0 -8
- package/dist/src/struct/3d/Polygon.js +0 -55
- package/dist/src/struct/3d/Polyline.d.ts +0 -25
- package/dist/src/struct/3d/Polyline.js +0 -109
- package/dist/src/struct/3d/Ray.d.ts +0 -21
- package/dist/src/struct/3d/Ray.js +0 -262
- package/dist/src/struct/3d/Rectangle.d.ts +0 -7
- package/dist/src/struct/3d/Rectangle.js +0 -35
- package/dist/src/struct/3d/Segment.d.ts +0 -32
- package/dist/src/struct/3d/Segment.js +0 -334
- package/dist/src/struct/3d/Shape.d.ts +0 -4
- package/dist/src/struct/3d/Shape.js +0 -27
- package/dist/src/struct/3d/Sphere.d.ts +0 -11
- package/dist/src/struct/3d/Sphere.js +0 -30
- package/dist/src/struct/3d/Triangle.d.ts +0 -8
- package/dist/src/struct/3d/Triangle.js +0 -53
- package/dist/src/struct/data/ArrayList.d.ts +0 -42
- package/dist/src/struct/data/ArrayList.js +0 -172
- package/dist/src/struct/data/ArrayObject.d.ts +0 -30
- package/dist/src/struct/data/ArrayObject.js +0 -131
- package/dist/src/struct/data/type.d.ts +0 -13
- package/dist/src/struct/data/type.js +0 -18
- package/dist/src/utils/array.d.ts +0 -24
- package/dist/src/utils/array.js +0 -89
- package/dist/src/utils/types.d.ts +0 -24
- package/dist/src/utils/types.js +0 -20
- package/dist/src-gis/app.d.ts +0 -1
- package/dist/src-gis/app.js +0 -4
- package/dist/src-gis/core/Cartographic.d.ts +0 -20
- package/dist/src-gis/core/Cartographic.js +0 -52
- package/dist/src-gis/core/EllipsoidGeodesic.d.ts +0 -14
- package/dist/src-gis/core/EllipsoidGeodesic.js +0 -51
- package/dist/src-gis/core/EllipsoidTerrainProvider.d.ts +0 -10
- package/dist/src-gis/core/EllipsoidTerrainProvider.js +0 -29
- package/dist/src-gis/core/HeightmapTerrainData.d.ts +0 -3
- package/dist/src-gis/core/HeightmapTerrainData.js +0 -9
- package/dist/src-gis/core/Rectangle.d.ts +0 -45
- package/dist/src-gis/core/Rectangle.js +0 -127
- package/dist/src-gis/core/TaskProcessor.d.ts +0 -35
- package/dist/src-gis/core/TaskProcessor.js +0 -183
- package/dist/src-gis/gis.d.ts +0 -5
- package/dist/src-gis/gis.js +0 -12
- package/dist/src-gis/globe.d.ts +0 -12
- package/dist/src-gis/globe.js +0 -61
- package/dist/src-gis/math/Cartographic.d.ts +0 -8
- package/dist/src-gis/math/Cartographic.js +0 -26
- package/dist/src-gis/math/GVec3.d.ts +0 -12
- package/dist/src-gis/math/GVec3.js +0 -69
- package/dist/src-gis/math/ellipsoid.d.ts +0 -8
- package/dist/src-gis/math/ellipsoid.js +0 -14
- package/dist/src-gis/provider/DcTerrainProvider.d.ts +0 -15
- package/dist/src-gis/provider/DcTerrainProvider.js +0 -19
- package/dist/src-gis/provider/TerrainProvider.d.ts +0 -3
- package/dist/src-gis/provider/TerrainProvider.js +0 -17
- package/dist/src-gis/scene/DcImageryProvider.d.ts +0 -6
- package/dist/src-gis/scene/DcImageryProvider.js +0 -35
- package/dist/src-gis/scene/GeographicTilingScheme.d.ts +0 -21
- package/dist/src-gis/scene/GeographicTilingScheme.js +0 -46
- package/dist/src-gis/scene/Globe.d.ts +0 -34
- package/dist/src-gis/scene/Globe.js +0 -62
- package/dist/src-gis/scene/GlobeSurfaceShaderSet.d.ts +0 -6
- package/dist/src-gis/scene/GlobeSurfaceShaderSet.js +0 -11
- package/dist/src-gis/scene/GlobeSurfaceTileProvider.d.ts +0 -21
- package/dist/src-gis/scene/GlobeSurfaceTileProvider.js +0 -15
- package/dist/src-gis/scene/ImageryLayerCollection.d.ts +0 -21
- package/dist/src-gis/scene/ImageryLayerCollection.js +0 -87
- package/dist/src-gis/scene/ImageryProvider.d.ts +0 -4
- package/dist/src-gis/scene/ImageryProvider.js +0 -28
- package/dist/src-gis/scene/QuadtreeTile.d.ts +0 -48
- package/dist/src-gis/scene/QuadtreeTile.js +0 -137
- package/dist/src-gis/scene/UrlTemplateImageryProvider.d.ts +0 -9
- package/dist/src-gis/scene/UrlTemplateImageryProvider.js +0 -29
- package/dist/src-gis/scene/quadtree_primitive.d.ts +0 -14
- package/dist/src-gis/scene/quadtree_primitive.js +0 -50
package/dist/app.js
CHANGED
|
@@ -185,6 +185,7 @@ geometry.computeVertexNormals();
|
|
|
185
185
|
var THREE = __importStar(require("three"));
|
|
186
186
|
var breath_light_1 = require("./effect/breath-light");
|
|
187
187
|
var Mat4_1 = require("./math/Mat4");
|
|
188
|
+
var index_1 = require("./index");
|
|
188
189
|
var tgeo = new THREE.BufferGeometry();
|
|
189
190
|
tgeo.setAttribute('position', new THREE.Float32BufferAttribute(geometry.getAttribute('position').array, 3));
|
|
190
191
|
tgeo.setAttribute('normal', new THREE.Float32BufferAttribute(geometry.getAttribute('normal').array, 3));
|
|
@@ -203,7 +204,9 @@ glv.add(mesh);
|
|
|
203
204
|
// glv.renderer.setRenderTarget(renderTarget);
|
|
204
205
|
// glv.render();
|
|
205
206
|
// glv.renderer.setRenderTarget(null);
|
|
206
|
-
// })
|
|
207
|
+
// })
|
|
208
|
+
var color = new index_1.Color();
|
|
209
|
+
debugger;
|
|
207
210
|
var LabelTexture = /** @class */ (function () {
|
|
208
211
|
function LabelTexture(width, height, sideColor, areaColor) {
|
|
209
212
|
if (width === void 0) { width = 1; }
|
package/dist/math/Color.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EventHandler } from "../render/eventhandler";
|
|
2
2
|
export declare class Color extends EventHandler {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
3
|
+
_r: number;
|
|
4
|
+
_g: number;
|
|
5
|
+
_b: number;
|
|
6
|
+
_a: number;
|
|
7
|
+
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
8
8
|
get isColor(): boolean;
|
|
9
9
|
get r(): number;
|
|
10
10
|
set r(value: number);
|
|
@@ -16,11 +16,14 @@ export declare class Color extends EventHandler {
|
|
|
16
16
|
set a(value: number);
|
|
17
17
|
set(value: any): this;
|
|
18
18
|
setHex(hex: number): this;
|
|
19
|
+
setHexCssString(style: string): this | undefined;
|
|
19
20
|
setRGB(r: number, g: number, b: number, a?: number): this;
|
|
20
21
|
clone(): any;
|
|
21
22
|
copy(color: this): this;
|
|
22
23
|
equals(c: this): boolean;
|
|
23
24
|
toArray(array?: number[], offset?: number): number[];
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
private byteToFloat;
|
|
26
|
+
private floatToByte;
|
|
27
|
+
getHexCssString(): string;
|
|
28
|
+
toJSON(): string;
|
|
26
29
|
}
|
package/dist/math/Color.js
CHANGED
|
@@ -17,16 +17,20 @@ exports.Color = void 0;
|
|
|
17
17
|
var eventhandler_1 = require("../render/eventhandler");
|
|
18
18
|
var Color = /** @class */ (function (_super) {
|
|
19
19
|
__extends(Color, _super);
|
|
20
|
-
function Color(
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
20
|
+
function Color(r, g, b, a) {
|
|
21
|
+
if (r === void 0) { r = 0; }
|
|
22
|
+
if (g === void 0) { g = 0; }
|
|
23
|
+
if (b === void 0) { b = 0; }
|
|
24
|
+
if (a === void 0) { a = 1; }
|
|
25
25
|
var _this = _super.call(this) || this;
|
|
26
|
-
_this._r =
|
|
27
|
-
_this._g =
|
|
28
|
-
_this._b =
|
|
29
|
-
_this._a =
|
|
26
|
+
_this._r = 0.0;
|
|
27
|
+
_this._g = 0.0;
|
|
28
|
+
_this._b = 0.0;
|
|
29
|
+
_this._a = 1.0;
|
|
30
|
+
_this._r = r;
|
|
31
|
+
_this._g = g;
|
|
32
|
+
_this._b = b;
|
|
33
|
+
_this._a = a;
|
|
30
34
|
return _this;
|
|
31
35
|
}
|
|
32
36
|
Object.defineProperty(Color.prototype, "isColor", {
|
|
@@ -99,18 +103,46 @@ var Color = /** @class */ (function (_super) {
|
|
|
99
103
|
};
|
|
100
104
|
Color.prototype.setHex = function (hex) {
|
|
101
105
|
hex = Math.floor(hex);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
this._r = (hex >> 16 & 255) / 255;
|
|
107
|
+
this._g = (hex >> 8 & 255) / 255;
|
|
108
|
+
this._b = (hex & 255) / 255;
|
|
109
|
+
return this;
|
|
110
|
+
};
|
|
111
|
+
Color.prototype.setHexCssString = function (style) {
|
|
112
|
+
var m = /^\#([A-Fa-f\d]+)$/.exec(style);
|
|
113
|
+
// hex color
|
|
114
|
+
var hex = m[1];
|
|
115
|
+
var size = hex.length;
|
|
116
|
+
if (size === 3) {
|
|
117
|
+
// #ff0
|
|
118
|
+
this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
|
|
119
|
+
this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
|
|
120
|
+
this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
|
|
121
|
+
return this;
|
|
107
122
|
}
|
|
108
|
-
else {
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
this.
|
|
123
|
+
else if (size === 6) {
|
|
124
|
+
// #ff0000
|
|
125
|
+
this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
|
|
126
|
+
this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
|
|
127
|
+
this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
else if (size === 4) {
|
|
131
|
+
// #ff0000
|
|
132
|
+
this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
|
|
133
|
+
this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
|
|
134
|
+
this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
|
|
135
|
+
this.a = parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255;
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
else if (size === 8) {
|
|
139
|
+
// #ff0000
|
|
140
|
+
this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
|
|
141
|
+
this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
|
|
142
|
+
this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
|
|
143
|
+
this.a = parseInt(hex.charAt(6) + hex.charAt(7), 16) / 255;
|
|
144
|
+
return this;
|
|
112
145
|
}
|
|
113
|
-
return this;
|
|
114
146
|
};
|
|
115
147
|
Color.prototype.setRGB = function (r, g, b, a) {
|
|
116
148
|
if (a === void 0) { a = 1.0; }
|
|
@@ -127,10 +159,11 @@ var Color = /** @class */ (function (_super) {
|
|
|
127
159
|
this._r = color.r;
|
|
128
160
|
this._g = color.g;
|
|
129
161
|
this._b = color.b;
|
|
162
|
+
this._a = color.a;
|
|
130
163
|
return this;
|
|
131
164
|
};
|
|
132
165
|
Color.prototype.equals = function (c) {
|
|
133
|
-
return (c.r === this.r) && (c.g === this.g) && (c.b === this.b);
|
|
166
|
+
return (c.r === this.r) && (c.g === this.g) && (c.b === this.b) && (c.a === this.a);
|
|
134
167
|
};
|
|
135
168
|
Color.prototype.toArray = function (array, offset) {
|
|
136
169
|
if (array === void 0) { array = []; }
|
|
@@ -141,11 +174,38 @@ var Color = /** @class */ (function (_super) {
|
|
|
141
174
|
array[offset + 3] = this.a;
|
|
142
175
|
return array;
|
|
143
176
|
};
|
|
144
|
-
Color.prototype.
|
|
145
|
-
return
|
|
177
|
+
Color.prototype.byteToFloat = function (val) {
|
|
178
|
+
return val / 255.0;
|
|
179
|
+
};
|
|
180
|
+
;
|
|
181
|
+
Color.prototype.floatToByte = function (val) {
|
|
182
|
+
return val === 1.0 ? 255.0 : (val * 256.0) | 0;
|
|
183
|
+
};
|
|
184
|
+
;
|
|
185
|
+
Color.prototype.getHexCssString = function () {
|
|
186
|
+
var r = this.floatToByte(this._r).toString(16);
|
|
187
|
+
if (r.length < 2) {
|
|
188
|
+
r = "0" + r;
|
|
189
|
+
}
|
|
190
|
+
var g = this.floatToByte(this._g).toString(16);
|
|
191
|
+
if (g.length < 2) {
|
|
192
|
+
g = "0" + g;
|
|
193
|
+
}
|
|
194
|
+
var b = this.floatToByte(this._b).toString(16);
|
|
195
|
+
if (b.length < 2) {
|
|
196
|
+
b = "0" + b;
|
|
197
|
+
}
|
|
198
|
+
if (this._a < 1) {
|
|
199
|
+
var hexAlpha = this.floatToByte(this._a).toString(16);
|
|
200
|
+
if (hexAlpha.length < 2) {
|
|
201
|
+
hexAlpha = "0" + hexAlpha;
|
|
202
|
+
}
|
|
203
|
+
return "#" + r + g + b + hexAlpha;
|
|
204
|
+
}
|
|
205
|
+
return "#" + r + g + b;
|
|
146
206
|
};
|
|
147
207
|
Color.prototype.toJSON = function () {
|
|
148
|
-
return this.
|
|
208
|
+
return this.getHexCssString();
|
|
149
209
|
};
|
|
150
210
|
return Color;
|
|
151
211
|
}(eventhandler_1.EventHandler));
|
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -214,6 +214,7 @@ import * as THREE from "three"
|
|
|
214
214
|
import { diamondMaterial } from "./diamondMaterialShader";
|
|
215
215
|
import { BreathLight } from "./effect/breath-light";
|
|
216
216
|
import { Mat4 } from "./math/Mat4";
|
|
217
|
+
import { Color } from "./index";
|
|
217
218
|
var tgeo = new THREE.BufferGeometry();
|
|
218
219
|
tgeo.setAttribute('position', new THREE.Float32BufferAttribute(geometry.getAttribute('position').array, 3));
|
|
219
220
|
tgeo.setAttribute('normal', new THREE.Float32BufferAttribute(geometry.getAttribute('normal').array, 3));
|
|
@@ -233,9 +234,11 @@ glv.add(mesh);
|
|
|
233
234
|
// glv.renderer.setRenderTarget(renderTarget);
|
|
234
235
|
// glv.render();
|
|
235
236
|
// glv.renderer.setRenderTarget(null);
|
|
236
|
-
// })
|
|
237
|
+
// })
|
|
237
238
|
|
|
238
239
|
|
|
240
|
+
const color = new Color()
|
|
241
|
+
debugger
|
|
239
242
|
|
|
240
243
|
class LabelTexture {
|
|
241
244
|
width: number;
|
package/src/index.ts
CHANGED
package/src/math/Color.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { EventHandler } from "../render/eventhandler";
|
|
1
|
+
import { EventHandler } from "../render/eventhandler";
|
|
2
2
|
|
|
3
3
|
export class Color extends EventHandler {
|
|
4
|
-
|
|
4
|
+
_r: number = 0.0;
|
|
5
|
+
_g: number = 0.0;
|
|
6
|
+
_b: number = 0.0;
|
|
7
|
+
_a: number = 1.0;
|
|
8
|
+
|
|
9
|
+
constructor(r: number = 0, g: number = 0, b: number = 0, a: number = 1) {
|
|
5
10
|
super();
|
|
11
|
+
this._r = r;
|
|
12
|
+
this._g = g;
|
|
13
|
+
this._b = b;
|
|
14
|
+
this._a = a;
|
|
6
15
|
}
|
|
7
|
-
|
|
16
|
+
|
|
8
17
|
get isColor() {
|
|
9
18
|
return true;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
|
-
|
|
13
21
|
get r() {
|
|
14
22
|
return this._r;
|
|
15
23
|
}
|
|
@@ -40,7 +48,7 @@ export class Color extends EventHandler {
|
|
|
40
48
|
if (this._b !== value) {
|
|
41
49
|
this._b = value;
|
|
42
50
|
this.fire('change', 'b', this._b, value)
|
|
43
|
-
}
|
|
51
|
+
}
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
get a() {
|
|
@@ -67,21 +75,57 @@ export class Color extends EventHandler {
|
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
setHex(hex: number) {
|
|
70
|
-
|
|
71
78
|
hex = Math.floor(hex);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this._a = (hex & 255) / 255;
|
|
77
|
-
} else {
|
|
78
|
-
this._r = (hex >> 16 & 255) / 255;
|
|
79
|
-
this._g = (hex >> 8 & 255) / 255;
|
|
80
|
-
this._b = (hex & 255) / 255;
|
|
81
|
-
}
|
|
79
|
+
|
|
80
|
+
this._r = (hex >> 16 & 255) / 255;
|
|
81
|
+
this._g = (hex >> 8 & 255) / 255;
|
|
82
|
+
this._b = (hex & 255) / 255;
|
|
82
83
|
|
|
83
84
|
return this;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setHexCssString(style: string) {
|
|
88
|
+
let m: any = /^\#([A-Fa-f\d]+)$/.exec(style)
|
|
89
|
+
// hex color
|
|
90
|
+
|
|
91
|
+
const hex = m[1];
|
|
92
|
+
const size = hex.length;
|
|
84
93
|
|
|
94
|
+
if (size === 3) {
|
|
95
|
+
|
|
96
|
+
// #ff0
|
|
97
|
+
this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
|
|
98
|
+
this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
|
|
99
|
+
this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
|
|
100
|
+
|
|
101
|
+
return this;
|
|
102
|
+
|
|
103
|
+
} else if (size === 6) {
|
|
104
|
+
|
|
105
|
+
// #ff0000
|
|
106
|
+
this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
|
|
107
|
+
this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
|
|
108
|
+
this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
else if (size === 4) {
|
|
112
|
+
|
|
113
|
+
// #ff0000
|
|
114
|
+
this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
|
|
115
|
+
this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
|
|
116
|
+
this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
|
|
117
|
+
this.a = parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
else if (size === 8) {
|
|
121
|
+
|
|
122
|
+
// #ff0000
|
|
123
|
+
this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
|
|
124
|
+
this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
|
|
125
|
+
this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
|
|
126
|
+
this.a = parseInt(hex.charAt(6) + hex.charAt(7), 16) / 255;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
85
129
|
}
|
|
86
130
|
|
|
87
131
|
setRGB(r: number, g: number, b: number, a: number = 1.0) {
|
|
@@ -92,7 +136,6 @@ export class Color extends EventHandler {
|
|
|
92
136
|
this._a = a;
|
|
93
137
|
|
|
94
138
|
return this;
|
|
95
|
-
|
|
96
139
|
}
|
|
97
140
|
|
|
98
141
|
clone() {
|
|
@@ -103,12 +146,13 @@ export class Color extends EventHandler {
|
|
|
103
146
|
this._r = color.r;
|
|
104
147
|
this._g = color.g;
|
|
105
148
|
this._b = color.b;
|
|
149
|
+
this._a = color.a;
|
|
106
150
|
|
|
107
151
|
return this;
|
|
108
152
|
}
|
|
109
153
|
|
|
110
154
|
equals(c: this) {
|
|
111
|
-
return (c.r === this.r) && (c.g === this.g) && (c.b === this.b);
|
|
155
|
+
return (c.r === this.r) && (c.g === this.g) && (c.b === this.b) && (c.a === this.a);
|
|
112
156
|
}
|
|
113
157
|
|
|
114
158
|
toArray(array: number[] = [], offset = 0) {
|
|
@@ -120,13 +164,39 @@ export class Color extends EventHandler {
|
|
|
120
164
|
|
|
121
165
|
return array;
|
|
122
166
|
}
|
|
167
|
+
private byteToFloat(val: number) {
|
|
168
|
+
return val / 255.0;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
private floatToByte(val: number) {
|
|
172
|
+
return val === 1.0 ? 255.0 : (val * 256.0) | 0;
|
|
173
|
+
};
|
|
123
174
|
|
|
124
|
-
|
|
125
|
-
|
|
175
|
+
getHexCssString() {
|
|
176
|
+
let r = this.floatToByte(this._r).toString(16);
|
|
177
|
+
if (r.length < 2) {
|
|
178
|
+
r = `0${r}`;
|
|
179
|
+
}
|
|
180
|
+
let g = this.floatToByte(this._g).toString(16);
|
|
181
|
+
if (g.length < 2) {
|
|
182
|
+
g = `0${g}`;
|
|
183
|
+
}
|
|
184
|
+
let b = this.floatToByte(this._b).toString(16);
|
|
185
|
+
if (b.length < 2) {
|
|
186
|
+
b = `0${b}`;
|
|
187
|
+
}
|
|
188
|
+
if (this._a < 1) {
|
|
189
|
+
let hexAlpha = this.floatToByte(this._a).toString(16);
|
|
190
|
+
if (hexAlpha.length < 2) {
|
|
191
|
+
hexAlpha = `0${hexAlpha}`;
|
|
192
|
+
}
|
|
193
|
+
return `#${r}${g}${b}${hexAlpha}`;
|
|
194
|
+
}
|
|
195
|
+
return `#${r}${g}${b}`;
|
|
126
196
|
}
|
|
127
197
|
|
|
128
198
|
toJSON() {
|
|
129
|
-
return this.
|
|
199
|
+
return this.getHexCssString();
|
|
130
200
|
}
|
|
131
|
-
|
|
201
|
+
|
|
132
202
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Mat4 } from "src/math/Mat4";
|
|
2
|
-
import { Thing } from "src/render/thing";
|
|
3
|
-
import { TypedConstraint } from "./constaint/constraint";
|
|
4
|
-
export declare class Bone extends Thing {
|
|
5
|
-
children: Bone[];
|
|
6
|
-
contraints: TypedConstraint[];
|
|
7
|
-
matrix: Mat4;
|
|
8
|
-
constructor();
|
|
9
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.Bone = void 0;
|
|
19
|
-
var Mat4_1 = require("src/math/Mat4");
|
|
20
|
-
var thing_1 = require("src/render/thing");
|
|
21
|
-
/*
|
|
22
|
-
* @Description :
|
|
23
|
-
* @Author : 赵耀圣
|
|
24
|
-
* @QQ : 549184003
|
|
25
|
-
* @Date : 2021-03-22 17:41:30
|
|
26
|
-
* @LastEditTime : 2021-03-23 16:19:09
|
|
27
|
-
* @FilePath : \cga.js\src\IKanimation\Bone.ts
|
|
28
|
-
*/
|
|
29
|
-
var Bone = /** @class */ (function (_super) {
|
|
30
|
-
__extends(Bone, _super);
|
|
31
|
-
function Bone() {
|
|
32
|
-
var _this = _super.call(this) || this;
|
|
33
|
-
_this.children = [];
|
|
34
|
-
_this.contraints = [];
|
|
35
|
-
_this.matrix = Mat4_1.Mat4.Identity;
|
|
36
|
-
return _this;
|
|
37
|
-
}
|
|
38
|
-
return Bone;
|
|
39
|
-
}(thing_1.Thing));
|
|
40
|
-
exports.Bone = Bone;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Quat } from "../math/Quat";
|
|
2
|
-
import { Vec3 } from "../math/Vec3";
|
|
3
|
-
import { TypedConstraint } from "./constaint/constraint";
|
|
4
|
-
import { ISolver } from "./isolver";
|
|
5
|
-
import { Skeleton } from "./skeleton";
|
|
6
|
-
/**
|
|
7
|
-
* @description :
|
|
8
|
-
* @param {*}
|
|
9
|
-
* @return {*}
|
|
10
|
-
* @example :
|
|
11
|
-
*/
|
|
12
|
-
export declare class CCDSolver implements ISolver {
|
|
13
|
-
constructor();
|
|
14
|
-
updateTarget(): void;
|
|
15
|
-
projectPlane(v: Vec3, normal: Vec3): Vec3;
|
|
16
|
-
calcAngle(v1: Vec3, v2: Vec3, dir: Vec3): number;
|
|
17
|
-
/**
|
|
18
|
-
* @description :
|
|
19
|
-
* @param {Vec3} target 目标点
|
|
20
|
-
* @param {Vec3} zeroPos 关节原点
|
|
21
|
-
* @param {Vec3} effector 末端效应点
|
|
22
|
-
* @return {*}
|
|
23
|
-
* @example :
|
|
24
|
-
*/
|
|
25
|
-
solveTranslate(target: Vec3, zeroPos: Vec3, effector: Vec3): void;
|
|
26
|
-
/**
|
|
27
|
-
* @description :
|
|
28
|
-
* @param {Vec3} target 目标点
|
|
29
|
-
* @param {Vec3} zeroPos 关节原点
|
|
30
|
-
* @param {Vec3} effector 末端效应点
|
|
31
|
-
* @return {*}
|
|
32
|
-
* @example :
|
|
33
|
-
*/
|
|
34
|
-
solveRotation(target: Vec3, zeroPos: Vec3, effector: Vec3, contraints?: TypedConstraint[]): Quat;
|
|
35
|
-
solveIK(skeleton: Skeleton, target: Vec3): void;
|
|
36
|
-
solve(bones: any): void;
|
|
37
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @Description :
|
|
4
|
-
* @Author : 赵耀圣
|
|
5
|
-
* @QQ : 549184003
|
|
6
|
-
* @Date : 2021-03-22 17:27:16
|
|
7
|
-
* @LastEditTime : 2021-03-23 18:01:49
|
|
8
|
-
* @FilePath : \cga.js\src\IKanimation\CCDSolver.ts
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.CCDSolver = void 0;
|
|
12
|
-
var Math_1 = require("../math/Math");
|
|
13
|
-
var Plane_1 = require("../struct/3d/Plane");
|
|
14
|
-
var Quat_1 = require("../math/Quat");
|
|
15
|
-
var Vec3_1 = require("../math/Vec3");
|
|
16
|
-
var _quat = new Quat_1.Quat();
|
|
17
|
-
var _plane = new Plane_1.Plane();
|
|
18
|
-
/**
|
|
19
|
-
* @description :
|
|
20
|
-
* @param {*}
|
|
21
|
-
* @return {*}
|
|
22
|
-
* @example :
|
|
23
|
-
*/
|
|
24
|
-
var CCDSolver = /** @class */ (function () {
|
|
25
|
-
function CCDSolver() {
|
|
26
|
-
}
|
|
27
|
-
CCDSolver.prototype.updateTarget = function () {
|
|
28
|
-
};
|
|
29
|
-
CCDSolver.prototype.projectPlane = function (v, normal) {
|
|
30
|
-
return v.clone().projectOnPlaneNormal(normal);
|
|
31
|
-
};
|
|
32
|
-
CCDSolver.prototype.calcAngle = function (v1, v2, dir) {
|
|
33
|
-
var vc1 = v1.clone();
|
|
34
|
-
var vc2 = v2.clone();
|
|
35
|
-
var angle = (0, Math_1.clamp)(vc1.normalize().dot(vc2.normalize()), -1, 1);
|
|
36
|
-
angle = Math.acos(angle);
|
|
37
|
-
if (vc1.cross(vc2).dot(dir) < 0)
|
|
38
|
-
return -angle;
|
|
39
|
-
return angle;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* @description :
|
|
43
|
-
* @param {Vec3} target 目标点
|
|
44
|
-
* @param {Vec3} zeroPos 关节原点
|
|
45
|
-
* @param {Vec3} effector 末端效应点
|
|
46
|
-
* @return {*}
|
|
47
|
-
* @example :
|
|
48
|
-
*/
|
|
49
|
-
CCDSolver.prototype.solveTranslate = function (target, zeroPos, effector) {
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* @description :
|
|
53
|
-
* @param {Vec3} target 目标点
|
|
54
|
-
* @param {Vec3} zeroPos 关节原点
|
|
55
|
-
* @param {Vec3} effector 末端效应点
|
|
56
|
-
* @return {*}
|
|
57
|
-
* @example :
|
|
58
|
-
*/
|
|
59
|
-
CCDSolver.prototype.solveRotation = function (target, zeroPos, effector, contraints) {
|
|
60
|
-
var dir0 = effector.clone().sub(zeroPos).normalize();
|
|
61
|
-
var dir1 = target.clone().sub(zeroPos).normalize();
|
|
62
|
-
var rotationAxis = (0, Vec3_1.v3)().cross(dir0, dir1).normalize();
|
|
63
|
-
_plane.setFromPointNormal(zeroPos, rotationAxis);
|
|
64
|
-
//最近点
|
|
65
|
-
var closestDir = this.projectPlane(target, rotationAxis);
|
|
66
|
-
closestDir.sub(zeroPos);
|
|
67
|
-
var angle = 0;
|
|
68
|
-
_quat.setFromUnitVecs(dir0, closestDir);
|
|
69
|
-
return _quat.clone();
|
|
70
|
-
};
|
|
71
|
-
CCDSolver.prototype.solveIK = function (skeleton, target) {
|
|
72
|
-
var i = 0;
|
|
73
|
-
while (i++ < skeleton.boneNum) {
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
CCDSolver.prototype.solve = function (bones) {
|
|
77
|
-
// for (var i = bones.Length - 2; i > -1; i--) {
|
|
78
|
-
// // Slerp if weight is < 0
|
|
79
|
-
// //CCD tends to overemphasise the rotations of the bones closer to the target position. Reducing bone weight down the hierarchy will compensate for this effect.
|
|
80
|
-
// var w = bones[i].weight * IKPositionWeight;
|
|
81
|
-
// if (w > 0) {
|
|
82
|
-
// Vec3 toLastBone = bones[bones.Length - 1].transform.position - bones[i].transform.position;
|
|
83
|
-
// Vec3 toTarget = targetPosition - bones[i].transform.position;
|
|
84
|
-
// // Get the rotation to direct the last bone to the target
|
|
85
|
-
// Quat targetRotation = Quat.FromToRotation(toLastBone, toTarget) * bones[i].transform.rotation;
|
|
86
|
-
// if (w >= 1) bones[i].transform.rotation = targetRotation;
|
|
87
|
-
// else bones[i].transform.rotation = Quaternion.Lerp(bones[i].transform.rotation, targetRotation, w);
|
|
88
|
-
// }
|
|
89
|
-
// }
|
|
90
|
-
};
|
|
91
|
-
return CCDSolver;
|
|
92
|
-
}());
|
|
93
|
-
exports.CCDSolver = CCDSolver;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Joint = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* @Description :
|
|
6
|
-
* @Author : 赵耀圣
|
|
7
|
-
* @QQ : 549184003
|
|
8
|
-
* @Date : 2021-03-23 16:09:29
|
|
9
|
-
* @LastEditTime : 2021-03-23 16:31:32
|
|
10
|
-
* @FilePath : \cga.js\src\IKanimation\Joint.ts
|
|
11
|
-
*/
|
|
12
|
-
var Joint = /** @class */ (function () {
|
|
13
|
-
function Joint() {
|
|
14
|
-
}
|
|
15
|
-
return Joint;
|
|
16
|
-
}());
|
|
17
|
-
exports.Joint = Joint;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @Description :
|
|
4
|
-
* @Author : 赵耀圣
|
|
5
|
-
* @QQ : 549184003
|
|
6
|
-
* @Date : 2021-03-23 15:38:27
|
|
7
|
-
* @LastEditTime : 2021-03-23 16:05:43
|
|
8
|
-
* @FilePath : \cga.js\src\IKanimation\constaint\constraint.ts
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.TypedConstraint = exports.ISpace = void 0;
|
|
12
|
-
var Mat4_1 = require("../../math/Mat4");
|
|
13
|
-
var ISpace;
|
|
14
|
-
(function (ISpace) {
|
|
15
|
-
ISpace[ISpace["Globe"] = 0] = "Globe";
|
|
16
|
-
ISpace[ISpace["Local"] = 1] = "Local";
|
|
17
|
-
})(ISpace = exports.ISpace || (exports.ISpace = {}));
|
|
18
|
-
var TypedConstraint = /** @class */ (function () {
|
|
19
|
-
function TypedConstraint() {
|
|
20
|
-
this.space = ISpace.Local;
|
|
21
|
-
this.matrix = Mat4_1.Mat4.Identity;
|
|
22
|
-
}
|
|
23
|
-
return TypedConstraint;
|
|
24
|
-
}());
|
|
25
|
-
exports.TypedConstraint = TypedConstraint;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Vec3 } from "src/math/Vec3";
|
|
2
|
-
import { TypedConstraint } from "./constraint";
|
|
3
|
-
/**
|
|
4
|
-
* @description : 铰链约束
|
|
5
|
-
* @example :
|
|
6
|
-
*/
|
|
7
|
-
export declare class HingeContraint extends TypedConstraint {
|
|
8
|
-
axis: Vec3;
|
|
9
|
-
minAngle: number;
|
|
10
|
-
maxAngle: number;
|
|
11
|
-
constructor();
|
|
12
|
-
}
|