@woosh/meep-engine 2.134.5 → 2.135.0

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 (155) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/editor/tools/v2/TransformControlsGizmo.js +1 -1
  4. package/editor/view/node-graph/NodeGraphEditorView.js +2 -2
  5. package/package.json +1 -1
  6. package/src/core/assert.d.ts +0 -2
  7. package/src/core/assert.d.ts.map +1 -1
  8. package/src/core/assert.js +0 -6
  9. package/src/core/color/Color.d.ts +0 -5
  10. package/src/core/color/Color.d.ts.map +1 -1
  11. package/src/core/color/Color.js +1 -7
  12. package/src/core/geom/2d/hash-grid/SpatialHashGrid.js +386 -386
  13. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +1 -1
  14. package/src/core/geom/2d/quad-tree-binary/QuadTree.js +714 -714
  15. package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +160 -160
  16. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +96 -96
  17. package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +1 -1
  18. package/src/core/geom/packing/max-rect/findBestContainer.js +4 -4
  19. package/src/core/geom/packing/max-rect/packOneBox.js +2 -2
  20. package/src/core/geom/vec3/v3_rigid_align_paired_unit_vectors.js +1 -1
  21. package/src/core/graph/layout/box/BoxLayouter.js +7 -7
  22. package/src/core/graph/layout/box/position_box_next_to_box.js +6 -6
  23. package/src/core/math/computeWholeDivisorLow.js +33 -33
  24. package/src/core/math/linalg/eigen/eigen_values_find_spectral_gap.d.ts.map +1 -0
  25. package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts +10 -0
  26. package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts.map +1 -0
  27. package/src/core/{graph → math/linalg}/eigen/matrix_eigenvalues_in_place.js +8 -7
  28. package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts.map +1 -0
  29. package/src/core/{graph → math/linalg}/eigen/matrix_householder_in_place.js +11 -5
  30. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +15 -0
  31. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -0
  32. package/src/core/{graph → math/linalg}/eigen/matrix_qr_in_place.js +8 -2
  33. package/src/core/{graph → math/linalg}/eigen/matrix_top_eigenvector_power_iteration.d.ts +0 -3
  34. package/src/core/math/linalg/eigen/matrix_top_eigenvector_power_iteration.d.ts.map +1 -0
  35. package/src/core/{graph → math/linalg}/eigen/matrix_top_eigenvector_power_iteration.js +0 -3
  36. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts +19 -0
  37. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts.map +1 -0
  38. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.js +161 -0
  39. package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts +15 -0
  40. package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts.map +1 -0
  41. package/src/core/math/linalg/polynomial_real_roots_in_interval.js +200 -0
  42. package/src/core/math/solveCubic.d.ts +15 -0
  43. package/src/core/math/solveCubic.d.ts.map +1 -0
  44. package/src/core/math/solveCubic.js +82 -0
  45. package/src/core/math/spline/spline3_hermite_bounds_t.d.ts +23 -0
  46. package/src/core/math/spline/spline3_hermite_bounds_t.d.ts.map +1 -0
  47. package/src/core/math/spline/spline3_hermite_bounds_t.js +109 -0
  48. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts +25 -0
  49. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts.map +1 -0
  50. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.js +44 -0
  51. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts +16 -0
  52. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts.map +1 -0
  53. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.js +120 -0
  54. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts +11 -0
  55. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts.map +1 -0
  56. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.js +451 -0
  57. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts +12 -0
  58. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts.map +1 -0
  59. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.js +339 -0
  60. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts +15 -0
  61. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts.map +1 -0
  62. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.js +21 -0
  63. package/src/core/math/spline/spline3_hermite_to_monomial.d.ts +24 -0
  64. package/src/core/math/spline/spline3_hermite_to_monomial.d.ts.map +1 -0
  65. package/src/core/math/spline/spline3_hermite_to_monomial.js +37 -0
  66. package/src/core/math/spline/v3_computeCatmullRomSplineUniformDistance.js +1 -1
  67. package/src/core/model/node-graph/visual/NodeGraphVisualData.js +1 -1
  68. package/src/core/model/reactive/model/util/createRandomReactiveExpression.js +185 -185
  69. package/src/core/process/delay.js +16 -16
  70. package/src/engine/animation/async/TimeSeries.js +300 -300
  71. package/src/engine/animation/curve/AnimationCurve.d.ts +0 -4
  72. package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
  73. package/src/engine/animation/curve/AnimationCurve.js +1 -6
  74. package/src/engine/animation/curve/draw/position_canvas_to_curve.js +2 -2
  75. package/src/engine/animation/curve/draw/position_curve_to_canvas.js +2 -2
  76. package/src/engine/ecs/fow/shader/FogOfWarRenderer.js +145 -145
  77. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +2 -2
  78. package/src/engine/ecs/parent/entity_node_compute_bounding_box.js +1 -1
  79. package/src/engine/ecs/transform/Transform.d.ts +0 -10
  80. package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
  81. package/src/engine/ecs/transform/Transform.js +0 -12
  82. package/src/engine/graphics/composit/CompositLayer.js +254 -254
  83. package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.js +1 -1
  84. package/src/engine/graphics/ecs/path/tube/build/build_geometry_linear.js +2 -2
  85. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +3 -3
  86. package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +201 -201
  87. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
  88. package/src/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +2 -2
  89. package/src/engine/graphics/render/forward_plus/LightManager.js +1226 -1226
  90. package/src/engine/graphics/render/forward_plus/model/PointLight.js +1 -1
  91. package/src/engine/graphics/sh3/lpv/lpv_obtain_storage_cached_volume.js +1 -1
  92. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +2 -2
  93. package/src/engine/graphics/texture/atlas/TextureAtlasDebugger.js +1 -1
  94. package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.js +145 -145
  95. package/src/engine/graphics/texture/sampler/serialization/TextureBinaryBufferSerializer.js +2 -2
  96. package/src/engine/intelligence/behavior/ecs/BehaviorComponent.d.ts +2 -6
  97. package/src/engine/intelligence/behavior/ecs/BehaviorComponent.d.ts.map +1 -1
  98. package/src/engine/intelligence/behavior/ecs/BehaviorComponent.js +0 -10
  99. package/src/engine/intelligence/mcts/MonteCarlo.js +275 -275
  100. package/src/engine/navigation/ecs/path_following/PathFollower.js +222 -222
  101. package/src/generation/grid/GridData.js +220 -220
  102. package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +385 -385
  103. package/src/view/elements/image/SvgImageView.js +1 -1
  104. package/src/view/elements/windrose/WindRoseDiagram.js +369 -369
  105. package/src/view/minimap/gl/MinimapFogOfWar.js +3 -3
  106. package/src/view/util/DomSizeObserver.js +1 -1
  107. package/src/core/binary/clz32.d.ts +0 -6
  108. package/src/core/binary/clz32.d.ts.map +0 -1
  109. package/src/core/binary/clz32.js +0 -5
  110. package/src/core/binary/type/dataTypeFromTypedArray.d.ts +0 -8
  111. package/src/core/binary/type/dataTypeFromTypedArray.d.ts.map +0 -1
  112. package/src/core/binary/type/dataTypeFromTypedArray.js +0 -11
  113. package/src/core/collection/array/computeHashIntegerArray.d.ts +0 -1
  114. package/src/core/collection/array/computeHashIntegerArray.d.ts.map +0 -1
  115. package/src/core/collection/array/computeHashIntegerArray.js +0 -7
  116. package/src/core/collection/array/typed/typedArrayToDataType.d.ts +0 -6
  117. package/src/core/collection/array/typed/typedArrayToDataType.d.ts.map +0 -1
  118. package/src/core/collection/array/typed/typedArrayToDataType.js +0 -6
  119. package/src/core/geom/3d/mat4/MATRIX_4_IDENTITY.d.ts +0 -6
  120. package/src/core/geom/3d/mat4/MATRIX_4_IDENTITY.d.ts.map +0 -1
  121. package/src/core/geom/3d/mat4/MATRIX_4_IDENTITY.js +0 -7
  122. package/src/core/graph/eigen/eigen_values_find_spectral_gap.d.ts.map +0 -1
  123. package/src/core/graph/eigen/matrix_eigenvalues_in_place.d.ts +0 -8
  124. package/src/core/graph/eigen/matrix_eigenvalues_in_place.d.ts.map +0 -1
  125. package/src/core/graph/eigen/matrix_householder_in_place.d.ts.map +0 -1
  126. package/src/core/graph/eigen/matrix_qr_in_place.d.ts +0 -9
  127. package/src/core/graph/eigen/matrix_qr_in_place.d.ts.map +0 -1
  128. package/src/core/graph/eigen/matrix_top_eigenvector_power_iteration.d.ts.map +0 -1
  129. package/src/core/math/spline/cubicCurve.d.ts +0 -6
  130. package/src/core/math/spline/cubicCurve.d.ts.map +0 -1
  131. package/src/core/math/spline/cubicCurve.js +0 -6
  132. package/src/core/math/spline/spline_bezier2.d.ts +0 -6
  133. package/src/core/math/spline/spline_bezier2.d.ts.map +0 -1
  134. package/src/core/math/spline/spline_bezier2.js +0 -6
  135. package/src/core/math/spline/spline_bezier3.d.ts +0 -6
  136. package/src/core/math/spline/spline_bezier3.d.ts.map +0 -1
  137. package/src/core/math/spline/spline_bezier3.js +0 -6
  138. package/src/core/math/spline/spline_bezier3_bounds.d.ts +0 -6
  139. package/src/core/math/spline/spline_bezier3_bounds.d.ts.map +0 -1
  140. package/src/core/math/spline/spline_bezier3_bounds.js +0 -6
  141. package/src/core/math/spline/spline_hermite3.d.ts +0 -6
  142. package/src/core/math/spline/spline_hermite3.d.ts.map +0 -1
  143. package/src/core/math/spline/spline_hermite3.js +0 -6
  144. package/src/core/math/spline/spline_hermite3_bounds.d.ts +0 -6
  145. package/src/core/math/spline/spline_hermite3_bounds.d.ts.map +0 -1
  146. package/src/core/math/spline/spline_hermite3_bounds.js +0 -6
  147. package/src/core/math/spline/spline_hermite3_to_bezier.d.ts +0 -2
  148. package/src/core/math/spline/spline_hermite3_to_bezier.d.ts.map +0 -1
  149. package/src/core/math/spline/spline_hermite3_to_bezier.js +0 -6
  150. package/src/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.d.ts +0 -37
  151. package/src/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.d.ts.map +0 -1
  152. package/src/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.js +0 -70
  153. /package/src/core/{graph → math/linalg}/eigen/eigen_values_find_spectral_gap.d.ts +0 -0
  154. /package/src/core/{graph → math/linalg}/eigen/eigen_values_find_spectral_gap.js +0 -0
  155. /package/src/core/{graph → math/linalg}/eigen/matrix_householder_in_place.d.ts +0 -0
