@woosh/meep-engine 2.42.7 → 2.43.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.
- package/core/binary/BitSet.js +4 -4
- package/core/binary/ctz32.js +40 -0
- package/core/collection/ObservedMap.js +61 -57
- package/core/collection/heap/FastBinaryHeap.js +7 -1
- package/core/collection/heap/Uint32Heap.js +19 -0
- package/core/collection/map/AsyncLoadingCache.js +3 -1
- package/core/geom/2d/compute_polygon_area_2d.js +32 -0
- package/core/geom/2d/compute_polygon_area_2d.spec.js +10 -0
- package/core/geom/2d/compute_triangle_area_2d.js +15 -0
- package/core/geom/2d/compute_triangle_area_2d.spec.js +9 -0
- package/core/geom/2d/convex-hull/convex_hull_jarvis_2d.js +64 -0
- package/core/geom/2d/convex-hull/convex_hull_jarvis_2d.spec.js +33 -0
- package/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +82 -0
- package/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +135 -0
- package/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +282 -0
- package/core/geom/2d/convex-hull/orientation3.js +444 -0
- package/core/geom/2d/convex-hull/orientation3_array.js +22 -0
- package/core/geom/2d/convex-hull/orientation3_v2.js +12 -0
- package/core/geom/2d/intersect_ray_2d.js +56 -0
- package/core/geom/2d/quad-tree/QuadTreeNode.js +0 -81
- package/core/geom/2d/quad-tree/qt_match_data_by_circle.js +70 -0
- package/core/geom/3d/matrix/m4_multiply_alphatensor.js +131 -0
- package/core/geom/3d/plane/orient3d_fast.js +2 -6
- package/core/geom/3d/tetrahedra/README.md +7 -0
- package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +3 -1
- package/core/geom/3d/tetrahedra/delaunay/Cavity.js +48 -0
- package/core/geom/3d/tetrahedra/{compute_delaunay_tetrahedral_mesh.js → delaunay/compute_delaunay_tetrahedral_mesh.js} +15 -7
- package/core/geom/3d/tetrahedra/{compute_delaunay_tetrahedral_mesh.spec.js → delaunay/compute_delaunay_tetrahedral_mesh.spec.js} +0 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +73 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_toward_cavity.js +48 -0
- package/core/geom/3d/tetrahedra/hxt/a.js +524 -0
- package/core/geom/3d/tetrahedra/hxt/hxt.js +140 -0
- package/core/geom/3d/tetrahedra/hxt/hxt.wasm +0 -0
- package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +35 -20
- package/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +98 -0
- package/core/geom/3d/tetrahedra/tetrahedra_collection.js +60 -131
- package/core/geom/packing/{MaxRectangles.js → max-rect/MaxRectangles.js} +28 -124
- package/core/geom/packing/max-rect/removeRedundantBoxes.js +69 -0
- package/core/geom/packing/max-rect/removeRedundantBoxesArray.js +40 -0
- package/core/geom/v3_distance_above_plane.js +1 -1
- package/core/graph/layout/BoxLayouter.js +2 -88
- package/core/graph/layout/CircleLayout.js +2 -1
- package/core/graph/layout/box/forceIntoBox.js +45 -0
- package/core/graph/layout/box/pullBoxTowardsPoint.js +20 -0
- package/core/graph/layout/box/resolveAABB2Overlap.js +22 -0
- package/core/math/bessel_3.js +11 -0
- package/core/math/bessel_i0.js +26 -0
- package/core/process/executor/ConcurrentExecutor.spec.js +2 -1
- package/core/process/task/util/actionTask.js +19 -0
- package/core/process/task/util/countTask.js +62 -0
- package/core/process/task/util/delayTask.js +45 -0
- package/core/process/task/util/emptyTask.js +19 -0
- package/core/process/task/util/failingTask.js +17 -0
- package/core/process/task/util/futureTask.js +48 -0
- package/core/process/task/util/promiseTask.js +42 -0
- package/core/process/task/util/randomCountTask.js +64 -0
- package/core/process/task/util/wrapTaskIgnoreFailure.js +47 -0
- package/engine/Engine.js +8 -8
- package/engine/EngineBootstrapper.js +1 -1
- package/engine/asset/AssetManager.js +197 -53
- package/engine/asset/AssetRequest.js +32 -0
- package/engine/asset/loaders/ArrayBufferLoader.js +62 -50
- package/engine/asset/loaders/image/png/PNG.js +15 -1
- package/engine/asset/loaders/image/png/PNGReader.js +3 -2
- package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +2 -1
- package/engine/ecs/storage/BinaryBufferDeSerializer.js +1 -1
- package/engine/ecs/storage/JSONDeSerializer.js +2 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapOptimizer.js +2 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
- package/engine/graphics/camera/makeScreenScissorFrustum.js +1 -1
- package/engine/graphics/camera/testClippingPlaneComputation.js +4 -45
- package/engine/graphics/ecs/camera/FrustumProjector.js +6 -0
- package/engine/graphics/ecs/decal/v2/FPDecalSystem.js +5 -0
- package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +23 -4
- package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +1 -1
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +11 -0
- package/engine/graphics/geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js +1 -2
- package/engine/graphics/impostors/octahedral/ImpostorBaker.js +5 -2
- package/engine/graphics/impostors/octahedral/ImpostorDescription.js +18 -0
- package/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +15 -0
- package/engine/graphics/impostors/octahedral/prototypeBaker.js +66 -79
- package/engine/graphics/impostors/octahedral/shader/ImpostorShaderWireframeV0.js +134 -0
- package/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +128 -0
- package/engine/graphics/impostors/octahedral/util/build_geometry_from_cutout_shape.js +32 -0
- package/engine/graphics/impostors/octahedral/util/load_mesh_for_bake.js +31 -0
- package/engine/graphics/impostors/octahedral/util/makeImpostorAtlasPreview.js +107 -0
- package/engine/graphics/material/manager/ManagedMaterial.js +4 -0
- package/engine/graphics/material/manager/MaterialManager.js +1 -0
- package/engine/graphics/material/optimization/MaterialOptimizationContext.js +7 -3
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +2 -2
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +0 -19
- package/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +83 -27
- package/engine/graphics/shadows/ShadowMapRenderer.js +11 -4
- package/engine/graphics/texture/atlas/AbstractTextureAtlas.js +2 -1
- package/engine/graphics/texture/atlas/CachingTextureAtlas.js +208 -38
- package/engine/graphics/texture/atlas/TextureAtlas.js +31 -24
- package/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.js +1 -1
- package/engine/graphics/texture/sampler/filter/box.js +16 -0
- package/engine/graphics/texture/sampler/filter/cubic2.js +32 -0
- package/engine/graphics/texture/sampler/filter/gaussian.js +16 -0
- package/engine/graphics/texture/sampler/filter/kaiser_1.js +19 -0
- package/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +19 -0
- package/engine/graphics/texture/sampler/filter/mitchell.js +55 -0
- package/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +109 -0
- package/engine/graphics/texture/sampler/filter/triangle.js +19 -0
- package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +187 -86
- package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +77 -25
- package/engine/graphics/texture/sampler/search/make_edge_condition_channel_threshold.js +34 -0
- package/engine/graphics/texture/sampler/search/sampler2d_find_pixels.js +24 -0
- package/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +212 -0
- package/engine/knowledge/database/StaticKnowledgeDataTable.js +1 -1
- package/engine/navigation/grid/AStar.js +1 -1
- package/engine/plugin/EnginePluginManager.js +28 -27
- package/engine/plugin/PluginReferenceContext.js +9 -0
- package/engine/scene/Scene.js +1 -1
- package/engine/scene/SerializedScene.js +1 -1
- package/engine/scene/transitionToScene.js +3 -1
- package/generation/example/main.js +1 -1
- package/generation/grid/generation/GridTaskApplyActionToCells.js +1 -1
- package/generation/grid/generation/GridTaskDensityMarkerDistribution.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +1 -1
- package/generation/grid/generation/NoopGridTaskGenerator.js +1 -1
- package/generation/grid/generation/discrete/GridTaskCellularAutomata.js +2 -1
- package/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
- package/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +3 -2
- package/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +1 -1
- package/generation/grid/generation/grid/GridTaskAddNodesFixed.js +1 -1
- package/generation/grid/generation/road/GridTaskGenerateRoads.js +3 -2
- package/generation/grid/generation/util/buildDistanceMapToObjective.js +1 -1
- package/generation/markers/GridActionRuleSet.js +2 -1
- package/generation/placement/GridCellActionTransformNearbyMarkers.js +2 -4
- package/generation/theme/ThemeEngine.js +4 -1
- package/package.json +1 -1
- package/view/asset/AssetLoaderStatusView.js +5 -5
- package/view/minimap/gl/MinimapTerrainGL.js +1 -2
- package/view/renderModel.js +1 -1
- package/view/tooltip/TooltipView.js +5 -5
- package/core/process/task/TaskUtils.js +0 -352
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { MinimapWorldLayer } from "./MinimapWorldLayer.js";
|
|
2
|
-
import { Mesh, MeshBasicMaterial, PlaneBufferGeometry } from "three";
|
|
2
|
+
import { Mesh, MeshBasicMaterial, NearestFilter, PlaneBufferGeometry } from "three";
|
|
3
3
|
import ObservedValue from "../../../core/model/ObservedValue.js";
|
|
4
4
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
5
5
|
import { Cache } from "../../../core/cache/Cache.js";
|
|
6
6
|
import { GameAssetType } from "../../../engine/asset/GameAssetType.js";
|
|
7
|
-
import { NearestFilter } from "three/src/constants.js";
|
|
8
7
|
|
|
9
8
|
export class MinimapTerrainGL extends MinimapWorldLayer {
|
|
10
9
|
/**
|
package/view/renderModel.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
import Future from '../core/process/Future.js';
|
|
5
5
|
|
|
6
6
|
import ConcurrentExecutor from '../core/process/executor/ConcurrentExecutor.js';
|
|
7
|
-
import { futureTask } from "../core/process/task/TaskUtils.js";
|
|
8
7
|
import { promiseMaterialLoaded } from "../engine/graphics/util/promiseMaterialLoaded.js";
|
|
9
8
|
import { guessAssetType } from "../engine/asset/guessAssetType.js";
|
|
10
9
|
import { makeModelView as _makeModelView } from "../engine/graphics/makeModelView.js";
|
|
10
|
+
import { futureTask } from "../core/process/task/util/futureTask.js";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
//use an executor to prevent stalling main thread when building previews
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import View from "../View.js";
|
|
2
|
-
import dom from "../DOM.js";
|
|
3
2
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
4
|
-
import { forceIntoBox, pullBoxTowardsPoint, resolveAABB2Overlap } from "../../core/graph/layout/BoxLayouter.js";
|
|
5
3
|
import AABB2 from "../../core/geom/AABB2.js";
|
|
6
4
|
import { CompassArrowView } from "../elements/CompassArrowView.js";
|
|
7
5
|
import EmptyView from "../elements/EmptyView.js";
|
|
8
6
|
import { EPSILON } from "../../core/math/MathUtils.js";
|
|
7
|
+
import { forceIntoBox } from "../../core/graph/layout/box/forceIntoBox.js";
|
|
8
|
+
import { pullBoxTowardsPoint } from "../../core/graph/layout/box/pullBoxTowardsPoint.js";
|
|
9
|
+
import { resolveAABB2Overlap } from "../../core/graph/layout/box/resolveAABB2Overlap.js";
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class TooltipView extends View {
|
|
@@ -25,10 +26,9 @@ class TooltipView extends View {
|
|
|
25
26
|
*/
|
|
26
27
|
this.model = tip;
|
|
27
28
|
|
|
28
|
-
//build dom tree
|
|
29
|
-
const dRoot = dom('div').addClass("tooltip-view");
|
|
30
29
|
//set dom element
|
|
31
|
-
this.el =
|
|
30
|
+
this.el = document.createElement('div');
|
|
31
|
+
this.addClass("tooltip-view");
|
|
32
32
|
|
|
33
33
|
const vContents = new EmptyView({ classList: ['contents'] });
|
|
34
34
|
|
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 22/05/2016.
|
|
3
|
-
*/
|
|
4
|
-
import { randomizeArrayElementOrder } from "../../collection/ArrayUtils.js";
|
|
5
|
-
import { seededRandom } from "../../math/random/seededRandom.js";
|
|
6
|
-
import Task from "./Task.js";
|
|
7
|
-
import { TaskSignal } from "./TaskSignal.js";
|
|
8
|
-
import { clamp01 } from "../../math/clamp01.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {function} action
|
|
13
|
-
* @param {string} name
|
|
14
|
-
* @return {Task}
|
|
15
|
-
*/
|
|
16
|
-
export function actionTask(action, name = "unnamed") {
|
|
17
|
-
return new Task({
|
|
18
|
-
name,
|
|
19
|
-
cycleFunction() {
|
|
20
|
-
action();
|
|
21
|
-
|
|
22
|
-
return TaskSignal.EndSuccess;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {number} seed RNG seed
|
|
30
|
-
* @param {number|function(*):number} initial
|
|
31
|
-
* @param {number|function(*):number} limit
|
|
32
|
-
* @param {function(index:int)} callback
|
|
33
|
-
* @returns {Task}
|
|
34
|
-
*/
|
|
35
|
-
export function randomCountTask(seed, initial, limit, callback) {
|
|
36
|
-
|
|
37
|
-
const random = seededRandom(seed);
|
|
38
|
-
|
|
39
|
-
const span = limit - initial;
|
|
40
|
-
|
|
41
|
-
const sequence = new Uint16Array(span);
|
|
42
|
-
|
|
43
|
-
let i = 0;
|
|
44
|
-
|
|
45
|
-
function cycle() {
|
|
46
|
-
if (i >= span) {
|
|
47
|
-
return TaskSignal.EndSuccess;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const order = sequence[i];
|
|
51
|
-
|
|
52
|
-
const index = order + initial;
|
|
53
|
-
|
|
54
|
-
callback(index);
|
|
55
|
-
|
|
56
|
-
i++;
|
|
57
|
-
|
|
58
|
-
return TaskSignal.Continue;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return new Task({
|
|
62
|
-
name: `Count ${initial} -> ${limit}`,
|
|
63
|
-
initializer() {
|
|
64
|
-
|
|
65
|
-
i = 0;
|
|
66
|
-
|
|
67
|
-
//generate sequence
|
|
68
|
-
for (let i = 0; i < span; i++) {
|
|
69
|
-
sequence[i] = i;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
//shuffle
|
|
73
|
-
randomizeArrayElementOrder(random, sequence);
|
|
74
|
-
},
|
|
75
|
-
cycleFunction: cycle,
|
|
76
|
-
computeProgress: function () {
|
|
77
|
-
|
|
78
|
-
if (span === 0) {
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return i / span;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
* @param {number|function(*):number} initial
|
|
90
|
-
* @param {number|function(*):number} limit
|
|
91
|
-
* @param {function(index:int)} callback
|
|
92
|
-
* @returns {Task}
|
|
93
|
-
*/
|
|
94
|
-
export function countTask(initial, limit, callback) {
|
|
95
|
-
let initialValue = 0;
|
|
96
|
-
let limitValue = 0;
|
|
97
|
-
|
|
98
|
-
let i = initialValue;
|
|
99
|
-
|
|
100
|
-
function cycle() {
|
|
101
|
-
if (i >= limitValue) {
|
|
102
|
-
return TaskSignal.EndSuccess;
|
|
103
|
-
}
|
|
104
|
-
callback(i);
|
|
105
|
-
i++;
|
|
106
|
-
|
|
107
|
-
return TaskSignal.Continue;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const initialType = typeof initial;
|
|
111
|
-
const limitType = typeof limit;
|
|
112
|
-
|
|
113
|
-
const name = "count (from " + ((initialType === 'number') ? initial : 'variable') + " to " + ((limitType === 'number') ? limit : 'variable') + ")";
|
|
114
|
-
|
|
115
|
-
return new Task({
|
|
116
|
-
name: name,
|
|
117
|
-
initializer() {
|
|
118
|
-
|
|
119
|
-
if (initialType === "number") {
|
|
120
|
-
initialValue = initial;
|
|
121
|
-
} else if (initialType === "function") {
|
|
122
|
-
initialValue = initial();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (limitType === "number") {
|
|
126
|
-
limitValue = limit;
|
|
127
|
-
} else if (limitType === "function") {
|
|
128
|
-
limitValue = limit();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
i = initialValue;
|
|
132
|
-
|
|
133
|
-
},
|
|
134
|
-
cycleFunction: cycle,
|
|
135
|
-
computeProgress: function () {
|
|
136
|
-
const span = limitValue - initialValue;
|
|
137
|
-
|
|
138
|
-
if (span === 0) {
|
|
139
|
-
return 0;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return (i - initialValue) / span;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
*
|
|
149
|
-
* @param {number} delay in milliseconds
|
|
150
|
-
* @param {string} [name]
|
|
151
|
-
* @returns {Task}
|
|
152
|
-
*/
|
|
153
|
-
export function delayTask(delay, name = "unnamed") {
|
|
154
|
-
let startTime = -1;
|
|
155
|
-
|
|
156
|
-
const estimatedDuration = delay / 1000;
|
|
157
|
-
return new Task({
|
|
158
|
-
name: `delay (${delay}ms): ${name}`,
|
|
159
|
-
initializer() {
|
|
160
|
-
startTime = Date.now();
|
|
161
|
-
},
|
|
162
|
-
cycleFunction() {
|
|
163
|
-
if (Date.now() >= startTime + delay) {
|
|
164
|
-
return TaskSignal.EndSuccess;
|
|
165
|
-
} else {
|
|
166
|
-
return TaskSignal.Yield;
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
computeProgress() {
|
|
170
|
-
if (startTime === -1) {
|
|
171
|
-
return 0;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const currentTime = Date.now();
|
|
175
|
-
const remainingTime = currentTime - startTime;
|
|
176
|
-
|
|
177
|
-
let fraction = remainingTime / delay;
|
|
178
|
-
|
|
179
|
-
if (Number.isNaN(fraction)) {
|
|
180
|
-
fraction = 0;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return clamp01(fraction);
|
|
184
|
-
},
|
|
185
|
-
estimatedDuration
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
*
|
|
191
|
-
* @param {string} [name="no-operation"]
|
|
192
|
-
* @returns {Task}
|
|
193
|
-
*/
|
|
194
|
-
export function emptyTask(name = "no-operation") {
|
|
195
|
-
return new Task({
|
|
196
|
-
name,
|
|
197
|
-
cycleFunction: function () {
|
|
198
|
-
return TaskSignal.EndSuccess;
|
|
199
|
-
},
|
|
200
|
-
computeProgress: function () {
|
|
201
|
-
return 1;
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
* @param e value to be thrown
|
|
209
|
-
*/
|
|
210
|
-
export function failingTask(e) {
|
|
211
|
-
return new Task({
|
|
212
|
-
name: "Failing Task",
|
|
213
|
-
cycleFunction: function () {
|
|
214
|
-
throw e;
|
|
215
|
-
},
|
|
216
|
-
computeProgress: function () {
|
|
217
|
-
return 0;
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
*
|
|
224
|
-
* @param {Future} future
|
|
225
|
-
* @param {String} name
|
|
226
|
-
* @returns {Task}
|
|
227
|
-
*/
|
|
228
|
-
export function futureTask(future, name) {
|
|
229
|
-
if (typeof future.resolve !== 'function') {
|
|
230
|
-
// Not a future
|
|
231
|
-
throw new Error("No resolve function on the supplied object");
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
let resolved = false;
|
|
235
|
-
let rejected = false;
|
|
236
|
-
let error = null;
|
|
237
|
-
|
|
238
|
-
future.then(function () {
|
|
239
|
-
resolved = true;
|
|
240
|
-
}, function (e) {
|
|
241
|
-
rejected = true;
|
|
242
|
-
error = e;
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
function cycle() {
|
|
246
|
-
future.resolve();
|
|
247
|
-
if (resolved) {
|
|
248
|
-
return TaskSignal.EndSuccess;
|
|
249
|
-
} else if (rejected) {
|
|
250
|
-
throw error;
|
|
251
|
-
} else {
|
|
252
|
-
//give up CPU share
|
|
253
|
-
return TaskSignal.Yield;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function progress() {
|
|
258
|
-
return resolved ? 1 : 0;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return new Task({
|
|
262
|
-
name: name,
|
|
263
|
-
cycleFunction: cycle,
|
|
264
|
-
computeProgress: progress
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
*
|
|
270
|
-
* @param {Promise} promise
|
|
271
|
-
* @param {string} name
|
|
272
|
-
* @returns {Task}
|
|
273
|
-
*/
|
|
274
|
-
export function promiseTask(promise, name) {
|
|
275
|
-
let resolved = false;
|
|
276
|
-
let rejected = false;
|
|
277
|
-
let error = null;
|
|
278
|
-
|
|
279
|
-
promise.then(function () {
|
|
280
|
-
resolved = true;
|
|
281
|
-
}, function (e) {
|
|
282
|
-
rejected = true;
|
|
283
|
-
error = e;
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
function cycle() {
|
|
287
|
-
if (resolved) {
|
|
288
|
-
return TaskSignal.EndSuccess;
|
|
289
|
-
} else if (rejected) {
|
|
290
|
-
throw error;
|
|
291
|
-
} else {
|
|
292
|
-
//give up CPU share
|
|
293
|
-
return TaskSignal.Yield;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function progress() {
|
|
298
|
-
return resolved ? 1 : 0;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return new Task({
|
|
302
|
-
name: name,
|
|
303
|
-
cycleFunction: cycle,
|
|
304
|
-
computeProgress: progress
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
*
|
|
311
|
-
* @param {Task} task
|
|
312
|
-
* @returns {Task}
|
|
313
|
-
*/
|
|
314
|
-
export function wrapTaskIgnoreFailure(task) {
|
|
315
|
-
let initializationFailed = false;
|
|
316
|
-
|
|
317
|
-
const wrapper = new Task({
|
|
318
|
-
name: `Ignore Failure of [${task.name}]`,
|
|
319
|
-
initializer() {
|
|
320
|
-
try {
|
|
321
|
-
task.initialize();
|
|
322
|
-
} catch (e) {
|
|
323
|
-
initializationFailed = true;
|
|
324
|
-
console.warn(e);
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
estimatedDuration: task.estimatedDuration,
|
|
328
|
-
cycleFunction() {
|
|
329
|
-
|
|
330
|
-
task.__executedCpuTime = wrapper.__executedCpuTime;
|
|
331
|
-
task.__executedCycleCount = wrapper.__executedCycleCount;
|
|
332
|
-
|
|
333
|
-
if (initializationFailed) {
|
|
334
|
-
//initializer failed, don't execute the source task
|
|
335
|
-
return TaskSignal.EndSuccess;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const c = task.cycle();
|
|
339
|
-
|
|
340
|
-
if (c === TaskSignal.EndFailure) {
|
|
341
|
-
return TaskSignal.EndSuccess;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return c;
|
|
345
|
-
},
|
|
346
|
-
computeProgress() {
|
|
347
|
-
return task.computeProgress();
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
return wrapper;
|
|
352
|
-
}
|