@xort/cga 0.0.72 → 0.0.73
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/IKanimation/Bone.js +1 -3
- package/dist/IKanimation/CCDSolver.js +2 -2
- package/dist/IKanimation/constaint/hinge.js +1 -3
- package/dist/IKanimation/constaint/slider.js +1 -3
- package/dist/alg/common.js +2 -2
- package/dist/alg/extrude.js +54 -56
- package/dist/alg/pointset.js +5 -5
- package/dist/alg/trianglution.js +10 -12
- package/dist/app.js +10 -14
- package/dist/diamondMaterialShader.js +2 -6
- package/dist/effect/breath-light.js +1 -3
- package/dist/extends/geometryaid.js +7 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -6
- package/dist/math/Color.d.ts +29 -0
- package/dist/math/Color.js +195 -0
- package/dist/math/Euler.js +10 -12
- package/dist/math/HVec3.js +1 -3
- package/dist/math/Mat3.js +1 -1
- package/dist/math/Mat4.js +6 -6
- package/dist/math/Quat.js +2 -4
- package/dist/math/Vec.js +1 -3
- package/dist/math/Vec2.js +1 -3
- package/dist/math/Vec3.js +5 -7
- package/dist/math/Vec4.js +1 -3
- package/dist/math/vector.js +7 -9
- package/dist/render/buffer-attribute.js +28 -12
- package/dist/render/eventhandler.d.ts +1 -1
- package/dist/render/eventhandler.js +7 -9
- package/dist/render/geometry.js +2 -2
- package/dist/render/mesh.js +9 -11
- package/dist/render/thing.js +8 -10
- package/dist/render/types.js +1 -2
- package/dist/struct/3d/Box.js +3 -3
- package/dist/struct/3d/Capsule.js +1 -3
- package/dist/struct/3d/Circle.js +2 -2
- package/dist/struct/3d/Disk.js +1 -1
- package/dist/struct/3d/Line.js +4 -4
- package/dist/struct/3d/Path.js +11 -13
- package/dist/struct/3d/Plane.js +10 -12
- package/dist/struct/3d/Point.js +1 -3
- package/dist/struct/3d/Polygon.js +1 -3
- package/dist/struct/3d/Polyline.js +1 -3
- package/dist/struct/3d/Rectangle.js +1 -3
- package/dist/struct/3d/Segment.js +7 -9
- package/dist/struct/3d/Shape.js +1 -3
- package/dist/struct/3d/Sphere.js +1 -1
- package/dist/struct/3d/Triangle.js +1 -3
- package/dist/struct/data/ArrayList.js +9 -11
- package/dist/struct/data/ArrayObject.js +1 -3
- package/docs/guide/distLineAll.md +5 -5
- package/docs/guide/distPointAll.md +6 -6
- package/docs/guide/distRayAll.md +4 -4
- package/docs/guide/distSegmentAll.md +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/math/Color.ts +157 -0
|
@@ -0,0 +1,195 @@
|
|
|
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.Color = exports.LinearToSRGB = exports.SRGBToLinear = exports.hue2rgb = void 0;
|
|
36
|
+
var eventhandler_1 = require("src/render/eventhandler");
|
|
37
|
+
var THREE = __importStar(require("three"));
|
|
38
|
+
function hue2rgb(p, q, t) {
|
|
39
|
+
if (t < 0)
|
|
40
|
+
t += 1;
|
|
41
|
+
if (t > 1)
|
|
42
|
+
t -= 1;
|
|
43
|
+
if (t < 1 / 6)
|
|
44
|
+
return p + (q - p) * 6 * t;
|
|
45
|
+
if (t < 1 / 2)
|
|
46
|
+
return q;
|
|
47
|
+
if (t < 2 / 3)
|
|
48
|
+
return p + (q - p) * 6 * (2 / 3 - t);
|
|
49
|
+
return p;
|
|
50
|
+
}
|
|
51
|
+
exports.hue2rgb = hue2rgb;
|
|
52
|
+
function SRGBToLinear(c) {
|
|
53
|
+
return (c < 0.04045) ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
54
|
+
}
|
|
55
|
+
exports.SRGBToLinear = SRGBToLinear;
|
|
56
|
+
function LinearToSRGB(c) {
|
|
57
|
+
return (c < 0.0031308) ? c * 12.92 : 1.055 * (Math.pow(c, 0.41666)) - 0.055;
|
|
58
|
+
}
|
|
59
|
+
exports.LinearToSRGB = LinearToSRGB;
|
|
60
|
+
var Color = /** @class */ (function (_super) {
|
|
61
|
+
__extends(Color, _super);
|
|
62
|
+
function Color(_r, _g, _b, _a) {
|
|
63
|
+
if (_r === void 0) { _r = 0; }
|
|
64
|
+
if (_g === void 0) { _g = 0; }
|
|
65
|
+
if (_b === void 0) { _b = 0; }
|
|
66
|
+
if (_a === void 0) { _a = 1; }
|
|
67
|
+
var _this = _super.call(this) || this;
|
|
68
|
+
_this._r = _r;
|
|
69
|
+
_this._g = _g;
|
|
70
|
+
_this._b = _b;
|
|
71
|
+
_this._a = _a;
|
|
72
|
+
return _this;
|
|
73
|
+
}
|
|
74
|
+
Object.defineProperty(Color.prototype, "isColor", {
|
|
75
|
+
get: function () {
|
|
76
|
+
return true;
|
|
77
|
+
},
|
|
78
|
+
enumerable: false,
|
|
79
|
+
configurable: true
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(Color.prototype, "r", {
|
|
82
|
+
get: function () {
|
|
83
|
+
return this._r;
|
|
84
|
+
},
|
|
85
|
+
set: function (value) {
|
|
86
|
+
if (this._r !== value) {
|
|
87
|
+
this._r = value;
|
|
88
|
+
this.fire('change', 'r', this._r, value);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
enumerable: false,
|
|
92
|
+
configurable: true
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(Color.prototype, "g", {
|
|
95
|
+
get: function () {
|
|
96
|
+
return this._g;
|
|
97
|
+
},
|
|
98
|
+
set: function (value) {
|
|
99
|
+
if (this._g !== value) {
|
|
100
|
+
this._g = value;
|
|
101
|
+
this.fire('change', 'g', this._g, value);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
enumerable: false,
|
|
105
|
+
configurable: true
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(Color.prototype, "b", {
|
|
108
|
+
get: function () {
|
|
109
|
+
return this._g;
|
|
110
|
+
},
|
|
111
|
+
set: function (value) {
|
|
112
|
+
if (this._b !== value) {
|
|
113
|
+
this._b = value;
|
|
114
|
+
this.fire('change', 'b', this._b, value);
|
|
115
|
+
}
|
|
116
|
+
THREE.Color;
|
|
117
|
+
},
|
|
118
|
+
enumerable: false,
|
|
119
|
+
configurable: true
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(Color.prototype, "a", {
|
|
122
|
+
get: function () {
|
|
123
|
+
return this._a;
|
|
124
|
+
},
|
|
125
|
+
set: function (value) {
|
|
126
|
+
if (this._a !== value) {
|
|
127
|
+
this._a = value;
|
|
128
|
+
this.fire('change', 'a', this._a, value);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
enumerable: false,
|
|
132
|
+
configurable: true
|
|
133
|
+
});
|
|
134
|
+
Color.prototype.set = function (value) {
|
|
135
|
+
if (value && value.isColor) {
|
|
136
|
+
this.copy(value);
|
|
137
|
+
}
|
|
138
|
+
else if (typeof value === 'number') {
|
|
139
|
+
this.setHex(value);
|
|
140
|
+
}
|
|
141
|
+
return this;
|
|
142
|
+
};
|
|
143
|
+
Color.prototype.setHex = function (hex) {
|
|
144
|
+
hex = Math.floor(hex);
|
|
145
|
+
if (hex > 0xffffff) {
|
|
146
|
+
this._r = (hex >> 32 & 255) / 255;
|
|
147
|
+
this._g = (hex >> 16 & 255) / 255;
|
|
148
|
+
this._b = (hex >> 8 & 255) / 255;
|
|
149
|
+
this._a = (hex & 255) / 255;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this._r = (hex >> 16 & 255) / 255;
|
|
153
|
+
this._g = (hex >> 8 & 255) / 255;
|
|
154
|
+
this._b = (hex & 255) / 255;
|
|
155
|
+
}
|
|
156
|
+
return this;
|
|
157
|
+
};
|
|
158
|
+
Color.prototype.setRGB = function (r, g, b, a) {
|
|
159
|
+
if (a === void 0) { a = 1.0; }
|
|
160
|
+
this._r = r;
|
|
161
|
+
this._g = g;
|
|
162
|
+
this._b = b;
|
|
163
|
+
this._a = a;
|
|
164
|
+
return this;
|
|
165
|
+
};
|
|
166
|
+
Color.prototype.clone = function () {
|
|
167
|
+
return new this.constructor(this.r, this.g, this.b, this.a);
|
|
168
|
+
};
|
|
169
|
+
Color.prototype.copy = function (color) {
|
|
170
|
+
this._r = color.r;
|
|
171
|
+
this._g = color.g;
|
|
172
|
+
this._b = color.b;
|
|
173
|
+
return this;
|
|
174
|
+
};
|
|
175
|
+
Color.prototype.equals = function (c) {
|
|
176
|
+
return (c.r === this.r) && (c.g === this.g) && (c.b === this.b);
|
|
177
|
+
};
|
|
178
|
+
Color.prototype.toArray = function (array, offset) {
|
|
179
|
+
if (array === void 0) { array = []; }
|
|
180
|
+
if (offset === void 0) { offset = 0; }
|
|
181
|
+
array[offset] = this.r;
|
|
182
|
+
array[offset + 1] = this.g;
|
|
183
|
+
array[offset + 2] = this.b;
|
|
184
|
+
array[offset + 3] = this.a;
|
|
185
|
+
return array;
|
|
186
|
+
};
|
|
187
|
+
Color.prototype.getHex = function () {
|
|
188
|
+
return (this.r * 255) << 32 ^ (this.g * 255) << 16 ^ (this.b * 255) << 8 ^ (this.a * 255) << 0;
|
|
189
|
+
};
|
|
190
|
+
Color.prototype.toJSON = function () {
|
|
191
|
+
return this.getHex();
|
|
192
|
+
};
|
|
193
|
+
return Color;
|
|
194
|
+
}(eventhandler_1.EventHandler));
|
|
195
|
+
exports.Color = Color;
|
package/dist/math/Euler.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -21,8 +19,8 @@ var Math_1 = require("./Math");
|
|
|
21
19
|
var Mat4_1 = require("./Mat4");
|
|
22
20
|
var Quat_1 = require("./Quat");
|
|
23
21
|
var eventhandler_1 = require("../render/eventhandler");
|
|
24
|
-
var _matrix =
|
|
25
|
-
var _Quat =
|
|
22
|
+
var _matrix = Mat4_1.m4();
|
|
23
|
+
var _Quat = Quat_1.quat();
|
|
26
24
|
var RotationOrders = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
|
|
27
25
|
var DefaultOrder = "XYZ";
|
|
28
26
|
var Euler = /** @class */ (function (_super) {
|
|
@@ -119,7 +117,7 @@ var Euler = /** @class */ (function (_super) {
|
|
|
119
117
|
var m31 = te[2], m32 = te[6], m33 = te[10];
|
|
120
118
|
order = order || this._order;
|
|
121
119
|
if (order === "XYZ") {
|
|
122
|
-
this._y = Math.asin(
|
|
120
|
+
this._y = Math.asin(Math_1.clamp(m13, -1, 1));
|
|
123
121
|
if (Math.abs(m13) < 0.9999999) {
|
|
124
122
|
this._x = Math.atan2(-m23, m33);
|
|
125
123
|
this._z = Math.atan2(-m12, m11);
|
|
@@ -130,7 +128,7 @@ var Euler = /** @class */ (function (_super) {
|
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
else if (order === "YXZ") {
|
|
133
|
-
this._x = Math.asin(-
|
|
131
|
+
this._x = Math.asin(-Math_1.clamp(m23, -1, 1));
|
|
134
132
|
if (Math.abs(m23) < 0.9999999) {
|
|
135
133
|
this._y = Math.atan2(m13, m33);
|
|
136
134
|
this._z = Math.atan2(m21, m22);
|
|
@@ -141,7 +139,7 @@ var Euler = /** @class */ (function (_super) {
|
|
|
141
139
|
}
|
|
142
140
|
}
|
|
143
141
|
else if (order === "ZXY") {
|
|
144
|
-
this._x = Math.asin(
|
|
142
|
+
this._x = Math.asin(Math_1.clamp(m32, -1, 1));
|
|
145
143
|
if (Math.abs(m32) < 0.9999999) {
|
|
146
144
|
this._y = Math.atan2(-m31, m33);
|
|
147
145
|
this._z = Math.atan2(-m12, m22);
|
|
@@ -152,7 +150,7 @@ var Euler = /** @class */ (function (_super) {
|
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
else if (order === "ZYX") {
|
|
155
|
-
this._y = Math.asin(-
|
|
153
|
+
this._y = Math.asin(-Math_1.clamp(m31, -1, 1));
|
|
156
154
|
if (Math.abs(m31) < 0.9999999) {
|
|
157
155
|
this._x = Math.atan2(m32, m33);
|
|
158
156
|
this._z = Math.atan2(m21, m11);
|
|
@@ -163,7 +161,7 @@ var Euler = /** @class */ (function (_super) {
|
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
else if (order === "YZX") {
|
|
166
|
-
this._z = Math.asin(
|
|
164
|
+
this._z = Math.asin(Math_1.clamp(m21, -1, 1));
|
|
167
165
|
if (Math.abs(m21) < 0.9999999) {
|
|
168
166
|
this._x = Math.atan2(-m23, m22);
|
|
169
167
|
this._y = Math.atan2(-m31, m11);
|
|
@@ -174,7 +172,7 @@ var Euler = /** @class */ (function (_super) {
|
|
|
174
172
|
}
|
|
175
173
|
}
|
|
176
174
|
else if (order === "XZY") {
|
|
177
|
-
this._z = Math.asin(-
|
|
175
|
+
this._z = Math.asin(-Math_1.clamp(m12, -1, 1));
|
|
178
176
|
if (Math.abs(m12) < 0.9999999) {
|
|
179
177
|
this._x = Math.atan2(m32, m22);
|
|
180
178
|
this._y = Math.atan2(m13, m11);
|
|
@@ -233,7 +231,7 @@ var Euler = /** @class */ (function (_super) {
|
|
|
233
231
|
return optionalResult.set(this._x, this._y, this._z);
|
|
234
232
|
}
|
|
235
233
|
else {
|
|
236
|
-
return
|
|
234
|
+
return Vec3_1.v3(this._x, this._y, this._z);
|
|
237
235
|
}
|
|
238
236
|
};
|
|
239
237
|
return Euler;
|
package/dist/math/HVec3.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/dist/math/Mat3.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.m3 = exports.Mat3 = void 0;
|
|
4
4
|
var Vec3_1 = require("./Vec3");
|
|
5
|
-
var _Vec =
|
|
5
|
+
var _Vec = Vec3_1.v3();
|
|
6
6
|
var Mat3 = /** @class */ (function () {
|
|
7
7
|
function Mat3() {
|
|
8
8
|
this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
package/dist/math/Mat4.js
CHANGED
|
@@ -777,14 +777,14 @@ var Mat4 = /** @class */ (function () {
|
|
|
777
777
|
return Mat4;
|
|
778
778
|
}());
|
|
779
779
|
exports.Mat4 = Mat4;
|
|
780
|
-
var _v1 =
|
|
780
|
+
var _v1 = Vec3_1.v3();
|
|
781
781
|
var _m1 = m4();
|
|
782
782
|
var _m2 = m4();
|
|
783
|
-
var _zero =
|
|
784
|
-
var _one =
|
|
785
|
-
var _x =
|
|
786
|
-
var _y =
|
|
787
|
-
var _z =
|
|
783
|
+
var _zero = Vec3_1.v3(0, 0, 0);
|
|
784
|
+
var _one = Vec3_1.v3(1, 1, 1);
|
|
785
|
+
var _x = Vec3_1.v3();
|
|
786
|
+
var _y = Vec3_1.v3();
|
|
787
|
+
var _z = Vec3_1.v3();
|
|
788
788
|
function m4() {
|
|
789
789
|
return new Mat4();
|
|
790
790
|
}
|
package/dist/math/Quat.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -283,7 +281,7 @@ var Quat = /** @class */ (function (_super) {
|
|
|
283
281
|
return this.normalize();
|
|
284
282
|
};
|
|
285
283
|
Quat.prototype.angleTo = function (q) {
|
|
286
|
-
return 2 * Math.acos(Math.abs(
|
|
284
|
+
return 2 * Math.acos(Math.abs(Math_1.clamp(this.dot(q), -1, 1)));
|
|
287
285
|
};
|
|
288
286
|
Quat.prototype.rotateTowards = function (q, step) {
|
|
289
287
|
var angle = this.angleTo(q);
|
package/dist/math/Vec.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/dist/math/Vec2.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/dist/math/Vec3.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -550,14 +548,14 @@ var Vec3 = /** @class */ (function (_super) {
|
|
|
550
548
|
if (normal)
|
|
551
549
|
return this.angleToEx(v, normal);
|
|
552
550
|
var theta = this.dot(v) / Math.sqrt(this.lengthSq() * v.lengthSq());
|
|
553
|
-
return Math.acos(
|
|
551
|
+
return Math.acos(Math_1.clamp(theta, -1, 1));
|
|
554
552
|
};
|
|
555
553
|
Vec3.prototype.angleToEx = function (v, normal) {
|
|
556
554
|
var theta = this.dot(v) / Math.sqrt(this.lengthSq() * v.lengthSq());
|
|
557
555
|
if (this.clone().cross(v).dot(normal) > 0)
|
|
558
|
-
return Math.acos(
|
|
556
|
+
return Math.acos(Math_1.clamp(theta, -1, 1));
|
|
559
557
|
else
|
|
560
|
-
return Math.PI * 2 - Math.acos(
|
|
558
|
+
return Math.PI * 2 - Math.acos(Math_1.clamp(theta, -1, 1));
|
|
561
559
|
};
|
|
562
560
|
Vec3.prototype.distanceTo = function (v) {
|
|
563
561
|
return Math.sqrt(this.distanceToSquared(v));
|
|
@@ -1082,7 +1080,7 @@ var Vec3 = /** @class */ (function (_super) {
|
|
|
1082
1080
|
}(eventhandler_1.EventHandler));
|
|
1083
1081
|
exports.Vec3 = Vec3;
|
|
1084
1082
|
var _vec = v3();
|
|
1085
|
-
var _quat =
|
|
1083
|
+
var _quat = Quat_1.quat();
|
|
1086
1084
|
function v3(x, y, z) {
|
|
1087
1085
|
return new Vec3(x, y, z);
|
|
1088
1086
|
}
|
package/dist/math/Vec4.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/dist/math/vector.js
CHANGED
|
@@ -8,14 +8,12 @@
|
|
|
8
8
|
* @LastEditTime : 2021-08-02 15:50:16
|
|
9
9
|
* @FilePath : \cga.js\src\math\VecArray.ts
|
|
10
10
|
*/
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
12
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
13
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
14
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
15
|
+
r[k] = a[j];
|
|
16
|
+
return r;
|
|
19
17
|
};
|
|
20
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
19
|
var Polygon_1 = require("../struct/3d/Polygon");
|
|
@@ -258,7 +256,7 @@ var vector = /** @class */ (function () {
|
|
|
258
256
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
259
257
|
vec[_i - 2] = arguments[_i];
|
|
260
258
|
}
|
|
261
|
-
vecs.splice.apply(vecs,
|
|
259
|
+
vecs.splice.apply(vecs, __spreadArrays([i * vecs.length, 0], vecs));
|
|
262
260
|
};
|
|
263
261
|
//
|
|
264
262
|
/**
|
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -243,9 +241,11 @@ var Int8BufferAttribute = /** @class */ (function (_super) {
|
|
|
243
241
|
__extends(Int8BufferAttribute, _super);
|
|
244
242
|
function Int8BufferAttribute(array, itemSize, normalized) {
|
|
245
243
|
if (normalized === void 0) { normalized = false; }
|
|
244
|
+
var _this = this;
|
|
246
245
|
if (Array.isArray(array))
|
|
247
246
|
array = new Int8Array(array);
|
|
248
|
-
|
|
247
|
+
_this = _super.call(this, new Int8Array(array), itemSize, normalized) || this;
|
|
248
|
+
return _this;
|
|
249
249
|
}
|
|
250
250
|
return Int8BufferAttribute;
|
|
251
251
|
}(BufferAttribute));
|
|
@@ -254,9 +254,11 @@ var Uint8BufferAttribute = /** @class */ (function (_super) {
|
|
|
254
254
|
__extends(Uint8BufferAttribute, _super);
|
|
255
255
|
function Uint8BufferAttribute(array, itemSize, normalized) {
|
|
256
256
|
if (normalized === void 0) { normalized = false; }
|
|
257
|
+
var _this = this;
|
|
257
258
|
if (Array.isArray(array))
|
|
258
259
|
array = new Uint8Array(array);
|
|
259
|
-
|
|
260
|
+
_this = _super.call(this, array, itemSize, normalized) || this;
|
|
261
|
+
return _this;
|
|
260
262
|
}
|
|
261
263
|
return Uint8BufferAttribute;
|
|
262
264
|
}(BufferAttribute));
|
|
@@ -265,9 +267,11 @@ var Uint8ClampedBufferAttribute = /** @class */ (function (_super) {
|
|
|
265
267
|
__extends(Uint8ClampedBufferAttribute, _super);
|
|
266
268
|
function Uint8ClampedBufferAttribute(array, itemSize, normalized) {
|
|
267
269
|
if (normalized === void 0) { normalized = false; }
|
|
270
|
+
var _this = this;
|
|
268
271
|
if (Array.isArray(array))
|
|
269
272
|
array = new Uint8ClampedArray(array);
|
|
270
|
-
|
|
273
|
+
_this = _super.call(this, array, itemSize, normalized) || this;
|
|
274
|
+
return _this;
|
|
271
275
|
}
|
|
272
276
|
return Uint8ClampedBufferAttribute;
|
|
273
277
|
}(BufferAttribute));
|
|
@@ -276,9 +280,11 @@ var Int16BufferAttribute = /** @class */ (function (_super) {
|
|
|
276
280
|
__extends(Int16BufferAttribute, _super);
|
|
277
281
|
function Int16BufferAttribute(array, itemSize, normalized) {
|
|
278
282
|
if (normalized === void 0) { normalized = false; }
|
|
283
|
+
var _this = this;
|
|
279
284
|
if (Array.isArray(array))
|
|
280
285
|
array = new Int16Array(array);
|
|
281
|
-
|
|
286
|
+
_this = _super.call(this, array, itemSize, normalized) || this;
|
|
287
|
+
return _this;
|
|
282
288
|
}
|
|
283
289
|
return Int16BufferAttribute;
|
|
284
290
|
}(BufferAttribute));
|
|
@@ -287,9 +293,11 @@ var Uint16BufferAttribute = /** @class */ (function (_super) {
|
|
|
287
293
|
__extends(Uint16BufferAttribute, _super);
|
|
288
294
|
function Uint16BufferAttribute(array, itemSize, normalized) {
|
|
289
295
|
if (normalized === void 0) { normalized = false; }
|
|
296
|
+
var _this = this;
|
|
290
297
|
if (Array.isArray(array))
|
|
291
298
|
array = new Uint16Array(array);
|
|
292
|
-
|
|
299
|
+
_this = _super.call(this, array, itemSize) || this;
|
|
300
|
+
return _this;
|
|
293
301
|
}
|
|
294
302
|
return Uint16BufferAttribute;
|
|
295
303
|
}(BufferAttribute));
|
|
@@ -298,9 +306,11 @@ var Int32BufferAttribute = /** @class */ (function (_super) {
|
|
|
298
306
|
__extends(Int32BufferAttribute, _super);
|
|
299
307
|
function Int32BufferAttribute(array, itemSize, normalized) {
|
|
300
308
|
if (normalized === void 0) { normalized = false; }
|
|
309
|
+
var _this = this;
|
|
301
310
|
if (Array.isArray(array))
|
|
302
311
|
array = new Int32Array(array);
|
|
303
|
-
|
|
312
|
+
_this = _super.call(this, array, itemSize, normalized) || this;
|
|
313
|
+
return _this;
|
|
304
314
|
}
|
|
305
315
|
return Int32BufferAttribute;
|
|
306
316
|
}(BufferAttribute));
|
|
@@ -309,9 +319,11 @@ var Uint32BufferAttribute = /** @class */ (function (_super) {
|
|
|
309
319
|
__extends(Uint32BufferAttribute, _super);
|
|
310
320
|
function Uint32BufferAttribute(array, itemSize, normalized) {
|
|
311
321
|
if (normalized === void 0) { normalized = false; }
|
|
322
|
+
var _this = this;
|
|
312
323
|
if (Array.isArray(array))
|
|
313
324
|
array = new Uint32Array(array);
|
|
314
|
-
|
|
325
|
+
_this = _super.call(this, array, itemSize, normalized) || this;
|
|
326
|
+
return _this;
|
|
315
327
|
}
|
|
316
328
|
return Uint32BufferAttribute;
|
|
317
329
|
}(BufferAttribute));
|
|
@@ -320,9 +332,11 @@ var Float32BufferAttribute = /** @class */ (function (_super) {
|
|
|
320
332
|
__extends(Float32BufferAttribute, _super);
|
|
321
333
|
function Float32BufferAttribute(array, itemSize, normalized) {
|
|
322
334
|
if (normalized === void 0) { normalized = false; }
|
|
335
|
+
var _this = this;
|
|
323
336
|
if (Array.isArray(array))
|
|
324
337
|
array = new Float32Array(array);
|
|
325
|
-
|
|
338
|
+
_this = _super.call(this, array, itemSize, normalized) || this;
|
|
339
|
+
return _this;
|
|
326
340
|
}
|
|
327
341
|
return Float32BufferAttribute;
|
|
328
342
|
}(BufferAttribute));
|
|
@@ -331,9 +345,11 @@ var Float64BufferAttribute = /** @class */ (function (_super) {
|
|
|
331
345
|
__extends(Float64BufferAttribute, _super);
|
|
332
346
|
function Float64BufferAttribute(array, itemSize, normalized) {
|
|
333
347
|
if (normalized === void 0) { normalized = false; }
|
|
348
|
+
var _this = this;
|
|
334
349
|
if (Array.isArray(array))
|
|
335
350
|
array = new Float64Array(array);
|
|
336
|
-
|
|
351
|
+
_this = _super.call(this, array, itemSize, normalized) || this;
|
|
352
|
+
return _this;
|
|
337
353
|
}
|
|
338
354
|
return Float64BufferAttribute;
|
|
339
355
|
}(BufferAttribute));
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
+
r[k] = a[j];
|
|
7
|
+
return r;
|
|
10
8
|
};
|
|
11
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
10
|
exports.EventHandler = void 0;
|
|
@@ -141,7 +139,7 @@ var EventHandler = /** @class */ (function () {
|
|
|
141
139
|
// eslint-disable-next-line no-unmodified-loop-condition
|
|
142
140
|
for (var i = 0; (callbacks || this._callbackActive[name]) && (i < (callbacks || this._callbackActive[name]).length); i++) {
|
|
143
141
|
var evt = (callbacks || this._callbackActive[name])[i];
|
|
144
|
-
(_a = evt.callback).call.apply(_a,
|
|
142
|
+
(_a = evt.callback).call.apply(_a, __spreadArrays([evt.scope], args));
|
|
145
143
|
if (evt.once) {
|
|
146
144
|
var ind = this._callbacks[name].indexOf(evt);
|
|
147
145
|
if (ind !== -1) {
|
package/dist/render/geometry.js
CHANGED
|
@@ -95,7 +95,7 @@ var BufferGeometry = /** @class */ (function () {
|
|
|
95
95
|
else if (attribute instanceof buffer_attribute_1.BufferAttribute) {
|
|
96
96
|
this.attributes[name] = attribute;
|
|
97
97
|
}
|
|
98
|
-
else if (
|
|
98
|
+
else if (types_1.isBufferArray(attribute)) {
|
|
99
99
|
this.setAttribute(name, new buffer_attribute_1.BufferAttribute(attribute, itemSize));
|
|
100
100
|
}
|
|
101
101
|
return this;
|
|
@@ -174,7 +174,7 @@ var BufferGeometry = /** @class */ (function () {
|
|
|
174
174
|
return this;
|
|
175
175
|
};
|
|
176
176
|
BufferGeometry.prototype.lookAt = function (vector) {
|
|
177
|
-
_m1.lookAt(
|
|
177
|
+
_m1.lookAt(Vec3_1.v3(), vector, Vec3_1.Vec3.UnitY);
|
|
178
178
|
this.applyMat4(_m1);
|
|
179
179
|
return this;
|
|
180
180
|
};
|