@woosh/meep-engine 2.33.61 → 2.33.65
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/FilePath.js +28 -2
- package/core/binary/BinaryBuffer.js +13 -0
- package/ecs/grid/pick.js +44 -0
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +1 -1
- package/editor/process/ObstacleGridDisplayProcess.js +1 -1
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
- package/editor/tools/FoliagePaintTool.js +1 -1
- package/editor/tools/GridPaintTool.js +2 -2
- package/editor/tools/paint/TerrainPaintTool.js +2 -2
- package/editor/tools/paint/TerrainTexturePaintTool.js +1 -1
- package/editor/view/EditorView.js +1 -1
- package/editor/view/GridPickCoordinateView.js +2 -2
- package/engine/asset/AssetManager.js +1 -1
- package/engine/asset/AssetTransformer.js +2 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +5 -21
- package/engine/asset/loaders/async_traverse_three_object.js +24 -0
- package/engine/ecs/animation/InverseKinematicsSystem.js +1 -1
- package/engine/ecs/attachment/AttachmentSystem.js +3 -51
- package/engine/ecs/evaluation/world/ReadTerrainLayerWeightPointFitness.js +1 -1
- package/engine/ecs/fow/FogOfWarRevealerSystem.js +2 -2
- package/engine/ecs/team/Team.js +82 -0
- package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
- package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +112 -0
- package/engine/ecs/terrain/util/obtainTerrain.js +23 -0
- package/engine/ecs/tooltip/TooltipComponentSystem.js +1 -1
- package/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +1 -1
- package/engine/graphics/ecs/water/WaterSystem.js +1 -1
- package/engine/graphics/ecs/water2/shader/testWaterShader.js +1 -1
- package/engine/graphics/geometry/AttributeSpec.d.ts +8 -0
- package/engine/graphics/geometry/VertexDataSpec.d.ts +15 -0
- package/engine/graphics/geometry/buffered/deinterleaveBufferAttribute.js +39 -0
- package/engine/graphics/geometry/buffered/deinterleaveBufferGeometry.js +50 -0
- package/engine/graphics/micron/MICRON_GEOMETRY_FIELD.js +1 -0
- package/engine/graphics/micron/MICRON_URI_FIELD.js +1 -0
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +10 -7
- package/engine/graphics/micron/convert_three_object_to_micron.js +17 -2
- package/engine/graphics/micron/format/MicronGeometry.d.ts +4 -0
- package/engine/graphics/micron/format/MicronGeometry.js +6 -0
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +107 -6
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +5 -3
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -2
- package/engine/graphics/render/webgpu/sample/MeshInstance.js +108 -0
- package/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +7 -3
- package/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +4 -3
- package/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +13 -6
- package/engine/graphics/render/webgpu/sample/main.js +83 -45
- package/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +5 -3
- package/engine/graphics/util/modelHitTest.js +63 -0
- package/engine/grid/systems/GridPosition2TransformSystem.js +1 -1
- package/engine/grid/systems/ViewportGridProjectionSystem.js +1 -1
- package/engine/grid/transform2grid/Transform2GridPositionSystem.js +1 -1
- package/engine/scene/transitionToScene.js +1 -1
- package/generation/grid/actions/ContinuousGridCellActionSetTerrainHeight.js +1 -1
- package/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.js +1 -1
- package/generation/markers/debug/visualizeMarkers.js +1 -1
- package/generation/theme/ThemeEngine.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/main.js +1 -1
- package/view/minimap/Minimap.js +1 -1
- package/engine/graphics/render/webgpu/sample/_main.ts +0 -650
package/core/FilePath.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const PATH_SEPARATOR = '/';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Strips all directories from the path.
|
|
3
5
|
* @example 'a/b/c' -> 'c'
|
|
@@ -9,7 +11,7 @@ function computePathBase(path) {
|
|
|
9
11
|
throw new Error('path is not a string');
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
const lastSlashIndex = path.lastIndexOf(
|
|
14
|
+
const lastSlashIndex = path.lastIndexOf(PATH_SEPARATOR);
|
|
13
15
|
|
|
14
16
|
if (lastSlashIndex !== -1) {
|
|
15
17
|
return path.substring(lastSlashIndex + 1);
|
|
@@ -18,6 +20,30 @@ function computePathBase(path) {
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Returns the directory name of a path, similar to the Unix dirname command.
|
|
25
|
+
* @param {string} path
|
|
26
|
+
* @return {string}
|
|
27
|
+
*/
|
|
28
|
+
export function computePathDirectory(path) {
|
|
29
|
+
if (typeof path !== "string") {
|
|
30
|
+
throw new Error('path is not a string');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let lastSlashIndex = path.lastIndexOf(PATH_SEPARATOR);
|
|
34
|
+
|
|
35
|
+
//rewind in case of trailing slashes
|
|
36
|
+
while (lastSlashIndex > 0 && path.charAt(lastSlashIndex - 1) === PATH_SEPARATOR) {
|
|
37
|
+
lastSlashIndex--;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (lastSlashIndex !== -1) {
|
|
41
|
+
return path.substring(0, lastSlashIndex);
|
|
42
|
+
} else {
|
|
43
|
+
return path;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
21
47
|
/**
|
|
22
48
|
*
|
|
23
49
|
* @param {string} path
|
|
@@ -44,4 +70,4 @@ function computeFileExtension(path) {
|
|
|
44
70
|
export {
|
|
45
71
|
computePathBase,
|
|
46
72
|
computeFileExtension
|
|
47
|
-
};
|
|
73
|
+
};
|
|
@@ -57,6 +57,19 @@ BinaryBuffer.prototype.fromArrayBuffer = function (arrayBuffer) {
|
|
|
57
57
|
this.position = 0;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @param {ArrayBuffer} v
|
|
63
|
+
* @return {BinaryBuffer}
|
|
64
|
+
*/
|
|
65
|
+
BinaryBuffer.fromArrayBuffer = function (v) {
|
|
66
|
+
const r = new BinaryBuffer();
|
|
67
|
+
|
|
68
|
+
r.fromArrayBuffer(v);
|
|
69
|
+
|
|
70
|
+
return r;
|
|
71
|
+
};
|
|
72
|
+
|
|
60
73
|
/**
|
|
61
74
|
*
|
|
62
75
|
* @returns {BinaryBuffer}
|
package/ecs/grid/pick.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { assert } from "../../core/assert.js";
|
|
2
|
+
import Vector3 from "../../core/geom/Vector3.js";
|
|
3
|
+
import { SurfacePoint3 } from "../../core/geom/3d/SurfacePoint3.js";
|
|
4
|
+
import Vector2 from "../../core/geom/Vector2.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {number} x
|
|
9
|
+
* @param {number} y
|
|
10
|
+
* @param {GraphicsEngine} graphicsEngine
|
|
11
|
+
* @param {Terrain} terrain
|
|
12
|
+
* @param {function(gridPosition:Vector2,worldPosition:Vector3,normal:Vector3)} callback
|
|
13
|
+
*/
|
|
14
|
+
export function pick(x, y, graphicsEngine, terrain, callback) {
|
|
15
|
+
|
|
16
|
+
assert.isNumber(x, 'x');
|
|
17
|
+
assert.isNumber(y, 'y');
|
|
18
|
+
|
|
19
|
+
assert.defined(terrain, 'terrain');
|
|
20
|
+
assert.notNull(terrain, 'terrain');
|
|
21
|
+
|
|
22
|
+
assert.isFunction(callback, 'callback');
|
|
23
|
+
|
|
24
|
+
const vSource = new Vector3(x, y, 0);
|
|
25
|
+
const vTarget = new Vector3();
|
|
26
|
+
|
|
27
|
+
graphicsEngine.normalizeViewportPoint(vSource, vSource);
|
|
28
|
+
graphicsEngine.viewportProjectionRay(vSource.x, vSource.y, vSource, vTarget);
|
|
29
|
+
|
|
30
|
+
const surfacePoint3 = new SurfacePoint3();
|
|
31
|
+
|
|
32
|
+
const hitFound = terrain.raycastFirstSync(surfacePoint3, vSource.x, vSource.y, vSource.z, vTarget.x, vTarget.y, vTarget.z);
|
|
33
|
+
|
|
34
|
+
if (!hitFound) {
|
|
35
|
+
// nothing found
|
|
36
|
+
} else {
|
|
37
|
+
|
|
38
|
+
const gridPosition = new Vector2();
|
|
39
|
+
terrain.mapPointWorld2Grid(surfacePoint3.position, gridPosition);
|
|
40
|
+
gridPosition._add(0.5, 0.5);
|
|
41
|
+
callback(gridPosition, surfacePoint3.position, surfacePoint3.normal);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
2
1
|
import Vector4 from "../../../core/geom/Vector4.js";
|
|
3
2
|
import { Action } from "../../../core/process/undo/Action.js";
|
|
3
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
4
4
|
|
|
5
5
|
class PaintTerrainOverlayAction extends Action {
|
|
6
6
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EditorProcess } from "./EditorProcess.js";
|
|
2
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
3
2
|
import GridObstacle from "../../engine/grid/components/GridObstacle.js";
|
|
4
3
|
import GridPosition from "../../engine/grid/components/GridPosition.js";
|
|
5
4
|
import { Sampler2D } from "../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
5
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
6
6
|
|
|
7
7
|
class ObstacleGridDisplayProcess extends EditorProcess {
|
|
8
8
|
|
|
@@ -4,7 +4,6 @@ import Task from "../../../core/process/task/Task.js";
|
|
|
4
4
|
import TaskSignal from "../../../core/process/task/TaskSignal.js";
|
|
5
5
|
import EntityBuilder from "../../../engine/ecs/EntityBuilder.js";
|
|
6
6
|
import { BufferGeometry, Float32BufferAttribute, Line, LineBasicMaterial } from "three";
|
|
7
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
8
7
|
import Renderable from "../../../engine/ecs/components/Renderable.js";
|
|
9
8
|
import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
|
|
10
9
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
@@ -14,6 +13,7 @@ import { EventType } from "../../../engine/ecs/EntityManager.js";
|
|
|
14
13
|
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
15
14
|
import GridPosition from "../../../engine/grid/components/GridPosition.js";
|
|
16
15
|
import { ProcessState } from "../../../core/process/ProcessState.js";
|
|
16
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Tool from "./engine/Tool.js";
|
|
2
2
|
import Vector1 from "../../core/geom/Vector1.js";
|
|
3
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
4
3
|
import ObservedValue from "../../core/model/ObservedValue.js";
|
|
5
4
|
import Vector4 from "../../core/geom/Vector4.js";
|
|
6
5
|
import loadSampler2D from "../../engine/graphics/texture/sampler/loadSampler2D.js";
|
|
7
6
|
import convertSampler2D2Canvas from "../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
8
7
|
import { InstancedMeshComponent } from "../../engine/ecs/foliage/ecs/InstancedMeshComponent.js";
|
|
9
8
|
import { parseHex } from "../../core/color/parseHex.js";
|
|
9
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
10
10
|
|
|
11
11
|
class FoliagePaintTool extends Tool {
|
|
12
12
|
constructor() {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import Tool from "./engine/Tool.js";
|
|
2
2
|
import GridPosition from "../../engine/grid/components/GridPosition.js";
|
|
3
3
|
import GridObstacle from "../../engine/grid/components/GridObstacle.js";
|
|
4
|
-
import { pick } from "../../../model/game/util/ScreenGridPicker.js";
|
|
5
4
|
import Vector4 from "../../core/geom/Vector4.js";
|
|
6
5
|
import ObservedValue from "../../core/model/ObservedValue.js";
|
|
7
6
|
import Vector1 from "../../core/geom/Vector1.js";
|
|
8
7
|
import WriteGridValueAction from "../actions/concrete/WriteGridValueAction.js";
|
|
9
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
10
8
|
import PaintTerrainOverlayAction from "../actions/concrete/PaintTerrainOverlayAction.js";
|
|
11
9
|
import { decodeMouseEventButtons, PointerDevice } from "../../engine/input/devices/PointerDevice.js";
|
|
12
10
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
13
11
|
import TopDownCameraControllerSystem from "../../engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
14
12
|
import { parseHex } from "../../core/color/parseHex.js";
|
|
13
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
14
|
+
import { pick } from "../../ecs/grid/pick.js";
|
|
15
15
|
|
|
16
16
|
class GridPaintTool extends Tool {
|
|
17
17
|
constructor() {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { max2 } from "../../../core/math/max2.js";
|
|
2
2
|
import Tool from "../engine/Tool.js";
|
|
3
3
|
import { Color } from "../../../core/color/Color.js";
|
|
4
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
5
4
|
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
6
5
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
7
|
-
import { pick } from "../../../../model/game/util/ScreenGridPicker.js";
|
|
8
6
|
import convertSampler2D2Canvas from "../../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
9
7
|
import ObservedString from "../../../core/model/ObservedString.js";
|
|
10
8
|
import { GameAssetType } from "../../../engine/asset/GameAssetType.js";
|
|
11
9
|
import Vector1 from "../../../core/geom/Vector1.js";
|
|
10
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
11
|
+
import { pick } from "../../../ecs/grid/pick.js";
|
|
12
12
|
|
|
13
13
|
export class TerrainPaintTool extends Tool {
|
|
14
14
|
constructor() {
|
|
@@ -4,7 +4,7 @@ import { TerrainPaintTool } from "./TerrainPaintTool.js";
|
|
|
4
4
|
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
5
5
|
import { PatchTerrainTextureAction } from "../../actions/concrete/PatchTerrainTextureAction.js";
|
|
6
6
|
import { convertSampler2D2DataURL } from "../../../engine/graphics/texture/sampler/convertSampler2D2DataURL.js";
|
|
7
|
-
import { obtainTerrain } from "
|
|
7
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
8
8
|
|
|
9
9
|
export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
10
10
|
constructor() {
|
|
@@ -22,7 +22,6 @@ import MeshLibraryView from "./library/MeshLibraryView.js";
|
|
|
22
22
|
import BottomLeftResizeHandleView from "../../view/elements/BottomLeftResizeHandleView.js";
|
|
23
23
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
24
24
|
import Vector3 from "../../core/geom/Vector3.js";
|
|
25
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
26
25
|
import Mesh from "../../engine/graphics/ecs/mesh/Mesh.js";
|
|
27
26
|
import { Transform } from "../../engine/ecs/transform/Transform.js";
|
|
28
27
|
import SelectionClearAction from "../actions/concrete/SelectionClearAction.js";
|
|
@@ -32,6 +31,7 @@ import SelectionAddAction from "../actions/concrete/SelectionAddAction.js";
|
|
|
32
31
|
import { noop, passThrough } from "../../core/function/Functions.js";
|
|
33
32
|
import { ProcessState } from "../../core/process/ProcessState.js";
|
|
34
33
|
import { MeshEvents } from "../../engine/graphics/ecs/mesh/MeshEvents.js";
|
|
34
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
35
35
|
|
|
36
36
|
class ViewManager extends View {
|
|
37
37
|
constructor() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import View from "../../view/View.js";
|
|
2
|
-
import { pick } from "../../../model/game/util/ScreenGridPicker.js";
|
|
3
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
4
2
|
import domify from "../../view/DOM.js";
|
|
5
3
|
import { PointerDevice } from "../../engine/input/devices/PointerDevice.js";
|
|
4
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
5
|
+
import { pick } from "../../ecs/grid/pick.js";
|
|
6
6
|
|
|
7
7
|
class GridPickCoordinateView extends View {
|
|
8
8
|
/**
|
|
@@ -231,7 +231,7 @@ AssetManager.prototype.submitRequest = function (path, type, request) {
|
|
|
231
231
|
for (let i = 0; i < transformer_count; i++) {
|
|
232
232
|
const transformer = transformers[i];
|
|
233
233
|
|
|
234
|
-
const transformed_asset = await transformer.transform(asset);
|
|
234
|
+
const transformed_asset = await transformer.transform(asset, assetDescription);
|
|
235
235
|
|
|
236
236
|
if (typeof transformed_asset !== "object") {
|
|
237
237
|
console.error('Transformer produced invalid result. Ignoring result.', transformer, assetDescription);
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
export class AssetTransformer {
|
|
8
8
|
/**
|
|
9
9
|
* @param {A} source
|
|
10
|
+
* @param {AssetDescription} asset_description
|
|
10
11
|
* @returns {A}
|
|
11
12
|
*/
|
|
12
|
-
async transform(source) {
|
|
13
|
+
async transform(source, asset_description) {
|
|
13
14
|
throw new Error('Not Implemented');
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -25,6 +25,8 @@ import { computeGeometryEquality } from "./geometry/geometry/computeGeometryEqua
|
|
|
25
25
|
import { traverseThreeObject } from "../../graphics/ecs/highlight/renderer/traverseThreeObject.js";
|
|
26
26
|
import { computeTextureHash } from "./material/computeTextureHash.js";
|
|
27
27
|
import { computeTextureEquality } from "./material/computeTextureEquality.js";
|
|
28
|
+
import { async_traverse_three_object } from "./async_traverse_three_object.js";
|
|
29
|
+
import { deinterleaveBufferGeometry } from "../../graphics/geometry/buffered/deinterleaveBufferGeometry.js";
|
|
28
30
|
|
|
29
31
|
const animationOptimizer = new AnimationOptimizer();
|
|
30
32
|
const materialCache = StaticMaterialCache.Global;
|
|
@@ -130,26 +132,6 @@ function buildDracoDecoderPath() {
|
|
|
130
132
|
return `${pathname}/libs/draco/`;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
* @param {THREE.Object3D} object
|
|
136
|
-
* @param {function} callback
|
|
137
|
-
* @param {*} [thisArg]
|
|
138
|
-
*/
|
|
139
|
-
async function async_traverse(object, callback, thisArg) {
|
|
140
|
-
await callback.call(thisArg, object);
|
|
141
|
-
|
|
142
|
-
const children = object.children;
|
|
143
|
-
const n = children.length;
|
|
144
|
-
|
|
145
|
-
for (let i = 0; i < n; i++) {
|
|
146
|
-
const child = children[i];
|
|
147
|
-
|
|
148
|
-
// TODO we can parallelize this if necessary
|
|
149
|
-
await async_traverse(child, callback, thisArg);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
135
|
export class GLTFAssetLoader extends AssetLoader {
|
|
154
136
|
|
|
155
137
|
constructor() {
|
|
@@ -312,6 +294,8 @@ export class GLTFAssetLoader extends AssetLoader {
|
|
|
312
294
|
mesh.geometry = geometry;
|
|
313
295
|
}
|
|
314
296
|
|
|
297
|
+
mesh.geometry = deinterleaveBufferGeometry(geometry);
|
|
298
|
+
|
|
315
299
|
|
|
316
300
|
if (this.__enable_texture_cache) {
|
|
317
301
|
// replace textures from cache
|
|
@@ -387,7 +371,7 @@ export class GLTFAssetLoader extends AssetLoader {
|
|
|
387
371
|
}
|
|
388
372
|
|
|
389
373
|
|
|
390
|
-
await
|
|
374
|
+
await async_traverse_three_object(root, process_object);
|
|
391
375
|
|
|
392
376
|
|
|
393
377
|
// compute object bounding sphere
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {THREE.Object3D} object
|
|
4
|
+
* @param {function} callback
|
|
5
|
+
* @param {*} [thisArg]
|
|
6
|
+
* @param {*} [ctx]
|
|
7
|
+
*/
|
|
8
|
+
export async function async_traverse_three_object(object, callback, thisArg, ctx) {
|
|
9
|
+
await callback.call(thisArg, object, ctx);
|
|
10
|
+
|
|
11
|
+
const children = object.children;
|
|
12
|
+
const n = children.length;
|
|
13
|
+
|
|
14
|
+
const child_promises = [];
|
|
15
|
+
|
|
16
|
+
for (let i = 0; i < n; i++) {
|
|
17
|
+
const child = children[i];
|
|
18
|
+
|
|
19
|
+
child_promises.push(async_traverse_three_object(child, callback, thisArg, ctx));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// wait for all children at the same time
|
|
23
|
+
await Promise.all(child_promises);
|
|
24
|
+
}
|
|
@@ -3,9 +3,9 @@ import { InverseKinematics } from "./InverseKinematics.js";
|
|
|
3
3
|
import Mesh, { MeshFlags } from "../../graphics/ecs/mesh/Mesh.js";
|
|
4
4
|
import { TwoBoneInverseKinematicsSolver } from "./TwoBoneInverseKinematicsSolver.js";
|
|
5
5
|
import { extractSkeletonFromMeshComponent } from "../../graphics/ecs/mesh/SkeletonUtils.js";
|
|
6
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
7
6
|
import { OneBoneSurfaceAlignmentSolver } from "./OneBoneSurfaceAlignmentSolver.js";
|
|
8
7
|
import { IKProblem } from "./IKProblem.js";
|
|
8
|
+
import { obtainTerrain } from "../terrain/util/obtainTerrain.js";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
export class InverseKinematicsSystem extends System {
|
|
@@ -7,38 +7,6 @@ import Mesh from "../../graphics/ecs/mesh/Mesh.js";
|
|
|
7
7
|
import { BoneAttachmentBinding } from "./BoneAttachmentBinding.js";
|
|
8
8
|
import { TransformAttachmentBinding } from "./TransformAttachmentBinding.js";
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* @readonly
|
|
12
|
-
* @enum {number}
|
|
13
|
-
*/
|
|
14
|
-
const WaitingType = {
|
|
15
|
-
Entity: 0,
|
|
16
|
-
Socket: 1,
|
|
17
|
-
Mesh: 2,
|
|
18
|
-
Transform: 3
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
class WaitingEntry {
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {number} entity
|
|
25
|
-
* @param {WaitingType} type
|
|
26
|
-
*/
|
|
27
|
-
constructor(entity, type) {
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @type {number}
|
|
31
|
-
*/
|
|
32
|
-
this.entity = entity;
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @type {WaitingType}
|
|
36
|
-
*/
|
|
37
|
-
this.type = type;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
10
|
export class AttachmentSystem extends System {
|
|
43
11
|
constructor() {
|
|
44
12
|
super();
|
|
@@ -315,17 +283,10 @@ export class AttachmentSystem extends System {
|
|
|
315
283
|
}
|
|
316
284
|
}
|
|
317
285
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
* @param {number} entity
|
|
321
|
-
* @private
|
|
322
|
-
*/
|
|
323
|
-
__update_entity(entity) {
|
|
324
|
-
const bindings = this.parentBindingIndex.get(entity);
|
|
286
|
+
__updateAll() {
|
|
287
|
+
for (const [entity, bindings] of this.parentBindingIndex) {
|
|
325
288
|
|
|
326
|
-
if (bindings !== undefined) {
|
|
327
289
|
const n = bindings.length;
|
|
328
|
-
|
|
329
290
|
for (let i = 0; i < n; i++) {
|
|
330
291
|
const binding = bindings[i];
|
|
331
292
|
|
|
@@ -334,15 +295,6 @@ export class AttachmentSystem extends System {
|
|
|
334
295
|
}
|
|
335
296
|
}
|
|
336
297
|
|
|
337
|
-
/**
|
|
338
|
-
*
|
|
339
|
-
* @param {Mesh} mesh
|
|
340
|
-
* @param {number} entity
|
|
341
|
-
*/
|
|
342
|
-
visitComponent(mesh, entity) {
|
|
343
|
-
this.__update_entity(entity);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
298
|
update(timeDelta) {
|
|
347
299
|
//process wait queue
|
|
348
300
|
this.processWaiting();
|
|
@@ -355,6 +307,6 @@ export class AttachmentSystem extends System {
|
|
|
355
307
|
return;
|
|
356
308
|
}
|
|
357
309
|
|
|
358
|
-
|
|
310
|
+
this.__updateAll();
|
|
359
311
|
}
|
|
360
312
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PointFitnessFunction } from "../PointFitnessFunction.js";
|
|
2
|
-
import { obtainTerrain } from "../../../../../model/game/scenes/SceneUtils.js";
|
|
3
2
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
4
3
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
5
4
|
import { assert } from "../../../../core/assert.js";
|
|
5
|
+
import { obtainTerrain } from "../../terrain/util/obtainTerrain.js";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
const v3 = new Vector3();
|
|
@@ -2,10 +2,10 @@ import { System } from "../System.js";
|
|
|
2
2
|
import { FogOfWarRevealer } from "./FogOfWarRevealer.js";
|
|
3
3
|
import { SignalBinding } from "../../../core/events/signal/SignalBinding.js";
|
|
4
4
|
import { FogOfWar } from "./FogOfWar.js";
|
|
5
|
-
import Team from "
|
|
5
|
+
import Team from "../team/Team.js";
|
|
6
6
|
import { Transform } from "../transform/Transform.js";
|
|
7
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
8
7
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
8
|
+
import { obtainTerrain } from "../terrain/util/obtainTerrain.js";
|
|
9
9
|
|
|
10
10
|
const v2 = new Vector2();
|
|
11
11
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Alex on 13/04/2016.
|
|
3
|
+
*/
|
|
4
|
+
import ObservedInteger from "../../../core/model/ObservedInteger.js";
|
|
5
|
+
import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
|
|
6
|
+
|
|
7
|
+
class Team extends ObservedInteger {
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param value
|
|
11
|
+
* @constructor
|
|
12
|
+
*/
|
|
13
|
+
constructor(value = 0) {
|
|
14
|
+
super(value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
clone() {
|
|
18
|
+
return new Team(this.getValue());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {object} json
|
|
24
|
+
* @returns {Team}
|
|
25
|
+
*/
|
|
26
|
+
static fromJSON(json) {
|
|
27
|
+
const t = new Team();
|
|
28
|
+
|
|
29
|
+
t.fromJSON(json);
|
|
30
|
+
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Team.typeName = "Team";
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export default Team;
|
|
39
|
+
|
|
40
|
+
export class TeamSerializationAdapter extends BinaryClassSerializationAdapter{
|
|
41
|
+
constructor(){
|
|
42
|
+
super();
|
|
43
|
+
|
|
44
|
+
this.klass = Team;
|
|
45
|
+
this.version = 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param {BinaryBuffer} buffer
|
|
51
|
+
* @param {Team} value
|
|
52
|
+
*/
|
|
53
|
+
serialize(buffer, value) {
|
|
54
|
+
const v = value.getValue();
|
|
55
|
+
|
|
56
|
+
if (v === Infinity) {
|
|
57
|
+
buffer.writeInt32(2147483647);
|
|
58
|
+
} else if (v === -Infinity) {
|
|
59
|
+
buffer.writeInt32(-2147483648);
|
|
60
|
+
} else {
|
|
61
|
+
//TODO it's possible to write encoded Infinity values by accident
|
|
62
|
+
buffer.writeInt32(v);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param {BinaryBuffer} buffer
|
|
69
|
+
* @param {Team} value
|
|
70
|
+
*/
|
|
71
|
+
deserialize(buffer, value) {
|
|
72
|
+
const v = buffer.readInt32();
|
|
73
|
+
|
|
74
|
+
if (v === 2147483647) {
|
|
75
|
+
value.set(Infinity);
|
|
76
|
+
} else if (v === -2147483648) {
|
|
77
|
+
value.set(-Infinity);
|
|
78
|
+
} else {
|
|
79
|
+
value.set(v);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -9,13 +9,13 @@ import { Transform } from '../../transform/Transform.js';
|
|
|
9
9
|
import ClingToTerrain from './ClingToTerrain.js';
|
|
10
10
|
|
|
11
11
|
import Vector3 from '../../../../core/geom/Vector3.js';
|
|
12
|
-
import { obtainTerrain } from "../../../../../model/game/scenes/SceneUtils.js";
|
|
13
12
|
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
14
|
-
import { EPSILON} from "../../../../core/math/MathUtils.js";
|
|
13
|
+
import { EPSILON } from "../../../../core/math/MathUtils.js";
|
|
15
14
|
import { Matrix4 } from "three";
|
|
16
15
|
import { assert } from "../../../../core/assert.js";
|
|
17
16
|
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
18
17
|
import { Deque } from "../../../../core/collection/queue/Deque.js";
|
|
18
|
+
import { obtainTerrain } from "../util/obtainTerrain.js";
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
/**
|