@woosh/meep-engine 2.43.1 → 2.43.4
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/core/binary/BinaryBuffer.js +13 -1
- package/core/binary/BitSet.js +2 -2
- package/core/bvh2/aabb3/aabb3_array_combine.js +2 -2
- package/core/collection/RingBuffer.js +4 -2
- package/core/collection/RingBuffer.spec.js +59 -0
- package/core/collection/array/ArrayIteratorRandom.js +1 -1
- package/core/collection/{ArrayUtils.spec.js → array/arrayPickBestElement.spec.js} +1 -1
- package/core/collection/array/arrayPickBestElements.js +51 -0
- package/core/collection/array/arrayPickMinElement.js +43 -0
- package/core/collection/array/arrayQuickSort.js +1 -1
- package/core/collection/array/arraySetSortingDiff.js +1 -1
- package/core/collection/array/arraySwapElements.js +12 -0
- package/core/collection/array/array_range_equal_strict.js +22 -0
- package/core/collection/array/groupArrayBy.js +42 -0
- package/core/collection/array/isArrayEqual.js +50 -0
- package/core/collection/array/randomMultipleFromArray.js +34 -0
- package/core/collection/array/randomizeArrayElementOrder.js +23 -0
- package/core/color/sRGB_to_linear.js +9 -4
- package/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +1 -1
- package/core/geom/3d/aabb/aabb3_build_frustum.js +1 -1
- package/core/geom/3d/aabb/compute_aabb_from_points.js +1 -1
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +3 -1
- package/core/geom/3d/morton/v3_morton_encode_transformed.spec.js +20 -0
- package/core/geom/3d/plane/orient3d_fast.js +11 -10
- package/core/geom/3d/plane/orient3d_robust.js +41 -0
- package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +0 -23
- package/core/geom/3d/plane/plane_three_compute_convex3_plane_intersection.js +24 -0
- package/core/geom/3d/shape/UnionShape3D.js +1 -1
- package/core/geom/3d/sphere/harmonics/README.md +15 -0
- package/core/geom/3d/sphere/harmonics/sh3_add.js +21 -0
- package/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +618 -0
- package/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.js +49 -0
- package/core/geom/3d/sphere/harmonics/sh3_sample_irradiance_by_direction.js +53 -0
- package/core/geom/3d/tetrahedra/README.md +10 -1
- package/core/geom/3d/tetrahedra/TetrahedralMesh.js +650 -0
- package/core/geom/3d/tetrahedra/TetrahedralMesh.spec.js +233 -0
- package/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js +75 -0
- package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +2 -2
- package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +4 -4
- package/core/geom/3d/tetrahedra/delaunay/Cavity.js +49 -7
- package/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +51 -17
- package/core/geom/3d/tetrahedra/delaunay/debug_validate_mesh.js +19 -0
- package/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +191 -0
- package/core/geom/3d/tetrahedra/delaunay/push_boundary_with_validation.js +27 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +59 -43
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_sub_determinant.js +77 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_sub_determinant.spec.js +30 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.js +58 -0
- package/core/geom/3d/tetrahedra/delaunay/validate_cavity_boundary.js +60 -0
- package/core/geom/3d/tetrahedra/{point_in_tetrahedron_circumsphere.js → in_sphere_fast.js} +11 -13
- package/core/geom/3d/tetrahedra/in_sphere_robust.js +53 -0
- package/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +44 -35
- package/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js +83 -0
- package/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.spec.js +24 -0
- package/core/geom/3d/tetrahedra/tetrahedron_contains_point.spec.js +66 -0
- package/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.js +166 -0
- package/core/geom/3d/util/make_justified_point_grid.js +31 -0
- package/core/geom/Bezier.js +0 -27
- package/core/geom/Plane.js +0 -4
- package/core/geom/packing/miniball/Subspan.js +2 -2
- package/core/geom/v3_lerp.js +6 -1
- package/core/math/isqrt.js +28 -0
- package/core/math/isqrt.spec.js +9 -0
- package/core/math/max.spec.js +25 -0
- package/core/math/min2.spec.js +25 -0
- package/core/model/node-graph/node/NodeInstance.js +3 -3
- package/core/primitives/strings/prefixTree/PrefixTreeLeaf.js +1 -1
- package/core/process/delay.js +5 -0
- package/core/process/task/util/randomCountTask.js +1 -1
- package/editor/Editor.js +3 -0
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +195 -11
- package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.js +16 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +4 -0
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +1 -1
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +6 -0
- package/editor/view/ecs/components/common/AutoCanvasView.js +13 -25
- package/engine/EngineHarness.js +11 -5
- package/engine/asset/AssetManager.d.ts +5 -1
- package/engine/asset/AssetManager.js +50 -15
- package/engine/asset/AssetManager.spec.js +17 -11
- package/engine/asset/AssetRequest.js +57 -0
- package/engine/asset/loaders/ArrayBufferLoader.js +22 -0
- package/engine/asset/loaders/AssetLoader.js +1 -1
- package/engine/ecs/System.js +1 -1
- package/engine/ecs/dynamic_actions/DynamicActorSystem.js +1 -1
- package/engine/ecs/terrain/ecs/TerrainSystem.js +7 -1
- package/engine/ecs/transform/copy_three_transform.js +15 -0
- package/engine/graphics/FrameRunner.js +5 -9
- package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +1 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +1 -1
- package/engine/graphics/ecs/camera/Camera.js +1 -10
- package/engine/graphics/ecs/camera/CameraSystem.js +8 -8
- package/engine/graphics/ecs/camera/ProjectionType.js +9 -0
- package/engine/graphics/ecs/camera/build_three_camera_object.js +3 -3
- package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +59 -4
- package/engine/graphics/ecs/light/Light.js +6 -1
- package/engine/graphics/ecs/light/LightSystem.d.ts +1 -1
- package/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +2 -17
- package/engine/graphics/geometry/VertexDataSpec.js +1 -1
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +2 -2
- package/engine/graphics/impostors/octahedral/prototypeBaker.js +3 -3
- package/engine/graphics/micron/plugin/GLTFAssetTransformer.js +1 -1
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +3 -1
- package/engine/graphics/particles/node-based/codegen/modules/FunctionSignature.js +1 -1
- package/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/engine/graphics/render/forward_plus/LightManager.spec.js +4 -0
- package/engine/graphics/render/forward_plus/computeFrustumCorners.js +4 -2
- package/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/engine/graphics/render/layers/RenderLayerUtils.js +2 -2
- package/engine/graphics/sh3/LightProbeVolume.js +595 -0
- package/engine/graphics/sh3/SH3VisualisationMaterial.js +79 -0
- package/engine/graphics/sh3/prototypeSH3Probe.js +427 -0
- package/engine/graphics/sh3/visualise_probe.js +40 -0
- package/engine/graphics/shaders/DenoiseShader.js +1 -1
- package/engine/graphics/texture/atlas/AtlasPatch.js +11 -3
- package/engine/graphics/texture/atlas/CachingTextureAtlas.js +2 -2
- package/engine/graphics/texture/atlas/TextureAtlas.js +22 -4
- package/engine/graphics/texture/atlas/TextureAtlas.spec.js +22 -0
- package/engine/graphics/texture/sampler/Sampler2D.js +0 -64
- package/engine/graphics/texture/sampler/Sampler2D.spec.js +2 -1
- package/engine/graphics/texture/sampler/sampler2d_combine.js +67 -0
- package/engine/intelligence/behavior/ecs/BehaviorSystem.spec.js +0 -3
- package/engine/intelligence/blackboard/AbstractBlackboard.d.ts +1 -1
- package/engine/network/PriorityFetch.js +192 -0
- package/engine/simulation/DormandPrince.js +1 -1
- package/engine/ui/DraggableAspect.js +0 -1
- package/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
- package/package.json +2 -1
- package/samples/terrain/from_image_2.js +127 -82
- package/view/elements/CanvasView.js +7 -1
- package/view/elements/image/HTMLElementCacheKey.js +1 -1
- package/view/util/DomSizeObserver.js +3 -5
- package/core/collection/ArrayUtils.js +0 -263
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_toward_cavity.js +0 -48
- package/core/geom/3d/tetrahedra/hxt/a.js +0 -524
- package/core/geom/3d/tetrahedra/hxt/hxt.js +0 -140
- package/core/geom/3d/tetrahedra/hxt/hxt.wasm +0 -0
- package/core/geom/3d/tetrahedra/tetrahedra_collection.js +0 -383
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { seededRandom } from "../../../math/random/seededRandom.js";
|
|
2
2
|
import { TaskSignal } from "../TaskSignal.js";
|
|
3
3
|
import Task from "../Task.js";
|
|
4
|
-
import { randomizeArrayElementOrder } from "../../../collection/
|
|
4
|
+
import { randomizeArrayElementOrder } from "../../../collection/array/randomizeArrayElementOrder.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
package/editor/Editor.js
CHANGED
|
@@ -71,6 +71,8 @@ import { ObservedIntegerEditor } from "./ecs/component/editors/ObservedIntegerEd
|
|
|
71
71
|
|
|
72
72
|
import '../../../../css/editor/EntityEditorView.scss';
|
|
73
73
|
import '../../../../css/editor/EditorView.scss';
|
|
74
|
+
import {ParameterTrackSet} from "../engine/graphics/particles/particular/engine/parameter/ParameterTrackSet.js";
|
|
75
|
+
import {ParameterTrackSetEditor} from "./ecs/component/editors/ecs/ParameterTrackSetEditor.js";
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* @template T
|
|
@@ -369,6 +371,7 @@ function initialize_basic_registry(registry) {
|
|
|
369
371
|
registry.set(Quaternion, new QuaternionEditor());
|
|
370
372
|
|
|
371
373
|
registry.set(Sampler2D, new Sampler2DEditor());
|
|
374
|
+
registry.set(ParameterTrackSet, new ParameterTrackSetEditor());
|
|
372
375
|
|
|
373
376
|
registry.set(HTMLElement, new HTMLElementEditor());
|
|
374
377
|
registry.set(HTMLCanvasElement, new HTMLElementEditor());
|
|
@@ -2,6 +2,11 @@ import { TypeEditor } from "../../TypeEditor.js";
|
|
|
2
2
|
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
3
3
|
import { plot_data } from "../../../../../engine/animation/curve/draw/plot_data.js";
|
|
4
4
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
5
|
+
import {ColorEditor} from "../ColorEditor.js";
|
|
6
|
+
import {ColorPickerView} from "../../../../../view/elements/ColorPickerView.js";
|
|
7
|
+
import {AutoCanvasView} from "../../../../view/ecs/components/common/AutoCanvasView.js";
|
|
8
|
+
import EmptyView from "../../../../../view/elements/EmptyView.js";
|
|
9
|
+
import {MouseEvents} from "../../../../../engine/input/devices/events/MouseEvents.js";
|
|
5
10
|
|
|
6
11
|
export class ParameterLookupTableEditor extends TypeEditor {
|
|
7
12
|
get schema() {
|
|
@@ -16,29 +21,208 @@ export class ParameterLookupTableEditor extends TypeEditor {
|
|
|
16
21
|
|
|
17
22
|
build(parent, field,registry) {
|
|
18
23
|
|
|
19
|
-
const canvasView = new CanvasView();
|
|
20
|
-
canvasView.size.set(200, 100);
|
|
21
|
-
const ctx = canvasView.context2d;
|
|
22
|
-
|
|
23
|
-
const data = [];
|
|
24
|
-
|
|
25
24
|
/**
|
|
26
25
|
* @type {ParameterLookupTable}
|
|
27
26
|
*/
|
|
28
27
|
const lut = field.adapter.read(parent, field.name);
|
|
28
|
+
const trackName = field.adapter.read(parent, "name");
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
// if it is a track scale
|
|
31
|
+
if (trackName === "scale"){
|
|
32
|
+
const canvasView = new CanvasView();
|
|
33
|
+
canvasView.size.set(200, 100);
|
|
34
|
+
const ctx = canvasView.context2d;
|
|
35
|
+
|
|
36
|
+
const data = [];
|
|
37
|
+
|
|
38
|
+
const sample = [];
|
|
39
|
+
for (let i = 0; i < canvasView.size.x; i++) {
|
|
40
|
+
const f = i / (canvasView.size.x - 1);
|
|
41
|
+
|
|
42
|
+
lut.sample(f, sample);
|
|
43
|
+
|
|
44
|
+
data[i] = sample[0];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
plot_data({ ctx, data, width: canvasView.size.x, height: canvasView.size.y, margin: new Vector2(4, 4) });
|
|
48
|
+
|
|
49
|
+
return canvasView;
|
|
50
|
+
} else if (trackName === "color"){
|
|
51
|
+
// if it is color track
|
|
52
|
+
const resultView = new EmptyView();
|
|
53
|
+
const canvasView = new CanvasView();
|
|
54
|
+
canvasView.css({borderColor: 'white', borderStyle: 'solid', borderWidth: '1px',});
|
|
55
|
+
canvasView.size.set(200, 70);
|
|
56
|
+
|
|
57
|
+
const ctx = canvasView.context2d;
|
|
58
|
+
|
|
59
|
+
const colorView = new EmptyView({tag: "input", attr: {type: "color"}, css: {padding: "0px", border: "0px"}});
|
|
60
|
+
|
|
61
|
+
resultView.addChild(canvasView);
|
|
62
|
+
resultView.addChild(colorView);
|
|
63
|
+
|
|
64
|
+
//canvas internal configuration, such as background
|
|
65
|
+
let config = {
|
|
66
|
+
tileSize: new Vector2(10, 10),
|
|
67
|
+
tileColor1: "rgb(255, 255, 255)",
|
|
68
|
+
tileColor2: "rgb(119,119,119)",
|
|
69
|
+
gradientBoxYRange: new Vector2(30, canvasView.size.y),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
this.DrawBackground(canvasView, ctx, config);
|
|
73
|
+
this.DrawGradient(canvasView, lut, ctx, config);
|
|
74
|
+
let stops = this.DrawStops(canvasView, lut, ctx, colorView, config, 0);
|
|
75
|
+
|
|
76
|
+
canvasView.el.addEventListener(MouseEvents.Click, (e) => {
|
|
77
|
+
const rect = canvasView.el.getBoundingClientRect();
|
|
78
|
+
let x = e.clientX - rect.left,
|
|
79
|
+
y = e.clientY - rect.top;
|
|
80
|
+
for (let i = 0; i < stops.length; i++) {
|
|
81
|
+
if (stops[i].x <= x && stops[i].x + stops[i].width >= x &&
|
|
82
|
+
stops[i].y <= y && stops[i].y + stops[i].height >= y){
|
|
83
|
+
let s = [];
|
|
84
|
+
lut.sample(lut.positions[i], s);
|
|
85
|
+
|
|
86
|
+
this.convertRGB(s);
|
|
87
|
+
|
|
88
|
+
colorView.el.value = this.RGBToHex(s[0], s[1], s[2]);
|
|
89
|
+
canvasView.clear();
|
|
90
|
+
|
|
91
|
+
this.DrawBackground(canvasView, ctx, config);
|
|
92
|
+
this.DrawGradient(canvasView, lut, ctx, config);
|
|
93
|
+
stops = this.DrawStops(canvasView, lut, ctx, colorView, config, i);
|
|
94
|
+
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return resultView;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* converts rgb to hex string
|
|
105
|
+
* @param {Float} r
|
|
106
|
+
* @param {Float} g
|
|
107
|
+
* @param {Float} b
|
|
108
|
+
*/
|
|
109
|
+
RGBToHex(r,g,b) {
|
|
110
|
+
r = r.toString(16);
|
|
111
|
+
g = g.toString(16);
|
|
112
|
+
b = b.toString(16);
|
|
113
|
+
|
|
114
|
+
if (r.length == 1)
|
|
115
|
+
r = "0" + r;
|
|
116
|
+
if (g.length == 1)
|
|
117
|
+
g = "0" + g;
|
|
118
|
+
if (b.length == 1)
|
|
119
|
+
b = "0" + b;
|
|
120
|
+
|
|
121
|
+
return "#" + r + g + b;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* converts lut color sample to RGB
|
|
126
|
+
* @param {[]} sample
|
|
127
|
+
*/
|
|
128
|
+
convertRGB(sample){
|
|
129
|
+
sample[0] = Math.floor(sample[0] * 255);
|
|
130
|
+
sample[1] = Math.floor(sample[1] * 255);
|
|
131
|
+
sample[2] = Math.floor(sample[2] * 255);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* draws tiled background
|
|
135
|
+
* @param {CanvasView} canvasView
|
|
136
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
137
|
+
* @param {{}} config
|
|
138
|
+
*/
|
|
139
|
+
DrawBackground(canvasView, ctx, config){
|
|
140
|
+
for (let i = 0; i < canvasView.size.x; i += config.tileSize.x) {
|
|
141
|
+
for (let j = config.gradientBoxYRange.x; j < config.gradientBoxYRange.y; j += config.tileSize.y){
|
|
142
|
+
ctx.fillStyle = (((i / config.tileSize.x) + (j / config.tileSize.y)) % 2 === 0 ? config.tileColor1 : config.tileColor2);
|
|
143
|
+
ctx.fillRect(i, j, config.tileSize.x, config.tileSize.y);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
31
147
|
|
|
148
|
+
/**
|
|
149
|
+
* draws gradient
|
|
150
|
+
* @param {CanvasView} canvasView
|
|
151
|
+
* @param {ParameterLookupTable} lut
|
|
152
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
153
|
+
* @param {{}} config
|
|
154
|
+
*/
|
|
155
|
+
DrawGradient(canvasView, lut, ctx, config){
|
|
156
|
+
const sample = [];
|
|
32
157
|
for (let i = 0; i < canvasView.size.x; i++) {
|
|
33
158
|
const f = i / (canvasView.size.x - 1);
|
|
34
|
-
|
|
35
159
|
lut.sample(f, sample);
|
|
36
160
|
|
|
37
|
-
|
|
161
|
+
this.convertRGB(sample);
|
|
162
|
+
|
|
163
|
+
ctx.fillStyle = `rgba(${sample[0]},${sample[1]},${sample[2]}, ${sample[3]})`;
|
|
164
|
+
ctx.fillRect(i, config.gradientBoxYRange.x, 1, config.gradientBoxYRange.y - config.gradientBoxYRange.x);
|
|
38
165
|
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* draws gradient stops
|
|
170
|
+
* @param {CanvasView} canvasView
|
|
171
|
+
* @param {ParameterLookupTable} lut
|
|
172
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
173
|
+
* @param {EmptyView} colorView
|
|
174
|
+
* @param {{}} config
|
|
175
|
+
* @param {Integer} selectedInd
|
|
176
|
+
* @returns {*[]}
|
|
177
|
+
*/
|
|
178
|
+
DrawStops(canvasView, lut, ctx, colorView, config, selectedInd){
|
|
179
|
+
const sample = [];
|
|
39
180
|
|
|
40
|
-
|
|
181
|
+
let stops = [];
|
|
182
|
+
for (let i = 0; i < lut.positions.length; i++){
|
|
183
|
+
const posX = lut.positions[i] * canvasView.size.x;
|
|
184
|
+
if (i === selectedInd){
|
|
185
|
+
lut.sample(lut.positions[i], sample);
|
|
41
186
|
|
|
42
|
-
|
|
187
|
+
this.convertRGB(sample);
|
|
188
|
+
|
|
189
|
+
colorView.el.value = this.RGBToHex(sample[0], sample[1], sample[2]);
|
|
190
|
+
}
|
|
191
|
+
stops.push(this.DrawStop(ctx, config, posX, i=== selectedInd));
|
|
192
|
+
}
|
|
193
|
+
return stops;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* draws gradient stop
|
|
197
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
198
|
+
* @param {Object} config
|
|
199
|
+
* @param {Integer} posX
|
|
200
|
+
* @param {Boolean} isSelected
|
|
201
|
+
*/
|
|
202
|
+
DrawStop(ctx, config, posX, isSelected){
|
|
203
|
+
ctx.beginPath();
|
|
204
|
+
ctx.moveTo(posX, config.gradientBoxYRange.x + 7);
|
|
205
|
+
ctx.lineTo(posX - 5, config.gradientBoxYRange.x);
|
|
206
|
+
ctx.lineTo(posX - 5, config.gradientBoxYRange.x - 12);
|
|
207
|
+
ctx.lineTo(posX + 5, config.gradientBoxYRange.x - 12);
|
|
208
|
+
ctx.lineTo(posX + 5, config.gradientBoxYRange.x);
|
|
209
|
+
ctx.closePath();
|
|
210
|
+
|
|
211
|
+
ctx.lineWidth = (isSelected ? 4 : 2);
|
|
212
|
+
if (!isSelected)
|
|
213
|
+
ctx.strokeStyle = "rgb(114,114,114)";
|
|
214
|
+
else
|
|
215
|
+
ctx.strokeStyle = "rgb(0,23,255)";
|
|
216
|
+
ctx.stroke();
|
|
217
|
+
ctx.fillStyle = "rgb(255, 255, 255)";
|
|
218
|
+
ctx.fill();
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
x: posX - 5,
|
|
222
|
+
y: config.gradientBoxYRange.x - 12,
|
|
223
|
+
width: 10,
|
|
224
|
+
height: 12,
|
|
225
|
+
posX: posX,
|
|
226
|
+
};
|
|
43
227
|
}
|
|
44
228
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import List from "../../../../../core/collection/list/List.js";
|
|
2
|
+
import { ObjectEditor } from "../primitive/ObjectEditor.js";
|
|
3
|
+
import {ParameterTrack} from "../../../../../engine/graphics/particles/particular/engine/parameter/ParameterTrack.js";
|
|
4
|
+
|
|
5
|
+
export class ParameterTrackSetEditor extends ObjectEditor {
|
|
6
|
+
get schema() {
|
|
7
|
+
return {
|
|
8
|
+
properties: {
|
|
9
|
+
tracks: {
|
|
10
|
+
type: List,
|
|
11
|
+
type_parameters: [ParameterTrack],
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
EmissionFromType
|
|
13
13
|
} from "../../../../../engine/graphics/particles/particular/engine/emitter/EmissionFromType.js";
|
|
14
14
|
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
15
|
+
import {ParameterTrackSetEditor} from "./ParameterTrackSetEditor.js";
|
|
15
16
|
|
|
16
17
|
export class ParticleEmitterLayerEditor extends ObjectEditor {
|
|
17
18
|
get schema() {
|
|
@@ -35,6 +36,9 @@ export class ParticleEmitterLayerEditor extends ObjectEditor {
|
|
|
35
36
|
type: Number,
|
|
36
37
|
numeric_type: DataType.Uint32
|
|
37
38
|
},
|
|
39
|
+
parameterTracks: {
|
|
40
|
+
editor: new ParameterTrackSetEditor()
|
|
41
|
+
},
|
|
38
42
|
scaledSpriteHalfSize: {
|
|
39
43
|
transient: true
|
|
40
44
|
},
|
|
@@ -315,6 +315,12 @@ export class BlenderCameraOrientationGizmo extends CanvasView {
|
|
|
315
315
|
this.__try_update();
|
|
316
316
|
|
|
317
317
|
if (this.selectedAxis !== null) {
|
|
318
|
+
|
|
319
|
+
if (this.on.axisSelected.hasHandlers()) {
|
|
320
|
+
// axis selection will be handled, stop propagation
|
|
321
|
+
evt.stopPropagation();
|
|
322
|
+
}
|
|
323
|
+
|
|
318
324
|
this.on.axisSelected.send2(
|
|
319
325
|
this.selectedAxis.axis,
|
|
320
326
|
this.selectedAxis.direction.clone()
|
|
@@ -1,54 +1,42 @@
|
|
|
1
|
-
import View from "../../../../../view/View.js";
|
|
2
1
|
import { DomSizeObserver } from "../../../../../view/util/DomSizeObserver.js";
|
|
2
|
+
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
* Automatically tracks size on the screen, including that computed from CSS and - re-renders content when size changes
|
|
5
6
|
* @extends View
|
|
6
7
|
*/
|
|
7
|
-
export class AutoCanvasView extends
|
|
8
|
+
export class AutoCanvasView extends CanvasView {
|
|
8
9
|
constructor({ classList = [] } = {}) {
|
|
9
10
|
super();
|
|
10
11
|
|
|
11
|
-
this.
|
|
12
|
-
classList.forEach(c => this.addClass(c));
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @type {CanvasRenderingContext2D}
|
|
17
|
-
*/
|
|
18
|
-
this.context2d = this.el.getContext('2d');
|
|
12
|
+
this.addClasses(classList);
|
|
19
13
|
|
|
20
14
|
const sizeObserver = new DomSizeObserver();
|
|
15
|
+
this.__sizeObserver = sizeObserver;
|
|
21
16
|
|
|
22
17
|
const size = sizeObserver.dimensions.size;
|
|
23
|
-
size.onChanged.add(() => {
|
|
24
|
-
this.render();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
sizeObserver.attach(this.el);
|
|
28
18
|
|
|
29
|
-
|
|
19
|
+
// subscribe to visual dimension changes
|
|
20
|
+
size.onChanged.add(this.render, this);
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.render();
|
|
34
|
-
});
|
|
35
|
-
this.on.unlinked.add(() => sizeObserver.stop());
|
|
22
|
+
sizeObserver.watchView(this);
|
|
23
|
+
this.on.linked.add(this.render,this);
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
render() {
|
|
39
|
-
const dimensions = this.
|
|
27
|
+
const dimensions = this.__sizeObserver.dimensions;
|
|
40
28
|
const size = dimensions.size;
|
|
41
29
|
|
|
42
30
|
const width = size.x;
|
|
43
31
|
const height = size.y;
|
|
44
32
|
|
|
45
|
-
if (width
|
|
33
|
+
if (width <= 0 || height <= 0) {
|
|
46
34
|
//canvas too small
|
|
47
35
|
return;
|
|
48
36
|
}
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
this.
|
|
38
|
+
// resize canvas as necessary
|
|
39
|
+
this.size.set(width, height);
|
|
52
40
|
|
|
53
41
|
this.draw(this.context2d, width, height);
|
|
54
42
|
}
|
package/engine/EngineHarness.js
CHANGED
|
@@ -236,6 +236,8 @@ export class EngineHarness {
|
|
|
236
236
|
* @param {number} [cameraFieldOfView]
|
|
237
237
|
* @param {number} [cameraFarDistance]
|
|
238
238
|
* @param {boolean} [cameraController=true]
|
|
239
|
+
* @param {boolean} [cameraAutoClip]
|
|
240
|
+
* @param shadowmapResolution
|
|
239
241
|
*/
|
|
240
242
|
static async buildBasics({
|
|
241
243
|
engine,
|
|
@@ -252,11 +254,13 @@ export class EngineHarness {
|
|
|
252
254
|
enableLights = true,
|
|
253
255
|
cameraFieldOfView,
|
|
254
256
|
cameraFarDistance,
|
|
255
|
-
cameraController = true
|
|
257
|
+
cameraController = true,
|
|
258
|
+
cameraAutoClip = false,
|
|
259
|
+
shadowmapResolution
|
|
256
260
|
}) {
|
|
257
261
|
|
|
258
262
|
if (enableLights) {
|
|
259
|
-
EngineHarness.buildLights({ engine: engine });
|
|
263
|
+
EngineHarness.buildLights({ engine: engine, shadowmapResolution });
|
|
260
264
|
}
|
|
261
265
|
|
|
262
266
|
const camera = EngineHarness.buildCamera({
|
|
@@ -266,7 +270,8 @@ export class EngineHarness {
|
|
|
266
270
|
yaw,
|
|
267
271
|
distance,
|
|
268
272
|
fieldOfView: cameraFieldOfView,
|
|
269
|
-
distanceMax: cameraFarDistance
|
|
273
|
+
distanceMax: cameraFarDistance,
|
|
274
|
+
autoClip: cameraAutoClip
|
|
270
275
|
});
|
|
271
276
|
|
|
272
277
|
const cameraEntity = camera.entity;
|
|
@@ -300,13 +305,14 @@ export class EngineHarness {
|
|
|
300
305
|
*
|
|
301
306
|
* @param {Engine} engine
|
|
302
307
|
* @param {EntityComponentDataset} ecd
|
|
308
|
+
* @param shadowmapResolution
|
|
303
309
|
*/
|
|
304
|
-
static buildLights({ engine, ecd = engine.entityManager.dataset }) {
|
|
310
|
+
static buildLights({ engine, ecd = engine.entityManager.dataset, shadowmapResolution = 1024 }) {
|
|
305
311
|
const em = engine.entityManager;
|
|
306
312
|
|
|
307
313
|
if (em.getSystem(LightSystem) === null) {
|
|
308
314
|
em.addSystem(new LightSystem(engine, {
|
|
309
|
-
shadowResolution:
|
|
315
|
+
shadowResolution: shadowmapResolution
|
|
310
316
|
}));
|
|
311
317
|
}
|
|
312
318
|
|
|
@@ -4,6 +4,10 @@ import {CrossOriginConfig} from "./CORS/CrossOriginConfig";
|
|
|
4
4
|
import {AssetTransformer} from "./AssetTransformer";
|
|
5
5
|
import Engine from "../Engine";
|
|
6
6
|
|
|
7
|
+
interface PromiseOptions {
|
|
8
|
+
skip_queue: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
export class AssetManager {
|
|
8
12
|
constructor(engine: Engine)
|
|
9
13
|
|
|
@@ -11,7 +15,7 @@ export class AssetManager {
|
|
|
11
15
|
|
|
12
16
|
load_concurrency: number
|
|
13
17
|
|
|
14
|
-
promise<T>(path: string, type: string): Promise<Asset<T>>
|
|
18
|
+
promise<T>(path: string, type: string, options?: PromiseOptions): Promise<Asset<T>>
|
|
15
19
|
|
|
16
20
|
remove(path: string, type: string): boolean
|
|
17
21
|
|
|
@@ -16,7 +16,7 @@ import { noop } from "../../core/function/Functions.js";
|
|
|
16
16
|
import { Deque } from "../../core/collection/queue/Deque.js";
|
|
17
17
|
import Task from "../../core/process/task/Task.js";
|
|
18
18
|
import { TaskSignal } from "../../core/process/task/TaskSignal.js";
|
|
19
|
-
import { AssetRequest } from "./AssetRequest.js";
|
|
19
|
+
import { AssetRequest, AssetRequestFlags } from "./AssetRequest.js";
|
|
20
20
|
import FastBinaryHeap from "../../core/collection/heap/FastBinaryHeap.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -38,12 +38,18 @@ class PendingAsset {
|
|
|
38
38
|
* @constructor
|
|
39
39
|
*/
|
|
40
40
|
constructor(description) {
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @type {AssetDescription}
|
|
44
|
+
*/
|
|
41
45
|
this.description = description;
|
|
46
|
+
|
|
42
47
|
/**
|
|
43
48
|
*
|
|
44
49
|
* @type {AssetRequest[]}
|
|
45
50
|
*/
|
|
46
51
|
this.requests = [];
|
|
52
|
+
|
|
47
53
|
/**
|
|
48
54
|
*
|
|
49
55
|
* @type {BoundedValue}
|
|
@@ -297,9 +303,10 @@ export class AssetManager {
|
|
|
297
303
|
/**
|
|
298
304
|
* @param {String} path
|
|
299
305
|
* @param {String} type
|
|
306
|
+
* @param {boolean} [skip_queue] if true will skip the queue and dispatch request immediately
|
|
300
307
|
* @returns {Promise<Asset>}
|
|
301
308
|
*/
|
|
302
|
-
promise(path, type) {
|
|
309
|
+
promise(path, type, { skip_queue = false } = {}) {
|
|
303
310
|
return new Promise((resolve, reject) => {
|
|
304
311
|
this.get(path, type, resolve, reject);
|
|
305
312
|
});
|
|
@@ -312,8 +319,9 @@ export class AssetManager {
|
|
|
312
319
|
* @param {function(asset:Asset<T>)} callback
|
|
313
320
|
* @param {function(*)} [failure]
|
|
314
321
|
* @param {function(loaded:number, total:number)} [progress]
|
|
322
|
+
* @param {boolean} [skip_queue]
|
|
315
323
|
*/
|
|
316
|
-
get(path, type, callback, failure = console.error, progress = noop) {
|
|
324
|
+
get(path, type, callback, failure = console.error, progress = noop, skip_queue = false) {
|
|
317
325
|
if (typeof path !== "string") {
|
|
318
326
|
throw new Error("Path must be string. Path = " + JSON.stringify(path));
|
|
319
327
|
}
|
|
@@ -327,6 +335,9 @@ export class AssetManager {
|
|
|
327
335
|
} else {
|
|
328
336
|
//create request object
|
|
329
337
|
const assetRequest = new AssetRequest(callback, failure, progress);
|
|
338
|
+
|
|
339
|
+
assetRequest.writeFlag(AssetRequestFlags.SkipQueue, skip_queue);
|
|
340
|
+
|
|
330
341
|
//submit request
|
|
331
342
|
this.submitRequest(assetDescription, assetRequest);
|
|
332
343
|
}
|
|
@@ -387,6 +398,25 @@ export class AssetManager {
|
|
|
387
398
|
}
|
|
388
399
|
}
|
|
389
400
|
|
|
401
|
+
/**
|
|
402
|
+
* Force load of the asset
|
|
403
|
+
* @param {PendingAsset} asset
|
|
404
|
+
* @private
|
|
405
|
+
*/
|
|
406
|
+
__force_load(asset) {
|
|
407
|
+
// check if the asset is already being loaded
|
|
408
|
+
if (this.__pending_asset_active_load_set.has(asset)) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// remove from queue
|
|
413
|
+
this.__pending_asset_wait_queue.delete(asset);
|
|
414
|
+
|
|
415
|
+
// dispatch
|
|
416
|
+
this.__dispatch_pending_asset(asset);
|
|
417
|
+
|
|
418
|
+
}
|
|
419
|
+
|
|
390
420
|
/**
|
|
391
421
|
* Asset has been loaded successfully, failed, or aborted
|
|
392
422
|
* @param {PendingAsset} pending_asset
|
|
@@ -584,28 +614,33 @@ export class AssetManager {
|
|
|
584
614
|
submitRequest(assetDescription, request) {
|
|
585
615
|
const requestMap = this.request_map;
|
|
586
616
|
|
|
617
|
+
let shouldSchedule = false;
|
|
587
618
|
let pendingAsset = requestMap.get(assetDescription);
|
|
588
|
-
if (pendingAsset !== undefined) {
|
|
589
|
-
//already loading
|
|
590
|
-
pendingAsset.requests.push(request);
|
|
591
619
|
|
|
592
|
-
|
|
593
|
-
|
|
620
|
+
if (pendingAsset === undefined) {
|
|
621
|
+
pendingAsset = new PendingAsset(assetDescription);
|
|
622
|
+
requestMap.set(assetDescription, pendingAsset);
|
|
594
623
|
|
|
595
|
-
|
|
624
|
+
shouldSchedule = true;
|
|
596
625
|
}
|
|
597
626
|
|
|
598
|
-
|
|
599
|
-
pendingAsset = new PendingAsset(assetDescription);
|
|
627
|
+
pendingAsset.requests.push(request);
|
|
600
628
|
|
|
601
|
-
|
|
629
|
+
if (shouldSchedule) {
|
|
630
|
+
// not loading yet, lets create a load container and schedule it
|
|
631
|
+
this.__schedule_load(pendingAsset);
|
|
632
|
+
} else {
|
|
633
|
+
// update priority queue if necessary
|
|
634
|
+
this.__pending_asset_wait_queue.updateElementScore(pendingAsset);
|
|
635
|
+
}
|
|
602
636
|
|
|
603
|
-
const requests = pendingAsset.requests;
|
|
604
|
-
requests.push(request);
|
|
605
637
|
|
|
606
|
-
|
|
638
|
+
if (request.getFlag(AssetRequestFlags.SkipQueue)) {
|
|
639
|
+
this.__force_load(pendingAsset);
|
|
640
|
+
}
|
|
607
641
|
}
|
|
608
642
|
|
|
643
|
+
|
|
609
644
|
/**
|
|
610
645
|
*
|
|
611
646
|
* @param {string} type
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { Asset } from "./Asset.js";
|
|
2
2
|
import { AssetManager } from "./AssetManager.js";
|
|
3
|
+
import { AssetLoader } from "./loaders/AssetLoader.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @return {Engine}
|
|
8
|
+
*/
|
|
9
|
+
function dummyEngine() {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
3
12
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
0
|
|
10
|
-
));
|
|
13
|
+
class DummyLoader extends AssetLoader {
|
|
14
|
+
load(path, success, failure, progress) {
|
|
15
|
+
success(new Asset(() => 1));
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
test('successful get', () => {
|
|
14
|
-
const am = new AssetManager();
|
|
20
|
+
const am = new AssetManager(dummyEngine());
|
|
15
21
|
|
|
16
|
-
am.registerLoader('a',
|
|
22
|
+
am.registerLoader('a', new DummyLoader());
|
|
17
23
|
|
|
18
24
|
|
|
19
25
|
return new Promise(function (resolve, reject) {
|
|
@@ -22,9 +28,9 @@ test('successful get', () => {
|
|
|
22
28
|
});
|
|
23
29
|
|
|
24
30
|
test('tryGet loaded resource', async () => {
|
|
25
|
-
const am = new AssetManager();
|
|
31
|
+
const am = new AssetManager(dummyEngine());
|
|
26
32
|
|
|
27
|
-
am.registerLoader('a',
|
|
33
|
+
am.registerLoader('a', new DummyLoader());
|
|
28
34
|
|
|
29
35
|
await am.promise('bla', 'a');
|
|
30
36
|
|