@aura3d/rendering 1.3.3 → 1.4.1
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/dist/ForwardPass.js +7 -1
- package/dist/ForwardPass.js.map +1 -1
- package/dist/MorphTarget.d.ts +1 -0
- package/dist/MorphTarget.d.ts.map +1 -1
- package/dist/MorphTarget.js.map +1 -1
- package/dist/Renderer.js +7 -1
- package/dist/Renderer.js.map +1 -1
- package/package.json +38 -4
- 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 -1663
- 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 -123
- 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 -2626
- 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,188 +0,0 @@
|
|
|
1
|
-
import { Material, type RenderState } from "./Material";
|
|
2
|
-
import { DEFAULT_PBR_ENVIRONMENT_INTENSITY, DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP } from "./PBRLightingDefaults";
|
|
3
|
-
import { Sampler } from "./Sampler";
|
|
4
|
-
import { DEFAULT_NORMAL_MAPPED_PBR_SHADER_NAME } from "./ShaderLibrary";
|
|
5
|
-
import { Texture } from "./Texture";
|
|
6
|
-
import { TextureBinding } from "./TextureBinding";
|
|
7
|
-
|
|
8
|
-
export interface NormalMappedPBRMaterialOptions {
|
|
9
|
-
readonly name?: string;
|
|
10
|
-
readonly baseColor?: readonly [number, number, number, number];
|
|
11
|
-
readonly metallic?: number;
|
|
12
|
-
readonly roughness?: number;
|
|
13
|
-
readonly environmentColor?: readonly [number, number, number];
|
|
14
|
-
readonly environmentIntensity?: number;
|
|
15
|
-
readonly proceduralEnvironmentMap?: NormalMappedPBRProceduralEnvironmentMapOptions;
|
|
16
|
-
readonly environmentMapTexture?: TextureBinding;
|
|
17
|
-
readonly environmentMapIntensity?: number;
|
|
18
|
-
readonly environmentMapSpecularIntensity?: number;
|
|
19
|
-
readonly environmentMapRotation?: number;
|
|
20
|
-
readonly environmentMapMipCount?: number;
|
|
21
|
-
readonly environmentBrdfLutTexture?: TextureBinding;
|
|
22
|
-
readonly emissiveColor?: readonly [number, number, number];
|
|
23
|
-
readonly emissiveStrength?: number;
|
|
24
|
-
readonly normalTexture: Texture;
|
|
25
|
-
readonly normalSampler?: Sampler;
|
|
26
|
-
readonly normalScale?: number;
|
|
27
|
-
readonly renderState?: Partial<RenderState>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface NormalMappedPBRProceduralEnvironmentMapOptions {
|
|
31
|
-
readonly skyColor: readonly [number, number, number];
|
|
32
|
-
readonly horizonColor: readonly [number, number, number];
|
|
33
|
-
readonly groundColor: readonly [number, number, number];
|
|
34
|
-
readonly specularColor: readonly [number, number, number];
|
|
35
|
-
readonly intensity: number;
|
|
36
|
-
readonly specularIntensity: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class NormalMappedPBRMaterial extends Material {
|
|
40
|
-
constructor(options: NormalMappedPBRMaterialOptions) {
|
|
41
|
-
const baseColor = options.baseColor ?? [1, 1, 1, 1];
|
|
42
|
-
const environmentColor = options.environmentColor ?? [1, 1, 1];
|
|
43
|
-
const proceduralEnvironmentMap: NormalMappedPBRProceduralEnvironmentMapOptions = options.proceduralEnvironmentMap ?? DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP;
|
|
44
|
-
const emissiveColor = options.emissiveColor ?? [0, 0, 0];
|
|
45
|
-
validateColor4(baseColor, "baseColor");
|
|
46
|
-
validateColor3(environmentColor, "environmentColor");
|
|
47
|
-
validateProceduralEnvironmentMap(proceduralEnvironmentMap);
|
|
48
|
-
validateNonNegative(options.environmentMapIntensity ?? 0, "environmentMapIntensity");
|
|
49
|
-
validateNonNegative(options.environmentMapSpecularIntensity ?? 0, "environmentMapSpecularIntensity");
|
|
50
|
-
validateFinite(options.environmentMapRotation ?? 0, "environmentMapRotation");
|
|
51
|
-
validateMipCount(options.environmentMapMipCount ?? 1);
|
|
52
|
-
validateColor3(emissiveColor, "emissiveColor");
|
|
53
|
-
validateUnit(options.metallic ?? 0, "metallic");
|
|
54
|
-
validateUnit(options.roughness ?? 0.5, "roughness");
|
|
55
|
-
validateNonNegative(options.environmentIntensity ?? DEFAULT_PBR_ENVIRONMENT_INTENSITY, "environmentIntensity");
|
|
56
|
-
validateNonNegative(options.emissiveStrength ?? 1, "emissiveStrength");
|
|
57
|
-
const normalScale = options.normalScale ?? 1;
|
|
58
|
-
if (!Number.isFinite(normalScale) || normalScale < 0) {
|
|
59
|
-
throw new RangeError("PBR normalScale must be finite and non-negative");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
super({
|
|
63
|
-
name: options.name ?? "normal-mapped-pbr",
|
|
64
|
-
shaderKey: DEFAULT_NORMAL_MAPPED_PBR_SHADER_NAME,
|
|
65
|
-
renderState: options.renderState,
|
|
66
|
-
parameters: {
|
|
67
|
-
u_baseColor: baseColor,
|
|
68
|
-
u_metallic: options.metallic ?? 0,
|
|
69
|
-
u_roughness: options.roughness ?? 0.5,
|
|
70
|
-
u_environmentColor: environmentColor,
|
|
71
|
-
u_environmentIntensity: options.environmentIntensity ?? DEFAULT_PBR_ENVIRONMENT_INTENSITY,
|
|
72
|
-
u_environmentSkyColor: proceduralEnvironmentMap.skyColor,
|
|
73
|
-
u_environmentHorizonColor: proceduralEnvironmentMap.horizonColor,
|
|
74
|
-
u_environmentGroundColor: proceduralEnvironmentMap.groundColor,
|
|
75
|
-
u_environmentSpecularColor: proceduralEnvironmentMap.specularColor,
|
|
76
|
-
u_environmentMapIntensity: proceduralEnvironmentMap.intensity,
|
|
77
|
-
u_environmentSpecularIntensity: proceduralEnvironmentMap.specularIntensity,
|
|
78
|
-
u_environmentMapTexture: options.environmentMapTexture ?? new TextureBinding({ name: "u_environmentMapTexture", required: false }),
|
|
79
|
-
u_environmentMapTextureEnabled: options.environmentMapTexture ? 1 : 0,
|
|
80
|
-
u_environmentMapTextureIntensity: options.environmentMapIntensity ?? 0,
|
|
81
|
-
u_environmentMapTextureSpecularIntensity: options.environmentMapSpecularIntensity ?? 0,
|
|
82
|
-
u_environmentMapTextureRotation: options.environmentMapRotation ?? 0,
|
|
83
|
-
u_environmentMapTextureMipCount: options.environmentMapMipCount ?? 1,
|
|
84
|
-
u_environmentMapTextureEncoding: 0,
|
|
85
|
-
u_environmentBrdfLutTexture: options.environmentBrdfLutTexture ?? new TextureBinding({ name: "u_environmentBrdfLutTexture", required: false }),
|
|
86
|
-
u_environmentBrdfLutEnabled: options.environmentBrdfLutTexture ? 1 : 0,
|
|
87
|
-
u_emissiveColor: emissiveColor,
|
|
88
|
-
u_emissiveStrength: options.emissiveStrength ?? 1,
|
|
89
|
-
u_lightCount: 0,
|
|
90
|
-
u_lightData: new Float32Array(0),
|
|
91
|
-
u_normalTexture: new TextureBinding({
|
|
92
|
-
name: "u_normalTexture",
|
|
93
|
-
texture: options.normalTexture,
|
|
94
|
-
sampler: options.normalSampler,
|
|
95
|
-
required: true
|
|
96
|
-
}),
|
|
97
|
-
u_normalScale: normalScale,
|
|
98
|
-
u_modelViewProjection: identityMatrix(),
|
|
99
|
-
u_normalMatrix: identityMatrix()
|
|
100
|
-
},
|
|
101
|
-
requiredAttributes: ["a_position", "a_normal", "a_tangent", "a_uv"],
|
|
102
|
-
uniformSchema: [
|
|
103
|
-
{ name: "u_baseColor", kind: "vec4" },
|
|
104
|
-
{ name: "u_metallic", kind: "float" },
|
|
105
|
-
{ name: "u_roughness", kind: "float" },
|
|
106
|
-
{ name: "u_environmentColor", kind: "vec3" },
|
|
107
|
-
{ name: "u_environmentIntensity", kind: "float" },
|
|
108
|
-
{ name: "u_environmentSkyColor", kind: "vec3" },
|
|
109
|
-
{ name: "u_environmentHorizonColor", kind: "vec3" },
|
|
110
|
-
{ name: "u_environmentGroundColor", kind: "vec3" },
|
|
111
|
-
{ name: "u_environmentSpecularColor", kind: "vec3" },
|
|
112
|
-
{ name: "u_environmentMapIntensity", kind: "float" },
|
|
113
|
-
{ name: "u_environmentSpecularIntensity", kind: "float" },
|
|
114
|
-
{ name: "u_environmentMapTexture", kind: "texture2d", required: false },
|
|
115
|
-
{ name: "u_environmentMapTextureEnabled", kind: "float" },
|
|
116
|
-
{ name: "u_environmentMapTextureIntensity", kind: "float" },
|
|
117
|
-
{ name: "u_environmentMapTextureSpecularIntensity", kind: "float" },
|
|
118
|
-
{ name: "u_environmentMapTextureRotation", kind: "float" },
|
|
119
|
-
{ name: "u_environmentMapTextureMipCount", kind: "float" },
|
|
120
|
-
{ name: "u_environmentMapTextureEncoding", kind: "float" },
|
|
121
|
-
{ name: "u_environmentBrdfLutTexture", kind: "texture2d", required: false },
|
|
122
|
-
{ name: "u_environmentBrdfLutEnabled", kind: "float", required: false },
|
|
123
|
-
{ name: "u_emissiveColor", kind: "vec3" },
|
|
124
|
-
{ name: "u_emissiveStrength", kind: "float" },
|
|
125
|
-
{ name: "u_lightCount", kind: "float" },
|
|
126
|
-
{ name: "u_lightData", kind: "any" },
|
|
127
|
-
{ name: "u_normalTexture", kind: "texture2d" },
|
|
128
|
-
{ name: "u_normalScale", kind: "float" },
|
|
129
|
-
{ name: "u_modelViewProjection", kind: "mat4" },
|
|
130
|
-
{ name: "u_normalMatrix", kind: "mat4" }
|
|
131
|
-
]
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function validateNonNegative(value: number, label: string): void {
|
|
137
|
-
if (!Number.isFinite(value) || value < 0) {
|
|
138
|
-
throw new RangeError(`PBR ${label} must be finite and non-negative`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function validateFinite(value: number, label: string): void {
|
|
143
|
-
if (!Number.isFinite(value)) {
|
|
144
|
-
throw new RangeError(`PBR ${label} must be finite`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function validateMipCount(value: number): void {
|
|
149
|
-
if (!Number.isInteger(value) || value < 1) {
|
|
150
|
-
throw new RangeError("PBR environmentMapMipCount must be a positive integer");
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function validateProceduralEnvironmentMap(value: NormalMappedPBRProceduralEnvironmentMapOptions): void {
|
|
155
|
-
validateColor3(value.skyColor, "proceduralEnvironmentMap.skyColor");
|
|
156
|
-
validateColor3(value.horizonColor, "proceduralEnvironmentMap.horizonColor");
|
|
157
|
-
validateColor3(value.groundColor, "proceduralEnvironmentMap.groundColor");
|
|
158
|
-
validateColor3(value.specularColor, "proceduralEnvironmentMap.specularColor");
|
|
159
|
-
validateNonNegative(value.intensity, "proceduralEnvironmentMap.intensity");
|
|
160
|
-
validateNonNegative(value.specularIntensity, "proceduralEnvironmentMap.specularIntensity");
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function validateUnit(value: number, label: string): void {
|
|
164
|
-
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
165
|
-
throw new RangeError(`PBR ${label} must be finite and within [0, 1]`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function validateColor4(value: readonly number[], label: string): void {
|
|
170
|
-
if (value.length !== 4 || value.some((channel) => !Number.isFinite(channel) || channel < 0 || channel > 1)) {
|
|
171
|
-
throw new RangeError(`PBR ${label} must contain four finite values in [0, 1]`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function validateColor3(value: readonly number[], label: string): void {
|
|
176
|
-
if (value.length !== 3 || value.some((channel) => !Number.isFinite(channel) || channel < 0 || channel > 1)) {
|
|
177
|
-
throw new RangeError(`PBR ${label} must contain three finite values in [0, 1]`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function identityMatrix(): Float32Array {
|
|
182
|
-
return new Float32Array([
|
|
183
|
-
1, 0, 0, 0,
|
|
184
|
-
0, 1, 0, 0,
|
|
185
|
-
0, 0, 1, 0,
|
|
186
|
-
0, 0, 0, 1
|
|
187
|
-
]);
|
|
188
|
-
}
|
package/src/OceanFixtures.ts
DELETED
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
export type OceanFixturePreset = "calm" | "moderate" | "rough" | "storm";
|
|
2
|
-
|
|
3
|
-
export interface OceanFixtureOptions {
|
|
4
|
-
readonly preset?: OceanFixturePreset;
|
|
5
|
-
readonly seed?: number;
|
|
6
|
-
readonly elapsedSeconds?: number;
|
|
7
|
-
readonly sampleCount?: number;
|
|
8
|
-
readonly cameraX?: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface OceanWaveDescriptor {
|
|
12
|
-
readonly amplitude: number;
|
|
13
|
-
readonly wavelength: number;
|
|
14
|
-
readonly speed: number;
|
|
15
|
-
readonly direction: readonly [number, number];
|
|
16
|
-
readonly steepness: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface OceanWaveSample {
|
|
20
|
-
readonly x: number;
|
|
21
|
-
readonly z: number;
|
|
22
|
-
readonly height: number;
|
|
23
|
-
readonly horizontalDisplacement: readonly [number, number];
|
|
24
|
-
readonly normal: readonly [number, number, number];
|
|
25
|
-
readonly foam: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface OceanFoamPatch {
|
|
29
|
-
readonly id: string;
|
|
30
|
-
readonly x: number;
|
|
31
|
-
readonly z: number;
|
|
32
|
-
readonly intensity: number;
|
|
33
|
-
readonly radius: number;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface OceanBuoyancySample {
|
|
37
|
-
readonly objectId: "marker-buoy";
|
|
38
|
-
readonly samplePointCount: number;
|
|
39
|
-
readonly submergedPointCount: number;
|
|
40
|
-
readonly waterHeight: number;
|
|
41
|
-
readonly submergedVolume: number;
|
|
42
|
-
readonly force: readonly [number, number, number];
|
|
43
|
-
readonly drag: readonly [number, number, number];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface OceanFixtureSample {
|
|
47
|
-
readonly id: "external-parity-old-branch-ocean-fixture";
|
|
48
|
-
readonly source: "origin-master-ocean-gerstner-foam-buoyancy-adapted";
|
|
49
|
-
readonly sourceFiles: readonly string[];
|
|
50
|
-
readonly preset: OceanFixturePreset;
|
|
51
|
-
readonly seed: number;
|
|
52
|
-
readonly elapsedSeconds: number;
|
|
53
|
-
readonly waveCount: number;
|
|
54
|
-
readonly waves: readonly OceanWaveDescriptor[];
|
|
55
|
-
readonly samples: readonly OceanWaveSample[];
|
|
56
|
-
readonly foamPatches: readonly OceanFoamPatch[];
|
|
57
|
-
readonly buoyancy: OceanBuoyancySample;
|
|
58
|
-
readonly minHeight: number;
|
|
59
|
-
readonly maxHeight: number;
|
|
60
|
-
readonly averageHeight: number;
|
|
61
|
-
readonly averageFoam: number;
|
|
62
|
-
readonly maxFoam: number;
|
|
63
|
-
readonly hash: string;
|
|
64
|
-
readonly claimBoundary: string;
|
|
65
|
-
readonly blockedClaims: readonly string[];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const sourceFiles = [
|
|
69
|
-
"origin/master:src/ocean/GerstnerWaves.ts",
|
|
70
|
-
"origin/master:src/ocean/FoamGenerator.ts",
|
|
71
|
-
"origin/master:src/ocean/BuoyancySystem.ts",
|
|
72
|
-
"origin/master:src/ocean/OceanFFT.ts",
|
|
73
|
-
"origin/master:src/ocean/OceanRenderer.ts"
|
|
74
|
-
] as const;
|
|
75
|
-
|
|
76
|
-
const blockedClaims = [
|
|
77
|
-
"FFT ocean spectrum parity",
|
|
78
|
-
"planar reflection/refraction water renderer",
|
|
79
|
-
"underwater volume rendering",
|
|
80
|
-
"screen-space caustics parity",
|
|
81
|
-
"shoreline foam simulation",
|
|
82
|
-
"production buoyancy physics",
|
|
83
|
-
"Unity HDRP water parity",
|
|
84
|
-
"Unreal Water plugin parity"
|
|
85
|
-
] as const;
|
|
86
|
-
|
|
87
|
-
export function sampleOceanFixture(options: OceanFixtureOptions = {}): OceanFixtureSample {
|
|
88
|
-
const preset = options.preset ?? "moderate";
|
|
89
|
-
const seed = integerOption(options.seed ?? 0x0cea6, "seed");
|
|
90
|
-
const elapsedSeconds = nonNegativeNumber(options.elapsedSeconds ?? 0, "elapsedSeconds");
|
|
91
|
-
const sampleCount = integerRange(options.sampleCount ?? 9, 5, 32, "sampleCount");
|
|
92
|
-
const cameraX = finiteNumber(options.cameraX ?? 0, "cameraX");
|
|
93
|
-
const waves = oceanPresetWaves(preset);
|
|
94
|
-
const samples = Array.from({ length: sampleCount }, (_, index) => {
|
|
95
|
-
const t = sampleCount <= 1 ? 0 : index / (sampleCount - 1);
|
|
96
|
-
const x = round3(-1.2 + t * 2.4 + Math.sin(seed + index) * 0.035 + cameraX * 0.08);
|
|
97
|
-
const z = round3(0.42 + Math.cos(seed * 0.17 + index) * 0.08);
|
|
98
|
-
const evaluated = evaluateWaves(waves, x, z, elapsedSeconds);
|
|
99
|
-
const compression = waveCompression(waves, x, z, elapsedSeconds);
|
|
100
|
-
const crestFoam = Math.abs(evaluated.height) * (preset === "calm" ? 0.16 : 0.42);
|
|
101
|
-
const foam = round3(Math.max(0, (1.08 - compression) * 1.45 + crestFoam));
|
|
102
|
-
return {
|
|
103
|
-
x,
|
|
104
|
-
z,
|
|
105
|
-
height: evaluated.height,
|
|
106
|
-
horizontalDisplacement: evaluated.horizontalDisplacement,
|
|
107
|
-
normal: evaluated.normal,
|
|
108
|
-
foam
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
const foamPatches = samples
|
|
112
|
-
.filter((sample) => sample.foam > 0.08)
|
|
113
|
-
.slice(0, 8)
|
|
114
|
-
.map((sample, index) => ({
|
|
115
|
-
id: `ocean-foam-${index}`,
|
|
116
|
-
x: sample.x,
|
|
117
|
-
z: sample.z,
|
|
118
|
-
intensity: sample.foam,
|
|
119
|
-
radius: round3(0.035 + sample.foam * 0.04)
|
|
120
|
-
}));
|
|
121
|
-
const buoyancy = calculateBuoyancy(waves, elapsedSeconds, cameraX);
|
|
122
|
-
const heights = samples.map((sample) => sample.height);
|
|
123
|
-
const foams = samples.map((sample) => sample.foam);
|
|
124
|
-
const hash = stableHash([
|
|
125
|
-
preset,
|
|
126
|
-
seed,
|
|
127
|
-
elapsedSeconds.toFixed(3),
|
|
128
|
-
samples.map((sample) => `${sample.x}:${sample.height}:${sample.foam}`).join("|"),
|
|
129
|
-
foamPatches.length,
|
|
130
|
-
buoyancy.force.join(",")
|
|
131
|
-
].join("#"));
|
|
132
|
-
return {
|
|
133
|
-
id: "external-parity-old-branch-ocean-fixture",
|
|
134
|
-
source: "origin-master-ocean-gerstner-foam-buoyancy-adapted",
|
|
135
|
-
sourceFiles,
|
|
136
|
-
preset,
|
|
137
|
-
seed,
|
|
138
|
-
elapsedSeconds: round3(elapsedSeconds),
|
|
139
|
-
waveCount: waves.length,
|
|
140
|
-
waves,
|
|
141
|
-
samples,
|
|
142
|
-
foamPatches,
|
|
143
|
-
buoyancy,
|
|
144
|
-
minHeight: round3(Math.min(...heights)),
|
|
145
|
-
maxHeight: round3(Math.max(...heights)),
|
|
146
|
-
averageHeight: round3(heights.reduce((sum, value) => sum + value, 0) / heights.length),
|
|
147
|
-
averageFoam: round3(foams.reduce((sum, value) => sum + value, 0) / foams.length),
|
|
148
|
-
maxFoam: round3(Math.max(...foams)),
|
|
149
|
-
hash,
|
|
150
|
-
claimBoundary: "This adapts old Gerstner, foam, and buoyancy concepts into deterministic local telemetry and simple markers; it does not implement a production ocean renderer.",
|
|
151
|
-
blockedClaims
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function oceanPresetWaves(preset: OceanFixturePreset): readonly OceanWaveDescriptor[] {
|
|
156
|
-
if (preset === "calm") {
|
|
157
|
-
return [
|
|
158
|
-
wave(0.045, 0.9, 0.55, [1, 0.12], 0.2),
|
|
159
|
-
wave(0.026, 0.48, 0.42, [0.58, 0.82], 0.18)
|
|
160
|
-
];
|
|
161
|
-
}
|
|
162
|
-
if (preset === "rough") {
|
|
163
|
-
return [
|
|
164
|
-
wave(0.13, 1.4, 0.86, [1, 0.08], 0.58),
|
|
165
|
-
wave(0.09, 0.82, 0.72, [0.86, 0.5], 0.48),
|
|
166
|
-
wave(0.052, 0.46, 0.58, [0.54, 0.84], 0.42),
|
|
167
|
-
wave(0.032, 0.28, 0.48, [0.35, 0.94], 0.36)
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
if (preset === "storm") {
|
|
171
|
-
return [
|
|
172
|
-
wave(0.18, 1.75, 1.02, [1, 0.06], 0.72),
|
|
173
|
-
wave(0.13, 1.08, 0.88, [0.92, 0.39], 0.62),
|
|
174
|
-
wave(0.082, 0.62, 0.75, [0.76, 0.65], 0.54),
|
|
175
|
-
wave(0.052, 0.36, 0.62, [0.48, 0.88], 0.48),
|
|
176
|
-
wave(0.034, 0.22, 0.52, [0.28, 0.96], 0.42)
|
|
177
|
-
];
|
|
178
|
-
}
|
|
179
|
-
return [
|
|
180
|
-
wave(0.08, 1.1, 0.72, [1, 0.1], 0.38),
|
|
181
|
-
wave(0.055, 0.68, 0.58, [0.8, 0.6], 0.32),
|
|
182
|
-
wave(0.036, 0.38, 0.46, [0.6, 0.8], 0.28)
|
|
183
|
-
];
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function wave(amplitude: number, wavelength: number, speed: number, direction: readonly [number, number], steepness: number): OceanWaveDescriptor {
|
|
187
|
-
const length = Math.hypot(direction[0], direction[1]) || 1;
|
|
188
|
-
return {
|
|
189
|
-
amplitude,
|
|
190
|
-
wavelength,
|
|
191
|
-
speed,
|
|
192
|
-
direction: [round3(direction[0] / length), round3(direction[1] / length)],
|
|
193
|
-
steepness: Math.min(1, steepness)
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function evaluateWaves(waves: readonly OceanWaveDescriptor[], x: number, z: number, time: number): {
|
|
198
|
-
readonly height: number;
|
|
199
|
-
readonly horizontalDisplacement: readonly [number, number];
|
|
200
|
-
readonly normal: readonly [number, number, number];
|
|
201
|
-
} {
|
|
202
|
-
let height = 0;
|
|
203
|
-
let dx = 0;
|
|
204
|
-
let dz = 0;
|
|
205
|
-
let nx = 0;
|
|
206
|
-
let ny = 1;
|
|
207
|
-
let nz = 0;
|
|
208
|
-
for (const descriptor of waves) {
|
|
209
|
-
const k = (2 * Math.PI) / descriptor.wavelength;
|
|
210
|
-
const omega = descriptor.speed * k;
|
|
211
|
-
const phase = k * (descriptor.direction[0] * x + descriptor.direction[1] * z) - omega * time;
|
|
212
|
-
const sin = Math.sin(phase);
|
|
213
|
-
const cos = Math.cos(phase);
|
|
214
|
-
const q = descriptor.steepness / Math.max(0.0001, descriptor.amplitude * k * waves.length);
|
|
215
|
-
const waveAmplitude = k * descriptor.amplitude;
|
|
216
|
-
height += descriptor.amplitude * sin;
|
|
217
|
-
dx += q * descriptor.amplitude * descriptor.direction[0] * cos;
|
|
218
|
-
dz += q * descriptor.amplitude * descriptor.direction[1] * cos;
|
|
219
|
-
nx -= descriptor.direction[0] * waveAmplitude * cos;
|
|
220
|
-
ny -= q * waveAmplitude * sin;
|
|
221
|
-
nz -= descriptor.direction[1] * waveAmplitude * cos;
|
|
222
|
-
}
|
|
223
|
-
const normalLength = Math.hypot(nx, ny, nz) || 1;
|
|
224
|
-
return {
|
|
225
|
-
height: round3(height),
|
|
226
|
-
horizontalDisplacement: [round3(dx), round3(dz)],
|
|
227
|
-
normal: [round3(nx / normalLength), round3(ny / normalLength), round3(nz / normalLength)]
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function waveCompression(waves: readonly OceanWaveDescriptor[], x: number, z: number, time: number): number {
|
|
232
|
-
let compression = 1;
|
|
233
|
-
for (const descriptor of waves) {
|
|
234
|
-
const k = (2 * Math.PI) / descriptor.wavelength;
|
|
235
|
-
const omega = descriptor.speed * k;
|
|
236
|
-
const phase = k * (descriptor.direction[0] * x + descriptor.direction[1] * z) - omega * time;
|
|
237
|
-
compression -= descriptor.steepness * descriptor.amplitude * k * Math.sin(phase) * 0.35;
|
|
238
|
-
}
|
|
239
|
-
return round3(compression);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function calculateBuoyancy(waves: readonly OceanWaveDescriptor[], time: number, cameraX: number): OceanBuoyancySample {
|
|
243
|
-
const position: [number, number, number] = [round3(cameraX * 0.04), -0.12, 0.44];
|
|
244
|
-
const velocity: [number, number, number] = [0.18, 0, -0.04];
|
|
245
|
-
const samplePoints: readonly (readonly [number, number, number])[] = [
|
|
246
|
-
[-0.08, -0.035, -0.045],
|
|
247
|
-
[0.08, -0.035, -0.045],
|
|
248
|
-
[-0.08, -0.035, 0.045],
|
|
249
|
-
[0.08, -0.035, 0.045],
|
|
250
|
-
[0, 0.035, 0]
|
|
251
|
-
];
|
|
252
|
-
const mass = 18;
|
|
253
|
-
const volume = 0.055;
|
|
254
|
-
const density = 1000;
|
|
255
|
-
const gravity = 9.81;
|
|
256
|
-
let submerged = 0;
|
|
257
|
-
let waterHeightSum = 0;
|
|
258
|
-
let buoyancyY = -mass * gravity;
|
|
259
|
-
let dragX = 0;
|
|
260
|
-
let dragZ = 0;
|
|
261
|
-
for (const point of samplePoints) {
|
|
262
|
-
const worldX = position[0] + point[0];
|
|
263
|
-
const worldY = position[1] + point[1];
|
|
264
|
-
const worldZ = position[2] + point[2];
|
|
265
|
-
const waterHeight = evaluateWaves(waves, worldX, worldZ, time).height;
|
|
266
|
-
waterHeightSum += waterHeight;
|
|
267
|
-
const depth = waterHeight - worldY;
|
|
268
|
-
if (depth <= 0) continue;
|
|
269
|
-
submerged += 1;
|
|
270
|
-
buoyancyY += density * gravity * depth / samplePoints.length;
|
|
271
|
-
const speedSq = velocity[0] * velocity[0] + velocity[2] * velocity[2];
|
|
272
|
-
const drag = 0.5 * density * 0.38 * depth * speedSq / samplePoints.length;
|
|
273
|
-
dragX -= velocity[0] * drag;
|
|
274
|
-
dragZ -= velocity[2] * drag;
|
|
275
|
-
}
|
|
276
|
-
return {
|
|
277
|
-
objectId: "marker-buoy",
|
|
278
|
-
samplePointCount: samplePoints.length,
|
|
279
|
-
submergedPointCount: submerged,
|
|
280
|
-
waterHeight: round3(waterHeightSum / samplePoints.length),
|
|
281
|
-
submergedVolume: round3((submerged / samplePoints.length) * volume),
|
|
282
|
-
force: [round3(dragX), round3(buoyancyY), round3(dragZ)],
|
|
283
|
-
drag: [round3(dragX), 0, round3(dragZ)]
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function integerOption(value: number, name: string): number {
|
|
288
|
-
if (!Number.isInteger(value)) throw new RangeError(`${name} must be an integer.`);
|
|
289
|
-
return value;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function integerRange(value: number, min: number, max: number, name: string): number {
|
|
293
|
-
if (!Number.isInteger(value) || value < min || value > max) throw new RangeError(`${name} must be an integer between ${min} and ${max}.`);
|
|
294
|
-
return value;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function nonNegativeNumber(value: number, name: string): number {
|
|
298
|
-
if (!Number.isFinite(value) || value < 0) throw new RangeError(`${name} must be non-negative.`);
|
|
299
|
-
return value;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function finiteNumber(value: number, name: string): number {
|
|
303
|
-
if (!Number.isFinite(value)) throw new RangeError(`${name} must be finite.`);
|
|
304
|
-
return value;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function round3(value: number): number {
|
|
308
|
-
return Math.round(value * 1_000) / 1_000;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function stableHash(value: string): string {
|
|
312
|
-
let hash = 0x811c9dc5;
|
|
313
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
314
|
-
hash ^= value.charCodeAt(index);
|
|
315
|
-
hash = Math.imul(hash, 0x01000193);
|
|
316
|
-
}
|
|
317
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
318
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { PBRProceduralEnvironmentMapOptions } from "./PBRMaterial";
|
|
2
|
-
|
|
3
|
-
export const DEFAULT_PBR_ENVIRONMENT_INTENSITY = 0.18;
|
|
4
|
-
|
|
5
|
-
export const DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP: PBRProceduralEnvironmentMapOptions = {
|
|
6
|
-
skyColor: [0.45, 0.55, 0.72],
|
|
7
|
-
horizonColor: [0.72, 0.68, 0.58],
|
|
8
|
-
groundColor: [0.08, 0.08, 0.09],
|
|
9
|
-
specularColor: [1, 1, 1],
|
|
10
|
-
intensity: 0.28,
|
|
11
|
-
specularIntensity: 0.65
|
|
12
|
-
};
|