@zephyr3d/scene 0.9.24 → 0.9.26
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/animation/hair/gpu_hair_simulation.js +1090 -0
- package/dist/animation/hair/gpu_hair_simulation.js.map +1 -0
- package/dist/animation/joint_dynamics/controller.js +7 -5
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +81 -5
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -4
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +58 -24
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/multi_chain_spring_system.js +577 -179
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +4 -3
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_node_pose_tracker.js +40 -0
- package/dist/animation/spring/spring_node_pose_tracker.js.map +1 -0
- package/dist/animation/spring/spring_particle.js +2 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +11 -3
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +10 -0
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/engine.js +53 -43
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptingsystem.js +119 -6
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +3 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +284 -67
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/zhair/zhair_format.js +288 -0
- package/dist/asset/loaders/zhair/zhair_format.js.map +1 -0
- package/dist/asset/loaders/zhair/zhair_loader.js +221 -0
- package/dist/asset/loaders/zhair/zhair_loader.js.map +1 -0
- package/dist/asset/model.js +178 -67
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +193 -21
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +3 -1
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +4040 -1290
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/material/eye.js +932 -0
- package/dist/material/eye.js.map +1 -0
- package/dist/material/hair.js +917 -0
- package/dist/material/hair.js.map +1 -0
- package/dist/material/hairstrand.js +842 -0
- package/dist/material/hairstrand.js.map +1 -0
- package/dist/material/hairstrand_data.js +162 -0
- package/dist/material/hairstrand_data.js.map +1 -0
- package/dist/material/lambert.js +5 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +338 -300
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +120 -19
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +1 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +5 -3
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +5 -4
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +3 -3
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +73 -18
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +4 -4
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +48 -11
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mtoon.js +6 -5
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrblueprint.js +146 -28
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrblueprint_instance.js +501 -0
- package/dist/material/pbrblueprint_instance.js.map +1 -0
- package/dist/material/pbrmr.js +15 -16
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/shader/helper.js +766 -456
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +55 -0
- package/dist/material/shader/terrain_blend.js.map +1 -0
- package/dist/material/skin.js +192 -32
- package/dist/material/skin.js.map +1 -1
- package/dist/material/spriteblueprint.js +16 -1
- package/dist/material/spriteblueprint.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +86 -23
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/water.js +3 -1
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/bloom.js +167 -7
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/coloradjust.js +2 -1
- package/dist/posteffect/coloradjust.js.map +1 -1
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +2 -1
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -1
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js +4 -1
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/skinsss.js +368 -69
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +16 -9
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +91 -34
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/posteffect/tonemap.js +44 -1
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +45 -39
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +4 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +19 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +36 -2
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +26 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +52 -51
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +1 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +3 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +3 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +3 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/oit.js +29 -0
- package/dist/render/oit.js.map +1 -0
- package/dist/render/render_queue.js +3 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +2 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +61 -1
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/shadow_mask_pass.js +73 -8
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/sky.js +166 -126
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +36 -35
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +8 -0
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -0
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +4 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/hair.js +963 -0
- package/dist/scene/hair.js.map +1 -0
- package/dist/scene/light.js +5 -1
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +481 -47
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +3 -0
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +3 -0
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +6 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +3 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -1
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +273 -249
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +3 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +6 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/texture_cache.js +309 -0
- package/dist/scene/terrain-cm/texture_cache.js.map +1 -0
- package/dist/scene/water.js +6 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/diffusion.js +54 -0
- package/dist/shaders/diffusion.js.map +1 -0
- package/dist/shaders/shadow.js +33 -21
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/temporal.js +71 -33
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shadow/dom.js +546 -0
- package/dist/shadow/dom.js.map +1 -0
- package/dist/shadow/pcf_opt.js +3 -5
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +1 -1
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/receiver_bias.js +41 -0
- package/dist/shadow/receiver_bias.js.map +1 -0
- package/dist/shadow/shader.js +20 -60
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +89 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +50 -50
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +150 -37
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/shape.js +11 -2
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +50 -9
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +112 -2
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/func.js +142 -49
- package/dist/utility/blueprint/material/func.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +490 -25
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +898 -4
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +431 -100
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +370 -3
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +133 -1
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +26 -5
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/hair.js +1141 -0
- package/dist/utility/serialization/scene/hair.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +84 -4
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1867 -166
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +231 -14
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +141 -7
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +18 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +4 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +92 -69
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +4 -0
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +96 -95
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/values.js +105 -58
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"water.js","sources":["../../../../src/utility/serialization/scene/water.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { Vector2 } from '@zephyr3d/base';\r\nimport type { SceneNode } from '../../../scene';\r\nimport { GraphNode } from '../../../scene';\r\nimport { Water } from '../../../scene/water';\r\nimport { defineProps, type SerializableClass } from '../types';\r\nimport type { WaveGenerator } from '../../../render';\r\nimport { FBMWaveGenerator, FFTWaveGenerator } from '../../../render';\r\nimport type { Texture2D } from '@zephyr3d/device';\r\nimport type { ResourceManager } from '../manager';\r\n\r\n/** @internal */\r\nexport function getFBMWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: FBMWaveGenerator,\r\n name: 'FBMWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'NumOctaves',\r\n description: 'Number of FBM noise octaves used to build the wave pattern',\r\n type: 'int',\r\n options: { minValue: 1, maxValue: 8 },\r\n default: 4,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.numOctaves;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.numOctaves = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wind',\r\n description: 'Wind direction and speed that drive the FBM waves',\r\n type: 'vec2',\r\n default: [0.1, 0],\r\n options: {\r\n animatable: true\r\n },\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.wind.x;\r\n value.num[1] = this.wind.y;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.wind = new Vector2(value.num[0], value.num[1]);\r\n }\r\n },\r\n {\r\n name: 'Amplitude',\r\n description: 'Wave height amplitude for the FBM wave generator',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 5 },\r\n default: 0.3,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.amplitude;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.amplitude = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Frequency',\r\n description: 'Wave frequency for the FBM wave generator',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 16 },\r\n default: 3,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.frequency;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.frequency = value.num[0];\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getFFTWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: FFTWaveGenerator,\r\n name: 'FFTWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'Alignment',\r\n description: 'How strongly FFT waves align with the wind direction',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.alignment;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.alignment = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wind',\r\n description: 'Wind direction and speed that drive the FFT waves',\r\n type: 'vec2',\r\n options: {\r\n animatable: true\r\n },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.wind.x;\r\n value.num[1] = this.wind.y;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.wind = new Vector2(value.num[0], value.num[1]);\r\n }\r\n },\r\n {\r\n name: 'FoamWidth',\r\n description: 'Width of foam bands generated on the wave crests',\r\n type: 'float',\r\n default: 1.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.foamWidth;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.foamWidth = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'FoamContrast',\r\n description: 'Contrast of the foam pattern on FFT waves',\r\n type: 'float',\r\n default: 7.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.foamContrast;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.foamContrast = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'WaveLengthCascades',\r\n description: 'Wavelength values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [400, 100, 15],\r\n options: { animatable: true, minValue: 0, maxValue: 1000 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveLength(0);\r\n value.num[1] = this.getWaveLength(1);\r\n value.num[2] = this.getWaveLength(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveLength(0, value.num[0]);\r\n this.setWaveLength(1, value.num[1]);\r\n this.setWaveLength(2, value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'WaveStrengthCascades',\r\n description: 'Strength values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [0.4, 0.4, 0.2],\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveStrength(0);\r\n value.num[1] = this.getWaveStrength(1);\r\n value.num[2] = this.getWaveStrength(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveStrength(0, value.num[0]);\r\n this.setWaveStrength(1, value.num[1]);\r\n this.setWaveStrength(2, value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'WaveCroppinessCascades',\r\n description: 'Croppiness values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [-1.5, -1.2, -0.5],\r\n options: { animatable: true, minValue: -4, maxValue: 0 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveCroppiness(0);\r\n value.num[1] = this.getWaveCroppiness(1);\r\n value.num[2] = this.getWaveCroppiness(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveCroppiness(0, value.num[0]);\r\n this.setWaveCroppiness(1, value.num[1]);\r\n this.setWaveCroppiness(2, value.num[2]);\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getWaterClass(manager: ResourceManager): SerializableClass {\r\n return {\r\n ctor: Water,\r\n name: 'Water',\r\n parent: GraphNode,\r\n createFunc(ctx: SceneNode) {\r\n const node = new Water(ctx.scene!);\r\n node.parent = ctx;\r\n return { obj: node };\r\n },\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'WaveGenerator',\r\n description: 'Wave generator used to drive the water surface',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n objectTypes: [FFTWaveGenerator, FBMWaveGenerator]\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.object[0] = this.waveGenerator ?? null;\r\n },\r\n set(this: Water, value) {\r\n if (!value.object[0]) {\r\n this.waveGenerator = null;\r\n } else {\r\n this.waveGenerator = value.object[0] as WaveGenerator;\r\n }\r\n }\r\n },\r\n {\r\n name: 'GridScale',\r\n description: 'Scale of the water simulation grid',\r\n type: 'float',\r\n default: 1,\r\n options: { minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.gridScale;\r\n },\r\n set(this: Water, value) {\r\n this.gridScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wireframe',\r\n description: 'If true, renders the water surface as wireframe',\r\n type: 'bool',\r\n default: false,\r\n get(this: Water, value) {\r\n value.bool[0] = this.wireframe;\r\n },\r\n set(this: Water, value) {\r\n this.wireframe = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'AnimationSpeed',\r\n description: 'Playback speed of wave animation',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: Water, value) {\r\n value.num[0] = this.animationSpeed;\r\n },\r\n set(this: Water, value) {\r\n this.animationSpeed = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'DepthScale',\r\n description: 'Depth attenuation scale for the water material',\r\n type: 'float',\r\n default: 10,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.depthMulti;\r\n },\r\n set(this: Water, value) {\r\n this.material.depthMulti = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'RefractionStrength',\r\n description: 'Strength of underwater refraction',\r\n type: 'float',\r\n default: 0,\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.refractionStrength;\r\n },\r\n set(this: Water, value) {\r\n this.material.refractionStrength = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Displace',\r\n description: 'Vertex displacement scale for water waves',\r\n type: 'float',\r\n default: 16,\r\n options: { minValue: 1, maxValue: 256 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.displace;\r\n },\r\n set(this: Water, value) {\r\n this.material.displace = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'TAAStrength',\r\n description: 'Temporal anti-aliasing strength for the water surface',\r\n type: 'float',\r\n default: 0.4,\r\n options: { minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.TAAStrength;\r\n },\r\n set(this: Water, value) {\r\n this.TAAStrength = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ScatterRampTexture',\r\n description: 'Ramp texture used for water scatter lighting',\r\n type: 'object',\r\n default: null,\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = manager.getAssetId(this.material.scatterRampTexture) ?? '';\r\n },\r\n async set(value) {\r\n if (!value) {\r\n this.material.scatterRampTexture = null;\r\n } else {\r\n if (value.str[0]) {\r\n const assetId = value.str[0];\r\n let tex: Nullable<Texture2D>;\r\n try {\r\n tex = await manager.fetchTexture<Texture2D>(assetId);\r\n } catch (err) {\r\n console.error(`Load asset failed: ${value.str[0]}: ${err}`);\r\n tex = null;\r\n }\r\n if (tex?.isTexture2D()) {\r\n this.material.scatterRampTexture = tex;\r\n } else {\r\n console.error('Invalid texture type');\r\n }\r\n }\r\n }\r\n }\r\n },\r\n {\r\n name: 'AbsorptionRampTexture',\r\n description: 'Ramp texture used for water absorption',\r\n type: 'object',\r\n default: null,\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = manager.getAssetId(this.material.absorptionRampTexture) ?? '';\r\n },\r\n async set(this: Water, value) {\r\n if (!value) {\r\n this.material.absorptionRampTexture = null;\r\n } else {\r\n if (value.str[0]) {\r\n const assetId = value.str[0];\r\n let tex: Nullable<Texture2D>;\r\n try {\r\n tex = await manager.fetchTexture<Texture2D>(assetId);\r\n } catch (err) {\r\n console.error(`Load asset failed: ${value.str[0]}: ${err}`);\r\n tex = null;\r\n }\r\n if (tex?.isTexture2D()) {\r\n this.material.absorptionRampTexture = tex;\r\n } else {\r\n console.error('Invalid texture type');\r\n }\r\n }\r\n }\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n"],"names":["getFBMWaveGeneratorClass","ctor","FBMWaveGenerator","name","getProps","defineProps","description","type","options","minValue","maxValue","default","get","value","num","numOctaves","set","animatable","wind","x","y","Vector2","amplitude","frequency","getFFTWaveGeneratorClass","FFTWaveGenerator","alignment","foamWidth","foamContrast","getWaveLength","setWaveLength","getWaveStrength","setWaveStrength","getWaveCroppiness","setWaveCroppiness","getWaterClass","manager","Water","parent","GraphNode","createFunc","ctx","node","scene","obj","objectTypes","isNullable","object","waveGenerator","gridScale","bool","wireframe","animationSpeed","material","depthMulti","refractionStrength","displace","TAAStrength","str","getAssetId","scatterRampTexture","assetId","tex","fetchTexture","err","console","error","isTexture2D","absorptionRampTexture"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,iBACO,SAASA,wBAAAA,GAAAA;IACd,OAAO;QACLC,IAAMC,EAAAA,gBAAAA;QACNC,IAAM,EAAA,kBAAA;AACNC,QAAAA,QAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOC,WAAY,CAAA;AACjB,gBAAA;oBACEF,IAAM,EAAA,YAAA;oBACNG,WAAa,EAAA,4DAAA;oBACbC,IAAM,EAAA,KAAA;oBACNC,OAAS,EAAA;wBAAEC,QAAU,EAAA,CAAA;wBAAGC,QAAU,EAAA;AAAE,qBAAA;oBACpCC,OAAS,EAAA,CAAA;AACTC,oBAAAA,GAAAA,CAAAA,CAA4BC,KAAK,EAAA;AAC/BA,wBAAAA,KAAAA,CAAMC,GAAG,CAAC,CAAA,CAAE,GAAG,IAAI,CAACC,UAAU;AAChC,qBAAA;AACAC,oBAAAA,GAAAA,CAAAA,CAA4BH,KAAK,EAAA;AAC/B,wBAAA,IAAI,CAACE,UAAU,GAAGF,KAAMC,CAAAA,GAAG,CAAC,CAAE,CAAA;AAChC;AACF,iBAAA;AACA,gBAAA;oBACEX,IAAM,EAAA,MAAA;oBACNG,WAAa,EAAA,mDAAA;oBACbC,IAAM,EAAA,MAAA;oBACNI,OAAS,EAAA;AAAC,wBAAA,GAAA;AAAK,wBAAA;AAAE,qBAAA;oBACjBH,OAAS,EAAA;wBACPS,UAAY,EAAA;AACd,qBAAA;AACAL,oBAAAA,GAAAA,CAAAA,CAA4BC,KAAK,EAAA;wBAC/BA,KAAMC,CAAAA,GAAG,CAAC,CAAE,CAAA,GAAG,IAAI,CAACI,IAAI,CAACC,CAAC;wBAC1BN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A,OAAAA,CAAQC,KAAK,CAAC,sBAAA,CAAA;AAChB;AACF;AACF;AACF;AACF;AACD,aAAA,CAAA;AACH;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"water.js","sources":["../../../../src/utility/serialization/scene/water.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { Vector2 } from '@zephyr3d/base';\r\nimport type { SceneNode } from '../../../scene';\r\nimport { GraphNode } from '../../../scene';\r\nimport { Water } from '../../../scene/water';\r\nimport { defineProps, type SerializableClass } from '../types';\r\nimport type { WaveGenerator } from '../../../render';\r\nimport { FBMWaveGenerator, FFTWaveGenerator } from '../../../render';\r\nimport type { Texture2D } from '@zephyr3d/device';\r\nimport type { ResourceManager } from '../manager';\r\n\r\n/** @internal */\r\nexport function getFBMWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: FBMWaveGenerator,\r\n name: 'FBMWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'NumOctaves',\r\n description: 'Number of FBM noise octaves used to build the wave pattern',\r\n type: 'int',\r\n options: { minValue: 1, maxValue: 8 },\r\n default: 4,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.numOctaves;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.numOctaves = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wind',\r\n description: 'Wind direction and speed that drive the FBM waves',\r\n type: 'vec2',\r\n default: [0.1, 0],\r\n options: {\r\n animatable: true\r\n },\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.wind.x;\r\n value.num[1] = this.wind.y;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.wind = new Vector2(value.num[0], value.num[1]);\r\n }\r\n },\r\n {\r\n name: 'Amplitude',\r\n description: 'Wave height amplitude for the FBM wave generator',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 5 },\r\n default: 0.3,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.amplitude;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.amplitude = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Frequency',\r\n description: 'Wave frequency for the FBM wave generator',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 16 },\r\n default: 3,\r\n get(this: FBMWaveGenerator, value) {\r\n value.num[0] = this.frequency;\r\n },\r\n set(this: FBMWaveGenerator, value) {\r\n this.frequency = value.num[0];\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getFFTWaveGeneratorClass(): SerializableClass {\r\n return {\r\n ctor: FFTWaveGenerator,\r\n name: 'FFTWaveGenerator',\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'Alignment',\r\n description: 'How strongly FFT waves align with the wind direction',\r\n type: 'float',\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.alignment;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.alignment = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wind',\r\n description: 'Wind direction and speed that drive the FFT waves',\r\n type: 'vec2',\r\n options: {\r\n animatable: true\r\n },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.wind.x;\r\n value.num[1] = this.wind.y;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.wind = new Vector2(value.num[0], value.num[1]);\r\n }\r\n },\r\n {\r\n name: 'FoamWidth',\r\n description: 'Width of foam bands generated on the wave crests',\r\n type: 'float',\r\n default: 1.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.foamWidth;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.foamWidth = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'FoamContrast',\r\n description: 'Contrast of the foam pattern on FFT waves',\r\n type: 'float',\r\n default: 7.2,\r\n options: { animatable: true, minValue: 0, maxValue: 10 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.foamContrast;\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.foamContrast = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'WaveLengthCascades',\r\n description: 'Wavelength values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [400, 100, 15],\r\n options: { animatable: true, minValue: 0, maxValue: 1000 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveLength(0);\r\n value.num[1] = this.getWaveLength(1);\r\n value.num[2] = this.getWaveLength(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveLength(0, value.num[0]);\r\n this.setWaveLength(1, value.num[1]);\r\n this.setWaveLength(2, value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'WaveStrengthCascades',\r\n description: 'Strength values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [0.4, 0.4, 0.2],\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveStrength(0);\r\n value.num[1] = this.getWaveStrength(1);\r\n value.num[2] = this.getWaveStrength(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveStrength(0, value.num[0]);\r\n this.setWaveStrength(1, value.num[1]);\r\n this.setWaveStrength(2, value.num[2]);\r\n }\r\n },\r\n {\r\n name: 'WaveCroppinessCascades',\r\n description: 'Croppiness values for the three FFT wave cascades',\r\n type: 'vec3',\r\n default: [-1.5, -1.2, -0.5],\r\n options: { animatable: true, minValue: -4, maxValue: 0 },\r\n get(this: FFTWaveGenerator, value) {\r\n value.num[0] = this.getWaveCroppiness(0);\r\n value.num[1] = this.getWaveCroppiness(1);\r\n value.num[2] = this.getWaveCroppiness(2);\r\n },\r\n set(this: FFTWaveGenerator, value) {\r\n this.setWaveCroppiness(0, value.num[0]);\r\n this.setWaveCroppiness(1, value.num[1]);\r\n this.setWaveCroppiness(2, value.num[2]);\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport function getWaterClass(manager: ResourceManager): SerializableClass {\r\n return {\r\n ctor: Water,\r\n name: 'Water',\r\n parent: GraphNode,\r\n createFunc(ctx: SceneNode) {\r\n const node = new Water(ctx.scene!);\r\n node.parent = ctx;\r\n return { obj: node };\r\n },\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'WaveGenerator',\r\n description: 'Wave generator used to drive the water surface',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n objectTypes: [FFTWaveGenerator, FBMWaveGenerator]\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.object[0] = this.waveGenerator ?? null;\r\n },\r\n set(this: Water, value) {\r\n if (!value.object[0]) {\r\n this.waveGenerator = null;\r\n } else {\r\n this.waveGenerator = value.object[0] as WaveGenerator;\r\n }\r\n }\r\n },\r\n {\r\n name: 'GridScale',\r\n description: 'Scale of the water simulation grid',\r\n type: 'float',\r\n default: 1,\r\n options: { minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.gridScale;\r\n },\r\n set(this: Water, value) {\r\n this.gridScale = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Wireframe',\r\n description: 'If true, renders the water surface as wireframe',\r\n type: 'bool',\r\n default: false,\r\n get(this: Water, value) {\r\n value.bool[0] = this.wireframe;\r\n },\r\n set(this: Water, value) {\r\n this.wireframe = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'AnimationSpeed',\r\n description: 'Playback speed of wave animation',\r\n type: 'float',\r\n default: 1,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: Water, value) {\r\n value.num[0] = this.animationSpeed;\r\n },\r\n set(this: Water, value) {\r\n this.animationSpeed = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'DepthScale',\r\n description: 'Depth attenuation scale for the water material',\r\n type: 'float',\r\n default: 10,\r\n options: { animatable: true, minValue: 0, maxValue: 100 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.depthMulti;\r\n },\r\n set(this: Water, value) {\r\n this.material.depthMulti = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'RefractionStrength',\r\n description: 'Strength of underwater refraction',\r\n type: 'float',\r\n default: 0,\r\n options: { animatable: true, minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.refractionStrength;\r\n },\r\n set(this: Water, value) {\r\n this.material.refractionStrength = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'Displace',\r\n description: 'Vertex displacement scale for water waves',\r\n type: 'float',\r\n default: 16,\r\n options: { minValue: 1, maxValue: 256 },\r\n get(this: Water, value) {\r\n value.num[0] = this.material.displace;\r\n },\r\n set(this: Water, value) {\r\n this.material.displace = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'TAAStrength',\r\n description: 'Temporal anti-aliasing strength for the water surface',\r\n type: 'float',\r\n default: 0.4,\r\n options: { minValue: 0, maxValue: 1 },\r\n get(this: Water, value) {\r\n value.num[0] = this.TAAStrength;\r\n },\r\n set(this: Water, value) {\r\n this.TAAStrength = value.num[0];\r\n }\r\n },\r\n {\r\n name: 'ScatterRampTexture',\r\n description: 'Ramp texture used for water scatter lighting',\r\n type: 'object',\r\n default: null,\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = manager.getAssetId(this.material.scatterRampTexture) ?? '';\r\n },\r\n async set(value) {\r\n if (!value) {\r\n this.material.scatterRampTexture = null;\r\n } else {\r\n if (value.str[0]) {\r\n const assetId = value.str[0];\r\n let tex: Nullable<Texture2D>;\r\n try {\r\n tex = await manager.fetchTexture<Texture2D>(assetId);\r\n } catch (err) {\r\n console.error(`Load asset failed: ${value.str[0]}: ${err}`);\r\n tex = null;\r\n }\r\n if (tex?.isTexture2D()) {\r\n this.material.scatterRampTexture = tex;\r\n } else {\r\n console.error('Invalid texture type');\r\n }\r\n }\r\n }\r\n }\r\n },\r\n {\r\n name: 'AbsorptionRampTexture',\r\n description: 'Ramp texture used for water absorption',\r\n type: 'object',\r\n default: null,\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: Water, value) {\r\n value.str[0] = manager.getAssetId(this.material.absorptionRampTexture) ?? '';\r\n },\r\n async set(this: Water, value) {\r\n if (!value) {\r\n this.material.absorptionRampTexture = null;\r\n } else {\r\n if (value.str[0]) {\r\n const assetId = value.str[0];\r\n let tex: Nullable<Texture2D>;\r\n try {\r\n tex = await manager.fetchTexture<Texture2D>(assetId);\r\n } catch (err) {\r\n console.error(`Load asset failed: ${value.str[0]}: ${err}`);\r\n tex = null;\r\n }\r\n if (tex?.isTexture2D()) {\r\n this.material.absorptionRampTexture = tex;\r\n } else {\r\n console.error('Invalid texture type');\r\n }\r\n }\r\n }\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n}\r\n"],"names":["getFBMWaveGeneratorClass","ctor","FBMWaveGenerator","name","getProps","defineProps","description","type","options","minValue","maxValue","default","get","value","num","numOctaves","set","animatable","wind","x","y","Vector2","amplitude","frequency","getFFTWaveGeneratorClass","FFTWaveGenerator","alignment","foamWidth","foamContrast","getWaveLength","setWaveLength","getWaveStrength","setWaveStrength","getWaveCroppiness","setWaveCroppiness","getWaterClass","manager","Water","parent","GraphNode","createFunc","ctx","node","scene","obj","objectTypes","isNullable","object","waveGenerator","gridScale","bool","wireframe","animationSpeed","material","depthMulti","refractionStrength","displace","TAAStrength","str","getAssetId","scatterRampTexture","assetId","tex","fetchTexture","err","console","error","isTexture2D","absorptionRampTexture"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,iBACO,SAASA,wBAAAA,GAAAA;IACd,OAAO;QACLC,IAAMC,EAAAA,gBAAAA;QACNC,IAAM,EAAA,kBAAA;AACNC,QAAAA,QAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOC,WAAY,CAAA;AACjB,gBAAA;oBACEF,IAAM,EAAA,YAAA;oBACNG,WA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,CAAK,IAAA,EAAA;AAC5E,qBAAA;AACA,oBAAA,MAAMpD,KAAiBH,KAAK,EAAA;AAC1B,wBAAA,IAAI,CAACA,KAAO,EAAA;AACV,4BAAA,IAAI,CAACwC,QAAQ,CAACe,qBAAqB,GAAG,IAAA;yBACjC,MAAA;AACL,4BAAA,IAAIvD,KAAM6C,CAAAA,GAAG,CAAC,CAAA,CAAE,EAAE;AAChB,gCAAA,MAAMG,OAAUhD,GAAAA,KAAAA,CAAM6C,GAAG,CAAC,CAAE,CAAA;gCAC5B,IAAII,GAAAA;gCACJ,IAAI;oCACFA,GAAM,GAAA,MAAM1B,OAAQ2B,CAAAA,YAAY,CAAYF,OAAAA,CAAAA;AAC9C,iCAAA,CAAE,OAAOG,GAAK,EAAA;AACZC,oCAAAA,OAAAA,CAAQC,KAAK,CAAC,CAAC,mBAAmB,EAAErD,KAAAA,CAAM6C,GAAG,CAAC,CAAE,CAAA,CAAC,EAAE,EAAEM,GAAK,CAAA,CAAA,CAAA;oCAC1DF,GAAM,GAAA,IAAA;AACR;AACA,gCAAA,IAAIA,KAAKK,WAAe,EAAA,EAAA;AACtB,oCAAA,IAAI,CAACd,QAAQ,CAACe,qBAAqB,GAAGN,GAAAA;iCACjC,MAAA;AACLG,oCAAAA,OAAAA,CAAQC,KAAK,CAAC,sBAAA,CAAA;AAChB;AACF;AACF;AACF;AACF;AACD,aAAA,CAAA;AACH;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/utility/serialization/types.ts"],"sourcesContent":["import type { GenericConstructor, Nullable, RequireOptionals } from '@zephyr3d/base';\r\n\r\n/**\r\n * Enumerates supported data types for serializable properties.\r\n *\r\n * This type informs serializers/editors how to interpret and encode values.\r\n * 'bool'|'int'|'float'|'vec2'|'vec3'|'vec4'|'int2'|'int3'|'int4'|'string'|'rgb'|'rgba'|'object'|'object_array'|'embedded'|'command';\r\n *\r\n * @public\r\n */\r\nexport type PropertyType = string;\r\n\r\n/**\r\n * Maps a property type discriminator to the corresponding value lane key.\r\n *\r\n * @public\r\n */\r\nexport type PropertyToType<T extends string> = T extends\r\n | 'float'\r\n | 'vec2'\r\n | 'vec3'\r\n | 'vec4'\r\n | 'int'\r\n | 'int2'\r\n | 'int3'\r\n | 'int4'\r\n | 'rgb'\r\n | 'rgba'\r\n ? 'num'\r\n : T extends 'bool'\r\n ? 'bool'\r\n : T extends 'string'\r\n ? 'str'\r\n : T extends 'object' | 'object_array'\r\n ? 'object'\r\n : 'num' | 'bool' | 'str' | 'object';\r\n/**\r\n * Container for a serializable property's value.\r\n *\r\n * Values are carried in typed arrays (even for single values) to support\r\n * both scalar and array-like properties in a unified shape.\r\n *\r\n * Conventions:\r\n * - `num` carries numeric data for types like `int`, `float`, `vec*`, `int*`, `rgb`, `rgba`\r\n * - `str` carries string data for `string`\r\n * - `bool` carries boolean data for `bool`\r\n * - `object` carries references/instances for `object`, `object_array`, `embedded`\r\n *\r\n * Only the relevant field(s) for the property's {@link PropertyType} will be populated.\r\n *\r\n * @public\r\n */\r\nexport type PropertyValue = {\r\n /** Numeric lane(s) for numeric, vector, or color types. */\r\n num?: number[];\r\n /** String lane(s) for text properties. */\r\n str?: string[];\r\n /** Boolean lane(s) for boolean properties. */\r\n bool?: boolean[];\r\n /** Object lane(s) for object references or embedded objects. */\r\n object?: Nullable<object>[];\r\n};\r\n\r\n/**\r\n * Editor-oriented edit types that augment how a property is presented/edited.\r\n *\r\n * This is orthogonal to {@link PropertyType} and is purely an editor hint.\r\n *\r\n * @public\r\n */\r\nexport type PropEdit = 'aabb' | 'quaternion' | 'proptrack' | 'curve1f';\r\n\r\n/**\r\n * Extra scene-node picker hints for a property.\r\n *\r\n * @public\r\n */\r\nexport type PropertySceneNodeOptions = {\r\n kind?: 'node' | 'mesh';\r\n};\r\n\r\n/**\r\n * Additional options controlling how a property is displayed, constrained, and edited.\r\n *\r\n * These options are consumed primarily by an editor/inspector UI, but may\r\n * also influence validation and tooling behavior.\r\n *\r\n * @public\r\n */\r\nexport type PropertyAccessorOptions = {\r\n /** Human-friendly label for UI. Defaults to `name` if omitted. */\r\n label?: string;\r\n /** Logical grouping/category in UI. */\r\n group?: string;\r\n /** Editor presentation hint (e.g., quaternion gizmo, animation track). */\r\n edit?: PropEdit;\r\n /** Minimum numeric value (for sliders/spinners). */\r\n minValue?: number;\r\n /** Maximum numeric value (for sliders/spinners). */\r\n maxValue?: number;\r\n /** Whether string property is multiline. */\r\n multiline?: boolean;\r\n /** Step/speed for numeric editing UI. */\r\n speed?: number;\r\n /** Whether the property can be animated/keyframed. */\r\n animatable?: boolean;\r\n /** Allowed MIME types for file-picker-like editors. */\r\n mimeTypes?: string[];\r\n /** Accept scene hierarchy node drag-drop in the inspector. */\r\n sceneNode?: PropertySceneNodeOptions;\r\n /** Render object-array entries inline instead of expandable nested groups. */\r\n inlineObjectArray?: boolean;\r\n /** Allowed constructor types when choosing/creating object references. */\r\n objectTypes?: GenericConstructor[];\r\n /**\r\n * Optional enumeration metadata.\r\n * `labels[i]` corresponds to `values[i]`.\r\n */\r\n enum?: { labels: string[]; values: unknown[] };\r\n};\r\n\r\n/**\r\n * Returns the property accessor list unchanged while preserving typing.\r\n *\r\n * @public\r\n */\r\nexport function defineProps(accessors: PropertyAccessor<any, 'DUMMY'>[]): PropertyAccessor[] {\r\n return accessors;\r\n}\r\n\r\n/**\r\n * Descriptor for a serializable property of a class/type.\r\n *\r\n * This binds together:\r\n * - Metadata: `type`, `name`, `default`, `readonly`, `persistent`, `options`\r\n * - Accessors: `get`, `set`, `add`, `delete`, `create` for manipulating the underlying object state\r\n * - Predicates: `isValid`, `isNullable`, `isHidden` to control UI and validation\r\n * - Commands: `command` for action-style properties (`type: 'command'`)\r\n * - Utilities: `getDefaultValue` to compute defaults dynamically\r\n *\r\n * The accessors are invoked with `this` bound to the owning object instance.\r\n *\r\n * @typeParam T - The instance type that owns the property.\r\n * @public\r\n */\r\nexport type PropertyAccessor<T = object, U extends string = ''> = {\r\n /** The storage/serialization data type. */\r\n type: PropertyType;\r\n /** Unique property name (stable identifier for tooling/serialization). */\r\n name: string;\r\n /** Description of this property */\r\n description?: string;\r\n /**\r\n * Optional evaluation phase/order hint (lower runs earlier).\r\n * Useful for staged initialization or batched updates in editors.\r\n */\r\n phase?: number;\r\n /** If true, the property is read-only in UI and programmatic setters may be disallowed. */\r\n readonly?: boolean;\r\n /** Default value used if none is provided. Can be a primitive, array, or object. */\r\n default?: any;\r\n /**\r\n * If true, the property is persisted during save/serialize.\r\n * Non-persistent properties may be computed or session-only.\r\n */\r\n //persistent?: boolean;\r\n /** Editor and validation options for this property. */\r\n options?: PropertyAccessorOptions;\r\n /**\r\n * Reads the current value from `this` into the provided `value` container.\r\n *\r\n * Implementations should fully populate the appropriate lane(s) (e.g., `num`, `str`, etc.)\r\n * according to the property's {@link PropertyType}.\r\n *\r\n * @param value - Output container to be filled by the getter.\r\n */\r\n get: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>\r\n ) => void;\r\n /**\r\n * Writes an incoming value to `this`.\r\n *\r\n * For array-like properties, `index` can target a specific element.\r\n * Implementations should read from the appropriate lane(s) of `value` according to {@link PropertyType}.\r\n *\r\n * @param value - Input container carrying the new value.\r\n * @param index - Optional element index for array-like properties.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n set?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Creates a new embedded/contained object for object-like properties.\r\n *\r\n * Typically used for `embedded` or `object_array` to instantiate an element.\r\n *\r\n * @param ctor - Constructor to instantiate.\r\n * @param index - Target index where the new object will be inserted.\r\n * @returns The newly created object instance.\r\n */\r\n create?: (this: T, ctor: GenericConstructor, index: number) => Nullable<object>;\r\n /**\r\n * Deletes an element from an array-like property or clears a value.\r\n *\r\n * @param index - Target element index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n delete?: (this: T, index: number) => void | Promise<void>;\r\n /**\r\n * Adds a new element/value to an array-like property.\r\n *\r\n * If `index` is omitted, implementations may append to the end.\r\n *\r\n * @param value - The value to add (read appropriate lane(s) per {@link PropertyType}).\r\n * @param index - Optional insertion index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n add?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Validates the current state of `this` with respect to this property.\r\n *\r\n * Returning `false` may block serialization or UI confirmation.\r\n *\r\n * @returns `true` if valid, otherwise `false`.\r\n */\r\n isValid?: (this: T) => boolean;\r\n /**\r\n * Indicates whether this property is serializable. Default is serializable if not present.\r\n *\r\n * @returns `true` if persistent, otherwise `false`.\r\n */\r\n isPersistent?: (this: T) => boolean;\r\n /**\r\n * Indicates whether a specific element or slot may be `null` or `undefined`.\r\n *\r\n * Applies to array-like or optional properties.\r\n *\r\n * @param index - Target element index.\r\n * @returns `true` if nullable, otherwise `false`.\r\n */\r\n isNullable?: (this: T, index: number) => boolean;\r\n /**\r\n * Controls visibility of a specific element or the property in UI.\r\n *\r\n * @param index - Target element index.\r\n * @param obj - Value at index\r\n * @returns `true` if hidden, otherwise `false`.\r\n */\r\n isHidden?: (this: T, index: number, obj?: unknown) => boolean;\r\n /**\r\n * Executes a command-style property.\r\n *\r\n * Only meaningful for `type: 'command'`. Return value may indicate success or toggle state.\r\n *\r\n * @param index - Optional command index for multi-command groups.\r\n * @returns Command result, commonly a boolean for toggle-like actions.\r\n */\r\n command?: (this: T, index: number) => boolean;\r\n /**\r\n * Supplies a default value dynamically at runtime.\r\n *\r\n * If provided, this takes precedence over the static `default` field.\r\n */\r\n getDefaultValue?: (this: T) => any;\r\n};\r\n\r\n/**\r\n * Descriptor for a serializable class/type.\r\n *\r\n * This defines how a class is identified, constructed, and inspected for properties.\r\n * Editors and serializers can use this metadata to instantiate objects, load initial\r\n * parameters, and enumerate property accessors.\r\n *\r\n * @public\r\n */\r\nexport type SerializableClass = {\r\n /** Concrete constructor for the serializable class. */\r\n ctor: GenericConstructor;\r\n /** Optional parent/superclass constructor to represent inheritance in tooling. */\r\n parent?: GenericConstructor;\r\n /** If true, suppresses title rendering in UI for compact displays. */\r\n noTitle?: boolean;\r\n /** Display name used by tooling and editors. */\r\n name: string;\r\n /**\r\n * Custom factory to create an instance and optionally control property loading.\r\n *\r\n * If `loadProps` is `false`, the caller may skip default property loading\r\n * (useful for lazy or staged initialization).\r\n *\r\n * @param ctx - Optional construction context (editor/runtime-specific).\r\n * @param init - Optional initialization payload.\r\n * @returns The created object and a `loadProps` hint.\r\n */\r\n createFunc?: (\r\n ctx?: any,\r\n init?: any\r\n ) => { obj: any; loadProps?: boolean } | Promise<{ obj: any; loadProps?: boolean }>;\r\n /**\r\n * Extracts initialization parameters from an instance suitable for re-creation.\r\n *\r\n * This is the inverse of `createFunc`'s `init` argument, enabling round-trip\r\n * serialization of constructor/initializer data.\r\n *\r\n * @param obj - The instance to introspect.\r\n * @returns An initialization payload (serializable).\r\n */\r\n getInitParams?: (obj: any, flags: { saveProps: boolean }) => any;\r\n /**\r\n * Enumerates property accessors for this class.\r\n *\r\n * The returned list defines the full set of serializable/editor-visible properties.\r\n *\r\n * @returns Array of property accessors.\r\n */\r\n getProps: () => PropertyAccessor<any>[];\r\n};\r\n"],"names":["defineProps","accessors"],"mappings":"AAyHA;;;;IAKO,SAASA,WAAAA,CAAYC,SAA2C,EAAA;IACrE,OAAOA,SAAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/utility/serialization/types.ts"],"sourcesContent":["import type { GenericConstructor, Nullable, RequireOptionals } from '@zephyr3d/base';\r\n\r\n/**\r\n * Enumerates supported data types for serializable properties.\r\n *\r\n * This type informs serializers/editors how to interpret and encode values.\r\n * 'bool'|'int'|'float'|'vec2'|'vec3'|'vec4'|'int2'|'int3'|'int4'|'string'|'rgb'|'rgba'|'object'|'object_array'|'embedded'|'command';\r\n *\r\n * @public\r\n */\r\nexport type PropertyType = string;\r\n\r\n/**\r\n * Maps a property type discriminator to the corresponding value lane key.\r\n *\r\n * @public\r\n */\r\nexport type PropertyToType<T extends string> = T extends\r\n | 'float'\r\n | 'vec2'\r\n | 'vec3'\r\n | 'vec4'\r\n | 'int'\r\n | 'int2'\r\n | 'int3'\r\n | 'int4'\r\n | 'rgb'\r\n | 'rgba'\r\n ? 'num'\r\n : T extends 'bool'\r\n ? 'bool'\r\n : T extends 'string'\r\n ? 'str'\r\n : T extends 'object' | 'object_array'\r\n ? 'object'\r\n : 'num' | 'bool' | 'str' | 'object';\r\n/**\r\n * Container for a serializable property's value.\r\n *\r\n * Values are carried in typed arrays (even for single values) to support\r\n * both scalar and array-like properties in a unified shape.\r\n *\r\n * Conventions:\r\n * - `num` carries numeric data for types like `int`, `float`, `vec*`, `int*`, `rgb`, `rgba`\r\n * - `str` carries string data for `string`\r\n * - `bool` carries boolean data for `bool`\r\n * - `object` carries references/instances for `object`, `object_array`, `embedded`\r\n *\r\n * Only the relevant field(s) for the property's {@link PropertyType} will be populated.\r\n *\r\n * @public\r\n */\r\nexport type PropertyValue = {\r\n /** Numeric lane(s) for numeric, vector, or color types. */\r\n num?: number[];\r\n /** String lane(s) for text properties. */\r\n str?: string[];\r\n /** Boolean lane(s) for boolean properties. */\r\n bool?: boolean[];\r\n /** Object lane(s) for object references or embedded objects. */\r\n object?: Nullable<object>[];\r\n};\r\n\r\n/**\r\n * Editor-oriented edit types that augment how a property is presented/edited.\r\n *\r\n * This is orthogonal to {@link PropertyType} and is purely an editor hint.\r\n *\r\n * @public\r\n */\r\nexport type PropEdit = 'aabb' | 'quaternion' | 'proptrack' | 'curve1f';\r\n\r\n/**\r\n * Extra scene-node picker hints for a property.\r\n *\r\n * @public\r\n */\r\nexport type PropertySceneNodeOptions = {\r\n kind?: 'node' | 'mesh';\r\n};\r\n\r\n/**\r\n * Additional options controlling how a property is displayed, constrained, and edited.\r\n *\r\n * These options are consumed primarily by an editor/inspector UI, but may\r\n * also influence validation and tooling behavior.\r\n *\r\n * @public\r\n */\r\nexport type PropertyAccessorOptions = {\r\n /** Human-friendly label for UI. Defaults to `name` if omitted. */\r\n label?: string;\r\n /** Logical grouping/category in UI. */\r\n group?: string;\r\n /** Whether the inspector group should be expanded by default. */\r\n defaultOpen?: boolean;\r\n /** Editor presentation hint (e.g., quaternion gizmo, animation track). */\r\n edit?: PropEdit;\r\n /** Minimum numeric value (for sliders/spinners). */\r\n minValue?: number;\r\n /** Maximum numeric value (for sliders/spinners). */\r\n maxValue?: number;\r\n /** Whether string property is multiline. */\r\n multiline?: boolean;\r\n /** Step/speed for numeric editing UI. */\r\n speed?: number;\r\n /** Whether the property can be animated/keyframed. */\r\n animatable?: boolean;\r\n /** Allowed MIME types for file-picker-like editors. */\r\n mimeTypes?: string[];\r\n /** Accept scene hierarchy node drag-drop in the inspector. */\r\n sceneNode?: PropertySceneNodeOptions;\r\n /** Render object-array entries inline instead of expandable nested groups. */\r\n inlineObjectArray?: boolean;\r\n /** Allowed constructor types when choosing/creating object references. */\r\n objectTypes?: GenericConstructor[];\r\n /**\r\n * Optional enumeration metadata.\r\n * `labels[i]` corresponds to `values[i]`.\r\n */\r\n enum?: { labels: string[]; values: unknown[] };\r\n};\r\n\r\n/**\r\n * Returns the property accessor list unchanged while preserving typing.\r\n *\r\n * @public\r\n */\r\nexport function defineProps(accessors: PropertyAccessor<any, 'DUMMY'>[]): PropertyAccessor[] {\r\n return accessors;\r\n}\r\n\r\n/**\r\n * Descriptor for a serializable property of a class/type.\r\n *\r\n * This binds together:\r\n * - Metadata: `type`, `name`, `default`, `readonly`, `persistent`, `options`\r\n * - Accessors: `get`, `set`, `add`, `delete`, `create` for manipulating the underlying object state\r\n * - Predicates: `isValid`, `isNullable`, `isHidden` to control UI and validation\r\n * - Commands: `command` for action-style properties (`type: 'command'`)\r\n * - Utilities: `getDefaultValue` to compute defaults dynamically\r\n *\r\n * The accessors are invoked with `this` bound to the owning object instance.\r\n *\r\n * @typeParam T - The instance type that owns the property.\r\n * @public\r\n */\r\nexport type PropertyAccessor<T = object, U extends string = ''> = {\r\n /** The storage/serialization data type. */\r\n type: PropertyType;\r\n /** Unique property name (stable identifier for tooling/serialization). */\r\n name: string;\r\n /** Description of this property */\r\n description?: string;\r\n /**\r\n * Optional evaluation phase/order hint (lower runs earlier).\r\n * Useful for staged initialization or batched updates in editors.\r\n */\r\n phase?: number;\r\n /** If true, the property is read-only in UI and programmatic setters may be disallowed. */\r\n readonly?: boolean;\r\n /** Default value used if none is provided. Can be a primitive, array, or object. */\r\n default?: any;\r\n /**\r\n * If true, the property is persisted during save/serialize.\r\n * Non-persistent properties may be computed or session-only.\r\n */\r\n //persistent?: boolean;\r\n /** Editor and validation options for this property. */\r\n options?: PropertyAccessorOptions;\r\n /**\r\n * Reads the current value from `this` into the provided `value` container.\r\n *\r\n * Implementations should fully populate the appropriate lane(s) (e.g., `num`, `str`, etc.)\r\n * according to the property's {@link PropertyType}.\r\n *\r\n * @param value - Output container to be filled by the getter.\r\n */\r\n get: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>\r\n ) => void;\r\n /**\r\n * Writes an incoming value to `this`.\r\n *\r\n * For array-like properties, `index` can target a specific element.\r\n * Implementations should read from the appropriate lane(s) of `value` according to {@link PropertyType}.\r\n *\r\n * @param value - Input container carrying the new value.\r\n * @param index - Optional element index for array-like properties.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n set?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Creates a new embedded/contained object for object-like properties.\r\n *\r\n * Typically used for `embedded` or `object_array` to instantiate an element.\r\n *\r\n * @param ctor - Constructor to instantiate.\r\n * @param index - Target index where the new object will be inserted.\r\n * @returns The newly created object instance.\r\n */\r\n create?: (this: T, ctor: GenericConstructor, index: number) => Nullable<object>;\r\n /**\r\n * Deletes an element from an array-like property or clears a value.\r\n *\r\n * @param index - Target element index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n delete?: (this: T, index: number) => void | Promise<void>;\r\n /**\r\n * Adds a new element/value to an array-like property.\r\n *\r\n * If `index` is omitted, implementations may append to the end.\r\n *\r\n * @param value - The value to add (read appropriate lane(s) per {@link PropertyType}).\r\n * @param index - Optional insertion index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n add?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Validates the current state of `this` with respect to this property.\r\n *\r\n * Returning `false` may block serialization or UI confirmation.\r\n *\r\n * @returns `true` if valid, otherwise `false`.\r\n */\r\n isValid?: (this: T) => boolean;\r\n /**\r\n * Indicates whether this property is serializable. Default is serializable if not present.\r\n *\r\n * @returns `true` if persistent, otherwise `false`.\r\n */\r\n isPersistent?: (this: T) => boolean;\r\n /**\r\n * Indicates whether a specific element or slot may be `null` or `undefined`.\r\n *\r\n * Applies to array-like or optional properties.\r\n *\r\n * @param index - Target element index.\r\n * @returns `true` if nullable, otherwise `false`.\r\n */\r\n isNullable?: (this: T, index: number) => boolean;\r\n /**\r\n * Controls visibility of a specific element or the property in UI.\r\n *\r\n * @param index - Target element index.\r\n * @param obj - Value at index\r\n * @returns `true` if hidden, otherwise `false`.\r\n */\r\n isHidden?: (this: T, index: number, obj?: unknown) => boolean;\r\n /**\r\n * Executes a command-style property.\r\n *\r\n * Only meaningful for `type: 'command'`. Return value may indicate success or toggle state.\r\n *\r\n * @param index - Optional command index for multi-command groups.\r\n * @returns Command result, commonly a boolean for toggle-like actions.\r\n */\r\n command?: (this: T, index: number) => boolean;\r\n /**\r\n * Supplies a default value dynamically at runtime.\r\n *\r\n * If provided, this takes precedence over the static `default` field.\r\n */\r\n getDefaultValue?: (this: T) => any;\r\n};\r\n\r\n/**\r\n * Descriptor for a serializable class/type.\r\n *\r\n * This defines how a class is identified, constructed, and inspected for properties.\r\n * Editors and serializers can use this metadata to instantiate objects, load initial\r\n * parameters, and enumerate property accessors.\r\n *\r\n * @public\r\n */\r\nexport type SerializableClass = {\r\n /** Concrete constructor for the serializable class. */\r\n ctor: GenericConstructor;\r\n /** Optional parent/superclass constructor to represent inheritance in tooling. */\r\n parent?: GenericConstructor;\r\n /** If true, suppresses title rendering in UI for compact displays. */\r\n noTitle?: boolean;\r\n /** Display name used by tooling and editors. */\r\n name: string;\r\n /**\r\n * Custom factory to create an instance and optionally control property loading.\r\n *\r\n * If `loadProps` is `false`, the caller may skip default property loading\r\n * (useful for lazy or staged initialization).\r\n *\r\n * @param ctx - Optional construction context (editor/runtime-specific).\r\n * @param init - Optional initialization payload.\r\n * @returns The created object and a `loadProps` hint.\r\n */\r\n createFunc?: (\r\n ctx?: any,\r\n init?: any\r\n ) => { obj: any; loadProps?: boolean } | Promise<{ obj: any; loadProps?: boolean }>;\r\n /**\r\n * Extracts initialization parameters from an instance suitable for re-creation.\r\n *\r\n * This is the inverse of `createFunc`'s `init` argument, enabling round-trip\r\n * serialization of constructor/initializer data.\r\n *\r\n * @param obj - The instance to introspect.\r\n * @returns An initialization payload (serializable).\r\n */\r\n getInitParams?: (obj: any, flags: { saveProps: boolean }) => any;\r\n /**\r\n * Enumerates property accessors for this class.\r\n *\r\n * The returned list defines the full set of serializable/editor-visible properties.\r\n *\r\n * @returns Array of property accessors.\r\n */\r\n getProps: () => PropertyAccessor<any>[];\r\n};\r\n"],"names":["defineProps","accessors"],"mappings":"AA2HA;;;;IAKO,SAASA,WAAAA,CAAYC,SAA2C,EAAA;IACrE,OAAOA,SAAAA;AACT;;;;"}
|
|
@@ -3,23 +3,23 @@ import { Disposable, DRef, Vector4 } from '@zephyr3d/base';
|
|
|
3
3
|
import { fetchSampler } from './misc.js';
|
|
4
4
|
import { getDevice } from '../app/api.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* CubemapSHProjector is responsible for projecting a cubemap texture into spherical harmonics (SH) coefficients.
|
|
8
|
-
* This is commonly used for efficient environment lighting approximation in real-time rendering.
|
|
9
|
-
*
|
|
10
|
-
* The class uses Monte Carlo sampling to compute the first 9 spherical harmonics coefficients (up to order 2)
|
|
11
|
-
* from a cubemap texture, which can then be used for ambient lighting calculations.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const projector = new CubemapSHProjector(10000);
|
|
16
|
-
* const shBuffer = device.createBuffer(4 * 4 * 9, { usage: 'uniform' });
|
|
17
|
-
* projector.projectCubemap(environmentCubemap, shBuffer);
|
|
18
|
-
* // shBuffer now contains the 9 SH coefficients as RGB values
|
|
19
|
-
* projector.dispose();
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
6
|
+
/**
|
|
7
|
+
* CubemapSHProjector is responsible for projecting a cubemap texture into spherical harmonics (SH) coefficients.
|
|
8
|
+
* This is commonly used for efficient environment lighting approximation in real-time rendering.
|
|
9
|
+
*
|
|
10
|
+
* The class uses Monte Carlo sampling to compute the first 9 spherical harmonics coefficients (up to order 2)
|
|
11
|
+
* from a cubemap texture, which can then be used for ambient lighting calculations.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const projector = new CubemapSHProjector(10000);
|
|
16
|
+
* const shBuffer = device.createBuffer(4 * 4 * 9, { usage: 'uniform' });
|
|
17
|
+
* projector.projectCubemap(environmentCubemap, shBuffer);
|
|
18
|
+
* // shBuffer now contains the 9 SH coefficients as RGB values
|
|
19
|
+
* projector.dispose();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
23
|
*/ class CubemapSHProjector extends Disposable {
|
|
24
24
|
static _programInst = null;
|
|
25
25
|
static _bindGroupInst = null;
|
|
@@ -27,60 +27,69 @@ import { getDevice } from '../app/api.js';
|
|
|
27
27
|
_primitive;
|
|
28
28
|
_renderTarget;
|
|
29
29
|
_numSamples;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new CubemapSHProjector instance.
|
|
32
|
-
*
|
|
33
|
-
* @param numSamples - Number of Monte Carlo samples to use for SH projection.
|
|
34
|
-
* Higher values provide better accuracy but slower computation.
|
|
35
|
-
* Default is 10000.
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new CubemapSHProjector instance.
|
|
32
|
+
*
|
|
33
|
+
* @param numSamples - Number of Monte Carlo samples to use for SH projection.
|
|
34
|
+
* Higher values provide better accuracy but slower computation.
|
|
35
|
+
* Default is 10000.
|
|
36
36
|
*/ constructor(numSamples = 10000){
|
|
37
37
|
super();
|
|
38
38
|
this._numSamples = numSamples;
|
|
39
39
|
this._primitive = new DRef();
|
|
40
40
|
this._renderTarget = new DRef();
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Projects a cubemap texture into spherical harmonics coefficients and stores them in a GPUBuffer.
|
|
44
|
-
*
|
|
45
|
-
* The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.
|
|
46
|
-
* The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.
|
|
47
|
-
* The layout is:
|
|
48
|
-
* - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀
|
|
49
|
-
* - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁
|
|
50
|
-
* - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂
|
|
51
|
-
*
|
|
52
|
-
* @param cubemap - The input cubemap texture to project
|
|
53
|
-
* @param outBuffer - GPU data buffer to receive the computed SH coefficients.
|
|
54
|
-
* Must be large enough to hold 9 RGB values (36 floats for RGBA32F format).
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* const shBuffer = device.createDataBuffer(9 * 4 * 4); // 9 coefficients * 4 components * 4 bytes
|
|
59
|
-
* projector.projectCubemap(environmentMap, shBuffer);
|
|
60
|
-
* ```
|
|
42
|
+
/**
|
|
43
|
+
* Projects a cubemap texture into spherical harmonics coefficients and stores them in a GPUBuffer.
|
|
44
|
+
*
|
|
45
|
+
* The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.
|
|
46
|
+
* The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.
|
|
47
|
+
* The layout is:
|
|
48
|
+
* - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀
|
|
49
|
+
* - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁
|
|
50
|
+
* - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂
|
|
51
|
+
*
|
|
52
|
+
* @param cubemap - The input cubemap texture to project
|
|
53
|
+
* @param outBuffer - GPU data buffer to receive the computed SH coefficients.
|
|
54
|
+
* Must be large enough to hold 9 RGB values (36 floats for RGBA32F format).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const shBuffer = device.createDataBuffer(9 * 4 * 4); // 9 coefficients * 4 components * 4 bytes
|
|
59
|
+
* projector.projectCubemap(environmentMap, shBuffer);
|
|
60
|
+
* ```
|
|
61
61
|
*/ projectCubemap(cubemap, outBuffer, radianceSource = true) {
|
|
62
|
+
const device = getDevice();
|
|
63
|
+
if (!this._renderTarget.get()) {
|
|
64
|
+
const texture = device.createTexture2D('rgba32f', 3, 3, {
|
|
65
|
+
mipmapping: false
|
|
66
|
+
});
|
|
67
|
+
this._renderTarget.set(device.createFrameBuffer([
|
|
68
|
+
texture
|
|
69
|
+
], null));
|
|
70
|
+
}
|
|
62
71
|
this.projectCubemapToTexture(cubemap, this._renderTarget.get(), radianceSource);
|
|
63
72
|
this._renderTarget.get().getColorAttachments()[0].readPixelsToBuffer(0, 0, 3, 3, 0, 0, outBuffer);
|
|
64
73
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Projects a cubemap texture into spherical harmonics coefficients and stores them in a 3x3 texture.
|
|
67
|
-
*
|
|
68
|
-
* The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.
|
|
69
|
-
* The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.
|
|
70
|
-
* The layout is:
|
|
71
|
-
* - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀
|
|
72
|
-
* - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁
|
|
73
|
-
* - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂
|
|
74
|
-
*
|
|
75
|
-
* @param cubemap - The input cubemap texture to project
|
|
76
|
-
* @param outFramebuffer - Framebuffer that contains the 3x3 texture to receive the computed SH coefficients in color attachment slot 0.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* const shTexture = device.createTexture2D('rgba32f', 3, 3); // 9 coefficients * 4 components * 4 bytes
|
|
81
|
-
* const shFramebuffer = device.createFrameBuffer([shTexture], null);
|
|
82
|
-
* projector.projectCubemapToTexture(environmentMap, shFramebuffer);
|
|
83
|
-
* ```
|
|
74
|
+
/**
|
|
75
|
+
* Projects a cubemap texture into spherical harmonics coefficients and stores them in a 3x3 texture.
|
|
76
|
+
*
|
|
77
|
+
* The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.
|
|
78
|
+
* The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.
|
|
79
|
+
* The layout is:
|
|
80
|
+
* - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀
|
|
81
|
+
* - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁
|
|
82
|
+
* - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂
|
|
83
|
+
*
|
|
84
|
+
* @param cubemap - The input cubemap texture to project
|
|
85
|
+
* @param outFramebuffer - Framebuffer that contains the 3x3 texture to receive the computed SH coefficients in color attachment slot 0.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const shTexture = device.createTexture2D('rgba32f', 3, 3); // 9 coefficients * 4 components * 4 bytes
|
|
90
|
+
* const shFramebuffer = device.createFrameBuffer([shTexture], null);
|
|
91
|
+
* projector.projectCubemapToTexture(environmentMap, shFramebuffer);
|
|
92
|
+
* ```
|
|
84
93
|
*/ projectCubemapToTexture(cubemap, framebuffer, radianceSource = true) {
|
|
85
94
|
const device = getDevice();
|
|
86
95
|
const clearColor = new Vector4(0, 0, 0, 1);
|
|
@@ -97,9 +106,9 @@ import { getDevice } from '../app/api.js';
|
|
|
97
106
|
this._primitive.get().drawInstanced(9);
|
|
98
107
|
device.popDeviceStates();
|
|
99
108
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Disposes of all resources allocated by this projector instance.
|
|
102
|
-
* Should be called when the projector is no longer needed to prevent memory leaks.
|
|
109
|
+
/**
|
|
110
|
+
* Disposes of all resources allocated by this projector instance.
|
|
111
|
+
* Should be called when the projector is no longer needed to prevent memory leaks.
|
|
103
112
|
*/ onDispose() {
|
|
104
113
|
super.onDispose();
|
|
105
114
|
this._primitive.dispose();
|
|
@@ -108,16 +117,16 @@ import { getDevice } from '../app/api.js';
|
|
|
108
117
|
this._renderTarget.dispose();
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Initializes the GPU resources needed for SH projection.
|
|
113
|
-
* This method is called automatically by projectCubemap() and sets up:
|
|
114
|
-
* - Sample directions primitive (Monte Carlo samples on unit sphere)
|
|
115
|
-
* - Render target (3x3 RGBA32F texture)
|
|
116
|
-
* - Render states (additive blending, no depth test)
|
|
117
|
-
* - GPU program for SH evaluation
|
|
118
|
-
*
|
|
119
|
-
* @param device - The graphics device to create resources with
|
|
120
|
-
* @internal
|
|
120
|
+
/**
|
|
121
|
+
* Initializes the GPU resources needed for SH projection.
|
|
122
|
+
* This method is called automatically by projectCubemap() and sets up:
|
|
123
|
+
* - Sample directions primitive (Monte Carlo samples on unit sphere)
|
|
124
|
+
* - Render target (3x3 RGBA32F texture)
|
|
125
|
+
* - Render states (additive blending, no depth test)
|
|
126
|
+
* - GPU program for SH evaluation
|
|
127
|
+
*
|
|
128
|
+
* @param device - The graphics device to create resources with
|
|
129
|
+
* @internal
|
|
121
130
|
*/ init(device) {
|
|
122
131
|
if (!this._primitive.get()) {
|
|
123
132
|
const samples = new Float32Array(this._numSamples * 4);
|
|
@@ -154,14 +163,6 @@ import { getDevice } from '../app/api.js';
|
|
|
154
163
|
primitive.primitiveType = 'point-list';
|
|
155
164
|
this._primitive.set(primitive);
|
|
156
165
|
}
|
|
157
|
-
if (!this._renderTarget.get()) {
|
|
158
|
-
const texture = device.createTexture2D('rgba32f', 3, 3, {
|
|
159
|
-
mipmapping: false
|
|
160
|
-
});
|
|
161
|
-
this._renderTarget.set(device.createFrameBuffer([
|
|
162
|
-
texture
|
|
163
|
-
], null));
|
|
164
|
-
}
|
|
165
166
|
if (!CubemapSHProjector._renderStats) {
|
|
166
167
|
CubemapSHProjector._renderStats = device.createRenderStateSet();
|
|
167
168
|
CubemapSHProjector._renderStats.useDepthState().enableTest(false).enableWrite(false);
|
|
@@ -173,19 +174,19 @@ import { getDevice } from '../app/api.js';
|
|
|
173
174
|
CubemapSHProjector._bindGroupInst = device.createBindGroup(CubemapSHProjector._programInst.bindGroupLayouts[0]);
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Creates the GPU program for spherical harmonics evaluation.
|
|
178
|
-
*
|
|
179
|
-
* The vertex shader uses instanced rendering to generate 9 instances (one per SH coefficient).
|
|
180
|
-
* Each instance renders all sample points, but the vertex shader maps them to different
|
|
181
|
-
* pixels in the 3x3 output texture based on the instance ID.
|
|
182
|
-
*
|
|
183
|
-
* The fragment shader evaluates the appropriate SH basis function based on the pixel location,
|
|
184
|
-
* samples the cubemap in the sample direction, and multiplies by the integration weight.
|
|
185
|
-
*
|
|
186
|
-
* @param device - The graphics device to create the program with
|
|
187
|
-
* @returns The compiled GPU program
|
|
188
|
-
* @internal
|
|
177
|
+
/**
|
|
178
|
+
* Creates the GPU program for spherical harmonics evaluation.
|
|
179
|
+
*
|
|
180
|
+
* The vertex shader uses instanced rendering to generate 9 instances (one per SH coefficient).
|
|
181
|
+
* Each instance renders all sample points, but the vertex shader maps them to different
|
|
182
|
+
* pixels in the 3x3 output texture based on the instance ID.
|
|
183
|
+
*
|
|
184
|
+
* The fragment shader evaluates the appropriate SH basis function based on the pixel location,
|
|
185
|
+
* samples the cubemap in the sample direction, and multiplies by the integration weight.
|
|
186
|
+
*
|
|
187
|
+
* @param device - The graphics device to create the program with
|
|
188
|
+
* @returns The compiled GPU program
|
|
189
|
+
* @internal
|
|
189
190
|
*/ static _createProgram(device) {
|
|
190
191
|
const program = device.buildRenderProgram({
|
|
191
192
|
vertex (pb) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shprojector.js","sources":["../../src/utility/shprojector.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BindGroup,\r\n FrameBuffer,\r\n GPUDataBuffer,\r\n GPUProgram,\r\n RenderStateSet,\r\n TextureCube\r\n} from '@zephyr3d/device';\r\nimport { Primitive } from '../render/primitive';\r\nimport type { Nullable } from '@zephyr3d/base';\r\nimport { Disposable, DRef, Vector4 } from '@zephyr3d/base';\r\nimport { fetchSampler } from './misc';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * CubemapSHProjector is responsible for projecting a cubemap texture into spherical harmonics (SH) coefficients.\r\n * This is commonly used for efficient environment lighting approximation in real-time rendering.\r\n *\r\n * The class uses Monte Carlo sampling to compute the first 9 spherical harmonics coefficients (up to order 2)\r\n * from a cubemap texture, which can then be used for ambient lighting calculations.\r\n *\r\n * @example\r\n * ```typescript\r\n * const projector = new CubemapSHProjector(10000);\r\n * const shBuffer = device.createBuffer(4 * 4 * 9, { usage: 'uniform' });\r\n * projector.projectCubemap(environmentCubemap, shBuffer);\r\n * // shBuffer now contains the 9 SH coefficients as RGB values\r\n * projector.dispose();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class CubemapSHProjector extends Disposable {\r\n private static _programInst: Nullable<GPUProgram> = null;\r\n private static _bindGroupInst: Nullable<BindGroup> = null;\r\n private static _renderStats: Nullable<RenderStateSet> = null;\r\n private readonly _primitive: DRef<Primitive>;\r\n private readonly _renderTarget: DRef<FrameBuffer>;\r\n private readonly _numSamples: number;\r\n /**\r\n * Creates a new CubemapSHProjector instance.\r\n *\r\n * @param numSamples - Number of Monte Carlo samples to use for SH projection.\r\n * Higher values provide better accuracy but slower computation.\r\n * Default is 10000.\r\n */\r\n constructor(numSamples = 10000) {\r\n super();\r\n this._numSamples = numSamples;\r\n this._primitive = new DRef();\r\n this._renderTarget = new DRef();\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a GPUBuffer.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outBuffer - GPU data buffer to receive the computed SH coefficients.\r\n * Must be large enough to hold 9 RGB values (36 floats for RGBA32F format).\r\n *\r\n * @example\r\n * ```typescript\r\n * const shBuffer = device.createDataBuffer(9 * 4 * 4); // 9 coefficients * 4 components * 4 bytes\r\n * projector.projectCubemap(environmentMap, shBuffer);\r\n * ```\r\n */\r\n projectCubemap(cubemap: TextureCube, outBuffer: GPUDataBuffer, radianceSource = true) {\r\n this.projectCubemapToTexture(cubemap, this._renderTarget.get()!, radianceSource);\r\n this._renderTarget.get()!.getColorAttachments()[0].readPixelsToBuffer(0, 0, 3, 3, 0, 0, outBuffer);\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a 3x3 texture.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outFramebuffer - Framebuffer that contains the 3x3 texture to receive the computed SH coefficients in color attachment slot 0.\r\n *\r\n * @example\r\n * ```typescript\r\n * const shTexture = device.createTexture2D('rgba32f', 3, 3); // 9 coefficients * 4 components * 4 bytes\r\n * const shFramebuffer = device.createFrameBuffer([shTexture], null);\r\n * projector.projectCubemapToTexture(environmentMap, shFramebuffer);\r\n * ```\r\n */\r\n projectCubemapToTexture(cubemap: TextureCube, framebuffer: FrameBuffer, radianceSource = true) {\r\n const device = getDevice();\r\n const clearColor = new Vector4(0, 0, 0, 1);\r\n this.init(device);\r\n device.pushDeviceStates();\r\n device.setRenderStates(CubemapSHProjector._renderStats);\r\n device.setProgram(CubemapSHProjector._programInst);\r\n device.setFramebuffer(framebuffer);\r\n device.clearFrameBuffer(clearColor, null, null);\r\n const bindGroup = CubemapSHProjector._bindGroupInst!;\r\n bindGroup.setTexture('cubemap', cubemap, fetchSampler('clamp_linear_nomip'));\r\n bindGroup.setValue('scale', radianceSource ? 1.0 : Math.PI);\r\n device.setBindGroup(0, bindGroup);\r\n this._primitive.get()!.drawInstanced(9);\r\n device.popDeviceStates();\r\n }\r\n /**\r\n * Disposes of all resources allocated by this projector instance.\r\n * Should be called when the projector is no longer needed to prevent memory leaks.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._primitive.dispose();\r\n if (this._renderTarget.get()) {\r\n this._renderTarget.get()!.getColorAttachments()[0].dispose();\r\n this._renderTarget.dispose();\r\n }\r\n }\r\n /**\r\n * Initializes the GPU resources needed for SH projection.\r\n * This method is called automatically by projectCubemap() and sets up:\r\n * - Sample directions primitive (Monte Carlo samples on unit sphere)\r\n * - Render target (3x3 RGBA32F texture)\r\n * - Render states (additive blending, no depth test)\r\n * - GPU program for SH evaluation\r\n *\r\n * @param device - The graphics device to create resources with\r\n * @internal\r\n */\r\n private init(device: AbstractDevice) {\r\n if (!this._primitive.get()) {\r\n const samples = new Float32Array(this._numSamples * 4);\r\n for (let i = 0; i < this._numSamples; i++) {\r\n let x1: number, x2: number, s: number;\r\n do {\r\n x1 = Math.random() * 2 - 1;\r\n x2 = Math.random() * 2 - 1;\r\n s = x1 * x1 + x2 * x2;\r\n } while (s >= 1);\r\n const sqrtS = Math.sqrt(1 - s);\r\n samples[i * 4 + 0] = 2 * x1 * sqrtS;\r\n samples[i * 4 + 1] = 2 * x2 * sqrtS;\r\n samples[i * 4 + 2] = 1 - 2 * s;\r\n samples[i * 4 + 3] = (4 * Math.PI) / this._numSamples;\r\n }\r\n const primitive = new Primitive();\r\n primitive.createAndSetVertexBuffer('position_f32x4', samples);\r\n if (device.type === 'webgl') {\r\n primitive.createAndSetVertexBuffer(\r\n 'tex0_f32',\r\n new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8]),\r\n 'instance'\r\n );\r\n }\r\n primitive.indexCount = this._numSamples;\r\n primitive.indexStart = 0;\r\n primitive.primitiveType = 'point-list';\r\n this._primitive.set(primitive);\r\n }\r\n\r\n if (!this._renderTarget.get()) {\r\n const texture = device.createTexture2D('rgba32f', 3, 3, {\r\n mipmapping: false\r\n })!;\r\n this._renderTarget.set(device.createFrameBuffer([texture], null));\r\n }\r\n\r\n if (!CubemapSHProjector._renderStats) {\r\n CubemapSHProjector._renderStats = device.createRenderStateSet();\r\n CubemapSHProjector._renderStats.useDepthState().enableTest(false).enableWrite(false);\r\n CubemapSHProjector._renderStats\r\n .useBlendingState()\r\n .enable(true)\r\n .setBlendEquation('add', 'add')\r\n .setBlendFuncRGB('one', 'one')\r\n .setBlendFuncAlpha('zero', 'one');\r\n CubemapSHProjector._renderStats.useRasterizerState().setCullMode('none');\r\n }\r\n\r\n if (!CubemapSHProjector._programInst) {\r\n CubemapSHProjector._programInst = CubemapSHProjector._createProgram(device)!;\r\n CubemapSHProjector._bindGroupInst = device.createBindGroup(\r\n CubemapSHProjector._programInst.bindGroupLayouts[0]\r\n );\r\n }\r\n }\r\n /**\r\n * Creates the GPU program for spherical harmonics evaluation.\r\n *\r\n * The vertex shader uses instanced rendering to generate 9 instances (one per SH coefficient).\r\n * Each instance renders all sample points, but the vertex shader maps them to different\r\n * pixels in the 3x3 output texture based on the instance ID.\r\n *\r\n * The fragment shader evaluates the appropriate SH basis function based on the pixel location,\r\n * samples the cubemap in the sample direction, and multiplies by the integration weight.\r\n *\r\n * @param device - The graphics device to create the program with\r\n * @returns The compiled GPU program\r\n * @internal\r\n */\r\n private static _createProgram(device: AbstractDevice) {\r\n const program = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.directionWeight = pb.vec4().attrib('position');\r\n if (device.type === 'webgl') {\r\n this.$inputs.instanceId = pb.float().attrib('texCoord0');\r\n }\r\n pb.main(function () {\r\n this.$outputs.direction = this.$inputs.directionWeight.xyz;\r\n this.$outputs.weight = this.$inputs.directionWeight.w;\r\n if (pb.getDevice().type !== 'webgpu') {\r\n this.$builtins.pointSize = 1;\r\n }\r\n this.$outputs.shIndex =\r\n device.type === 'webgl' ? this.$inputs.instanceId : pb.int(this.$builtins.instanceIndex);\r\n this.$l.x = pb.mod(this.$outputs.shIndex, 3);\r\n this.$l.y = pb.div(this.$outputs.shIndex, 3);\r\n this.$l.ndcX = pb.sub(pb.div(pb.add(pb.float(this.x), 0.5), 1.5), 1);\r\n this.$l.ndcY = pb.sub(pb.div(pb.add(pb.float(this.y), 0.5), 1.5), 1);\r\n this.$l.$builtins.position = pb.vec4(this.ndcX, this.ndcY, 0, 1);\r\n if (pb.getDevice().type === 'webgpu') {\r\n this.$builtins.position = pb.mul(this.$builtins.position, pb.vec4(1, -1, 1, 1));\r\n }\r\n });\r\n },\r\n fragment(pb) {\r\n this.$outputs.color = pb.vec4();\r\n this.cubemap = pb.texCube().uniform(0);\r\n this.scale = pb.float().uniform(0);\r\n pb.func('cosineLobeBandFactor', [pb.int('l')], function () {\r\n this.$if(pb.equal(this.l, 0), function () {\r\n this.$return(pb.float(1));\r\n });\r\n this.$if(pb.lessThanEqual(this.l, 3), function () {\r\n this.$return(2 / 3);\r\n });\r\n this.$return(1 / 4);\r\n });\r\n pb.func('Y0', [pb.vec3('v')], function () {\r\n this.$return(0.282094791773878);\r\n });\r\n pb.func('Y1', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, -0.4886025119));\r\n });\r\n pb.func('Y2', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.z, 0.4886025119));\r\n });\r\n pb.func('Y3', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, -0.4886025119));\r\n });\r\n pb.func('Y4', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.y, 1.0925484306));\r\n });\r\n pb.func('Y5', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y6', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.z, this.v.z, 3), 1), 0.3153915652));\r\n });\r\n pb.func('Y7', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y8', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.x, this.v.x), pb.mul(this.v.y, this.v.y)), 0.5462742153));\r\n });\r\n pb.func('evalBasis', [pb.vec3('dir'), pb.int('c')], function () {\r\n this.$if(pb.equal(this.c, 0), function () {\r\n this.$return(this.Y0(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 1), function () {\r\n this.$return(this.Y1(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 2), function () {\r\n this.$return(this.Y2(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 3), function () {\r\n this.$return(this.Y3(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 4), function () {\r\n this.$return(this.Y4(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 5), function () {\r\n this.$return(this.Y5(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 6), function () {\r\n this.$return(this.Y6(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 7), function () {\r\n this.$return(this.Y7(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 8), function () {\r\n this.$return(this.Y8(this.dir));\r\n })\r\n .$else(function () {\r\n this.$return(0);\r\n });\r\n });\r\n pb.main(function () {\r\n this.$l.radiance = pb.textureSampleLevel(this.cubemap, this.$inputs.direction, 0).rgb;\r\n this.$l.bandFactor = this.cosineLobeBandFactor(\r\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\r\n );\r\n this.$l.sh = this.evalBasis(\r\n this.$inputs.direction,\r\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\r\n );\r\n this.$outputs.color = pb.vec4(\r\n pb.mul(this.radiance, this.sh, this.$inputs.weight, this.bandFactor, this.scale),\r\n 1\r\n );\r\n });\r\n }\r\n })!;\r\n program.name = '@CubemapSHProjector_SHProject';\r\n return program;\r\n }\r\n}\r\n"],"names":["CubemapSHProjector","Disposable","_programInst","_bindGroupInst","_renderStats","_primitive","_renderTarget","_numSamples","numSamples","DRef","projectCubemap","cubemap","outBuffer","radianceSource","projectCubemapToTexture","get","getColorAttachments","readPixelsToBuffer","framebuffer","device","getDevice","clearColor","Vector4","init","pushDeviceStates","setRenderStates","setProgram","setFramebuffer","clearFrameBuffer","bindGroup","setTexture","fetchSampler","setValue","Math","PI","setBindGroup","drawInstanced","popDeviceStates","onDispose","dispose","samples","Float32Array","i","x1","x2","s","random","sqrtS","sqrt","primitive","Primitive","createAndSetVertexBuffer","type","indexCount","indexStart","primitiveType","set","texture","createTexture2D","mipmapping","createFrameBuffer","createRenderStateSet","useDepthState","enableTest","enableWrite","useBlendingState","enable","setBlendEquation","setBlendFuncRGB","setBlendFuncAlpha","useRasterizerState","setCullMode","_createProgram","createBindGroup","bindGroupLayouts","program","buildRenderProgram","vertex","pb","$inputs","directionWeight","vec4","attrib","instanceId","float","main","$outputs","direction","xyz","weight","w","$builtins","pointSize","shIndex","int","instanceIndex","$l","x","mod","y","div","ndcX","sub","add","ndcY","position","mul","fragment","color","texCube","uniform","scale","func","$if","equal","l","$return","lessThanEqual","vec3","v","z","c","Y0","dir","$elseif","Y1","Y2","Y3","Y4","Y5","Y6","Y7","Y8","$else","radiance","textureSampleLevel","rgb","bandFactor","cosineLobeBandFactor","sh","evalBasis","name"],"mappings":";;;;;AAeA;;;;;;;;;;;;;;;;;IAkBO,MAAMA,kBAA2BC,SAAAA,UAAAA,CAAAA;AACtC,IAAA,OAAeC,eAAqC,IAAK;AACzD,IAAA,OAAeC,iBAAsC,IAAK;AAC1D,IAAA,OAAeC,eAAyC,IAAK;IAC5CC,UAA4B;IAC5BC,aAAiC;IACjCC,WAAoB;AACrC;;;;;;MAOA,WAAA,CAAYC,UAAa,GAAA,KAAK,CAAE;QAC9B,KAAK,EAAA;QACL,IAAI,CAACD,WAAW,GAAGC,UAAAA;QACnB,IAAI,CAACH,UAAU,GAAG,IAAII,IAAAA,EAAA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QAAQ,EAAE,IAAI,CAACK,EAAE,EAAE,IAAI,CAAC5D,OAAO,CAACU,MAAM,EAAE,IAAI,CAACgD,UAAU,EAAE,IAAI,CAAC1B,KAAK,CAC/E,EAAA,CAAA,CAAA;AAEJ,iBAAA,CAAA;AACF;AACF,SAAA,CAAA;AACApC,QAAAA,OAAAA,CAAQkE,IAAI,GAAG,+BAAA;QACf,OAAOlE,OAAAA;AACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"shprojector.js","sources":["../../src/utility/shprojector.ts"],"sourcesContent":["import type {\n AbstractDevice,\n BindGroup,\n FrameBuffer,\n GPUDataBuffer,\n GPUProgram,\n RenderStateSet,\n TextureCube\n} from '@zephyr3d/device';\nimport { Primitive } from '../render/primitive';\nimport type { Nullable } from '@zephyr3d/base';\nimport { Disposable, DRef, Vector4 } from '@zephyr3d/base';\nimport { fetchSampler } from './misc';\nimport { getDevice } from '../app/api';\n\n/**\n * CubemapSHProjector is responsible for projecting a cubemap texture into spherical harmonics (SH) coefficients.\n * This is commonly used for efficient environment lighting approximation in real-time rendering.\n *\n * The class uses Monte Carlo sampling to compute the first 9 spherical harmonics coefficients (up to order 2)\n * from a cubemap texture, which can then be used for ambient lighting calculations.\n *\n * @example\n * ```typescript\n * const projector = new CubemapSHProjector(10000);\n * const shBuffer = device.createBuffer(4 * 4 * 9, { usage: 'uniform' });\n * projector.projectCubemap(environmentCubemap, shBuffer);\n * // shBuffer now contains the 9 SH coefficients as RGB values\n * projector.dispose();\n * ```\n *\n * @public\n */\nexport class CubemapSHProjector extends Disposable {\n private static _programInst: Nullable<GPUProgram> = null;\n private static _bindGroupInst: Nullable<BindGroup> = null;\n private static _renderStats: Nullable<RenderStateSet> = null;\n private readonly _primitive: DRef<Primitive>;\n private readonly _renderTarget: DRef<FrameBuffer>;\n private readonly _numSamples: number;\n /**\n * Creates a new CubemapSHProjector instance.\n *\n * @param numSamples - Number of Monte Carlo samples to use for SH projection.\n * Higher values provide better accuracy but slower computation.\n * Default is 10000.\n */\n constructor(numSamples = 10000) {\n super();\n this._numSamples = numSamples;\n this._primitive = new DRef();\n this._renderTarget = new DRef();\n }\n /**\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a GPUBuffer.\n *\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\n * The layout is:\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\n *\n * @param cubemap - The input cubemap texture to project\n * @param outBuffer - GPU data buffer to receive the computed SH coefficients.\n * Must be large enough to hold 9 RGB values (36 floats for RGBA32F format).\n *\n * @example\n * ```typescript\n * const shBuffer = device.createDataBuffer(9 * 4 * 4); // 9 coefficients * 4 components * 4 bytes\n * projector.projectCubemap(environmentMap, shBuffer);\n * ```\n */\n projectCubemap(cubemap: TextureCube, outBuffer: GPUDataBuffer, radianceSource = true) {\n const device = getDevice();\n if (!this._renderTarget.get()) {\n const texture = device.createTexture2D('rgba32f', 3, 3, {\n mipmapping: false\n })!;\n this._renderTarget.set(device.createFrameBuffer([texture], null));\n }\n this.projectCubemapToTexture(cubemap, this._renderTarget.get()!, radianceSource);\n this._renderTarget.get()!.getColorAttachments()[0].readPixelsToBuffer(0, 0, 3, 3, 0, 0, outBuffer);\n }\n /**\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a 3x3 texture.\n *\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\n * The layout is:\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\n *\n * @param cubemap - The input cubemap texture to project\n * @param outFramebuffer - Framebuffer that contains the 3x3 texture to receive the computed SH coefficients in color attachment slot 0.\n *\n * @example\n * ```typescript\n * const shTexture = device.createTexture2D('rgba32f', 3, 3); // 9 coefficients * 4 components * 4 bytes\n * const shFramebuffer = device.createFrameBuffer([shTexture], null);\n * projector.projectCubemapToTexture(environmentMap, shFramebuffer);\n * ```\n */\n projectCubemapToTexture(cubemap: TextureCube, framebuffer: FrameBuffer, radianceSource = true) {\n const device = getDevice();\n const clearColor = new Vector4(0, 0, 0, 1);\n this.init(device);\n device.pushDeviceStates();\n device.setRenderStates(CubemapSHProjector._renderStats);\n device.setProgram(CubemapSHProjector._programInst);\n device.setFramebuffer(framebuffer);\n device.clearFrameBuffer(clearColor, null, null);\n const bindGroup = CubemapSHProjector._bindGroupInst!;\n bindGroup.setTexture('cubemap', cubemap, fetchSampler('clamp_linear_nomip'));\n bindGroup.setValue('scale', radianceSource ? 1.0 : Math.PI);\n device.setBindGroup(0, bindGroup);\n this._primitive.get()!.drawInstanced(9);\n device.popDeviceStates();\n }\n /**\n * Disposes of all resources allocated by this projector instance.\n * Should be called when the projector is no longer needed to prevent memory leaks.\n */\n protected onDispose() {\n super.onDispose();\n this._primitive.dispose();\n if (this._renderTarget.get()) {\n this._renderTarget.get()!.getColorAttachments()[0].dispose();\n this._renderTarget.dispose();\n }\n }\n /**\n * Initializes the GPU resources needed for SH projection.\n * This method is called automatically by projectCubemap() and sets up:\n * - Sample directions primitive (Monte Carlo samples on unit sphere)\n * - Render target (3x3 RGBA32F texture)\n * - Render states (additive blending, no depth test)\n * - GPU program for SH evaluation\n *\n * @param device - The graphics device to create resources with\n * @internal\n */\n private init(device: AbstractDevice) {\n if (!this._primitive.get()) {\n const samples = new Float32Array(this._numSamples * 4);\n for (let i = 0; i < this._numSamples; i++) {\n let x1: number, x2: number, s: number;\n do {\n x1 = Math.random() * 2 - 1;\n x2 = Math.random() * 2 - 1;\n s = x1 * x1 + x2 * x2;\n } while (s >= 1);\n const sqrtS = Math.sqrt(1 - s);\n samples[i * 4 + 0] = 2 * x1 * sqrtS;\n samples[i * 4 + 1] = 2 * x2 * sqrtS;\n samples[i * 4 + 2] = 1 - 2 * s;\n samples[i * 4 + 3] = (4 * Math.PI) / this._numSamples;\n }\n const primitive = new Primitive();\n primitive.createAndSetVertexBuffer('position_f32x4', samples);\n if (device.type === 'webgl') {\n primitive.createAndSetVertexBuffer(\n 'tex0_f32',\n new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8]),\n 'instance'\n );\n }\n primitive.indexCount = this._numSamples;\n primitive.indexStart = 0;\n primitive.primitiveType = 'point-list';\n this._primitive.set(primitive);\n }\n\n if (!CubemapSHProjector._renderStats) {\n CubemapSHProjector._renderStats = device.createRenderStateSet();\n CubemapSHProjector._renderStats.useDepthState().enableTest(false).enableWrite(false);\n CubemapSHProjector._renderStats\n .useBlendingState()\n .enable(true)\n .setBlendEquation('add', 'add')\n .setBlendFuncRGB('one', 'one')\n .setBlendFuncAlpha('zero', 'one');\n CubemapSHProjector._renderStats.useRasterizerState().setCullMode('none');\n }\n\n if (!CubemapSHProjector._programInst) {\n CubemapSHProjector._programInst = CubemapSHProjector._createProgram(device)!;\n CubemapSHProjector._bindGroupInst = device.createBindGroup(\n CubemapSHProjector._programInst.bindGroupLayouts[0]\n );\n }\n }\n /**\n * Creates the GPU program for spherical harmonics evaluation.\n *\n * The vertex shader uses instanced rendering to generate 9 instances (one per SH coefficient).\n * Each instance renders all sample points, but the vertex shader maps them to different\n * pixels in the 3x3 output texture based on the instance ID.\n *\n * The fragment shader evaluates the appropriate SH basis function based on the pixel location,\n * samples the cubemap in the sample direction, and multiplies by the integration weight.\n *\n * @param device - The graphics device to create the program with\n * @returns The compiled GPU program\n * @internal\n */\n private static _createProgram(device: AbstractDevice) {\n const program = device.buildRenderProgram({\n vertex(pb) {\n this.$inputs.directionWeight = pb.vec4().attrib('position');\n if (device.type === 'webgl') {\n this.$inputs.instanceId = pb.float().attrib('texCoord0');\n }\n pb.main(function () {\n this.$outputs.direction = this.$inputs.directionWeight.xyz;\n this.$outputs.weight = this.$inputs.directionWeight.w;\n if (pb.getDevice().type !== 'webgpu') {\n this.$builtins.pointSize = 1;\n }\n this.$outputs.shIndex =\n device.type === 'webgl' ? this.$inputs.instanceId : pb.int(this.$builtins.instanceIndex);\n this.$l.x = pb.mod(this.$outputs.shIndex, 3);\n this.$l.y = pb.div(this.$outputs.shIndex, 3);\n this.$l.ndcX = pb.sub(pb.div(pb.add(pb.float(this.x), 0.5), 1.5), 1);\n this.$l.ndcY = pb.sub(pb.div(pb.add(pb.float(this.y), 0.5), 1.5), 1);\n this.$l.$builtins.position = pb.vec4(this.ndcX, this.ndcY, 0, 1);\n if (pb.getDevice().type === 'webgpu') {\n this.$builtins.position = pb.mul(this.$builtins.position, pb.vec4(1, -1, 1, 1));\n }\n });\n },\n fragment(pb) {\n this.$outputs.color = pb.vec4();\n this.cubemap = pb.texCube().uniform(0);\n this.scale = pb.float().uniform(0);\n pb.func('cosineLobeBandFactor', [pb.int('l')], function () {\n this.$if(pb.equal(this.l, 0), function () {\n this.$return(pb.float(1));\n });\n this.$if(pb.lessThanEqual(this.l, 3), function () {\n this.$return(2 / 3);\n });\n this.$return(1 / 4);\n });\n pb.func('Y0', [pb.vec3('v')], function () {\n this.$return(0.282094791773878);\n });\n pb.func('Y1', [pb.vec3('v')], function () {\n this.$return(pb.mul(this.v.y, -0.4886025119));\n });\n pb.func('Y2', [pb.vec3('v')], function () {\n this.$return(pb.mul(this.v.z, 0.4886025119));\n });\n pb.func('Y3', [pb.vec3('v')], function () {\n this.$return(pb.mul(this.v.x, -0.4886025119));\n });\n pb.func('Y4', [pb.vec3('v')], function () {\n this.$return(pb.mul(this.v.x, this.v.y, 1.0925484306));\n });\n pb.func('Y5', [pb.vec3('v')], function () {\n this.$return(pb.mul(this.v.y, this.v.z, -1.0925484306));\n });\n pb.func('Y6', [pb.vec3('v')], function () {\n this.$return(pb.mul(pb.sub(pb.mul(this.v.z, this.v.z, 3), 1), 0.3153915652));\n });\n pb.func('Y7', [pb.vec3('v')], function () {\n this.$return(pb.mul(this.v.x, this.v.z, -1.0925484306));\n });\n pb.func('Y8', [pb.vec3('v')], function () {\n this.$return(pb.mul(pb.sub(pb.mul(this.v.x, this.v.x), pb.mul(this.v.y, this.v.y)), 0.5462742153));\n });\n pb.func('evalBasis', [pb.vec3('dir'), pb.int('c')], function () {\n this.$if(pb.equal(this.c, 0), function () {\n this.$return(this.Y0(this.dir));\n })\n .$elseif(pb.equal(this.c, 1), function () {\n this.$return(this.Y1(this.dir));\n })\n .$elseif(pb.equal(this.c, 2), function () {\n this.$return(this.Y2(this.dir));\n })\n .$elseif(pb.equal(this.c, 3), function () {\n this.$return(this.Y3(this.dir));\n })\n .$elseif(pb.equal(this.c, 4), function () {\n this.$return(this.Y4(this.dir));\n })\n .$elseif(pb.equal(this.c, 5), function () {\n this.$return(this.Y5(this.dir));\n })\n .$elseif(pb.equal(this.c, 6), function () {\n this.$return(this.Y6(this.dir));\n })\n .$elseif(pb.equal(this.c, 7), function () {\n this.$return(this.Y7(this.dir));\n })\n .$elseif(pb.equal(this.c, 8), function () {\n this.$return(this.Y8(this.dir));\n })\n .$else(function () {\n this.$return(0);\n });\n });\n pb.main(function () {\n this.$l.radiance = pb.textureSampleLevel(this.cubemap, this.$inputs.direction, 0).rgb;\n this.$l.bandFactor = this.cosineLobeBandFactor(\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\n );\n this.$l.sh = this.evalBasis(\n this.$inputs.direction,\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\n );\n this.$outputs.color = pb.vec4(\n pb.mul(this.radiance, this.sh, this.$inputs.weight, this.bandFactor, this.scale),\n 1\n );\n });\n }\n })!;\n program.name = '@CubemapSHProjector_SHProject';\n return program;\n }\n}\n"],"names":["CubemapSHProjector","Disposable","_programInst","_bindGroupInst","_renderStats","_primitive","_renderTarget","_numSamples","numSamples","DRef","projectCubemap","cubemap","outBuffer","radianceSource","device","getDevice","get","texture","createTexture2D","mipmapping","set","createFrameBuffer","projectCubemapToTexture","getColorAttachments","readPixelsToBuffer","framebuffer","clearColor","Vector4","init","pushDeviceStates","setRenderStates","setProgram","setFramebuffer","clearFrameBuffer","bindGroup","setTexture","fetchSampler","setValue","Math","PI","setBindGroup","drawInstanced","popDeviceStates","onDispose","dispose","samples","Float32Array","i","x1","x2","s","random","sqrtS","sqrt","primitive","Primitive","createAndSetVertexBuffer","type","indexCount","indexStart","primitiveType","createRenderStateSet","useDepthState","enableTest","enableWrite","useBlendingState","enable","setBlendEquation","setBlendFuncRGB","setBlendFuncAlpha","useRasterizerState","setCullMode","_createProgram","createBindGroup","bindGroupLayouts","program","buildRenderProgram","vertex","pb","$inputs","directionWeight","vec4","attrib","instanceId","float","main","$outputs","direction","xyz","weight","w","$builtins","pointSize","shIndex","int","instanceIndex","$l","x","mod","y","div","ndcX","sub","add","ndcY","position","mul","fragment","color","texCube","uniform","scale","func","$if","equal","l","$return","lessThanEqual","vec3","v","z","c","Y0","dir","$elseif","Y1","Y2","Y3","Y4","Y5","Y6","Y7","Y8","$else","radiance","textureSampleLevel","rgb","bandFactor","cosineLobeBandFactor","sh","evalBasis","name"],"mappings":";;;;;AAeA;;;;;;;;;;;;;;;;;IAkBO,MAAMA,kBAA2BC,SAAAA,UAAAA,CAAAA;AACtC,IAAA,OAAeC,eAAqC,IAAK;AACzD,IAAA,OAAeC,iBAAsC,IAAK;AAC1D,IAAA,OAAeC,eAAyC,IAAK;IAC5CC,UAA4B;IAC5BC,aAAiC;IACjCC,WAAoB;AACrC;;;;;;MAOA,WAAA,CAAYC,UAAa,GAAA,KAAK,CAAE;QAC9B,KAAK,EAAA;QACL,IAAI,CAACD,WAAW,GAAGC,UAAAA;QACnB,IAAI,CAACH,UAAU,GAAG,IAAII,IAAAA,EAAAA;QACtB,IAAI,CAACH,aAAa,GAAG,IAAIG,IAAAA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