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