@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,397 +0,0 @@
|
|
|
1
|
-
import { Material, type RenderState } from "./Material";
|
|
2
|
-
import { DEFAULT_PBR_ENVIRONMENT_INTENSITY, DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP } from "./PBRLightingDefaults";
|
|
3
|
-
import type { PBRProceduralEnvironmentMapOptions } from "./PBRMaterial";
|
|
4
|
-
import { DEFAULT_SKINNED_LIT_SHADER_NAME } from "./ShaderLibrary";
|
|
5
|
-
import { TextureBinding } from "./TextureBinding";
|
|
6
|
-
|
|
7
|
-
export interface SkinnedLitMaterialOptions {
|
|
8
|
-
readonly name?: string;
|
|
9
|
-
readonly color?: readonly [number, number, number, number];
|
|
10
|
-
readonly baseColor?: readonly [number, number, number, number];
|
|
11
|
-
readonly baseColorTexture?: TextureBinding;
|
|
12
|
-
readonly baseColorTextureOffset?: readonly [number, number];
|
|
13
|
-
readonly baseColorTextureScale?: readonly [number, number];
|
|
14
|
-
readonly baseColorTextureRotation?: number;
|
|
15
|
-
readonly normalTexture?: TextureBinding;
|
|
16
|
-
readonly normalScale?: number;
|
|
17
|
-
readonly metallicRoughnessTexture?: TextureBinding;
|
|
18
|
-
readonly occlusionTexture?: TextureBinding;
|
|
19
|
-
readonly occlusionStrength?: number;
|
|
20
|
-
readonly emissiveTexture?: TextureBinding;
|
|
21
|
-
readonly clearcoatTexture?: TextureBinding;
|
|
22
|
-
readonly clearcoatNormalTexture?: TextureBinding;
|
|
23
|
-
readonly sheenColorTexture?: TextureBinding;
|
|
24
|
-
readonly sheenRoughnessTexture?: TextureBinding;
|
|
25
|
-
readonly transmissionTexture?: TextureBinding;
|
|
26
|
-
readonly iridescenceTexture?: TextureBinding;
|
|
27
|
-
readonly iridescenceThicknessTexture?: TextureBinding;
|
|
28
|
-
readonly anisotropyTexture?: TextureBinding;
|
|
29
|
-
readonly volumeThicknessTexture?: TextureBinding;
|
|
30
|
-
readonly renderState?: Partial<RenderState>;
|
|
31
|
-
readonly metallic?: number;
|
|
32
|
-
readonly roughness?: number;
|
|
33
|
-
readonly environmentColor?: readonly [number, number, number];
|
|
34
|
-
readonly environmentIntensity?: number;
|
|
35
|
-
readonly proceduralEnvironmentMap?: PBRProceduralEnvironmentMapOptions;
|
|
36
|
-
readonly environmentMapTexture?: TextureBinding;
|
|
37
|
-
readonly environmentMapIntensity?: number;
|
|
38
|
-
readonly environmentMapSpecularIntensity?: number;
|
|
39
|
-
readonly environmentMapRotation?: number;
|
|
40
|
-
readonly environmentMapMipCount?: number;
|
|
41
|
-
readonly environmentBrdfLutTexture?: TextureBinding;
|
|
42
|
-
readonly emissiveColor?: readonly [number, number, number];
|
|
43
|
-
readonly emissiveStrength?: number;
|
|
44
|
-
readonly clearcoatFactor?: number;
|
|
45
|
-
readonly clearcoatRoughnessFactor?: number;
|
|
46
|
-
readonly transmissionFactor?: number;
|
|
47
|
-
readonly diffuseTransmissionFactor?: number;
|
|
48
|
-
readonly diffuseTransmissionColorFactor?: readonly [number, number, number];
|
|
49
|
-
readonly transmissionFallbackEnergy?: number;
|
|
50
|
-
readonly volumeThicknessFactor?: number;
|
|
51
|
-
readonly volumeAttenuationDistance?: number;
|
|
52
|
-
readonly volumeAttenuationColor?: readonly [number, number, number];
|
|
53
|
-
readonly ior?: number;
|
|
54
|
-
readonly specularFactor?: number;
|
|
55
|
-
readonly specularColorFactor?: readonly [number, number, number];
|
|
56
|
-
readonly sheenColorFactor?: readonly [number, number, number];
|
|
57
|
-
readonly sheenRoughnessFactor?: number;
|
|
58
|
-
readonly anisotropyStrength?: number;
|
|
59
|
-
readonly anisotropyRotation?: number;
|
|
60
|
-
readonly iridescenceFactor?: number;
|
|
61
|
-
readonly iridescenceIor?: number;
|
|
62
|
-
readonly iridescenceThicknessMinimum?: number;
|
|
63
|
-
readonly iridescenceThicknessMaximum?: number;
|
|
64
|
-
readonly dispersion?: number;
|
|
65
|
-
readonly keyLightDirection?: readonly [number, number, number];
|
|
66
|
-
readonly keyLightColor?: readonly [number, number, number];
|
|
67
|
-
readonly fillLightColor?: readonly [number, number, number];
|
|
68
|
-
readonly lightIntensity?: number;
|
|
69
|
-
readonly maxJoints?: number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export class SkinnedLitMaterial extends Material {
|
|
73
|
-
public readonly maxJoints: number;
|
|
74
|
-
|
|
75
|
-
constructor(options: SkinnedLitMaterialOptions = {}) {
|
|
76
|
-
const baseColor = options.baseColor ?? options.color ?? [1, 1, 1, 1];
|
|
77
|
-
const environmentColor = options.environmentColor ?? [1, 1, 1];
|
|
78
|
-
const proceduralEnvironmentMap: PBRProceduralEnvironmentMapOptions = options.proceduralEnvironmentMap ?? DEFAULT_PBR_PROCEDURAL_ENVIRONMENT_MAP;
|
|
79
|
-
const emissiveColor = options.emissiveColor ?? [0, 0, 0];
|
|
80
|
-
const diffuseTransmissionColorFactor = options.diffuseTransmissionColorFactor ?? [1, 1, 1];
|
|
81
|
-
const volumeAttenuationColor = options.volumeAttenuationColor ?? [1, 1, 1];
|
|
82
|
-
const specularColorFactor = options.specularColorFactor ?? [1, 1, 1];
|
|
83
|
-
const sheenColorFactor = options.sheenColorFactor ?? [0, 0, 0];
|
|
84
|
-
validateColor4(baseColor, "baseColor");
|
|
85
|
-
validateVec2(options.baseColorTextureOffset ?? [0, 0], "baseColorTextureOffset");
|
|
86
|
-
validateVec2(options.baseColorTextureScale ?? [1, 1], "baseColorTextureScale");
|
|
87
|
-
validateFinite(options.baseColorTextureRotation ?? 0, "baseColorTextureRotation");
|
|
88
|
-
validateNonNegative(options.normalScale ?? 1, "normalScale");
|
|
89
|
-
validateUnit(options.occlusionStrength ?? 1, "occlusionStrength");
|
|
90
|
-
validateColor3(environmentColor, "environmentColor");
|
|
91
|
-
validateColor3(emissiveColor, "emissiveColor");
|
|
92
|
-
validateColor3(diffuseTransmissionColorFactor, "diffuseTransmissionColorFactor");
|
|
93
|
-
validateColor3(volumeAttenuationColor, "volumeAttenuationColor");
|
|
94
|
-
validateNonNegativeColor3(specularColorFactor, "specularColorFactor");
|
|
95
|
-
validateColor3(sheenColorFactor, "sheenColorFactor");
|
|
96
|
-
validateUnit(options.metallic ?? 0, "metallic");
|
|
97
|
-
validateUnit(options.roughness ?? 0.5, "roughness");
|
|
98
|
-
validateNonNegative(options.environmentIntensity ?? DEFAULT_PBR_ENVIRONMENT_INTENSITY, "environmentIntensity");
|
|
99
|
-
validateProceduralEnvironmentMap(proceduralEnvironmentMap);
|
|
100
|
-
validateNonNegative(options.environmentMapIntensity ?? 0, "environmentMapIntensity");
|
|
101
|
-
validateNonNegative(options.environmentMapSpecularIntensity ?? 0, "environmentMapSpecularIntensity");
|
|
102
|
-
validateFinite(options.environmentMapRotation ?? 0, "environmentMapRotation");
|
|
103
|
-
validateMipCount(options.environmentMapMipCount ?? 1);
|
|
104
|
-
validateNonNegative(options.emissiveStrength ?? 1, "emissiveStrength");
|
|
105
|
-
validateUnit(options.clearcoatFactor ?? 0, "clearcoatFactor");
|
|
106
|
-
validateUnit(options.clearcoatRoughnessFactor ?? 0, "clearcoatRoughnessFactor");
|
|
107
|
-
validateUnit(options.transmissionFactor ?? 0, "transmissionFactor");
|
|
108
|
-
validateUnit(options.diffuseTransmissionFactor ?? 0, "diffuseTransmissionFactor");
|
|
109
|
-
validateUnit(options.transmissionFallbackEnergy ?? 0.08, "transmissionFallbackEnergy");
|
|
110
|
-
validateNonNegative(options.volumeThicknessFactor ?? 0, "volumeThicknessFactor");
|
|
111
|
-
validatePositive(options.volumeAttenuationDistance ?? 1_000_000, "volumeAttenuationDistance");
|
|
112
|
-
validateUnit(options.specularFactor ?? 1, "specularFactor");
|
|
113
|
-
validateUnit(options.sheenRoughnessFactor ?? 0, "sheenRoughnessFactor");
|
|
114
|
-
validateUnit(options.anisotropyStrength ?? 0, "anisotropyStrength");
|
|
115
|
-
validateFinite(options.anisotropyRotation ?? 0, "anisotropyRotation");
|
|
116
|
-
validateUnit(options.iridescenceFactor ?? 0, "iridescenceFactor");
|
|
117
|
-
validateFinite(options.iridescenceIor ?? 1.3, "iridescenceIor");
|
|
118
|
-
validateNonNegative(options.iridescenceThicknessMinimum ?? 100, "iridescenceThicknessMinimum");
|
|
119
|
-
validateNonNegative(options.iridescenceThicknessMaximum ?? 400, "iridescenceThicknessMaximum");
|
|
120
|
-
validateNonNegative(options.dispersion ?? 0, "dispersion");
|
|
121
|
-
validatePositive(options.ior ?? 1.5, "ior");
|
|
122
|
-
const maxJoints = options.maxJoints ?? 96;
|
|
123
|
-
if (!Number.isInteger(maxJoints) || maxJoints <= 0 || maxJoints > 96) {
|
|
124
|
-
throw new Error("SkinnedLitMaterial maxJoints must be an integer in [1, 96]");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// The skinned-lit shader supports glTF extension scalar factors only
|
|
128
|
-
// (u_clearcoatFactor, u_sheenColorFactor, ...); it declares no extension
|
|
129
|
-
// texture uniforms. Extension texture options (clearcoatTexture,
|
|
130
|
-
// sheenColorTexture, ...) are therefore accepted for glTF compatibility but
|
|
131
|
-
// intentionally NOT declared as uniforms — declaring them would make
|
|
132
|
-
// MaterialBinding fail validation against the shader.
|
|
133
|
-
super({
|
|
134
|
-
name: options.name ?? "skinned-lit",
|
|
135
|
-
shaderKey: DEFAULT_SKINNED_LIT_SHADER_NAME,
|
|
136
|
-
renderState: options.renderState,
|
|
137
|
-
parameters: {
|
|
138
|
-
u_baseColor: baseColor,
|
|
139
|
-
u_baseColorTexture: options.baseColorTexture ?? new TextureBinding({ name: "u_baseColorTexture", required: false }),
|
|
140
|
-
u_baseColorTextureEnabled: options.baseColorTexture ? 1 : 0,
|
|
141
|
-
u_baseColorTextureOffset: options.baseColorTextureOffset ?? [0, 0],
|
|
142
|
-
u_baseColorTextureScale: options.baseColorTextureScale ?? [1, 1],
|
|
143
|
-
u_baseColorTextureRotation: options.baseColorTextureRotation ?? 0,
|
|
144
|
-
u_normalTexture: options.normalTexture ?? new TextureBinding({ name: "u_normalTexture", required: false }),
|
|
145
|
-
u_normalTextureEnabled: options.normalTexture ? 1 : 0,
|
|
146
|
-
u_normalScale: options.normalScale ?? 1,
|
|
147
|
-
u_metallicRoughnessTexture: options.metallicRoughnessTexture ?? new TextureBinding({ name: "u_metallicRoughnessTexture", required: false }),
|
|
148
|
-
u_metallicRoughnessTextureEnabled: options.metallicRoughnessTexture ? 1 : 0,
|
|
149
|
-
u_occlusionTexture: options.occlusionTexture ?? new TextureBinding({ name: "u_occlusionTexture", required: false }),
|
|
150
|
-
u_occlusionTextureEnabled: options.occlusionTexture ? 1 : 0,
|
|
151
|
-
u_occlusionStrength: options.occlusionStrength ?? 1,
|
|
152
|
-
u_emissiveTexture: options.emissiveTexture ?? new TextureBinding({ name: "u_emissiveTexture", required: false }),
|
|
153
|
-
u_emissiveTextureEnabled: options.emissiveTexture ? 1 : 0,
|
|
154
|
-
u_alphaCutoff: 0,
|
|
155
|
-
u_metallic: options.metallic ?? 0,
|
|
156
|
-
u_roughness: options.roughness ?? 0.5,
|
|
157
|
-
u_environmentColor: environmentColor,
|
|
158
|
-
u_environmentIntensity: options.environmentIntensity ?? DEFAULT_PBR_ENVIRONMENT_INTENSITY,
|
|
159
|
-
u_environmentSkyColor: proceduralEnvironmentMap.skyColor,
|
|
160
|
-
u_environmentHorizonColor: proceduralEnvironmentMap.horizonColor,
|
|
161
|
-
u_environmentGroundColor: proceduralEnvironmentMap.groundColor,
|
|
162
|
-
u_environmentSpecularColor: proceduralEnvironmentMap.specularColor,
|
|
163
|
-
u_environmentMapIntensity: proceduralEnvironmentMap.intensity,
|
|
164
|
-
u_environmentSpecularIntensity: proceduralEnvironmentMap.specularIntensity,
|
|
165
|
-
u_environmentMapTexture: options.environmentMapTexture ?? new TextureBinding({ name: "u_environmentMapTexture", required: false }),
|
|
166
|
-
u_environmentMapTextureEnabled: options.environmentMapTexture ? 1 : 0,
|
|
167
|
-
u_environmentMapTextureIntensity: options.environmentMapIntensity ?? 0,
|
|
168
|
-
u_environmentMapTextureSpecularIntensity: options.environmentMapSpecularIntensity ?? 0,
|
|
169
|
-
u_environmentMapTextureRotation: options.environmentMapRotation ?? 0,
|
|
170
|
-
u_environmentMapTextureMipCount: options.environmentMapMipCount ?? 1,
|
|
171
|
-
u_environmentMapTextureEncoding: 0,
|
|
172
|
-
u_environmentBrdfLutTexture: options.environmentBrdfLutTexture ?? new TextureBinding({ name: "u_environmentBrdfLutTexture", required: false }),
|
|
173
|
-
u_environmentBrdfLutEnabled: options.environmentBrdfLutTexture ? 1 : 0,
|
|
174
|
-
u_emissiveColor: emissiveColor,
|
|
175
|
-
u_emissiveStrength: options.emissiveStrength ?? 1,
|
|
176
|
-
u_clearcoatFactor: options.clearcoatFactor ?? 0,
|
|
177
|
-
u_clearcoatRoughnessFactor: options.clearcoatRoughnessFactor ?? 0,
|
|
178
|
-
u_transmissionFactor: options.transmissionFactor ?? 0,
|
|
179
|
-
u_diffuseTransmissionFactor: options.diffuseTransmissionFactor ?? 0,
|
|
180
|
-
u_diffuseTransmissionColorFactor: diffuseTransmissionColorFactor,
|
|
181
|
-
u_transmissionFallbackEnergy: options.transmissionFallbackEnergy ?? 0.08,
|
|
182
|
-
u_volumeThicknessFactor: options.volumeThicknessFactor ?? 0,
|
|
183
|
-
u_volumeAttenuationDistance: options.volumeAttenuationDistance ?? 1_000_000,
|
|
184
|
-
u_volumeAttenuationColor: volumeAttenuationColor,
|
|
185
|
-
u_ior: options.ior ?? 1.5,
|
|
186
|
-
u_specularFactor: options.specularFactor ?? 1,
|
|
187
|
-
u_specularColorFactor: specularColorFactor,
|
|
188
|
-
u_sheenColorFactor: sheenColorFactor,
|
|
189
|
-
u_sheenRoughnessFactor: options.sheenRoughnessFactor ?? 0,
|
|
190
|
-
u_anisotropyStrength: options.anisotropyStrength ?? 0,
|
|
191
|
-
u_anisotropyRotation: options.anisotropyRotation ?? 0,
|
|
192
|
-
u_iridescenceFactor: options.iridescenceFactor ?? 0,
|
|
193
|
-
u_iridescenceIor: options.iridescenceIor ?? 1.3,
|
|
194
|
-
u_iridescenceThicknessMinimum: options.iridescenceThicknessMinimum ?? 100,
|
|
195
|
-
u_iridescenceThicknessMaximum: options.iridescenceThicknessMaximum ?? 400,
|
|
196
|
-
u_dispersion: options.dispersion ?? 0,
|
|
197
|
-
u_lightCount: 0,
|
|
198
|
-
u_lightData: new Float32Array(0),
|
|
199
|
-
u_shadowMapTexture: new TextureBinding({ name: "u_shadowMapTexture", required: false }),
|
|
200
|
-
u_shadowMapEnabled: 0,
|
|
201
|
-
u_shadowMapMatrix: identityMatrix(),
|
|
202
|
-
u_shadowMapStrength: 0,
|
|
203
|
-
u_shadowMapBias: 0,
|
|
204
|
-
u_shadowMapSlopeBias: 0,
|
|
205
|
-
u_shadowMapTexelSize: [1, 1],
|
|
206
|
-
u_shadowPcfSampleCount: 1,
|
|
207
|
-
u_shadowPcfSamples: new Float32Array(32 * 4),
|
|
208
|
-
u_outputColorSpace: 1,
|
|
209
|
-
u_cameraPosition: [0, 0, 1],
|
|
210
|
-
u_modelMatrix: identityMatrix(),
|
|
211
|
-
u_normalMatrix: identityMatrix(),
|
|
212
|
-
u_modelViewProjection: identityMatrix(),
|
|
213
|
-
u_jointCount: 1,
|
|
214
|
-
u_jointMatrices: identityMatrix()
|
|
215
|
-
},
|
|
216
|
-
requiredAttributes: [
|
|
217
|
-
"a_position",
|
|
218
|
-
"a_normal",
|
|
219
|
-
...(usesTextureCoordinates(options) ? ["a_uv"] : []),
|
|
220
|
-
...(options.normalTexture ? ["a_tangent"] : []),
|
|
221
|
-
"a_joints",
|
|
222
|
-
"a_weights"
|
|
223
|
-
],
|
|
224
|
-
uniformSchema: [
|
|
225
|
-
{ name: "u_baseColor", kind: "vec4" },
|
|
226
|
-
{ name: "u_baseColorTexture", kind: "texture2d", required: false },
|
|
227
|
-
{ name: "u_baseColorTextureEnabled", kind: "float" },
|
|
228
|
-
{ name: "u_baseColorTextureOffset", kind: "vec2" },
|
|
229
|
-
{ name: "u_baseColorTextureScale", kind: "vec2" },
|
|
230
|
-
{ name: "u_baseColorTextureRotation", kind: "float" },
|
|
231
|
-
{ name: "u_normalTexture", kind: "texture2d", required: false },
|
|
232
|
-
{ name: "u_normalTextureEnabled", kind: "float" },
|
|
233
|
-
{ name: "u_normalScale", kind: "float" },
|
|
234
|
-
{ name: "u_metallicRoughnessTexture", kind: "texture2d", required: false },
|
|
235
|
-
{ name: "u_metallicRoughnessTextureEnabled", kind: "float" },
|
|
236
|
-
{ name: "u_occlusionTexture", kind: "texture2d", required: false },
|
|
237
|
-
{ name: "u_occlusionTextureEnabled", kind: "float" },
|
|
238
|
-
{ name: "u_occlusionStrength", kind: "float" },
|
|
239
|
-
{ name: "u_emissiveTexture", kind: "texture2d", required: false },
|
|
240
|
-
{ name: "u_emissiveTextureEnabled", kind: "float" },
|
|
241
|
-
{ name: "u_alphaCutoff", kind: "float" },
|
|
242
|
-
{ name: "u_metallic", kind: "float" },
|
|
243
|
-
{ name: "u_roughness", kind: "float" },
|
|
244
|
-
{ name: "u_environmentColor", kind: "vec3" },
|
|
245
|
-
{ name: "u_environmentIntensity", kind: "float" },
|
|
246
|
-
{ name: "u_environmentSkyColor", kind: "vec3" },
|
|
247
|
-
{ name: "u_environmentHorizonColor", kind: "vec3" },
|
|
248
|
-
{ name: "u_environmentGroundColor", kind: "vec3" },
|
|
249
|
-
{ name: "u_environmentSpecularColor", kind: "vec3" },
|
|
250
|
-
{ name: "u_environmentMapIntensity", kind: "float" },
|
|
251
|
-
{ name: "u_environmentSpecularIntensity", kind: "float" },
|
|
252
|
-
{ name: "u_environmentMapTexture", kind: "texture2d", required: false },
|
|
253
|
-
{ name: "u_environmentMapTextureEnabled", kind: "float" },
|
|
254
|
-
{ name: "u_environmentMapTextureIntensity", kind: "float" },
|
|
255
|
-
{ name: "u_environmentMapTextureSpecularIntensity", kind: "float" },
|
|
256
|
-
{ name: "u_environmentMapTextureRotation", kind: "float" },
|
|
257
|
-
{ name: "u_environmentMapTextureMipCount", kind: "float" },
|
|
258
|
-
{ name: "u_environmentMapTextureEncoding", kind: "float" },
|
|
259
|
-
{ name: "u_environmentBrdfLutTexture", kind: "texture2d", required: false },
|
|
260
|
-
{ name: "u_environmentBrdfLutEnabled", kind: "float", required: false },
|
|
261
|
-
{ name: "u_emissiveColor", kind: "vec3" },
|
|
262
|
-
{ name: "u_emissiveStrength", kind: "float" },
|
|
263
|
-
{ name: "u_clearcoatFactor", kind: "float" },
|
|
264
|
-
{ name: "u_clearcoatRoughnessFactor", kind: "float" },
|
|
265
|
-
{ name: "u_transmissionFactor", kind: "float" },
|
|
266
|
-
{ name: "u_diffuseTransmissionFactor", kind: "float" },
|
|
267
|
-
{ name: "u_diffuseTransmissionColorFactor", kind: "vec3" },
|
|
268
|
-
{ name: "u_transmissionFallbackEnergy", kind: "float" },
|
|
269
|
-
{ name: "u_volumeThicknessFactor", kind: "float" },
|
|
270
|
-
{ name: "u_volumeAttenuationDistance", kind: "float" },
|
|
271
|
-
{ name: "u_volumeAttenuationColor", kind: "vec3" },
|
|
272
|
-
{ name: "u_ior", kind: "float" },
|
|
273
|
-
{ name: "u_specularFactor", kind: "float" },
|
|
274
|
-
{ name: "u_specularColorFactor", kind: "vec3" },
|
|
275
|
-
{ name: "u_sheenColorFactor", kind: "vec3" },
|
|
276
|
-
{ name: "u_sheenRoughnessFactor", kind: "float" },
|
|
277
|
-
{ name: "u_anisotropyStrength", kind: "float" },
|
|
278
|
-
{ name: "u_anisotropyRotation", kind: "float" },
|
|
279
|
-
{ name: "u_iridescenceFactor", kind: "float" },
|
|
280
|
-
{ name: "u_iridescenceIor", kind: "float" },
|
|
281
|
-
{ name: "u_iridescenceThicknessMinimum", kind: "float" },
|
|
282
|
-
{ name: "u_iridescenceThicknessMaximum", kind: "float" },
|
|
283
|
-
{ name: "u_dispersion", kind: "float" },
|
|
284
|
-
{ name: "u_lightCount", kind: "float" },
|
|
285
|
-
{ name: "u_lightData", kind: "any" },
|
|
286
|
-
{ name: "u_shadowMapTexture", kind: "texture2d", required: false },
|
|
287
|
-
{ name: "u_shadowMapEnabled", kind: "float" },
|
|
288
|
-
{ name: "u_shadowMapMatrix", kind: "mat4" },
|
|
289
|
-
{ name: "u_shadowMapStrength", kind: "float" },
|
|
290
|
-
{ name: "u_shadowMapBias", kind: "float" },
|
|
291
|
-
{ name: "u_shadowMapSlopeBias", kind: "float" },
|
|
292
|
-
{ name: "u_shadowMapTexelSize", kind: "vec2" },
|
|
293
|
-
{ name: "u_shadowPcfSampleCount", kind: "float" },
|
|
294
|
-
{ name: "u_shadowPcfSamples", kind: "any" },
|
|
295
|
-
{ name: "u_outputColorSpace", kind: "float" },
|
|
296
|
-
{ name: "u_cameraPosition", kind: "vec3" },
|
|
297
|
-
{ name: "u_modelMatrix", kind: "mat4" },
|
|
298
|
-
{ name: "u_normalMatrix", kind: "mat4" },
|
|
299
|
-
{ name: "u_modelViewProjection", kind: "mat4" },
|
|
300
|
-
{ name: "u_jointCount", kind: "float" },
|
|
301
|
-
{ name: "u_jointMatrices", kind: "any" }
|
|
302
|
-
]
|
|
303
|
-
});
|
|
304
|
-
this.maxJoints = maxJoints;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function usesTextureCoordinates(options: SkinnedLitMaterialOptions): boolean {
|
|
309
|
-
return Boolean(
|
|
310
|
-
options.baseColorTexture ||
|
|
311
|
-
options.normalTexture ||
|
|
312
|
-
options.metallicRoughnessTexture ||
|
|
313
|
-
options.occlusionTexture ||
|
|
314
|
-
options.emissiveTexture ||
|
|
315
|
-
options.clearcoatTexture ||
|
|
316
|
-
options.clearcoatNormalTexture ||
|
|
317
|
-
options.sheenColorTexture ||
|
|
318
|
-
options.sheenRoughnessTexture ||
|
|
319
|
-
options.transmissionTexture ||
|
|
320
|
-
options.iridescenceTexture ||
|
|
321
|
-
options.iridescenceThicknessTexture ||
|
|
322
|
-
options.anisotropyTexture ||
|
|
323
|
-
options.volumeThicknessTexture
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function validateColor4(color: readonly [number, number, number, number], label: string): void {
|
|
328
|
-
if (color.length !== 4 || color.some((channel) => channel < 0 || channel > 1 || !Number.isFinite(channel))) {
|
|
329
|
-
throw new Error(`SkinnedLitMaterial ${label} must contain four finite values in [0, 1]`);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function validateColor3(color: readonly [number, number, number], label: string): void {
|
|
334
|
-
if (color.length !== 3 || color.some((channel) => channel < 0 || channel > 1 || !Number.isFinite(channel))) {
|
|
335
|
-
throw new Error(`SkinnedLitMaterial ${label} must contain three finite values in [0, 1]`);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function validateNonNegativeColor3(color: readonly [number, number, number], label: string): void {
|
|
340
|
-
if (color.length !== 3 || color.some((channel) => channel < 0 || !Number.isFinite(channel))) {
|
|
341
|
-
throw new Error(`SkinnedLitMaterial ${label} must contain three finite non-negative values`);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function validateVec2(value: readonly [number, number], label: string): void {
|
|
346
|
-
if (value.length !== 2 || value.some((entry) => !Number.isFinite(entry))) {
|
|
347
|
-
throw new Error(`SkinnedLitMaterial ${label} must contain two finite values`);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function validateUnit(value: number, label: string): void {
|
|
352
|
-
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
353
|
-
throw new Error(`SkinnedLitMaterial ${label} must be finite and in [0, 1]`);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
function validateNonNegative(value: number, label: string): void {
|
|
358
|
-
if (!Number.isFinite(value) || value < 0) {
|
|
359
|
-
throw new Error(`SkinnedLitMaterial ${label} must be finite and non-negative`);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
function validateFinite(value: number, label: string): void {
|
|
364
|
-
if (!Number.isFinite(value)) {
|
|
365
|
-
throw new Error(`SkinnedLitMaterial ${label} must be finite`);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function validatePositive(value: number, label: string): void {
|
|
370
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
371
|
-
throw new Error(`SkinnedLitMaterial ${label} must be finite and positive`);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
function validateMipCount(value: number): void {
|
|
376
|
-
if (!Number.isInteger(value) || value < 1) {
|
|
377
|
-
throw new Error("SkinnedLitMaterial environmentMapMipCount must be a positive integer");
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
function validateProceduralEnvironmentMap(value: PBRProceduralEnvironmentMapOptions): void {
|
|
382
|
-
validateColor3(value.skyColor, "proceduralEnvironmentMap.skyColor");
|
|
383
|
-
validateColor3(value.horizonColor, "proceduralEnvironmentMap.horizonColor");
|
|
384
|
-
validateColor3(value.groundColor, "proceduralEnvironmentMap.groundColor");
|
|
385
|
-
validateColor3(value.specularColor, "proceduralEnvironmentMap.specularColor");
|
|
386
|
-
validateNonNegative(value.intensity, "proceduralEnvironmentMap.intensity");
|
|
387
|
-
validateNonNegative(value.specularIntensity, "proceduralEnvironmentMap.specularIntensity");
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
function identityMatrix(): Float32Array {
|
|
391
|
-
return new Float32Array([
|
|
392
|
-
1, 0, 0, 0,
|
|
393
|
-
0, 1, 0, 0,
|
|
394
|
-
0, 0, 1, 0,
|
|
395
|
-
0, 0, 0, 1
|
|
396
|
-
]);
|
|
397
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Material } from "./Material";
|
|
2
|
-
import { DEFAULT_SKINNED_UNLIT_SHADER_NAME } from "./ShaderLibrary";
|
|
3
|
-
|
|
4
|
-
export interface SkinnedUnlitMaterialOptions {
|
|
5
|
-
readonly name?: string;
|
|
6
|
-
readonly color?: readonly [number, number, number, number];
|
|
7
|
-
readonly maxJoints?: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class SkinnedUnlitMaterial extends Material {
|
|
11
|
-
public readonly maxJoints: number;
|
|
12
|
-
|
|
13
|
-
constructor(options: SkinnedUnlitMaterialOptions = {}) {
|
|
14
|
-
const color = options.color ?? [1, 1, 1, 1];
|
|
15
|
-
validateColor(color);
|
|
16
|
-
const maxJoints = options.maxJoints ?? 96;
|
|
17
|
-
if (!Number.isInteger(maxJoints) || maxJoints <= 0 || maxJoints > 96) {
|
|
18
|
-
throw new Error("SkinnedUnlitMaterial maxJoints must be an integer in [1, 96]");
|
|
19
|
-
}
|
|
20
|
-
super({
|
|
21
|
-
name: options.name ?? "skinned-unlit",
|
|
22
|
-
shaderKey: DEFAULT_SKINNED_UNLIT_SHADER_NAME,
|
|
23
|
-
parameters: {
|
|
24
|
-
u_baseColor: color,
|
|
25
|
-
u_modelViewProjection: identityMatrix(),
|
|
26
|
-
u_jointCount: 1,
|
|
27
|
-
u_jointMatrices: identityMatrix()
|
|
28
|
-
},
|
|
29
|
-
requiredAttributes: ["a_position", "a_joints", "a_weights"],
|
|
30
|
-
uniformSchema: [
|
|
31
|
-
{ name: "u_baseColor", kind: "vec4" },
|
|
32
|
-
{ name: "u_modelViewProjection", kind: "mat4" },
|
|
33
|
-
{ name: "u_jointCount", kind: "float" },
|
|
34
|
-
{ name: "u_jointMatrices", kind: "any" }
|
|
35
|
-
]
|
|
36
|
-
});
|
|
37
|
-
this.maxJoints = maxJoints;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
set color(value: readonly [number, number, number, number]) {
|
|
41
|
-
validateColor(value);
|
|
42
|
-
this.setParameter("u_baseColor", value);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get color(): readonly [number, number, number, number] {
|
|
46
|
-
return this.getParameter("u_baseColor") as readonly [number, number, number, number];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function validateColor(color: readonly [number, number, number, number]): void {
|
|
51
|
-
if (color.length !== 4 || color.some((channel) => channel < 0 || channel > 1 || !Number.isFinite(channel))) {
|
|
52
|
-
throw new Error("SkinnedUnlitMaterial color must contain four finite values in [0, 1]");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function identityMatrix(): Float32Array {
|
|
57
|
-
return new Float32Array([
|
|
58
|
-
1, 0, 0, 0,
|
|
59
|
-
0, 1, 0, 0,
|
|
60
|
-
0, 0, 1, 0,
|
|
61
|
-
0, 0, 0, 1
|
|
62
|
-
]);
|
|
63
|
-
}
|
package/src/SkinningBounds.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { Geometry, type Bounds3 } from "./Geometry";
|
|
2
|
-
import {
|
|
3
|
-
applyMorphTargets,
|
|
4
|
-
computeMorphTargetEnvelopeBounds,
|
|
5
|
-
computeMorphTargetWeightedBounds,
|
|
6
|
-
type MorphTargetDelta
|
|
7
|
-
} from "./MorphTarget";
|
|
8
|
-
|
|
9
|
-
export interface SkinningBoundsPalette {
|
|
10
|
-
readonly jointCount: number;
|
|
11
|
-
readonly matrices: Float32Array | readonly number[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function computeSkinnedGeometryBounds(geometry: Geometry, skinning: SkinningBoundsPalette | undefined): Bounds3 {
|
|
15
|
-
if (!skinning || !geometry.vertexBuffer.format.hasAttribute("position") || !geometry.vertexBuffer.format.hasAttribute("joints") || !geometry.vertexBuffer.format.hasAttribute("weights")) {
|
|
16
|
-
return geometry.bounds;
|
|
17
|
-
}
|
|
18
|
-
const min: [number, number, number] = [Infinity, Infinity, Infinity];
|
|
19
|
-
const max: [number, number, number] = [-Infinity, -Infinity, -Infinity];
|
|
20
|
-
for (let vertex = 0; vertex < geometry.vertexBuffer.vertexCount; vertex += 1) {
|
|
21
|
-
const position = geometry.vertexBuffer.getAttribute(vertex, "position");
|
|
22
|
-
const joints = geometry.vertexBuffer.getAttribute(vertex, "joints");
|
|
23
|
-
const weights = geometry.vertexBuffer.getAttribute(vertex, "weights");
|
|
24
|
-
const skinned = skinPoint(position, joints, weights, skinning);
|
|
25
|
-
includeBoundsPoint(min, max, skinned);
|
|
26
|
-
}
|
|
27
|
-
if (!Number.isFinite(min[0]) || !Number.isFinite(max[0])) return geometry.bounds;
|
|
28
|
-
return { min, max };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function computeSkinnedMorphTargetWeightedBounds(
|
|
32
|
-
geometry: Geometry,
|
|
33
|
-
skinning: SkinningBoundsPalette | undefined,
|
|
34
|
-
targets: readonly MorphTargetDelta[] | undefined,
|
|
35
|
-
weights: readonly number[] | undefined
|
|
36
|
-
): Bounds3 {
|
|
37
|
-
if (!targets || targets.length === 0 || !weights || weights.length === 0) {
|
|
38
|
-
return computeSkinnedGeometryBounds(geometry, skinning);
|
|
39
|
-
}
|
|
40
|
-
if (!skinning) {
|
|
41
|
-
return computeMorphTargetWeightedBounds(geometry, targets, weights);
|
|
42
|
-
}
|
|
43
|
-
const morphed = applyMorphTargets(geometry, targets, weights);
|
|
44
|
-
try {
|
|
45
|
-
return computeSkinnedGeometryBounds(morphed, skinning);
|
|
46
|
-
} finally {
|
|
47
|
-
morphed.dispose();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function computeSkinnedMorphTargetEnvelopeBounds(
|
|
52
|
-
geometry: Geometry,
|
|
53
|
-
skinning: SkinningBoundsPalette | undefined,
|
|
54
|
-
targets: readonly MorphTargetDelta[] | undefined
|
|
55
|
-
): Bounds3 {
|
|
56
|
-
if (!targets || targets.length === 0) {
|
|
57
|
-
return computeSkinnedGeometryBounds(geometry, skinning);
|
|
58
|
-
}
|
|
59
|
-
if (!skinning || !geometry.vertexBuffer.format.hasAttribute("position") || !geometry.vertexBuffer.format.hasAttribute("joints") || !geometry.vertexBuffer.format.hasAttribute("weights")) {
|
|
60
|
-
return computeMorphTargetEnvelopeBounds(geometry, targets);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const min: [number, number, number] = [Infinity, Infinity, Infinity];
|
|
64
|
-
const max: [number, number, number] = [-Infinity, -Infinity, -Infinity];
|
|
65
|
-
for (let vertex = 0; vertex < geometry.vertexBuffer.vertexCount; vertex += 1) {
|
|
66
|
-
const base = geometry.vertexBuffer.getAttribute(vertex, "position");
|
|
67
|
-
const lower: [number, number, number] = [base[0] ?? 0, base[1] ?? 0, base[2] ?? 0];
|
|
68
|
-
const upper: [number, number, number] = [base[0] ?? 0, base[1] ?? 0, base[2] ?? 0];
|
|
69
|
-
for (const target of targets) {
|
|
70
|
-
const delta = target.positions?.[vertex];
|
|
71
|
-
if (!delta) continue;
|
|
72
|
-
for (let axis = 0; axis < 3; axis += 1) {
|
|
73
|
-
const value = delta[axis] ?? 0;
|
|
74
|
-
if (value < 0) lower[axis] += value;
|
|
75
|
-
if (value > 0) upper[axis] += value;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const joints = geometry.vertexBuffer.getAttribute(vertex, "joints");
|
|
79
|
-
const weights = geometry.vertexBuffer.getAttribute(vertex, "weights");
|
|
80
|
-
includeBoundsPoint(min, max, skinPoint(lower, joints, weights, skinning));
|
|
81
|
-
includeBoundsPoint(min, max, skinPoint(upper, joints, weights, skinning));
|
|
82
|
-
}
|
|
83
|
-
if (!Number.isFinite(min[0]) || !Number.isFinite(max[0])) return geometry.bounds;
|
|
84
|
-
return { min, max };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function skinPoint(
|
|
88
|
-
position: readonly number[],
|
|
89
|
-
joints: readonly number[],
|
|
90
|
-
weights: readonly number[],
|
|
91
|
-
skinning: SkinningBoundsPalette
|
|
92
|
-
): readonly [number, number, number] {
|
|
93
|
-
const input: readonly [number, number, number] = [position[0] ?? 0, position[1] ?? 0, position[2] ?? 0];
|
|
94
|
-
const output: [number, number, number] = [0, 0, 0];
|
|
95
|
-
let weightSum = 0;
|
|
96
|
-
for (let slot = 0; slot < 4; slot += 1) {
|
|
97
|
-
const weight = weights[slot] ?? 0;
|
|
98
|
-
if (weight === 0) continue;
|
|
99
|
-
const joint = Math.max(0, Math.min(skinning.jointCount - 1, Math.trunc(joints[slot] ?? 0)));
|
|
100
|
-
const transformed = transformPoint(skinning.matrices, joint * 16, input);
|
|
101
|
-
output[0] += transformed[0] * weight;
|
|
102
|
-
output[1] += transformed[1] * weight;
|
|
103
|
-
output[2] += transformed[2] * weight;
|
|
104
|
-
weightSum += weight;
|
|
105
|
-
}
|
|
106
|
-
return weightSum > 0.0001 ? output : input;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function transformPoint(matrices: Float32Array | readonly number[], offset: number, point: readonly [number, number, number]): readonly [number, number, number] {
|
|
110
|
-
const x = point[0];
|
|
111
|
-
const y = point[1];
|
|
112
|
-
const z = point[2];
|
|
113
|
-
return [
|
|
114
|
-
(mat(matrices, offset + 0) * x) + (mat(matrices, offset + 4) * y) + (mat(matrices, offset + 8) * z) + mat(matrices, offset + 12),
|
|
115
|
-
(mat(matrices, offset + 1) * x) + (mat(matrices, offset + 5) * y) + (mat(matrices, offset + 9) * z) + mat(matrices, offset + 13),
|
|
116
|
-
(mat(matrices, offset + 2) * x) + (mat(matrices, offset + 6) * y) + (mat(matrices, offset + 10) * z) + mat(matrices, offset + 14)
|
|
117
|
-
];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function mat(matrices: Float32Array | readonly number[], index: number): number {
|
|
121
|
-
return matrices[index] ?? 0;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function includeBoundsPoint(min: [number, number, number], max: [number, number, number], point: readonly [number, number, number]): void {
|
|
125
|
-
min[0] = Math.min(min[0], point[0]);
|
|
126
|
-
min[1] = Math.min(min[1], point[1]);
|
|
127
|
-
min[2] = Math.min(min[2], point[2]);
|
|
128
|
-
max[0] = Math.max(max[0], point[0]);
|
|
129
|
-
max[1] = Math.max(max[1], point[1]);
|
|
130
|
-
max[2] = Math.max(max[2], point[2]);
|
|
131
|
-
}
|