@woosh/meep-engine 2.33.59 → 2.33.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/bvh2/aabb3/AABB3.js +4 -1
- package/core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js +6 -6
- package/core/cache/Cache.js +7 -0
- package/core/collection/array/fastArrayEquals.js +17 -0
- package/core/collection/array/typed/is_typed_array_equals.js +58 -0
- package/core/collection/map/AbstractAsyncMap.js +30 -0
- package/core/collection/map/AsyncMapWrapper.js +16 -0
- package/core/collection/map/AsyncRemoteHashMap.js +358 -0
- package/core/collection/map/CachedAsyncMap.js +34 -0
- package/core/geom/3d/SurfacePoint3.js +44 -5
- package/core/geom/Vector2.d.ts +2 -0
- package/core/geom/Vector4.js +5 -5
- package/core/geom/packing/MaxRectangles.js +13 -4
- package/core/math/hash/murmur3_32.js +3 -3
- 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/animation/removeEntityGenericEffect.js +22 -31
- package/engine/asset/Asset.js +0 -45
- package/engine/asset/AssetDescription.js +51 -0
- package/engine/asset/AssetManager.d.ts +7 -0
- package/engine/asset/AssetManager.js +98 -2
- package/engine/asset/AssetTransformer.d.ts +5 -0
- package/engine/asset/AssetTransformer.js +15 -0
- package/engine/asset/loaders/GLTFAssetLoader.js +27 -25
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +2 -2
- package/engine/asset/loaders/material/computeTextureEquality.js +2 -2
- package/engine/asset/loaders/material/computeTextureHash.js +7 -13
- package/engine/ecs/animation/InverseKinematicsSystem.js +1 -1
- package/engine/ecs/attachment/AttachmentSystem.js +18 -17
- package/engine/ecs/evaluation/world/ReadTerrainLayerWeightPointFitness.js +1 -1
- package/engine/ecs/fow/FogOfWarRevealerSystem.js +2 -2
- package/engine/ecs/grid/HeightMap2NormalMap.js +1 -1
- package/engine/ecs/grid/NormalMap2AOMap.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +60 -45
- package/engine/ecs/gui/position/ViewportPositionSystem.js +5 -5
- package/engine/ecs/parent/EntityNode.d.ts +20 -0
- package/engine/ecs/parent/EntityNode.js +284 -0
- package/engine/ecs/parent/FaceEditor.js +137 -0
- package/engine/ecs/parent/testCompositionEntityNode.js +153 -0
- package/engine/ecs/parent/testHuDPerf.js +123 -0
- package/engine/ecs/storage/binary/BinaryClassUpgrader.js +1 -0
- package/engine/ecs/team/Team.js +82 -0
- package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
- package/engine/ecs/terrain/ecs/Terrain.js +14 -5
- 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/ecs/util/removeComponentsExcept.js +3 -3
- package/engine/graphics/GraphicsEngine.js +4 -5
- package/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
- package/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +1 -1
- package/engine/graphics/ecs/light/LightSystem.js +1 -1
- package/engine/graphics/ecs/mesh/Mesh.js +5 -5
- package/engine/graphics/ecs/mesh/MeshSystem.js +12 -20
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +29 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +158 -1
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/engine/graphics/ecs/trail2d/Trail2D.js +35 -1
- package/engine/graphics/ecs/trail2d/Trail2DSystem.js +26 -19
- package/engine/graphics/ecs/trail2d/makeGradientTrail.js +68 -0
- package/engine/graphics/ecs/water/WaterSystem.js +1 -1
- package/engine/graphics/ecs/water2/shader/testWaterShader.js +1 -1
- package/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +55 -11
- package/engine/graphics/micron/convert_three_object_to_micron.js +24 -7
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +107 -4
- package/engine/graphics/micron/plugin/serialization/BufferGeometrySerializationAdapter.js +176 -0
- package/engine/graphics/micron/render/v1/MaterialContext.js +1 -0
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +19 -3
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +3 -6
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -4
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +3 -1
- package/engine/graphics/render/frame_graph/FrameGraphBuilder.js +36 -0
- package/engine/graphics/render/frame_graph/IRenderContext.js +8 -0
- package/engine/graphics/render/frame_graph/RenderPass.js +32 -0
- package/engine/graphics/render/frame_graph/RenderPassFlags.js +6 -0
- package/engine/graphics/render/frame_graph/RenderPassResources.js +15 -0
- package/engine/graphics/render/frame_graph/Resource.js +21 -0
- package/engine/graphics/render/frame_graph/ResourceReference.js +14 -0
- package/engine/graphics/render/frame_graph/TextureDescriptor.js +30 -0
- package/engine/graphics/render/frame_graph/UsageModeType.js +5 -0
- package/engine/graphics/render/frame_graph/sample/deferred/GBufferDrawPass.js +27 -0
- package/engine/graphics/render/frame_graph/sample/deferred/PresentPass.js +17 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
- package/engine/graphics/render/webgpu/sample/MeshInstance.js +99 -0
- package/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +71 -0
- package/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +39 -0
- package/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +21 -0
- package/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +41 -0
- package/engine/graphics/render/webgpu/sample/main.js +604 -0
- package/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +9 -0
- package/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +30 -0
- package/engine/graphics/shadows/ShadowMapRenderer.js +10 -4
- package/engine/graphics/shadows/testShadowMapRendering.js +0 -2
- package/engine/graphics/texture/sampler/Sampler2D.js +24 -45
- package/engine/{ecs/grid → graphics/texture/sampler}/sampler2DToFloat32Texture.js +1 -1
- 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/intelligence/behavior/ecs/WaitForEventBehavior.js +3 -0
- package/engine/save/storage/IndexedDBStorage.js +8 -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 +117 -0
- package/util/ScreenGridPicker.js +3 -0
- package/view/minimap/Minimap.js +1 -1
- package/engine/ecs/sockets/AttachmentSocketsSystem.js +0 -10
|
@@ -19,7 +19,6 @@ import { CrossOriginKind } from "../CORS/CrossOriginKind.js";
|
|
|
19
19
|
import { computeObjectBoundingSphere } from "./gltf/computeObjectBoundingSphere.js";
|
|
20
20
|
import { isMesh } from "./gltf/isMesh.js";
|
|
21
21
|
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
22
|
-
import { convert_three_object_to_micron } from "../../graphics/micron/convert_three_object_to_micron.js";
|
|
23
22
|
import { HashSet } from "../../../core/collection/HashSet.js";
|
|
24
23
|
import { computeGeometryHash } from "./geometry/geometry/computeGeometryHash.js";
|
|
25
24
|
import { computeGeometryEquality } from "./geometry/geometry/computeGeometryEquality.js";
|
|
@@ -173,11 +172,20 @@ export class GLTFAssetLoader extends AssetLoader {
|
|
|
173
172
|
this.loader = loader;
|
|
174
173
|
|
|
175
174
|
/**
|
|
176
|
-
*
|
|
175
|
+
* Asset optimization flag
|
|
176
|
+
* Whether or not geometry de-duping should be done
|
|
177
177
|
* @type {boolean}
|
|
178
178
|
* @private
|
|
179
179
|
*/
|
|
180
|
-
this.
|
|
180
|
+
this.__enable_geometry_cache = false;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Asset optimization flag
|
|
184
|
+
* Whether or not texture de-duping should be done
|
|
185
|
+
* @type {boolean}
|
|
186
|
+
* @private
|
|
187
|
+
*/
|
|
188
|
+
this.__enable_texture_cache = false;
|
|
181
189
|
|
|
182
190
|
/**
|
|
183
191
|
*
|
|
@@ -216,7 +224,7 @@ export class GLTFAssetLoader extends AssetLoader {
|
|
|
216
224
|
* @param {boolean} v
|
|
217
225
|
*/
|
|
218
226
|
set is_micron_enabled(v) {
|
|
219
|
-
|
|
227
|
+
console.warn('Deprecated. Handled by the MicronRenderPlugin. Remove usage, no further action required');
|
|
220
228
|
}
|
|
221
229
|
|
|
222
230
|
/**
|
|
@@ -224,7 +232,7 @@ export class GLTFAssetLoader extends AssetLoader {
|
|
|
224
232
|
* @returns {boolean}
|
|
225
233
|
*/
|
|
226
234
|
get is_micron_enabled() {
|
|
227
|
-
|
|
235
|
+
throw new Error('Deprecated. Handled by the MicronRenderPlugin. Remove usage, no further action required. To check for presence of micron, check plugins instead.');
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
async link(assetManager, engine) {
|
|
@@ -275,14 +283,15 @@ export class GLTFAssetLoader extends AssetLoader {
|
|
|
275
283
|
alphaTest: object.material.alphaTest
|
|
276
284
|
});
|
|
277
285
|
|
|
278
|
-
|
|
286
|
+
if (this.__enable_texture_cache) {
|
|
287
|
+
object.customDepthMaterial = materialCache.acquire(depthMaterial);
|
|
288
|
+
}
|
|
279
289
|
}
|
|
280
290
|
}
|
|
281
291
|
|
|
282
292
|
|
|
283
293
|
load(path, success, failure, progress) {
|
|
284
294
|
const loader = this.loader;
|
|
285
|
-
const geometry_cache = this.__geometry_cache;
|
|
286
295
|
const texture_cache = this.__texture_cache;
|
|
287
296
|
|
|
288
297
|
|
|
@@ -290,19 +299,24 @@ export class GLTFAssetLoader extends AssetLoader {
|
|
|
290
299
|
*
|
|
291
300
|
* @param {THREE.Mesh|THREE.SkinnedMesh} mesh
|
|
292
301
|
*/
|
|
293
|
-
async
|
|
302
|
+
const processMesh = async (mesh) => {
|
|
294
303
|
let geometry = mesh.geometry;
|
|
295
304
|
|
|
296
305
|
if (geometry === undefined) {
|
|
297
306
|
throw new Error(`No geometry found`);
|
|
298
307
|
}
|
|
299
308
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
309
|
+
if (this.__enable_geometry_cache) {
|
|
310
|
+
// replace geometry
|
|
311
|
+
geometry = this.__geometry_cache.ensure(geometry);
|
|
312
|
+
mesh.geometry = geometry;
|
|
313
|
+
}
|
|
314
|
+
|
|
303
315
|
|
|
304
|
-
|
|
305
|
-
|
|
316
|
+
if (this.__enable_texture_cache) {
|
|
317
|
+
// replace textures from cache
|
|
318
|
+
replace_material_textures_from_cache(mesh.material, texture_cache);
|
|
319
|
+
}
|
|
306
320
|
|
|
307
321
|
const isSkinned = mesh.isSkinnedMesh === true;
|
|
308
322
|
|
|
@@ -431,18 +445,6 @@ export class GLTFAssetLoader extends AssetLoader {
|
|
|
431
445
|
asset.animations = animations;
|
|
432
446
|
}
|
|
433
447
|
|
|
434
|
-
// build micron mesh
|
|
435
|
-
if (
|
|
436
|
-
this.__enable_micron
|
|
437
|
-
&& (asset.animations === undefined || asset.animations.length === 0)
|
|
438
|
-
) {
|
|
439
|
-
// TODO deal with animations
|
|
440
|
-
const micron_root = await convert_three_object_to_micron(root.clone());
|
|
441
|
-
micron_root.boundingSphere = root.boundingSphere;
|
|
442
|
-
|
|
443
|
-
asset.micron = micron_root;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
448
|
success(asset);
|
|
447
449
|
}, function (xhr) {
|
|
448
450
|
//dispatch progress callback
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
|
|
2
2
|
import { assert } from "../../../../core/assert.js";
|
|
3
|
-
import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqualStrict.js";
|
|
4
3
|
import { bitmap2sampler_gl } from "./bitmap2sampler_gl.js";
|
|
4
|
+
import { fastArrayEquals } from "../../../../core/collection/array/fastArrayEquals.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -114,5 +114,5 @@ export function computeImageBitmapEquality(a, b) {
|
|
|
114
114
|
|
|
115
115
|
const b_s = obtainSampler(b, ctx);
|
|
116
116
|
|
|
117
|
-
return
|
|
117
|
+
return fastArrayEquals(a_s.data, b_s.data);
|
|
118
118
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computeImageBitmapEquality } from "./computeImageBitmapEquality.js";
|
|
2
|
-
import {
|
|
2
|
+
import { fastArrayEquals } from "../../../../core/collection/array/fastArrayEquals.js";
|
|
3
3
|
|
|
4
4
|
//
|
|
5
5
|
|
|
@@ -184,5 +184,5 @@ function textureMipmapEqual(a, b) {
|
|
|
184
184
|
return true;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
return
|
|
187
|
+
return fastArrayEquals(aData, bData);
|
|
188
188
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { max2 } from "../../../../core/math/max2.js";
|
|
2
1
|
import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
|
|
3
2
|
import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
|
|
4
3
|
import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
|
|
4
|
+
import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -59,6 +59,7 @@ export function computeImageDataHash(image) {
|
|
|
59
59
|
*/
|
|
60
60
|
function computeSpecificHash(texture) {
|
|
61
61
|
let dataHash = 0;
|
|
62
|
+
let i;
|
|
62
63
|
|
|
63
64
|
if (texture.image !== null && texture.image !== undefined) {
|
|
64
65
|
|
|
@@ -73,25 +74,18 @@ function computeSpecificHash(texture) {
|
|
|
73
74
|
if (Array.isArray(mipmaps)) {
|
|
74
75
|
const nMipmaps = mipmaps.length;
|
|
75
76
|
|
|
76
|
-
for (
|
|
77
|
+
for (i = 0; i < nMipmaps; i++) {
|
|
77
78
|
const mipmap = mipmaps[i];
|
|
78
79
|
|
|
79
|
-
if (mipmap.width > 16) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
80
|
const data = mipmap.data;
|
|
84
|
-
|
|
85
81
|
const dataSize = data.length;
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for (let i = 0; i < dataSize; i += dataStride) {
|
|
90
|
-
const datum = data[i];
|
|
91
|
-
|
|
92
|
-
dataHash = ((dataHash << 5) - dataHash) + datum;
|
|
83
|
+
if (dataSize > 1024) {
|
|
84
|
+
continue;
|
|
93
85
|
}
|
|
94
86
|
|
|
87
|
+
dataHash = ((dataHash << 5) - dataHash) + murmur3_32(data, 1337);
|
|
88
|
+
|
|
95
89
|
break;
|
|
96
90
|
}
|
|
97
91
|
|
|
@@ -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 {
|
|
@@ -6,7 +6,6 @@ import { assert } from "../../../core/assert.js";
|
|
|
6
6
|
import Mesh from "../../graphics/ecs/mesh/Mesh.js";
|
|
7
7
|
import { BoneAttachmentBinding } from "./BoneAttachmentBinding.js";
|
|
8
8
|
import { TransformAttachmentBinding } from "./TransformAttachmentBinding.js";
|
|
9
|
-
import { MeshSystem } from "../../graphics/ecs/mesh/MeshSystem.js";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* @readonly
|
|
@@ -318,10 +317,10 @@ export class AttachmentSystem extends System {
|
|
|
318
317
|
|
|
319
318
|
/**
|
|
320
319
|
*
|
|
321
|
-
* @param {Mesh} mesh
|
|
322
320
|
* @param {number} entity
|
|
321
|
+
* @private
|
|
323
322
|
*/
|
|
324
|
-
|
|
323
|
+
__update_entity(entity) {
|
|
325
324
|
const bindings = this.parentBindingIndex.get(entity);
|
|
326
325
|
|
|
327
326
|
if (bindings !== undefined) {
|
|
@@ -335,25 +334,27 @@ export class AttachmentSystem extends System {
|
|
|
335
334
|
}
|
|
336
335
|
}
|
|
337
336
|
|
|
337
|
+
/**
|
|
338
|
+
*
|
|
339
|
+
* @param {Mesh} mesh
|
|
340
|
+
* @param {number} entity
|
|
341
|
+
*/
|
|
342
|
+
visitComponent(mesh, entity) {
|
|
343
|
+
this.__update_entity(entity);
|
|
344
|
+
}
|
|
345
|
+
|
|
338
346
|
update(timeDelta) {
|
|
339
347
|
//process wait queue
|
|
340
348
|
this.processWaiting();
|
|
341
349
|
|
|
342
|
-
|
|
343
|
-
*
|
|
344
|
-
* @type {MeshSystem}
|
|
345
|
-
*/
|
|
346
|
-
const meshSystem = this.entityManager.getSystem(MeshSystem);
|
|
350
|
+
const em = this.entityManager;
|
|
347
351
|
|
|
348
|
-
|
|
352
|
+
const ecd = em.dataset;
|
|
349
353
|
|
|
350
|
-
|
|
351
|
-
|
|
354
|
+
if (ecd === null) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
352
357
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
* @param {AttachmentBinding} binding
|
|
356
|
-
*/
|
|
357
|
-
function updateBinding(binding) {
|
|
358
|
-
binding.update();
|
|
358
|
+
ecd.traverseComponents(Attachment, this.visitComponent, this);
|
|
359
|
+
}
|
|
359
360
|
}
|
|
@@ -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
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Sampler2D } from '../../graphics/texture/sampler/Sampler2D.js';
|
|
6
6
|
import NormalMapShader from '../../graphics/shaders/NormalMapShader2.js';
|
|
7
7
|
import ImageFilter from '../../graphics/filter/ImageFilter.js';
|
|
8
|
-
import { sampler2DtoFloat32Texture } from "
|
|
8
|
+
import { sampler2DtoFloat32Texture } from "../../graphics/texture/sampler/sampler2DToFloat32Texture.js";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
function convertChannel(v) {
|
|
@@ -9,7 +9,7 @@ import sampler2D2Texture from '../../graphics/texture/sampler/Sampler2D2Texture.
|
|
|
9
9
|
import AmbientOcclusionShader from '../../graphics/shaders/AmbientOcclusionShader.js';
|
|
10
10
|
import GaussianBlurShader from '../../graphics/shaders/GaussianBlurShader.js';
|
|
11
11
|
import ImageFilter from '../../graphics/filter/ImageFilter.js';
|
|
12
|
-
import { sampler2DtoFloat32Texture } from "
|
|
12
|
+
import { sampler2DtoFloat32Texture } from "../../graphics/texture/sampler/sampler2DToFloat32Texture.js";
|
|
13
13
|
|
|
14
14
|
function filterResult2Texture(data, width, height) {
|
|
15
15
|
const result = new DataTexture();
|
|
@@ -6,23 +6,15 @@
|
|
|
6
6
|
import { System } from '../../System.js';
|
|
7
7
|
import HeadsUpDisplay from './HeadsUpDisplay.js';
|
|
8
8
|
import { Transform } from '../../transform/Transform.js';
|
|
9
|
-
|
|
10
|
-
import { Matrix4 } from 'three';
|
|
11
9
|
import { GraphicsEngine } from "../../../graphics/GraphicsEngine.js";
|
|
12
10
|
import { FogOfWarVisibilityPredicate } from "../../fow/FogOfWarVisibilityPredicate.js";
|
|
13
|
-
import Vector4 from "../../../../core/geom/Vector4.js";
|
|
14
11
|
import ViewportPosition from "../position/ViewportPosition.js";
|
|
15
12
|
import GUIElement from "../GUIElement.js";
|
|
16
13
|
import { HeadsUpDisplayFlag } from "./HeadsUpDisplayFlag.js";
|
|
14
|
+
import { mat4 } from "gl-matrix";
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* @type {Vector4}
|
|
21
|
-
*/
|
|
22
|
-
const v4 = new Vector4();
|
|
23
|
-
const projectionMatrix = new Matrix4();
|
|
16
|
+
const projection = new Float32Array(16);
|
|
24
17
|
|
|
25
|
-
const up = new Vector4();
|
|
26
18
|
|
|
27
19
|
/**
|
|
28
20
|
*
|
|
@@ -77,7 +69,7 @@ class HeadsUpDisplaySystem extends System {
|
|
|
77
69
|
}
|
|
78
70
|
|
|
79
71
|
/**
|
|
80
|
-
*
|
|
72
|
+
* NOTE: for the sake of speed all of the matrix and vector multiplications have been inlined, readability of this method is pretty bad
|
|
81
73
|
* @param {HeadsUpDisplay} hud
|
|
82
74
|
* @param {Transform} transform
|
|
83
75
|
* @param {ViewportPosition} vp
|
|
@@ -87,48 +79,69 @@ class HeadsUpDisplaySystem extends System {
|
|
|
87
79
|
__apply_entity_transformation(hud, transform, vp, element) {
|
|
88
80
|
const worldOffset = hud.worldOffset;
|
|
89
81
|
|
|
90
|
-
let
|
|
91
|
-
let
|
|
92
|
-
let
|
|
93
|
-
|
|
94
|
-
v4.set(
|
|
95
|
-
worldOffsetX,
|
|
96
|
-
worldOffsetY,
|
|
97
|
-
worldOffsetZ,
|
|
98
|
-
1
|
|
99
|
-
);
|
|
82
|
+
let x = worldOffset.x;
|
|
83
|
+
let y = worldOffset.y;
|
|
84
|
+
let z = worldOffset.z;
|
|
100
85
|
|
|
101
86
|
if (hud.getFlag(HeadsUpDisplayFlag.TransformWorldOffset)) {
|
|
102
87
|
//apply scale and rotation
|
|
88
|
+
const transform_scale = transform.scale;
|
|
89
|
+
|
|
90
|
+
x *= transform_scale.x;
|
|
91
|
+
y *= transform_scale.y;
|
|
92
|
+
z *= transform_scale.y;
|
|
103
93
|
|
|
104
|
-
|
|
94
|
+
const q = transform.rotation;
|
|
95
|
+
|
|
96
|
+
const qx = q.x;
|
|
97
|
+
const qy = q.y;
|
|
98
|
+
const qz = q.z;
|
|
99
|
+
const qw = q.w;
|
|
100
|
+
|
|
101
|
+
// calculate quat * vec
|
|
102
|
+
const ix = qw * x + qy * z - qz * y;
|
|
103
|
+
const iy = qw * y + qz * x - qx * z;
|
|
104
|
+
const iz = qw * z + qx * y - qy * x;
|
|
105
|
+
const iw = -qx * x - qy * y - qz * z;
|
|
106
|
+
|
|
107
|
+
// calculate result * inverse quat
|
|
108
|
+
x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
|
|
109
|
+
y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
|
110
|
+
z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
|
105
111
|
|
|
106
|
-
v4.applyQuaternion(transform.rotation);
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
// add transform position to get final world position
|
|
109
115
|
const position = transform.position;
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const worldPositionY = v4.y;
|
|
115
|
-
const worldPositionZ = v4.z;
|
|
117
|
+
x += position.x;
|
|
118
|
+
y += position.y;
|
|
119
|
+
z += position.z;
|
|
116
120
|
|
|
121
|
+
const worldPositionX = x;
|
|
122
|
+
const worldPositionY = y;
|
|
123
|
+
const worldPositionZ = z;
|
|
117
124
|
|
|
118
125
|
// Convert the [-1, 1] screen coordinate into a world coordinate on the near plane
|
|
119
|
-
v4.threeApplyMatrix4(projectionMatrix);
|
|
120
126
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
// apply projection matrix
|
|
128
|
+
const _x = projection[0] * x + projection[4] * y + projection[8] * z + projection[12];
|
|
129
|
+
const _y = projection[1] * x + projection[5] * y + projection[9] * z + projection[13];
|
|
130
|
+
const _z = projection[2] * x + projection[6] * y + projection[10] * z + projection[14];
|
|
131
|
+
const _w = projection[3] * x + projection[7] * y + projection[11] * z + projection[15];
|
|
132
|
+
|
|
133
|
+
// apply perspective transform
|
|
134
|
+
const d = 1 / Math.abs(_w);
|
|
135
|
+
x = _x * d;
|
|
136
|
+
y = _y * d;
|
|
137
|
+
z = _z * d;
|
|
125
138
|
|
|
126
|
-
const ndcX = (
|
|
127
|
-
const ndcY = (1 -
|
|
139
|
+
const ndcX = (x + 1) / 2;
|
|
140
|
+
const ndcY = (1 - y) / 2;
|
|
128
141
|
|
|
129
142
|
vp.position.set(ndcX, ndcY);
|
|
130
143
|
|
|
131
|
-
const trackedPositionOutOfBounds =
|
|
144
|
+
const trackedPositionOutOfBounds = z > 1 || z < -1;
|
|
132
145
|
|
|
133
146
|
const visible = (!trackedPositionOutOfBounds || vp.stickToScreenEdge) && this.__visibility_predicate.test(worldPositionX, worldPositionY, worldPositionZ);
|
|
134
147
|
|
|
@@ -141,18 +154,20 @@ class HeadsUpDisplaySystem extends System {
|
|
|
141
154
|
if (hud.getFlag(HeadsUpDisplayFlag.PerspectiveRotation)) {
|
|
142
155
|
//compute rotation in screen-space
|
|
143
156
|
|
|
144
|
-
|
|
145
|
-
|
|
157
|
+
const w_y_1 = worldPositionY + 1;
|
|
158
|
+
|
|
159
|
+
const _up_x = projection[0] * worldPositionX + projection[4] * w_y_1 + projection[8] * worldPositionZ + projection[12];
|
|
160
|
+
const _up_y = projection[1] * worldPositionX + projection[5] * w_y_1 + projection[9] * worldPositionZ + projection[13];
|
|
161
|
+
const _up_w = projection[3] * worldPositionX + projection[7] * w_y_1 + projection[11] * worldPositionZ + projection[15];
|
|
146
162
|
|
|
147
163
|
// compute perspective divide
|
|
148
|
-
const d = 1 / Math.abs(
|
|
164
|
+
const d = 1 / Math.abs(_up_w);
|
|
149
165
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
up.z *= d;
|
|
166
|
+
const up_x = _up_x * d;
|
|
167
|
+
const up_y = _up_y * d;
|
|
153
168
|
|
|
154
|
-
const up_ndcX = (
|
|
155
|
-
const up_ndcY = (1 -
|
|
169
|
+
const up_ndcX = (up_x + 1) / 2;
|
|
170
|
+
const up_ndcY = (1 - up_y) / 2;
|
|
156
171
|
|
|
157
172
|
const angle = Math.atan2(up_ndcY - ndcY, up_ndcX - ndcX);
|
|
158
173
|
|
|
@@ -176,7 +191,7 @@ class HeadsUpDisplaySystem extends System {
|
|
|
176
191
|
*/
|
|
177
192
|
const camera = this.graphics.camera;
|
|
178
193
|
|
|
179
|
-
|
|
194
|
+
mat4.multiply(projection, camera.projectionMatrix.elements, camera.matrixWorldInverse.elements);
|
|
180
195
|
|
|
181
196
|
const visibilityPredicate = this.__visibility_predicate;
|
|
182
197
|
|
|
@@ -5,7 +5,6 @@ import { System } from '../../System.js';
|
|
|
5
5
|
import ViewportPosition from './ViewportPosition.js';
|
|
6
6
|
import GUIElement from "../GUIElement.js";
|
|
7
7
|
import { assert } from "../../../../core/assert.js";
|
|
8
|
-
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
9
8
|
import { SignalBinding } from "../../../../core/events/signal/SignalBinding.js";
|
|
10
9
|
import { EPSILON } from "../../../../core/math/MathUtils.js";
|
|
11
10
|
import AABB2 from "../../../../core/geom/AABB2.js";
|
|
@@ -202,8 +201,9 @@ function setElementPosition(view, bounds, viewportSize, vp) {
|
|
|
202
201
|
if (vp.stickToScreenEdge) {
|
|
203
202
|
|
|
204
203
|
|
|
205
|
-
const
|
|
206
|
-
const
|
|
204
|
+
const screenEdgeWidth = vp.screenEdgeWidth;
|
|
205
|
+
const clipEdgeX = screenEdgeWidth / viewportSize.x;
|
|
206
|
+
const clipEdgeY = screenEdgeWidth / viewportSize.y;
|
|
207
207
|
|
|
208
208
|
|
|
209
209
|
stickyBounds.set(clipEdgeX, clipEdgeY, 1 - clipEdgeX, 1 - clipEdgeY);
|
|
@@ -241,8 +241,8 @@ function setElementPosition(view, bounds, viewportSize, vp) {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
|
|
244
|
-
const targetX =
|
|
245
|
-
const targetY =
|
|
244
|
+
const targetX = x * (viewportSize.x);
|
|
245
|
+
const targetY = y * (viewportSize.y);
|
|
246
246
|
|
|
247
247
|
const viewPosition = view.position;
|
|
248
248
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import EntityBuilder from "../EntityBuilder";
|
|
2
|
+
import {EntityComponentDataset} from "../EntityComponentDataset";
|
|
3
|
+
import {Transform} from "../transform/Transform";
|
|
4
|
+
|
|
5
|
+
export class EntityNode {
|
|
6
|
+
constructor(entity?: EntityBuilder)
|
|
7
|
+
|
|
8
|
+
parent: EntityNode | null
|
|
9
|
+
entity: EntityBuilder
|
|
10
|
+
|
|
11
|
+
transform: Transform
|
|
12
|
+
|
|
13
|
+
addChild(node: EntityNode): boolean
|
|
14
|
+
|
|
15
|
+
removeChild(node: EntityNode): boolean
|
|
16
|
+
|
|
17
|
+
build(ecd: EntityComponentDataset): void
|
|
18
|
+
|
|
19
|
+
destroy(): void
|
|
20
|
+
}
|