@woosh/meep-engine 2.33.23 → 2.33.27
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/binary/BitSet.js +151 -167
- package/core/binary/BitSet.spec.js +99 -1
- package/core/binary/ValidatingBitSetWrapper.js +81 -0
- package/core/bvh2/BinaryNode.js +1 -1
- package/core/bvh2/aabb3/AABB3.js +21 -10
- package/core/bvh2/aabb3/AABB3Math.js +1 -1
- package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
- package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
- package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
- package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
- package/core/bvh2/traversal/__detailed_box_volume_intersection.js +22 -5
- package/core/cache/Cache.d.ts +4 -2
- package/core/cache/Cache.js +5 -2
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/HashMap.d.ts +9 -2
- package/core/collection/HashSet.d.ts +7 -2
- package/core/collection/HashSet.js +7 -2
- package/core/collection/array/arrayQuickSort.js +9 -6
- package/core/collection/array/array_swap.js +22 -0
- package/core/collection/array/binarySearchHighIndex.js +1 -1
- package/core/collection/array/computeHashArray.js +22 -0
- package/core/collection/array/computeHashIntegerArray.js +15 -0
- package/core/collection/array/copyArray.js +2 -2
- package/core/collection/array/typed/typed_array_copy.js +1 -1
- package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
- package/core/color/Color.js +2 -1
- package/core/function/FunctionCompiler.js +2 -1
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
- package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +3 -3
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
- package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
- package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
- package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
- package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
- package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
- package/core/geom/3d/shape/AbstractShape3D.js +65 -0
- package/core/geom/3d/shape/TransformedShape3D.js +181 -0
- package/core/geom/3d/shape/TransformedShape3D.spec.js +33 -0
- package/core/geom/3d/shape/UnionShape3D.js +255 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +101 -0
- package/core/geom/3d/shape/UnitCubeShape3D.spec.js +42 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +55 -0
- package/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.js +48 -0
- package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
- package/core/geom/AABB2.js +1 -1
- package/core/geom/ConicRay.js +3 -1
- package/core/geom/LineSegment.js +0 -78
- package/core/geom/Matrix4.js +7 -8
- package/core/geom/Rectangle.js +2 -1
- package/core/geom/Vector1.js +1 -1
- package/core/geom/Vector3.js +2 -1
- package/core/geom/Vector4.js +2 -1
- package/core/geom/random/randomPointInBox.js +7 -3
- package/core/geom/random/randomPointInPoint.js +6 -3
- package/core/geom/random/randomPointInSphere.js +9 -5
- package/core/geom/random/randomPointOnBox.js +7 -3
- package/core/geom/random/randomPointOnSphere.js +6 -3
- package/core/geom/v3_length.js +8 -3
- package/core/graph/graph_k_means_cluster.js +1 -1
- package/core/json/resolvePathByArray.js +2 -2
- package/core/math/MathUtils.js +0 -354
- package/core/math/MathUtils.spec.js +7 -1
- package/core/math/gaussian.js +9 -0
- package/core/math/hash/computeHashFloat.js +17 -0
- package/core/math/hash/computeHashFloatArray.js +34 -0
- package/core/math/hash/computeObjectHash.js +54 -0
- package/core/math/intersects1D.js +19 -0
- package/core/math/interval/NumericInterval.js +2 -2
- package/core/math/isValueBetween.js +10 -0
- package/core/math/isValueBetweenInclusive.js +10 -0
- package/core/math/noise/curl_noise_3dt.js +1 -1
- package/core/math/noise/sdnoise.js +10 -10
- package/core/math/overlap1D.js +19 -0
- package/core/math/pingpong.js +17 -0
- package/core/math/random/makeRangedRandom.js +19 -0
- package/core/math/random/randomFloatBetween.js +14 -0
- package/core/math/random/randomFromArray.js +19 -0
- package/core/math/random/randomGaussian.js +15 -0
- package/core/math/random/randomIntegerBetween.js +14 -0
- package/core/math/random/roundFair.js +15 -0
- package/core/math/separation1D.js +21 -0
- package/core/math/solveQuadratic.js +25 -0
- package/core/model/BoundedValue.js +1 -1
- package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
- package/core/model/node-graph/node/Port.js +1 -1
- package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
- package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
- package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
- package/core/model/stat/LinearModifier.js +1 -1
- package/core/parser/simple/Token.d.ts +13 -0
- package/core/parser/simple/Token.js +61 -27
- package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
- package/core/primitives/strings/insert_after_or_replace.js +27 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/tools/FoliagePaintTool.js +4 -4
- package/editor/view/ecs/EntityEditor.js +2 -2
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
- package/engine/EngineHarness.js +1 -0
- package/engine/animation/AnimationUtils.js +5 -5
- package/engine/animation/curve/AnimationCurve.js +72 -0
- package/engine/animation/curve/Keyframe.js +27 -0
- package/engine/animation/keyed2/AnimationTrack.js +27 -3
- package/engine/asset/Asset.js +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +62 -1
- package/engine/asset/loaders/image/ImageDecoderWorker.js +4 -3
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +10 -2
- package/engine/asset/loaders/image/ImageRGBADataLoader.js +3 -3
- package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
- package/engine/asset/loaders/image/png/PNG.js +113 -6
- package/engine/asset/loaders/image/png/PNGReader.js +5 -0
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +1 -1
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +6 -1
- package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
- package/engine/asset/loaders/material/computeTextureEquality.js +40 -49
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/EntityBuilder.js +25 -5
- package/engine/ecs/EntityComponentDataset.js +1 -1
- package/engine/ecs/animation/Animation.js +2 -1
- package/engine/ecs/animation/InverseKinematics.js +2 -1
- package/engine/ecs/attachment/AttachmentBinding.js +8 -0
- package/engine/ecs/attachment/AttachmentSystem.js +4 -0
- package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
- package/engine/ecs/components/Tag.js +27 -6
- package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
- package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
- package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
- package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
- package/engine/ecs/foliage/InstancedFoliage.js +277 -266
- package/engine/ecs/foliage/ecs/Foliage2System.js +7 -7
- package/engine/ecs/foliage/ecs/InstancedMeshComponent.js +37 -0
- package/engine/ecs/foliage/ecs/{Foliage2.js → InstancedMeshLayer.js} +3 -45
- package/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +6 -5
- package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +7 -6
- package/engine/ecs/fow/FogOfWar.js +4 -0
- package/engine/ecs/fow/FogOfWarSystem.js +2 -0
- package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
- package/engine/ecs/gui/GUIElement.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
- package/engine/ecs/gui/position/ViewportPosition.js +2 -1
- package/engine/ecs/storage/binary/BinarySerializationRegistry.js +1 -1
- package/engine/ecs/system/AbstractContextSystem.js +1 -1
- package/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/engine/ecs/systems/SteeringSystem.js +1 -1
- package/engine/ecs/systems/TagSystem.js +17 -0
- package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +12 -16
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
- package/engine/ecs/tooltip/TooltipComponent.js +15 -0
- package/engine/ecs/transform/Transform.js +19 -6
- package/engine/graphics/GraphicsEngine.js +11 -6
- package/engine/graphics/composit/CompositLayer.js +17 -4
- package/engine/graphics/composit/CompositingStages.js +8 -0
- package/engine/graphics/composit/LayerCompositer.js +35 -6
- package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
- package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
- package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
- package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
- package/engine/graphics/ecs/light/Light.d.ts +1 -1
- package/engine/graphics/ecs/light/Light.js +5 -0
- package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
- package/engine/graphics/ecs/mesh/Mesh.js +2 -1
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
- package/engine/graphics/geometry/AttributeSpec.js +105 -0
- package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +14 -72
- package/engine/graphics/geometry/instancing/rewriteMaterial.js +70 -0
- package/engine/graphics/material/manager/MaterialManager.js +2 -1
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
- package/engine/graphics/micron/buildPatchwork.js +1 -1
- package/engine/graphics/micron/format/MicronGeometry.js +3 -3
- package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
- package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +11 -9
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -2
- package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
- package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +8 -2
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +80 -16
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +71 -77
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +2 -1
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +141 -14
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +8 -7
- package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +1 -1
- package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
- package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
- package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
- package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
- package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +24 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -71
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +81 -48
- package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +478 -0
- package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +938 -0
- package/engine/graphics/particles/particular/group/Operation.js +18 -0
- package/engine/graphics/particles/particular/group/OperationType.js +9 -0
- package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
- package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
- package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
- package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
- package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
- package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
- package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
- package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
- package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +16 -11
- package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
- package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
- package/engine/graphics/render/forward_plus/LightManager.js +117 -94
- package/engine/graphics/render/forward_plus/PointLight.js +9 -0
- package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
- package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
- package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
- package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
- package/engine/graphics/render/forward_plus/materials/FPlusDebugMaterial.js +3 -3
- package/engine/graphics/render/forward_plus/materials/ForwardPlusThreeMaterial.js +1 -1
- package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +594 -59
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +208 -89
- package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
- package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
- package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
- package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +74 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
- package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
- package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
- package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/engine/graphics/shaders/TerrainShader.js +4 -5
- package/engine/graphics/shadows/ShadowMapRenderer.js +8 -2
- package/engine/graphics/texture/atlas/ManagedTextureAtlas.js +12 -1
- package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
- package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +3 -1
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +1 -1
- package/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +66 -0
- package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
- package/engine/graphics/util/composeMatrix4.js +33 -23
- package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
- package/engine/grid/components/GridObstacle.js +1 -1
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
- package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
- package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
- package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
- package/engine/navigation/ecs/components/Path.js +1 -6
- package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
- package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
- package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
- package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
- package/engine/ui/notification/notificationGenerator.js +1 -1
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
- package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
- package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
- package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
- package/generation/theme/ThemeEngine.js +1 -1
- package/misc/makeMaterialIconCached.js +2 -2
- package/package.json +1 -1
- package/view/elements/image/HTMLElementCacheKey.js +2 -1
- package/view/elements/radial/RadialText.js +2 -1
- package/view/minimap/gl/MinimapMarkersGL.js +6 -100
- package/view/minimap/gl/MinimapWorldGL.js +12 -5
- package/view/minimap/gl/buildMaterial.js +94 -0
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
- package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -357
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Color,
|
|
3
|
-
GridHelper,
|
|
4
2
|
Group,
|
|
5
3
|
HemisphereLight,
|
|
6
4
|
Line,
|
|
7
5
|
LineBasicMaterial,
|
|
8
6
|
Mesh,
|
|
7
|
+
MeshBasicMaterial,
|
|
8
|
+
OctahedronBufferGeometry,
|
|
9
9
|
PerspectiveCamera,
|
|
10
10
|
PlaneHelper,
|
|
11
11
|
Scene,
|
|
@@ -16,12 +16,11 @@ import {
|
|
|
16
16
|
import { min2 } from "../../../../core/math/min2.js";
|
|
17
17
|
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
18
18
|
import { PointLight } from "./PointLight.js";
|
|
19
|
-
import { randomFloatBetween } from "../../../../core/math/MathUtils.js";
|
|
20
19
|
import { makeHelperSphereGeometry } from "../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
|
|
21
20
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
22
21
|
import { MouseEvents } from "../../../input/devices/events/MouseEvents.js";
|
|
23
22
|
import { RingBuffer } from "../../../../core/collection/RingBuffer.js";
|
|
24
|
-
import {
|
|
23
|
+
import { query_bvh_frustum_from_objects } from "./query/query_bvh_frustum_from_objects.js";
|
|
25
24
|
import { prettyPrint } from "../../../../core/NumberFormat.js";
|
|
26
25
|
import { FPlusDebugMaterial } from "./materials/FPlusDebugMaterial.js";
|
|
27
26
|
import { parseColor } from "../../../../core/color/ColorUtils.js";
|
|
@@ -38,6 +37,13 @@ import Vector3 from "../../../../core/geom/Vector3.js";
|
|
|
38
37
|
import { MetricCollection } from "../../../development/performance/MetricCollection.js";
|
|
39
38
|
import { MetricStatistics } from "../../../development/performance/MetricStatistics.js";
|
|
40
39
|
import { SpotLight } from "./SpotLight.js";
|
|
40
|
+
import { randomFloatBetween } from "../../../../core/math/random/randomFloatBetween.js";
|
|
41
|
+
import Signal from "../../../../core/events/signal/Signal.js";
|
|
42
|
+
import SimplexNoise from "simplex-noise";
|
|
43
|
+
import Stats from "three/examples/jsm/libs/stats.module.js";
|
|
44
|
+
import { threeUpdateTransform } from "../../util/threeUpdateTransform.js";
|
|
45
|
+
|
|
46
|
+
const on_render = new Signal();
|
|
41
47
|
|
|
42
48
|
const lm = new LightManager();
|
|
43
49
|
|
|
@@ -45,7 +51,8 @@ const camera = new PerspectiveCamera(30);
|
|
|
45
51
|
camera.position.z = 1;
|
|
46
52
|
|
|
47
53
|
camera.layers.enable(3);
|
|
48
|
-
camera.layers.enable(
|
|
54
|
+
camera.layers.enable(4);
|
|
55
|
+
// camera.layers.enable(1);
|
|
49
56
|
|
|
50
57
|
camera.near = 1;
|
|
51
58
|
camera.far = 15;
|
|
@@ -56,14 +63,19 @@ camera.updateMatrixWorld(true);
|
|
|
56
63
|
|
|
57
64
|
// lm.setTileMapResolution(32,32,32);
|
|
58
65
|
lm.setTileMapResolution(24, 14, 8);
|
|
66
|
+
// lm.setTileMapResolution(16, 8, 10);
|
|
59
67
|
|
|
60
68
|
console.log(lm);
|
|
69
|
+
window.lights = lm;
|
|
61
70
|
|
|
62
71
|
const random = seededRandom(0);
|
|
63
72
|
|
|
64
73
|
const scene = new Scene();
|
|
74
|
+
scene.matrixAutoUpdate = false;
|
|
75
|
+
scene.autoUpdate = false;
|
|
65
76
|
|
|
66
|
-
const sphere_geometry =
|
|
77
|
+
const sphere_geometry = new OctahedronBufferGeometry(1, 2);
|
|
78
|
+
const sphere_geometry_shell = makeHelperSphereGeometry(1);
|
|
67
79
|
// const sphere_geometry = new SphereBufferGeometry(1, 8, 8);
|
|
68
80
|
|
|
69
81
|
// const directionalLight = new DirectionalLight(0xffffff, 0.7);
|
|
@@ -77,6 +89,7 @@ scene.add(new HemisphereLight("rgb(107,187,255)", "rgb(105,97,83)", 0.2));
|
|
|
77
89
|
|
|
78
90
|
|
|
79
91
|
const fp_materials = [];
|
|
92
|
+
const scratch_v2 = new Vector2();
|
|
80
93
|
|
|
81
94
|
function getFPStandard() {
|
|
82
95
|
const r = new FPlusStandardMaterial();
|
|
@@ -85,12 +98,6 @@ function getFPStandard() {
|
|
|
85
98
|
r.attach_lights(lm);
|
|
86
99
|
}
|
|
87
100
|
|
|
88
|
-
if (renderer !== undefined) {
|
|
89
|
-
|
|
90
|
-
renderer.getSize(
|
|
91
|
-
r.uniforms.resolution.value
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
101
|
|
|
95
102
|
fp_materials.push(r);
|
|
96
103
|
|
|
@@ -136,6 +143,10 @@ function addKnot(position, scale, rotation) {
|
|
|
136
143
|
group.add(mesh);
|
|
137
144
|
group.add(outline);
|
|
138
145
|
|
|
146
|
+
group.matrixAutoUpdate = false;
|
|
147
|
+
|
|
148
|
+
threeUpdateTransform(group);
|
|
149
|
+
|
|
139
150
|
scene.add(group);
|
|
140
151
|
}
|
|
141
152
|
|
|
@@ -165,18 +176,27 @@ function addSpotLight(position, direction, color, distance = 1, angle = 1, penum
|
|
|
165
176
|
lm.addLight(light);
|
|
166
177
|
}
|
|
167
178
|
|
|
179
|
+
const noise = new SimplexNoise(random);
|
|
180
|
+
|
|
168
181
|
/**
|
|
169
182
|
*
|
|
170
183
|
* @param {number[]} position
|
|
171
184
|
* @param {number} radius
|
|
172
185
|
* @param {string|number} color
|
|
173
186
|
* @param {number} intensity
|
|
187
|
+
* @param {boolean} wander
|
|
188
|
+
* @param {number} [wander_radius]
|
|
174
189
|
*/
|
|
175
|
-
function addPointLight(
|
|
190
|
+
function addPointLight({
|
|
191
|
+
position, radius, color, intensity = 1,
|
|
192
|
+
wander = false,
|
|
193
|
+
wander_radius = 5
|
|
194
|
+
}) {
|
|
176
195
|
|
|
177
196
|
const light = new PointLight();
|
|
178
197
|
|
|
179
|
-
light.position
|
|
198
|
+
const p = light.position;
|
|
199
|
+
p.set(
|
|
180
200
|
position[0],
|
|
181
201
|
position[1],
|
|
182
202
|
position[2],
|
|
@@ -199,23 +219,85 @@ function addPointLight(position, radius, color, intensity = 1) {
|
|
|
199
219
|
|
|
200
220
|
lm.addLight(light);
|
|
201
221
|
|
|
222
|
+
// outer shell
|
|
223
|
+
const visual_group = new Group();
|
|
224
|
+
|
|
225
|
+
const color_uint = light.color.toUint();
|
|
202
226
|
const sphere_material = new LineBasicMaterial({
|
|
203
227
|
depthTest: true,
|
|
204
228
|
depthWrite: false,
|
|
205
229
|
transparent: true,
|
|
206
230
|
linewidth: 1,
|
|
207
231
|
fog: false,
|
|
208
|
-
color:
|
|
232
|
+
color: color_uint,
|
|
209
233
|
opacity: min2(intensity, 1)
|
|
210
234
|
});
|
|
211
235
|
|
|
212
|
-
const mesh = new Line(
|
|
236
|
+
const mesh = new Line(sphere_geometry_shell, sphere_material);
|
|
213
237
|
|
|
214
238
|
mesh.layers.set(1);
|
|
215
|
-
mesh.position.set(light.position.x, light.position.y, light.position.z);
|
|
216
239
|
mesh.scale.setScalar(light.radius.getValue());
|
|
217
240
|
|
|
218
|
-
|
|
241
|
+
// center
|
|
242
|
+
const mesh_center_0 = new Mesh(sphere_geometry, new MeshBasicMaterial({
|
|
243
|
+
color: color_uint
|
|
244
|
+
}));
|
|
245
|
+
mesh_center_0.layers.disableAll();
|
|
246
|
+
mesh_center_0.layers.set(4);
|
|
247
|
+
mesh_center_0.scale.setScalar(0.02);
|
|
248
|
+
mesh_center_0.matrixAutoUpdate = false;
|
|
249
|
+
|
|
250
|
+
visual_group.add(mesh_center_0);
|
|
251
|
+
|
|
252
|
+
const mesh_center_1 = new Mesh(sphere_geometry, new MeshBasicMaterial({
|
|
253
|
+
color: color_uint,
|
|
254
|
+
transparent: true,
|
|
255
|
+
opacity: 0.033
|
|
256
|
+
}));
|
|
257
|
+
mesh_center_1.scale.setScalar(0.1);
|
|
258
|
+
mesh_center_1.layers.disableAll();
|
|
259
|
+
mesh_center_1.layers.set(4);
|
|
260
|
+
mesh_center_1.matrixAutoUpdate = false;
|
|
261
|
+
|
|
262
|
+
visual_group.add(mesh_center_1);
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
visual_group.add(mesh);
|
|
266
|
+
visual_group.position.set(p.x, p.y, p.z);
|
|
267
|
+
|
|
268
|
+
threeUpdateTransform(visual_group);
|
|
269
|
+
visual_group.matrixAutoUpdate = false;
|
|
270
|
+
|
|
271
|
+
scene.add(visual_group);
|
|
272
|
+
|
|
273
|
+
if (wander) {
|
|
274
|
+
const source_p_x = position[0];
|
|
275
|
+
const source_p_y = position[1];
|
|
276
|
+
const source_p_z = position[2];
|
|
277
|
+
|
|
278
|
+
on_render.add((renderer, camera, scene, time_delta, time) => {
|
|
279
|
+
|
|
280
|
+
const t = time * 0.0001;
|
|
281
|
+
|
|
282
|
+
const noise_x = noise.noise4D(source_p_x, source_p_y, source_p_z, t) * wander_radius;
|
|
283
|
+
const noise_y = noise.noise4D(source_p_x + 31.341, source_p_y - 43.23, source_p_z + 12.34, t) * wander_radius;
|
|
284
|
+
const noise_z = noise.noise4D(source_p_x - 231.141, source_p_y + 124.123, source_p_z - 54.4341, t) * wander_radius;
|
|
285
|
+
|
|
286
|
+
p.set(
|
|
287
|
+
source_p_x + noise_x,
|
|
288
|
+
source_p_y + noise_y,
|
|
289
|
+
source_p_z + noise_z,
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
visual_group.position.set(
|
|
293
|
+
p.x,
|
|
294
|
+
p.y,
|
|
295
|
+
p.z,
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
threeUpdateTransform(visual_group);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
219
301
|
}
|
|
220
302
|
|
|
221
303
|
const box_geometry = new TorusKnotBufferGeometry(1, 0.3, 128, 128);
|
|
@@ -235,26 +317,29 @@ function prepare_scene_0() {
|
|
|
235
317
|
|
|
236
318
|
const bounds_size = 15;
|
|
237
319
|
|
|
320
|
+
const light_radius = 5;
|
|
321
|
+
|
|
238
322
|
for (let i = 0; i < 5000; i++) {
|
|
239
|
-
const radius = randomFloatBetween(random,
|
|
323
|
+
const radius = randomFloatBetween(random, light_radius, light_radius);
|
|
240
324
|
const intensity = randomFloatBetween(random, 2, 2);
|
|
241
|
-
addPointLight(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
intensity
|
|
325
|
+
addPointLight({
|
|
326
|
+
position: [
|
|
327
|
+
randomFloatBetween(random, -bounds_size, bounds_size),
|
|
328
|
+
randomFloatBetween(random, -bounds_size, bounds_size),
|
|
329
|
+
randomFloatBetween(random, -bounds_size, bounds_size),
|
|
330
|
+
], radius: radius, color: `hsv(${random().toFixed(4)}, 0.8, 1)`, intensity: intensity
|
|
331
|
+
}
|
|
249
332
|
);
|
|
250
333
|
}
|
|
251
334
|
|
|
335
|
+
const bounds_size_2 = 15;
|
|
336
|
+
|
|
252
337
|
for (let i = 0; i < 500; i++) {
|
|
253
338
|
|
|
254
339
|
addKnot([
|
|
255
|
-
randomFloatBetween(random, -
|
|
256
|
-
randomFloatBetween(random, -
|
|
257
|
-
randomFloatBetween(random, -
|
|
340
|
+
randomFloatBetween(random, -bounds_size_2, bounds_size_2),
|
|
341
|
+
randomFloatBetween(random, -bounds_size_2, bounds_size_2),
|
|
342
|
+
randomFloatBetween(random, -bounds_size_2, bounds_size_2)
|
|
258
343
|
], 0.5, [
|
|
259
344
|
randomFloatBetween(random, 0, Math.PI),
|
|
260
345
|
randomFloatBetween(random, 0, Math.PI),
|
|
@@ -264,10 +349,11 @@ function prepare_scene_0() {
|
|
|
264
349
|
}
|
|
265
350
|
|
|
266
351
|
function prepare_scene_1() {
|
|
267
|
-
addPointLight(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
352
|
+
addPointLight({
|
|
353
|
+
position: [
|
|
354
|
+
0, 0, -3
|
|
355
|
+
], radius: 1, color: 0xFF0000
|
|
356
|
+
}
|
|
271
357
|
);
|
|
272
358
|
|
|
273
359
|
// tight planes around the light
|
|
@@ -279,10 +365,11 @@ function prepare_scene_1() {
|
|
|
279
365
|
}
|
|
280
366
|
|
|
281
367
|
function prepare_scene_3() {
|
|
282
|
-
addPointLight(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
368
|
+
addPointLight({
|
|
369
|
+
position: [
|
|
370
|
+
0, 0, -4
|
|
371
|
+
], radius: 1, color: 0xFF0000
|
|
372
|
+
}
|
|
286
373
|
);
|
|
287
374
|
|
|
288
375
|
// tight planes around the light
|
|
@@ -298,17 +385,17 @@ function prepare_scene_3() {
|
|
|
298
385
|
}
|
|
299
386
|
|
|
300
387
|
function prepare_scene_2() {
|
|
301
|
-
addPointLight(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
388
|
+
addPointLight({
|
|
389
|
+
position: [
|
|
390
|
+
1.5, 0, -4
|
|
391
|
+
], radius: 1.5, color: 0xFF0000, intensity: 1
|
|
392
|
+
}
|
|
306
393
|
);
|
|
307
|
-
addPointLight(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
394
|
+
addPointLight({
|
|
395
|
+
position: [
|
|
396
|
+
-1.5, 0, -4
|
|
397
|
+
], radius: 1.5, color: 0x00FF00, intensity: 1
|
|
398
|
+
}
|
|
312
399
|
);
|
|
313
400
|
|
|
314
401
|
addKnot([0, 0, -5], 1, [0, 0, 0]);
|
|
@@ -325,17 +412,17 @@ function prepare_scene_5() {
|
|
|
325
412
|
const offset = new Vector3(100, 100, 100);
|
|
326
413
|
|
|
327
414
|
|
|
328
|
-
addPointLight(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
415
|
+
addPointLight({
|
|
416
|
+
position: [
|
|
417
|
+
1.5 + offset.x, 0 + offset.y, -4 + offset.z
|
|
418
|
+
], radius: 1.5, color: 0xFF0000, intensity: 10
|
|
419
|
+
}
|
|
333
420
|
);
|
|
334
|
-
addPointLight(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
421
|
+
addPointLight({
|
|
422
|
+
position: [
|
|
423
|
+
-1.5 + offset.x, 0 + offset.y, -4 + offset.z
|
|
424
|
+
], radius: 1.5, color: 0x00FF00, intensity: 10
|
|
425
|
+
}
|
|
339
426
|
);
|
|
340
427
|
|
|
341
428
|
addKnot(
|
|
@@ -360,7 +447,7 @@ function prepare_scene_5() {
|
|
|
360
447
|
function addSponza() {
|
|
361
448
|
const loader = new GLTFLoader();
|
|
362
449
|
|
|
363
|
-
loader.load("data/models/sponza-pbr/sponza.glb", (gltf) => {
|
|
450
|
+
loader.load("data/models/sponza-pbr/gltf/sponza.glb", (gltf) => {
|
|
364
451
|
|
|
365
452
|
gltf.scene.traverse(m => {
|
|
366
453
|
if (m.isLight) {
|
|
@@ -388,6 +475,8 @@ function addSponza() {
|
|
|
388
475
|
|
|
389
476
|
});
|
|
390
477
|
|
|
478
|
+
threeUpdateTransform(m_0);
|
|
479
|
+
|
|
391
480
|
scene.add(m_0);
|
|
392
481
|
|
|
393
482
|
const m_1 = gltf.scene.clone(true);
|
|
@@ -400,6 +489,8 @@ function addSponza() {
|
|
|
400
489
|
|
|
401
490
|
});
|
|
402
491
|
|
|
492
|
+
threeUpdateTransform(m_1);
|
|
493
|
+
|
|
403
494
|
scene.add(m_1);
|
|
404
495
|
|
|
405
496
|
});
|
|
@@ -407,8 +498,8 @@ function addSponza() {
|
|
|
407
498
|
|
|
408
499
|
function prepare_scene_4() {
|
|
409
500
|
|
|
410
|
-
controls.target.set(2.1731179577352857,
|
|
411
|
-
camera.position.set(-
|
|
501
|
+
controls.target.set(2.1731179577352857, 2.4, -0.26);
|
|
502
|
+
camera.position.set(-8, 3.3, -0.26);
|
|
412
503
|
|
|
413
504
|
camera.near = 1;
|
|
414
505
|
camera.far = 50;
|
|
@@ -418,16 +509,19 @@ function prepare_scene_4() {
|
|
|
418
509
|
controls.update();
|
|
419
510
|
|
|
420
511
|
|
|
421
|
-
for (let i = 0; i <
|
|
512
|
+
for (let i = 0; i < 500; i++) {
|
|
422
513
|
const radius = randomFloatBetween(random, 2, 2);
|
|
423
|
-
addPointLight(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
514
|
+
addPointLight({
|
|
515
|
+
position: [
|
|
516
|
+
randomFloatBetween(random, -17, 17),
|
|
517
|
+
randomFloatBetween(random, -2, 13),
|
|
518
|
+
randomFloatBetween(random, -10, 10),
|
|
519
|
+
],
|
|
520
|
+
radius: radius,
|
|
521
|
+
color: `hsv(${random().toFixed(4)}, 0.8, 1)`,
|
|
522
|
+
intensity: randomFloatBetween(random, 6, 6),
|
|
523
|
+
wander: true
|
|
524
|
+
}
|
|
431
525
|
);
|
|
432
526
|
}
|
|
433
527
|
|
|
@@ -460,14 +554,13 @@ function prepare_scene_6() {
|
|
|
460
554
|
controls.update();
|
|
461
555
|
|
|
462
556
|
|
|
463
|
-
addPointLight(
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
3
|
|
557
|
+
addPointLight({
|
|
558
|
+
position: [
|
|
559
|
+
11,
|
|
560
|
+
1,
|
|
561
|
+
0,
|
|
562
|
+
], radius: 2, color: `hsv(0.5, 0.8, 1)`, intensity: 3
|
|
563
|
+
}
|
|
471
564
|
);
|
|
472
565
|
|
|
473
566
|
//
|
|
@@ -531,7 +624,7 @@ fp_materials.forEach(m => {
|
|
|
531
624
|
|
|
532
625
|
renderer.getSize(v2);
|
|
533
626
|
|
|
534
|
-
m.uniforms.
|
|
627
|
+
m.uniforms.fp_resolution.value.set(
|
|
535
628
|
v2.x * window.devicePixelRatio, v2.y * window.devicePixelRatio
|
|
536
629
|
);
|
|
537
630
|
|
|
@@ -541,8 +634,12 @@ camera.aspect = window.innerWidth / window.innerHeight;
|
|
|
541
634
|
camera.updateProjectionMatrix();
|
|
542
635
|
|
|
543
636
|
|
|
544
|
-
scene.add(new GridHelper());
|
|
545
|
-
scene.background = new Color(0x666666);
|
|
637
|
+
// scene.add(new GridHelper());
|
|
638
|
+
// scene.background = new Color(0x666666);
|
|
639
|
+
|
|
640
|
+
const stats = new Stats();
|
|
641
|
+
stats.dom.style.cssText = 'position:fixed;top:0;right:0;cursor:pointer;opacity:0.9;z-index:10000';
|
|
642
|
+
document.body.appendChild(stats.dom);
|
|
546
643
|
|
|
547
644
|
const controls = new OrbitControls(camera, renderer.domElement);
|
|
548
645
|
|
|
@@ -586,10 +683,17 @@ function animate() {
|
|
|
586
683
|
material_fp_standard.uniforms.fp_f_camera_near.value = camera.near;
|
|
587
684
|
material_fp_standard.uniforms.fp_f_camera_far.value = camera.far;
|
|
588
685
|
|
|
686
|
+
|
|
687
|
+
renderer.getSize(scratch_v2);
|
|
688
|
+
scratch_v2.multiplyScalar(renderer.getPixelRatio());
|
|
689
|
+
|
|
589
690
|
fp_materials.forEach(m => {
|
|
590
691
|
|
|
591
692
|
m.uniforms.fp_f_camera_near.value = camera.near;
|
|
592
693
|
m.uniforms.fp_f_camera_far.value = camera.far;
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
m.uniforms.fp_resolution.value.set(scratch_v2.x, scratch_v2.y);
|
|
593
697
|
});
|
|
594
698
|
|
|
595
699
|
lightClusterWidget.update();
|
|
@@ -597,7 +701,9 @@ function animate() {
|
|
|
597
701
|
|
|
598
702
|
renderer.render(scene, camera);
|
|
599
703
|
|
|
704
|
+
on_render.send6(renderer, camera, scene, time_delta, t);
|
|
600
705
|
|
|
706
|
+
stats.update();
|
|
601
707
|
}
|
|
602
708
|
|
|
603
709
|
const metrics = new MetricCollection();
|
|
@@ -628,20 +734,20 @@ function print_perf_stats() {
|
|
|
628
734
|
setInterval(print_perf_stats, 2000);
|
|
629
735
|
|
|
630
736
|
function do_sample() {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
737
|
+
query_bvh_frustum_from_objects.iteration_count = 0;
|
|
738
|
+
query_bvh_frustum_from_objects.rejection_count = 0;
|
|
739
|
+
query_bvh_frustum_from_objects.rejection_sphere_count = 0;
|
|
740
|
+
query_bvh_frustum_from_objects.plane_tests = 0;
|
|
741
|
+
query_bvh_frustum_from_objects.plane_tests_early_exits = 0;
|
|
636
742
|
|
|
637
743
|
const t0 = performance.now();
|
|
638
744
|
lm.buildTiles(camera);
|
|
639
745
|
const t1 = performance.now();
|
|
640
746
|
|
|
641
747
|
metrics.get("time").record(t1 - t0);
|
|
642
|
-
metrics.get("iterations").record(
|
|
643
|
-
metrics.get("rejections").record(
|
|
644
|
-
metrics.get("sphere_rejections").record(
|
|
748
|
+
metrics.get("iterations").record(query_bvh_frustum_from_objects.iteration_count);
|
|
749
|
+
metrics.get("rejections").record(query_bvh_frustum_from_objects.rejection_count);
|
|
750
|
+
metrics.get("sphere_rejections").record(query_bvh_frustum_from_objects.rejection_sphere_count);
|
|
645
751
|
}
|
|
646
752
|
|
|
647
753
|
function draw_camera_view_planes() {
|
|
@@ -714,3 +820,16 @@ document.body.appendChild(debugger_button.el);
|
|
|
714
820
|
const layerSwitcher = createLayerSwitcher(camera);
|
|
715
821
|
|
|
716
822
|
document.body.appendChild(layerSwitcher.domElement);
|
|
823
|
+
|
|
824
|
+
function onWindowResize() {
|
|
825
|
+
|
|
826
|
+
const w = window.innerWidth;
|
|
827
|
+
const h = window.innerHeight;
|
|
828
|
+
|
|
829
|
+
camera.aspect = w / h;
|
|
830
|
+
camera.updateProjectionMatrix();
|
|
831
|
+
|
|
832
|
+
renderer.setSize(w, h);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
window.addEventListener("resize", onWindowResize);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const _lut_array_buffer = new ArrayBuffer(84);
|
|
2
|
+
/**
|
|
3
|
+
* Mapping from 3 plane bitfield, corresponding to intersection point of the planes
|
|
4
|
+
* @type {number[]}
|
|
5
|
+
*/
|
|
6
|
+
export const triplanar_corner_mapping = new Uint8Array(_lut_array_buffer, 0, 43);
|
|
7
|
+
|
|
8
|
+
triplanar_corner_mapping[0b010101] = 0;
|
|
9
|
+
triplanar_corner_mapping[0b100101] = 1;
|
|
10
|
+
triplanar_corner_mapping[0b011001] = 2;
|
|
11
|
+
triplanar_corner_mapping[0b101001] = 3;
|
|
12
|
+
triplanar_corner_mapping[0b010110] = 4;
|
|
13
|
+
triplanar_corner_mapping[0b100110] = 5;
|
|
14
|
+
triplanar_corner_mapping[0b011010] = 6;
|
|
15
|
+
triplanar_corner_mapping[0b101010] = 7;
|
|
16
|
+
/**
|
|
17
|
+
* Mapping from 2 plane bitfield to 2 corner bitfield, corresponding to corner indices of intersecting planes
|
|
18
|
+
* @type {number[]}
|
|
19
|
+
*/
|
|
20
|
+
export const biplanar_edge_mapping = new Uint8Array(_lut_array_buffer, 43, 41);
|
|
21
|
+
|
|
22
|
+
biplanar_edge_mapping[0b000101] = 0 | (1 << 3);
|
|
23
|
+
biplanar_edge_mapping[0b000110] = 4 | (5 << 3);
|
|
24
|
+
|
|
25
|
+
biplanar_edge_mapping[0b001001] = 2 | (3 << 3);
|
|
26
|
+
biplanar_edge_mapping[0b001010] = 6 | (7 << 3);
|
|
27
|
+
|
|
28
|
+
biplanar_edge_mapping[0b010100] = 0 | (4 << 3);
|
|
29
|
+
biplanar_edge_mapping[0b011000] = 2 | (6 << 3);
|
|
30
|
+
|
|
31
|
+
biplanar_edge_mapping[0b100100] = 1 | (5 << 3);
|
|
32
|
+
biplanar_edge_mapping[0b101000] = 3 | (7 << 3);
|
|
33
|
+
|
|
34
|
+
biplanar_edge_mapping[0b010001] = 0 | (2 << 3);
|
|
35
|
+
biplanar_edge_mapping[0b010010] = 4 | (6 << 3);
|
|
36
|
+
|
|
37
|
+
biplanar_edge_mapping[0b100001] = 1 | (3 << 3);
|
|
38
|
+
biplanar_edge_mapping[0b100010] = 5 | (7 << 3);
|
package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { v3_distance_sqr } from "../../../../../core/geom/v3_distance_sqr.js";
|
|
2
|
+
import { biplanar_edge_mapping, triplanar_corner_mapping } from "./cube_mapping.js";
|
|
3
|
+
import { line3_computeSegmentPointDistance_sqr } from "../../../../../core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {number} radius
|
|
8
|
+
* @param {number} light_x
|
|
9
|
+
* @param {number} light_y
|
|
10
|
+
* @param {number} light_z
|
|
11
|
+
* @param {number} outside_plane_count
|
|
12
|
+
* @param {number} outside_plane_bitfield
|
|
13
|
+
* @param {number[]} points
|
|
14
|
+
* @return {boolean}
|
|
15
|
+
*/
|
|
16
|
+
export function detailed_sphere_frustum_intersection_test(
|
|
17
|
+
radius, light_x, light_y, light_z,
|
|
18
|
+
outside_plane_count, outside_plane_bitfield,
|
|
19
|
+
points
|
|
20
|
+
) {
|
|
21
|
+
|
|
22
|
+
const radius_sqr = radius * radius;
|
|
23
|
+
|
|
24
|
+
if (outside_plane_count === 3) {
|
|
25
|
+
// nearest point in a corner, find the corner
|
|
26
|
+
const point_index = triplanar_corner_mapping[outside_plane_bitfield];
|
|
27
|
+
|
|
28
|
+
const point_address = point_index * 3;
|
|
29
|
+
|
|
30
|
+
const point_x = points[point_address];
|
|
31
|
+
const point_y = points[point_address + 1];
|
|
32
|
+
const point_z = points[point_address + 2];
|
|
33
|
+
|
|
34
|
+
const distance_to_light_sqr = v3_distance_sqr(
|
|
35
|
+
point_x, point_y, point_z,
|
|
36
|
+
light_x, light_y, light_z
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// query_bvh_frustum_from_objects.checks_sphere_frustum_corner++;
|
|
40
|
+
|
|
41
|
+
// return distance_to_light_sqr <= radius_sqr;
|
|
42
|
+
|
|
43
|
+
if (distance_to_light_sqr > radius_sqr) {
|
|
44
|
+
|
|
45
|
+
// query_bvh_frustum_from_objects.rejection_sphere_count++;
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
} else if (outside_plane_count === 2) {
|
|
50
|
+
// nearest point is on an edge of two plane intersection
|
|
51
|
+
const edge_bitfield = biplanar_edge_mapping[outside_plane_bitfield];
|
|
52
|
+
|
|
53
|
+
// get 2 corners from edge bitfield
|
|
54
|
+
const corner_index_0 = edge_bitfield & 0b111;
|
|
55
|
+
const corner_address_0 = corner_index_0 * 3;
|
|
56
|
+
|
|
57
|
+
const corner_index_1 = (edge_bitfield >> 3) & 0b111;
|
|
58
|
+
const corner_address_1 = corner_index_1 * 3;
|
|
59
|
+
|
|
60
|
+
const point_0_x = points[corner_address_0];
|
|
61
|
+
const point_0_y = points[corner_address_0 + 1];
|
|
62
|
+
const point_0_z = points[corner_address_0 + 2];
|
|
63
|
+
|
|
64
|
+
const point_1_x = points[corner_address_1];
|
|
65
|
+
const point_1_y = points[corner_address_1 + 1];
|
|
66
|
+
const point_1_z = points[corner_address_1 + 2];
|
|
67
|
+
|
|
68
|
+
const distance_to_frustum_sqr = line3_computeSegmentPointDistance_sqr(
|
|
69
|
+
point_0_x, point_0_y, point_0_z,
|
|
70
|
+
point_1_x, point_1_y, point_1_z,
|
|
71
|
+
light_x, light_y, light_z
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
// query_bvh_frustum_from_objects.checks_sphere_frustum_edge++;
|
|
75
|
+
|
|
76
|
+
// return distance_to_frustum_sqr <= radius_sqr;
|
|
77
|
+
|
|
78
|
+
if (distance_to_frustum_sqr > radius_sqr) {
|
|
79
|
+
|
|
80
|
+
// query_bvh_frustum_from_objects.rejection_sphere_count++;
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return true;
|
|
86
|
+
}
|