@woosh/meep-engine 2.50.2 → 2.51.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/README.md +4 -1
- package/editor/actions/concrete/WriteGridValueAction.js +13 -18
- package/editor/ecs/component/editors/Sampler2DEditor.js +2 -2
- package/editor/process/SymbolicDisplayProcess.js +1 -1
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +1 -1
- package/editor/process/symbolic/makeCameraSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
- package/editor/process/symbolic/makeLightSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makePathSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +1 -1
- package/editor/view/ecs/components/GridObstacleController.js +2 -2
- package/editor/view/ecs/components/TerrainController.js +2 -2
- package/package.json +1 -1
- package/samples/terrain/editor.js +2 -2
- package/src/core/UUID.spec.js +8 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +4 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +57 -55
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.spec.js +54 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +3 -3
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.spec.js +60 -0
- package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +2 -2
- package/src/core/cache/Cache.d.ts +4 -0
- package/src/core/cache/Cache.js +32 -18
- package/src/core/cache/Cache.spec.js +33 -0
- package/src/core/cache/CacheElement.js +1 -0
- package/src/core/cache/FrequencySketch.js +26 -23
- package/src/core/cache/FrequencySketch.spec.js +5 -0
- package/src/core/cache/LoadingCache.d.ts +2 -0
- package/src/core/cache/LoadingCache.js +16 -7
- package/src/core/cache/LoadingCache.spec.js +24 -0
- package/src/core/collection/HashMap.d.ts +2 -0
- package/src/core/collection/HashMap.spec.js +51 -2
- package/src/core/collection/list/List.d.ts +13 -1
- package/src/core/collection/list/List.js +702 -684
- package/src/core/collection/list/List.spec.js +93 -0
- package/src/core/collection/map/AsyncLoadingCache.js +1 -0
- package/src/core/fsm/simple/SimpleStateMachine.js +23 -22
- package/src/core/function/extractFunctionBody.spec.js +15 -0
- package/src/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +69 -33
- package/src/core/geom/2d/convex-hull/convex_hull_monotone_2d.spec.js +33 -0
- package/src/core/geom/2d/convex-hull/orientation3.js +55 -10
- package/src/core/geom/2d/quad-tree/PointQuadTree.js +10 -0
- package/src/core/geom/3d/aabb/aabb3_array_combine.js +3 -3
- package/src/core/graph/{convertGraphToDotString.js → convert_graph_to_dot_string.js} +1 -1
- package/src/core/graph/convert_graph_to_dot_string.spec.js +28 -0
- package/src/core/math/noise/sdnoise.js +5 -7
- package/src/core/math/noise/sdnoise.spec.js +87 -0
- package/src/core/process/matcher/Matchers.js +1 -1
- package/src/engine/asset/loaders/image/png/PNG.spec.js +5 -0
- package/src/engine/asset/loaders/image/png/PNGReader.spec.js +5 -0
- package/src/engine/asset/loaders/image/png/crc.spec.js +15 -0
- package/src/engine/{Platform.js → browserInfo.js} +1 -5
- package/src/engine/ecs/EntityBlueprint.js +4 -0
- package/src/engine/ecs/EntityBuilder.js +48 -49
- package/src/engine/ecs/EntityBuilderFlags.js +2 -2
- package/src/engine/ecs/fow/FogOfWar.js +48 -54
- package/src/engine/ecs/guid/GUID.js +1 -0
- package/src/engine/ecs/{systems → renderable}/RenderSystem.d.ts +1 -1
- package/src/engine/ecs/{systems → renderable}/RenderSystem.js +10 -38
- package/src/engine/ecs/renderable/Renderable.d.ts +25 -0
- package/src/engine/ecs/{components → renderable}/Renderable.js +18 -83
- package/src/engine/ecs/renderable/Renderable.spec.js +10 -0
- package/src/engine/ecs/speaker/VoiceSystem.js +15 -9
- package/src/engine/ecs/systems/MeshColliderSystem.js +1 -1
- package/src/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +1 -1
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +2 -2
- package/src/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +3 -3
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +2 -2
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +2 -2
- package/src/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +2 -2
- package/src/engine/graphics/copy_transform_to_threejs_object.js +12 -0
- package/src/engine/graphics/debug/VisualSymbolLine.js +1 -1
- package/src/engine/graphics/ecs/decal/DecalSystem.js +1 -1
- package/src/engine/graphics/ecs/highlight/renderer/makeGaussianBlurShader.js +1 -4
- package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.d.ts +1 -1
- package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.js +2 -2
- package/src/engine/graphics/ecs/mesh/applyTransformToThreeObject.js +2 -5
- package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.js +2 -2
- package/src/engine/graphics/geometry/optimization/merge/prototypeGeometryMerge.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
- package/src/engine/graphics/shaders/SoftOutlineShader.js +2 -4
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.spec.js +24 -0
- package/src/engine/graphics/texture/atlas/TextureAtlas.spec.js +46 -0
- package/src/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
- package/src/engine/graphics/texture/sampler/bicubic.spec.js +13 -0
- package/src/engine/graphics/texture/sampler/differenceSampler.js +1 -1
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +5 -1
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.spec.js +183 -0
- package/src/engine/graphics/texture/sampler/filter/filter_lanczos3.js +20 -0
- package/src/engine/graphics/texture/sampler/filter/mitchell.js +0 -21
- package/src/engine/graphics/texture/sampler/filter/mitchell_v1.js +21 -0
- package/src/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +17 -16
- package/src/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +11 -9
- package/src/engine/graphics/texture/sampler/{scaleSampler2D.js → resize/sampler2d_scale.js} +8 -8
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale.spec.js +73 -0
- package/src/engine/graphics/texture/sampler/{sampler2_d_scale_down_lanczos.js → resize/sampler2d_scale_down_lanczos.js} +3 -24
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.spec.js +29 -0
- package/src/engine/graphics/texture/sampler/{sampler2d_scale_down_linear.js → resize/sampler2d_scale_down_linear.js} +5 -5
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.spec.js +44 -0
- package/src/engine/graphics/texture/sampler/resize/{sampler2d_downsample_mipmap.js → sampler2d_scale_down_mipmap.js} +2 -2
- package/src/engine/graphics/texture/sampler/resize/{sampler2d_downsample_mipmap.spec.js → sampler2d_scale_down_mipmap.spec.js} +2 -2
- package/src/engine/graphics/texture/sampler/{genericResampleSampler2D.js → resize/sampler2d_scale_generic.js} +16 -12
- package/src/engine/graphics/texture/sampler/{upsampleSampler2D.js → resize/sampler2d_scale_up_linear.js} +5 -2
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_up_linear.spec.js +14 -0
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +4 -2
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.spec.js +15 -0
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.js +2 -2
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +66 -0
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.spec.js +108 -0
- package/src/engine/graphics/trail/TemporalPath.js +83 -78
- package/src/engine/graphics/trail/TemporalPath.spec.js +5 -0
- package/src/engine/graphics/trail/x/RibbonX.spec.js +5 -0
- package/src/engine/input/devices/InputDeviceSwitch.spec.js +5 -0
- package/src/engine/input/ecs/{InputBinding.js → components/InputBinding.js} +1 -1
- package/src/engine/input/ecs/components/InputController.js +2 -2
- package/src/engine/input/ecs/ism/InputBinding.js +2 -2
- package/src/engine/input/ecs/util/TerrainCameraTargetSampler.js +1 -1
- package/src/engine/input/ecs/util/TopDownCameraControllerHelper.js +1 -1
- package/src/engine/intelligence/behavior/behavior_to_dot.spec.js +25 -0
- package/src/engine/intelligence/behavior/util/DelayBehavior.js +6 -4
- package/src/engine/intelligence/blackboard/Blackboard.d.ts +2 -0
- package/src/engine/intelligence/blackboard/Blackboard.js +36 -2
- package/src/engine/intelligence/blackboard/Blackboard.spec.js +49 -0
- package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.spec.js +2 -0
- package/src/engine/navigation/grid/{AStar.js → find_path_on_grid_astar.js} +21 -18
- package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +7 -0
- package/src/engine/sound/ecs/SoundListenerSystem.js +1 -1
- package/src/generation/markers/debug/visualizeMarkers.js +1 -1
- package/src/engine/MeepSettings.js +0 -9
- package/src/engine/User.js +0 -28
- package/src/engine/UserController.js +0 -273
- package/src/engine/ecs/components/AABB.js +0 -33
- package/src/engine/ecs/components/AABBCollider.js +0 -15
- package/src/engine/ecs/components/Renderable.d.ts +0 -14
- package/src/engine/ecs/grid/Sampler2DDecoder.js +0 -57
- package/src/engine/ecs/grid/makeTerrainGeometry.js +0 -110
- package/src/engine/ecs/systems/AABBColliderSystem.js +0 -61
- package/src/engine/ecs/systems/AABBSystem.js +0 -89
- package/src/engine/graphics/texture/sampler/sampler2d_make_array_filler_function.js +0 -65
- package/src/engine/graphics/texture/sampler/sampler2d_scale_down_linear.spec.js +0 -17
- package/src/engine/graphics/trail/x/simulator/RibbonState.js +0 -10
- package/src/engine/grid/Grid.js +0 -131
- package/src/engine/navigation/grid/GridField.js +0 -328
- /package/src/engine/ecs/{components → renderable}/RenderableFlags.js +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { crc } from "./crc.js";
|
|
2
|
+
|
|
3
|
+
test("sanity", () => {
|
|
4
|
+
|
|
5
|
+
const empty = crc(new Uint8Array(0), 0, 0);
|
|
6
|
+
|
|
7
|
+
expect(typeof empty).toBe("number");
|
|
8
|
+
expect(Number.isInteger(empty)).toBe(true);
|
|
9
|
+
|
|
10
|
+
const one = crc(new Uint8Array([1]), 0, 1);
|
|
11
|
+
|
|
12
|
+
expect(typeof one).toBe("number");
|
|
13
|
+
expect(Number.isInteger(one)).toBe(true);
|
|
14
|
+
|
|
15
|
+
});
|
|
@@ -4,7 +4,7 @@ let cached = null;
|
|
|
4
4
|
* https://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser
|
|
5
5
|
* @returns {{name:String, version:Number}}
|
|
6
6
|
*/
|
|
7
|
-
function browserInfo() {
|
|
7
|
+
export function browserInfo() {
|
|
8
8
|
if (cached !== null) {
|
|
9
9
|
return cached;
|
|
10
10
|
}
|
|
@@ -46,7 +46,3 @@ function browserInfo() {
|
|
|
46
46
|
|
|
47
47
|
return result;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
browserInfo
|
|
52
|
-
}
|
|
@@ -15,59 +15,58 @@ const DEFAULT_FLAGS =
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Representation of an entity, helps build entities and keep track of them without having to access {@link EntityComponentDataset} directly
|
|
18
|
+
* @class
|
|
18
19
|
*/
|
|
19
20
|
class EntityBuilder {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @type {number}
|
|
24
|
+
*/
|
|
25
|
+
entity = void 0;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generation is a unique identifier coming from the dataset
|
|
29
|
+
* Generation of an existing entity must match for it to be considered "the same"
|
|
30
|
+
* @type {number}
|
|
31
|
+
*/
|
|
32
|
+
generation = -1;
|
|
33
|
+
|
|
20
34
|
/**
|
|
21
35
|
*
|
|
22
|
-
* @
|
|
36
|
+
* @type {Array}
|
|
23
37
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* @type {EntityBuilderFlags|number}
|
|
58
|
-
*/
|
|
59
|
-
this.flags = DEFAULT_FLAGS;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
* @type {Object}
|
|
64
|
-
*/
|
|
65
|
-
this.properties = {};
|
|
66
|
-
|
|
67
|
-
this.on = {
|
|
68
|
-
built: new Signal()
|
|
69
|
-
};
|
|
70
|
-
}
|
|
38
|
+
element = [];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @type {{name:string,listener:(function|Function), context:*}[]}
|
|
43
|
+
*/
|
|
44
|
+
deferredListeners = [];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @type {EntityComponentDataset}
|
|
49
|
+
*/
|
|
50
|
+
dataset = null;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @type {EntityBuilderFlags|number}
|
|
55
|
+
*/
|
|
56
|
+
flags = DEFAULT_FLAGS;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @type {Object}
|
|
61
|
+
*/
|
|
62
|
+
properties = {};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @readonly
|
|
66
|
+
*/
|
|
67
|
+
on = {
|
|
68
|
+
built: new Signal()
|
|
69
|
+
};
|
|
71
70
|
|
|
72
71
|
/**
|
|
73
72
|
* Handles event when entity is removed without invoking {@link #destroy} method
|
|
@@ -200,7 +199,7 @@ class EntityBuilder {
|
|
|
200
199
|
|
|
201
200
|
/**
|
|
202
201
|
*
|
|
203
|
-
* @param {
|
|
202
|
+
* @param {function} klass
|
|
204
203
|
* @returns {*|null}
|
|
205
204
|
*/
|
|
206
205
|
removeComponent(klass) {
|
|
@@ -8,11 +8,11 @@ export const EntityBuilderFlags = {
|
|
|
8
8
|
*/
|
|
9
9
|
Built: 1,
|
|
10
10
|
/**
|
|
11
|
-
* If component type is not registered on the {@link EntityComponentDataset} when calling {@link #build} - will register the component first
|
|
11
|
+
* If component type is not registered on the {@link EntityComponentDataset} when calling {@link EntityBuilder#build} - will register the component first
|
|
12
12
|
*/
|
|
13
13
|
RegisterComponents: 2,
|
|
14
14
|
/**
|
|
15
|
-
* Entity builder will watch destruction of the entity (subscribe to event), this will make the EntityBuilder automatically
|
|
15
|
+
* Entity builder will watch destruction of the entity (subscribe to event), this will make the {@link EntityBuilder} automatically
|
|
16
16
|
* recognize when the corresponding entity is destroyed outside the EntityBuilder API
|
|
17
17
|
* NOTE: useful to turn off to save a bit of memory, as those event listeners take up a bit of space. Feel free to turn this flag off when you don't care to keep the reference to the EntityBuilder
|
|
18
18
|
*/
|
|
@@ -45,62 +45,63 @@ const revealMaskTableSpec = new RowFirstTableSpec([
|
|
|
45
45
|
|
|
46
46
|
const fadeRow = [];
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @class
|
|
50
|
+
*/
|
|
48
51
|
export class FogOfWar {
|
|
49
|
-
constructor() {
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @type {boolean}
|
|
53
|
-
*/
|
|
54
|
-
this.textureNeedsUpdate = false;
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
57
|
-
* @type {boolean}
|
|
58
|
-
*/
|
|
59
|
-
this.distanceFieldNeedsUpdate = false;
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @type {boolean}
|
|
56
|
+
*/
|
|
57
|
+
textureNeedsUpdate = true;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @type {boolean}
|
|
61
|
+
*/
|
|
62
|
+
distanceFieldNeedsUpdate = false;
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @type {DataTexture|null}
|
|
67
|
+
*/
|
|
68
|
+
texture = null;
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Resolution scale of FoW versus terrain resolution, higher number makes FoW more detailed
|
|
72
|
+
* @type {Vector1}
|
|
73
|
+
*/
|
|
74
|
+
scale = new Vector1(1);
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Size of the fog area
|
|
78
|
+
* @type {Vector2}
|
|
79
|
+
*/
|
|
80
|
+
size = new Vector2(0, 0);
|
|
89
81
|
|
|
90
|
-
|
|
82
|
+
color = new Vector4(0.1, 0.1, 0.1, 1);
|
|
91
83
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Contains indices of pixes that are currently being updated
|
|
86
|
+
* @type {RowFirstTable}
|
|
87
|
+
*/
|
|
88
|
+
fadeMask = new RowFirstTable(revealMaskTableSpec);
|
|
97
89
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
on = {
|
|
91
|
+
textureChanged: new Signal()
|
|
92
|
+
};
|
|
101
93
|
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @type {Sampler2D}
|
|
97
|
+
*/
|
|
98
|
+
sampler = Sampler2D.uint8(1, 0, 0);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @type {Sampler2D}
|
|
103
|
+
*/
|
|
104
|
+
distanceSampler = Sampler2D.uint8(1, 0, 0);
|
|
104
105
|
|
|
105
106
|
/**
|
|
106
107
|
*
|
|
@@ -159,13 +160,6 @@ export class FogOfWar {
|
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
initialize() {
|
|
163
|
-
this.sampler = new Sampler2D(new Uint8Array(0), 1, 0, 0);
|
|
164
|
-
this.distanceSampler = new Sampler2D(new Uint8Array(0), 1, 0, 0);
|
|
165
|
-
|
|
166
|
-
this.textureNeedsUpdate = true;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
163
|
/**
|
|
170
164
|
*
|
|
171
165
|
* @param {number} x
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {System} from "../System";
|
|
2
2
|
import {GraphicsEngine} from "../../graphics/GraphicsEngine";
|
|
3
|
-
import Renderable from "
|
|
3
|
+
import Renderable from "./Renderable";
|
|
4
4
|
|
|
5
5
|
export default class RenderSystem extends System<Renderable> {
|
|
6
6
|
constructor(graphics: GraphicsEngine)
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* Created by Alex on 01/04/2014.
|
|
3
3
|
*/
|
|
4
4
|
import { System } from '../System.js';
|
|
5
|
-
import Renderable from '
|
|
5
|
+
import Renderable from './Renderable.js';
|
|
6
6
|
import { Transform } from '../transform/Transform.js';
|
|
7
7
|
import { SignalBinding } from "../../../core/events/signal/SignalBinding.js";
|
|
8
|
-
import { RenderableFlags } from "
|
|
8
|
+
import { RenderableFlags } from "./RenderableFlags.js";
|
|
9
9
|
import { rootObject3DFastMatrixUpdate } from "../../graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js";
|
|
10
10
|
import { updateNodeByTransformAndBBB } from "../../graphics/ecs/mesh/updateNodeByTransformAndBBB.js";
|
|
11
|
-
import { three_computeObjectBoundingBox } from "../../graphics/three/three_computeObjectBoundingBox.js";
|
|
12
11
|
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
13
12
|
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
13
|
+
import { copy_transform_to_threejs_object } from "../../graphics/copy_transform_to_threejs_object.js";
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -111,37 +111,11 @@ class RenderSystem extends System {
|
|
|
111
111
|
|
|
112
112
|
if (renderable.getFlag(RenderableFlags.BoundingBoxNeedsUpdate)) {
|
|
113
113
|
// compute bounding box
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
renderable.clearFlag(RenderableFlags.BoundingBoxNeedsUpdate);
|
|
114
|
+
renderable.computeBoundsFromObject();
|
|
117
115
|
}
|
|
118
116
|
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
const p = m.position;
|
|
122
|
-
if (p.x !== x || p.y !== y || p.z !== z) {
|
|
123
|
-
p.set(x, y, z);
|
|
124
|
-
}
|
|
125
|
-
updateMeshTransform(renderable);
|
|
126
|
-
updateNodeByTransformAndBBB(renderable.bvh, renderable.boundingBox, transform);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function copyScaleOfMesh(x, y, z) {
|
|
130
|
-
const m = renderable.object;
|
|
131
|
-
const scale = m.scale;
|
|
132
|
-
if (scale.x !== x || scale.y !== y || scale.z !== z) {
|
|
133
|
-
scale.set(x, y, z);
|
|
134
|
-
}
|
|
135
|
-
updateMeshTransform(renderable);
|
|
136
|
-
updateNodeByTransformAndBBB(renderable.bvh, renderable.boundingBox, transform);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function handleRotationChange() {
|
|
140
|
-
const m = renderable.object;
|
|
141
|
-
const euler = m.rotation;
|
|
142
|
-
|
|
143
|
-
transform.rotation.__setFromEuler(euler.x, euler.y, euler.z, euler.order);
|
|
144
|
-
|
|
117
|
+
function handle_transform_change() {
|
|
118
|
+
copy_transform_to_threejs_object(renderable.object, transform);
|
|
145
119
|
updateMeshTransform(renderable);
|
|
146
120
|
updateNodeByTransformAndBBB(renderable.bvh, renderable.boundingBox, transform);
|
|
147
121
|
}
|
|
@@ -149,9 +123,9 @@ class RenderSystem extends System {
|
|
|
149
123
|
const position = transform.position;
|
|
150
124
|
const scale = transform.scale;
|
|
151
125
|
|
|
152
|
-
const bPosition = new SignalBinding(position.onChanged,
|
|
153
|
-
const bRotation = new SignalBinding(transform.rotation.onChanged,
|
|
154
|
-
const bScale = new SignalBinding(scale.onChanged,
|
|
126
|
+
const bPosition = new SignalBinding(position.onChanged, handle_transform_change);
|
|
127
|
+
const bRotation = new SignalBinding(transform.rotation.onChanged, handle_transform_change);
|
|
128
|
+
const bScale = new SignalBinding(scale.onChanged, handle_transform_change);
|
|
155
129
|
|
|
156
130
|
bPosition.link();
|
|
157
131
|
bRotation.link();
|
|
@@ -163,9 +137,7 @@ class RenderSystem extends System {
|
|
|
163
137
|
bScale
|
|
164
138
|
];
|
|
165
139
|
|
|
166
|
-
|
|
167
|
-
copyScaleOfMesh(scale.x, scale.y, scale.z);
|
|
168
|
-
handleRotationChange();
|
|
140
|
+
handle_transform_change();
|
|
169
141
|
|
|
170
142
|
this.bvh.insertNode(renderable.bvh);
|
|
171
143
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Object3D} from "three";
|
|
2
|
+
import {AABB3} from "../../../core/geom/3d/aabb/AABB3";
|
|
3
|
+
import {LeafNode} from "../../../core/bvh2/LeafNode";
|
|
4
|
+
|
|
5
|
+
export default class Renderable {
|
|
6
|
+
readonly object: Object3D
|
|
7
|
+
readonly boundingBox: AABB3
|
|
8
|
+
|
|
9
|
+
matrixAutoUpdate: boolean
|
|
10
|
+
boundingBoxNeedsUpdate: boolean
|
|
11
|
+
|
|
12
|
+
readonly bvh: LeafNode<Object3D>
|
|
13
|
+
|
|
14
|
+
constructor(object: Object3D)
|
|
15
|
+
|
|
16
|
+
setFlag(flag: number): void
|
|
17
|
+
|
|
18
|
+
clearFlag(flag: number): void
|
|
19
|
+
|
|
20
|
+
writeFlag(flag: number, value: boolean): void
|
|
21
|
+
|
|
22
|
+
getFlag(flag: number): boolean
|
|
23
|
+
|
|
24
|
+
computeBoundsFromObject(): void
|
|
25
|
+
}
|
|
@@ -5,29 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import { LeafNode } from "../../../core/bvh2/LeafNode.js";
|
|
7
7
|
import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
|
|
8
|
-
import { Vector3 as ThreeVector3 } from "three";
|
|
9
|
-
import { max2 } from "../../../core/math/max2.js";
|
|
10
|
-
import { min2 } from "../../../core/math/min2.js";
|
|
11
8
|
import { RenderableFlags } from "./RenderableFlags.js";
|
|
9
|
+
import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
10
|
+
import {
|
|
11
|
+
expand_aabb_by_transformed_three_object
|
|
12
|
+
} from "../../graphics/three/expand_aabb_by_transformed_three_object.js";
|
|
12
13
|
|
|
13
14
|
const DEFAULT_FLAGS = RenderableFlags.UpdateMatrix | RenderableFlags.BoundingBoxNeedsUpdate;
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @type {Vector3[]}
|
|
19
|
-
*/
|
|
20
|
-
const scratch_corners = [
|
|
21
|
-
new ThreeVector3(),
|
|
22
|
-
new ThreeVector3(),
|
|
23
|
-
new ThreeVector3(),
|
|
24
|
-
new ThreeVector3(),
|
|
25
|
-
new ThreeVector3(),
|
|
26
|
-
new ThreeVector3(),
|
|
27
|
-
new ThreeVector3(),
|
|
28
|
-
new ThreeVector3()
|
|
29
|
-
];
|
|
30
|
-
|
|
31
17
|
/**
|
|
32
18
|
@deprecated use {@link ShadedGeometry} instead
|
|
33
19
|
*/
|
|
@@ -157,83 +143,32 @@ class Renderable {
|
|
|
157
143
|
computeBoundsFromObject() {
|
|
158
144
|
const object = this.object;
|
|
159
145
|
|
|
160
|
-
|
|
161
|
-
y0 = Infinity,
|
|
162
|
-
z0 = Infinity,
|
|
163
|
-
x1 = -Infinity,
|
|
164
|
-
y1 = -Infinity,
|
|
165
|
-
z1 = -Infinity;
|
|
166
|
-
|
|
167
|
-
object.updateMatrixWorld(false, true);
|
|
168
|
-
|
|
169
|
-
object.traverse(function (object) {
|
|
170
|
-
if (object.isLine || object.isMesh) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const geometry = object.geometry;
|
|
174
|
-
|
|
175
|
-
geometry.computeBoundingBox();
|
|
176
|
-
|
|
177
|
-
const boundingBox = geometry.boundingBox;
|
|
146
|
+
object.updateMatrixWorld();
|
|
178
147
|
|
|
179
|
-
|
|
180
|
-
|
|
148
|
+
const aabb = new Float32Array([
|
|
149
|
+
Infinity, Infinity, Infinity,
|
|
150
|
+
-Infinity, -Infinity, -Infinity
|
|
151
|
+
]);
|
|
181
152
|
|
|
182
|
-
|
|
183
|
-
// object has 0 bounds, skip
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
object.updateMatrixWorld();
|
|
188
|
-
|
|
189
|
-
const worldMatrix = object.matrixWorld;
|
|
190
|
-
|
|
191
|
-
// set corner data
|
|
192
|
-
scratch_corners[0].set(bbMin.x, bbMin.y, bbMin.z);
|
|
193
|
-
scratch_corners[1].set(bbMin.x, bbMin.y, bbMax.z);
|
|
194
|
-
scratch_corners[2].set(bbMin.x, bbMax.y, bbMin.z);
|
|
195
|
-
scratch_corners[3].set(bbMin.x, bbMax.y, bbMax.z);
|
|
196
|
-
scratch_corners[4].set(bbMax.x, bbMin.y, bbMin.z);
|
|
197
|
-
scratch_corners[5].set(bbMax.x, bbMin.y, bbMax.z);
|
|
198
|
-
scratch_corners[6].set(bbMax.x, bbMax.y, bbMin.z);
|
|
199
|
-
scratch_corners[7].set(bbMax.x, bbMax.y, bbMax.z);
|
|
200
|
-
|
|
201
|
-
for (let i = 0; i < 8; i++) {
|
|
202
|
-
const corner = scratch_corners[i];
|
|
203
|
-
|
|
204
|
-
corner.applyMatrix4(worldMatrix);
|
|
205
|
-
|
|
206
|
-
x0 = min2(x0, corner.x);
|
|
207
|
-
y0 = min2(y0, corner.y);
|
|
208
|
-
z0 = min2(z0, corner.z);
|
|
209
|
-
|
|
210
|
-
x1 = max2(x1, corner.x);
|
|
211
|
-
y1 = max2(y1, corner.y);
|
|
212
|
-
z1 = max2(z1, corner.z);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
});
|
|
153
|
+
expand_aabb_by_transformed_three_object(aabb, object, MATRIX_4_IDENTITY);
|
|
216
154
|
|
|
217
155
|
// sanity checks to ensure valid bounds
|
|
218
|
-
if (!Number.isFinite(
|
|
219
|
-
|
|
220
|
-
x1 = 0;
|
|
156
|
+
if (!Number.isFinite(aabb[0])) {
|
|
157
|
+
aabb[0] = aabb[3] = 0;
|
|
221
158
|
}
|
|
222
159
|
|
|
223
|
-
if (!Number.isFinite(
|
|
224
|
-
|
|
225
|
-
y1 = 0;
|
|
160
|
+
if (!Number.isFinite(aabb[1])) {
|
|
161
|
+
aabb[1] = aabb[4] = 0;
|
|
226
162
|
}
|
|
227
163
|
|
|
228
|
-
if (!Number.isFinite(
|
|
229
|
-
|
|
230
|
-
z1 = 0;
|
|
164
|
+
if (!Number.isFinite(aabb[2])) {
|
|
165
|
+
aabb[2] = aabb[5] = 0;
|
|
231
166
|
}
|
|
232
167
|
|
|
233
168
|
|
|
234
|
-
this.boundingBox.
|
|
169
|
+
this.boundingBox.readFromArray(aabb);
|
|
235
170
|
|
|
236
|
-
this.
|
|
171
|
+
this.clearFlag(RenderableFlags.BoundingBoxNeedsUpdate);
|
|
237
172
|
}
|
|
238
173
|
}
|
|
239
174
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Renderable from "./Renderable.js";
|
|
2
|
+
import { Object3D } from "three";
|
|
3
|
+
import { RenderableFlags } from "./RenderableFlags.js";
|
|
4
|
+
|
|
5
|
+
test("constructor", () => {
|
|
6
|
+
|
|
7
|
+
const unit = new Renderable(new Object3D());
|
|
8
|
+
|
|
9
|
+
expect(unit.getFlag(RenderableFlags.BoundingBoxNeedsUpdate)).toBe(true);
|
|
10
|
+
});
|
|
@@ -20,7 +20,6 @@ import { Blackboard } from "../../intelligence/blackboard/Blackboard.js";
|
|
|
20
20
|
import { VoiceFlags } from "./VoiceFlags.js";
|
|
21
21
|
import { assert } from "../../../core/assert.js";
|
|
22
22
|
import { weightedRandomFromArray } from "../../../core/collection/array/weightedRandomFromArray.js";
|
|
23
|
-
import { MeepSettings } from "../../MeepSettings.js";
|
|
24
23
|
import { GameAssetType } from "../../asset/GameAssetType.js";
|
|
25
24
|
import { DomSizeObserver } from "../../../view/util/DomSizeObserver.js";
|
|
26
25
|
import { SpeechBubbleView } from "./SpeechBubbleView.js";
|
|
@@ -140,8 +139,6 @@ class Context extends SystemEntityContext {
|
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
const VOICE_SETTINGS = MeepSettings.ecs.Voice;
|
|
144
|
-
|
|
145
142
|
const SPEECH_BUBBLE_ANIMATION_INTRO = new AnimationTrack(['alpha']);
|
|
146
143
|
SPEECH_BUBBLE_ANIMATION_INTRO.addKey(0, [0]);
|
|
147
144
|
SPEECH_BUBBLE_ANIMATION_INTRO.addKey(0.1, [1]);
|
|
@@ -167,8 +164,12 @@ export class VoiceSystem extends AbstractContextSystem {
|
|
|
167
164
|
/**
|
|
168
165
|
*
|
|
169
166
|
* @param {Engine} engine
|
|
167
|
+
* @param settings
|
|
170
168
|
*/
|
|
171
|
-
constructor(engine
|
|
169
|
+
constructor(engine, settings = {
|
|
170
|
+
font: "unknown.ttf", //path to font file
|
|
171
|
+
font_size: 16
|
|
172
|
+
}) {
|
|
172
173
|
super(Context);
|
|
173
174
|
|
|
174
175
|
this.dependencies = [Voice];
|
|
@@ -239,9 +240,16 @@ export class VoiceSystem extends AbstractContextSystem {
|
|
|
239
240
|
|
|
240
241
|
/**
|
|
241
242
|
*
|
|
243
|
+
* @type {string}
|
|
242
244
|
* @private
|
|
243
245
|
*/
|
|
244
|
-
this.
|
|
246
|
+
this.__font_path = settings.font;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
*
|
|
250
|
+
* @private
|
|
251
|
+
*/
|
|
252
|
+
this.__font_size = settings.font_size;
|
|
245
253
|
|
|
246
254
|
/**
|
|
247
255
|
* Print debug output into console
|
|
@@ -274,11 +282,9 @@ export class VoiceSystem extends AbstractContextSystem {
|
|
|
274
282
|
assert.defined(this.lines, 'lines');
|
|
275
283
|
assert.defined(this.sets, 'sets');
|
|
276
284
|
|
|
277
|
-
const p_font_setting = engine.assetManager.promise(
|
|
278
|
-
|
|
279
|
-
const font = font_asset.create();
|
|
285
|
+
const p_font_setting = engine.assetManager.promise(this.__font_path, GameAssetType.Font).then(font_asset => {
|
|
280
286
|
|
|
281
|
-
this.__font =
|
|
287
|
+
this.__font = font_asset.create();
|
|
282
288
|
});
|
|
283
289
|
|
|
284
290
|
p_font_setting.then(() => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { System } from '../System.js';
|
|
5
5
|
import Tag from '../components/Tag.js';
|
|
6
6
|
import { Transform } from '../transform/Transform.js';
|
|
7
|
-
import Renderable from '../
|
|
7
|
+
import Renderable from '../renderable/Renderable.js';
|
|
8
8
|
import MeshCollider from '../components/MeshCollider.js';
|
|
9
9
|
import { Raycaster } from "three";
|
|
10
10
|
|