@woosh/meep-engine 2.43.1 → 2.43.3
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/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/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/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 +8 -10
- 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/tetrahedra/README.md +10 -1
- package/core/geom/3d/tetrahedra/{tetrahedra_collection.js → TetrahedralMesh.js} +236 -152
- package/core/geom/3d/tetrahedra/TetrahedralMesh.spec.js +156 -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 +45 -7
- package/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +44 -9
- package/core/geom/3d/tetrahedra/delaunay/debug_validate_mesh.js +19 -0
- package/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +155 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity2.js +224 -0
- 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_insert_point.js +98 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_toward_cavity.js +13 -6
- package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +9 -9
- package/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +1 -1
- 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 +119 -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/task/util/randomCountTask.js +1 -1
- 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/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/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/geometry/VertexDataSpec.js +1 -1
- 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/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 +7 -1
- 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/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 +1 -1
- 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_compute_cavity.js +0 -73
- 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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assert } from "../../../assert.js";
|
|
2
|
-
import { isArrayEqual } from "../../../collection/ArrayUtils.js";
|
|
3
2
|
import List from "../../../collection/list/List.js";
|
|
4
3
|
import { NodeInstancePortReference } from "./NodeInstancePortReference.js";
|
|
5
4
|
import { PortDirection } from "./PortDirection.js";
|
|
5
|
+
import { isArrayEqual } from "../../../collection/array/isArrayEqual.js";
|
|
6
6
|
|
|
7
7
|
export class NodeInstance {
|
|
8
8
|
constructor() {
|
|
@@ -27,14 +27,14 @@ export class NodeInstance {
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Internal instance data
|
|
30
|
-
* @type {
|
|
30
|
+
* @type {Array}
|
|
31
31
|
*/
|
|
32
32
|
this.parameters = [];
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* @transient
|
|
37
|
-
* @type {
|
|
37
|
+
* @type {Array}
|
|
38
38
|
*/
|
|
39
39
|
this.outputsValues = [];
|
|
40
40
|
|
|
@@ -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
|
*
|
|
@@ -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
|
}
|
|
@@ -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
|
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @enum {number}
|
|
4
|
+
*/
|
|
5
|
+
export const AssetRequestFlags = {
|
|
6
|
+
/**
|
|
7
|
+
* Will always skip the wait queue
|
|
8
|
+
*/
|
|
9
|
+
SkipQueue: 1
|
|
10
|
+
};
|
|
11
|
+
|
|
1
12
|
export class AssetRequest {
|
|
2
13
|
/**
|
|
3
14
|
*
|
|
@@ -28,5 +39,51 @@ export class AssetRequest {
|
|
|
28
39
|
* @type {number}
|
|
29
40
|
*/
|
|
30
41
|
this.priority = 0;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {number}
|
|
46
|
+
*/
|
|
47
|
+
this.flags = 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {number|AssetRequestFlags} flag
|
|
53
|
+
* @returns {void}
|
|
54
|
+
*/
|
|
55
|
+
setFlag(flag) {
|
|
56
|
+
this.flags |= flag;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {number|AssetRequestFlags} flag
|
|
62
|
+
* @returns {void}
|
|
63
|
+
*/
|
|
64
|
+
clearFlag(flag) {
|
|
65
|
+
this.flags &= ~flag;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param {number|AssetRequestFlags} flag
|
|
71
|
+
* @param {boolean} value
|
|
72
|
+
*/
|
|
73
|
+
writeFlag(flag, value) {
|
|
74
|
+
if (value) {
|
|
75
|
+
this.setFlag(flag);
|
|
76
|
+
} else {
|
|
77
|
+
this.clearFlag(flag);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param {number|AssetRequestFlags} flag
|
|
84
|
+
* @returns {boolean}
|
|
85
|
+
*/
|
|
86
|
+
getFlag(flag) {
|
|
87
|
+
return (this.flags & flag) === flag;
|
|
31
88
|
}
|
|
32
89
|
}
|
|
@@ -3,6 +3,23 @@ import { AssetLoader } from "./AssetLoader.js";
|
|
|
3
3
|
import { CrossOriginKind } from "../CORS/CrossOriginKind.js";
|
|
4
4
|
|
|
5
5
|
export class ArrayBufferLoader extends AssetLoader {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {"auto"|"low"|"high"} fetch_priority
|
|
9
|
+
*/
|
|
10
|
+
constructor({
|
|
11
|
+
fetch_priority = "auto"
|
|
12
|
+
} = {}) {
|
|
13
|
+
super();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @type {"auto"|"low"|"high"}
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
this.__fetch_priority = fetch_priority;
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
load(path, success, failure, progress) {
|
|
7
24
|
const coc = this.assetManager.crossOriginConfig;
|
|
8
25
|
|
|
@@ -13,6 +30,11 @@ export class ArrayBufferLoader extends AssetLoader {
|
|
|
13
30
|
headers: headers
|
|
14
31
|
});
|
|
15
32
|
|
|
33
|
+
if (typeof request.priority !== "undefined") {
|
|
34
|
+
// priority API is present
|
|
35
|
+
request.priority = this.__fetch_priority;
|
|
36
|
+
}
|
|
37
|
+
|
|
16
38
|
fetch(request)
|
|
17
39
|
.then(handle_response)
|
|
18
40
|
.then(response_to_asset)
|
package/engine/ecs/System.js
CHANGED
|
@@ -34,7 +34,7 @@ class System {
|
|
|
34
34
|
/**
|
|
35
35
|
* Component types that are used internally by the system
|
|
36
36
|
* Declaring this helps EntityManager to ensure that all relevant component types are properly registered for the system
|
|
37
|
-
* @type {
|
|
37
|
+
* @type {Array}
|
|
38
38
|
*/
|
|
39
39
|
this.components_used = [];
|
|
40
40
|
}
|
|
@@ -4,7 +4,6 @@ import { SystemEntityContext } from "../system/SystemEntityContext.js";
|
|
|
4
4
|
import { DataScope } from "../../../../model/game/unit/actions/data/DataScope.js";
|
|
5
5
|
import { Blackboard } from "../../intelligence/blackboard/Blackboard.js";
|
|
6
6
|
import { compareNumbersDescending, returnTrue } from "../../../core/function/Functions.js";
|
|
7
|
-
import { randomMultipleFromArray } from "../../../core/collection/ArrayUtils.js";
|
|
8
7
|
import { EntityProxyScope } from "../binding/EntityProxyScope.js";
|
|
9
8
|
import EntityBuilder, { EntityBuilderFlags } from "../EntityBuilder.js";
|
|
10
9
|
import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorComponent.js";
|
|
@@ -20,6 +19,7 @@ import { computeContextualDynamicRuleDebugString } from "./rules/computeContextu
|
|
|
20
19
|
import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
|
|
21
20
|
import { randomFromArray } from "../../../core/math/random/randomFromArray.js";
|
|
22
21
|
import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
|
|
22
|
+
import { randomMultipleFromArray } from "../../../core/collection/array/randomMultipleFromArray.js";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* In seconds
|
|
@@ -41,22 +41,18 @@ export class FrameRunner {
|
|
|
41
41
|
|
|
42
42
|
this.running = true;
|
|
43
43
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const action = this.action;
|
|
47
|
-
|
|
48
|
-
function cycle() {
|
|
49
|
-
if (!self.running) {
|
|
44
|
+
const cycle = () => {
|
|
45
|
+
if (!this.running) {
|
|
50
46
|
//not supposed to be running, bail
|
|
51
47
|
return;
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
action();
|
|
50
|
+
this.action();
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
this.animationFrameId = requestAnimationFrame(cycle);
|
|
57
53
|
}
|
|
58
54
|
|
|
59
|
-
|
|
55
|
+
this.animationFrameId = requestAnimationFrame(cycle);
|
|
60
56
|
|
|
61
57
|
return true;
|
|
62
58
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isArrayEqual } from "../../../../../core/collection/ArrayUtils.js";
|
|
2
1
|
import { computeStringHash } from "../../../../../core/primitives/strings/computeStringHash.js";
|
|
3
2
|
import { invokeObjectHash } from "../../../../../core/model/object/invokeObjectHash.js";
|
|
4
3
|
import { computeHashArray } from "../../../../../core/collection/array/computeHashArray.js";
|
|
5
4
|
import { computeHashIntegerArray } from "../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
5
|
+
import { isArrayEqual } from "../../../../../core/collection/array/isArrayEqual.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
@@ -3,10 +3,10 @@ import { BlendStateMatrix } from "../../blending/BlendStateMatrix.js";
|
|
|
3
3
|
import { AnimationStateDefinition } from "./AnimationStateDefinition.js";
|
|
4
4
|
import { AnimationClipDefinition } from "../../AnimationClipDefinition.js";
|
|
5
5
|
import { AnimationClip } from "../../AnimationClip.js";
|
|
6
|
-
import { isArrayEqual } from "../../../../../../../core/collection/ArrayUtils.js";
|
|
7
6
|
import { invokeObjectHash } from "../../../../../../../core/model/object/invokeObjectHash.js";
|
|
8
7
|
import { computeHashArray } from "../../../../../../../core/collection/array/computeHashArray.js";
|
|
9
8
|
import { computeHashIntegerArray } from "../../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
9
|
+
import { isArrayEqual } from "../../../../../../../core/collection/array/isArrayEqual.js";
|
|
10
10
|
|
|
11
11
|
export class AnimationGraphDefinition {
|
|
12
12
|
constructor() {
|
|
@@ -13,16 +13,7 @@ import Vector3 from "../../../../core/geom/Vector3.js";
|
|
|
13
13
|
import { frustum_from_camera } from "./frustum_from_camera.js";
|
|
14
14
|
import { invertQuaternionOrientation } from "./InvertQuaternionOrientation.js";
|
|
15
15
|
import { v3_distance_above_plane } from "../../../../core/geom/v3_distance_above_plane.js";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @enum {String}
|
|
20
|
-
* @readonly
|
|
21
|
-
*/
|
|
22
|
-
export const ProjectionType = {
|
|
23
|
-
Perspective: "perspective",
|
|
24
|
-
Orthographic: "orthographic"
|
|
25
|
-
};
|
|
16
|
+
import { ProjectionType } from "./ProjectionType.js";
|
|
26
17
|
|
|
27
18
|
/**
|
|
28
19
|
* @class
|
|
@@ -142,12 +142,13 @@ export class CameraSystem extends System {
|
|
|
142
142
|
const position = transform.position;
|
|
143
143
|
const rotation = transform.rotation;
|
|
144
144
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
const signalBindings = [
|
|
146
|
+
new SignalBinding(position.onChanged, synchronizePosition),
|
|
147
|
+
new SignalBinding(rotation.onChanged, synchronizeRotation),
|
|
148
|
+
new SignalBinding(camera.projectionType.onChanged, rebuild),
|
|
149
|
+
new SignalBinding(camera.active.onChanged, synchronizeActiveState),
|
|
150
|
+
new SignalBinding(camera.fov.onChanged, rebuild)
|
|
151
|
+
];
|
|
151
152
|
|
|
152
153
|
signalBindings.forEach(b => b.link());
|
|
153
154
|
|
|
@@ -158,7 +159,6 @@ export class CameraSystem extends System {
|
|
|
158
159
|
synchronizeRotation(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
159
160
|
synchronizeActiveState(camera.active.getValue());
|
|
160
161
|
|
|
161
|
-
|
|
162
162
|
assert.notEqual(camera.object, null, 'Camera object must not be null (invariant)');
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -212,7 +212,7 @@ export class CameraSystem extends System {
|
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
if(c.object.updateProjectionMatrix !== undefined) {
|
|
215
|
+
if (c.object.updateProjectionMatrix !== undefined) {
|
|
216
216
|
c.object.updateProjectionMatrix();
|
|
217
217
|
c.object.updateMatrix();
|
|
218
218
|
c.object.updateMatrixWorld(true);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Camera } from "./Camera.js";
|
|
2
1
|
import { OrthographicCamera as ThreeOrthographicCamera, PerspectiveCamera as ThreePerspectiveCamera } from "three";
|
|
2
|
+
import { ProjectionType } from "./ProjectionType.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -13,10 +13,10 @@ export function build_three_camera_object(component) {
|
|
|
13
13
|
default:
|
|
14
14
|
console.error(`Unsupported camera projection type "${component.projectionType.getValue()}", defaulting to perspective projection`);
|
|
15
15
|
//fallthrough
|
|
16
|
-
case
|
|
16
|
+
case ProjectionType.Perspective:
|
|
17
17
|
result = new ThreePerspectiveCamera(component.fov.getValue(), 1, 1, 50);
|
|
18
18
|
break;
|
|
19
|
-
case
|
|
19
|
+
case ProjectionType.Orthographic:
|
|
20
20
|
result = new ThreeOrthographicCamera(-10, 10, 20, -20, 1, 1);
|
|
21
21
|
break;
|
|
22
22
|
}
|