@aura3d/rendering 1.4.0 → 1.4.2
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/package.json +38 -4
- package/AGENTS.md +0 -46
- package/src/ArchitecturalLightingFixtures.ts +0 -241
- package/src/ArchitecturalMaterialCatalog.ts +0 -130
- package/src/ArchitecturalMeasurementFixtures.ts +0 -155
- package/src/BRDFLut.ts +0 -47
- package/src/CameraFraming.ts +0 -200
- package/src/CanonicalSceneFixtures.ts +0 -95
- package/src/CascadedShadowMaps.ts +0 -449
- package/src/ColorManagement.ts +0 -127
- package/src/CullingFixtures.ts +0 -280
- package/src/DecalGeometry.ts +0 -26
- package/src/DepthPass.ts +0 -110
- package/src/EnvironmentBackgroundPass.ts +0 -194
- package/src/EnvironmentBackgroundResources.ts +0 -309
- package/src/EnvironmentLighting.ts +0 -96
- package/src/EnvironmentMapResources.ts +0 -1026
- package/src/EnvironmentPipeline.ts +0 -69
- package/src/EnvironmentPlatform.ts +0 -1306
- package/src/EnvironmentPreset.ts +0 -155
- package/src/Exposure.ts +0 -66
- package/src/ExternalParityRenderPreset.ts +0 -725
- package/src/ForwardPass.ts +0 -1668
- package/src/FrameVisualMetrics.ts +0 -301
- package/src/Geometry.ts +0 -461
- package/src/GeometryPrimitives.ts +0 -2
- package/src/HDRRenderPipeline.ts +0 -94
- package/src/IBL.ts +0 -86
- package/src/IndexBuffer.ts +0 -57
- package/src/InstancedPBRMaterial.ts +0 -186
- package/src/InstancedUnlitMaterial.ts +0 -60
- package/src/Instancing.ts +0 -19
- package/src/LightCollector.ts +0 -82
- package/src/LightUniforms.ts +0 -47
- package/src/LightingDebug.ts +0 -80
- package/src/LightingDefaults.ts +0 -79
- package/src/LightingRig.ts +0 -301
- package/src/LineGeometry.ts +0 -2
- package/src/Material.ts +0 -209
- package/src/MaterialBinding.ts +0 -131
- package/src/MaterialInstance.ts +0 -59
- package/src/MaterialPresets.ts +0 -272
- package/src/MorphTarget.ts +0 -124
- package/src/MorphTargetPlan.ts +0 -178
- package/src/MorphUnlitMaterial.ts +0 -60
- package/src/NormalMappedPBRMaterial.ts +0 -188
- package/src/OceanFixtures.ts +0 -318
- package/src/PBRLightingDefaults.ts +0 -12
- package/src/PBRMaterial.ts +0 -442
- package/src/PMREM.ts +0 -53
- package/src/PbrReference.ts +0 -681
- package/src/PostProcessPass.ts +0 -2507
- package/src/ProceduralTextureFixtures.ts +0 -393
- package/src/ProductTurntableFixtures.ts +0 -815
- package/src/Raycaster.ts +0 -21
- package/src/ReflectionProbe.ts +0 -13
- package/src/ReflectionSurfaces.ts +0 -219
- package/src/RenderBackend.ts +0 -43
- package/src/RenderDebugViews.ts +0 -138
- package/src/RenderDevice.ts +0 -836
- package/src/RenderGraph.ts +0 -194
- package/src/RenderPass.ts +0 -27
- package/src/RenderPipeline.ts +0 -101
- package/src/RenderQueue.ts +0 -12
- package/src/RenderState.ts +0 -12
- package/src/Renderer.ts +0 -2631
- package/src/RendererDebugOverlay.ts +0 -80
- package/src/RendererFeatureGates.ts +0 -150
- package/src/RendererPostprocessPlan.ts +0 -279
- package/src/RendererTiming.ts +0 -251
- package/src/RendererVisualPipelineReport.ts +0 -836
- package/src/ResourceLifecycle.ts +0 -21
- package/src/Sampler.ts +0 -37
- package/src/SceneOptimization.ts +0 -518
- package/src/ShaderChunks.ts +0 -393
- package/src/ShaderLibrary.ts +0 -2766
- package/src/ShaderModule.ts +0 -36
- package/src/ShaderPreprocessor.ts +0 -260
- package/src/ShaderReflection.ts +0 -201
- package/src/ShadowMap.ts +0 -237
- package/src/ShadowPass.ts +0 -198
- package/src/ShadowProjection.ts +0 -115
- package/src/SkinnedLitMaterial.ts +0 -397
- package/src/SkinnedUnlitMaterial.ts +0 -63
- package/src/SkinningBounds.ts +0 -131
- package/src/SpaceEnvironmentFixtures.ts +0 -200
- package/src/SpriteGeometry.ts +0 -21
- package/src/StereoCameraRig.ts +0 -127
- package/src/StereoEffects.ts +0 -274
- package/src/TerrainFixtures.ts +0 -180
- package/src/Texture.ts +0 -307
- package/src/TextureBinding.ts +0 -91
- package/src/TexturedPBRMaterial.ts +0 -1112
- package/src/TexturedUnlitMaterial.ts +0 -67
- package/src/ToneMapping.ts +0 -105
- package/src/UniformBinder.ts +0 -16
- package/src/UniformLayout.ts +0 -129
- package/src/UnlitMaterial.ts +0 -75
- package/src/VegetationFixtures.ts +0 -314
- package/src/VertexBuffer.ts +0 -120
- package/src/VertexFormat.ts +0 -171
- package/src/VoxelWorldFixtures.ts +0 -280
- package/src/WeatherFixtures.ts +0 -223
- package/src/WebGL2Device.ts +0 -2280
- package/src/WebGL2StateCache.ts +0 -330
- package/src/WebGPUDevice.ts +0 -2877
- package/src/WebGPURenderToTextureProof.ts +0 -139
- package/src/advanced-runtime/AdvancedRenderer.ts +0 -73
- package/src/advanced-runtime/index.ts +0 -9
- package/src/animation/AnimationMaterialStyle.ts +0 -32
- package/src/animation/AnimationRenderPreset.ts +0 -45
- package/src/animation/AnimationToonMaterial.ts +0 -387
- package/src/animation/AnimationVisualQuality.ts +0 -71
- package/src/animation/applyAnimationRenderPreset.ts +0 -180
- package/src/animation/index.ts +0 -5
- package/src/cinematic/BloomPass.ts +0 -26
- package/src/cinematic/CinematicDepthComposition.ts +0 -30
- package/src/cinematic/CinematicEvidence.ts +0 -123
- package/src/cinematic/CinematicLightingRig.ts +0 -144
- package/src/cinematic/CinematicMaterialPresets.ts +0 -130
- package/src/cinematic/CinematicPostProcess.ts +0 -83
- package/src/cinematic/DepthHazePass.ts +0 -30
- package/src/cinematic/EmissivePracticalLightSystem.ts +0 -45
- package/src/cinematic/FilmGrainPass.ts +0 -24
- package/src/cinematic/FogVolumeSystem.ts +0 -30
- package/src/cinematic/GlowCardSystem.ts +0 -44
- package/src/cinematic/RainParticleSystem.ts +0 -151
- package/src/cinematic/VignettePass.ts +0 -25
- package/src/cinematic/WetReflectionApproximation.ts +0 -27
- package/src/cinematic/index.ts +0 -14
- package/src/effects/CollisionModule.ts +0 -64
- package/src/effects/ColorModule.ts +0 -60
- package/src/effects/ForceModule.ts +0 -25
- package/src/effects/GPUParticleBackend.ts +0 -569
- package/src/effects/Particle.ts +0 -108
- package/src/effects/ParticleDiagnostics.ts +0 -224
- package/src/effects/ParticleEffectPresets.ts +0 -147
- package/src/effects/ParticleEmitter.ts +0 -326
- package/src/effects/ParticleModule.ts +0 -26
- package/src/effects/ParticleRenderPass.ts +0 -117
- package/src/effects/ParticleRenderer.ts +0 -132
- package/src/effects/ParticleSystem.ts +0 -333
- package/src/effects/SizeModule.ts +0 -56
- package/src/effects/TrailModule.ts +0 -72
- package/src/effects/VelocityModule.ts +0 -75
- package/src/effects/index.ts +0 -15
- package/src/index.ts +0 -925
- package/src/materials/AlphaSorting.ts +0 -30
- package/src/materials/MaterialExtensions.ts +0 -42
- package/src/materials/PhysicalMaterial.ts +0 -133
- package/src/materials/TransmissionPass.ts +0 -51
- package/src/performance/BVH.ts +0 -18
- package/src/performance/Batcher.ts +0 -2
- package/src/performance/FrustumCuller.ts +0 -9
- package/src/performance/LOD.ts +0 -20
- package/src/performance/Octree.ts +0 -10
- package/src/performance/RenderItemSorting.ts +0 -170
- package/src/performance/RendererStats.ts +0 -43
- package/src/performance/ResourceBudget.ts +0 -44
- package/src/postprocess/BloomPass.ts +0 -28
- package/src/postprocess/CinematicDiagnostics.ts +0 -642
- package/src/postprocess/ColorGradingPass.ts +0 -24
- package/src/postprocess/DepthOfFieldPass.ts +0 -12
- package/src/postprocess/EffectComposer.ts +0 -349
- package/src/postprocess/SSAOPass.ts +0 -20
- package/src/postprocess/index.ts +0 -34
- package/src/production-runtime/AnimationControlsPipeline.ts +0 -77
- package/src/production-runtime/PBRHDRPipeline.ts +0 -381
- package/src/production-runtime/ProductionEffectsPipeline.ts +0 -85
- package/src/production-runtime/ProductionRendererTypes.ts +0 -136
- package/src/production-runtime/ProductionRuntimeRenderer.ts +0 -172
- package/src/production-runtime/ProductionWebGL2Renderer.ts +0 -313
- package/src/production-runtime/ProductionWebGPURenderer.ts +0 -396
- package/src/production-runtime/TransmissionBackdropCapture.ts +0 -130
- package/src/production-runtime/animation/MorphTargetRenderer.ts +0 -2
- package/src/production-runtime/animation/SkinningRenderer.ts +0 -2
- package/src/production-runtime/backends/RendererBackend.ts +0 -17
- package/src/production-runtime/backends/WebGL2RendererBackend.ts +0 -30
- package/src/production-runtime/backends/WebGPURendererBackend.ts +0 -24
- package/src/production-runtime/backends/webgl2/WebGL2Buffer.ts +0 -2
- package/src/production-runtime/backends/webgl2/WebGL2Capabilities.ts +0 -2
- package/src/production-runtime/backends/webgl2/WebGL2RenderTarget.ts +0 -2
- package/src/production-runtime/backends/webgl2/WebGL2Shader.ts +0 -2
- package/src/production-runtime/backends/webgl2/WebGL2StateCache.ts +0 -1
- package/src/production-runtime/backends/webgl2/WebGL2Texture.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPUBuffer.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPUCapabilities.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPURenderTarget.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPUShader.ts +0 -2
- package/src/production-runtime/backends/webgpu/WebGPUTexture.ts +0 -2
- package/src/production-runtime/color/ColorManagement.ts +0 -3
- package/src/production-runtime/color/ToneMapping.ts +0 -7
- package/src/production-runtime/diagnostics/FrameCapture.ts +0 -2
- package/src/production-runtime/diagnostics/GPUCapabilities.ts +0 -2
- package/src/production-runtime/diagnostics/RendererStats.ts +0 -2
- package/src/production-runtime/environment/EnvironmentMap.ts +0 -1
- package/src/production-runtime/environment/HDRLoader.ts +0 -57
- package/src/production-runtime/environment/PMREMGenerator.ts +0 -713
- package/src/production-runtime/framegraph/FrameGraph.ts +0 -18
- package/src/production-runtime/framegraph/RenderPass.ts +0 -15
- package/src/production-runtime/geometry/ProjectedDecalGeometry.ts +0 -439
- package/src/production-runtime/index.ts +0 -127
- package/src/production-runtime/lights/LightManager.ts +0 -7
- package/src/production-runtime/lights/ShadowMapRenderer.ts +0 -5
- package/src/production-runtime/materials/GLTFMaterialAdapter.ts +0 -6
- package/src/production-runtime/materials/GLTFPBRMaterialAdapter.ts +0 -2
- package/src/production-runtime/materials/MaterialCompiler.ts +0 -7
- package/src/production-runtime/materials/MaterialTextureBindings.ts +0 -5
- package/src/production-runtime/materials/PBRMaterial.ts +0 -2
- package/src/production-runtime/materials/PBRShaderFeatures.ts +0 -2
- package/src/production-runtime/passes/ContactShadowPass.ts +0 -184
- package/src/production-runtime/passes/DepthPrepass.ts +0 -7
- package/src/production-runtime/passes/OpaquePass.ts +0 -7
- package/src/production-runtime/passes/ShadowPass.ts +0 -7
- package/src/production-runtime/passes/SkyboxPass.ts +0 -7
- package/src/production-runtime/passes/ToneMappingPass.ts +0 -7
- package/src/production-runtime/passes/TransparentPass.ts +0 -7
- package/src/production-runtime/postprocess/BloomPass.ts +0 -51
- package/src/production-runtime/postprocess/ColorGradingPass.ts +0 -49
- package/src/production-runtime/postprocess/DOFPass.ts +0 -47
- package/src/production-runtime/postprocess/FXAAPass.ts +0 -53
- package/src/production-runtime/postprocess/ProductionEffectComposer.ts +0 -78
- package/src/production-runtime/postprocess/ProductionPostProcessTypes.ts +0 -174
- package/src/production-runtime/postprocess/SSAOPass.ts +0 -45
- package/src/production-runtime/resources/GPUBuffer.ts +0 -2
- package/src/production-runtime/resources/GPUTexture.ts +0 -2
- package/src/production-runtime/resources/RenderTarget.ts +0 -3
- package/src/production-runtime/resources/ResourceCache.ts +0 -7
- package/src/production-runtime/scene/Camera.ts +0 -1
- package/src/production-runtime/scene/Lights.ts +0 -2
- package/src/production-runtime/scene/RenderableMesh.ts +0 -2
- package/src/production-runtime/scene/RenderablePrimitive.ts +0 -1
- package/src/production-runtime/scene/RenderableScene.ts +0 -4
- package/src/production-runtime/shaders/ShaderProgramLibrary.ts +0 -7
- package/src/production-runtime/shaders/chunks/brdf.glsl +0 -2
- package/src/production-runtime/shaders/chunks/ibl.glsl +0 -3
- package/src/production-runtime/shaders/chunks/pbr.frag.glsl +0 -47
- package/src/production-runtime/shaders/chunks/pbr.vert.glsl +0 -8
- package/src/production-runtime/shaders/chunks/shadows.glsl +0 -2
- package/src/production-runtime/shaders/wgsl/pbr.wgsl +0 -3
- package/src/production-runtime/shaders/wgsl/postprocess.wgsl +0 -2
- package/src/production-runtime/shaders/wgsl/skybox.wgsl +0 -2
- package/src/shaders/depth.frag.glsl +0 -5
- package/src/shaders/depth.vert.glsl +0 -8
- package/src/shaders/pbr-direct.frag.glsl +0 -687
- package/src/shaders/pbr-direct.vert.glsl +0 -18
- package/src/shaders/unlit.frag.glsl +0 -18
- package/src/shaders/unlit.vert.glsl +0 -13
- package/src/shadows/CascadedShadowPipeline.ts +0 -53
- package/src/shadows/ContactShadows.ts +0 -106
- package/src/shadows/ShadowDebugViews.ts +0 -46
- package/src/threejs-compatibility/InstancingSystem.ts +0 -17
- package/src/threejs-compatibility/LightingSystem.ts +0 -22
- package/src/threejs-compatibility/MaterialSystem.ts +0 -9
- package/src/threejs-compatibility/RenderTargetSystem.ts +0 -35
- package/src/threejs-compatibility/RendererDiagnostics.ts +0 -61
- package/src/threejs-compatibility/SceneRenderer.ts +0 -34
- package/src/threejs-compatibility/ShadowSystem.ts +0 -19
- package/src/threejs-compatibility/TextureSystem.ts +0 -19
- package/src/threejs-compatibility/ThreeCompatRenderer.ts +0 -90
- package/src/threejs-compatibility/TransparencySystem.ts +0 -19
- package/src/threejs-compatibility/index.ts +0 -29
- package/src/threejs-compatibility/performance/BVH.ts +0 -14
- package/src/threejs-compatibility/performance/FrustumCulling.ts +0 -10
- package/src/threejs-compatibility/performance/Instancing.ts +0 -4
- package/src/threejs-compatibility/performance/LODSystem.ts +0 -16
- package/src/threejs-compatibility/performance/OcclusionCulling.ts +0 -6
- package/src/threejs-compatibility/performance/RaycastAcceleration.ts +0 -12
- package/src/threejs-compatibility/performance/RendererProfiler.ts +0 -19
- package/src/threejs-compatibility/performance/TextureStreaming.ts +0 -4
- package/src/threejs-compatibility/performance/index.ts +0 -12
- package/src/threejs-compatibility/postprocess/BloomPass.ts +0 -16
- package/src/threejs-compatibility/postprocess/ColorGradingPass.ts +0 -16
- package/src/threejs-compatibility/postprocess/DepthOfFieldPass.ts +0 -21
- package/src/threejs-compatibility/postprocess/EffectComposer.ts +0 -14
- package/src/threejs-compatibility/postprocess/FXAAPass.ts +0 -15
- package/src/threejs-compatibility/postprocess/MotionBlurPass.ts +0 -20
- package/src/threejs-compatibility/postprocess/OutlinePass.ts +0 -21
- package/src/threejs-compatibility/postprocess/PostProcessTypes.ts +0 -169
- package/src/threejs-compatibility/postprocess/RenderPass.ts +0 -9
- package/src/threejs-compatibility/postprocess/SMAAPass.ts +0 -15
- package/src/threejs-compatibility/postprocess/SSAOPass.ts +0 -21
- package/src/threejs-compatibility/postprocess/ShaderPass.ts +0 -7
- package/src/threejs-compatibility/postprocess/TAAPass.ts +0 -15
- package/src/threejs-compatibility/postprocess/VignettePass.ts +0 -16
- package/src/threejs-compatibility/postprocess/index.ts +0 -15
- package/src/threejs-compatibility/shaders/NodeMaterial.ts +0 -21
- package/src/threejs-compatibility/shaders/RawShaderMaterial.ts +0 -6
- package/src/threejs-compatibility/shaders/ShaderDiagnostics.ts +0 -17
- package/src/threejs-compatibility/shaders/ShaderMaterial.ts +0 -18
- package/src/threejs-compatibility/shaders/ThreeCompatShaderChunks.ts +0 -6
- package/src/threejs-compatibility/shaders/Uniforms.ts +0 -18
- package/src/threejs-compatibility/shaders/index.ts +0 -9
- package/src/threejs-compatibility/vfx/GPUPointCloud.ts +0 -7
- package/src/threejs-compatibility/vfx/LineRenderer.ts +0 -13
- package/src/threejs-compatibility/vfx/ParticleSystem.ts +0 -23
- package/src/threejs-compatibility/vfx/SpriteSystem.ts +0 -14
- package/src/threejs-compatibility/vfx/TrailRenderer.ts +0 -8
- package/src/threejs-compatibility/vfx/VFXDiagnostics.ts +0 -23
- package/src/threejs-compatibility/vfx/index.ts +0 -9
- package/src/threejs-example-parity/index.ts +0 -205
- package/src/webgpu/WebGPUBuffer.ts +0 -1
- package/src/webgpu/WebGPUCompute.ts +0 -2
- package/src/webgpu/WebGPUPipelineCache.ts +0 -15
- package/src/webgpu/WebGPUPostProcess.ts +0 -2
- package/src/webgpu/WebGPUTexture.ts +0 -2
- package/tsconfig.json +0 -26
- package/vitest.config.ts +0 -20
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
export type VoxelFixtureBlockType =
|
|
2
|
-
| "air"
|
|
3
|
-
| "stone"
|
|
4
|
-
| "dirt"
|
|
5
|
-
| "grass"
|
|
6
|
-
| "sand"
|
|
7
|
-
| "water"
|
|
8
|
-
| "wood"
|
|
9
|
-
| "leaves"
|
|
10
|
-
| "glass"
|
|
11
|
-
| "coal-ore"
|
|
12
|
-
| "iron-ore"
|
|
13
|
-
| "gold-ore"
|
|
14
|
-
| "diamond-ore"
|
|
15
|
-
| "bedrock"
|
|
16
|
-
| "cobblestone"
|
|
17
|
-
| "planks"
|
|
18
|
-
| "brick"
|
|
19
|
-
| "snow"
|
|
20
|
-
| "ice"
|
|
21
|
-
| "lava";
|
|
22
|
-
|
|
23
|
-
export type VoxelFixtureLod = "near" | "mid" | "far" | "culled";
|
|
24
|
-
|
|
25
|
-
export interface VoxelFixtureOptions {
|
|
26
|
-
readonly seed?: number;
|
|
27
|
-
readonly chunkSize?: number;
|
|
28
|
-
readonly viewDistance?: number;
|
|
29
|
-
readonly cameraChunkX?: number;
|
|
30
|
-
readonly cameraChunkZ?: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface VoxelBlockDescriptor {
|
|
34
|
-
readonly type: VoxelFixtureBlockType;
|
|
35
|
-
readonly color: readonly [number, number, number, number];
|
|
36
|
-
readonly hardness: number;
|
|
37
|
-
readonly toolRequired: string | null;
|
|
38
|
-
readonly drops: VoxelFixtureBlockType | null;
|
|
39
|
-
readonly sound: string;
|
|
40
|
-
readonly animated: boolean;
|
|
41
|
-
readonly lightLevel: number;
|
|
42
|
-
readonly transparent: boolean;
|
|
43
|
-
readonly solid: boolean;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface VoxelVisibleBlock {
|
|
47
|
-
readonly id: string;
|
|
48
|
-
readonly type: VoxelFixtureBlockType;
|
|
49
|
-
readonly x: number;
|
|
50
|
-
readonly y: number;
|
|
51
|
-
readonly z: number;
|
|
52
|
-
readonly lod: VoxelFixtureLod;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface VoxelWorldFixture {
|
|
56
|
-
readonly id: "external-parity-old-branch-voxel-world-fixture";
|
|
57
|
-
readonly source: "origin-master-voxel-world-adapted";
|
|
58
|
-
readonly seed: number;
|
|
59
|
-
readonly chunkSize: number;
|
|
60
|
-
readonly viewDistance: number;
|
|
61
|
-
readonly registry: readonly VoxelBlockDescriptor[];
|
|
62
|
-
readonly blockTypeCount: number;
|
|
63
|
-
readonly solidBlockTypes: number;
|
|
64
|
-
readonly transparentBlockTypes: number;
|
|
65
|
-
readonly animatedBlockTypes: number;
|
|
66
|
-
readonly emittingBlockTypes: number;
|
|
67
|
-
readonly chunkQueueSize: number;
|
|
68
|
-
readonly generatingChunks: number;
|
|
69
|
-
readonly meshingChunks: number;
|
|
70
|
-
readonly lodCounts: Record<VoxelFixtureLod, number>;
|
|
71
|
-
readonly blockCounts: Partial<Record<VoxelFixtureBlockType, number>>;
|
|
72
|
-
readonly visibleBlocks: readonly VoxelVisibleBlock[];
|
|
73
|
-
readonly visibleFaceEstimate: number;
|
|
74
|
-
readonly memoryBytes: number;
|
|
75
|
-
readonly hash: string;
|
|
76
|
-
readonly claimBoundary: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const registry: readonly VoxelBlockDescriptor[] = [
|
|
80
|
-
block("air", [0, 0, 0, 0], 0, null, null, "none", false, 0, true, false),
|
|
81
|
-
block("stone", [0.5, 0.5, 0.5, 1], 1.5, "pickaxe", "cobblestone", "stone", false, 0, false, true),
|
|
82
|
-
block("dirt", [0.4, 0.25, 0.15, 1], 0.5, null, "dirt", "dirt", false, 0, false, true),
|
|
83
|
-
block("grass", [0.3, 0.7, 0.3, 1], 0.6, null, "dirt", "grass", false, 0, false, true),
|
|
84
|
-
block("sand", [0.9, 0.85, 0.6, 1], 0.5, null, "sand", "sand", false, 0, false, true),
|
|
85
|
-
block("water", [0.15, 0.4, 0.8, 0.6], 100, null, null, "water", true, 0, true, false),
|
|
86
|
-
block("wood", [0.4, 0.25, 0.1, 1], 2, "axe", "wood", "wood", false, 0, false, true),
|
|
87
|
-
block("leaves", [0.2, 0.6, 0.2, 0.9], 0.2, null, null, "grass", false, 0, true, true),
|
|
88
|
-
block("glass", [0.7, 0.9, 1, 0.3], 0.3, null, "glass", "glass", false, 0, true, true),
|
|
89
|
-
block("coal-ore", [0.12, 0.12, 0.12, 1], 3, "pickaxe", "coal-ore", "stone", false, 0, false, true),
|
|
90
|
-
block("iron-ore", [0.72, 0.5, 0.34, 1], 3, "pickaxe", "iron-ore", "stone", false, 0, false, true),
|
|
91
|
-
block("gold-ore", [1, 0.78, 0.2, 1], 3, "pickaxe", "gold-ore", "stone", false, 0, false, true),
|
|
92
|
-
block("diamond-ore", [0.2, 0.85, 1, 1], 3, "pickaxe", "diamond-ore", "stone", false, 0, false, true),
|
|
93
|
-
block("bedrock", [0.05, 0.05, 0.06, 1], 1000, null, null, "stone", false, 0, false, true),
|
|
94
|
-
block("cobblestone", [0.38, 0.38, 0.38, 1], 2, "pickaxe", "cobblestone", "stone", false, 0, false, true),
|
|
95
|
-
block("planks", [0.64, 0.42, 0.2, 1], 2, "axe", "planks", "wood", false, 0, false, true),
|
|
96
|
-
block("brick", [0.62, 0.24, 0.18, 1], 2, "pickaxe", "brick", "stone", false, 0, false, true),
|
|
97
|
-
block("snow", [0.92, 0.96, 1, 1], 0.2, null, "snow", "snow", false, 0, false, true),
|
|
98
|
-
block("ice", [0.64, 0.88, 1, 0.72], 0.5, null, "ice", "glass", false, 0, true, true),
|
|
99
|
-
block("lava", [1, 0.28, 0.02, 0.95], 100, null, null, "lava", true, 12, true, false)
|
|
100
|
-
];
|
|
101
|
-
|
|
102
|
-
export function sampleVoxelWorldFixture(options: VoxelFixtureOptions = {}): VoxelWorldFixture {
|
|
103
|
-
const seed = integer(options.seed ?? 0x3d2025, "seed");
|
|
104
|
-
const chunkSize = integer(options.chunkSize ?? 16, "chunkSize");
|
|
105
|
-
if (chunkSize < 8 || chunkSize > 64) throw new RangeError("Voxel fixture chunkSize must be between 8 and 64.");
|
|
106
|
-
const viewDistance = integer(options.viewDistance ?? 4, "viewDistance");
|
|
107
|
-
if (viewDistance < 1 || viewDistance > 16) throw new RangeError("Voxel fixture viewDistance must be between 1 and 16.");
|
|
108
|
-
const cameraChunkX = Math.trunc(options.cameraChunkX ?? 0);
|
|
109
|
-
const cameraChunkZ = Math.trunc(options.cameraChunkZ ?? 0);
|
|
110
|
-
const blockCounts: Partial<Record<VoxelFixtureBlockType, number>> = {};
|
|
111
|
-
const visibleBlocks: VoxelVisibleBlock[] = [];
|
|
112
|
-
let visibleFaceEstimate = 0;
|
|
113
|
-
|
|
114
|
-
for (let x = 0; x < chunkSize; x += 1) {
|
|
115
|
-
for (let z = 0; z < chunkSize; z += 1) {
|
|
116
|
-
const worldX = cameraChunkX * chunkSize + x;
|
|
117
|
-
const worldZ = cameraChunkZ * chunkSize + z;
|
|
118
|
-
const height = terrainHeight(worldX, worldZ, seed, chunkSize);
|
|
119
|
-
const surface = surfaceBlock(worldX, worldZ, seed, height, chunkSize);
|
|
120
|
-
addCount(blockCounts, "bedrock", 1);
|
|
121
|
-
addCount(blockCounts, "stone", Math.max(0, height - 4));
|
|
122
|
-
addCount(blockCounts, "dirt", 3);
|
|
123
|
-
addCount(blockCounts, surface, 1);
|
|
124
|
-
if (height < chunkSize * 0.38) addCount(blockCounts, "water", Math.ceil(chunkSize * 0.38 - height));
|
|
125
|
-
if (noise(worldX * 0.19 + 31, worldZ * 0.19 - 17, seed) > 0.9) addCount(blockCounts, oreBlock(height), 1);
|
|
126
|
-
if (surface === "grass" && noise(worldX * 0.13 + 1000, worldZ * 0.13 + 1000, seed) > 0.88) {
|
|
127
|
-
addCount(blockCounts, "wood", 3);
|
|
128
|
-
addCount(blockCounts, "leaves", 6);
|
|
129
|
-
}
|
|
130
|
-
visibleFaceEstimate += 4 + Math.round(Math.abs(height - chunkSize * 0.5) * 0.8);
|
|
131
|
-
if (visibleBlocks.length < 28 && (x + z) % 3 === 0) {
|
|
132
|
-
const distance = Math.hypot(x - chunkSize / 2, z - chunkSize / 2) / chunkSize * viewDistance;
|
|
133
|
-
visibleBlocks.push({
|
|
134
|
-
id: `voxel-${x}-${z}`,
|
|
135
|
-
type: surface,
|
|
136
|
-
x: Number(((x / chunkSize - 0.5) * 2.3).toFixed(4)),
|
|
137
|
-
y: Number(((height / chunkSize) * 0.72 - 0.64).toFixed(4)),
|
|
138
|
-
z: Number(((z / chunkSize - 0.5) * 0.44 - 0.22).toFixed(4)),
|
|
139
|
-
lod: lodForDistance(distance)
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const lodCounts = chunkLodCounts(viewDistance);
|
|
146
|
-
const chunkQueueSize = Object.values(lodCounts).reduce((sum, count) => sum + count, 0);
|
|
147
|
-
const memoryBytes = chunkQueueSize * chunkSize * chunkSize * chunkSize * 2;
|
|
148
|
-
return {
|
|
149
|
-
id: "external-parity-old-branch-voxel-world-fixture",
|
|
150
|
-
source: "origin-master-voxel-world-adapted",
|
|
151
|
-
seed,
|
|
152
|
-
chunkSize,
|
|
153
|
-
viewDistance,
|
|
154
|
-
registry,
|
|
155
|
-
blockTypeCount: registry.length,
|
|
156
|
-
solidBlockTypes: registry.filter((entry) => entry.solid).length,
|
|
157
|
-
transparentBlockTypes: registry.filter((entry) => entry.transparent).length,
|
|
158
|
-
animatedBlockTypes: registry.filter((entry) => entry.animated).length,
|
|
159
|
-
emittingBlockTypes: registry.filter((entry) => entry.lightLevel > 0).length,
|
|
160
|
-
chunkQueueSize,
|
|
161
|
-
generatingChunks: Math.min(2, chunkQueueSize),
|
|
162
|
-
meshingChunks: Math.min(3, chunkQueueSize),
|
|
163
|
-
lodCounts,
|
|
164
|
-
blockCounts,
|
|
165
|
-
visibleBlocks,
|
|
166
|
-
visibleFaceEstimate,
|
|
167
|
-
memoryBytes,
|
|
168
|
-
hash: hashVoxel(seed, chunkSize, viewDistance, blockCounts, lodCounts, visibleFaceEstimate),
|
|
169
|
-
claimBoundary: "Deterministic block registry, chunk queue, terrain columns, LOD buckets, and visible block markers adapted from the old voxel-world example; this is not a production voxel engine, mesh builder, collision system, multiplayer sandbox, or Minecraft parity claim."
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function block(
|
|
174
|
-
type: VoxelFixtureBlockType,
|
|
175
|
-
color: readonly [number, number, number, number],
|
|
176
|
-
hardness: number,
|
|
177
|
-
toolRequired: string | null,
|
|
178
|
-
drops: VoxelFixtureBlockType | null,
|
|
179
|
-
sound: string,
|
|
180
|
-
animated: boolean,
|
|
181
|
-
lightLevel: number,
|
|
182
|
-
transparent: boolean,
|
|
183
|
-
solid: boolean
|
|
184
|
-
): VoxelBlockDescriptor {
|
|
185
|
-
return { type, color, hardness, toolRequired, drops, sound, animated, lightLevel, transparent, solid };
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function terrainHeight(x: number, z: number, seed: number, chunkSize: number): number {
|
|
189
|
-
const base = noise(x * 0.08, z * 0.08, seed);
|
|
190
|
-
const detail = noise(x * 0.21 + 11, z * 0.21 - 7, seed) * 0.32;
|
|
191
|
-
return Math.max(3, Math.min(chunkSize - 2, Math.round(chunkSize * (0.34 + base * 0.34 + detail))));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function surfaceBlock(x: number, z: number, seed: number, height: number, chunkSize: number): VoxelFixtureBlockType {
|
|
195
|
-
if (height < chunkSize * 0.38) return "sand";
|
|
196
|
-
if (height > chunkSize * 0.78) return noise(x * 0.13, z * 0.13, seed) > 0.45 ? "snow" : "stone";
|
|
197
|
-
const biome = noise(x * 0.05 - 20, z * 0.05 + 30, seed);
|
|
198
|
-
if (biome < 0.18) return "sand";
|
|
199
|
-
if (biome > 0.82) return "stone";
|
|
200
|
-
return "grass";
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function oreBlock(height: number): VoxelFixtureBlockType {
|
|
204
|
-
if (height < 6) return "diamond-ore";
|
|
205
|
-
if (height < 9) return "gold-ore";
|
|
206
|
-
if (height < 12) return "iron-ore";
|
|
207
|
-
return "coal-ore";
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function lodForDistance(distance: number): VoxelFixtureLod {
|
|
211
|
-
if (distance <= 1.25) return "near";
|
|
212
|
-
if (distance <= 2.5) return "mid";
|
|
213
|
-
if (distance <= 4) return "far";
|
|
214
|
-
return "culled";
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function chunkLodCounts(viewDistance: number): Record<VoxelFixtureLod, number> {
|
|
218
|
-
const counts: Record<VoxelFixtureLod, number> = { near: 0, mid: 0, far: 0, culled: 0 };
|
|
219
|
-
const unloadDistance = viewDistance * 1.5;
|
|
220
|
-
for (let x = -viewDistance; x <= viewDistance; x += 1) {
|
|
221
|
-
for (let z = -viewDistance; z <= viewDistance; z += 1) {
|
|
222
|
-
const distance = Math.hypot(x, z);
|
|
223
|
-
if (distance <= viewDistance) counts[lodForDistance(distance)] += 1;
|
|
224
|
-
else if (distance <= unloadDistance) counts.culled += 1;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return counts;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function addCount(counts: Partial<Record<VoxelFixtureBlockType, number>>, type: VoxelFixtureBlockType, count: number): void {
|
|
231
|
-
counts[type] = (counts[type] ?? 0) + count;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function noise(x: number, z: number, seed: number): number {
|
|
235
|
-
const xi = Math.floor(x);
|
|
236
|
-
const zi = Math.floor(z);
|
|
237
|
-
const xf = x - xi;
|
|
238
|
-
const zf = z - zi;
|
|
239
|
-
const top = lerp(hash(xi, zi, seed), hash(xi + 1, zi, seed), smoothstep(xf));
|
|
240
|
-
const bottom = lerp(hash(xi, zi + 1, seed), hash(xi + 1, zi + 1, seed), smoothstep(xf));
|
|
241
|
-
return lerp(top, bottom, smoothstep(zf));
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function hash(x: number, z: number, seed: number): number {
|
|
245
|
-
let value = Math.imul(x, 374761393) + Math.imul(z, 668265263) + seed;
|
|
246
|
-
value = Math.imul(value ^ (value >>> 13), 1274126177);
|
|
247
|
-
return ((value ^ (value >>> 16)) >>> 0) / 4294967296;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function hashVoxel(
|
|
251
|
-
seed: number,
|
|
252
|
-
chunkSize: number,
|
|
253
|
-
viewDistance: number,
|
|
254
|
-
blockCounts: Partial<Record<VoxelFixtureBlockType, number>>,
|
|
255
|
-
lodCounts: Record<VoxelFixtureLod, number>,
|
|
256
|
-
visibleFaceEstimate: number
|
|
257
|
-
): string {
|
|
258
|
-
let value = 0x811c9dc5;
|
|
259
|
-
for (const entry of [seed, chunkSize, viewDistance, visibleFaceEstimate, ...Object.values(blockCounts), ...Object.values(lodCounts)]) {
|
|
260
|
-
const scaled = Math.round((entry ?? 0) * 10);
|
|
261
|
-
value ^= scaled & 0xff;
|
|
262
|
-
value = Math.imul(value, 0x01000193) >>> 0;
|
|
263
|
-
value ^= (scaled >>> 8) & 0xff;
|
|
264
|
-
value = Math.imul(value, 0x01000193) >>> 0;
|
|
265
|
-
}
|
|
266
|
-
return value.toString(16).padStart(8, "0");
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function integer(value: number, label: string): number {
|
|
270
|
-
if (!Number.isInteger(value)) throw new RangeError(`Voxel fixture ${label} must be an integer.`);
|
|
271
|
-
return value;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function lerp(left: number, right: number, t: number): number {
|
|
275
|
-
return left + (right - left) * t;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function smoothstep(value: number): number {
|
|
279
|
-
return value * value * (3 - 2 * value);
|
|
280
|
-
}
|
package/src/WeatherFixtures.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
export type WeatherFixtureType = "clear" | "cloudy" | "rain" | "heavy-rain" | "thunderstorm" | "snow";
|
|
2
|
-
|
|
3
|
-
export interface WeatherFixtureOptions {
|
|
4
|
-
readonly type?: WeatherFixtureType;
|
|
5
|
-
readonly elapsedSeconds?: number;
|
|
6
|
-
readonly seed?: number;
|
|
7
|
-
readonly cameraX?: number;
|
|
8
|
-
readonly cameraZ?: number;
|
|
9
|
-
readonly maxVisualDrops?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface WeatherVisualDrop {
|
|
13
|
-
readonly x: number;
|
|
14
|
-
readonly y: number;
|
|
15
|
-
readonly z: number;
|
|
16
|
-
readonly length: number;
|
|
17
|
-
readonly alpha: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface WeatherPuddlePatch {
|
|
21
|
-
readonly x: number;
|
|
22
|
-
readonly z: number;
|
|
23
|
-
readonly radius: number;
|
|
24
|
-
readonly depth: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface WeatherFixtureSample {
|
|
28
|
-
readonly type: WeatherFixtureType;
|
|
29
|
-
readonly cloudCoverage: number;
|
|
30
|
-
readonly fogDensity: number;
|
|
31
|
-
readonly rainIntensity: number;
|
|
32
|
-
readonly snowIntensity: number;
|
|
33
|
-
readonly windSpeed: number;
|
|
34
|
-
readonly windDirectionX: number;
|
|
35
|
-
readonly windDirectionZ: number;
|
|
36
|
-
readonly lightningFrequency: number;
|
|
37
|
-
readonly visibleDropCount: number;
|
|
38
|
-
readonly splashCount: number;
|
|
39
|
-
readonly puddleDepth: number;
|
|
40
|
-
readonly wetness: number;
|
|
41
|
-
readonly ambientIntensity: number;
|
|
42
|
-
readonly visibilityMeters: number;
|
|
43
|
-
readonly visualDrops: readonly WeatherVisualDrop[];
|
|
44
|
-
readonly puddlePatches: readonly WeatherPuddlePatch[];
|
|
45
|
-
readonly hash: string;
|
|
46
|
-
readonly source: "origin-master-weather-system-adapted";
|
|
47
|
-
readonly claimBoundary: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function sampleWeatherFixture(options: WeatherFixtureOptions = {}): WeatherFixtureSample {
|
|
51
|
-
const type = options.type ?? "rain";
|
|
52
|
-
const preset = weatherPreset(type);
|
|
53
|
-
const elapsedSeconds = Math.max(0, finite(options.elapsedSeconds ?? 1, "elapsedSeconds"));
|
|
54
|
-
const seed = Math.floor(options.seed ?? 0x5ea50a);
|
|
55
|
-
if (!Number.isInteger(seed)) {
|
|
56
|
-
throw new RangeError("Weather fixture seed must be an integer.");
|
|
57
|
-
}
|
|
58
|
-
const cameraX = finite(options.cameraX ?? 0, "cameraX");
|
|
59
|
-
const cameraZ = finite(options.cameraZ ?? 0, "cameraZ");
|
|
60
|
-
const windGust = (seeded01(seed + Math.floor(elapsedSeconds * 17)) * 2 - 1) * preset.windGustiness;
|
|
61
|
-
const windSpeed = Math.max(0, preset.windSpeed * (1 + windGust));
|
|
62
|
-
const weatherLoad = preset.rainIntensity + preset.snowIntensity;
|
|
63
|
-
const visibleDropCount = Math.round(weatherLoad * 420 + windSpeed * 8 + Math.abs(cameraX + cameraZ) * 3);
|
|
64
|
-
const splashCount = Math.round(preset.rainIntensity * elapsedSeconds * 180);
|
|
65
|
-
const puddleDepth = clamp(preset.rainIntensity * elapsedSeconds * 0.018 + preset.wetnessRate * 0.08, 0, 1);
|
|
66
|
-
const wetness = clamp(preset.wetnessRate + puddleDepth * 0.45, 0, 1);
|
|
67
|
-
const visualDrops = sampleVisualDrops({
|
|
68
|
-
count: Math.min(Math.max(0, Math.floor(options.maxVisualDrops ?? 36)), visibleDropCount),
|
|
69
|
-
seed,
|
|
70
|
-
elapsedSeconds,
|
|
71
|
-
cameraX,
|
|
72
|
-
cameraZ,
|
|
73
|
-
intensity: weatherLoad,
|
|
74
|
-
windSpeed
|
|
75
|
-
});
|
|
76
|
-
const puddlePatches = samplePuddlePatches({
|
|
77
|
-
count: preset.rainIntensity > 0 ? Math.max(1, Math.min(8, Math.round(preset.rainIntensity * 8))) : 0,
|
|
78
|
-
seed,
|
|
79
|
-
cameraX,
|
|
80
|
-
cameraZ,
|
|
81
|
-
depth: puddleDepth
|
|
82
|
-
});
|
|
83
|
-
const hash = hashWeather([
|
|
84
|
-
preset.cloudCoverage,
|
|
85
|
-
preset.fogDensity,
|
|
86
|
-
preset.rainIntensity,
|
|
87
|
-
preset.snowIntensity,
|
|
88
|
-
windSpeed,
|
|
89
|
-
visibleDropCount,
|
|
90
|
-
splashCount,
|
|
91
|
-
puddleDepth,
|
|
92
|
-
wetness,
|
|
93
|
-
preset.visibility,
|
|
94
|
-
visualDrops.length,
|
|
95
|
-
puddlePatches.length
|
|
96
|
-
]);
|
|
97
|
-
return {
|
|
98
|
-
type,
|
|
99
|
-
cloudCoverage: preset.cloudCoverage,
|
|
100
|
-
fogDensity: preset.fogDensity,
|
|
101
|
-
rainIntensity: preset.rainIntensity,
|
|
102
|
-
snowIntensity: preset.snowIntensity,
|
|
103
|
-
windSpeed: Number(windSpeed.toFixed(4)),
|
|
104
|
-
windDirectionX: preset.windDirectionX,
|
|
105
|
-
windDirectionZ: preset.windDirectionZ,
|
|
106
|
-
lightningFrequency: preset.lightningFrequency,
|
|
107
|
-
visibleDropCount,
|
|
108
|
-
splashCount,
|
|
109
|
-
puddleDepth: Number(puddleDepth.toFixed(4)),
|
|
110
|
-
wetness: Number(wetness.toFixed(4)),
|
|
111
|
-
ambientIntensity: preset.ambientIntensity,
|
|
112
|
-
visibilityMeters: preset.visibility,
|
|
113
|
-
visualDrops,
|
|
114
|
-
puddlePatches,
|
|
115
|
-
hash,
|
|
116
|
-
source: "origin-master-weather-system-adapted",
|
|
117
|
-
claimBoundary: "Deterministic weather, wind, rain/snow particle-count, splash, puddle, wetness, fog, and cloud telemetry adapted from the old weather system; this is bounded scene evidence, not volumetric clouds, full precipitation rendering, atmospheric scattering, or weather simulation parity."
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function weatherPreset(type: WeatherFixtureType): {
|
|
122
|
-
readonly cloudCoverage: number;
|
|
123
|
-
readonly fogDensity: number;
|
|
124
|
-
readonly rainIntensity: number;
|
|
125
|
-
readonly snowIntensity: number;
|
|
126
|
-
readonly windSpeed: number;
|
|
127
|
-
readonly windDirectionX: number;
|
|
128
|
-
readonly windDirectionZ: number;
|
|
129
|
-
readonly windGustiness: number;
|
|
130
|
-
readonly lightningFrequency: number;
|
|
131
|
-
readonly ambientIntensity: number;
|
|
132
|
-
readonly wetnessRate: number;
|
|
133
|
-
readonly visibility: number;
|
|
134
|
-
} {
|
|
135
|
-
switch (type) {
|
|
136
|
-
case "clear":
|
|
137
|
-
return { cloudCoverage: 0.1, fogDensity: 0, rainIntensity: 0, snowIntensity: 0, windSpeed: 2, windDirectionX: 1, windDirectionZ: 0, windGustiness: 0.1, lightningFrequency: 0, ambientIntensity: 0.8, wetnessRate: 0, visibility: 50_000 };
|
|
138
|
-
case "cloudy":
|
|
139
|
-
return { cloudCoverage: 0.85, fogDensity: 0.1, rainIntensity: 0, snowIntensity: 0, windSpeed: 5, windDirectionX: 1, windDirectionZ: 0, windGustiness: 0.3, lightningFrequency: 0, ambientIntensity: 0.6, wetnessRate: 0, visibility: 20_000 };
|
|
140
|
-
case "heavy-rain":
|
|
141
|
-
return { cloudCoverage: 1, fogDensity: 0.3, rainIntensity: 0.9, snowIntensity: 0, windSpeed: 9, windDirectionX: 1, windDirectionZ: 0, windGustiness: 0.5, lightningFrequency: 1.5, ambientIntensity: 0.4, wetnessRate: 0.9, visibility: 5_000 };
|
|
142
|
-
case "thunderstorm":
|
|
143
|
-
return { cloudCoverage: 1, fogDensity: 0.35, rainIntensity: 1, snowIntensity: 0, windSpeed: 12, windDirectionX: 1, windDirectionZ: 0, windGustiness: 0.7, lightningFrequency: 3, ambientIntensity: 0.35, wetnessRate: 1, visibility: 3_000 };
|
|
144
|
-
case "snow":
|
|
145
|
-
return { cloudCoverage: 0.95, fogDensity: 0.2, rainIntensity: 0, snowIntensity: 0.6, windSpeed: 5.5, windDirectionX: 1, windDirectionZ: 0, windGustiness: 0.35, lightningFrequency: 0, ambientIntensity: 0.6, wetnessRate: 0.2, visibility: 8_000 };
|
|
146
|
-
case "rain":
|
|
147
|
-
return { cloudCoverage: 0.9, fogDensity: 0.2, rainIntensity: 0.6, snowIntensity: 0, windSpeed: 6.5, windDirectionX: 1, windDirectionZ: 0, windGustiness: 0.4, lightningFrequency: 0.5, ambientIntensity: 0.5, wetnessRate: 0.6, visibility: 10_000 };
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function hashWeather(values: readonly number[]): string {
|
|
152
|
-
let hash = 0x811c9dc5;
|
|
153
|
-
for (const value of values) {
|
|
154
|
-
const scaled = Math.round(value * 10_000);
|
|
155
|
-
hash ^= scaled & 0xff;
|
|
156
|
-
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
157
|
-
hash ^= (scaled >>> 8) & 0xff;
|
|
158
|
-
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
159
|
-
}
|
|
160
|
-
return hash.toString(16).padStart(8, "0");
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function sampleVisualDrops(options: {
|
|
164
|
-
readonly count: number;
|
|
165
|
-
readonly seed: number;
|
|
166
|
-
readonly elapsedSeconds: number;
|
|
167
|
-
readonly cameraX: number;
|
|
168
|
-
readonly cameraZ: number;
|
|
169
|
-
readonly intensity: number;
|
|
170
|
-
readonly windSpeed: number;
|
|
171
|
-
}): readonly WeatherVisualDrop[] {
|
|
172
|
-
return Array.from({ length: options.count }, (_, index): WeatherVisualDrop => {
|
|
173
|
-
const lane = seeded01(options.seed + index * 97);
|
|
174
|
-
const fall = (seeded01(options.seed ^ (index * 131)) + options.elapsedSeconds * (0.42 + options.intensity * 0.18)) % 1;
|
|
175
|
-
const x = options.cameraX - 1.25 + lane * 2.5 + Math.sin(options.elapsedSeconds * 1.7 + index) * 0.025;
|
|
176
|
-
const z = options.cameraZ - 0.38 + seeded01(options.seed + index * 53) * 0.76;
|
|
177
|
-
const y = 0.78 - fall * 1.38;
|
|
178
|
-
return {
|
|
179
|
-
x: Number(x.toFixed(4)),
|
|
180
|
-
y: Number(y.toFixed(4)),
|
|
181
|
-
z: Number(z.toFixed(4)),
|
|
182
|
-
length: Number((0.055 + options.intensity * 0.055 + options.windSpeed * 0.003).toFixed(4)),
|
|
183
|
-
alpha: Number((0.28 + options.intensity * 0.36).toFixed(4))
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function samplePuddlePatches(options: {
|
|
189
|
-
readonly count: number;
|
|
190
|
-
readonly seed: number;
|
|
191
|
-
readonly cameraX: number;
|
|
192
|
-
readonly cameraZ: number;
|
|
193
|
-
readonly depth: number;
|
|
194
|
-
}): readonly WeatherPuddlePatch[] {
|
|
195
|
-
return Array.from({ length: options.count }, (_, index): WeatherPuddlePatch => {
|
|
196
|
-
const x = options.cameraX - 1.08 + seeded01(options.seed + index * 19) * 2.16;
|
|
197
|
-
const z = options.cameraZ - 0.32 + seeded01(options.seed + index * 47) * 0.64;
|
|
198
|
-
const radius = 0.035 + seeded01(options.seed ^ (index * 83)) * 0.05 + options.depth * 0.08;
|
|
199
|
-
return {
|
|
200
|
-
x: Number(x.toFixed(4)),
|
|
201
|
-
z: Number(z.toFixed(4)),
|
|
202
|
-
radius: Number(radius.toFixed(4)),
|
|
203
|
-
depth: Number(options.depth.toFixed(4))
|
|
204
|
-
};
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function seeded01(seed: number): number {
|
|
209
|
-
let value = seed >>> 0;
|
|
210
|
-
value ^= value << 13;
|
|
211
|
-
value ^= value >>> 17;
|
|
212
|
-
value ^= value << 5;
|
|
213
|
-
return ((value >>> 0) % 10_000) / 10_000;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function finite(value: number, label: string): number {
|
|
217
|
-
if (!Number.isFinite(value)) throw new RangeError(`Weather fixture ${label} must be finite.`);
|
|
218
|
-
return value;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function clamp(value: number, min: number, max: number): number {
|
|
222
|
-
return Math.max(min, Math.min(max, value));
|
|
223
|
-
}
|