@woosh/meep-engine 2.51.0 → 2.53.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/editor/actions/concrete/WriteGridValueAction.js +1 -1
- package/editor/ecs/component/prototypeObjectEditor.js +1 -1
- package/editor/process/ObstacleGridDisplayProcess.js +2 -2
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
- package/editor/tools/GridPaintTool.js +2 -2
- package/package.json +4 -3
- package/samples/generation/SampleGenerator0.js +1 -1
- package/samples/generation/generators/interactive/mir_generator_place_buff_objects.js +1 -1
- package/samples/generation/generators/mir_generator_place_bases.js +1 -1
- package/samples/generation/generators/mir_generator_place_road_decorators.js +1 -1
- package/samples/generation/generators/mir_generator_place_starting_point.js +1 -1
- package/samples/generation/main.js +2 -2
- package/samples/generation/rules/matcher_play_area.js +1 -1
- package/samples/generation/rules/matcher_tag_occupied.js +1 -1
- package/samples/generation/rules/matcher_tag_traversable.js +1 -1
- package/samples/generation/themes/SampleTheme0.js +5 -5
- package/src/core/NumberFormat.js +0 -71
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -0
- package/src/core/bvh2/bvh3/query/BVHQueryAny.js +16 -0
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +5 -5
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -3
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +22 -0
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +64 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +2 -3
- package/src/core/collection/table/RowFirstTableSpec.js +8 -4
- package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +41 -0
- package/src/core/geom/3d/matrix/MATRIX_4_IDENTITY.spec.js +10 -0
- package/src/core/geom/3d/topology/struct/TopoMesh.js +3 -2
- package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +4 -4
- package/src/core/geom/Vector2.d.ts +9 -0
- package/src/core/geom/Vector2.js +8 -22
- package/src/core/geom/Vector2.spec.js +153 -0
- package/src/core/model/ModuleRegistry.js +2 -4
- package/src/core/model/ModuleRegistry.spec.js +31 -0
- package/src/core/model/reactive/js/compileReactiveToJS.spec.js +14 -0
- package/src/core/model/reactive/model/logic/ReactiveAnd.spec.js +31 -1
- package/src/core/model/reactive/model/logic/ReactiveOr.spec.js +53 -0
- package/src/core/model/stat/LinearModifier.js +2 -2
- package/src/core/model/stat/LinearModifier.spec.js +62 -0
- package/src/core/model/stat/Stat.js +12 -0
- package/src/core/model/stat/Stat.spec.js +36 -0
- package/src/core/primitives/array/computeStridedIntegerArrayHash.spec.js +28 -0
- package/src/core/primitives/numbers/number_format_by_thousands.js +14 -0
- package/src/core/primitives/numbers/number_pretty_print.js +49 -0
- package/src/core/primitives/strings/computeStringHash.spec.js +12 -5
- package/src/core/process/BaseProcess.js +8 -8
- package/src/engine/Clock.js +30 -29
- package/src/engine/Clock.spec.js +26 -0
- package/src/engine/Engine.spec.js +4 -0
- package/src/engine/ecs/EntityBuilder.js +3 -1
- package/src/engine/ecs/EntityBuilder.spec.js +21 -0
- package/src/engine/ecs/EntityComponentDataset.js +1 -1
- package/src/engine/ecs/EntityObserver.spec.js +1 -1
- package/src/engine/ecs/dynamic_actions/actions/definition/{WhiteToBlackboardActionDescription.js → WriteToBlackboardActionDescription.js} +2 -2
- package/src/engine/ecs/dynamic_actions/actions/definition/deserializeActionFromJSON.js +2 -2
- package/src/engine/ecs/gui/GUIElement.js +1 -1
- package/src/engine/ecs/gui/position/ViewportPosition.js +3 -3
- package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.js +21 -0
- package/src/engine/ecs/parent/EntityNode.js +1 -1
- package/src/engine/ecs/parent/EntityNode.spec.js +104 -0
- package/src/engine/ecs/speaker/Voice.js +4 -0
- package/src/engine/ecs/team/Team.js +0 -44
- package/src/engine/ecs/team/TeamSerializationAdapter.js +46 -0
- package/src/engine/ecs/terrain/ecs/TerrainClassifier.js +1 -1
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +1 -1
- package/src/engine/ecs/transform/Transform.js +2 -1
- package/src/engine/ecs/transform/Transform.spec.js +24 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +2 -6
- package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraph.spec.js +5 -0
- package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +24 -25
- package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.spec.js +5 -0
- package/src/engine/graphics/ecs/decal/DecalSystem.js +2 -20
- package/src/engine/graphics/ecs/decal/v2/Decal.js +32 -32
- package/src/engine/graphics/ecs/decal/v2/Decal.spec.js +5 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +4 -2
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +4 -33
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +8 -4
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.spec.js +5 -0
- package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +0 -12
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +2 -6
- package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +2 -4
- package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +0 -2
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -6
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -6
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +4 -8
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
- package/src/engine/graphics/shadows/testShadowMapRendering.js +0 -2
- package/src/engine/graphics/texture/TextureBackedMemoryRegion.js +4 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
- package/src/engine/graphics/texture/sampler/filter/filter_lanczos3.js +7 -2
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +3 -23
- package/src/engine/grid/grid2transform/GridPosition2Transform.js +122 -0
- package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.js +70 -0
- package/src/engine/grid/grid2transform/GridPosition2TransformSerializationUpgrader_0_1.js +40 -0
- package/src/engine/grid/{systems → grid2transform}/GridPosition2TransformSystem.js +3 -3
- package/src/engine/grid/{components → obstacle}/GridObstacle.js +45 -25
- package/src/engine/grid/obstacle/GridObstacle.spec.js +175 -0
- package/src/engine/grid/{components → position}/GridPosition.js +6 -14
- package/src/engine/grid/{systems → position}/GridPositionSystem.js +1 -1
- package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +1 -1
- package/src/engine/input/devices/PointerDevice.spec.js +5 -0
- package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +5 -1
- package/src/engine/navigation/ecs/path_following/PathFollower.js +40 -32
- package/src/engine/navigation/ecs/path_following/PathFollower.spec.js +27 -0
- package/src/engine/plugin/EnginePlugin.js +12 -14
- package/src/engine/plugin/EnginePlugin.spec.js +5 -0
- package/src/engine/plugin/EnginePluginManager.js +18 -22
- package/src/engine/scene/transitionToScene.js +12 -1
- package/src/engine/simulation/Ticker.js +1 -1
- package/src/generation/filtering/CellFilter.js +6 -9
- package/src/generation/filtering/boolean/CellFilterLiteralBoolean.js +1 -4
- package/src/generation/filtering/core/CellFilterBinaryOperation.js +12 -15
- package/src/generation/filtering/core/CellFilterOperationTertiary.js +15 -19
- package/src/generation/filtering/numeric/CellFilterLiteralFloat.js +6 -9
- package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainObstacle.js +1 -1
- package/src/generation/grid/actions/ContinuousGridCellActionWriteObstacle.js +2 -2
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
- package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +1 -1
- package/src/generation/theme/TerrainLayerDescription.js +1 -1
- package/src/view/common/LabelView.js +3 -3
- package/src/engine/ecs/components/AimController.js +0 -18
- package/src/engine/ecs/components/Attacker.js +0 -13
- package/src/engine/ecs/components/MeshCollider.js +0 -15
- package/src/engine/ecs/components/RangedAttack.js +0 -12
- package/src/engine/ecs/components/TargetAI.js +0 -11
- package/src/engine/ecs/components/ViewportMeshProjection.js +0 -18
- package/src/engine/ecs/systems/AimControllerSystem.js +0 -63
- package/src/engine/ecs/systems/AttackerSystem.js +0 -67
- package/src/engine/ecs/systems/MeshColliderSystem.js +0 -47
- package/src/engine/ecs/systems/MonsterAISystem.js +0 -163
- package/src/engine/ecs/systems/MortalitySystem.js +0 -46
- package/src/engine/ecs/systems/RangedAttackSystem.js +0 -132
- package/src/engine/ecs/systems/SerializationMetadataSystem.js +0 -10
- package/src/engine/ecs/systems/TargetAISystem.js +0 -107
- package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +0 -68
- package/src/engine/graphics/particles/ParticleEmitterLibrary.js +0 -87
- package/src/engine/graphics/texture/ExportCanvasAsPNG.js +0 -7
- package/src/engine/grid/components/GridObstacle.spec.js +0 -46
- package/src/engine/grid/components/GridPosition2Transform.js +0 -232
- package/src/engine/grid/components/ViewportGridProjection.js +0 -20
- package/src/engine/grid/systems/GridObstacleSystem.js +0 -58
- package/src/engine/grid/systems/ViewportGridProjectionSystem.js +0 -105
- package/src/engine/navigation/PathFinder.js +0 -172
- package/src/engine/navigation/PathWorker.js +0 -78
- package/src/engine/navigation/ecs/systems/PathFinderSystem.js +0 -63
- package/src/engine/navigation/ecs/systems/PathSystem.js +0 -19
- package/src/engine/navigation/funnel/Funnel.js +0 -196
- package/src/generation/ZoneNode.js +0 -9
- /package/{src/generation → samples/generation/grid}/GridTags.js +0 -0
- /package/src/{engine → core/primitives/array}/computeStridedIntegerArrayHash.js +0 -0
- /package/src/engine/grid/{components → grid2transform}/GridPosition2TransformFlags.js +0 -0
- /package/src/engine/grid/{components → obstacle}/GridObstacleSerializationAdapter.js +0 -0
- /package/src/engine/grid/{components → position}/GridPositionSerializationAdapter.js +0 -0
- /package/src/engine/grid/{components → position}/GridPositionSerializationUpdater_0_1.js +0 -0
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { ParticleEmitter } from "./particular/engine/emitter/ParticleEmitter.js";
|
|
2
|
-
import { GameAssetType } from "../../asset/GameAssetType.js";
|
|
3
|
-
import { assert } from "../../../core/assert.js";
|
|
4
|
-
import { JsonAssetLoader } from "../../asset/loaders/JsonAssetLoader.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use "Effect" API to achieve the same results
|
|
8
|
-
*/
|
|
9
|
-
export class ParticleEmitterLibrary {
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {AssetManager} assetManager
|
|
13
|
-
*/
|
|
14
|
-
constructor(assetManager) {
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @type {AssetManager}
|
|
18
|
-
*/
|
|
19
|
-
this.assetManager = assetManager;
|
|
20
|
-
|
|
21
|
-
this.data = {};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {string} path
|
|
27
|
-
* @returns {Promise<void>}
|
|
28
|
-
*/
|
|
29
|
-
async load_from_registry_file(path) {
|
|
30
|
-
|
|
31
|
-
const am = this.assetManager;
|
|
32
|
-
|
|
33
|
-
if (am.getLoaderByType(GameAssetType.JSON) === undefined) {
|
|
34
|
-
// add missing loader
|
|
35
|
-
await am.registerLoader(GameAssetType.JSON, new JsonAssetLoader());
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const asset = await am.promise(path, GameAssetType.JSON)
|
|
39
|
-
const particleSet = asset.create();
|
|
40
|
-
|
|
41
|
-
await this.load(particleSet);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {Object} listing
|
|
46
|
-
* @returns {Promise}
|
|
47
|
-
*/
|
|
48
|
-
load(listing) {
|
|
49
|
-
const assetManager = this.assetManager;
|
|
50
|
-
const data = this.data;
|
|
51
|
-
|
|
52
|
-
const promises = [];
|
|
53
|
-
|
|
54
|
-
for (let id in listing) {
|
|
55
|
-
const url = listing[id];
|
|
56
|
-
|
|
57
|
-
assert.typeOf(id, "string", "id");
|
|
58
|
-
assert.typeOf(url, "string", "url");
|
|
59
|
-
|
|
60
|
-
const assetPromise = assetManager.promise(url, GameAssetType.JSON);
|
|
61
|
-
|
|
62
|
-
promises.push(assetPromise);
|
|
63
|
-
|
|
64
|
-
assetPromise.then(asset => {
|
|
65
|
-
const json = asset.create();
|
|
66
|
-
|
|
67
|
-
data[id] = json;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return Promise.all(promises);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @param {string} id
|
|
76
|
-
* @returns {ParticleEmitter}
|
|
77
|
-
*/
|
|
78
|
-
create(id) {
|
|
79
|
-
const definition = this.data[id];
|
|
80
|
-
|
|
81
|
-
if (definition === undefined) {
|
|
82
|
-
throw new Error(`No definition found for emitter '${id}'`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return ParticleEmitter.fromJSON(definition);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import GridObstacle from "./GridObstacle.js";
|
|
2
|
-
|
|
3
|
-
test('resize 1x1 to 1x2', () => {
|
|
4
|
-
const g = new GridObstacle();
|
|
5
|
-
|
|
6
|
-
g.size.set(1, 1);
|
|
7
|
-
g.data = [7];
|
|
8
|
-
|
|
9
|
-
g.resize(1, 2);
|
|
10
|
-
|
|
11
|
-
expect(g.data[0]).toBe(7);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('resize 1x1 to 2x1', () => {
|
|
15
|
-
const g = new GridObstacle();
|
|
16
|
-
|
|
17
|
-
g.size.set(1, 1);
|
|
18
|
-
g.data = [7];
|
|
19
|
-
|
|
20
|
-
g.resize(2, 1);
|
|
21
|
-
|
|
22
|
-
expect(g.data[0]).toBe(7);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
test('resize 2x1 to 1x1', () => {
|
|
27
|
-
const g = new GridObstacle();
|
|
28
|
-
|
|
29
|
-
g.size.set(2, 1);
|
|
30
|
-
g.data = [3, 7];
|
|
31
|
-
|
|
32
|
-
g.resize(1, 1);
|
|
33
|
-
|
|
34
|
-
expect(g.data[0]).toBe(3);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('resize 1x2 to 1x1', () => {
|
|
38
|
-
const g = new GridObstacle();
|
|
39
|
-
|
|
40
|
-
g.size.set(1, 2);
|
|
41
|
-
g.data = [3, 7];
|
|
42
|
-
|
|
43
|
-
g.resize(1, 1);
|
|
44
|
-
|
|
45
|
-
expect(g.data[0]).toBe(3);
|
|
46
|
-
});
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import Vector2 from "../../../core/geom/Vector2.js";
|
|
2
|
-
import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
3
|
-
import { BinaryClassUpgrader } from "../../ecs/storage/binary/BinaryClassUpgrader.js";
|
|
4
|
-
import { GridPosition2TransformFlags } from "./GridPosition2TransformFlags.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Created by Alex on 20/01/2015.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const DEFAULT_FLAGS = GridPosition2TransformFlags.Immediate;
|
|
12
|
-
|
|
13
|
-
export class GridPosition2Transform {
|
|
14
|
-
constructor() {
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @type {Vector2}
|
|
18
|
-
*/
|
|
19
|
-
this.offset = new Vector2(0, 0);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @type {GridPosition2TransformFlags|number}
|
|
24
|
-
*/
|
|
25
|
-
this.flags = DEFAULT_FLAGS;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {number|GridPosition2TransformFlags} flag
|
|
31
|
-
* @returns {void}
|
|
32
|
-
*/
|
|
33
|
-
setFlag(flag) {
|
|
34
|
-
this.flags |= flag;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param {number|GridPosition2TransformFlags} flag
|
|
40
|
-
* @returns {void}
|
|
41
|
-
*/
|
|
42
|
-
clearFlag(flag) {
|
|
43
|
-
this.flags &= ~flag;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {number|GridPosition2TransformFlags} flag
|
|
49
|
-
* @param {boolean} value
|
|
50
|
-
*/
|
|
51
|
-
writeFlag(flag, value) {
|
|
52
|
-
if (value) {
|
|
53
|
-
this.setFlag(flag);
|
|
54
|
-
} else {
|
|
55
|
-
this.clearFlag(flag);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @param {number|GridPosition2TransformFlags} flag
|
|
62
|
-
* @returns {boolean}
|
|
63
|
-
*/
|
|
64
|
-
getFlag(flag) {
|
|
65
|
-
return (this.flags & flag) === flag;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
toJSON() {
|
|
69
|
-
return {
|
|
70
|
-
offset: this.offset.toJSON()
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
fromJSON(obj) {
|
|
75
|
-
|
|
76
|
-
if (typeof obj.offset === "object") {
|
|
77
|
-
this.offset.fromJSON(obj.offset);
|
|
78
|
-
} else {
|
|
79
|
-
this.offset.set(0, 0);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
* @param {GridPosition2Transform} other
|
|
87
|
-
*/
|
|
88
|
-
copy(other) {
|
|
89
|
-
this.offset.copy(other.offset);
|
|
90
|
-
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
96
|
-
* @returns {GridPosition2Transform}
|
|
97
|
-
*/
|
|
98
|
-
clone() {
|
|
99
|
-
const clone = new GridPosition2Transform();
|
|
100
|
-
|
|
101
|
-
clone.copy(this);
|
|
102
|
-
|
|
103
|
-
return clone;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
108
|
-
* @param {GridPosition2Transform} other
|
|
109
|
-
* @returns {boolean}
|
|
110
|
-
*/
|
|
111
|
-
equals(other) {
|
|
112
|
-
return this.offset.equals(other.offset);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @returns {number}
|
|
117
|
-
*/
|
|
118
|
-
hash() {
|
|
119
|
-
return this.offset.hashCode();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
GridPosition2Transform.typeName = "GridPosition2Transform";
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
export class GridPosition2TransformSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
128
|
-
constructor() {
|
|
129
|
-
super();
|
|
130
|
-
|
|
131
|
-
this.klass = GridPosition2Transform;
|
|
132
|
-
this.version = 1;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
* @param {BinaryBuffer} buffer
|
|
138
|
-
* @param {GridPosition2Transform} value
|
|
139
|
-
*/
|
|
140
|
-
serialize(buffer, value) {
|
|
141
|
-
const offsetX = value.offset.x;
|
|
142
|
-
const offsetY = value.offset.y;
|
|
143
|
-
|
|
144
|
-
let header = 3;
|
|
145
|
-
if (offsetX === 0 && offsetY === 0) {
|
|
146
|
-
header = 0;
|
|
147
|
-
} else if (offsetX === 0) {
|
|
148
|
-
header = 2;
|
|
149
|
-
} else if (offsetY === 0) {
|
|
150
|
-
header = 1;
|
|
151
|
-
} else {
|
|
152
|
-
//both coordinates are present
|
|
153
|
-
header = 3;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
buffer.writeUint8(header);
|
|
157
|
-
|
|
158
|
-
if ((header & 1) !== 0) {
|
|
159
|
-
//write X
|
|
160
|
-
buffer.writeFloat32(offsetX);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if ((header & 2) !== 0) {
|
|
164
|
-
//write Y
|
|
165
|
-
buffer.writeFloat32(offsetY);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
*
|
|
171
|
-
* @param {BinaryBuffer} buffer
|
|
172
|
-
* @param {GridPosition2Transform} value
|
|
173
|
-
*/
|
|
174
|
-
deserialize(buffer, value) {
|
|
175
|
-
//read header
|
|
176
|
-
const header = buffer.readUint8();
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
let offsetX = 0, offsetY = 0;
|
|
180
|
-
|
|
181
|
-
if ((header & 1) !== 0) {
|
|
182
|
-
//write X
|
|
183
|
-
offsetX = buffer.readFloat32();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if ((header & 2) !== 0) {
|
|
187
|
-
//write Y
|
|
188
|
-
offsetY = buffer.readFloat32();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
value.offset.set(offsetX, offsetY);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export class GridPosition2TransformSerializationUpgrader_0_1 extends BinaryClassUpgrader {
|
|
196
|
-
constructor() {
|
|
197
|
-
super();
|
|
198
|
-
|
|
199
|
-
//
|
|
200
|
-
this.__startVersion = 0;
|
|
201
|
-
this.__targetVersion = 1;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
upgrade(source, target) {
|
|
205
|
-
const offsetX = source.readFloat64();
|
|
206
|
-
const offsetY = source.readFloat64();
|
|
207
|
-
|
|
208
|
-
let header = 3;
|
|
209
|
-
if (offsetX === 0 && offsetY === 0) {
|
|
210
|
-
header = 0;
|
|
211
|
-
} else if (offsetX === 0) {
|
|
212
|
-
header = 2;
|
|
213
|
-
} else if (offsetY === 0) {
|
|
214
|
-
header = 1;
|
|
215
|
-
} else {
|
|
216
|
-
//both coordinates are present
|
|
217
|
-
header = 3;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
target.writeUint8(header);
|
|
221
|
-
|
|
222
|
-
if ((header & 1) !== 0) {
|
|
223
|
-
//write X
|
|
224
|
-
target.writeFloat32(offsetX);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if ((header & 2) !== 0) {
|
|
228
|
-
//write Y
|
|
229
|
-
target.writeFloat32(offsetY);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 28/01/2015.
|
|
3
|
-
*/
|
|
4
|
-
import { Matrix4 as ThreeMatrix4 } from 'three';
|
|
5
|
-
|
|
6
|
-
const emptyHash = {};
|
|
7
|
-
|
|
8
|
-
function ViewportGridProjection(options) {
|
|
9
|
-
if (options === void 0) {
|
|
10
|
-
options = emptyHash;
|
|
11
|
-
}
|
|
12
|
-
this.x = options.x || 0;
|
|
13
|
-
this.y = options.y || 0;
|
|
14
|
-
this.prevX = void 0;
|
|
15
|
-
this.prevY = void 0;
|
|
16
|
-
this.prevProjectionMatrix = new ThreeMatrix4();
|
|
17
|
-
this.snap = options.snap !== void 0 ? options.snap : true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default ViewportGridProjection;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 13/10/2014.
|
|
3
|
-
*/
|
|
4
|
-
import { System } from '../../ecs/System.js';
|
|
5
|
-
import GridPosition from '../components/GridPosition.js';
|
|
6
|
-
import GridObstacle from '../components/GridObstacle.js';
|
|
7
|
-
|
|
8
|
-
class GridObstacleSystem extends System {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
|
|
12
|
-
this.dependencies = [GridObstacle, GridPosition];
|
|
13
|
-
|
|
14
|
-
this.pathsNeedUpdate = false;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
startup(entityManager, success, failure) {
|
|
18
|
-
this.entityManager = entityManager;
|
|
19
|
-
|
|
20
|
-
success();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
recalculatePaths() {
|
|
24
|
-
//todo this should be somewhere else
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {GridObstacle} obstacle
|
|
30
|
-
* @param {GridPosition} p
|
|
31
|
-
* @param {int} entityId
|
|
32
|
-
*/
|
|
33
|
-
link(obstacle, p, entityId) {
|
|
34
|
-
|
|
35
|
-
this.pathsNeedUpdate = true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @param {GridObstacle} obstacle
|
|
41
|
-
* @param {GridPosition} p
|
|
42
|
-
* @param {int} entityId
|
|
43
|
-
*/
|
|
44
|
-
unlink(obstacle, p, entityId) {
|
|
45
|
-
|
|
46
|
-
this.pathsNeedUpdate = true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
update(timeDelta) {
|
|
50
|
-
if (this.pathsNeedUpdate) {
|
|
51
|
-
this.recalculatePaths();
|
|
52
|
-
this.pathsNeedUpdate = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export default GridObstacleSystem;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 28/01/2015.
|
|
3
|
-
*/
|
|
4
|
-
import { System } from '../../ecs/System.js';
|
|
5
|
-
import GeometryBVH from '../../ecs/components/GeometryBVH.js';
|
|
6
|
-
import GridPosition from '../components/GridPosition.js';
|
|
7
|
-
import ViewportGridProjection from '../components/ViewportGridProjection.js';
|
|
8
|
-
import Vector2 from "../../../core/geom/Vector2.js";
|
|
9
|
-
import Vector3 from "../../../core/geom/Vector3.js";
|
|
10
|
-
import { obtainTerrain } from "../../ecs/terrain/util/obtainTerrain.js";
|
|
11
|
-
|
|
12
|
-
class ViewportGridProjectionSystem extends System {
|
|
13
|
-
constructor(grid, graphicsEngine) {
|
|
14
|
-
super();
|
|
15
|
-
|
|
16
|
-
this.dependencies = [ViewportGridProjection];
|
|
17
|
-
|
|
18
|
-
this.graphicsEngine = graphicsEngine;
|
|
19
|
-
this.grid = grid;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
add(component, entity) {
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
remove(component, entity) {
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
update(timeDelta) {
|
|
29
|
-
const grid = this.grid;
|
|
30
|
-
const em = this.entityManager;
|
|
31
|
-
const renderer = this.graphicsEngine;
|
|
32
|
-
//
|
|
33
|
-
let terrain = null;
|
|
34
|
-
let terrainEntity = void 0;
|
|
35
|
-
obtainTerrain(em.dataset, function (t, entity) {
|
|
36
|
-
terrain = t;
|
|
37
|
-
terrainEntity = entity;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (terrain === void 0) {
|
|
41
|
-
//terrain failed to bind, can't project
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
//try to get bvh for terrain
|
|
45
|
-
const geometryBVH = em.getComponent(terrainEntity, GeometryBVH);
|
|
46
|
-
|
|
47
|
-
const terrainMesh = terrain.surfaceMesh;
|
|
48
|
-
if (terrainMesh === void 0) {
|
|
49
|
-
//mesh doesn't exist, can't project
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const v2 = new Vector2();
|
|
53
|
-
em.traverseEntities([ViewportGridProjection, GridPosition], function (p, gridPosition, entity) {
|
|
54
|
-
const worldProjectionMatrix = renderer.camera.projectionMatrix;
|
|
55
|
-
if (p.x === p.prevX && p.y === p.prevY && matricesEqual(worldProjectionMatrix, p.prevProjectionMatrix)) {
|
|
56
|
-
//NOTE: Assumes mesh is static in transform and topology
|
|
57
|
-
//result same as before, do nothing
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
p.prevX = p.x;
|
|
61
|
-
p.prevY = p.y;
|
|
62
|
-
p.prevProjectionMatrix.copy(worldProjectionMatrix);
|
|
63
|
-
v2.set(p.x, p.y);
|
|
64
|
-
renderer.normalizeViewportPoint(v2, v2);
|
|
65
|
-
if (geometryBVH !== null) {
|
|
66
|
-
//see if there's a bvh for this entity
|
|
67
|
-
const source = new Vector3();
|
|
68
|
-
const target = new Vector3();
|
|
69
|
-
renderer.viewportProjectionRay(v2.x, v2.y, source, target);
|
|
70
|
-
geometryBVH.raycast(source, target, function (point) {
|
|
71
|
-
processIntersection(grid, point, p, gridPosition);
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
const hits = renderer.intersectObjectUnderViewportPoint(v2.x, v2.y, terrainMesh, true);
|
|
75
|
-
if (hits !== void 0 && hits.length > 0) {
|
|
76
|
-
//take first hit
|
|
77
|
-
const hit = hits[0];
|
|
78
|
-
const point = hit.point;
|
|
79
|
-
processIntersection(grid, point, p, gridPosition);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
function matricesEqual(m0, m1) {
|
|
88
|
-
for (let i = 0; i < 16; i++) {
|
|
89
|
-
if (m0.elements[i] !== m1.elements[i]) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function processIntersection(grid, point, p, gridPosition) {
|
|
97
|
-
grid.pointWorld2Grid(point, gridPosition);
|
|
98
|
-
if (p.snap) {
|
|
99
|
-
//snap to grid
|
|
100
|
-
gridPosition.x = Math.round(gridPosition.x);
|
|
101
|
-
gridPosition.y = Math.round(gridPosition.y);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export default ViewportGridProjectionSystem;
|