@woosh/meep-engine 2.110.9 → 2.110.11
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/meep.cjs +23 -1
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +23 -1
- package/editor/ecs/component/editors/Sampler2DEditor.js +9 -9
- package/editor/ecs/component/editors/three/BufferGeometryEditor.js +4 -4
- package/editor/ecs/component/editors/three/MaterialEditor.js +3 -3
- package/editor/ecs/component/editors/three/MeshEditor.js +4 -4
- package/editor/ecs/component/editors/three/TextureEditor.js +1 -1
- package/editor/tools/paint/TerrainPaintTool.js +7 -7
- package/editor/tools/paint/TerrainTexturePaintTool.js +5 -5
- package/editor/view/ecs/components/GridObstacleController.js +6 -6
- package/editor/view/ecs/components/TerrainController.js +2 -2
- package/package.json +1 -1
- package/samples/terrain/editor.js +2 -2
- package/src/core/UUID.js +1 -1
- package/src/core/color/kelvin/prototype_kelvin_to_rgb.js +3 -3
- package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/AABB2.js +27 -1
- package/src/core/geom/3d/normal/octahedron/prototype.js +1 -1
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_volume.d.ts +9 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_volume.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_volume.js +18 -0
- package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.spec.js +17 -3
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.js +25 -2
- package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.d.ts +9 -0
- package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.js +21 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.d.ts +2 -1
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js +2 -1
- package/src/core/geom/3d/tetrahedra/triangle/prototype.js +1 -1
- package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.d.ts +2 -10
- package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.js +24 -31
- package/src/core/geom/mat3/m3_cm_invert.d.ts +7 -0
- package/src/core/geom/mat3/m3_cm_invert.d.ts.map +1 -0
- package/src/core/geom/mat3/m3_cm_invert.js +45 -0
- package/src/core/geom/vec2/v2_matrix3_cm_multiply.d.ts +10 -0
- package/src/core/geom/vec2/v2_matrix3_cm_multiply.d.ts.map +1 -0
- package/src/core/geom/vec2/v2_matrix3_cm_multiply.js +20 -0
- package/src/core/geom/vec2/v2_matrix3_rm_multiply.d.ts +10 -0
- package/src/core/geom/vec2/v2_matrix3_rm_multiply.d.ts.map +1 -0
- package/src/core/geom/vec2/v2_matrix3_rm_multiply.js +21 -0
- package/src/core/math/spline/spline_hermite3.js +2 -1
- package/src/core/math/spline/spline_hermite3_to_bezier.d.ts +12 -0
- package/src/core/math/spline/spline_hermite3_to_bezier.d.ts.map +1 -0
- package/src/core/math/spline/spline_hermite3_to_bezier.js +24 -0
- package/src/core/process/task/Task.d.ts.map +1 -1
- package/src/core/process/task/Task.js +2 -0
- package/src/core/process/task/util/actionTask.d.ts +2 -2
- package/src/core/process/task/util/actionTask.d.ts.map +1 -1
- package/src/core/process/task/util/actionTask.js +5 -2
- package/src/core/process/task/util/ignoreFailureTask.d.ts +8 -0
- package/src/core/process/task/util/ignoreFailureTask.d.ts.map +1 -0
- package/src/core/process/task/util/{wrapTaskIgnoreFailure.js → ignoreFailureTask.js} +9 -4
- package/src/core/process/task/util/task_tree_compute_leaf_tasks.d.ts +1 -1
- package/src/core/process/task/util/task_tree_compute_leaf_tasks.js +1 -1
- package/src/engine/animation/clip/AnimationTrack.js +1 -1
- package/src/engine/animation/curve/AnimationCurve.d.ts +11 -0
- package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
- package/src/engine/animation/curve/AnimationCurve.js +51 -4
- package/src/engine/animation/curve/draw/build_curve_editor.d.ts.map +1 -1
- package/src/engine/animation/curve/draw/build_curve_editor.js +15 -9
- package/src/engine/animation/curve/view/AnimationCurveView.d.ts +47 -0
- package/src/engine/animation/curve/view/AnimationCurveView.d.ts.map +1 -0
- package/src/engine/animation/curve/view/AnimationCurveView.js +343 -0
- package/src/engine/animation/curve/view/prototype.d.ts +2 -0
- package/src/engine/animation/curve/view/prototype.d.ts.map +1 -0
- package/src/engine/animation/curve/view/prototype.js +86 -0
- package/src/engine/asset/loaders/image/png/prototypePNG.js +1 -1
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +1 -1
- package/src/engine/ecs/guid/UUID.d.ts +10 -3
- package/src/engine/ecs/guid/UUID.d.ts.map +1 -1
- package/src/engine/ecs/guid/UUID.js +17 -5
- package/src/engine/ecs/guid/UUID.spec.js +7 -0
- package/src/engine/ecs/guid/UUIDSerializationAdapter.spec.d.ts +2 -0
- package/src/engine/ecs/guid/UUIDSerializationAdapter.spec.d.ts.map +1 -0
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +1 -1
- package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.js +3 -3
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.js +1 -1
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js +2 -2
- package/src/engine/graphics/texture/sampler/sampler2d_to_data_url.d.ts +8 -0
- package/src/engine/graphics/texture/sampler/sampler2d_to_data_url.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/sampler2d_to_data_url.js +22 -0
- package/src/engine/graphics/texture/sampler/sampler2d_to_data_url.spec.d.ts +2 -0
- package/src/engine/graphics/texture/sampler/sampler2d_to_data_url.spec.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{convertSampler2D2DataURL.spec.js → sampler2d_to_data_url.spec.js} +2 -2
- package/src/engine/graphics/texture/sampler/{Sampler2D2Canvas.d.ts → sampler2d_to_html_canvas.d.ts} +3 -3
- package/src/engine/graphics/texture/sampler/sampler2d_to_html_canvas.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{Sampler2D2Canvas.js → sampler2d_to_html_canvas.js} +7 -7
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -3
- package/src/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +1 -1
- package/src/engine/scene/transitionToScene.js +3 -3
- package/src/generation/filtering/numeric/util/visualise_filters_as_grid.js +3 -3
- package/src/misc/makeMatcapSelectionOption.js +2 -2
- package/src/view/elements/DropDownSelectionView.js +1 -1
- package/src/view/elements/tiles2d/Tile.d.ts +1 -1
- package/src/view/elements/tiles2d/Tile.d.ts.map +1 -1
- package/src/view/elements/tiles2d/Tile.js +2 -1
- package/src/core/process/task/util/wrapTaskIgnoreFailure.d.ts +0 -8
- package/src/core/process/task/util/wrapTaskIgnoreFailure.d.ts.map +0 -1
- package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.d.ts +0 -2
- package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.d.ts +0 -7
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.js +0 -23
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.d.ts +0 -2
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.d.ts.map +0 -1
- /package/src/engine/ecs/guid/{GUIDSerializationAdapter.spec.js → UUIDSerializationAdapter.spec.js} +0 -0
|
@@ -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 @@
|
|
|
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)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
|
|
2
|
-
import sampler2D2Canvas from "../../../../graphics/texture/sampler/
|
|
2
|
+
import sampler2D2Canvas from "../../../../graphics/texture/sampler/sampler2d_to_html_canvas.js";
|
|
3
3
|
import { AssetRequestScope } from "../../../AssetRequestScope.js";
|
|
4
4
|
import { ArrayBufferLoader } from "../../ArrayBufferLoader.js";
|
|
5
5
|
import { PNGReader } from "./PNGReader.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @
|
|
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
|
-
*
|
|
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":"
|
|
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
|
-
*
|
|
26
|
-
* @
|
|
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
|
|
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
|
-
*
|
|
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("
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"UUIDSerializationAdapter.spec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUIDSerializationAdapter.spec.js"],"names":[],"mappings":""}
|
package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js
CHANGED
|
@@ -70,7 +70,7 @@ import { load_and_set_cubemap_v0 } from "../../../../../load_and_set_cubemap_v0.
|
|
|
70
70
|
import {
|
|
71
71
|
AmbientOcclusionPostProcessEffect
|
|
72
72
|
} from "../../../../../render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
73
|
-
import
|
|
73
|
+
import sampler2d_to_html_canvas from "../../../../../texture/sampler/sampler2d_to_html_canvas.js";
|
|
74
74
|
import { threeUpdateTransform } from "../../../../../util/threeUpdateTransform.js";
|
|
75
75
|
import { ParticleEmitterSystem } from "../../../../ecs/ParticleEmitterSystem.js";
|
|
76
76
|
import { ParameterLookupTable } from "../../parameter/ParameterLookupTable.js";
|
|
@@ -1103,7 +1103,7 @@ function make_symbol_view({
|
|
|
1103
1103
|
|
|
1104
1104
|
const sampler_lut = lut_to_sampler(lut, view_lut.size.x, view_lut.size.y);
|
|
1105
1105
|
|
|
1106
|
-
|
|
1106
|
+
sampler2d_to_html_canvas(sampler_lut, 1, 0, view_lut.el);
|
|
1107
1107
|
|
|
1108
1108
|
symbol_view.addChild(view_lut)
|
|
1109
1109
|
|
|
@@ -31,7 +31,7 @@ import { makeGeometryIndexed } from "../../geometry/buffered/makeGeometryIndexed
|
|
|
31
31
|
import { DirectionalLight } from "../../render/forward_plus/model/DirectionalLight.js";
|
|
32
32
|
import { sampler2d_scale } from "../../texture/sampler/resize/sampler2d_scale.js";
|
|
33
33
|
import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
|
|
34
|
-
import sampler2D2Canvas from "../../texture/sampler/
|
|
34
|
+
import sampler2D2Canvas from "../../texture/sampler/sampler2d_to_html_canvas.js";
|
|
35
35
|
import { PathTracedScene } from "./PathTracedScene.js";
|
|
36
36
|
import { PathTracer } from "./PathTracer.js";
|
|
37
37
|
import { make_sun, prepare_scene_gltf } from "./prepare_scene_gltf.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
2
|
-
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
3
|
-
import sampler2D2Canvas from "../../../texture/sampler/Sampler2D2Canvas.js";
|
|
4
1
|
import { vec3 } from "gl-matrix";
|
|
2
|
+
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
3
|
+
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
4
|
+
import sampler2D2Canvas from "../../../texture/sampler/sampler2d_to_html_canvas.js";
|
|
5
5
|
import { make_sky_hosek } from "../../path_tracer/make_sky_hosek.js";
|
|
6
6
|
|
|
7
7
|
const view = new CanvasView();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
2
2
|
import EmptyView from "../../../../../view/elements/EmptyView.js";
|
|
3
|
-
import sampler2D2Canvas from "../
|
|
3
|
+
import sampler2D2Canvas from "../sampler2d_to_html_canvas.js";
|
|
4
4
|
|
|
5
5
|
export function debug_draw_sampler(engine, sampler, x = 0, y = 0) {
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { downloadUrlAsFile } from "../../../../core/binary/downloadUrlAsFile.js";
|
|
2
|
-
import {
|
|
2
|
+
import { sampler2d_to_data_url } from "./sampler2d_to_data_url.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@ import { convertSampler2D2DataURL } from "./convertSampler2D2DataURL.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export function downloadSampler2DAsPNG(sampler, file_name = 'image') {
|
|
10
10
|
|
|
11
|
-
const dataURL =
|
|
11
|
+
const dataURL = sampler2d_to_data_url(sampler);
|
|
12
12
|
|
|
13
13
|
downloadUrlAsFile(dataURL, `${file_name}.png`);
|
|
14
14
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an input image to a data url string
|
|
3
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs
|
|
4
|
+
* @param {Sampler2D} sampler
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function sampler2d_to_data_url(sampler: Sampler2D): string;
|
|
8
|
+
//# sourceMappingURL=sampler2d_to_data_url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampler2d_to_data_url.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/sampler2d_to_data_url.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,2DAFa,MAAM,CAYlB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sampler2d_compute_texel_value_conversion_scale_to_uint8
|
|
3
|
+
} from "./sampler2d_compute_texel_value_conversion_scale_to_uint8.js";
|
|
4
|
+
import sampler2d_to_html_canvas from "./sampler2d_to_html_canvas.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts an input image to a data url string
|
|
8
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs
|
|
9
|
+
* @param {Sampler2D} sampler
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
export function sampler2d_to_data_url(sampler) {
|
|
13
|
+
|
|
14
|
+
const canvas = document.createElement('canvas');
|
|
15
|
+
|
|
16
|
+
const { scale, offset } = sampler2d_compute_texel_value_conversion_scale_to_uint8(sampler);
|
|
17
|
+
|
|
18
|
+
sampler2d_to_html_canvas(sampler, scale, offset, canvas);
|
|
19
|
+
|
|
20
|
+
return canvas.toDataURL('image/png');
|
|
21
|
+
|
|
22
|
+
}
|