@woosh/meep-engine 2.110.9 → 2.110.10

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.
Files changed (56) hide show
  1. package/build/meep.cjs +23 -1
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +23 -1
  4. package/package.json +1 -1
  5. package/src/core/UUID.js +1 -1
  6. package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
  7. package/src/core/geom/2d/aabb/AABB2.js +27 -1
  8. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.js +25 -2
  9. package/src/core/geom/3d/tetrahedra/get_tetrahedron_volume.d.ts +9 -0
  10. package/src/core/geom/3d/tetrahedra/get_tetrahedron_volume.d.ts.map +1 -0
  11. package/src/core/geom/3d/tetrahedra/get_tetrahedron_volume.js +18 -0
  12. package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.d.ts +9 -0
  13. package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.d.ts.map +1 -0
  14. package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.js +21 -0
  15. package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.d.ts +2 -10
  16. package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.d.ts.map +1 -1
  17. package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.js +3 -40
  18. package/src/core/geom/mat3/m3_cm_invert.d.ts +7 -0
  19. package/src/core/geom/mat3/m3_cm_invert.d.ts.map +1 -0
  20. package/src/core/geom/mat3/m3_cm_invert.js +45 -0
  21. package/src/core/geom/vec2/v2_matrix3_cm_multiply.d.ts +10 -0
  22. package/src/core/geom/vec2/v2_matrix3_cm_multiply.d.ts.map +1 -0
  23. package/src/core/geom/vec2/v2_matrix3_cm_multiply.js +20 -0
  24. package/src/core/geom/vec2/v2_matrix3_rm_multiply.d.ts +10 -0
  25. package/src/core/geom/vec2/v2_matrix3_rm_multiply.d.ts.map +1 -0
  26. package/src/core/geom/vec2/v2_matrix3_rm_multiply.js +21 -0
  27. package/src/core/math/spline/spline_hermite3.js +2 -1
  28. package/src/core/math/spline/spline_hermite3_to_bezier.d.ts +12 -0
  29. package/src/core/math/spline/spline_hermite3_to_bezier.d.ts.map +1 -0
  30. package/src/core/math/spline/spline_hermite3_to_bezier.js +24 -0
  31. package/src/engine/animation/clip/AnimationTrack.js +1 -1
  32. package/src/engine/animation/curve/AnimationCurve.d.ts +11 -0
  33. package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
  34. package/src/engine/animation/curve/AnimationCurve.js +51 -4
  35. package/src/engine/animation/curve/draw/build_curve_editor.d.ts.map +1 -1
  36. package/src/engine/animation/curve/draw/build_curve_editor.js +15 -9
  37. package/src/engine/animation/curve/view/AnimationCurveView.d.ts +47 -0
  38. package/src/engine/animation/curve/view/AnimationCurveView.d.ts.map +1 -0
  39. package/src/engine/animation/curve/view/AnimationCurveView.js +343 -0
  40. package/src/engine/animation/curve/view/prototype.d.ts +2 -0
  41. package/src/engine/animation/curve/view/prototype.d.ts.map +1 -0
  42. package/src/engine/animation/curve/view/prototype.js +86 -0
  43. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +1 -1
  44. package/src/engine/ecs/guid/UUID.d.ts +10 -3
  45. package/src/engine/ecs/guid/UUID.d.ts.map +1 -1
  46. package/src/engine/ecs/guid/UUID.js +17 -5
  47. package/src/engine/ecs/guid/UUID.spec.js +7 -0
  48. package/src/engine/ecs/guid/UUIDSerializationAdapter.spec.d.ts +2 -0
  49. package/src/engine/ecs/guid/UUIDSerializationAdapter.spec.d.ts.map +1 -0
  50. package/src/view/elements/DropDownSelectionView.js +1 -1
  51. package/src/view/elements/tiles2d/Tile.d.ts +1 -1
  52. package/src/view/elements/tiles2d/Tile.d.ts.map +1 -1
  53. package/src/view/elements/tiles2d/Tile.js +2 -1
  54. package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.d.ts +0 -2
  55. package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.d.ts.map +0 -1
  56. /package/src/engine/ecs/guid/{GUIDSerializationAdapter.spec.js → UUIDSerializationAdapter.spec.js} +0 -0
@@ -14,6 +14,7 @@ import { DraggableAspect } from "../../../ui/DraggableAspect.js";
14
14
  import { animation_curve_compute_aabb } from "../animation_curve_compute_aabb.js";