@@ -1,301 +1,301 @@
1
- import { assert } from "../../../core/assert.js";
2
- import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
3
- import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
4
- import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
5
- import { inverseLerp } from "../../../core/math/inverseLerp.js";
6
- import { lerp } from "../../../core/math/lerp.js";
7
- import { max2 } from "../../../core/math/max2.js";
8
- import { min2 } from "../../../core/math/min2.js";
9
- import { validate_enum_schema } from "../../../core/model/validate_enum_schema.js";
10
- import { table_find_min_index_in_ordered_column } from "./table_find_min_index_in_ordered_column.js";
11
-
12
- /**
13
- *
14
- * @type {number[]}
15
- */
16
- const scratch_row = [];
17
-
18
- /**
19
- * @template T
20
- */
21
- export class TimeSeries {
22
- /**
23
- * @type {RowFirstTableSpec}
24
- */
25
- spec
26
-
27
- /**
28
- * @type {RowFirstTable}
29
- */
30
- table
31
-
32
- time_column_index = 0;
33
-
34
- /**
35
- *
36
- * @type {Object<BinaryDataType>}
37
- */
38
- #schema = {}
39
-
40
- /**
41
- *
42
- * @type {Object<number>}
43
- */
44
- #schema_column_names_to_indices = {};
45
-
46
- /**
47
- *
48
- * @type {string[]}
49
- */
50
- #schema_column_indices_to_names = [];
51
-
52
- /**
53
- *
54
- * @param {Object<BinaryDataType>} schema
55
- * @param {string} [time_column_name]
56
- */
57
- constructor(schema, time_column_name = 'time') {
58
- assert.isString(time_column_name, 'time_column_name');
59
- assert.notNull(schema, 'schema');
60
- assert.isObject(schema, 'schema');
61
-
62
- let issues = [];
63
-
64
- if (!validate_enum_schema(schema, BinaryDataType, (issue) => issues.push(issue))) {
65
- throw new TypeError(`Invalid schema. Problems:\n ${issues.join('\n')}`);
66
- }
67
-
68
- this.#schema = schema;
69
-
70
- const schema_keys = Object.keys(schema);
71
-
72
- const time_row_index = schema_keys.indexOf(time_column_name);
73
-
74
- if (time_row_index === -1) {
75
- throw new TypeError(`supplies schema does not include time column '${time_column_name}', exising columns: ${schema_keys.join(', ')}`);
76
- }
77
-
78
- this.time_column_index = time_row_index;
79
-
80
-
81
- this.#schema_column_names_to_indices = {};
82
-
83
- for (let i = 0; i < schema_keys.length; i++) {
84
- const key = schema_keys[i];
85
-
86
- this.#schema_column_names_to_indices[key] = i;
87
- this.#schema_column_indices_to_names[i] = key;
88
- }
89
-
90
- this.spec = RowFirstTableSpec.get(Object.values(schema));
91
-
92
- this.table = new RowFirstTable(this.spec);
93
-
94
- }
95
-
96
- /**
97
- *
98
- * @param {number[]} row
99
- * @param {Object} object
100
- */
101
- #object_to_row(row, object) {
102
-
103
- const columnCount = this.spec.getColumnCount();
104
-
105
- for (let i = 0; i < columnCount; i++) {
106
-
107
- const key = this.#schema_column_indices_to_names[i];
108
-
109
- const value = object[key];
110
-
111
- const t = typeof value;
112
-
113
- if (t !== "number") {
114
- throw new TypeError(`Expected sample.${key} to be a number, instead was ${t} (=${value})`);
115
- }
116
-
117
- row[i] = value;
118
-
119
- }
120
- }
121
-
122
- /**
123
- *
124
- * @param {Object} object
125
- * @param {number[]} row
126
- */
127
- #row_to_object(object, row) {
128
-
129
- const columnCount = this.spec.getColumnCount();
130
- for (let i = 0; i < columnCount; i++) {
131
-
132
- const key = this.#schema_column_indices_to_names[i];
133
-
134
- object[key] = row[i];
135
- }
136
-
137
- }
138
-
139
- /**
140
- *
141
- * @param {number[]} row
142
- * @returns {Object}
143
- */
144
- #row_to_object_allocating(row) {
145
-
146
- const result = {};
147
-
148
- this.#row_to_object(result, row);
149
-
150
- return result;
151
- }
152
-
153
- /**
154
- *
155
- * @param {number} index
156
- * @returns {Object}
157
- */
158
- getSampleObjectByIndex(index) {
159
- this.table.readRow(index, scratch_row);
160
-
161
- return this.#row_to_object_allocating(scratch_row);
162
- }
163
-
164
- /**
165
- *
166
- * @returns {number}
167
- */
168
- get sample_count() {
169
- return this.table.length;
170
- }
171
-
172
- /**
173
- *
174
- * @returns {number}
175
- */
176
- get last_timestamp() {
177
- const table = this.table;
178
- const record_count = table.length;
179
-
180
- if (record_count === 0) {
181
- // default
182
- return 0;
183
- }
184
-
185
- const time_column = this.time_column_index;
186
- return table.readCellValue(record_count - 1, time_column);
187
- }
188
-
189
- /**
190
- *
191
- * @param {number[]} data
192
- */
193
- validateNextSample(data) {
194
-
195
- assert.isArrayLike(data, 'data');
196
-
197
- const table = this.table;
198
- const record_count = table.length;
199
-
200
- if (record_count > 0) {
201
- const time_column = this.time_column_index;
202
- const last_time = table.readCellValue(record_count - 1, time_column);
203
-
204
- const record = data[time_column];
205
-
206
- assert.isNumber(record, `data[${time_column}](time)`);
207
- assert.notNaN(record, `data[${time_column}](time)`);
208
- assert.isFiniteNumber(record, `data[${time_column}](time)`);
209
-
210
- if (record <= last_time) {
211
- throw new Error(`Sample.time[${time_column}] = ${record}, which is <= to previous time stamp(=${last_time}). Each sample's time stamp must be strictly greater than the previous one`);
212
- }
213
- }
214
-
215
- }
216
-
217
- /**
218
- *
219
- * @param {number[]} data
220
- */
221
- addSample(data) {
222
- // validate
223
- this.validateNextSample(data);
224
-
225
- const table = this.table;
226
- table.addRow(data);
227
- }
228
-
229
- /**
230
- *
231
- * @param {Object} sample
232
- */
233
- addObjectSample(sample) {
234
- this.#object_to_row(scratch_row, sample);
235
-
236
- this.addSample(scratch_row);
237
- }
238
-
239
- /**
240
- *
241
- * @param {number[]} result
242
- * @param {number} index
243
- */
244
- getSampleByIndex(result, index) {
245
- this.table.readRow(index, result)
246
- }
247
-
248
- /**
249
- *
250
- * @param {number} time
251
- * @returns {number}
252
- */
253
- findLowSampleIndexByTime(time) {
254
- const table = this.table;
255
- const time_column_index = this.time_column_index;
256
- return max2(0, table_find_min_index_in_ordered_column(table, time, time_column_index))
257
- }
258
-
259
- /**
260
- *
261
- * @param {number[]} result
262
- * @param {number} result_offset
263
- * @param {number} time
264
- */
265
- sampleLinear(result, result_offset, time) {
266
- const table = this.table;
267
- const time_column_index = this.time_column_index;
268
-
269
- // seek to the right sample
270
- const sample_index = this.findLowSampleIndexByTime(time);
271
- const next_sample_index = min2(table.length - 1, sample_index + 1);
272
-
273
- const prev = table.readCellValue(sample_index, time_column_index);
274
- const next = table.readCellValue(next_sample_index, time_column_index);
275
-
276
- const normalized_offset = inverseLerp(prev, next, time);
277
-
278
- const column_count = this.spec.getColumnCount();
279
-
280
- for (let i = 0; i < column_count; i++) {
281
- const v0 = table.readCellValue(sample_index, i);
282
- const v1 = table.readCellValue(next_sample_index, i);
283
-
284
- result[result_offset + i] = lerp(v0, v1, normalized_offset)
285
- }
286
- }
287
-
288
- /**
289
- * Get linearly interpolated sample for given time in object form, following supplied schema
290
- * @param {number} time
291
- * @returns {Object}
292
- */
293
- sampleObjectLinear(time) {
294
-
295
- this.sampleLinear(scratch_row, 0, time);
296
-
297
- return this.#row_to_object_allocating(scratch_row);
298
-
299
- }
300
-
1
+ import { assert } from "../../../core/assert.js";
2
+ import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
3
+ import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
4
+ import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
5
+ import { inverseLerp } from "../../../core/math/inverseLerp.js";
6
+ import { lerp } from "../../../core/math/lerp.js";
7
+ import { max2 } from "../../../core/math/max2.js";
8
+ import { min2 } from "../../../core/math/min2.js";
9
+ import { validate_enum_schema } from "../../../core/model/validate_enum_schema.js";
10
+ import { table_find_min_index_in_ordered_column } from "./table_find_min_index_in_ordered_column.js";
11
+
12
+ /**
13
+ *
14
+ * @type {number[]}
15
+ */
16
+ const scratch_row = [];
17
+
18
+ /**
19
+ * @template T
20
+ */
21
+ export class TimeSeries {
22
+ /**
23
+ * @type {RowFirstTableSpec}
24
+ */
25
+ spec
26
+
27
+ /**
28
+ * @type {RowFirstTable}
29
+ */
30
+ table
31
+
32
+ time_column_index = 0;
33
+
34
+ /**
35
+ *
36
+ * @type {Object<BinaryDataType>}
37
+ */
38
+ #schema = {}
39
+
40
+ /**
41
+ *
42
+ * @type {Object<number>}
43
+ */
44
+ #schema_column_names_to_indices = {};
45
+
46
+ /**
47
+ *
48
+ * @type {string[]}
49
+ */
50
+ #schema_column_indices_to_names = [];
51
+
52
+ /**
53
+ *
54
+ * @param {Object<BinaryDataType>} schema
55
+ * @param {string} [time_column_name]
56
+ */
57
+ constructor(schema, time_column_name = 'time') {
58
+ assert.isString(time_column_name, 'time_column_name');
59
+ assert.notNull(schema, 'schema');
60
+ assert.isObject(schema, 'schema');
61
+
62
+ let issues = [];
63
+
64
+ if (!validate_enum_schema(schema, BinaryDataType, (issue) => issues.push(issue))) {
65
+ throw new TypeError(`Invalid schema. Problems:\n ${issues.join('\n')}`);
66
+ }
67
+
68
+ this.#schema = schema;
69
+
70
+ const schema_keys = Object.keys(schema);
71
+
72
+ const time_row_index = schema_keys.indexOf(time_column_name);
73
+
74
+ if (time_row_index === -1) {
75
+ throw new TypeError(`supplies schema does not include time column '${time_column_name}', exising columns: ${schema_keys.join(', ')}`);
76
+ }
77
+
78
+ this.time_column_index = time_row_index;
79
+
80
+
81
+ this.#schema_column_names_to_indices = {};
82
+
83
+ for (let i = 0; i < schema_keys.length; i++) {
84
+ const key = schema_keys[i];
85
+
86
+ this.#schema_column_names_to_indices[key] = i;
87
+ this.#schema_column_indices_to_names[i] = key;
88
+ }
89
+
90
+ this.spec = RowFirstTableSpec.get(Object.values(schema));
91
+
92
+ this.table = new RowFirstTable(this.spec);
93
+
94
+ }
95
+
96
+ /**
97
+ *
98
+ * @param {number[]} row
99
+ * @param {Object} object
100
+ */
101
+ #object_to_row(row, object) {
102
+
103
+ const columnCount = this.spec.getColumnCount();
104
+
105
+ for (let i = 0; i < columnCount; i++) {
106
+
107
+ const key = this.#schema_column_indices_to_names[i];
108
+
109
+ const value = object[key];
110
+
111
+ const t = typeof value;
112
+
113
+ if (t !== "number") {
114
+ throw new TypeError(`Expected sample.${key} to be a number, instead was ${t} (=${value})`);
115
+ }
116
+
117
+ row[i] = value;
118
+
119
+ }
120
+ }
121
+
122
+ /**
123
+ *
124
+ * @param {Object} object
125
+ * @param {number[]} row
126
+ */
127
+ #row_to_object(object, row) {
128
+
129
+ const columnCount = this.spec.getColumnCount();
130
+ for (let i = 0; i < columnCount; i++) {
131
+
132
+ const key = this.#schema_column_indices_to_names[i];
133
+
134
+ object[key] = row[i];
135
+ }
136
+
137
+ }
138
+
139
+ /**
140
+ *
141
+ * @param {number[]} row
142
+ * @returns {Object}
143
+ */
144
+ #row_to_object_allocating(row) {
145
+
146
+ const result = {};
147
+
148
+ this.#row_to_object(result, row);
149
+
150
+ return result;
151
+ }
152
+
153
+ /**
154
+ *
155
+ * @param {number} index
156
+ * @returns {Object}
157
+ */
158
+ getSampleObjectByIndex(index) {
159
+ this.table.readRow(index, scratch_row);
160
+
161
+ return this.#row_to_object_allocating(scratch_row);
162
+ }
163
+
164
+ /**
165
+ *
166
+ * @returns {number}
167
+ */
168
+ get sample_count() {
169
+ return this.table.length;
170
+ }
171
+
172
+ /**
173
+ *
174
+ * @returns {number}
175
+ */
176
+ get last_timestamp() {
177
+ const table = this.table;
178
+ const record_count = table.length;
179
+
180
+ if (record_count === 0) {
181
+ // default
182
+ return 0;
183
+ }
184
+
185
+ const time_column = this.time_column_index;
186
+ return table.readCellValue(record_count - 1, time_column);
187
+ }
188
+
189
+ /**
190
+ *
191
+ * @param {number[]} data
192
+ */
193
+ validateNextSample(data) {
194
+
195
+ assert.isArrayLike(data, 'data');
196
+
197
+ const table = this.table;
198
+ const record_count = table.length;
199
+
200
+ if (record_count > 0) {
201
+ const time_column = this.time_column_index;
202
+ const last_time = table.readCellValue(record_count - 1, time_column);
203
+
204
+ const record = data[time_column];
205
+
206
+ assert.isNumber(record, `data[${time_column}](time)`);
207
+ assert.notNaN(record, `data[${time_column}](time)`);
208
+ assert.isFinite(record, `data[${time_column}](time)`);
209
+
210
+ if (record <= last_time) {
211
+ throw new Error(`Sample.time[${time_column}] = ${record}, which is <= to previous time stamp(=${last_time}). Each sample's time stamp must be strictly greater than the previous one`);
212
+ }
213
+ }
214
+
215
+ }
216
+
217
+ /**
218
+ *
219
+ * @param {number[]} data
220
+ */
221
+ addSample(data) {
222
+ // validate
223
+ this.validateNextSample(data);
224
+
225
+ const table = this.table;
226
+ table.addRow(data);
227
+ }
228
+
229
+ /**
230
+ *
231
+ * @param {Object} sample
232
+ */
233
+ addObjectSample(sample) {
234
+ this.#object_to_row(scratch_row, sample);
235
+
236
+ this.addSample(scratch_row);
237
+ }
238
+
239
+ /**
240
+ *
241
+ * @param {number[]} result
242
+ * @param {number} index
243
+ */
244
+ getSampleByIndex(result, index) {
245
+ this.table.readRow(index, result)
246
+ }
247
+
248
+ /**
249
+ *
250
+ * @param {number} time
251
+ * @returns {number}
252
+ */
253
+ findLowSampleIndexByTime(time) {
254
+ const table = this.table;
255
+ const time_column_index = this.time_column_index;
256
+ return max2(0, table_find_min_index_in_ordered_column(table, time, time_column_index))
257
+ }
258
+
259
+ /**
260
+ *
261
+ * @param {number[]} result
262
+ * @param {number} result_offset
263
+ * @param {number} time
264
+ */
265
+ sampleLinear(result, result_offset, time) {
266
+ const table = this.table;
267
+ const time_column_index = this.time_column_index;
268
+
269
+ // seek to the right sample
270
+ const sample_index = this.findLowSampleIndexByTime(time);
271
+ const next_sample_index = min2(table.length - 1, sample_index + 1);
272
+
273
+ const prev = table.readCellValue(sample_index, time_column_index);
274
+ const next = table.readCellValue(next_sample_index, time_column_index);
275
+
276
+ const normalized_offset = inverseLerp(prev, next, time);
277
+
278
+ const column_count = this.spec.getColumnCount();
279
+
280
+ for (let i = 0; i < column_count; i++) {
281
+ const v0 = table.readCellValue(sample_index, i);
282
+ const v1 = table.readCellValue(next_sample_index, i);
283
+
284
+ result[result_offset + i] = lerp(v0, v1, normalized_offset)
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Get linearly interpolated sample for given time in object form, following supplied schema
290
+ * @param {number} time
291
+ * @returns {Object}
292
+ */
293
+ sampleObjectLinear(time) {
294
+
295
+ this.sampleLinear(scratch_row, 0, time);
296
+
297
+ return this.#row_to_object_allocating(scratch_row);
298
+
299
+ }
300
+
301
301
  }
@@ -183,10 +183,6 @@ export class AnimationCurve implements Iterable<Keyframe> {
183
183
  * Alias to {@link alignAllTangents}.
184
184
  */
185
185
  smooth: () => void;
186
- /**
187
- * @deprecated use `getKeyIndexLow` instead
188
- */
189
- getKeyIndexByTime: (time: number) => number;
190
186
  [Symbol.iterator](): Generator<Keyframe, void, unknown>;
191
187
  }
192
188
  import { Keyframe } from "./Keyframe.js";
@@ -1 +1 @@
1
- {"version":3,"file":"AnimationCurve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/AnimationCurve.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,gDANwB,QAAQ;IAqZ5B;;;;OAIG;IACH,kBAHW,QAAQ,EAAE,GACR,cAAc,CAQ1B;IAED;;;;;;;;;OASG;IACH,6BANW,MAAM,eACN,MAAM,YACN,MAAM,aACN,MAAM,GACL,cAAc,CAUzB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,YACN,MAAM,UACN,MAAM,GACL,cAAc,CAOzB;IAED;;;;;;;OAOG;IACH,0BANW,MAAM,eACN,MAAM,YACN,MAAM,aACN,MAAM,GACL,cAAc,CAezB;IAldD;;;;;OAKG;IACH,eAFU,QAAQ,EAAE,CAEV;IAEV;;;;;OAKG;IACH,SAHW,QAAQ,GACN,MAAM,CAuClB;IAED;;;OAGG;IACH,cAFW,QAAQ,EAAE,QAUpB;IAED;;;;OAIG;IACH,YAHW,QAAQ,GACN,OAAO,CAYnB;IAED;;OAEG;IACH,cAEC;IAGD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,qBAEC;IAED;;;;OAIG;IACH,yBAUC;IAED;;;;OAIG;IACH,uBAUC;IAED;;;;OAIG;IACH,uBAcC;IAED;;;;;;OAMG;IACH,qBAHW,MAAM,GACJ,MAAM,CAmDlB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACL,MAAM,CAoCjB;IAED;;;;OAIG;IACH,qBAFW,MAAM,QAmChB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;IAED;;OAEG;IACH,yBAQC;IAGD;;;OAGG;IACH,YAFW,cAAc,QAIxB;IAED;;;OAGG;IACH,SAFY,cAAc,CAQzB;IAED;;;;OAIG;IACH,cAHW,cAAc,GACb,OAAO,CAIlB;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;MAIC;IAED;;aAkBC;IAoFL;;;;OAIG;IACH,2BAFU,OAAO,CAEwB;IAGzC;;;OAGG;IACH,mBAA+B;IAE/B;;OAEG;IACH,0BAhUe,MAAM,KACJ,MAAM,CA+TmB;IAnGtC,wDAQC;CAuEJ;yBA/ewB,eAAe"}
1
+ {"version":3,"file":"AnimationCurve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/AnimationCurve.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,gDANwB,QAAQ;IAqZ5B;;;;OAIG;IACH,kBAHW,QAAQ,EAAE,GACR,cAAc,CAQ1B;IAED;;;;;;;;;OASG;IACH,6BANW,MAAM,eACN,MAAM,YACN,MAAM,aACN,MAAM,GACL,cAAc,CAUzB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,YACN,MAAM,UACN,MAAM,GACL,cAAc,CAOzB;IAED;;;;;;;OAOG;IACH,0BANW,MAAM,eACN,MAAM,YACN,MAAM,aACN,MAAM,GACL,cAAc,CAezB;IAldD;;;;;OAKG;IACH,eAFU,QAAQ,EAAE,CAEV;IAEV;;;;;OAKG;IACH,SAHW,QAAQ,GACN,MAAM,CAuClB;IAED;;;OAGG;IACH,cAFW,QAAQ,EAAE,QAUpB;IAED;;;;OAIG;IACH,YAHW,QAAQ,GACN,OAAO,CAYnB;IAED;;OAEG;IACH,cAEC;IAGD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,qBAEC;IAED;;;;OAIG;IACH,yBAUC;IAED;;;;OAIG;IACH,uBAUC;IAED;;;;OAIG;IACH,uBAcC;IAED;;;;;;OAMG;IACH,qBAHW,MAAM,GACJ,MAAM,CAmDlB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACL,MAAM,CAoCjB;IAED;;;;OAIG;IACH,qBAFW,MAAM,QAmChB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;IAED;;OAEG;IACH,yBAQC;IAGD;;;OAGG;IACH,YAFW,cAAc,QAIxB;IAED;;;OAGG;IACH,SAFY,cAAc,CAQzB;IAED;;;;OAIG;IACH,cAHW,cAAc,GACb,OAAO,CAIlB;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;MAIC;IAED;;aAkBC;IAoFL;;;;OAIG;IACH,2BAFU,OAAO,CAEwB;IAGzC;;;OAGG;IACH,mBAA+B;IA9F3B,wDAQC;CAuEJ;yBA/ewB,eAAe"}
@@ -515,9 +515,4 @@ AnimationCurve.prototype.isAnimationCurve = true;
515
515
  * Smooths out the curve.
516
516
  * Alias to {@link alignAllTangents}.
517
517
  */
518
- AnimationCurve.prototype.smooth = AnimationCurve.prototype.alignAllTangents;
519
-
520
- /**
521
- * @deprecated use `getKeyIndexLow` instead
522
- */
523
- AnimationCurve.prototype.getKeyIndexByTime = AnimationCurve.prototype.getKeyIndexLow;
518
+ AnimationCurve.prototype.smooth = AnimationCurve.prototype.alignAllTangents;
@@ -18,7 +18,7 @@ export function position_canvas_to_curve(size, frame, margin, x, y) {
18
18
  const v = 1 - (y - margin.y) / (height - margin.y * 2);
19
19
 
20
20
  return new Vector2(
21
- u * frame.getWidth() + frame.x0,
22
- v * frame.getHeight() + frame.y0
21
+ u * frame.width + frame.x0,
22
+ v * frame.height + frame.y0
23
23
  );
24
24
  }
@@ -13,11 +13,11 @@ export function position_curve_to_canvas(size, frame, margin, x, y) {
13
13
  const width = size.x;
14
14
  const height = size.y;
15
15
 
16
- const curve_width = frame.getWidth();
16
+ const curve_width = frame.width;
17
17
  const curve_width_multiplier = curve_width > 0 ? 1 / curve_width : 0;
18
18
  const u = (x - frame.x0) * curve_width_multiplier;
19
19
 
20
- const curve_height = frame.getHeight();
20
+ const curve_height = frame.height;
21
21
  const curve_height_multiplier = curve_height > 0 ? 1 / curve_height : 0;
22
22
  const v = 1 - (y - frame.y0) * curve_height_multiplier;
23
23