@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
|
@@ -17,6 +17,7 @@ import { deserializeBinaryNodeFromBinaryBuffer } from "../../../core/bvh2/serial
|
|
|
17
17
|
import { computeGeometryBoundingSphereMiniball } from "../../graphics/geometry/buffered/computeGeometryBoundingSphereMiniball.js";
|
|
18
18
|
import { serializeRowFirstTable } from "../../../core/collection/table/serializeRowFirstTable.js";
|
|
19
19
|
import { deserializeRowFirstTable } from "../../../core/collection/table/deserializeRowFirstTable.js";
|
|
20
|
+
import { assert } from "../../../core/assert.js";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @readonly
|
|
@@ -28,364 +29,374 @@ const dataSpec = new RowFirstTableSpec([
|
|
|
28
29
|
DataType.Float32, DataType.Float32, DataType.Float32 //scale
|
|
29
30
|
]);
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
* @constructor
|
|
34
|
-
*/
|
|
35
|
-
function InstancedFoliage() {
|
|
36
|
-
/**
|
|
37
|
-
* Minimum area on the screen to be occupied by an instance, if instance bounding sphere occupies less than this - it will be culled
|
|
38
|
-
* Measured in pixels
|
|
39
|
-
* @type {number}
|
|
40
|
-
*/
|
|
41
|
-
this.minScreenArea = 32;
|
|
42
|
-
|
|
32
|
+
export class InstancedFoliage {
|
|
43
33
|
/**
|
|
44
34
|
*
|
|
45
|
-
* @
|
|
35
|
+
* @constructor
|
|
46
36
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
constructor() {
|
|
38
|
+
/**
|
|
39
|
+
* Minimum area on the screen to be occupied by an instance, if instance bounding sphere occupies less than this - it will be culled
|
|
40
|
+
* Measured in pixels
|
|
41
|
+
* @type {number}
|
|
42
|
+
*/
|
|
43
|
+
this.minScreenArea = 32;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @type {BinaryNode}
|
|
48
|
+
*/
|
|
49
|
+
this.bvh = new BinaryNode();
|
|
50
|
+
this.bvh.setNegativelyInfiniteBounds();
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @type {RowFirstTable}
|
|
55
|
+
*/
|
|
56
|
+
this.data = new RowFirstTable(dataSpec);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @type {InstancedMeshGroup}
|
|
61
|
+
*/
|
|
62
|
+
this.instances = new InstancedMeshGroup();
|
|
63
|
+
|
|
64
|
+
this.geometry = null;
|
|
65
|
+
this.instanceBoundingSphere = new Vector4(0, 0, 0, 0);
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
this.bvhVisibilityVisitor = new ThreeFrustumsIntersectionBVHVisitor();
|
|
69
|
+
|
|
70
|
+
this.visibilitySetBuilder = new FoliageVisibilitySetBuilder();
|
|
71
|
+
this.bvhVisibilityVisitor.collector = this.visibilitySetBuilder;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @type {*[]}
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
this.__garbage = [];
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @type {number}
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
this.__garbagePointer = 0;
|
|
85
|
+
}
|
|
49
86
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*/
|
|
54
|
-
this.data = new RowFirstTable(dataSpec);
|
|
87
|
+
hash() {
|
|
88
|
+
return this.data.hash();
|
|
89
|
+
}
|
|
55
90
|
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
* @type {InstancedMeshGroup}
|
|
59
|
-
*/
|
|
60
|
-
this.instances = new InstancedMeshGroup();
|
|
91
|
+
clear() {
|
|
61
92
|
|
|
62
|
-
|
|
63
|
-
|
|
93
|
+
this.data.clear();
|
|
94
|
+
this.bvh.reset();
|
|
64
95
|
|
|
96
|
+
}
|
|
65
97
|
|
|
66
|
-
|
|
98
|
+
dispose() {
|
|
99
|
+
this.instances.dispose();
|
|
100
|
+
}
|
|
67
101
|
|
|
68
|
-
|
|
69
|
-
|
|
102
|
+
initialize() {
|
|
103
|
+
|
|
104
|
+
}
|
|
70
105
|
|
|
71
106
|
/**
|
|
72
107
|
*
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
75
|
-
|
|
76
|
-
this.__garbage = [];
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
* @type {number}
|
|
80
|
-
* @private
|
|
108
|
+
* @param {Vector3} position
|
|
109
|
+
* @param {Quaternion} rotation
|
|
110
|
+
* @param {Vector3} scale
|
|
81
111
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
112
|
+
add(position, rotation, scale) {
|
|
113
|
+
const index = this.data.length;
|
|
84
114
|
|
|
85
|
-
|
|
86
|
-
return this.data.hash();
|
|
87
|
-
};
|
|
115
|
+
const encodedRotation = rotation.encodeToUint32();
|
|
88
116
|
|
|
89
|
-
|
|
117
|
+
//update data
|
|
118
|
+
this.data.addRow([
|
|
119
|
+
position.x, position.y, position.z,
|
|
120
|
+
encodedRotation,
|
|
121
|
+
scale.x, scale.y, scale.z
|
|
122
|
+
]);
|
|
90
123
|
|
|
91
|
-
|
|
92
|
-
|
|
124
|
+
const leaf = new LeafNode(
|
|
125
|
+
index,
|
|
126
|
+
Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY,
|
|
127
|
+
Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY
|
|
128
|
+
);
|
|
93
129
|
|
|
94
|
-
|
|
130
|
+
//compute bounding box for this instance
|
|
131
|
+
this.expandBoundingBoxForInstance(position, rotation, scale, leaf);
|
|
95
132
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
133
|
+
//insert bounding box into the spatial index
|
|
134
|
+
this.bvh.insertNode(leaf);
|
|
135
|
+
}
|
|
99
136
|
|
|
100
|
-
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
* @param {int} index Instance index
|
|
140
|
+
* @param {Vector3} position Position of instance will be read into this vector
|
|
141
|
+
* @param {Quaternion} rotation Rotation of instance will be read into this quaternion
|
|
142
|
+
* @param {Vector3} scale Scale of the instance will be read into this Vector
|
|
143
|
+
*/
|
|
144
|
+
read(index, position, rotation, scale) {
|
|
145
|
+
const elementData = [];
|
|
146
|
+
//read transform data for instance
|
|
147
|
+
this.data.getRow(index, elementData);
|
|
101
148
|
|
|
102
|
-
|
|
149
|
+
const positionX = elementData[0];
|
|
150
|
+
const positionY = elementData[1];
|
|
151
|
+
const positionZ = elementData[2];
|
|
103
152
|
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
* @param {Vector3} position
|
|
107
|
-
* @param {Quaternion} rotation
|
|
108
|
-
* @param {Vector3} scale
|
|
109
|
-
*/
|
|
110
|
-
InstancedFoliage.prototype.add = function (position, rotation, scale) {
|
|
111
|
-
const index = this.data.length;
|
|
153
|
+
const encodedRotation = elementData[3];
|
|
112
154
|
|
|
113
|
-
|
|
155
|
+
const scaleX = elementData[4];
|
|
156
|
+
const scaleY = elementData[5];
|
|
157
|
+
const scaleZ = elementData[6];
|
|
114
158
|
|
|
115
|
-
|
|
116
|
-
this.data.addRow([
|
|
117
|
-
position.x, position.y, position.z,
|
|
118
|
-
encodedRotation,
|
|
119
|
-
scale.x, scale.y, scale.z
|
|
120
|
-
]);
|
|
159
|
+
position.set(positionX, positionY, positionZ);
|
|
121
160
|
|
|
122
|
-
|
|
123
|
-
index,
|
|
124
|
-
Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY,
|
|
125
|
-
Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY
|
|
126
|
-
);
|
|
161
|
+
rotation.decodeFromUint32(encodedRotation);
|
|
127
162
|
|
|
128
|
-
|
|
129
|
-
|
|
163
|
+
scale.set(scaleX, scaleY, scaleZ);
|
|
164
|
+
}
|
|
130
165
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
166
|
+
/**
|
|
167
|
+
*
|
|
168
|
+
* @param {AABB3} result
|
|
169
|
+
* @param {Vector3} position
|
|
170
|
+
* @param {Quaternion} rotation
|
|
171
|
+
* @param {Vector3} scale
|
|
172
|
+
*/
|
|
173
|
+
expandBoundingBoxForInstance(position, rotation, scale, result) {
|
|
134
174
|
|
|
135
|
-
|
|
136
|
-
*
|
|
137
|
-
* @param {int} index Instance index
|
|
138
|
-
* @param {Vector3} position Position of instance will be read into this vector
|
|
139
|
-
* @param {Quaternion} rotation Rotation of instance will be read into this quaternion
|
|
140
|
-
* @param {Vector3} scale Scale of the instance will be read into this Vector
|
|
141
|
-
*/
|
|
142
|
-
InstancedFoliage.prototype.read = function (index, position, rotation, scale) {
|
|
143
|
-
const elementData = [];
|
|
144
|
-
//read transform data for instance
|
|
145
|
-
this.data.getRow(index, elementData);
|
|
175
|
+
const vertexData = this.geometry.attributes.position.array;
|
|
146
176
|
|
|
147
|
-
|
|
148
|
-
const positionY = elementData[1];
|
|
149
|
-
const positionZ = elementData[2];
|
|
177
|
+
const rXYZ = new Vector3(rotation.x, rotation.y, rotation.z);
|
|
150
178
|
|
|
151
|
-
|
|
179
|
+
const v = new Vector3(0, 0, 0);
|
|
152
180
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
181
|
+
const c0 = new Vector3(0, 0, 0);
|
|
182
|
+
const c1 = new Vector3(0, 0, 0);
|
|
183
|
+
const c2 = new Vector3(0, 0, 0);
|
|
156
184
|
|
|
157
|
-
|
|
185
|
+
for (let i = 0, l = vertexData.length; i < l; i += 3) {
|
|
186
|
+
const x = vertexData[i];
|
|
187
|
+
const y = vertexData[i + 1];
|
|
188
|
+
const z = vertexData[i + 2];
|
|
158
189
|
|
|
159
|
-
|
|
190
|
+
v.set(x, y, z);
|
|
160
191
|
|
|
161
|
-
|
|
162
|
-
};
|
|
192
|
+
//transform point
|
|
163
193
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* @param {AABB3} result
|
|
167
|
-
* @param {Vector3} position
|
|
168
|
-
* @param {Quaternion} rotation
|
|
169
|
-
* @param {Vector3} scale
|
|
170
|
-
*/
|
|
171
|
-
InstancedFoliage.prototype.expandBoundingBoxForInstance = function (position, rotation, scale, result) {
|
|
194
|
+
//apply scale
|
|
195
|
+
v.multiply(scale);
|
|
172
196
|
|
|
173
|
-
|
|
197
|
+
//apply rotation
|
|
198
|
+
c1.copy(v).multiplyScalar(rotation.w);
|
|
199
|
+
c0.copy(rXYZ).cross(v).add(c1);
|
|
200
|
+
c2.copy(rXYZ).cross(c0).multiplyScalar(2);
|
|
174
201
|
|
|
175
|
-
|
|
202
|
+
v.add(c2);
|
|
176
203
|
|
|
177
|
-
|
|
204
|
+
//apply translation
|
|
205
|
+
v.add(position);
|
|
178
206
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
207
|
+
result._expandToFitPoint(v.x, v.y, v.z);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
182
210
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const z = vertexData[i + 2];
|
|
211
|
+
computeInstanceBoundingSphere() {
|
|
212
|
+
this.instanceBoundingSphere = computeGeometryBoundingSphereMiniball(this.geometry);
|
|
213
|
+
}
|
|
187
214
|
|
|
188
|
-
|
|
215
|
+
setInstance(geometry, material) {
|
|
216
|
+
if (material === undefined) {
|
|
217
|
+
throw new Error(`Material is undefined`);
|
|
218
|
+
}
|
|
189
219
|
|
|
190
|
-
|
|
220
|
+
if (geometry === undefined) {
|
|
221
|
+
throw new Error(`Geometry is undefined`);
|
|
222
|
+
}
|
|
191
223
|
|
|
192
|
-
//apply scale
|
|
193
|
-
v.multiply(scale);
|
|
194
224
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
225
|
+
let bufferGeometry;
|
|
226
|
+
if ((geometry instanceof BufferGeometry)) {
|
|
227
|
+
bufferGeometry = geometry;
|
|
228
|
+
} else {
|
|
229
|
+
bufferGeometry = new BufferGeometry();
|
|
230
|
+
bufferGeometry.fromGeometry(geometry);
|
|
231
|
+
}
|
|
199
232
|
|
|
200
|
-
v.add(c2);
|
|
201
233
|
|
|
202
|
-
|
|
203
|
-
v.add(position);
|
|
234
|
+
this.geometry = bufferGeometry;
|
|
204
235
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
};
|
|
236
|
+
this.instances.setMaterial(material);
|
|
237
|
+
this.instances.setGeometry(bufferGeometry);
|
|
208
238
|
|
|
209
|
-
|
|
210
|
-
this.instanceBoundingSphere = computeGeometryBoundingSphereMiniball(this.geometry);
|
|
211
|
-
};
|
|
239
|
+
this.computeInstanceBoundingSphere();
|
|
212
240
|
|
|
213
|
-
|
|
214
|
-
if (material === undefined) {
|
|
215
|
-
throw new Error(`Material is undefined`);
|
|
216
|
-
}
|
|
241
|
+
//TODO: compute haul for the mesh, to use for fast AABB computation
|
|
217
242
|
|
|
218
|
-
if (geometry === undefined) {
|
|
219
|
-
throw new Error(`Geometry is undefined`);
|
|
220
243
|
}
|
|
221
244
|
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
* @param {BinaryBuffer} buffer
|
|
248
|
+
*/
|
|
249
|
+
deserialize(buffer) {
|
|
250
|
+
deserializeRowFirstTable(buffer, this.data);
|
|
222
251
|
|
|
223
|
-
|
|
224
|
-
if ((geometry instanceof BufferGeometry)) {
|
|
225
|
-
bufferGeometry = geometry;
|
|
226
|
-
} else {
|
|
227
|
-
bufferGeometry = new BufferGeometry();
|
|
228
|
-
bufferGeometry.fromGeometry(geometry);
|
|
252
|
+
deserializeBinaryNodeFromBinaryBuffer(this.bvh, buffer, deserializeLeafValueUintVar);
|
|
229
253
|
}
|
|
230
254
|
|
|
255
|
+
/**
|
|
256
|
+
*
|
|
257
|
+
* @param {BinaryBuffer} buffer
|
|
258
|
+
*/
|
|
259
|
+
serialize(buffer) {
|
|
231
260
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.instances.setMaterial(material);
|
|
235
|
-
this.instances.setGeometry(bufferGeometry);
|
|
261
|
+
//serialize data
|
|
262
|
+
serializeRowFirstTable(buffer, this.data);
|
|
236
263
|
|
|
237
|
-
|
|
264
|
+
const numRows = this.data.length;
|
|
238
265
|
|
|
239
|
-
|
|
266
|
+
if (numRows > 2147483647) {
|
|
267
|
+
throw new Error(`Data is too large to be written (length=${numRows})`);
|
|
268
|
+
}
|
|
240
269
|
|
|
241
|
-
};
|
|
242
270
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
* @param {BinaryBuffer} buffer
|
|
246
|
-
* @returns {number}
|
|
247
|
-
*/
|
|
248
|
-
function deserializeLeafValueUintVar(buffer) {
|
|
249
|
-
return buffer.readUintVar();
|
|
250
|
-
}
|
|
271
|
+
serializeBinaryNodeToBinaryBuffer(this.bvh, buffer, serializeLeafValueUintVar);
|
|
272
|
+
}
|
|
251
273
|
|
|
252
|
-
|
|
253
|
-
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
* @param index
|
|
277
|
+
* @param {int} ref
|
|
278
|
+
*/
|
|
279
|
+
__updateVisibility(index, ref) {
|
|
280
|
+
assert.isNonNegativeInteger(ref, 'ref');
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
*
|
|
284
|
+
* @type {FoliageVisibilitySetBuilder}
|
|
285
|
+
*/
|
|
286
|
+
const builder = this.visibilitySetBuilder;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
* @type {BitSet}
|
|
291
|
+
*/
|
|
292
|
+
const visibleElementSet = builder.visibleSet;
|
|
293
|
+
|
|
294
|
+
if (!visibleElementSet.get(ref)) {
|
|
295
|
+
//no longer visible
|
|
296
|
+
this.__garbage[this.__garbagePointer++] = ref;
|
|
297
|
+
} else {
|
|
298
|
+
//visible, and is already in the group, update the set
|
|
299
|
+
visibleElementSet.set(ref, false);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
254
302
|
|
|
255
|
-
|
|
256
|
-
};
|
|
303
|
+
__removeGarbage() {
|
|
257
304
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
* @param {BinaryBuffer} buffer
|
|
261
|
-
* @param {number} value
|
|
262
|
-
*/
|
|
263
|
-
function serializeLeafValueUintVar(buffer, value) {
|
|
264
|
-
buffer.writeUintVar(value);
|
|
265
|
-
}
|
|
305
|
+
const garbagePointer = this.__garbagePointer;
|
|
306
|
+
const instances = this.instances;
|
|
266
307
|
|
|
267
|
-
InstancedFoliage.prototype.serialize = function (buffer) {
|
|
268
308
|
|
|
269
|
-
|
|
270
|
-
serializeRowFirstTable(buffer, this.data);
|
|
309
|
+
const garbage = this.__garbage;
|
|
271
310
|
|
|
272
|
-
|
|
311
|
+
for (let i = 0; i < garbagePointer; i++) {
|
|
312
|
+
const ref = garbage[i];
|
|
313
|
+
instances.remove(ref);
|
|
314
|
+
}
|
|
273
315
|
|
|
274
|
-
if (numRows > 2147483647) {
|
|
275
|
-
throw new Error(`Data is too large to be written (length=${numRows})`);
|
|
276
316
|
}
|
|
277
317
|
|
|
278
|
-
|
|
279
|
-
serializeBinaryNodeToBinaryBuffer(this.bvh, buffer, serializeLeafValueUintVar);
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const tempQuaternion = new Quaternion();
|
|
284
|
-
const rowData = [];
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
*
|
|
288
|
-
* @param index
|
|
289
|
-
* @param {int} ref
|
|
290
|
-
*/
|
|
291
|
-
InstancedFoliage.prototype.__updateVisibility = function (index, ref) {
|
|
292
318
|
/**
|
|
293
319
|
*
|
|
294
|
-
* @
|
|
320
|
+
* @param {Frustum[]} frustums
|
|
321
|
+
* @param {function[]} [visibilityFilters]
|
|
295
322
|
*/
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
*
|
|
300
|
-
* @type {BitSet}
|
|
301
|
-
*/
|
|
302
|
-
const visibleElementSet = builder.visibleSet;
|
|
303
|
-
|
|
304
|
-
if (!visibleElementSet.get(ref)) {
|
|
305
|
-
//no longer visible
|
|
306
|
-
this.__garbage[this.__garbagePointer++] = ref;
|
|
307
|
-
} else {
|
|
308
|
-
//visible, and is already in the group, update the set
|
|
309
|
-
visibleElementSet.set(ref, false);
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
InstancedFoliage.prototype.__removeGarbage = function () {
|
|
323
|
+
update(frustums, visibilityFilters = []) {
|
|
324
|
+
const instances = this.instances;
|
|
314
325
|
|
|
315
|
-
|
|
316
|
-
const instances = this.instances;
|
|
326
|
+
this.bvhVisibilityVisitor.setFrustums(frustums);
|
|
317
327
|
|
|
328
|
+
const visibilitySetBuilder = this.visibilitySetBuilder;
|
|
329
|
+
visibilitySetBuilder.setFilters(visibilityFilters);
|
|
330
|
+
visibilitySetBuilder.initialize();
|
|
318
331
|
|
|
319
|
-
|
|
332
|
+
const visibleElementSet = visibilitySetBuilder.visibleSet;
|
|
320
333
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
instances.remove(ref);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
*
|
|
330
|
-
* @param {Frustum[]} frustums
|
|
331
|
-
* @param {function[]} [visibilityFilters]
|
|
332
|
-
*/
|
|
333
|
-
InstancedFoliage.prototype.update = function (frustums, visibilityFilters = []) {
|
|
334
|
-
const instances = this.instances;
|
|
334
|
+
//build visible set
|
|
335
|
+
traverseBinaryNodeUsingVisitor(this.bvh, this.bvhVisibilityVisitor);
|
|
335
336
|
|
|
336
|
-
|
|
337
|
+
visibilitySetBuilder.finalize();
|
|
337
338
|
|
|
338
|
-
|
|
339
|
-
visibilitySetBuilder.setFilters(visibilityFilters);
|
|
340
|
-
visibilitySetBuilder.initialize();
|
|
339
|
+
// console.log(`Visible: `, elementsToAdd.size);
|
|
341
340
|
|
|
342
|
-
|
|
341
|
+
//reset garbage pointer
|
|
342
|
+
this.__garbagePointer = 0;
|
|
343
343
|
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
//remove those that are no longer visible
|
|
345
|
+
instances.traverseReferences(this.__updateVisibility, this);
|
|
346
346
|
|
|
347
|
-
|
|
347
|
+
//cull instances that are no longer visible
|
|
348
|
+
this.__removeGarbage();
|
|
348
349
|
|
|
349
|
-
// console.log(`Visible: `, elementsToAdd.size);
|
|
350
350
|
|
|
351
|
-
|
|
352
|
-
this.__garbagePointer = 0;
|
|
351
|
+
const data = this.data;
|
|
353
352
|
|
|
354
|
-
|
|
355
|
-
|
|
353
|
+
//process entities that have become newly visible
|
|
354
|
+
for (let index = visibleElementSet.nextSetBit(0); index !== -1; index = visibleElementSet.nextSetBit(index + 1)) {
|
|
355
|
+
//read transform data for instance
|
|
356
|
+
data.getRow(index, rowData);
|
|
356
357
|
|
|
357
|
-
|
|
358
|
-
|
|
358
|
+
const positionX = rowData[0];
|
|
359
|
+
const positionY = rowData[1];
|
|
360
|
+
const positionZ = rowData[2];
|
|
359
361
|
|
|
362
|
+
const encodedRotation = rowData[3];
|
|
360
363
|
|
|
361
|
-
const data = this.data;
|
|
362
|
-
|
|
363
|
-
//process entities that have become newly visible
|
|
364
|
-
for (let index = visibleElementSet.nextSetBit(0); index !== -1; index = visibleElementSet.nextSetBit(index + 1)) {
|
|
365
|
-
//read transform data for instance
|
|
366
|
-
data.getRow(index, rowData);
|
|
367
364
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
365
|
+
const scaleX = rowData[4];
|
|
366
|
+
const scaleY = rowData[5];
|
|
367
|
+
const scaleZ = rowData[6];
|
|
371
368
|
|
|
372
|
-
|
|
369
|
+
const i = instances.add(index);
|
|
373
370
|
|
|
371
|
+
tempQuaternion.decodeFromUint32(encodedRotation);
|
|
374
372
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
373
|
+
//apply instance transforms
|
|
374
|
+
instances.setPositionAt(i, positionX, positionY, positionZ);
|
|
375
|
+
instances.setRotationAt(i, tempQuaternion.x, tempQuaternion.y, tempQuaternion.z, tempQuaternion.w);
|
|
376
|
+
instances.setScaleAt(i, scaleX, scaleY, scaleZ);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
378
380
|
|
|
379
|
-
|
|
381
|
+
/**
|
|
382
|
+
*
|
|
383
|
+
* @param {BinaryBuffer} buffer
|
|
384
|
+
* @returns {number}
|
|
385
|
+
*/
|
|
386
|
+
function deserializeLeafValueUintVar(buffer) {
|
|
387
|
+
return buffer.readUintVar();
|
|
388
|
+
}
|
|
380
389
|
|
|
381
|
-
|
|
390
|
+
/**
|
|
391
|
+
*
|
|
392
|
+
* @param {BinaryBuffer} buffer
|
|
393
|
+
* @param {number} value
|
|
394
|
+
*/
|
|
395
|
+
function serializeLeafValueUintVar(buffer, value) {
|
|
396
|
+
buffer.writeUintVar(value);
|
|
397
|
+
}
|
|
382
398
|
|
|
383
|
-
//apply instance transforms
|
|
384
|
-
instances.setPositionAt(i, positionX, positionY, positionZ);
|
|
385
|
-
instances.setRotationAt(i, tempQuaternion.x, tempQuaternion.y, tempQuaternion.z, tempQuaternion.w);
|
|
386
|
-
instances.setScaleAt(i, scaleX, scaleY, scaleZ);
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
399
|
|
|
400
|
+
const tempQuaternion = new Quaternion();
|
|
401
|
+
const rowData = [];
|
|
390
402
|
|
|
391
|
-
export { InstancedFoliage };
|