15
15
  import { sample_animation_curve_to_float_array } from "../compression/sample_animation_curve_to_float_array.js";
16
16
  import { Keyframe } from "../Keyframe.js";
17
+ import { build_tangent_editor } from "./build_tangent_editor.js";
17
18
 
18
19
  /**
19
20
  *
@@ -133,6 +134,10 @@ export function build_curve_editor({
133
134
 
134
135
  const keyframe_views = new Map();
135
136
 
137
+ /**
138
+ *
139
+ * @param {Keyframe} keyframe
140
+ */
136
141
  function add_keyframe(keyframe) {
137
142
  const vContainerMarker = new EmptyView({
138
143
  css: {
@@ -202,7 +207,8 @@ export function build_curve_editor({
202
207
 
203
208
  const previous = new Vector2();
204
209
  const draggable = new DraggableAspect({
205
- el: marker_el, drag(position) {
210
+ el: marker_el,
211
+ drag(position) {
206
212
  const delta = new Vector2();
207
213
  delta.subVectors(position, previous);
208
214
 
@@ -300,14 +306,14 @@ export function build_curve_editor({
300
306
  marker.bindSignal(frame_updated, updatePosition);
301
307
  marker.bindSignal(active_keyframe.onChanged, updateActiveState);
302
308
 
303
- // const vTangentEditor = build_tangent_editor({
304
- // keyframe: keyframe,
305
- // size: graph.size,
306
- // ctx: graph.context2d,
307
- // frame,
308
- // margin
309
- // });
310
- // vContainerMarker.addChild(vTangentEditor);
309
+ const vTangentEditor = build_tangent_editor({
310
+ keyframe: keyframe,
311
+ size: graph.size,
312
+ ctx: graph.context2d,
313
+ frame,
314
+ margin
315
+ });
316
+ vContainerMarker.addChild(vTangentEditor);
311
317
 
312
318
  vContainerMarker.addChild(marker);
313
319
 
@@ -0,0 +1,47 @@
1
+ export class AnimationCurveView extends EmptyView {
2
+ constructor();
3
+ /**
4
+ *
5
+ * @param {AnimationCurve} v
6
+ */
7
+ set curve(arg: AnimationCurve);
8
+ auto_set_frame(): void;
9
+ /**
10
+ *
11
+ * @param {Float32Array|number[]} out
12
+ * @param {number} x
13
+ * @param {number} y
14
+ */
15
+ point_curve_to_canvas(out: Float32Array | number[], x: number, y: number): void;
16
+ /**
17
+ *
18
+ * @param {Float32Array|number[]} out
19
+ * @param {number} x
20
+ * @param {number} y
21
+ */
22
+ point_canvas_to_curve(out: Float32Array | number[], x: number, y: number): void;
23
+ update(): void;
24
+ draw(): void;
25
+ draw_grid(): void;
26
+ draw_key_knots(): void;
27
+ draw_key_knot(key: any): void;
28
+ /**
29
+ *
30
+ * @param {Keyframe} keyframe
31
+ */
32
+ draw_key_tangents(keyframe: Keyframe): void;
33
+ /**
34
+ *
35
+ * @param {CanvasRenderingContext2D} ctx
36
+ * @param {Keyframe} keyframe
37
+ * @param {number} angle
38
+ * @param {number} handle_length in pixels
39
+ */
40
+ draw_tangent(ctx: CanvasRenderingContext2D, keyframe: Keyframe, angle: number, handle_length: number): void;
41
+ draw_tangents(): void;
42
+ draw_curve(): void;
43
+ #private;
44
+ }
45
+ import EmptyView from "../../../../view/elements/EmptyView.js";
46
+ import { AnimationCurve } from "../AnimationCurve.js";
47
+ //# sourceMappingURL=AnimationCurveView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimationCurveView.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/view/AnimationCurveView.js"],"names":[],"mappings":"AAeA;IAoCI,cAWC;IAtBD;;;OAGG;IACH,+BAIC;IAgBD,uBA6BC;IAoBD;;;;;OAKG;IACH,2BAJW,YAAY,GAAC,MAAM,EAAE,KACrB,MAAM,KACN,MAAM,QAWhB;IAED;;;;;OAKG;IACH,2BAJW,YAAY,GAAC,MAAM,EAAE,KACrB,MAAM,KACN,MAAM,QAQhB;IAED,eASC;IAED,aAsBC;IAED,kBAwBC;IAED,uBAQC;IAED,8BAiBC;IAGD;;;OAGG;IACH,4BAFW,QAAQ,QAelB;IAED;;;;;;OAMG;IACH,kBALW,wBAAwB,YACxB,QAAQ,SACR,MAAM,iBACN,MAAM,QA+BhB;IAED,sBASC;IAED,mBAqCC;;CAEJ;sBA/UqB,wCAAwC;+BAG/B,sBAAsB"}
@@ -0,0 +1,343 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+ import AABB2 from "../../../../core/geom/2d/aabb/AABB2.js";
3
+ import { m3_cm_compose_transform } from "../../../../core/geom/mat3/m3_cm_compose_transform.js";
4
+ import { m3_cm_invert } from "../../../../core/geom/mat3/m3_cm_invert.js";
5
+ import { v2_length } from "../../../../core/geom/vec2/v2_length.js";
6
+ import { v2_matrix3_cm_multiply } from "../../../../core/geom/vec2/v2_matrix3_cm_multiply.js";
7
+ import { CanvasView } from "../../../../view/elements/CanvasView.js";
8
+ import EmptyView from "../../../../view/elements/EmptyView.js";
9
+ import { canvas2d_draw_grid } from "../../../graphics/canvas/canvas2d_draw_grid.js";
10
+ import { animation_curve_compute_aabb } from "../animation_curve_compute_aabb.js";
11
+ import { AnimationCurve } from "../AnimationCurve.js";
12
+
13
+ const scratch_v2_a = new Float32Array(2);
14
+ const scratch_v2_b = new Float32Array(2);
15
+
16
+ export class AnimationCurveView extends EmptyView {
17
+
18
+ #curve = AnimationCurve.constant();
19
+ #canvas = new CanvasView();
20
+ #frame = new AABB2();
21
+ #curve_bounds = new AABB2();
22
+
23
+ /**
24
+ * 3x3 transform matrix
25
+ * Transform from curve space to canvas space
26
+ * @type {Float32Array}
27
+ */
28
+ #transform = new Float32Array(9);
29
+ /**
30
+ * 3x3 inverse of transform matrix
31
+ * @type {Float32Array}
32
+ */
33
+ #transform_inverse = new Float32Array(9);
34
+
35
+ /**
36
+ *
37
+ * @type {number}
38
+ */
39
+ #margin = 36
40
+
41
+ /**
42
+ *
43
+ * @param {AnimationCurve} v
44
+ */
45
+ set curve(v) {
46
+ this.#curve = v;
47
+
48
+ this.update();
49
+ }
50
+
51
+
52
+ constructor() {
53
+ super();
54
+
55
+ this.addChild(this.#canvas);
56
+
57
+ this.size.onChanged.add((x, y) => {
58
+
59
+ this.#canvas.size.set(x, y);
60
+ this.update();
61
+
62
+ });
63
+ }
64
+
65
+ auto_set_frame() {
66
+ animation_curve_compute_aabb(this.#curve_bounds, this.#curve);
67
+
68
+ this.#frame.copy(this.#curve_bounds);
69
+
70
+ if (this.#frame.height === 0) {
71
+ this.#frame.growHeight(0.5);
72
+ }
73
+
74
+ if (this.#frame.width === 0) {
75
+ this.#frame.growWidth(0.5);
76
+ }
77
+
78
+ const margin_top = this.#margin;
79
+ const margin_bottom = this.#margin;
80
+ const margin_left = this.#margin;
81
+ const margin_right = this.#margin;
82
+
83
+ const normalized_margin_left = (margin_left / this.size.x) * this.#frame.width;
84
+ const normalized_margin_right = (margin_right / this.size.x) * this.#frame.width;
85
+ const normalized_margin_top = (margin_top / this.size.y) * this.#frame.height;
86
+ const normalized_margin_bottom = (margin_bottom / this.size.y) * this.#frame.height;
87
+
88
+ this.#frame.x0 -= normalized_margin_left;
89
+ this.#frame.x1 += normalized_margin_right;
90
+ this.#frame.y0 -= normalized_margin_top;
91
+ this.#frame.y1 += normalized_margin_bottom;
92
+
93
+ this.#update_frame();
94
+ }
95
+
96
+ #update_frame() {
97
+
98
+ const frame = this.#frame;
99
+ const size = this.size;
100
+
101
+ const scale_x = size.x / frame.width;
102
+ const scale_y = -size.y / frame.height;
103
+
104
+ m3_cm_compose_transform(
105
+ this.#transform,
106
+ -frame.x0, -frame.y1,
107
+ scale_x, scale_y,
108
+ frame.x0, frame.y1, 0
109
+ );
110
+
111
+ m3_cm_invert(this.#transform_inverse, this.#transform);
112
+ }
113
+
114
+ /**
115
+ *
116
+ * @param {Float32Array|number[]} out
117
+ * @param {number} x
118
+ * @param {number} y
119
+ */
120
+ point_curve_to_canvas(out, x, y) {
121
+
122
+ assert.notNaN(x, 'x');
123
+ assert.notNaN(y, 'y');
124
+
125
+ v2_matrix3_cm_multiply(out, 0,
126
+ x, y, this.#transform
127
+ );
128
+
129
+ }
130
+
131
+ /**
132
+ *
133
+ * @param {Float32Array|number[]} out
134
+ * @param {number} x
135
+ * @param {number} y
136
+ */
137
+ point_canvas_to_curve(out, x, y) {
138
+
139
+ v2_matrix3_cm_multiply(out, 0,
140
+ x, y, this.#transform_inverse
141
+ );
142
+
143
+ }
144
+
145
+ update() {
146
+ if (this.size.x <= 0 || this.size.y <= 0) {
147
+ // size too small
148
+ return;
149
+ }
150
+
151
+ this.auto_set_frame();
152
+
153
+ this.draw();
154
+ }
155
+
156
+ draw() {
157
+ const ctx = this.#canvas.context2d;
158
+
159
+ ctx.fillStyle = '#222222';
160
+ ctx.fillRect(0, 0, this.size.x, this.size.y);
161
+
162
+ this.draw_grid();
163
+
164
+
165
+ ctx.fillStyle = 'none';
166
+ ctx.strokeStyle = '#00ff00';
167
+ ctx.lineWidth = 1;
168
+
169
+ this.draw_curve();
170
+
171
+ ctx.fillStyle = 'none';
172
+ ctx.strokeStyle = '#0080ff';
173
+ ctx.lineWidth = 1;
174
+
175
+ this.draw_tangents();
176
+
177
+ this.draw_key_knots();
178
+ }
179
+
180
+ draw_grid() {
181
+ const ctx = this.#canvas.context2d;
182
+
183
+ const width = this.size.x;
184
+ const height = this.size.y;
185
+
186
+ canvas2d_draw_grid({
187
+ ctx,
188
+ width,
189
+ height,
190
+ color: '#262626',
191
+ spacing: 32,
192
+ offset_x: 0
193
+ });
194
+
195
+ canvas2d_draw_grid({
196
+ ctx,
197
+ width,
198
+ height,
199
+ color: '#303030',
200
+ spacing: 32,
201
+ offset_x: 16,
202
+ offset_y: 16
203
+ });
204
+ }
205
+
206
+ draw_key_knots() {
207
+ const keys = this.#curve.keys;
208
+ const key_count = keys.length;
209
+
210
+ for (let i = 0; i < key_count; i++) {
211
+ this.draw_key_knot(keys[i]);
212
+ }
213
+
214
+ }
215
+
216
+ draw_key_knot(key) {
217
+
218
+ const ctx = this.#canvas.context2d;
219
+
220
+ this.point_curve_to_canvas(scratch_v2_a, key.time, key.value);
221
+
222
+ const stroke_width = 1;
223
+ const radius = 2;
224
+
225
+ ctx.beginPath();
226
+ ctx.arc(scratch_v2_a[0], scratch_v2_a[1], radius + stroke_width * 0.5, 0, 2 * Math.PI, false);
227
+ ctx.fillStyle = 'green';
228
+ ctx.fill();
229
+ ctx.lineWidth = stroke_width;
230
+ ctx.strokeStyle = 'rgba(0,133,0,0.2)';
231
+ ctx.stroke();
232
+
233
+ }
234
+
235
+
236
+ /**
237
+ *
238
+ * @param {Keyframe} keyframe
239
+ */
240
+ draw_key_tangents(keyframe) {
241
+ const handle_length = 36;
242
+
243
+ const ctx = this.#canvas.context2d;
244
+
245
+ // incoming
246
+ const in_angle = -Math.atan2(keyframe.inTangent, -1);
247
+ this.draw_tangent(ctx, keyframe, in_angle, handle_length);
248
+
249
+ // outgoing
250
+ const ut_angle = Math.atan2(keyframe.outTangent, 1);
251
+
252
+ this.draw_tangent(ctx, keyframe, ut_angle, handle_length);
253
+ }
254
+
255
+ /**
256
+ *
257
+ * @param {CanvasRenderingContext2D} ctx
258
+ * @param {Keyframe} keyframe
259
+ * @param {number} angle
260
+ * @param {number} handle_length in pixels
261
+ */
262
+ draw_tangent(ctx, keyframe, angle, handle_length) {
263
+ ctx.beginPath();
264
+
265
+ this.point_curve_to_canvas(scratch_v2_a, keyframe.time, keyframe.value);
266
+
267
+ ctx.moveTo(scratch_v2_a[0], scratch_v2_a[1]);
268
+
269
+ this.point_curve_to_canvas(scratch_v2_b,
270
+ keyframe.time + Math.cos(angle),
271
+ keyframe.value + Math.sin(angle)
272
+ );
273
+
274
+ // a - b
275
+ scratch_v2_b[0] -= scratch_v2_a[0];
276
+ scratch_v2_b[1] -= scratch_v2_a[1];
277
+
278
+ // normalize to desired length
279
+ const norm = handle_length / v2_length(scratch_v2_b[0], scratch_v2_b[1]);
280
+
281
+ scratch_v2_b[0] *= norm;
282
+ scratch_v2_b[1] *= norm;
283
+
284
+ // restore offset
285
+ scratch_v2_b[0] += scratch_v2_a[0];
286
+ scratch_v2_b[1] += scratch_v2_a[1];
287
+
288
+ ctx.lineTo(scratch_v2_b[0], scratch_v2_b[1]);
289
+
290
+ ctx.stroke();
291
+ }
292
+
293
+ draw_tangents() {
294
+ const curve = this.#curve;
295
+ const keys = curve.keys;
296
+
297
+ for (let i = 0; i < keys.length; i++) {
298
+ const keyframe = keys[i];
299
+
300
+ this.draw_key_tangents(keyframe);
301
+ }
302
+ }
303
+
304
+ draw_curve() {
305
+
306
+ const ctx = this.#canvas.context2d;
307
+
308
+ ctx.beginPath();
309
+
310
+ const curve = this.#curve;
311
+
312
+ const keys = curve.keys;
313
+
314
+ if (keys.length < 2) {
315
+ return;
316
+ }
317
+
318
+ const duration = curve.duration;
319
+ const first_key = curve.keys[0];
320
+ const time_start = first_key.time;
321
+
322
+ const segments = Math.ceil(this.size.x / 4);
323
+
324
+ this.point_curve_to_canvas(scratch_v2_a, first_key.time, first_key.value);
325
+
326
+ ctx.moveTo(scratch_v2_a[0], scratch_v2_a[1]);
327
+
328
+ for (let i = 1; i < segments; i++) {
329
+ const t = i / (segments - 1);
330
+
331
+ const time = time_start + duration * t;
332
+
333
+ const value = curve.evaluate(time);
334
+
335
+ this.point_curve_to_canvas(scratch_v2_a, time, value);
336
+
337
+ ctx.lineTo(scratch_v2_a[0], scratch_v2_a[1]);
338
+ }
339
+
340
+ ctx.stroke();
341
+ }
342
+
343
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prototype.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/view/prototype.js"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ import { randomFloatBetween } from "../../../../core/math/random/randomFloatBetween.js";
2
+ import { seededRandom } from "../../../../core/math/random/seededRandom.js";
3
+ import { CSS_ABSOLUTE_POSITIONING } from "../../../../view/CSS_ABSOLUTE_POSITIONING.js";
4
+ import { AnimationCurve } from "../AnimationCurve.js";
5
+ import { Keyframe } from "../Keyframe.js";
6
+ import { AnimationCurveView } from "./AnimationCurveView.js";
7
+
8
+ let px = 0;
9
+ let py = 0;
10
+
11
+ function addCurve(curve) {
12
+
13
+
14
+ const view = new AnimationCurveView();
15
+ view.curve = curve;
16
+
17
+ view.css(CSS_ABSOLUTE_POSITIONING);
18
+
19
+ view.size.set(460, 288);
20
+
21
+ if (px + view.size.x > window.innerWidth) {
22
+ px = 0;
23
+ py += view.size.y;
24
+ }
25
+
26
+ view.position.set(px, py);
27
+
28
+ px += view.size.x;
29
+
30
+
31
+ document.body.appendChild(view.el);
32
+
33
+ view.css({
34
+ border: "1px solid rgba(255,255,255,0.2)"
35
+ });
36
+
37
+ view.link();
38
+
39
+ }
40
+
41
+ document.body.style.background = "black";
42
+ document.body.style.overflow = "hidden";
43
+ document.body.style.margin = "0";
44
+
45
+ addCurve(AnimationCurve.constant());
46
+ addCurve(AnimationCurve.easeInOut(0,0,1000));
47
+ addCurve(AnimationCurve.linear());
48
+ addCurve(AnimationCurve.from([
49
+ Keyframe.from(0, 0),
50
+ Keyframe.from(1, 1),
51
+ Keyframe.from(2, 0.5)
52
+ ]));
53
+
54
+
55
+ addCurve(AnimationCurve.from([
56
+ Keyframe.from(-5, 7),
57
+ Keyframe.from(-2, -11)
58
+ ]));
59
+ addCurve(AnimationCurve.from([
60
+ Keyframe.from(-1, 1),
61
+ Keyframe.from(1, -1)
62
+ ]));
63
+
64
+
65
+ addCurve(AnimationCurve.from([
66
+ Keyframe.from(-5, 0),
67
+ Keyframe.from(1, 200)
68
+ ]));
69
+
70
+ const random = seededRandom();
71
+
72
+ const array = new Array(8).fill('');
73
+ const keys = array.map(()=> Keyframe.from(
74
+ randomFloatBetween(random,-100,100),
75
+ randomFloatBetween(random,-100,100),
76
+ ));
77
+
78
+ const curve = AnimationCurve.from(keys);
79
+
80
+ for (let i = 0; i < keys.length; i++) {
81
+
82
+ curve.alignTangents(i);
83
+ }
84
+ curve.smoothAllTangents();
85
+
86
+ addCurve(curve)
@@ -99,7 +99,7 @@ export class DynamicRuleDescription {
99
99
  }
100
100
 
101
101
  fromJSON({
102
- id = UUID.v1().toString(),
102
+ id = UUID.string(),
103
103
  condition,
104
104
  action,
105
105
  global_cooldowns = [],
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Globally unique identifier
3
- * @class
2
+ * Universally Unique Identifier
3
+ * @see IETF RFC 4122
4
+ *
4
5
  */
5
6
  export class UUID {
6
7
  /**
@@ -9,6 +10,12 @@ export class UUID {
9
10
  */
10
11
  static v1(): UUID;
11
12
  static v4(): UUID;
13
+ /**
14
+ * Shortcut to generate string-form ID
15
+ * Uses v4 UUID
16
+ * @return {string}
17
+ */
18
+ static string(): string;
12
19
  /**
13
20
  *
14
21
  * @param {string} string
@@ -27,7 +34,7 @@ export class UUID {
27
34
  get data(): Uint8Array;
28
35
  /**
29
36
  * Generate Variant 1 UUID
30
- * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/v1.js#L17
37
+ *
31
38
  */
32
39
  v1(): void;
33
40
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"UUID.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUID.js"],"names":[],"mappings":"AAuBA;;;GAGG;AACH;IAgHI;;;OAGG;IACH,aAFY,IAAI,CAQf;IAED,kBAMC;IA0CD;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,CAQf;IApLD;;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,WAqEC;IAED;;OAEG;IACH,WAUC;IAsBD;;;;OAIG;IACH,cAFW,MAAM,QAmChB;IAeD;;;OAGG;IACH,YAFa,MAAM,CA2BlB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAanB;IAED;;OAEG;IACH,QAFa,MAAM,CAWlB;IAED,iBAEC;IAED,uBAEC;IASL;;;OAGG;IACH,iBAFU,OAAO,CAEI;;CAZpB;;kBAIS,MAAM"}
1
+ {"version":3,"file":"UUID.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUID.js"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH;IAiHI;;;OAGG;IACH,aAFY,IAAI,CAQf;IAED,kBAMC;IAED;;;;OAIG;IACH,iBAFY,MAAM,CAIjB;IA0CD;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,CAQf;IA9LD;;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,WAsEC;IAED;;OAEG;IACH,WAUC;IA+BD;;;;OAIG;IACH,cAFW,MAAM,QAmChB;IAeD;;;OAGG;IACH,YAFa,MAAM,CA2BlB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAanB;IAED;;OAEG;IACH,QAFa,MAAM,CAWlB;IAED,iBAEC;IAED,uBAEC;IASL;;;OAGG;IACH,iBAFU,OAAO,CAEI;;CAZpB;;kBAIS,MAAM"}
@@ -9,6 +9,7 @@ import { seededRandom } from "../../../core/math/random/seededRandom.js";
9
9
  let _lastMSecs = 0;
10
10
  let _lastNSecs = 0;
11
11
 
12
+ // seed random with current time to lower potential correlation
12
13
  const random = seededRandom(Date.now());
13
14
 
14
15
  // node and clockseq need to be initialized to random values.
@@ -22,8 +23,9 @@ _nodeId[0] |= 0x01;
22
23
  let _clockseq = ((randomUint8(random) << 8) | randomUint8(random)) & 0x3fff;
23
24
 
24
25
  /**
25
- * Globally unique identifier
26
- * @class
26
+ * Universally Unique Identifier
27
+ * @see IETF RFC 4122
28
+ *
27
29
  */
28
30
  export class UUID {
29
31
  #data = new Uint8Array(16);
@@ -34,7 +36,7 @@ export class UUID {
34
36
  */
35
37
  set data(bytes) {
36
38
  assert.isArrayLike(bytes, 'bytes');
37
- assert.greaterThanOrEqual(bytes.length, 16, 'bytes.length >= 16');
39
+ assert.greaterThanOrEqual(bytes.length, 16, 'bytes.length < 16');
38
40
 
39
41
  array_copy(bytes, 0, this.#data, 0, 16);
40
42
  }
@@ -49,9 +51,10 @@ export class UUID {
49
51
 
50
52
  /**
51
53
  * Generate Variant 1 UUID
52
- * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/v1.js#L17
54
+ *
53
55
  */
54
56
  v1() {
57
+ // @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/v1.js#L17
55
58
 
56
59
  const b = this.#data;
57
60
 
@@ -83,7 +86,7 @@ export class UUID {
83
86
 
84
87
  // Per 4.2.1.2 Throw error if too many uuids are requested
85
88
  if (nsecs >= 10000) {
86
- throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
89
+ throw new Error(".v1(): Can't create more than 10M uuids/sec");
87
90
  }
88
91
 
89
92
  _lastMSecs = msecs;
@@ -157,6 +160,15 @@ export class UUID {
157
160
  return r;
158
161
  }
159
162
 
163
+ /**
164
+ * Shortcut to generate string-form ID
165
+ * Uses v4 UUID
166
+ * @return {string}
167
+ */
168
+ static string() {
169
+ return UUID.v4().toString();
170
+ }
171
+
160
172
  /***
161
173
  * String in UUID format
162
174
  * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/parse.js#L3
@@ -90,4 +90,11 @@ test("version bits in v4", () => {
90
90
  const uuid = UUID.v4();
91
91
 
92
92
  expect((uuid.data[6] >> 4) & 0xF).toEqual(4);
93
+ });
94
+
95
+ test("static 'string' method",()=>{
96
+ const s = UUID.string();
97
+
98
+ expect(typeof s).toBe("string");
99
+ expect(s.length).toBe(36);
93
100
  });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=UUIDSerializationAdapter.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UUIDSerializationAdapter.spec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUIDSerializationAdapter.spec.js"],"names":[],"mappings":""}
@@ -56,7 +56,7 @@ class DropDownSelectionView extends View {
56
56
 
57
57
  const text = this.transfrom(el);
58
58
 
59
- const id = UUID.v1().toString();
59
+ const id = UUID.string();
60
60
 
61
61
  this.mapping.set(el, id);
62
62
 
@@ -9,8 +9,8 @@ declare class TileView extends View<HTMLElement> {
9
9
  * @param {Vector2} [size]
10
10
  */
11
11
  constructor({ model, spacing, size }: Rectangle);
12
- model: Rectangle;
13
12
  uuid: string;
13
+ model: Rectangle;
14
14
  __cellSize: Rectangle;
15
15
  __spacing: Rectangle;
16
16
  el: Element;