@woosh/meep-engine 2.50.3 → 2.52.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/NumberFormat.js +0 -71
- 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 +58 -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/bvh3/query/BVHQueryAny.js +16 -0
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +5 -5
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -3
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +22 -0
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +64 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +2 -3
- package/src/core/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/geom/3d/aabb/aabb3_from_threejs_geometry.js +41 -0
- package/src/core/geom/3d/topology/struct/TopoMesh.js +3 -2
- package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +4 -4
- package/src/core/geom/Vector2.d.ts +9 -0
- package/src/core/geom/Vector2.js +8 -22
- package/src/core/geom/Vector2.spec.js +153 -0
- package/src/core/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/model/ModuleRegistry.js +2 -4
- package/src/core/model/ModuleRegistry.spec.js +31 -0
- package/src/core/model/reactive/js/compileReactiveToJS.spec.js +14 -0
- package/src/core/model/reactive/model/logic/ReactiveAnd.spec.js +31 -1
- package/src/core/model/reactive/model/logic/ReactiveOr.spec.js +53 -0
- package/src/core/model/stat/LinearModifier.js +2 -2
- package/src/core/model/stat/LinearModifier.spec.js +62 -0
- package/src/core/model/stat/Stat.js +12 -0
- package/src/core/model/stat/Stat.spec.js +36 -0
- package/src/core/primitives/array/computeStridedIntegerArrayHash.spec.js +28 -0
- package/src/core/primitives/numbers/number_format_by_thousands.js +14 -0
- package/src/core/primitives/numbers/number_pretty_print.js +49 -0
- package/src/core/primitives/strings/computeStringHash.spec.js +12 -5
- package/src/core/process/BaseProcess.js +8 -8
- package/src/engine/Clock.js +30 -29
- package/src/engine/Clock.spec.js +26 -0
- package/src/engine/{Platform.js → browserInfo.js} +1 -5
- package/src/engine/ecs/EntityBuilder.js +3 -1
- package/src/engine/ecs/EntityBuilder.spec.js +21 -0
- package/src/engine/ecs/fow/FogOfWar.js +48 -54
- package/src/engine/ecs/gui/GUIElement.js +1 -1
- package/src/engine/ecs/gui/position/ViewportPosition.js +3 -3
- 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/terrain/ecs/TerrainClassifier.js +1 -1
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +3 -3
- 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/ecs/transform/Transform.js +1 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
- 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/animation/animator/graph/AnimationGraph.spec.js +5 -0
- package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +24 -25
- package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.spec.js +5 -0
- package/src/engine/graphics/ecs/decal/DecalSystem.js +3 -21
- package/src/engine/graphics/ecs/decal/v2/Decal.js +32 -32
- package/src/engine/graphics/ecs/decal/v2/Decal.spec.js +5 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +4 -2
- package/src/engine/graphics/ecs/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/mesh-v2/ShadedGeometry.js +4 -33
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +8 -4
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.spec.js +5 -0
- package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +0 -12
- package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.js +2 -2
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -4
- package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +0 -2
- package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +1 -1
- package/src/engine/graphics/geometry/optimization/merge/prototypeGeometryMerge.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -3
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -4
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -5
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -6
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +4 -4
- package/src/engine/graphics/shaders/SoftOutlineShader.js +2 -4
- package/src/engine/graphics/shadows/testShadowMapRendering.js +0 -2
- 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/Sampler2D.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 +46 -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/grid/components/GridObstacle.js +45 -25
- package/src/engine/grid/components/GridObstacle.spec.js +130 -1
- package/src/engine/grid/components/GridPosition.js +5 -17
- package/src/engine/grid/components/GridPosition2Transform.js +1 -70
- package/src/engine/grid/components/GridPosition2TransformSerializationAdapter.js +70 -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/plugin/EnginePlugin.js +12 -14
- package/src/engine/plugin/EnginePlugin.spec.js +5 -0
- package/src/engine/plugin/EnginePluginManager.js +18 -22
- package/src/engine/scene/transitionToScene.js +12 -1
- package/src/engine/simulation/Ticker.js +1 -1
- package/src/engine/sound/ecs/SoundListenerSystem.js +1 -1
- package/src/generation/markers/debug/visualizeMarkers.js +1 -1
- package/src/generation/theme/TerrainLayerDescription.js +1 -1
- package/src/view/common/LabelView.js +3 -3
- 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/AimController.js +0 -18
- package/src/engine/ecs/components/Attacker.js +0 -13
- package/src/engine/ecs/components/MeshCollider.js +0 -15
- package/src/engine/ecs/components/RangedAttack.js +0 -12
- package/src/engine/ecs/components/Renderable.d.ts +0 -14
- package/src/engine/ecs/components/TargetAI.js +0 -11
- package/src/engine/ecs/components/ViewportMeshProjection.js +0 -18
- 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/ecs/systems/AimControllerSystem.js +0 -63
- package/src/engine/ecs/systems/AttackerSystem.js +0 -67
- package/src/engine/ecs/systems/MeshColliderSystem.js +0 -47
- package/src/engine/ecs/systems/MonsterAISystem.js +0 -163
- package/src/engine/ecs/systems/MortalitySystem.js +0 -46
- package/src/engine/ecs/systems/RangedAttackSystem.js +0 -132
- package/src/engine/ecs/systems/SerializationMetadataSystem.js +0 -10
- package/src/engine/ecs/systems/TargetAISystem.js +0 -107
- package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +0 -68
- package/src/engine/graphics/particles/ParticleEmitterLibrary.js +0 -87
- package/src/engine/graphics/texture/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/grid/components/ViewportGridProjection.js +0 -20
- package/src/engine/grid/systems/GridObstacleSystem.js +0 -58
- package/src/engine/grid/systems/ViewportGridProjectionSystem.js +0 -105
- package/src/engine/navigation/grid/GridField.js +0 -328
- /package/src/{engine → core/primitives/array}/computeStridedIntegerArrayHash.js +0 -0
- /package/src/engine/ecs/{components → renderable}/RenderableFlags.js +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import GridField from "../../../src/engine/navigation/grid/GridField.js";
|
|
2
1
|
import GridObstacle from "../../../src/engine/grid/components/GridObstacle.js";
|
|
3
2
|
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
4
3
|
|
|
@@ -16,31 +15,27 @@ class WriteGridValueAction extends Action {
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
async apply(editor) {
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @type {Engine}
|
|
20
|
+
*/
|
|
21
|
+
const engine = editor.engine;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @type {GridObstacle}
|
|
26
|
+
*/
|
|
27
|
+
const obstacle = engine.entityManager.dataset.getComponent(this.entity, GridObstacle);
|
|
20
28
|
this.obstacle = obstacle;
|
|
21
29
|
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.oldValue = gridField.read(this.x, this.y);
|
|
26
|
-
gridField.pointSet(this.x, this.y, this.value);
|
|
31
|
+
this.oldValue = obstacle.readPoint(this.x, this.y);
|
|
32
|
+
obstacle.writePoint(this.x, this.y, this.value);
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
async revert(editor) {
|
|
30
|
-
const gridField = obstacle2grid(this.obstacle);
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
this.obstacle.writePoint(this.x, this.y, this.oldValue);
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
function obstacle2grid(obstacle) {
|
|
37
|
-
const gridField = new GridField();
|
|
38
|
-
|
|
39
|
-
gridField.width = obstacle.size.x;
|
|
40
|
-
gridField.height = obstacle.size.y;
|
|
41
|
-
gridField.data = obstacle.data;
|
|
42
|
-
|
|
43
|
-
return gridField;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
export default WriteGridValueAction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TypeEditor } from "../TypeEditor.js";
|
|
2
2
|
import { CanvasView } from "../../../../src/view/elements/CanvasView.js";
|
|
3
3
|
import sampler2D2Canvas from "../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
4
|
-
import {
|
|
4
|
+
import { sampler2d_scale } from "../../../../src/engine/graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
5
5
|
import { Sampler2D } from "../../../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
6
6
|
import {
|
|
7
7
|
typedArrayConstructorByInstance
|
|
@@ -38,7 +38,7 @@ function draw_sampler(sampler, domElement) {
|
|
|
38
38
|
const res = 32;
|
|
39
39
|
const result_sampler = new Sampler2D(new TypedArrayConstructor(sampler.itemSize * res * res), sampler.itemSize, res, res);
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
sampler2d_scale(sampler, result_sampler);
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
const { scale, offset } = sampler2d_compute_texel_value_conversion_scale_to_uint8(result_sampler);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EditorProcess } from "./EditorProcess.js";
|
|
2
2
|
import { ParticleEmitter } from "../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js";
|
|
3
|
-
import RenderSystem from "../../src/engine/ecs/
|
|
3
|
+
import RenderSystem from "../../src/engine/ecs/renderable/RenderSystem.js";
|
|
4
4
|
import { Camera } from "../../src/engine/graphics/ecs/camera/Camera.js";
|
|
5
5
|
import { Light } from "../../src/engine/graphics/ecs/light/Light.js";
|
|
6
6
|
import { ComponentSymbolicDisplay } from "./symbolic/ComponentSymbolicDisplay.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EntityBuilder from "../../../src/engine/ecs/EntityBuilder.js";
|
|
2
|
-
import Renderable from "../../../src/engine/ecs/
|
|
2
|
+
import Renderable from "../../../src/engine/ecs/renderable/Renderable.js";
|
|
3
3
|
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
4
4
|
import EditorEntity from "../../ecs/EditorEntity.js";
|
|
5
5
|
import Script from "../../../src/engine/ecs/components/Script.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
2
2
|
import { CameraHelper } from "three";
|
|
3
3
|
import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
|
|
4
|
-
import Renderable from "../../../src/engine/ecs/
|
|
4
|
+
import Renderable from "../../../src/engine/ecs/renderable/Renderable.js";
|
|
5
5
|
import { Camera } from "../../../src/engine/graphics/ecs/camera/Camera.js";
|
|
6
6
|
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
7
7
|
|
|
@@ -4,7 +4,7 @@ import Task from "../../../src/core/process/task/Task.js";
|
|
|
4
4
|
import { TaskSignal } from "../../../src/core/process/task/TaskSignal.js";
|
|
5
5
|
import EntityBuilder from "../../../src/engine/ecs/EntityBuilder.js";
|
|
6
6
|
import { BufferGeometry, Float32BufferAttribute, Line, LineBasicMaterial } from "three";
|
|
7
|
-
import Renderable from "../../../src/engine/ecs/
|
|
7
|
+
import Renderable from "../../../src/engine/ecs/renderable/Renderable.js";
|
|
8
8
|
import { SurfacePoint3 } from "../../../src/core/geom/3d/SurfacePoint3.js";
|
|
9
9
|
import Vector3 from "../../../src/core/geom/Vector3.js";
|
|
10
10
|
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
@@ -2,7 +2,7 @@ import { Light } from "../../../src/engine/graphics/ecs/light/Light.js";
|
|
|
2
2
|
import { DirectionalLightHelper, PointLightHelper, SpotLightHelper } from "three";
|
|
3
3
|
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
4
4
|
import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
|
|
5
|
-
import Renderable from "../../../src/engine/ecs/
|
|
5
|
+
import Renderable from "../../../src/engine/ecs/renderable/Renderable.js";
|
|
6
6
|
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BufferGeometry, Float32BufferAttribute, Group, Line, LineBasicMaterial } from "three";
|
|
2
2
|
import Vector3 from "../../../src/core/geom/Vector3.js";
|
|
3
3
|
import { min2 } from "../../../src/core/math/min2.js";
|
|
4
|
-
import Renderable from "../../../src/engine/ecs/
|
|
4
|
+
import Renderable from "../../../src/engine/ecs/renderable/Renderable.js";
|
|
5
5
|
import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
|
|
6
6
|
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
7
7
|
import Path from "../../../src/engine/navigation/ecs/components/Path.js";
|
|
@@ -2,7 +2,7 @@ import { assert } from "../../../src/core/assert.js";
|
|
|
2
2
|
import { Sprite, SpriteMaterial } from "three";
|
|
3
3
|
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
4
4
|
import EntityBuilder from "../../../src/engine/ecs/EntityBuilder.js";
|
|
5
|
-
import Renderable from "../../../src/engine/ecs/
|
|
5
|
+
import Renderable from "../../../src/engine/ecs/renderable/Renderable.js";
|
|
6
6
|
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
7
7
|
import { synchronizeTransform } from "./synchronizeTransform.js";
|
|
8
8
|
|
|
@@ -4,7 +4,7 @@ import { CanvasView } from "../../../../src/view/elements/CanvasView.js";
|
|
|
4
4
|
import DatGuiController from "./DatGuiController.js";
|
|
5
5
|
import convertSampler2D2Canvas from "../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
6
6
|
import { Sampler2D } from "../../../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
7
|
-
import {
|
|
7
|
+
import { sampler2d_scale } from "../../../../src/engine/graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
8
8
|
import Vector2 from "../../../../src/core/geom/Vector2.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -17,7 +17,7 @@ export function buildGridObstaclePreview(grid, canvas) {
|
|
|
17
17
|
|
|
18
18
|
const target = Sampler2D.uint8(1, canvas.width, canvas.height);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
sampler2d_scale(source, target);
|
|
21
21
|
|
|
22
22
|
convertSampler2D2Canvas(target, 255, 0, canvas);
|
|
23
23
|
}
|
|
@@ -7,7 +7,7 @@ import CheckersTextureURI from "../../../../src/engine/graphics/texture/Checkers
|
|
|
7
7
|
import EmptyView from "../../../../src/view/elements/EmptyView.js";
|
|
8
8
|
import convertSampler2D2Canvas from "../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
9
9
|
import { CanvasView } from "../../../../src/view/elements/CanvasView.js";
|
|
10
|
-
import {
|
|
10
|
+
import { sampler2d_scale } from "../../../../src/engine/graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
11
11
|
import { Sampler2D } from "../../../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
12
12
|
import Signal from "../../../../src/core/events/signal/Signal.js";
|
|
13
13
|
import Vector2Control from "../../../../src/view/controller/controls/Vector2Control.js";
|
|
@@ -93,7 +93,7 @@ class LayersController extends View {
|
|
|
93
93
|
|
|
94
94
|
function update() {
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
sampler2d_scale(layer.diffuse, t);
|
|
97
97
|
|
|
98
98
|
convertSampler2D2Canvas(t, 1, 0, vCanvas.el);
|
|
99
99
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.j
|
|
|
11
11
|
import { Cache } from "../../src/core/cache/Cache.js";
|
|
12
12
|
import { computeStringHash } from "../../src/core/primitives/strings/computeStringHash.js";
|
|
13
13
|
import { noop, strictEquals } from "../../src/core/function/Functions.js";
|
|
14
|
-
import {
|
|
14
|
+
import { sampler2d_scale } from "../../src/engine/graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
15
15
|
import { Sampler2D } from "../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
16
16
|
import { BinaryDataType } from "../../src/core/binary/type/BinaryDataType.js";
|
|
17
17
|
import {
|
|
@@ -205,7 +205,7 @@ function makeTerrainEditor(root, terrain, engine) {
|
|
|
205
205
|
|
|
206
206
|
const preview = Sampler2D.uint8(4, PREVIEW_SIZE, PREVIEW_SIZE);
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
sampler2d_scale(source, preview);
|
|
209
209
|
|
|
210
210
|
PREVIEW_CACHE.put(url, preview);
|
|
211
211
|
|
package/src/core/NumberFormat.js
CHANGED
|
@@ -2,74 +2,3 @@
|
|
|
2
2
|
* Created by Alex on 08/08/2016.
|
|
3
3
|
* @copyright Alex Goldring 2016
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { assert } from "./assert.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {number} x
|
|
12
|
-
* @param {string} [separator]
|
|
13
|
-
* @returns {string}
|
|
14
|
-
*/
|
|
15
|
-
function formatNumberByThousands(x, separator) {
|
|
16
|
-
if (separator === undefined) {
|
|
17
|
-
separator = ','
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, separator);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {string} value
|
|
27
|
-
* @returns {number}
|
|
28
|
-
*/
|
|
29
|
-
function countDecimals(value) {
|
|
30
|
-
if (value % 1 === 0) {
|
|
31
|
-
//whole number
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
const s = value.toString();
|
|
35
|
-
const index = s.indexOf('.');
|
|
36
|
-
|
|
37
|
-
if (index === -1) {
|
|
38
|
-
return 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//find last 0
|
|
42
|
-
let endIndex = s.length - 1;
|
|
43
|
-
for (; endIndex > index && s.charAt(endIndex) === "0"; endIndex--) {
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
const result = endIndex - index;
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param {number} value
|
|
53
|
-
* @returns {string|number}
|
|
54
|
-
*/
|
|
55
|
-
function prettyPrint(value) {
|
|
56
|
-
assert.typeOf(value, 'number', 'value');
|
|
57
|
-
|
|
58
|
-
const MAX_DECIMALS = 2;
|
|
59
|
-
|
|
60
|
-
const fraction = value % 1;
|
|
61
|
-
if (fraction !== 0 && Math.abs(value) < 100) {
|
|
62
|
-
const decimals = countDecimals(value.toFixed(MAX_DECIMALS));
|
|
63
|
-
const decimalsToPrint = Math.min(decimals, MAX_DECIMALS);
|
|
64
|
-
return value.toFixed(decimalsToPrint);
|
|
65
|
-
} else {
|
|
66
|
-
//no fraction
|
|
67
|
-
return formatNumberByThousands(value - fraction, ",");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export {
|
|
73
|
-
prettyPrint,
|
|
74
|
-
formatNumberByThousands
|
|
75
|
-
};
|
|
@@ -11,6 +11,8 @@ export class ExplicitBinaryBoundingVolumeHierarchy {
|
|
|
11
11
|
|
|
12
12
|
remove_leaf(node: number): void
|
|
13
13
|
|
|
14
|
+
node_is_leaf(node: number): boolean
|
|
15
|
+
|
|
14
16
|
collect_nodes_all(destination: ArrayLike<number>, destination_offset: number): void
|
|
15
17
|
|
|
16
18
|
node_set_aabb_primitive(node_id: number, x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void
|
|
@@ -39,6 +41,8 @@ export class ExplicitBinaryBoundingVolumeHierarchy {
|
|
|
39
41
|
|
|
40
42
|
node_get_height(node: number): number
|
|
41
43
|
|
|
44
|
+
node_move_aabb(node: number, new_aabb: ArrayLike<number>): void
|
|
45
|
+
|
|
42
46
|
swap_nodes(node_a_id: number, node_b_id: number): boolean
|
|
43
47
|
|
|
44
48
|
release_all(): void
|
|
@@ -54,65 +54,67 @@ const INITIAL_CAPACITY = 128;
|
|
|
54
54
|
/**
|
|
55
55
|
* Bounding Volume Hierarchy implementation. Stores unsigned integer values at leaves, these are typically IDs or Index values.
|
|
56
56
|
* Highly optimized both in terms of memory usage and CPU. Most of the code inlined. No allocation are performed during usage (except for growing the tree capacity).
|
|
57
|
-
* RAM usage: 40 bytes per node. Compared with V8s per-object allocation size of 80 bytes
|
|
57
|
+
* RAM usage: 40 bytes per node. Compared with V8s per-object allocation size of 80 bytes
|
|
58
|
+
* @see https://blog.dashlane.com/how-is-data-stored-in-v8-js-engine-memory
|
|
59
|
+
* @class
|
|
58
60
|
*/
|
|
59
61
|
export class ExplicitBinaryBoundingVolumeHierarchy {
|
|
60
|
-
constructor() {
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
* @type {ArrayBuffer}
|
|
64
|
-
* @private
|
|
65
|
-
*/
|
|
66
|
-
this.__data_buffer = new ArrayBuffer(INITIAL_CAPACITY * ELEMENT_WORD_COUNT * 4);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* @type {Float32Array}
|
|
71
|
-
* @private
|
|
72
|
-
*/
|
|
73
|
-
this.__data_float32 = new Float32Array(this.__data_buffer);
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
* @type {Uint32Array}
|
|
78
|
-
* @private
|
|
79
|
-
*/
|
|
80
|
-
this.__data_uint32 = new Uint32Array(this.__data_buffer);
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* How many nodes are currently reserved, this will grow automatically through {@link #allocate_node} method usage
|
|
84
|
-
* @type {number}
|
|
85
|
-
* @private
|
|
86
|
-
*/
|
|
87
|
-
this.__capacity = INITIAL_CAPACITY;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Number of used nodes. These are either live nodes, or node sitting in the {@link #__free} pool
|
|
91
|
-
* @type {number}
|
|
92
|
-
* @private
|
|
93
|
-
*/
|
|
94
|
-
this.__size = 0;
|
|
95
62
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Pointer into __free array that's used as a stack, so this pointer represents top of the stack
|
|
104
|
-
* @type {number}
|
|
105
|
-
* @private
|
|
106
|
-
*/
|
|
107
|
-
this.__free_pointer = 0;
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @type {ArrayBuffer}
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
__data_buffer = new ArrayBuffer(INITIAL_CAPACITY * ELEMENT_WORD_COUNT * 4);
|
|
108
69
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @type {Float32Array}
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
__data_float32 = new Float32Array(this.__data_buffer);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @type {Uint32Array}
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
__data_uint32 = new Uint32Array(this.__data_buffer);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* How many nodes are currently reserved, this will grow automatically through {@link #allocate_node} method usage
|
|
86
|
+
* @type {number}
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
__capacity = INITIAL_CAPACITY;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Number of used nodes. These are either live nodes, or node sitting in the {@link #__free} pool
|
|
93
|
+
* @type {number}
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
__size = 0;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Indices of released nodes. Nodes are pulled from here first if available, before the whole tree gets resized
|
|
100
|
+
* @type {number[]}
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
__free = [];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Pointer into __free array that's used as a stack, so this pointer represents top of the stack
|
|
107
|
+
* @type {number}
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
__free_pointer = 0;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Root node of the hierarchy
|
|
114
|
+
* @type {number}
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
__root = NULL_NODE;
|
|
116
118
|
|
|
117
119
|
/**
|
|
118
120
|
*
|
|
@@ -581,6 +583,7 @@ export class ExplicitBinaryBoundingVolumeHierarchy {
|
|
|
581
583
|
*/
|
|
582
584
|
insert_leaf(leaf) {
|
|
583
585
|
assert.isNonNegativeInteger(leaf, 'leaf');
|
|
586
|
+
assert.equal(this.node_is_leaf(leaf), true, 'not is not a leaf');
|
|
584
587
|
|
|
585
588
|
let uint32 = this.__data_uint32;
|
|
586
589
|
|
|
@@ -248,3 +248,57 @@ test("swap two detached nodes", () => {
|
|
|
248
248
|
expect(bvh.node_get_user_data(a)).toBe(11);
|
|
249
249
|
expect(bvh.node_get_user_data(b)).toBe(7);
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
test("setting capacity", () => {
|
|
253
|
+
const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
254
|
+
|
|
255
|
+
bvh.node_capacity = 3;
|
|
256
|
+
|
|
257
|
+
expect(bvh.node_capacity).toEqual(3);
|
|
258
|
+
|
|
259
|
+
bvh.node_capacity = 3;
|
|
260
|
+
|
|
261
|
+
expect(bvh.node_capacity).toEqual(3);
|
|
262
|
+
|
|
263
|
+
bvh.node_capacity = 0;
|
|
264
|
+
|
|
265
|
+
expect(bvh.node_capacity).toEqual(0);
|
|
266
|
+
|
|
267
|
+
bvh.allocate_node();
|
|
268
|
+
|
|
269
|
+
bvh.node_capacity = 3;
|
|
270
|
+
|
|
271
|
+
expect(bvh.node_capacity).toEqual(3);
|
|
272
|
+
|
|
273
|
+
bvh.node_capacity = 1;
|
|
274
|
+
|
|
275
|
+
expect(bvh.node_capacity).toEqual(1);
|
|
276
|
+
|
|
277
|
+
expect(() => bvh.node_capacity = 0).toThrow();
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test("move leaf node", () => {
|
|
281
|
+
const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
282
|
+
|
|
283
|
+
const a = bvh.allocate_node();
|
|
284
|
+
const b = bvh.allocate_node();
|
|
285
|
+
|
|
286
|
+
bvh.node_set_aabb(a, [-1.1, -1.2, -1.3, 2.1, 2.2, 2.3]);
|
|
287
|
+
bvh.node_set_aabb(b, [3.1, 3.2, 3.2, 5.1, 5.2, 5.2]);
|
|
288
|
+
|
|
289
|
+
bvh.insert_leaf(a);
|
|
290
|
+
bvh.insert_leaf(b);
|
|
291
|
+
|
|
292
|
+
// convert to float32 and back to account for rounding errors when checking results
|
|
293
|
+
const a_new_bounds = Array.from(new Float32Array([
|
|
294
|
+
7.1, 7.2, 7.3,
|
|
295
|
+
11.1, 11.2, 11.3
|
|
296
|
+
]));
|
|
297
|
+
|
|
298
|
+
bvh.node_move_aabb(a, a_new_bounds);
|
|
299
|
+
|
|
300
|
+
const actual_bounds = [];
|
|
301
|
+
bvh.node_get_aabb(a, actual_bounds);
|
|
302
|
+
|
|
303
|
+
expect(actual_bounds).toEqual(a_new_bounds);
|
|
304
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AABB3 } from "
|
|
1
|
+
import { AABB3 } from "../../geom/3d/aabb/AABB3.js";
|
|
2
2
|
import { aabb3_from_v3_array } from "../../geom/3d/aabb/aabb3_from_v3_array.js";
|
|
3
3
|
import morton from "../../geom/3d/morton/Morton.js";
|
|
4
4
|
import { arrayQuickSort } from "../../collection/array/arrayQuickSort.js";
|
|
@@ -37,14 +37,14 @@ export function ebvh_build_for_geometry_morton(bvh, index_array, position_array)
|
|
|
37
37
|
// allocate nodes
|
|
38
38
|
const tri_count = index_array.length / 3;
|
|
39
39
|
const node_leaf_count = tri_count;
|
|
40
|
-
const node_bin_count =
|
|
40
|
+
const node_bin_count = max2(0, node_leaf_count - 1);
|
|
41
41
|
|
|
42
42
|
const node_total_count = node_leaf_count + node_bin_count;
|
|
43
43
|
|
|
44
44
|
const nodes = new Uint32Array(node_total_count);
|
|
45
45
|
|
|
46
46
|
// skip allocation calls, allocate exactly as many nodes as we need
|
|
47
|
-
bvh.
|
|
47
|
+
bvh.node_capacity = node_total_count;
|
|
48
48
|
bvh.__size = node_total_count;
|
|
49
49
|
|
|
50
50
|
for (let i = 0; i < node_total_count; i++) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ebvh_build_for_geometry_morton } from "./ebvh_build_for_geometry_morton.js";
|
|
2
|
+
import { ExplicitBinaryBoundingVolumeHierarchy, NULL_NODE } from "./ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
3
|
+
|
|
4
|
+
test("sanity check with 1 triangle", () => {
|
|
5
|
+
|
|
6
|
+
const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
7
|
+
|
|
8
|
+
ebvh_build_for_geometry_morton(bvh, [0, 1, 2], [
|
|
9
|
+
0, 1, 3,
|
|
10
|
+
13, 17, 19,
|
|
11
|
+
5, 7, 11
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
expect(bvh.root).not.toEqual(NULL_NODE);
|
|
15
|
+
|
|
16
|
+
const actual_bounds = [];
|
|
17
|
+
bvh.node_get_aabb(bvh.root, actual_bounds);
|
|
18
|
+
|
|
19
|
+
expect(actual_bounds).toEqual(
|
|
20
|
+
Array.from(new Float32Array([
|
|
21
|
+
0, 1, 3,
|
|
22
|
+
13, 17, 19
|
|
23
|
+
]))
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// check that first and only node has out triangle index stored
|
|
27
|
+
expect(bvh.node_is_leaf(bvh.root)).toEqual(true);
|
|
28
|
+
expect(bvh.node_get_user_data(bvh.root)).toEqual(0);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("sanity check with 2 triangles", () => {
|
|
32
|
+
const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
33
|
+
|
|
34
|
+
ebvh_build_for_geometry_morton(
|
|
35
|
+
bvh,
|
|
36
|
+
[
|
|
37
|
+
0, 0, 0,
|
|
38
|
+
1, 1, 1
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
0, 1, 3,
|
|
42
|
+
5, 7, 11
|
|
43
|
+
]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(bvh.root).not.toEqual(NULL_NODE);
|
|
47
|
+
|
|
48
|
+
const actual_bounds = [];
|
|
49
|
+
bvh.node_get_aabb(bvh.root, actual_bounds);
|
|
50
|
+
|
|
51
|
+
expect(actual_bounds).toEqual(
|
|
52
|
+
Array.from(new Float32Array([
|
|
53
|
+
0, 1, 3,
|
|
54
|
+
5, 7, 11
|
|
55
|
+
]))
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// check that first and only node has out triangle index stored
|
|
59
|
+
expect(bvh.node_is_leaf(bvh.root)).toEqual(false);
|
|
60
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BVHQuery } from "./BVHQuery.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Accept any node
|
|
5
|
+
*/
|
|
6
|
+
export class BVHQueryAny extends BVHQuery {
|
|
7
|
+
evaluate(node, tree) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @readonly
|
|
13
|
+
* @type {BVHQueryAny}
|
|
14
|
+
*/
|
|
15
|
+
static INSTANCE = new BVHQueryAny();
|
|
16
|
+
}
|
|
@@ -10,15 +10,15 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
|
10
10
|
* @param {number[]} destination
|
|
11
11
|
* @param {number} destination_offset
|
|
12
12
|
* @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
|
|
13
|
-
* @param {number}
|
|
13
|
+
* @param {number} root
|
|
14
14
|
* @returns {number} number of collected elements
|
|
15
15
|
*/
|
|
16
16
|
export function bvh_collect_user_data(
|
|
17
17
|
destination, destination_offset,
|
|
18
|
-
bvh,
|
|
18
|
+
bvh, root
|
|
19
19
|
) {
|
|
20
20
|
|
|
21
|
-
if (
|
|
21
|
+
if (root === NULL_NODE) {
|
|
22
22
|
return 0;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ export function bvh_collect_user_data(
|
|
|
28
28
|
*/
|
|
29
29
|
const stack_top = stack.pointer++;
|
|
30
30
|
|
|
31
|
-
stack[stack_top] =
|
|
31
|
+
stack[stack_top] = root;
|
|
32
32
|
|
|
33
33
|
let result_cursor = destination_offset;
|
|
34
34
|
|
|
@@ -54,7 +54,7 @@ export function bvh_collect_user_data(
|
|
|
54
54
|
stack[stack.pointer++] = child2;
|
|
55
55
|
|
|
56
56
|
} else {
|
|
57
|
-
// leaf
|
|
57
|
+
// leaf root
|
|
58
58
|
|
|
59
59
|
destination[result_cursor++] = bvh.node_get_user_data(node);
|
|
60
60
|
}
|
|
@@ -8,16 +8,15 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
|
8
8
|
* @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
|
|
9
9
|
* @param {number[]} result
|
|
10
10
|
* @param {number} result_offset
|
|
11
|
+
* @param {number} root
|
|
11
12
|
* @param {BVHQuery} query
|
|
12
13
|
* @returns {number}
|
|
13
14
|
*/
|
|
14
15
|
export function bvh_query_leaves_generic(
|
|
15
16
|
result, result_offset,
|
|
16
|
-
bvh, query
|
|
17
|
+
bvh, root, query
|
|
17
18
|
) {
|
|
18
19
|
|
|
19
|
-
const root = bvh.root;
|
|
20
|
-
|
|
21
20
|
if (root === NULL_NODE) {
|
|
22
21
|
return 0;
|
|
23
22
|
}
|