@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,200 +0,0 @@
|
|
|
1
|
-
export interface SpaceEnvironmentStar {
|
|
2
|
-
readonly x: number;
|
|
3
|
-
readonly y: number;
|
|
4
|
-
readonly depth: number;
|
|
5
|
-
readonly size: number;
|
|
6
|
-
readonly speed: number;
|
|
7
|
-
readonly brightness: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface SpaceEnvironmentNebula {
|
|
11
|
-
readonly x: number;
|
|
12
|
-
readonly y: number;
|
|
13
|
-
readonly radius: number;
|
|
14
|
-
readonly color: readonly [number, number, number];
|
|
15
|
-
readonly alpha: number;
|
|
16
|
-
readonly drift: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface SpaceEnvironmentDustParticle {
|
|
20
|
-
readonly x: number;
|
|
21
|
-
readonly y: number;
|
|
22
|
-
readonly velocityX: number;
|
|
23
|
-
readonly velocityY: number;
|
|
24
|
-
readonly size: number;
|
|
25
|
-
readonly alpha: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface SpaceEnvironmentFixture {
|
|
29
|
-
readonly id: "external-parity-old-branch-space-environment";
|
|
30
|
-
readonly source: "origin-master-space-environment-adapted";
|
|
31
|
-
readonly sourceFiles: readonly string[];
|
|
32
|
-
readonly width: number;
|
|
33
|
-
readonly height: number;
|
|
34
|
-
readonly elapsedSeconds: number;
|
|
35
|
-
readonly layerScroll: {
|
|
36
|
-
readonly distantStars: number;
|
|
37
|
-
readonly foregroundStars: number;
|
|
38
|
-
};
|
|
39
|
-
readonly stars: readonly SpaceEnvironmentStar[];
|
|
40
|
-
readonly nebulae: readonly SpaceEnvironmentNebula[];
|
|
41
|
-
readonly dust: readonly SpaceEnvironmentDustParticle[];
|
|
42
|
-
readonly starCount: number;
|
|
43
|
-
readonly nebulaCount: number;
|
|
44
|
-
readonly dustCount: number;
|
|
45
|
-
readonly visibleStarCount: number;
|
|
46
|
-
readonly averageStarBrightness: number;
|
|
47
|
-
readonly nebulaCoverage: number;
|
|
48
|
-
readonly dustAlpha: number;
|
|
49
|
-
readonly blockedClaims: readonly string[];
|
|
50
|
-
readonly claimBoundary: string;
|
|
51
|
-
readonly hash: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const sourceFiles = [
|
|
55
|
-
"origin/master:examples/space-shooter/src/SpaceEnvironment.ts",
|
|
56
|
-
"origin/master:src/assets/ProceduralTextures.ts"
|
|
57
|
-
] as const;
|
|
58
|
-
|
|
59
|
-
const blockedClaims = [
|
|
60
|
-
"3D volumetric nebula rendering",
|
|
61
|
-
"HDR skybox environment lighting",
|
|
62
|
-
"production space-scene asset pack",
|
|
63
|
-
"Unity VFX Graph background parity",
|
|
64
|
-
"Unreal Niagara background parity"
|
|
65
|
-
] as const;
|
|
66
|
-
|
|
67
|
-
const nebulaPalette = [
|
|
68
|
-
[0.42, 0.18, 0.76],
|
|
69
|
-
[0.12, 0.42, 0.88],
|
|
70
|
-
[0.78, 0.18, 0.48],
|
|
71
|
-
[0.1, 0.68, 0.72],
|
|
72
|
-
[0.86, 0.46, 0.72]
|
|
73
|
-
] as const;
|
|
74
|
-
|
|
75
|
-
export function sampleSpaceEnvironmentFixture(options: {
|
|
76
|
-
readonly width?: number;
|
|
77
|
-
readonly height?: number;
|
|
78
|
-
readonly elapsedSeconds?: number;
|
|
79
|
-
readonly seed?: number;
|
|
80
|
-
readonly starCount?: number;
|
|
81
|
-
readonly nebulaCount?: number;
|
|
82
|
-
readonly dustCount?: number;
|
|
83
|
-
} = {}): SpaceEnvironmentFixture {
|
|
84
|
-
const width = positiveInteger(options.width ?? 960, "width");
|
|
85
|
-
const height = positiveInteger(options.height ?? 540, "height");
|
|
86
|
-
const elapsedSeconds = finiteNonNegative(options.elapsedSeconds ?? 0, "elapsedSeconds");
|
|
87
|
-
const seed = positiveInteger(options.seed ?? 0x51ace, "seed");
|
|
88
|
-
const starCount = positiveInteger(options.starCount ?? 72, "starCount");
|
|
89
|
-
const nebulaCount = positiveInteger(options.nebulaCount ?? 5, "nebulaCount");
|
|
90
|
-
const dustCount = positiveInteger(options.dustCount ?? 96, "dustCount");
|
|
91
|
-
const stars = Array.from({ length: starCount }, (_, index) => sampleStar(seed, index, width, height, elapsedSeconds));
|
|
92
|
-
const nebulae = Array.from({ length: nebulaCount }, (_, index) => sampleNebula(seed, index, width, height, elapsedSeconds));
|
|
93
|
-
const dust = Array.from({ length: dustCount }, (_, index) => sampleDust(seed, index, width, height, elapsedSeconds));
|
|
94
|
-
const visibleStarCount = stars.filter((star) => star.x >= 0 && star.x <= width && star.y >= 0 && star.y <= height).length;
|
|
95
|
-
const averageStarBrightness = stars.reduce((sum, star) => sum + star.brightness, 0) / stars.length;
|
|
96
|
-
const nebulaCoverage = nebulae.reduce((sum, nebula) => sum + Math.PI * nebula.radius * nebula.radius, 0) / (width * height);
|
|
97
|
-
const dustAlpha = dust.reduce((sum, particle) => sum + particle.alpha, 0) / dust.length;
|
|
98
|
-
const fixtureWithoutHash = {
|
|
99
|
-
id: "external-parity-old-branch-space-environment" as const,
|
|
100
|
-
source: "origin-master-space-environment-adapted" as const,
|
|
101
|
-
sourceFiles,
|
|
102
|
-
width,
|
|
103
|
-
height,
|
|
104
|
-
elapsedSeconds: Number(elapsedSeconds.toFixed(4)),
|
|
105
|
-
layerScroll: {
|
|
106
|
-
distantStars: Number(((elapsedSeconds * 10) % height).toFixed(3)),
|
|
107
|
-
foregroundStars: Number(((elapsedSeconds * 25) % height).toFixed(3))
|
|
108
|
-
},
|
|
109
|
-
stars,
|
|
110
|
-
nebulae,
|
|
111
|
-
dust,
|
|
112
|
-
starCount,
|
|
113
|
-
nebulaCount,
|
|
114
|
-
dustCount,
|
|
115
|
-
visibleStarCount,
|
|
116
|
-
averageStarBrightness: Number(averageStarBrightness.toFixed(4)),
|
|
117
|
-
nebulaCoverage: Number(nebulaCoverage.toFixed(4)),
|
|
118
|
-
dustAlpha: Number(dustAlpha.toFixed(4)),
|
|
119
|
-
blockedClaims,
|
|
120
|
-
claimBoundary: "This fixture adapts old scrolling starfield, nebula, and dust concepts into deterministic 2D/background evidence. It does not claim volumetric space rendering, HDR skybox lighting, or Unity/Unreal VFX parity."
|
|
121
|
-
};
|
|
122
|
-
return {
|
|
123
|
-
...fixtureWithoutHash,
|
|
124
|
-
hash: stableHash(JSON.stringify(fixtureWithoutHash))
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function sampleStar(seed: number, index: number, width: number, height: number, elapsedSeconds: number): SpaceEnvironmentStar {
|
|
129
|
-
const depth = hash01(seed, index, 11);
|
|
130
|
-
const speed = 20 + hash01(seed, index, 23) * 80;
|
|
131
|
-
const rawY = hash01(seed, index, 37) * height + elapsedSeconds * speed;
|
|
132
|
-
const twinkle = 0.8 + Math.sin(elapsedSeconds * speed * 0.08 + hash01(seed, index, 41) * Math.PI * 2) * 0.2;
|
|
133
|
-
return {
|
|
134
|
-
x: Number((hash01(seed, index, 17) * width).toFixed(3)),
|
|
135
|
-
y: Number((rawY % height).toFixed(3)),
|
|
136
|
-
depth: Number(depth.toFixed(4)),
|
|
137
|
-
size: Number((0.8 + depth * 2.2).toFixed(3)),
|
|
138
|
-
speed: Number(speed.toFixed(3)),
|
|
139
|
-
brightness: Number(((0.52 + depth * 0.48) * twinkle).toFixed(4))
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function sampleNebula(seed: number, index: number, width: number, height: number, elapsedSeconds: number): SpaceEnvironmentNebula {
|
|
144
|
-
const radius = width * (0.12 + hash01(seed, index, 53) * 0.18);
|
|
145
|
-
const drift = (hash01(seed, index, 67) - 0.5) * 10;
|
|
146
|
-
const rawY = hash01(seed, index, 79) * height + elapsedSeconds * drift;
|
|
147
|
-
const palette = nebulaPalette[index % nebulaPalette.length] ?? nebulaPalette[0];
|
|
148
|
-
return {
|
|
149
|
-
x: Number((hash01(seed, index, 83) * width).toFixed(3)),
|
|
150
|
-
y: Number((((rawY % height) + height) % height).toFixed(3)),
|
|
151
|
-
radius: Number(radius.toFixed(3)),
|
|
152
|
-
color: palette,
|
|
153
|
-
alpha: Number((0.18 + hash01(seed, index, 97) * 0.22).toFixed(4)),
|
|
154
|
-
drift: Number(drift.toFixed(3))
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function sampleDust(seed: number, index: number, width: number, height: number, elapsedSeconds: number): SpaceEnvironmentDustParticle {
|
|
159
|
-
const velocityX = (hash01(seed, index, 109) - 0.5) * 20;
|
|
160
|
-
const velocityY = 30 + hash01(seed, index, 127) * 50;
|
|
161
|
-
const rawX = hash01(seed, index, 131) * width + elapsedSeconds * velocityX;
|
|
162
|
-
const rawY = hash01(seed, index, 149) * height + elapsedSeconds * velocityY;
|
|
163
|
-
return {
|
|
164
|
-
x: Number((((rawX % width) + width) % width).toFixed(3)),
|
|
165
|
-
y: Number((rawY % height).toFixed(3)),
|
|
166
|
-
velocityX: Number(velocityX.toFixed(3)),
|
|
167
|
-
velocityY: Number(velocityY.toFixed(3)),
|
|
168
|
-
size: Number((0.4 + hash01(seed, index, 157) * 1.3).toFixed(3)),
|
|
169
|
-
alpha: Number((0.28 + hash01(seed, index, 163) * 0.38).toFixed(4))
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function hash01(seed: number, index: number, salt: number): number {
|
|
174
|
-
let hash = (seed ^ Math.imul(index + 1, 0x9e3779b1) ^ Math.imul(salt + 1, 0x85ebca6b)) >>> 0;
|
|
175
|
-
hash ^= hash >>> 16;
|
|
176
|
-
hash = Math.imul(hash, 0x7feb352d) >>> 0;
|
|
177
|
-
hash ^= hash >>> 15;
|
|
178
|
-
hash = Math.imul(hash, 0x846ca68b) >>> 0;
|
|
179
|
-
hash ^= hash >>> 16;
|
|
180
|
-
return (hash >>> 0) / 0xffffffff;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function positiveInteger(value: number, name: string): number {
|
|
184
|
-
if (!Number.isInteger(value) || value <= 0) throw new RangeError(`Space environment ${name} must be a positive integer.`);
|
|
185
|
-
return value;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function finiteNonNegative(value: number, name: string): number {
|
|
189
|
-
if (!Number.isFinite(value) || value < 0) throw new RangeError(`Space environment ${name} must be finite and non-negative.`);
|
|
190
|
-
return value;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function stableHash(value: string): string {
|
|
194
|
-
let hash = 0x811c9dc5;
|
|
195
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
196
|
-
hash ^= value.charCodeAt(index);
|
|
197
|
-
hash = Math.imul(hash, 0x01000193);
|
|
198
|
-
}
|
|
199
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
200
|
-
}
|
package/src/SpriteGeometry.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Geometry } from "./Geometry";
|
|
2
|
-
import { IndexBuffer } from "./IndexBuffer";
|
|
3
|
-
import { VertexBuffer } from "./VertexBuffer";
|
|
4
|
-
import { VertexFormat } from "./VertexFormat";
|
|
5
|
-
|
|
6
|
-
export function createSpriteQuadGeometry(): Geometry {
|
|
7
|
-
const vertices = new VertexBuffer(VertexFormat.P3N3T2, 4);
|
|
8
|
-
vertices.setAttribute(0, "position", [-0.5, -0.5, 0]);
|
|
9
|
-
vertices.setAttribute(0, "normal", [0, 0, 1]);
|
|
10
|
-
vertices.setAttribute(0, "uv", [0, 1]);
|
|
11
|
-
vertices.setAttribute(1, "position", [0.5, -0.5, 0]);
|
|
12
|
-
vertices.setAttribute(1, "normal", [0, 0, 1]);
|
|
13
|
-
vertices.setAttribute(1, "uv", [1, 1]);
|
|
14
|
-
vertices.setAttribute(2, "position", [0.5, 0.5, 0]);
|
|
15
|
-
vertices.setAttribute(2, "normal", [0, 0, 1]);
|
|
16
|
-
vertices.setAttribute(2, "uv", [1, 0]);
|
|
17
|
-
vertices.setAttribute(3, "position", [-0.5, 0.5, 0]);
|
|
18
|
-
vertices.setAttribute(3, "normal", [0, 0, 1]);
|
|
19
|
-
vertices.setAttribute(3, "uv", [0, 0]);
|
|
20
|
-
return new Geometry(vertices, new IndexBuffer([0, 1, 2, 0, 2, 3], 4));
|
|
21
|
-
}
|
package/src/StereoCameraRig.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { invertMat4, multiplyMat4, type Mat4, type Vec3 } from "@aura3d/scene";
|
|
2
|
-
import type { PerspectiveCameraFrame } from "./CameraFraming";
|
|
3
|
-
|
|
4
|
-
export type StereoEye = "left" | "right";
|
|
5
|
-
export type StereoLayout = "side-by-side" | "over-under";
|
|
6
|
-
|
|
7
|
-
export interface StereoViewport {
|
|
8
|
-
readonly x: number;
|
|
9
|
-
readonly y: number;
|
|
10
|
-
readonly width: number;
|
|
11
|
-
readonly height: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface StereoCameraRigOptions {
|
|
15
|
-
readonly frame: Pick<PerspectiveCameraFrame, "cameraPosition" | "near" | "projectionMatrix" | "viewMatrix">;
|
|
16
|
-
readonly viewport: StereoViewport;
|
|
17
|
-
readonly eyeSeparation?: number;
|
|
18
|
-
readonly convergenceDistance?: number;
|
|
19
|
-
readonly layout?: StereoLayout;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface StereoEyeView {
|
|
23
|
-
readonly eye: StereoEye;
|
|
24
|
-
readonly eyeOffset: number;
|
|
25
|
-
readonly cameraPosition: Vec3;
|
|
26
|
-
readonly viewport: StereoViewport;
|
|
27
|
-
readonly viewMatrix: Mat4;
|
|
28
|
-
readonly projectionMatrix: Mat4;
|
|
29
|
-
readonly viewProjectionMatrix: Mat4;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface StereoCameraRig {
|
|
33
|
-
readonly layout: StereoLayout;
|
|
34
|
-
readonly eyeSeparation: number;
|
|
35
|
-
readonly convergenceDistance: number;
|
|
36
|
-
readonly views: readonly [StereoEyeView, StereoEyeView];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function createStereoCameraRig(options: StereoCameraRigOptions): StereoCameraRig {
|
|
40
|
-
validateViewport(options.viewport);
|
|
41
|
-
const eyeSeparation = options.eyeSeparation ?? 0.064;
|
|
42
|
-
const convergenceDistance = options.convergenceDistance ?? 10;
|
|
43
|
-
const layout = options.layout ?? "side-by-side";
|
|
44
|
-
if (!Number.isFinite(eyeSeparation) || eyeSeparation <= 0 || eyeSeparation > 1) {
|
|
45
|
-
throw new RangeError("Stereo eyeSeparation must be finite and in (0, 1].");
|
|
46
|
-
}
|
|
47
|
-
if (!Number.isFinite(convergenceDistance) || convergenceDistance <= options.frame.near) {
|
|
48
|
-
throw new RangeError("Stereo convergenceDistance must be finite and greater than the near plane.");
|
|
49
|
-
}
|
|
50
|
-
const half = eyeSeparation / 2;
|
|
51
|
-
const left = createEyeView("left", -half, options, layout, convergenceDistance);
|
|
52
|
-
const right = createEyeView("right", half, options, layout, convergenceDistance);
|
|
53
|
-
return {
|
|
54
|
-
layout,
|
|
55
|
-
eyeSeparation,
|
|
56
|
-
convergenceDistance,
|
|
57
|
-
views: [left, right]
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function createEyeView(
|
|
62
|
-
eye: StereoEye,
|
|
63
|
-
eyeOffset: number,
|
|
64
|
-
options: StereoCameraRigOptions,
|
|
65
|
-
layout: StereoLayout,
|
|
66
|
-
convergenceDistance: number
|
|
67
|
-
): StereoEyeView {
|
|
68
|
-
const viewMatrix = multiplyMat4(translationMat4(-eyeOffset, 0, 0), options.frame.viewMatrix as Mat4);
|
|
69
|
-
const projectionMatrix = offsetProjectionForConvergence(options.frame.projectionMatrix as Mat4, eyeOffset, options.frame.near, convergenceDistance);
|
|
70
|
-
return {
|
|
71
|
-
eye,
|
|
72
|
-
eyeOffset,
|
|
73
|
-
cameraPosition: offsetCameraPosition(options.frame.viewMatrix as Mat4, options.frame.cameraPosition, eyeOffset),
|
|
74
|
-
viewport: eyeViewport(eye, options.viewport, layout),
|
|
75
|
-
viewMatrix,
|
|
76
|
-
projectionMatrix,
|
|
77
|
-
viewProjectionMatrix: multiplyMat4(projectionMatrix, viewMatrix)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function offsetProjectionForConvergence(projection: Mat4, eyeOffset: number, near: number, convergenceDistance: number): Mat4 {
|
|
82
|
-
const result = [...projection] as Mat4;
|
|
83
|
-
result[8] = (result[8] ?? 0) + eyeOffset * near / convergenceDistance;
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function offsetCameraPosition(viewMatrix: Mat4, cameraPosition: readonly [number, number, number], eyeOffset: number): Vec3 {
|
|
88
|
-
const inverseView = invertMat4(viewMatrix);
|
|
89
|
-
const right: Vec3 = [inverseView[0], inverseView[1], inverseView[2]];
|
|
90
|
-
return [
|
|
91
|
-
cameraPosition[0] + right[0] * eyeOffset,
|
|
92
|
-
cameraPosition[1] + right[1] * eyeOffset,
|
|
93
|
-
cameraPosition[2] + right[2] * eyeOffset
|
|
94
|
-
];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function eyeViewport(eye: StereoEye, viewport: StereoViewport, layout: StereoLayout): StereoViewport {
|
|
98
|
-
if (layout === "side-by-side") {
|
|
99
|
-
const halfWidth = Math.floor(viewport.width / 2);
|
|
100
|
-
return eye === "left"
|
|
101
|
-
? { x: viewport.x, y: viewport.y, width: halfWidth, height: viewport.height }
|
|
102
|
-
: { x: viewport.x + halfWidth, y: viewport.y, width: viewport.width - halfWidth, height: viewport.height };
|
|
103
|
-
}
|
|
104
|
-
const halfHeight = Math.floor(viewport.height / 2);
|
|
105
|
-
return eye === "left"
|
|
106
|
-
? { x: viewport.x, y: viewport.y, width: viewport.width, height: halfHeight }
|
|
107
|
-
: { x: viewport.x, y: viewport.y + halfHeight, width: viewport.width, height: viewport.height - halfHeight };
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function validateViewport(viewport: StereoViewport): void {
|
|
111
|
-
const values = [viewport.x, viewport.y, viewport.width, viewport.height];
|
|
112
|
-
if (values.some((value) => !Number.isFinite(value))) {
|
|
113
|
-
throw new RangeError("Stereo viewport values must be finite.");
|
|
114
|
-
}
|
|
115
|
-
if (viewport.width < 2 || viewport.height < 2) {
|
|
116
|
-
throw new RangeError("Stereo viewport dimensions must be at least 2x2.");
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function translationMat4(x: number, y: number, z: number): Mat4 {
|
|
121
|
-
return [
|
|
122
|
-
1, 0, 0, 0,
|
|
123
|
-
0, 1, 0, 0,
|
|
124
|
-
0, 0, 1, 0,
|
|
125
|
-
x, y, z, 1
|
|
126
|
-
];
|
|
127
|
-
}
|
package/src/StereoEffects.ts
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import type { StereoLayout } from "./StereoCameraRig";
|
|
2
|
-
|
|
3
|
-
export type StereoEffectMode = "side-by-side" | "anaglyph" | "parallax-barrier";
|
|
4
|
-
|
|
5
|
-
export interface StereoEffectPlanOptions {
|
|
6
|
-
readonly mode: StereoEffectMode;
|
|
7
|
-
readonly width: number;
|
|
8
|
-
readonly height: number;
|
|
9
|
-
readonly eyeSeparation: number;
|
|
10
|
-
readonly convergenceDistance: number;
|
|
11
|
-
readonly parallaxStrength?: number;
|
|
12
|
-
readonly parallaxBarrierAxis?: "x" | "y";
|
|
13
|
-
readonly stripPitchPx?: number;
|
|
14
|
-
readonly layout?: StereoLayout;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface StereoEffectPlan {
|
|
18
|
-
readonly mode: StereoEffectMode;
|
|
19
|
-
readonly layout: StereoLayout;
|
|
20
|
-
readonly width: number;
|
|
21
|
-
readonly height: number;
|
|
22
|
-
readonly eyeCount: 2;
|
|
23
|
-
readonly eyeSeparation: number;
|
|
24
|
-
readonly convergenceDistance: number;
|
|
25
|
-
readonly parallaxStrength: number;
|
|
26
|
-
readonly parallaxSignal: number;
|
|
27
|
-
readonly composition: "dual-canvas" | "channel-composite" | "interleaved-mask";
|
|
28
|
-
readonly anaglyph?: AnaglyphCompositePlan;
|
|
29
|
-
readonly parallaxBarrier?: ParallaxBarrierInterleavePlan;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface AnaglyphCompositePlan {
|
|
33
|
-
readonly leftChannel: "red";
|
|
34
|
-
readonly rightChannels: readonly ["green", "blue"];
|
|
35
|
-
readonly leftCssFilter: string;
|
|
36
|
-
readonly rightCssFilter: string;
|
|
37
|
-
readonly blendMode: "screen";
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface AnaglyphPixelCompositeOptions {
|
|
41
|
-
readonly width: number;
|
|
42
|
-
readonly height: number;
|
|
43
|
-
readonly leftPixels: Uint8Array | Uint8ClampedArray;
|
|
44
|
-
readonly rightPixels: Uint8Array | Uint8ClampedArray;
|
|
45
|
-
readonly flipY?: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface AnaglyphPixelComposite {
|
|
49
|
-
readonly width: number;
|
|
50
|
-
readonly height: number;
|
|
51
|
-
readonly pixels: Uint8ClampedArray;
|
|
52
|
-
readonly composition: "renderer-owned-anaglyph-pixels";
|
|
53
|
-
readonly leftChannel: "red";
|
|
54
|
-
readonly rightChannels: readonly ["green", "blue"];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface ParallaxBarrierInterleavePlan {
|
|
58
|
-
readonly axis: "x" | "y";
|
|
59
|
-
readonly stripPitchPx: number;
|
|
60
|
-
readonly dutyCycle: number;
|
|
61
|
-
readonly leftMaskImage: string;
|
|
62
|
-
readonly rightMaskImage: string;
|
|
63
|
-
readonly overlayBackground: string;
|
|
64
|
-
readonly rightOpacity: number;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface ParallaxBarrierPixelCompositeOptions {
|
|
68
|
-
readonly width: number;
|
|
69
|
-
readonly height: number;
|
|
70
|
-
readonly leftPixels: Uint8Array | Uint8ClampedArray;
|
|
71
|
-
readonly rightPixels: Uint8Array | Uint8ClampedArray;
|
|
72
|
-
readonly axis?: "x" | "y";
|
|
73
|
-
readonly stripPitchPx?: number;
|
|
74
|
-
readonly dutyCycle?: number;
|
|
75
|
-
readonly flipY?: boolean;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface ParallaxBarrierPixelComposite {
|
|
79
|
-
readonly width: number;
|
|
80
|
-
readonly height: number;
|
|
81
|
-
readonly pixels: Uint8ClampedArray;
|
|
82
|
-
readonly axis: "x" | "y";
|
|
83
|
-
readonly stripPitchPx: number;
|
|
84
|
-
readonly dutyCycle: number;
|
|
85
|
-
readonly leftPixelCount: number;
|
|
86
|
-
readonly rightPixelCount: number;
|
|
87
|
-
readonly composition: "renderer-owned-interleaved-pixels";
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function createStereoEffectPlan(options: StereoEffectPlanOptions): StereoEffectPlan {
|
|
91
|
-
validatePositiveFinite(options.width, "Stereo effect width");
|
|
92
|
-
validatePositiveFinite(options.height, "Stereo effect height");
|
|
93
|
-
validatePositiveFinite(options.eyeSeparation, "Stereo effect eyeSeparation");
|
|
94
|
-
validatePositiveFinite(options.convergenceDistance, "Stereo effect convergenceDistance");
|
|
95
|
-
const parallaxStrength = options.parallaxStrength ?? 1;
|
|
96
|
-
validatePositiveFinite(parallaxStrength, "Stereo effect parallaxStrength");
|
|
97
|
-
const layout = options.layout ?? "side-by-side";
|
|
98
|
-
const base = {
|
|
99
|
-
mode: options.mode,
|
|
100
|
-
layout,
|
|
101
|
-
width: options.width,
|
|
102
|
-
height: options.height,
|
|
103
|
-
eyeCount: 2 as const,
|
|
104
|
-
eyeSeparation: options.eyeSeparation,
|
|
105
|
-
convergenceDistance: options.convergenceDistance,
|
|
106
|
-
parallaxStrength,
|
|
107
|
-
parallaxSignal: options.eyeSeparation * parallaxStrength / options.convergenceDistance
|
|
108
|
-
};
|
|
109
|
-
if (options.mode === "anaglyph") {
|
|
110
|
-
return {
|
|
111
|
-
...base,
|
|
112
|
-
composition: "channel-composite",
|
|
113
|
-
anaglyph: createAnaglyphCompositePlan()
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
if (options.mode === "parallax-barrier") {
|
|
117
|
-
return {
|
|
118
|
-
...base,
|
|
119
|
-
composition: "interleaved-mask",
|
|
120
|
-
parallaxBarrier: createParallaxBarrierInterleavePlan({
|
|
121
|
-
axis: options.parallaxBarrierAxis,
|
|
122
|
-
stripPitchPx: options.stripPitchPx
|
|
123
|
-
})
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
...base,
|
|
128
|
-
composition: "dual-canvas"
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function createAnaglyphCompositePlan(): AnaglyphCompositePlan {
|
|
133
|
-
return {
|
|
134
|
-
leftChannel: "red",
|
|
135
|
-
rightChannels: ["green", "blue"],
|
|
136
|
-
leftCssFilter: "sepia(1) saturate(5) hue-rotate(-50deg)",
|
|
137
|
-
rightCssFilter: "sepia(1) saturate(4) hue-rotate(135deg)",
|
|
138
|
-
blendMode: "screen"
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function createAnaglyphPixelComposite(options: AnaglyphPixelCompositeOptions): AnaglyphPixelComposite {
|
|
143
|
-
validatePositiveInteger(options.width, "Anaglyph composite width");
|
|
144
|
-
validatePositiveInteger(options.height, "Anaglyph composite height");
|
|
145
|
-
const expectedLength = options.width * options.height * 4;
|
|
146
|
-
if (options.leftPixels.length !== expectedLength || options.rightPixels.length !== expectedLength) {
|
|
147
|
-
throw new RangeError("Anaglyph composite requires leftPixels and rightPixels to be width * height * 4 bytes.");
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const output = new Uint8ClampedArray(expectedLength);
|
|
151
|
-
for (let y = 0; y < options.height; y += 1) {
|
|
152
|
-
const sourceY = options.flipY ? options.height - y - 1 : y;
|
|
153
|
-
for (let x = 0; x < options.width; x += 1) {
|
|
154
|
-
const sourceOffset = (sourceY * options.width + x) * 4;
|
|
155
|
-
const outputOffset = (y * options.width + x) * 4;
|
|
156
|
-
output[outputOffset] = options.leftPixels[sourceOffset] ?? 0;
|
|
157
|
-
output[outputOffset + 1] = options.rightPixels[sourceOffset + 1] ?? 0;
|
|
158
|
-
output[outputOffset + 2] = options.rightPixels[sourceOffset + 2] ?? 0;
|
|
159
|
-
output[outputOffset + 3] = Math.max(options.leftPixels[sourceOffset + 3] ?? 255, options.rightPixels[sourceOffset + 3] ?? 255);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
width: options.width,
|
|
165
|
-
height: options.height,
|
|
166
|
-
pixels: output,
|
|
167
|
-
composition: "renderer-owned-anaglyph-pixels",
|
|
168
|
-
leftChannel: "red",
|
|
169
|
-
rightChannels: ["green", "blue"]
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export function createParallaxBarrierInterleavePlan(options: {
|
|
174
|
-
readonly axis?: "x" | "y";
|
|
175
|
-
readonly stripPitchPx?: number;
|
|
176
|
-
readonly dutyCycle?: number;
|
|
177
|
-
readonly rightOpacity?: number;
|
|
178
|
-
} = {}): ParallaxBarrierInterleavePlan {
|
|
179
|
-
const axis = options.axis ?? "x";
|
|
180
|
-
validateAxis(axis);
|
|
181
|
-
const stripPitchPx = options.stripPitchPx ?? 12;
|
|
182
|
-
const dutyCycle = options.dutyCycle ?? 0.5;
|
|
183
|
-
const rightOpacity = options.rightOpacity ?? 0.82;
|
|
184
|
-
validatePositiveFinite(stripPitchPx, "Parallax barrier stripPitchPx");
|
|
185
|
-
if (!Number.isFinite(dutyCycle) || dutyCycle <= 0 || dutyCycle >= 1) {
|
|
186
|
-
throw new RangeError("Parallax barrier dutyCycle must be finite and in (0, 1).");
|
|
187
|
-
}
|
|
188
|
-
if (!Number.isFinite(rightOpacity) || rightOpacity < 0 || rightOpacity > 1) {
|
|
189
|
-
throw new RangeError("Parallax barrier rightOpacity must be finite and in [0, 1].");
|
|
190
|
-
}
|
|
191
|
-
const leftStop = stripPitchPx * dutyCycle;
|
|
192
|
-
const gradientAxis = axis === "x" ? "90deg" : "0deg";
|
|
193
|
-
return {
|
|
194
|
-
axis,
|
|
195
|
-
stripPitchPx,
|
|
196
|
-
dutyCycle,
|
|
197
|
-
leftMaskImage: `repeating-linear-gradient(${gradientAxis}, black 0 ${formatPx(leftStop)}, transparent ${formatPx(leftStop)} ${formatPx(stripPitchPx)})`,
|
|
198
|
-
rightMaskImage: `repeating-linear-gradient(${gradientAxis}, transparent 0 ${formatPx(leftStop)}, black ${formatPx(leftStop)} ${formatPx(stripPitchPx)})`,
|
|
199
|
-
overlayBackground: `repeating-linear-gradient(${gradientAxis}, rgba(255,255,255,0.06) 0 1px, transparent 1px ${formatPx(stripPitchPx)})`,
|
|
200
|
-
rightOpacity
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export function createParallaxBarrierPixelComposite(options: ParallaxBarrierPixelCompositeOptions): ParallaxBarrierPixelComposite {
|
|
205
|
-
validatePositiveInteger(options.width, "Parallax barrier composite width");
|
|
206
|
-
validatePositiveInteger(options.height, "Parallax barrier composite height");
|
|
207
|
-
const stripPitchPx = options.stripPitchPx ?? 12;
|
|
208
|
-
const dutyCycle = options.dutyCycle ?? 0.5;
|
|
209
|
-
const axis = options.axis ?? "x";
|
|
210
|
-
validateAxis(axis);
|
|
211
|
-
validatePositiveFinite(stripPitchPx, "Parallax barrier stripPitchPx");
|
|
212
|
-
if (!Number.isFinite(dutyCycle) || dutyCycle <= 0 || dutyCycle >= 1) {
|
|
213
|
-
throw new RangeError("Parallax barrier dutyCycle must be finite and in (0, 1).");
|
|
214
|
-
}
|
|
215
|
-
const expectedLength = options.width * options.height * 4;
|
|
216
|
-
if (options.leftPixels.length !== expectedLength || options.rightPixels.length !== expectedLength) {
|
|
217
|
-
throw new RangeError("Parallax barrier composite requires leftPixels and rightPixels to be width * height * 4 bytes.");
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const output = new Uint8ClampedArray(expectedLength);
|
|
221
|
-
let leftPixelCount = 0;
|
|
222
|
-
let rightPixelCount = 0;
|
|
223
|
-
const leftStripWidth = stripPitchPx * dutyCycle;
|
|
224
|
-
for (let y = 0; y < options.height; y += 1) {
|
|
225
|
-
const sourceY = options.flipY ? options.height - y - 1 : y;
|
|
226
|
-
for (let x = 0; x < options.width; x += 1) {
|
|
227
|
-
const coordinate = axis === "x" ? x : y;
|
|
228
|
-
const useLeft = (coordinate % stripPitchPx) < leftStripWidth;
|
|
229
|
-
const source = useLeft ? options.leftPixels : options.rightPixels;
|
|
230
|
-
const sourceOffset = (sourceY * options.width + x) * 4;
|
|
231
|
-
const outputOffset = (y * options.width + x) * 4;
|
|
232
|
-
output[outputOffset] = source[sourceOffset] ?? 0;
|
|
233
|
-
output[outputOffset + 1] = source[sourceOffset + 1] ?? 0;
|
|
234
|
-
output[outputOffset + 2] = source[sourceOffset + 2] ?? 0;
|
|
235
|
-
output[outputOffset + 3] = source[sourceOffset + 3] ?? 255;
|
|
236
|
-
if (useLeft) leftPixelCount += 1;
|
|
237
|
-
else rightPixelCount += 1;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return {
|
|
242
|
-
width: options.width,
|
|
243
|
-
height: options.height,
|
|
244
|
-
pixels: output,
|
|
245
|
-
axis,
|
|
246
|
-
stripPitchPx,
|
|
247
|
-
dutyCycle,
|
|
248
|
-
leftPixelCount,
|
|
249
|
-
rightPixelCount,
|
|
250
|
-
composition: "renderer-owned-interleaved-pixels"
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function validateAxis(value: unknown): asserts value is "x" | "y" {
|
|
255
|
-
if (value !== "x" && value !== "y") {
|
|
256
|
-
throw new RangeError("Parallax barrier axis must be x or y.");
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function validatePositiveFinite(value: number, label: string): void {
|
|
261
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
262
|
-
throw new RangeError(`${label} must be finite and positive.`);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function validatePositiveInteger(value: number, label: string): void {
|
|
267
|
-
if (!Number.isInteger(value) || value <= 0) {
|
|
268
|
-
throw new RangeError(`${label} must be a positive integer.`);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function formatPx(value: number): string {
|
|
273
|
-
return `${Number(value.toFixed(3))}px`;
|
|
274
|
-
}
|