@woosh/meep-engine 2.50.3 → 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/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.js +3 -5
- package/src/core/cache/CacheElement.js +1 -0
- 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/engine/{Platform.js → browserInfo.js} +1 -5
- package/src/engine/ecs/fow/FogOfWar.js +48 -54
- 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
|
@@ -195,7 +195,7 @@ function grad4(result, hash) {
|
|
|
195
195
|
* @param {number[]} derivatives
|
|
196
196
|
* @returns {number}
|
|
197
197
|
*/
|
|
198
|
-
function sdnoise1(derivatives, x) {
|
|
198
|
+
export function sdnoise1(derivatives, x) {
|
|
199
199
|
const i0 = x | 0;
|
|
200
200
|
const i1 = i0 + 1;
|
|
201
201
|
|
|
@@ -207,8 +207,7 @@ function sdnoise1(derivatives, x) {
|
|
|
207
207
|
let t1, t20, t40, t21, t41, x21;
|
|
208
208
|
|
|
209
209
|
const x20 = x0 * x0;
|
|
210
|
-
const t0 = 1.0
|
|
211
|
-
f - x20;
|
|
210
|
+
const t0 = 1.0 - x20;
|
|
212
211
|
// if(t0 < 0.0f) t0 = 0.0f; // Never happens for 1D: x0<=1 always
|
|
213
212
|
t20 = t0 * t0;
|
|
214
213
|
t40 = t20 * t20;
|
|
@@ -218,8 +217,7 @@ function sdnoise1(derivatives, x) {
|
|
|
218
217
|
n0 = t40 * gx0 * x0;
|
|
219
218
|
|
|
220
219
|
x21 = x1 * x1;
|
|
221
|
-
t1 = 1.0
|
|
222
|
-
f - x21;
|
|
220
|
+
t1 = 1.0 - x21;
|
|
223
221
|
// if(t1 < 0.0f) t1 = 0.0f; // Never happens for 1D: |x1|<=1 always
|
|
224
222
|
t21 = t1 * t1;
|
|
225
223
|
t41 = t21 * t21;
|
|
@@ -265,7 +263,7 @@ const G2 = 0.21132486540518713;
|
|
|
265
263
|
* @param {number[]} derivatives
|
|
266
264
|
* @returns {number}
|
|
267
265
|
*/
|
|
268
|
-
function sdnoise2(derivatives, x, y) {
|
|
266
|
+
export function sdnoise2(derivatives, x, y) {
|
|
269
267
|
let n0, n1, n2; /* Noise contributions from the three simplex corners */
|
|
270
268
|
let gx0, gy0, gx1, gy1, gx2, gy2; /* Gradients at simplex corners */
|
|
271
269
|
let t0, t1, t2, x1, x2, y1, y2;
|
|
@@ -280,7 +278,7 @@ function sdnoise2(derivatives, x, y) {
|
|
|
280
278
|
let ii, i = xs | 0;
|
|
281
279
|
let jj, j = ys | 0;
|
|
282
280
|
|
|
283
|
-
const t = (
|
|
281
|
+
const t = (i + j) * G2;
|
|
284
282
|
const X0 = i - t; /* Unskew the cell origin back to (x,y) space */
|
|
285
283
|
const Y0 = j - t;
|
|
286
284
|
const x0 = x - X0; /* The x,y distances from the cell origin */
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { sdnoise1, sdnoise2, sdnoise3, sdnoise4 } from "./sdnoise.js";
|
|
2
|
+
|
|
3
|
+
describe("sdnoise1", () => {
|
|
4
|
+
test("sanity", () => {
|
|
5
|
+
const derivatives = [];
|
|
6
|
+
|
|
7
|
+
const value = sdnoise1(derivatives, 0);
|
|
8
|
+
|
|
9
|
+
expect(typeof value).toBe("number");
|
|
10
|
+
expect(value).not.toBeNaN();
|
|
11
|
+
|
|
12
|
+
expect(derivatives.length).toEqual(1);
|
|
13
|
+
|
|
14
|
+
expect(typeof derivatives[0]).toBe("number");
|
|
15
|
+
expect(derivatives[0]).not.toBeNaN();
|
|
16
|
+
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("sdnoise2", () => {
|
|
21
|
+
test("sanity", () => {
|
|
22
|
+
const derivatives = [];
|
|
23
|
+
|
|
24
|
+
const value = sdnoise2(derivatives, 0, 0);
|
|
25
|
+
|
|
26
|
+
expect(typeof value).toBe("number");
|
|
27
|
+
expect(value).not.toBeNaN();
|
|
28
|
+
|
|
29
|
+
expect(derivatives.length).toEqual(2);
|
|
30
|
+
|
|
31
|
+
expect(typeof derivatives[0]).toBe("number");
|
|
32
|
+
expect(derivatives[0]).not.toBeNaN();
|
|
33
|
+
|
|
34
|
+
expect(typeof derivatives[1]).toBe("number");
|
|
35
|
+
expect(derivatives[1]).not.toBeNaN();
|
|
36
|
+
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("sdnoise3", () => {
|
|
41
|
+
test("sanity", () => {
|
|
42
|
+
const derivatives = [];
|
|
43
|
+
|
|
44
|
+
const value = sdnoise3(derivatives, 0, 0, 0);
|
|
45
|
+
|
|
46
|
+
expect(typeof value).toBe("number");
|
|
47
|
+
expect(value).not.toBeNaN();
|
|
48
|
+
|
|
49
|
+
expect(derivatives.length).toEqual(3);
|
|
50
|
+
|
|
51
|
+
expect(typeof derivatives[0]).toBe("number");
|
|
52
|
+
expect(derivatives[0]).not.toBeNaN();
|
|
53
|
+
|
|
54
|
+
expect(typeof derivatives[1]).toBe("number");
|
|
55
|
+
expect(derivatives[1]).not.toBeNaN();
|
|
56
|
+
|
|
57
|
+
expect(typeof derivatives[2]).toBe("number");
|
|
58
|
+
expect(derivatives[2]).not.toBeNaN();
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("sdnoise4", () => {
|
|
64
|
+
test("sanity", () => {
|
|
65
|
+
const derivatives = [];
|
|
66
|
+
|
|
67
|
+
const value = sdnoise4(derivatives, 0, 0, 0, 0);
|
|
68
|
+
|
|
69
|
+
expect(typeof value).toBe("number");
|
|
70
|
+
expect(value).not.toBeNaN();
|
|
71
|
+
|
|
72
|
+
expect(derivatives.length).toEqual(4);
|
|
73
|
+
|
|
74
|
+
expect(typeof derivatives[0]).toBe("number");
|
|
75
|
+
expect(derivatives[0]).not.toBeNaN();
|
|
76
|
+
|
|
77
|
+
expect(typeof derivatives[1]).toBe("number");
|
|
78
|
+
expect(derivatives[1]).not.toBeNaN();
|
|
79
|
+
|
|
80
|
+
expect(typeof derivatives[2]).toBe("number");
|
|
81
|
+
expect(derivatives[2]).not.toBeNaN();
|
|
82
|
+
|
|
83
|
+
expect(typeof derivatives[3]).toBe("number");
|
|
84
|
+
expect(derivatives[3]).not.toBeNaN();
|
|
85
|
+
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -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
|
-
}
|
|
@@ -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
|
|
|
@@ -6,7 +6,7 @@ import { Transform } from '../transform/Transform.js';
|
|
|
6
6
|
import RangedAttack from '../components/RangedAttack.js';
|
|
7
7
|
import PhysicalBody from '../components/PhysicalBody.js';
|
|
8
8
|
import Motion from '../components/Motion.js';
|
|
9
|
-
import Renderable from '../
|
|
9
|
+
import Renderable from '../renderable/Renderable.js';
|
|
10
10
|
import { Matrix4 as ThreeMatrix4, Vector3 as ThreeVector3 } from 'three';
|
|
11
11
|
import { solveQuadratic } from "../../../core/math/solveQuadratic.js";
|
|
12
12
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { System } from '../System.js';
|
|
5
5
|
import { Transform } from '../transform/Transform.js';
|
|
6
|
-
import Renderable from '../
|
|
6
|
+
import Renderable from '../renderable/Renderable.js';
|
|
7
7
|
import GeometryBVH from '../components/GeometryBVH.js';
|
|
8
8
|
import ViewportMeshProjection from '../components/ViewportMeshProjection.js';
|
|
9
9
|
import { Vector3 as ThreeVector3 } from 'three';
|
|
@@ -16,7 +16,7 @@ import { assert } from "../../../../../core/assert.js";
|
|
|
16
16
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
17
17
|
import { TerrainLayer } from "./TerrainLayer.js";
|
|
18
18
|
import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
|
|
19
|
-
import {
|
|
19
|
+
import { sampler2d_scale } from "../../../../graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
20
20
|
import List from "../../../../../core/collection/list/List.js";
|
|
21
21
|
import { Cache } from "../../../../../core/cache/Cache.js";
|
|
22
22
|
import { BinaryClassSerializationAdapter } from "../../../storage/binary/BinaryClassSerializationAdapter.js";
|
|
@@ -363,7 +363,7 @@ export class TerrainLayers {
|
|
|
363
363
|
|
|
364
364
|
const scaledLayerSampler = Sampler2D.uint8(3, resolution_x, resolution_y);
|
|
365
365
|
|
|
366
|
-
|
|
366
|
+
sampler2d_scale(layerSampler, scaledLayerSampler);
|
|
367
367
|
|
|
368
368
|
// write scaled texture into the cache
|
|
369
369
|
scaled_texture_cache.put(key, scaledLayerSampler);
|
|
@@ -2,9 +2,9 @@ import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
|
|
|
2
2
|
import convertSampler2D2Canvas from "../../../../graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
3
3
|
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
4
4
|
import EmptyView from "../../../../../view/elements/EmptyView.js";
|
|
5
|
-
import {
|
|
5
|
+
import { sampler2d_scale } from "../../../../graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
6
6
|
import { passThrough } from "../../../../../core/function/Functions.js";
|
|
7
|
-
import AABB2 from "../../../../../core/geom/AABB2.js";
|
|
7
|
+
import AABB2 from "../../../../../core/geom/2d/aabb/AABB2.js";
|
|
8
8
|
import View from "../../../../../view/View.js";
|
|
9
9
|
import SVG from "../../../../../view/SVG.js";
|
|
10
10
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
@@ -218,7 +218,7 @@ export class SplatMapOptimizerDebugger {
|
|
|
218
218
|
|
|
219
219
|
const s2 = Sampler2D.uint8(4, rW, rH);
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
sampler2d_scale(sampler, s2);
|
|
222
222
|
|
|
223
223
|
const canvasView = new CanvasView();
|
|
224
224
|
canvasView.size.set(rW, rH);
|