@zephyr3d/scene 0.7.0 → 0.8.0
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/animation.js +4 -33
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +24 -11
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +1 -0
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +0 -1
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/ik/ccd_solver.js +372 -0
- package/dist/animation/ik/ccd_solver.js.map +1 -0
- package/dist/animation/ik/fabrik_solver.js +399 -0
- package/dist/animation/ik/fabrik_solver.js.map +1 -0
- package/dist/animation/ik/ik_angle_constraint.js +181 -0
- package/dist/animation/ik/ik_angle_constraint.js.map +1 -0
- package/dist/animation/ik/ik_chain.js +163 -0
- package/dist/animation/ik/ik_chain.js.map +1 -0
- package/dist/animation/ik/ik_chain_builder.js +68 -0
- package/dist/animation/ik/ik_chain_builder.js.map +1 -0
- package/dist/animation/ik/ik_constraint.js +25 -0
- package/dist/animation/ik/ik_constraint.js.map +1 -0
- package/dist/animation/ik/ik_pole_constraint.js +123 -0
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -0
- package/dist/animation/ik/ik_solver.js +48 -0
- package/dist/animation/ik/ik_solver.js.map +1 -0
- package/dist/animation/ik/ik_track.js +96 -0
- package/dist/animation/ik/ik_track.js.map +1 -0
- package/dist/animation/ik/ik_utils.js +270 -0
- package/dist/animation/ik/ik_utils.js.map +1 -0
- package/dist/animation/ik/two_bone_ik_solver.js +332 -0
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -0
- package/dist/animation/ik_modifier.js +61 -0
- package/dist/animation/ik_modifier.js.map +1 -0
- package/dist/animation/ik_postprocessor.js +71 -0
- package/dist/animation/ik_postprocessor.js.map +1 -0
- package/dist/animation/manual_transform_processor.js +156 -0
- package/dist/animation/manual_transform_processor.js.map +1 -0
- package/dist/animation/morphtarget.js +7 -1
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -3
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/proptrack.js +37 -41
- package/dist/animation/proptrack.js.map +1 -1
- package/dist/animation/rotationtrack.js +0 -1
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +0 -1
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +57 -60
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +38 -0
- package/dist/animation/skeleton_modifier.js.map +1 -0
- package/dist/animation/skeleton_postprocessor.js +50 -0
- package/dist/animation/skeleton_postprocessor.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +503 -0
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -0
- package/dist/animation/spring/spring_chain.js +103 -0
- package/dist/animation/spring/spring_chain.js.map +1 -0
- package/dist/animation/spring/spring_collider.js +247 -0
- package/dist/animation/spring/spring_collider.js.map +1 -0
- package/dist/animation/spring/spring_constraint.js +21 -0
- package/dist/animation/spring/spring_constraint.js.map +1 -0
- package/dist/animation/spring/spring_particle.js +20 -0
- package/dist/animation/spring/spring_particle.js.map +1 -0
- package/dist/animation/spring/spring_system.js +526 -0
- package/dist/animation/spring/spring_system.js.map +1 -0
- package/dist/animation/spring_modifier.js +45 -0
- package/dist/animation/spring_modifier.js.map +1 -0
- package/dist/animation/spring_postprocessor.js +54 -0
- package/dist/animation/spring_postprocessor.js.map +1 -0
- package/dist/animation/translationtrack.js +0 -1
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/api.js +13 -4
- package/dist/app/api.js.map +1 -1
- package/dist/app/app.js +13 -1
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +33 -45
- package/dist/app/engine.js.map +1 -1
- package/dist/app/inputmgr.js.map +1 -1
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/screen.js +318 -0
- package/dist/app/screen.js.map +1 -0
- package/dist/app/scriptingsystem.js +10 -6
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +11 -22
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +79 -58
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/builtin.js +5 -5
- package/dist/asset/builtin.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +6 -2
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +1 -1
- package/dist/asset/loaders/dds/dds_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +14 -6
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/helpers.js +6 -2
- package/dist/asset/loaders/gltf/helpers.js.map +1 -1
- package/dist/asset/loaders/hdr/hdr.js +22 -15
- package/dist/asset/loaders/hdr/hdr.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +2 -1
- package/dist/asset/loaders/image/tga_Loader.js.map +1 -1
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
- package/dist/asset/loaders/loader.js +2 -2
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/model.js +9 -5
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/blitter.js +9 -11
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/box.js +0 -1
- package/dist/blitter/box.js.map +1 -1
- package/dist/blitter/copy.js.map +1 -1
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +1 -3
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +121 -37
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/fps.js +19 -17
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +45 -43
- package/dist/camera/orbit.js.map +1 -1
- package/dist/camera/orthocamera.js +27 -21
- package/dist/camera/orthocamera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +28 -19
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +15802 -15577
- package/dist/index.js +33 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/grassmaterial.js.map +1 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +11 -5
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +10 -9
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/foliage.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +66 -4
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +7 -0
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +3 -3
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/brdf.js.map +1 -1
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +3 -0
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/particle.js.map +1 -1
- package/dist/material/pbrblueprint.js +180 -22
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +41 -56
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite.js +301 -0
- package/dist/material/sprite.js.map +1 -0
- package/dist/material/sprite3d.js +301 -0
- package/dist/material/sprite3d.js.map +1 -0
- package/dist/material/sprite3d_std.js +116 -0
- package/dist/material/sprite3d_std.js.map +1 -0
- package/dist/material/sprite3dblueprint.js +235 -0
- package/dist/material/sprite3dblueprint.js.map +1 -0
- package/dist/material/sprite_std.js +116 -0
- package/dist/material/sprite_std.js.map +1 -0
- package/dist/material/spriteblueprint.js +235 -0
- package/dist/material/spriteblueprint.js.map +1 -0
- package/dist/material/terrain-cm.js +0 -1
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/ssr.js +7 -5
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +8 -6
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +0 -10
- package/dist/render/clipmap.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 +15 -17
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +3 -4
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable.js +15 -0
- package/dist/render/drawable.js.map +1 -0
- package/dist/render/drawable_mixin.js +8 -4
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +3 -1
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +67 -64
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/fullscreenquad.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +3 -1
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +3 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +1 -2
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +13 -13
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +4 -7
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/primitive.js +4 -5
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/render_queue.js +10 -5
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +16 -22
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +27 -52
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/rendertarget.js +5 -0
- package/dist/render/rendertarget.js.map +1 -0
- package/dist/render/screenrendertarget.js +56 -0
- package/dist/render/screenrendertarget.js.map +1 -0
- package/dist/render/shadowmap_pass.js +4 -5
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +16 -14
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +296 -0
- package/dist/scene/basesprite.js.map +1 -0
- package/dist/scene/batchgroup.js +4 -2
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +9 -10
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +22 -4
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +96 -26
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/octree.js.map +1 -1
- package/dist/scene/particlesys.js +25 -22
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/raycast_visitor.js +0 -16
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +7 -4
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +20 -35
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sprite.js +18 -0
- package/dist/scene/sprite.js.map +1 -0
- package/dist/scene/sprite3d.js +18 -0
- package/dist/scene/sprite3d.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +5 -4
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +3 -1
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +65 -48
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/water.js +35 -30
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/atmosphere.js +17 -29
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/fog.js.map +1 -1
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/pbr.js.map +1 -1
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/esm.js +1 -1
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +3 -1
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadowmapper.js +6 -18
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/box.js +9 -3
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/cylinder.js +2 -2
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +2 -2
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/shape.js +2 -1
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +2 -2
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/shapes/tetrahedron.js +5 -6
- package/dist/shapes/tetrahedron.js.map +1 -1
- package/dist/shapes/torus.js +2 -2
- package/dist/shapes/torus.js.map +1 -1
- package/dist/utility/aabbtree.js +1 -1
- package/dist/utility/aabbtree.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +578 -104
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/common/math.js +471 -9
- package/dist/utility/blueprint/common/math.js.map +1 -1
- package/dist/utility/blueprint/common.js +1 -1
- package/dist/utility/blueprint/common.js.map +1 -1
- package/dist/utility/blueprint/material/func.js +9 -5
- package/dist/utility/blueprint/material/func.js.map +1 -1
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +288 -80
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +92 -4
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +62 -45
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/blueprint/node.js +28 -1
- package/dist/utility/blueprint/node.js.map +1 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/debug.js.map +1 -1
- package/dist/utility/draco/decoder.js.map +1 -1
- package/dist/utility/misc.js +1 -1
- package/dist/utility/misc.js.map +1 -1
- package/dist/utility/panorama.js.map +1 -1
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/rendermipmap.js.map +1 -1
- package/dist/utility/serialization/json.js +19 -15
- package/dist/utility/serialization/json.js.map +1 -1
- package/dist/utility/serialization/manager.js +89 -22
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +44 -41
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -3
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +97 -9
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +102 -28
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +14 -12
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +216 -26
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +71 -100
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/misc.js +3 -2
- package/dist/utility/serialization/scene/misc.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +42 -9
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +7 -5
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +18 -15
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +3 -2
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +164 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -0
- package/dist/utility/serialization/scene/terrain.js +8 -6
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +11 -9
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +6 -0
- package/dist/utility/serialization/types.js.map +1 -0
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/gradientnoise.js.map +1 -1
- package/dist/utility/textures/randomnoise.js.map +1 -1
- package/dist/values.js +14 -14
- package/dist/values.js.map +1 -1
- package/package.json +80 -80
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture.js","sources":["../../../../src/utility/blueprint/material/texture.ts"],"sourcesContent":["import { BaseGraphNode } from '../node';\r\nimport { getParamName } from '../common';\r\nimport type {\r\n Texture2D,\r\n Texture2DArray,\r\n TextureAddressMode,\r\n TextureCube,\r\n TextureFilterMode\r\n} from '@zephyr3d/device';\r\nimport { DRef } from '@zephyr3d/base';\r\nimport { getDevice } from '../../../app/api';\r\nimport type { PropertyAccessor, SerializableClass } from '../../serialization';\r\n\r\n/**\r\n * Default 1x1 white 2D texture reference\r\n * @internal\r\n */\r\nconst defaultTexture2D: DRef<Texture2D> = new DRef();\r\n\r\n/**\r\n * Default 1x1 white cubemap texture reference\r\n * @internal\r\n */\r\nconst defaultTextureCube: DRef<TextureCube> = new DRef();\r\n\r\n/**\r\n * Default 1x1 white 2D array texture reference\r\n * @internal\r\n */\r\nconst defaultTexture2DArray: DRef<Texture2DArray> = new DRef();\r\n\r\n/**\r\n * Gets or creates the default 2D texture\r\n *\r\n * @remarks\r\n * Returns a 1x1 white (255, 255, 255, 255) texture used as a fallback\r\n * when no texture is assigned to a texture node.\r\n *\r\n * @returns A 1x1 white Texture2D instance\r\n *\r\n * @internal\r\n */\r\nexport function getDefaultTexture2D(): Texture2D {\r\n if (!defaultTexture2D.get()) {\r\n const defaultTex = getDevice().createTexture2D('rgba8unorm', 1, 1, {\r\n mipmapping: false\r\n });\r\n defaultTex.update(new Uint8Array([255, 255, 255, 255]), 0, 0, 1, 1);\r\n defaultTexture2D.set(defaultTex);\r\n }\r\n return defaultTexture2D.get();\r\n}\r\n\r\n/**\r\n * Gets or creates the default 2D array texture\r\n *\r\n * @remarks\r\n * Returns a 1x1x1 white (255, 255, 255, 255) array texture used as a fallback\r\n * when no texture is assigned to a 2D array texture node.\r\n *\r\n * @returns A 1x1x1 white Texture2DArray instance\r\n *\r\n * @internal\r\n */\r\nexport function getDefaultTexture2DArray(): Texture2DArray {\r\n if (!defaultTexture2DArray.get()) {\r\n const defaultTex = getDevice().createTexture2DArray('rgba8unorm', 1, 1, 1, {\r\n mipmapping: false\r\n });\r\n defaultTex.update(new Uint8Array([255, 255, 255, 255]), 0, 0, 0, 1, 1, 1);\r\n defaultTexture2DArray.set(defaultTex);\r\n }\r\n return defaultTexture2DArray.get();\r\n}\r\n\r\n/**\r\n * Gets or creates the default cubemap texture\r\n *\r\n * @remarks\r\n * Returns a 1x1 white (255, 255, 255, 255) cubemap texture (all 6 faces white)\r\n * used as a fallback when no texture is assigned to a cubemap texture node.\r\n *\r\n * @returns A 1x1 white TextureCube instance\r\n *\r\n * @internal\r\n */\r\nexport function getDefaultTextureCube(): TextureCube {\r\n if (!defaultTextureCube.get()) {\r\n const defaultTex = getDevice().createCubeTexture('rgba8unorm', 1, {\r\n mipmapping: false\r\n });\r\n for (let i = 0; i < 6; i++) {\r\n defaultTex.update(new Uint8Array([255, 255, 255, 255]), 0, 0, 1, 1, i);\r\n }\r\n defaultTextureCube.set(defaultTex);\r\n }\r\n return defaultTextureCube.get();\r\n}\r\n\r\n/**\r\n * Common property descriptors for texture nodes\r\n *\r\n * @remarks\r\n * Defines serialization properties shared by all texture node types:\r\n * - Name: Shader parameter name for the texture uniform\r\n * - sRGB: Whether texture should be loaded into sRGB color space\r\n * - AddressU: Horizontal texture wrapping mode\r\n * - AddressV: Vertical texture wrapping mode\r\n * - MinFilter: Minification filter mode\r\n * - MagFilter: Magnification filter mode\r\n * - MipFilter: Mipmap filter mode\r\n *\r\n * @internal\r\n */\r\nconst textureNodeProps = (function getTextureNodeProps(): PropertyAccessor<BaseTextureNode>[] {\r\n return [\r\n {\r\n name: 'Name',\r\n type: 'string',\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.paramName;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.paramName = value.str[0];\r\n }\r\n },\r\n {\r\n name: 'sRGB',\r\n type: 'bool',\r\n default: true,\r\n get(this: BaseTextureNode, value) {\r\n value.bool[0] = this.sRGB;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.sRGB = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'AddressU',\r\n type: 'string',\r\n default: 'clamp',\r\n options: {\r\n enum: {\r\n labels: ['clamp', 'repeat', 'mirrored-repeat'],\r\n values: ['clamp', 'repeat', 'mirrored-repeat']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.addressU;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.addressU = value.str[0] as TextureAddressMode;\r\n }\r\n },\r\n {\r\n name: 'AddressV',\r\n type: 'string',\r\n default: 'clamp',\r\n options: {\r\n enum: {\r\n labels: ['clamp', 'repeat', 'mirrored-repeat'],\r\n values: ['clamp', 'repeat', 'mirrored-repeat']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.addressV;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.addressV = value.str[0] as TextureAddressMode;\r\n }\r\n },\r\n {\r\n name: 'MinFilter',\r\n type: 'string',\r\n default: 'linear',\r\n options: {\r\n enum: {\r\n labels: ['nearest', 'linear'],\r\n values: ['nearest', 'linear']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.filterMin;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.filterMin = value.str[0] as TextureFilterMode;\r\n }\r\n },\r\n {\r\n name: 'MagFilter',\r\n type: 'string',\r\n default: 'linear',\r\n options: {\r\n enum: {\r\n labels: ['nearest', 'linear'],\r\n values: ['nearest', 'linear']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.filterMag;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.filterMag = value.str[0] as TextureFilterMode;\r\n }\r\n },\r\n {\r\n name: 'MipFilter',\r\n type: 'string',\r\n default: 'nearest',\r\n options: {\r\n enum: {\r\n labels: ['nearest', 'linear', 'none'],\r\n values: ['nearest', 'linear', 'none']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.filterMip;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.filterMip = value.str[0] as TextureFilterMode;\r\n }\r\n }\r\n ];\r\n})();\r\n\r\n/**\r\n * Abstract base class for texture nodes\r\n *\r\n * @remarks\r\n * Provides common functionality for all texture types in the material node graph.\r\n * Texture nodes represent shader texture uniforms and their sampling parameters.\r\n *\r\n * Common properties:\r\n * - **paramName**: The shader uniform name for this texture\r\n * - **addressU/V**: Texture coordinate wrapping modes (clamp, repeat, mirrored-repeat)\r\n * - **filterMin**: Minification filter (nearest, linear)\r\n * - **filterMag**: Magnification filter (nearest, linear)\r\n * - **filterMip**: Mipmap filter (nearest, linear, none)\r\n * - **texture**: Reference to the actual GPU texture resource\r\n * - **textureId**: Asset ID for serialization/loading\r\n *\r\n * Texture addressing modes:\r\n * - **clamp**: Coordinates outside [0,1] are clamped to edge colors\r\n * - **repeat**: Texture tiles infinitely (wraps around)\r\n * - **mirrored-repeat**: Texture tiles with alternating mirroring\r\n *\r\n * Filtering modes:\r\n * - **nearest**: Point sampling (sharp, pixelated)\r\n * - **linear**: Bilinear interpolation (smooth)\r\n * - **none**: No mipmap filtering (mip filter only)\r\n *\r\n * @typeParam T - The specific texture type (Texture2D, TextureCube, etc.)\r\n *\r\n * @public\r\n */\r\nexport abstract class BaseTextureNode extends BaseGraphNode {\r\n /** The shader parameter name for this texture uniform */\r\n private _paramName: string;\r\n /** Whether this texture should be loaded in sRGB color space */\r\n sRGB: boolean;\r\n /** Horizontal texture coordinate wrapping mode */\r\n addressU: TextureAddressMode;\r\n /** Vertical texture coordinate wrapping mode */\r\n addressV: TextureAddressMode;\r\n /** Minification filter mode */\r\n filterMin: TextureFilterMode;\r\n /** Magnification filter mode */\r\n filterMag: TextureFilterMode;\r\n /** Mipmap filter mode */\r\n filterMip: TextureFilterMode;\r\n /** Asset ID for the texture (for serialization) */\r\n textureId: string;\r\n /**\r\n * Creates a new texture node\r\n *\r\n * @remarks\r\n * Initializes with default sampling parameters:\r\n * - Auto-generated unique parameter name\r\n * - Clamp addressing mode\r\n * - Nearest filtering (point sampling)\r\n * - No mipmap filtering\r\n * - Empty texture ID\r\n */\r\n constructor() {\r\n super();\r\n this._paramName = getParamName();\r\n this.sRGB = true;\r\n this.addressU = 'clamp';\r\n this.addressV = 'clamp';\r\n this.filterMin = 'linear';\r\n this.filterMag = 'linear';\r\n this.filterMip = 'nearest';\r\n this.textureId = '';\r\n }\r\n /**\r\n * Gets the shader parameter name\r\n *\r\n * @returns The uniform name used in generated shader code\r\n */\r\n get paramName() {\r\n return this._paramName;\r\n }\r\n set paramName(val: string) {\r\n if (val !== this._paramName) {\r\n this._paramName = val;\r\n this.dispatchEvent('changed');\r\n }\r\n }\r\n /**\r\n * Indicates this node represents a shader uniform\r\n *\r\n * @returns Always true for texture nodes\r\n *\r\n * @remarks\r\n * Texture nodes create uniform declarations in the generated shader code.\r\n */\r\n get isUniform() {\r\n return true;\r\n }\r\n /**\r\n * Generates a string representation of this node\r\n *\r\n * @returns The parameter name\r\n */\r\n toString() {\r\n return this._paramName;\r\n }\r\n /**\r\n * Validates the node state\r\n *\r\n * @returns Empty string (always valid)\r\n *\r\n * @remarks\r\n * Texture nodes are always valid as they have no required inputs\r\n * and always have a valid texture (default if none assigned).\r\n */\r\n protected validate(): string {\r\n return '';\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns Empty string (overridden by subclasses)\r\n *\r\n * @remarks\r\n * Subclasses return texture type identifiers like 'tex2D', 'texCube', etc.\r\n */\r\n protected getType(): string {\r\n return '';\r\n }\r\n}\r\n\r\n/**\r\n * 2D texture constant node\r\n *\r\n * @remarks\r\n * Represents a 2D texture resource in the material node graph.\r\n * This is the most common texture type, used for:\r\n * - Albedo/diffuse maps\r\n * - Normal maps\r\n * - Roughness/metallic maps\r\n * - Emissive maps\r\n * - Any 2D image-based data\r\n *\r\n * The texture can be loaded from various image formats:\r\n * - JPEG (.jpg, .jpeg)\r\n * - PNG (.png)\r\n * - TGA (.tga)\r\n * - HDR/Radiance (.hdr)\r\n * - DDS (.dds)\r\n * - WebP (.webp)\r\n *\r\n * Output:\r\n * - Output 1: Texture sampler (tex2D type)\r\n *\r\n * @example\r\n * ```typescript\r\n * const albedoTex = new ConstantTexture2DNode();\r\n * albedoTex.paramName = 'albedoMap';\r\n * albedoTex.addressU = 'repeat';\r\n * albedoTex.addressV = 'repeat';\r\n * albedoTex.filterMin = 'linear';\r\n * albedoTex.filterMag = 'linear';\r\n *\r\n * // Sample the texture\r\n * const uv = new VertexUVNode();\r\n * const sample = new TextureSampleNode();\r\n * sample.connectInput(1, albedoTex, 1);\r\n * sample.connectInput(2, uv, 1);\r\n *\r\n * // Use in material\r\n * output.connectInput(1, sample, 1); // BaseColor\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ConstantTexture2DNode extends BaseTextureNode {\r\n /**\r\n * Creates a new 2D texture node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - One output slot for the texture sampler\r\n * - Default 1x1 white texture\r\n */\r\n constructor() {\r\n super();\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @param manager - The serialization manager for loading textures\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Includes:\r\n * - Texture asset loading with MIME type validation\r\n * - All common texture parameters (addressing, filtering)\r\n * - Error handling for invalid or missing textures\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: ConstantTexture2DNode,\r\n name: 'Texture2DNode',\r\n noTitle: true,\r\n getProps() {\r\n return [\r\n {\r\n name: 'Texture',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n mimeTypes: [\r\n 'image/jpeg',\r\n 'image/png',\r\n 'image/tga',\r\n 'image/vnd.radiance',\r\n 'image/x-dds',\r\n 'image/webp'\r\n ]\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: ConstantTexture2DNode, value) {\r\n value.str[0] = this.textureId;\r\n },\r\n async set(this: ConstantTexture2DNode, value) {\r\n this.textureId = value.str[0] ?? '';\r\n }\r\n },\r\n ...textureNodeProps\r\n ];\r\n }\r\n };\r\n }\r\n /**\r\n * Validates the node state\r\n *\r\n * @returns Empty string (always valid)\r\n */\r\n protected validate(): string {\r\n return '';\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'tex2D'\r\n */\r\n protected getType(): string {\r\n return 'tex2D';\r\n }\r\n}\r\n\r\n/**\r\n * 2D texture array constant node\r\n *\r\n * @remarks\r\n * Represents a 2D texture array resource in the material node graph.\r\n * A texture array is a collection of 2D textures with the same size and format,\r\n * accessed using a 3D coordinate (u, v, layer).\r\n *\r\n * Used for:\r\n * - Terrain texture splatting (multiple terrain textures in one array)\r\n * - Animation frames (sprite sheets)\r\n * - Texture atlases with uniform tile sizes\r\n * - Reducing texture bindings (multiple textures in one resource)\r\n *\r\n * Note: Only DDS format supports texture arrays.\r\n *\r\n * Output:\r\n * - Output 1: Texture array sampler (tex2DArray type)\r\n *\r\n * @example\r\n * ```typescript\r\n * const terrainTexArray = new ConstantTexture2DArrayNode();\r\n * terrainTexArray.paramName = 'terrainTextures';\r\n *\r\n * // Sample from layer 2\r\n * const uv = new VertexUVNode();\r\n * const layer = new ConstantScalarNode();\r\n * layer.x = 2.0;\r\n *\r\n * const uvLayer = new MakeVectorNode();\r\n * uvLayer.connectInput(1, uv, 1); // UV (vec2)\r\n * uvLayer.connectInput(2, layer, 1); // Layer (float)\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.connectInput(1, terrainTexArray, 1);\r\n * sample.connectInput(2, uvLayer, 1); // vec3 (u, v, layer)\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ConstantTexture2DArrayNode extends BaseTextureNode {\r\n /**\r\n * Creates a new 2D texture array node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - One output slot for the texture array sampler\r\n * - Default 1x1x1 white texture array\r\n */\r\n constructor() {\r\n super();\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @param manager - The serialization manager for loading textures\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Only accepts DDS format, which is the standard format for texture arrays.\r\n * Includes validation to ensure the loaded texture is actually a 2D array.\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: ConstantTexture2DArrayNode,\r\n name: 'Texture2DArrayNode',\r\n noTitle: true,\r\n getProps() {\r\n return [\r\n {\r\n name: 'Texture',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n mimeTypes: ['image/x-dds']\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: ConstantTexture2DArrayNode, value) {\r\n value.str[0] = this.textureId;\r\n },\r\n async set(this: ConstantTexture2DArrayNode, value) {\r\n this.textureId = value.str[0] ?? '';\r\n }\r\n },\r\n ...textureNodeProps\r\n ];\r\n }\r\n };\r\n }\r\n /**\r\n * Validates the node state\r\n *\r\n * @returns Empty string (always valid)\r\n */\r\n protected validate(): string {\r\n return '';\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'tex2DArray'\r\n */\r\n protected getType(): string {\r\n return 'tex2DArray';\r\n }\r\n}\r\n\r\n/**\r\n * Cubemap texture constant node\r\n *\r\n * @remarks\r\n * Represents a cubemap texture resource in the material node graph.\r\n * A cubemap consists of 6 square textures representing the faces of a cube,\r\n * sampled using a 3D direction vector.\r\n *\r\n * Used for:\r\n * - Environment maps (skyboxes)\r\n * - Reflections (environment reflections on shiny surfaces)\r\n * - Image-based lighting (IBL)\r\n * - Irradiance maps for ambient lighting\r\n * - Prefiltered environment maps for specular reflections\r\n *\r\n * Cubemap faces (standard ordering):\r\n * - +X (right), -X (left)\r\n * - +Y (top), -Y (bottom)\r\n * - +Z (front), -Z (back)\r\n *\r\n * Note: Only DDS format supports cubemap textures.\r\n *\r\n * Output:\r\n * - Output 1: Cubemap sampler (texCube type)\r\n *\r\n * @example\r\n * ```typescript\r\n * const envMap = new ConstantTextureCubeNode();\r\n * envMap.paramName = 'environmentMap';\r\n * envMap.filterMin = 'linear';\r\n * envMap.filterMag = 'linear';\r\n * envMap.filterMip = 'linear';\r\n *\r\n * // Sample environment for reflection\r\n * const normal = new VertexNormalNode();\r\n * const viewDir = new ViewDirectionNode();\r\n *\r\n * const reflectDir = new ReflectNode();\r\n * reflectDir.connectInput(1, viewDir, 1);\r\n * reflectDir.connectInput(2, normal, 1);\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.connectInput(1, envMap, 1);\r\n * sample.connectInput(2, reflectDir, 1); // vec3 direction\r\n *\r\n * // Use for reflections\r\n * output.connectInput(1, sample, 1);\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ConstantTextureCubeNode extends BaseTextureNode {\r\n /**\r\n * Creates a new cubemap texture node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - One output slot for the cubemap sampler\r\n * - Default 1x1 white cubemap (all faces white)\r\n * - No inputs (texture resource only)\r\n */\r\n constructor() {\r\n super();\r\n this._inputs = [];\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @param manager - The serialization manager for loading textures\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Only accepts DDS format, which is the standard format for cubemaps.\r\n * Includes validation to ensure the loaded texture is actually a cubemap.\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: ConstantTextureCubeNode,\r\n name: 'TextureCubeNode',\r\n noTitle: true,\r\n getProps() {\r\n return [\r\n {\r\n name: 'Texture',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n mimeTypes: ['image/x-dds']\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: ConstantTextureCubeNode, value) {\r\n value.str[0] = this.textureId;\r\n },\r\n async set(this: ConstantTextureCubeNode, value) {\r\n this.textureId = value.str[0] ?? '';\r\n }\r\n },\r\n ...textureNodeProps\r\n ];\r\n }\r\n };\r\n }\r\n /**\r\n * Validates the node state\r\n *\r\n * @returns Empty string (always valid)\r\n */\r\n protected validate(): string {\r\n return '';\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'texCube'\r\n */\r\n protected getType(): string {\r\n return 'texCube';\r\n }\r\n}\r\n\r\n/**\r\n * Texture sampling node\r\n *\r\n * @remarks\r\n * Samples a texture at the specified coordinates and returns the color value.\r\n * This is the primary way to read texture data in material shaders.\r\n *\r\n * Supports multiple texture types:\r\n * - **tex2D**: Requires vec2 coordinates (u, v)\r\n * - **tex2DArray**: Requires vec3 coordinates (u, v, layer)\r\n * - **texCube**: Requires vec3 direction vector\r\n *\r\n * Sampler types:\r\n * - **Color**: Standard color sampling (returns RGBA as-is)\r\n * - **Normal**: Normal map sampling (may apply special transformations)\r\n *\r\n * The sampling uses the texture's configured filtering and addressing modes.\r\n * Mipmap level is automatically selected based on screen-space derivatives.\r\n *\r\n * Inputs:\r\n * - Input 1: Texture sampler (tex2D, tex2DArray, or texCube)\r\n * - Input 2: Texture coordinates (vec2 for 2D, vec3 for array/cube)\r\n *\r\n * Output:\r\n * - Output 1: Sampled color (vec4 RGBA)\r\n *\r\n * @example\r\n * ```typescript\r\n * // Basic 2D texture sampling\r\n * const albedoTex = new ConstantTexture2DNode();\r\n * const uv = new VertexUVNode();\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.samplerType = 'Color';\r\n * sample.connectInput(1, albedoTex, 1);\r\n * sample.connectInput(2, uv, 1);\r\n *\r\n * output.connectInput(1, sample, 1); // Use as base color\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Normal map sampling\r\n * const normalMap = new ConstantTexture2DNode();\r\n * const uv = new VertexUVNode();\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.samplerType = 'Normal';\r\n * sample.connectInput(1, normalMap, 1);\r\n * sample.connectInput(2, uv, 1);\r\n *\r\n * output.connectInput(6, sample, 1); // Use as normal\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Cubemap environment sampling\r\n * const envMap = new ConstantTextureCubeNode();\r\n * const normal = new VertexNormalNode();\r\n * const viewDir = new ViewDirectionNode();\r\n *\r\n * const reflectDir = new ReflectNode();\r\n * reflectDir.connectInput(1, viewDir, 1);\r\n * reflectDir.connectInput(2, normal, 1);\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.connectInput(1, envMap, 1);\r\n * sample.connectInput(2, reflectDir, 1);\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class TextureSampleNode extends BaseGraphNode {\r\n /** The type of sampling (Color or Normal) */\r\n samplerType: 'Color' | 'Normal';\r\n /**\r\n * Creates a new texture sample node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - Two required inputs (texture and coordinates)\r\n * - One output (sampled color)\r\n * - Color sampler type by default\r\n */\r\n constructor() {\r\n super();\r\n this.samplerType = 'Color';\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n this._inputs = [\r\n {\r\n id: 1,\r\n name: 'texture',\r\n type: ['tex2D', 'tex2DArray', 'texCube'],\r\n required: true\r\n },\r\n {\r\n id: 2,\r\n name: 'coord',\r\n type: ['vec2', 'vec3'],\r\n required: true\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Serializes the sampler type (Color or Normal).\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: TextureSampleNode,\r\n name: 'TextureSampleNode',\r\n getProps(): PropertyAccessor<TextureSampleNode>[] {\r\n return [\r\n {\r\n name: 'SamplerType',\r\n type: 'string',\r\n options: {\r\n enum: {\r\n labels: ['Color', 'Normal'],\r\n values: ['Color', 'Normal']\r\n }\r\n },\r\n get(this: TextureSampleNode, value) {\r\n value.str[0] = this.samplerType;\r\n },\r\n set(this: TextureSampleNode, value) {\r\n this.samplerType = value.str[0] as any;\r\n }\r\n }\r\n ];\r\n }\r\n };\r\n }\r\n /**\r\n * Generates a string representation of this node\r\n *\r\n * @returns 'textureSample'\r\n */\r\n toString(): string {\r\n return 'textureSample';\r\n }\r\n /**\r\n * Validates the node state and input type compatibility\r\n *\r\n * @returns Error message if invalid, empty string if valid\r\n *\r\n * @remarks\r\n * Validation ensures:\r\n * - Both inputs are connected\r\n * - Texture input is a valid texture type\r\n * - Coordinate input matches texture dimensionality:\r\n * - tex2D requires vec2\r\n * - tex2DArray requires vec3 (u, v, layer)\r\n * - texCube requires vec3 (direction)\r\n */\r\n protected validate(): string {\r\n const err = super.validate();\r\n if (err) {\r\n return err;\r\n }\r\n const type0 = this._inputs[0].inputNode.getOutputType(this._inputs[0].inputId);\r\n if (!type0) {\r\n return `Cannot determine type of argument \\`${this._inputs[0].name}\\``;\r\n }\r\n if (!this._inputs[0].type.includes(type0)) {\r\n return `Invalid input type of argument \\`${this._inputs[0].name}\\`: ${type0}`;\r\n }\r\n const type1 = this._inputs[1].inputNode.getOutputType(this._inputs[1].inputId);\r\n if (!type1) {\r\n return `Cannot determine type of argument \\`${this._inputs[1].name}\\``;\r\n }\r\n const expectedType1 = type0 === 'tex2D' ? 'vec2' : 'vec3';\r\n if (type1 !== expectedType1) {\r\n return `Texture coordinate type should be ${expectedType1}`;\r\n }\r\n return '';\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'vec4' (RGBA color)\r\n */\r\n protected getType(): string {\r\n return 'vec4';\r\n }\r\n}\r\n\r\n/**\r\n * Texture sampling with explicit gradients node\r\n *\r\n * @remarks\r\n * Samples a texture using explicitly provided screen-space gradients (derivatives)\r\n * instead of automatically computed ones. This allows precise control over mipmap\r\n * level selection and can be used for advanced effects.\r\n *\r\n * Use cases:\r\n * - Manual mipmap level control\r\n * - Sampling in non-fragment shaders (where automatic derivatives aren't available)\r\n * - Custom anisotropic filtering\r\n * - Texture sampling in control flow that breaks derivatives\r\n * - Advanced procedural effects\r\n *\r\n * Note: The current implementation appears identical to TextureSampleNode.\r\n * Full gradient support would require additional inputs for dPdx and dPdy.\r\n *\r\n * Inputs:\r\n * - Input 1: Texture sampler (tex2D, tex2DArray, or texCube)\r\n * - Input 2: Texture coordinates (vec2 or vec3)\r\n *\r\n * Output:\r\n * - Output 1: Sampled color (vec4 RGBA)\r\n *\r\n * @public\r\n */\r\nexport class TextureSampleGrad extends BaseGraphNode {\r\n /** The type of sampling (Color or Normal) */\r\n samplerType: 'Color' | 'Normal';\r\n /**\r\n * Creates a new texture sample with gradients node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - Two required inputs (texture and coordinates)\r\n * - One output (sampled color)\r\n * - Color sampler type by default\r\n *\r\n * TODO: Add gradient inputs (dPdx, dPdy) for full explicit gradient support\r\n */\r\n constructor() {\r\n super();\r\n this.samplerType = 'Color';\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n this._inputs = [\r\n {\r\n id: 1,\r\n name: 'texture',\r\n type: ['tex2D', 'tex2DArray', 'texCube'],\r\n required: true\r\n },\r\n {\r\n id: 2,\r\n name: 'coord',\r\n type: ['vec2', 'vec3'],\r\n required: true\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Currently returns TextureSampleNode serialization (likely needs separate class).\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: TextureSampleNode,\r\n name: 'TextureSampleNode',\r\n getProps(): PropertyAccessor<TextureSampleNode>[] {\r\n return [\r\n {\r\n name: 'SamplerType',\r\n type: 'string',\r\n options: {\r\n enum: {\r\n labels: ['Color', 'Normal'],\r\n values: ['Color', 'Normal']\r\n }\r\n },\r\n get(this: TextureSampleNode, value) {\r\n value.str[0] = this.samplerType;\r\n },\r\n set(this: TextureSampleNode, value) {\r\n this.samplerType = value.str[0] as any;\r\n }\r\n }\r\n ];\r\n }\r\n };\r\n }\r\n /**\r\n * Generates a string representation of this node\r\n *\r\n * @returns 'textureSample'\r\n */\r\n toString(): string {\r\n return 'textureSample';\r\n }\r\n /**\r\n * Validates the node state and input type compatibility\r\n *\r\n * @returns Error message if invalid, empty string if valid\r\n *\r\n * @remarks\r\n * Validation ensures:\r\n * - Both inputs are connected\r\n * - Texture input is a valid texture type\r\n * - Coordinate input matches texture dimensionality\r\n */\r\n protected validate(): string {\r\n const err = super.validate();\r\n if (err) {\r\n return err;\r\n }\r\n const type0 = this._inputs[0].inputNode.getOutputType(this._inputs[0].inputId);\r\n if (!type0) {\r\n return `Cannot determine type of argument \\`${this._inputs[0].name}\\``;\r\n }\r\n if (!this._inputs[0].type.includes(type0)) {\r\n return `Invalid input type of argument \\`${this._inputs[0].name}\\`: ${type0}`;\r\n }\r\n const type1 = this._inputs[1].inputNode.getOutputType(this._inputs[1].inputId);\r\n if (!type1) {\r\n return `Cannot determine type of argument \\`${this._inputs[1].name}\\``;\r\n }\r\n const expectedType1 = type0 === 'tex2D' ? 'vec2' : 'vec3';\r\n if (type1 !== expectedType1) {\r\n return `Texture coordinate type should be ${expectedType1}`;\r\n }\r\n return '';\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'vec4' (RGBA color)\r\n */\r\n protected getType(): string {\r\n return 'vec4';\r\n }\r\n}\r\n"],"names":["defaultTexture2D","DRef","defaultTextureCube","defaultTexture2DArray","getDefaultTexture2D","get","defaultTex","getDevice","createTexture2D","mipmapping","update","Uint8Array","set","getDefaultTexture2DArray","createTexture2DArray","getDefaultTextureCube","createCubeTexture","i","textureNodeProps","getTextureNodeProps","name","type","isNullable","value","str","paramName","default","bool","sRGB","options","enum","labels","values","addressU","addressV","filterMin","filterMag","filterMip","BaseTextureNode","BaseGraphNode","textureId","_paramName","getParamName","val","dispatchEvent","isUniform","toString","ConstantTexture2DNode","_outputs","id","getSerializationCls","ctor","noTitle","getProps","mimeTypes","ConstantTexture2DArrayNode","ConstantTextureCubeNode","_inputs","TextureSampleNode","samplerType","required","err","validate","type0","inputNode","getOutputType","inputId","includes","type1","expectedType1","TextureSampleGrad"],"mapp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,CAAA,CAAA;AAC7D;QACA,OAAO,EAAA;AACT;AACA;;;;AAIC,MACD,OAA4B,GAAA;QAC1B,OAAO,MAAA;AACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"texture.js","sources":["../../../../src/utility/blueprint/material/texture.ts"],"sourcesContent":["import { BaseGraphNode } from '../node';\r\nimport { getParamName } from '../common';\r\nimport type {\r\n Texture2D,\r\n Texture2DArray,\r\n TextureAddressMode,\r\n TextureCube,\r\n TextureFilterMode\r\n} from '@zephyr3d/device';\r\nimport { DRef } from '@zephyr3d/base';\r\nimport { getDevice } from '../../../app/api';\r\nimport { defineProps, type PropertyAccessor, type SerializableClass } from '../../serialization/types';\r\n\r\n/**\r\n * Default 1x1 white 2D texture reference\r\n * @internal\r\n */\r\nconst defaultTexture2D: DRef<Texture2D> = new DRef();\r\n\r\n/**\r\n * Default 1x1 white cubemap texture reference\r\n * @internal\r\n */\r\nconst defaultTextureCube: DRef<TextureCube> = new DRef();\r\n\r\n/**\r\n * Default 1x1 white 2D array texture reference\r\n * @internal\r\n */\r\nconst defaultTexture2DArray: DRef<Texture2DArray> = new DRef();\r\n\r\n/**\r\n * Gets or creates the default 2D texture\r\n *\r\n * @remarks\r\n * Returns a 1x1 white (255, 255, 255, 255) texture used as a fallback\r\n * when no texture is assigned to a texture node.\r\n *\r\n * @returns A 1x1 white Texture2D instance\r\n *\r\n * @internal\r\n */\r\nexport function getDefaultTexture2D(): Texture2D {\r\n if (!defaultTexture2D.get()) {\r\n const defaultTex = getDevice().createTexture2D('rgba8unorm', 1, 1, {\r\n mipmapping: false\r\n })!;\r\n defaultTex.update(new Uint8Array([255, 255, 255, 255]), 0, 0, 1, 1);\r\n defaultTexture2D.set(defaultTex);\r\n }\r\n return defaultTexture2D.get()!;\r\n}\r\n\r\n/**\r\n * Gets or creates the default 2D array texture\r\n *\r\n * @remarks\r\n * Returns a 1x1x1 white (255, 255, 255, 255) array texture used as a fallback\r\n * when no texture is assigned to a 2D array texture node.\r\n *\r\n * @returns A 1x1x1 white Texture2DArray instance\r\n *\r\n * @internal\r\n */\r\nexport function getDefaultTexture2DArray(): Texture2DArray {\r\n if (!defaultTexture2DArray.get()) {\r\n const defaultTex = getDevice().createTexture2DArray('rgba8unorm', 1, 1, 1, {\r\n mipmapping: false\r\n })!;\r\n defaultTex.update(new Uint8Array([255, 255, 255, 255]), 0, 0, 0, 1, 1, 1);\r\n defaultTexture2DArray.set(defaultTex);\r\n }\r\n return defaultTexture2DArray.get()!;\r\n}\r\n\r\n/**\r\n * Gets or creates the default cubemap texture\r\n *\r\n * @remarks\r\n * Returns a 1x1 white (255, 255, 255, 255) cubemap texture (all 6 faces white)\r\n * used as a fallback when no texture is assigned to a cubemap texture node.\r\n *\r\n * @returns A 1x1 white TextureCube instance\r\n *\r\n * @internal\r\n */\r\nexport function getDefaultTextureCube(): TextureCube {\r\n if (!defaultTextureCube.get()) {\r\n const defaultTex = getDevice().createCubeTexture('rgba8unorm', 1, {\r\n mipmapping: false\r\n })!;\r\n for (let i = 0; i < 6; i++) {\r\n defaultTex.update(new Uint8Array([255, 255, 255, 255]), 0, 0, 1, 1, i);\r\n }\r\n defaultTextureCube.set(defaultTex);\r\n }\r\n return defaultTextureCube.get()!;\r\n}\r\n\r\n/**\r\n * Common property descriptors for texture nodes\r\n *\r\n * @remarks\r\n * Defines serialization properties shared by all texture node types:\r\n * - Name: Shader parameter name for the texture uniform\r\n * - sRGB: Whether texture should be loaded into sRGB color space\r\n * - AddressU: Horizontal texture wrapping mode\r\n * - AddressV: Vertical texture wrapping mode\r\n * - MinFilter: Minification filter mode\r\n * - MagFilter: Magnification filter mode\r\n * - MipFilter: Mipmap filter mode\r\n *\r\n * @internal\r\n */\r\nconst textureNodeProps = (function getTextureNodeProps(): PropertyAccessor<BaseTextureNode>[] {\r\n return defineProps([\r\n {\r\n name: 'Name',\r\n type: 'string',\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.paramName ? this.paramName.slice(2) : '';\r\n },\r\n set(this: BaseTextureNode, value) {\r\n if (!/^[A-Za-z0-9_]+$/.test(value.str[0])) {\r\n console.log(`Invalid parameter name: ${value.str[0]}`);\r\n } else {\r\n this.paramName = `u_${value.str[0]}`;\r\n }\r\n }\r\n },\r\n {\r\n name: 'sRGB',\r\n type: 'bool',\r\n default: true,\r\n get(this: BaseTextureNode, value) {\r\n value.bool[0] = this.sRGB;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.sRGB = value.bool[0];\r\n }\r\n },\r\n {\r\n name: 'AddressU',\r\n type: 'string',\r\n default: 'clamp',\r\n options: {\r\n enum: {\r\n labels: ['clamp', 'repeat', 'mirrored-repeat'],\r\n values: ['clamp', 'repeat', 'mirrored-repeat']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.addressU;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.addressU = value.str[0] as TextureAddressMode;\r\n }\r\n },\r\n {\r\n name: 'AddressV',\r\n type: 'string',\r\n default: 'clamp',\r\n options: {\r\n enum: {\r\n labels: ['clamp', 'repeat', 'mirrored-repeat'],\r\n values: ['clamp', 'repeat', 'mirrored-repeat']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.addressV;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.addressV = value.str[0] as TextureAddressMode;\r\n }\r\n },\r\n {\r\n name: 'MinFilter',\r\n type: 'string',\r\n default: 'linear',\r\n options: {\r\n enum: {\r\n labels: ['nearest', 'linear'],\r\n values: ['nearest', 'linear']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.filterMin;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.filterMin = value.str[0] as TextureFilterMode;\r\n }\r\n },\r\n {\r\n name: 'MagFilter',\r\n type: 'string',\r\n default: 'linear',\r\n options: {\r\n enum: {\r\n labels: ['nearest', 'linear'],\r\n values: ['nearest', 'linear']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.filterMag;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.filterMag = value.str[0] as TextureFilterMode;\r\n }\r\n },\r\n {\r\n name: 'MipFilter',\r\n type: 'string',\r\n default: 'nearest',\r\n options: {\r\n enum: {\r\n labels: ['nearest', 'linear', 'none'],\r\n values: ['nearest', 'linear', 'none']\r\n }\r\n },\r\n isNullable() {\r\n return false;\r\n },\r\n get(this: BaseTextureNode, value) {\r\n value.str[0] = this.filterMip;\r\n },\r\n set(this: BaseTextureNode, value) {\r\n this.filterMip = value.str[0] as TextureFilterMode;\r\n }\r\n }\r\n ]);\r\n})();\r\n\r\n/**\r\n * Abstract base class for texture nodes\r\n *\r\n * @remarks\r\n * Provides common functionality for all texture types in the material node graph.\r\n * Texture nodes represent shader texture uniforms and their sampling parameters.\r\n *\r\n * Common properties:\r\n * - **paramName**: The shader uniform name for this texture\r\n * - **addressU/V**: Texture coordinate wrapping modes (clamp, repeat, mirrored-repeat)\r\n * - **filterMin**: Minification filter (nearest, linear)\r\n * - **filterMag**: Magnification filter (nearest, linear)\r\n * - **filterMip**: Mipmap filter (nearest, linear, none)\r\n * - **texture**: Reference to the actual GPU texture resource\r\n * - **textureId**: Asset ID for serialization/loading\r\n *\r\n * Texture addressing modes:\r\n * - **clamp**: Coordinates outside [0,1] are clamped to edge colors\r\n * - **repeat**: Texture tiles infinitely (wraps around)\r\n * - **mirrored-repeat**: Texture tiles with alternating mirroring\r\n *\r\n * Filtering modes:\r\n * - **nearest**: Point sampling (sharp, pixelated)\r\n * - **linear**: Bilinear interpolation (smooth)\r\n * - **none**: No mipmap filtering (mip filter only)\r\n *\r\n * @typeParam T - The specific texture type (Texture2D, TextureCube, etc.)\r\n *\r\n * @public\r\n */\r\nexport abstract class BaseTextureNode extends BaseGraphNode {\r\n /** The shader parameter name for this texture uniform */\r\n private _paramName: string;\r\n /** Whether this texture should be loaded in sRGB color space */\r\n sRGB: boolean;\r\n /** Horizontal texture coordinate wrapping mode */\r\n addressU: TextureAddressMode;\r\n /** Vertical texture coordinate wrapping mode */\r\n addressV: TextureAddressMode;\r\n /** Minification filter mode */\r\n filterMin: TextureFilterMode;\r\n /** Magnification filter mode */\r\n filterMag: TextureFilterMode;\r\n /** Mipmap filter mode */\r\n filterMip: TextureFilterMode;\r\n /** Asset ID for the texture (for serialization) */\r\n textureId: string;\r\n /**\r\n * Creates a new texture node\r\n *\r\n * @remarks\r\n * Initializes with default sampling parameters:\r\n * - Auto-generated unique parameter name\r\n * - Clamp addressing mode\r\n * - Nearest filtering (point sampling)\r\n * - No mipmap filtering\r\n * - Empty texture ID\r\n */\r\n constructor() {\r\n super();\r\n this._paramName = getParamName();\r\n this.sRGB = true;\r\n this.addressU = 'clamp';\r\n this.addressV = 'clamp';\r\n this.filterMin = 'linear';\r\n this.filterMag = 'linear';\r\n this.filterMip = 'nearest';\r\n this.textureId = '';\r\n }\r\n /**\r\n * Gets the shader parameter name\r\n *\r\n * @returns The uniform name used in generated shader code\r\n */\r\n get paramName() {\r\n return this._paramName;\r\n }\r\n set paramName(val: string) {\r\n if (this._paramName !== val) {\r\n this._paramName = val;\r\n this.dispatchEvent('changed');\r\n }\r\n }\r\n\r\n /**\r\n * Indicates this node represents a shader uniform\r\n *\r\n * @returns Always true for texture nodes\r\n *\r\n * @remarks\r\n * Texture nodes create uniform declarations in the generated shader code.\r\n */\r\n get isUniform() {\r\n return true;\r\n }\r\n /**\r\n * Generates a string representation of this node\r\n *\r\n * @returns The parameter name\r\n */\r\n toString() {\r\n return this._paramName;\r\n }\r\n /**\r\n * Validates the node state\r\n *\r\n * @returns Empty string (always valid)\r\n *\r\n * @remarks\r\n * Texture nodes are always valid as they have no required inputs\r\n * and always have a valid texture (default if none assigned).\r\n */\r\n protected validate(): string {\r\n return this.textureId ? '' : 'Texture not specified';\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns Empty string (overridden by subclasses)\r\n *\r\n * @remarks\r\n * Subclasses return texture type identifiers like 'tex2D', 'texCube', etc.\r\n */\r\n protected getType(): string {\r\n return '';\r\n }\r\n}\r\n\r\n/**\r\n * 2D texture constant node\r\n *\r\n * @remarks\r\n * Represents a 2D texture resource in the material node graph.\r\n * This is the most common texture type, used for:\r\n * - Albedo/diffuse maps\r\n * - Normal maps\r\n * - Roughness/metallic maps\r\n * - Emissive maps\r\n * - Any 2D image-based data\r\n *\r\n * The texture can be loaded from various image formats:\r\n * - JPEG (.jpg, .jpeg)\r\n * - PNG (.png)\r\n * - TGA (.tga)\r\n * - HDR/Radiance (.hdr)\r\n * - DDS (.dds)\r\n * - WebP (.webp)\r\n *\r\n * Output:\r\n * - Output 1: Texture sampler (tex2D type)\r\n *\r\n * @example\r\n * ```typescript\r\n * const albedoTex = new ConstantTexture2DNode();\r\n * albedoTex.paramName = 'albedoMap';\r\n * albedoTex.addressU = 'repeat';\r\n * albedoTex.addressV = 'repeat';\r\n * albedoTex.filterMin = 'linear';\r\n * albedoTex.filterMag = 'linear';\r\n *\r\n * // Sample the texture\r\n * const uv = new VertexUVNode();\r\n * const sample = new TextureSampleNode();\r\n * sample.connectInput(1, albedoTex, 1);\r\n * sample.connectInput(2, uv, 1);\r\n *\r\n * // Use in material\r\n * output.connectInput(1, sample, 1); // BaseColor\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ConstantTexture2DNode extends BaseTextureNode {\r\n /**\r\n * Creates a new 2D texture node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - One output slot for the texture sampler\r\n * - Default 1x1 white texture\r\n */\r\n constructor() {\r\n super();\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @param manager - The serialization manager for loading textures\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Includes:\r\n * - Texture asset loading with MIME type validation\r\n * - All common texture parameters (addressing, filtering)\r\n * - Error handling for invalid or missing textures\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: ConstantTexture2DNode,\r\n name: 'Texture2DNode',\r\n noTitle: true,\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'Texture',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n mimeTypes: [\r\n 'image/jpeg',\r\n 'image/png',\r\n 'image/tga',\r\n 'image/vnd.radiance',\r\n 'image/x-dds',\r\n 'image/webp'\r\n ]\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: ConstantTexture2DNode, value) {\r\n value.str[0] = this.textureId;\r\n },\r\n async set(this: ConstantTexture2DNode, value) {\r\n this.textureId = value.str[0] ?? '';\r\n }\r\n },\r\n ...textureNodeProps\r\n ]);\r\n }\r\n };\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'tex2D'\r\n */\r\n protected getType(): string {\r\n return this.validate() ? '' : 'tex2D';\r\n }\r\n}\r\n\r\n/**\r\n * 2D texture array constant node\r\n *\r\n * @remarks\r\n * Represents a 2D texture array resource in the material node graph.\r\n * A texture array is a collection of 2D textures with the same size and format,\r\n * accessed using a 3D coordinate (u, v, layer).\r\n *\r\n * Used for:\r\n * - Terrain texture splatting (multiple terrain textures in one array)\r\n * - Animation frames (sprite sheets)\r\n * - Texture atlases with uniform tile sizes\r\n * - Reducing texture bindings (multiple textures in one resource)\r\n *\r\n * Note: Only DDS format supports texture arrays.\r\n *\r\n * Output:\r\n * - Output 1: Texture array sampler (tex2DArray type)\r\n *\r\n * @example\r\n * ```typescript\r\n * const terrainTexArray = new ConstantTexture2DArrayNode();\r\n * terrainTexArray.paramName = 'terrainTextures';\r\n *\r\n * // Sample from layer 2\r\n * const uv = new VertexUVNode();\r\n * const layer = new ConstantScalarNode();\r\n * layer.x = 2.0;\r\n *\r\n * const uvLayer = new MakeVectorNode();\r\n * uvLayer.connectInput(1, uv, 1); // UV (vec2)\r\n * uvLayer.connectInput(2, layer, 1); // Layer (float)\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.connectInput(1, terrainTexArray, 1);\r\n * sample.connectInput(2, uvLayer, 1); // vec3 (u, v, layer)\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ConstantTexture2DArrayNode extends BaseTextureNode {\r\n /**\r\n * Creates a new 2D texture array node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - One output slot for the texture array sampler\r\n * - Default 1x1x1 white texture array\r\n */\r\n constructor() {\r\n super();\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @param manager - The serialization manager for loading textures\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Only accepts DDS format, which is the standard format for texture arrays.\r\n * Includes validation to ensure the loaded texture is actually a 2D array.\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: ConstantTexture2DArrayNode,\r\n name: 'Texture2DArrayNode',\r\n noTitle: true,\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'Texture',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n mimeTypes: ['image/x-dds']\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: ConstantTexture2DArrayNode, value) {\r\n value.str[0] = this.textureId;\r\n },\r\n async set(this: ConstantTexture2DArrayNode, value) {\r\n this.textureId = value.str[0] ?? '';\r\n }\r\n },\r\n ...textureNodeProps\r\n ]);\r\n }\r\n };\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'tex2DArray'\r\n */\r\n protected getType(): string {\r\n return this.validate() ? '' : 'tex2DArray';\r\n }\r\n}\r\n\r\n/**\r\n * Cubemap texture constant node\r\n *\r\n * @remarks\r\n * Represents a cubemap texture resource in the material node graph.\r\n * A cubemap consists of 6 square textures representing the faces of a cube,\r\n * sampled using a 3D direction vector.\r\n *\r\n * Used for:\r\n * - Environment maps (skyboxes)\r\n * - Reflections (environment reflections on shiny surfaces)\r\n * - Image-based lighting (IBL)\r\n * - Irradiance maps for ambient lighting\r\n * - Prefiltered environment maps for specular reflections\r\n *\r\n * Cubemap faces (standard ordering):\r\n * - +X (right), -X (left)\r\n * - +Y (top), -Y (bottom)\r\n * - +Z (front), -Z (back)\r\n *\r\n * Note: Only DDS format supports cubemap textures.\r\n *\r\n * Output:\r\n * - Output 1: Cubemap sampler (texCube type)\r\n *\r\n * @example\r\n * ```typescript\r\n * const envMap = new ConstantTextureCubeNode();\r\n * envMap.paramName = 'environmentMap';\r\n * envMap.filterMin = 'linear';\r\n * envMap.filterMag = 'linear';\r\n * envMap.filterMip = 'linear';\r\n *\r\n * // Sample environment for reflection\r\n * const normal = new VertexNormalNode();\r\n * const viewDir = new ViewDirectionNode();\r\n *\r\n * const reflectDir = new ReflectNode();\r\n * reflectDir.connectInput(1, viewDir, 1);\r\n * reflectDir.connectInput(2, normal, 1);\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.connectInput(1, envMap, 1);\r\n * sample.connectInput(2, reflectDir, 1); // vec3 direction\r\n *\r\n * // Use for reflections\r\n * output.connectInput(1, sample, 1);\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ConstantTextureCubeNode extends BaseTextureNode {\r\n /**\r\n * Creates a new cubemap texture node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - One output slot for the cubemap sampler\r\n * - Default 1x1 white cubemap (all faces white)\r\n * - No inputs (texture resource only)\r\n */\r\n constructor() {\r\n super();\r\n this._inputs = [];\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @param manager - The serialization manager for loading textures\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Only accepts DDS format, which is the standard format for cubemaps.\r\n * Includes validation to ensure the loaded texture is actually a cubemap.\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: ConstantTextureCubeNode,\r\n name: 'TextureCubeNode',\r\n noTitle: true,\r\n getProps() {\r\n return defineProps([\r\n {\r\n name: 'Texture',\r\n type: 'object',\r\n default: null,\r\n options: {\r\n mimeTypes: ['image/x-dds']\r\n },\r\n isNullable() {\r\n return true;\r\n },\r\n get(this: ConstantTextureCubeNode, value) {\r\n value.str[0] = this.textureId;\r\n },\r\n async set(this: ConstantTextureCubeNode, value) {\r\n this.textureId = value.str[0] ?? '';\r\n }\r\n },\r\n ...textureNodeProps\r\n ]);\r\n }\r\n };\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'texCube'\r\n */\r\n protected getType(): string {\r\n return this.validate() ? '' : 'texCube';\r\n }\r\n}\r\n\r\n/**\r\n * Texture sampling node\r\n *\r\n * @remarks\r\n * Samples a texture at the specified coordinates and returns the color value.\r\n * This is the primary way to read texture data in material shaders.\r\n *\r\n * Supports multiple texture types:\r\n * - **tex2D**: Requires vec2 coordinates (u, v)\r\n * - **tex2DArray**: Requires vec3 coordinates (u, v, layer)\r\n * - **texCube**: Requires vec3 direction vector\r\n *\r\n * Sampler types:\r\n * - **Color**: Standard color sampling (returns RGBA as-is)\r\n * - **Normal**: Normal map sampling (may apply special transformations)\r\n *\r\n * The sampling uses the texture's configured filtering and addressing modes.\r\n * Mipmap level is automatically selected based on screen-space derivatives.\r\n *\r\n * Inputs:\r\n * - Input 1: Texture sampler (tex2D, tex2DArray, or texCube)\r\n * - Input 2: Texture coordinates (vec2 for 2D, vec3 for array/cube)\r\n *\r\n * Output:\r\n * - Output 1: Sampled color (vec4 RGBA)\r\n *\r\n * @example\r\n * ```typescript\r\n * // Basic 2D texture sampling\r\n * const albedoTex = new ConstantTexture2DNode();\r\n * const uv = new VertexUVNode();\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.samplerType = 'Color';\r\n * sample.connectInput(1, albedoTex, 1);\r\n * sample.connectInput(2, uv, 1);\r\n *\r\n * output.connectInput(1, sample, 1); // Use as base color\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Normal map sampling\r\n * const normalMap = new ConstantTexture2DNode();\r\n * const uv = new VertexUVNode();\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.samplerType = 'Normal';\r\n * sample.connectInput(1, normalMap, 1);\r\n * sample.connectInput(2, uv, 1);\r\n *\r\n * output.connectInput(6, sample, 1); // Use as normal\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Cubemap environment sampling\r\n * const envMap = new ConstantTextureCubeNode();\r\n * const normal = new VertexNormalNode();\r\n * const viewDir = new ViewDirectionNode();\r\n *\r\n * const reflectDir = new ReflectNode();\r\n * reflectDir.connectInput(1, viewDir, 1);\r\n * reflectDir.connectInput(2, normal, 1);\r\n *\r\n * const sample = new TextureSampleNode();\r\n * sample.connectInput(1, envMap, 1);\r\n * sample.connectInput(2, reflectDir, 1);\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class TextureSampleNode extends BaseGraphNode {\r\n /** The type of sampling (Color or Normal) */\r\n samplerType: 'Color' | 'Normal';\r\n /**\r\n * Creates a new texture sample node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - Two required inputs (texture and coordinates)\r\n * - One output (sampled color)\r\n * - Color sampler type by default\r\n */\r\n constructor() {\r\n super();\r\n this.samplerType = 'Color';\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: 'RGBA'\r\n },\r\n {\r\n id: 2,\r\n name: 'R',\r\n swizzle: 'r'\r\n },\r\n {\r\n id: 3,\r\n name: 'G',\r\n swizzle: 'g'\r\n },\r\n {\r\n id: 4,\r\n name: 'B',\r\n swizzle: 'b'\r\n },\r\n {\r\n id: 5,\r\n name: 'A',\r\n swizzle: 'a'\r\n },\r\n {\r\n id: 6,\r\n name: 'RGB',\r\n swizzle: 'rgb'\r\n }\r\n ];\r\n this._inputs = [\r\n {\r\n id: 1,\r\n name: 'texture',\r\n type: ['tex2D', 'tex2DArray', 'texCube'],\r\n required: true\r\n },\r\n {\r\n id: 2,\r\n name: 'coord',\r\n type: ['vec2', 'vec3'],\r\n required: true\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Serializes the sampler type (Color or Normal).\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: TextureSampleNode,\r\n name: 'TextureSampleNode',\r\n getProps(): PropertyAccessor<TextureSampleNode>[] {\r\n return defineProps([\r\n {\r\n name: 'SamplerType',\r\n type: 'string',\r\n options: {\r\n enum: {\r\n labels: ['Color', 'Normal'],\r\n values: ['Color', 'Normal']\r\n }\r\n },\r\n get(this: TextureSampleNode, value) {\r\n value.str[0] = this.samplerType;\r\n },\r\n set(this: TextureSampleNode, value) {\r\n this.samplerType = value.str[0] as any;\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n }\r\n /**\r\n * Generates a string representation of this node\r\n *\r\n * @returns 'textureSample'\r\n */\r\n toString(): string {\r\n return 'textureSample';\r\n }\r\n /**\r\n * Validates the node state and input type compatibility\r\n *\r\n * @returns Error message if invalid, empty string if valid\r\n *\r\n * @remarks\r\n * Validation ensures:\r\n * - Both inputs are connected\r\n * - Texture input is a valid texture type\r\n * - Coordinate input matches texture dimensionality:\r\n * - tex2D requires vec2\r\n * - tex2DArray requires vec3 (u, v, layer)\r\n * - texCube requires vec3 (direction)\r\n */\r\n protected validate(): string {\r\n const err = super.validate();\r\n if (err) {\r\n return err;\r\n }\r\n const type0 = this._inputs[0].inputNode!.getOutputType(this._inputs[0].inputId!);\r\n if (!type0) {\r\n return `Cannot determine type of argument \\`${this._inputs[0].name}\\``;\r\n }\r\n if (!this._inputs[0].type.includes(type0)) {\r\n return `Invalid input type of argument \\`${this._inputs[0].name}\\`: ${type0}`;\r\n }\r\n const type1 = this._inputs[1].inputNode!.getOutputType(this._inputs[1].inputId!);\r\n if (!type1) {\r\n return `Cannot determine type of argument \\`${this._inputs[1].name}\\``;\r\n }\r\n const expectedType1 = type0 === 'tex2D' ? 'vec2' : 'vec3';\r\n if (type1 !== expectedType1) {\r\n return `Texture coordinate type should be ${expectedType1}`;\r\n }\r\n return '';\r\n }\r\n /**\r\n * Gets the output type\r\n */\r\n protected getType(id: number) {\r\n const err = this.validate();\r\n if (err) {\r\n return '';\r\n }\r\n if (id === 1) {\r\n return 'vec4';\r\n } else if (id === 6) {\r\n return 'vec3';\r\n } else {\r\n return 'float';\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Texture sampling with explicit gradients node\r\n *\r\n * @remarks\r\n * Samples a texture using explicitly provided screen-space gradients (derivatives)\r\n * instead of automatically computed ones. This allows precise control over mipmap\r\n * level selection and can be used for advanced effects.\r\n *\r\n * Use cases:\r\n * - Manual mipmap level control\r\n * - Sampling in non-fragment shaders (where automatic derivatives aren't available)\r\n * - Custom anisotropic filtering\r\n * - Texture sampling in control flow that breaks derivatives\r\n * - Advanced procedural effects\r\n *\r\n * Note: The current implementation appears identical to TextureSampleNode.\r\n * Full gradient support would require additional inputs for dPdx and dPdy.\r\n *\r\n * Inputs:\r\n * - Input 1: Texture sampler (tex2D, tex2DArray, or texCube)\r\n * - Input 2: Texture coordinates (vec2 or vec3)\r\n *\r\n * Output:\r\n * - Output 1: Sampled color (vec4 RGBA)\r\n *\r\n * @public\r\n */\r\nexport class TextureSampleGrad extends BaseGraphNode {\r\n /** The type of sampling (Color or Normal) */\r\n samplerType: 'Color' | 'Normal';\r\n /**\r\n * Creates a new texture sample with gradients node\r\n *\r\n * @remarks\r\n * Initializes with:\r\n * - Two required inputs (texture and coordinates)\r\n * - One output (sampled color)\r\n * - Color sampler type by default\r\n *\r\n * TODO: Add gradient inputs (dPdx, dPdy) for full explicit gradient support\r\n */\r\n constructor() {\r\n super();\r\n this.samplerType = 'Color';\r\n this._outputs = [\r\n {\r\n id: 1,\r\n name: ''\r\n }\r\n ];\r\n this._inputs = [\r\n {\r\n id: 1,\r\n name: 'texture',\r\n type: ['tex2D', 'tex2DArray', 'texCube'],\r\n required: true\r\n },\r\n {\r\n id: 2,\r\n name: 'coord',\r\n type: ['vec2', 'vec3'],\r\n required: true\r\n }\r\n ];\r\n }\r\n /**\r\n * Gets the serialization descriptor for this node type\r\n *\r\n * @returns Serialization class descriptor\r\n *\r\n * @remarks\r\n * Currently returns TextureSampleNode serialization (likely needs separate class).\r\n */\r\n static getSerializationCls(): SerializableClass {\r\n return {\r\n ctor: TextureSampleNode,\r\n name: 'TextureSampleNode',\r\n getProps(): PropertyAccessor<TextureSampleNode>[] {\r\n return defineProps([\r\n {\r\n name: 'SamplerType',\r\n type: 'string',\r\n options: {\r\n enum: {\r\n labels: ['Color', 'Normal'],\r\n values: ['Color', 'Normal']\r\n }\r\n },\r\n get(this: TextureSampleNode, value) {\r\n value.str[0] = this.samplerType;\r\n },\r\n set(this: TextureSampleNode, value) {\r\n this.samplerType = value.str[0] as any;\r\n }\r\n }\r\n ]);\r\n }\r\n };\r\n }\r\n /**\r\n * Generates a string representation of this node\r\n *\r\n * @returns 'textureSample'\r\n */\r\n toString(): string {\r\n return 'textureSample';\r\n }\r\n /**\r\n * Validates the node state and input type compatibility\r\n *\r\n * @returns Error message if invalid, empty string if valid\r\n *\r\n * @remarks\r\n * Validation ensures:\r\n * - Both inputs are connected\r\n * - Texture input is a valid texture type\r\n * - Coordinate input matches texture dimensionality\r\n */\r\n protected validate(): string {\r\n const err = super.validate();\r\n if (err) {\r\n return err;\r\n }\r\n const type0 = this._inputs[0].inputNode!.getOutputType(this._inputs[0].inputId!);\r\n if (!type0) {\r\n return `Cannot determine type of argument \\`${this._inputs[0].name}\\``;\r\n }\r\n if (!this._inputs[0].type.includes(type0)) {\r\n return `Invalid input type of argument \\`${this._inputs[0].name}\\`: ${type0}`;\r\n }\r\n const type1 = this._inputs[1].inputNode!.getOutputType(this._inputs[1].inputId!);\r\n if (!type1) {\r\n return `Cannot determine type of argument \\`${this._inputs[1].name}\\``;\r\n }\r\n const expectedType1 = type0 === 'tex2D' ? 'vec2' : 'vec3';\r\n if (type1 !== expectedType1) {\r\n return `Texture coordinate type should be ${expectedType1}`;\r\n }\r\n return '';\r\n }\r\n /**\r\n * Gets the output type\r\n *\r\n * @returns 'vec4' (RGBA color)\r\n */\r\n protected getType(): string {\r\n return 'vec4';\r\n }\r\n}\r\n"],"names":["defaultTexture2D","DRef","defaultTextureCube","defaultTexture2DArray","getDefaultTexture2D","get","defaultTex","getDevice","createTexture2D","mipmapping","update","Uint8Array","set","getDefaultTexture2DArray","createTexture2DArray","getDefaultTextureCube","createCubeTexture","i","textureNodeProps","getTextureNodeProps","defineProps","name","type","isNullable","value","str","paramName","slice","test","console","log","default","bool","sRGB","options","enum","labels","values","addressU","addressV","filterMin","filterMag","filterMip","BaseTextureNode","BaseGraphNode","textureId","_paramName","getParamName","val","dispatchEvent","isUniform","toString","ConstantTexture2DNode","_outputs","id","getSerializationCls","ctor","noTitle","getProps","mimeTypes","validate","ConstantTexture2DArrayNode","ConstantTextureCubeNode","_inputs","TextureSampleNode","samplerType","swizzle","required","err","type0","inputNode","getOutputType","inputId","includes","type1","expectedType1","getType","TextureSampleGrad"],"mappings":";;;;;;AAaA;;;IAIA,MAAMA,mBAAoC,IAAIC,IAAAA,EAAAA;AAE9C;;;IAIA,MAAMC,qBAAwC,IAAID,IAAAA,EAAAA;AAElD;;;IAIA,MAAME,wBAA8C,IAAIF,IAAAA,EAAAA;AAExD;;;;;;;;;;AAUC,IACM,SAASG,mBAAAA,GAAAA;IACd,IAAI,CAACJ,gBAAiBK,CAAAA,GAAG,EAAI,EAAA;AAC3B,QAAA,MAAMC,aAAaC,SAAYC,EAAAA,CAAAA,eAAe,CAAC,YAAA,EAAc,GAAG,CAAG,EAAA;YACjEC,UAAY,EAAA;AACd,SAAA,CAAA;QACAH,UAAWI,CAAAA,MAAM,CAAC,IAAIC,UAAW,CAAA;AAAC,YAAA,GAAA;AAAK,YAAA,GAAA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O,CAAC,CAAA,CAAE,CAAC1C,IAAI,CAAC,EAAE,CAAC;AACxE;QACA,IAAI,CAAC,IAAI,CAAC0C,OAAO,CAAC,CAAE,CAAA,CAACzC,IAAI,CAACmD,QAAQ,CAACJ,KAAQ,CAAA,EAAA;AACzC,YAAA,OAAO,CAAC,iCAAiC,EAAE,IAAI,CAACN,OAAO,CAAC,CAAA,CAAE,CAAC1C,IAAI,CAAC,IAAI,EAAEgD,KAAO,CAAA,CAAA;AAC/E;AACA,QAAA,MAAMK,QAAQ,IAAI,CAACX,OAAO,CAAC,EAAE,CAACO,SAAS,CAAEC,aAAa,CAAC,IAAI,CAACR,OAAO,CAAC,CAAA,CAAE,CAACS,OAAO,CAAA;AAC9E,QAAA,IAAI,CAACE,KAAO,EAAA;AACV,YAAA,OAAO,CAAC,oCAAoC,EAAE,IAAI,CAACX,OAAO,CAAC,CAAA,CAAE,CAAC1C,IAAI,CAAC,EAAE,CAAC;AACxE;QACA,MAAMsD,aAAAA,GAAgBN,KAAU,KAAA,OAAA,GAAU,MAAS,GAAA,MAAA;AACnD,QAAA,IAAIK,UAAUC,aAAe,EAAA;YAC3B,OAAO,CAAC,kCAAkC,EAAEA,aAAe,CAAA,CAAA;AAC7D;QACA,OAAO,EAAA;AACT;AACA;;;;AAIC,MACD,OAA4B,GAAA;QAC1B,OAAO,MAAA;AACT;AACF;;;;"}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { Observable } from '@zephyr3d/base';
|
|
2
2
|
|
|
3
|
+
/** @internal */ function getNodeTypeComponents(type) {
|
|
4
|
+
switch(type){
|
|
5
|
+
case 'float':
|
|
6
|
+
case 'bool':
|
|
7
|
+
return 1;
|
|
8
|
+
case 'vec2':
|
|
9
|
+
case 'bvec2':
|
|
10
|
+
return 2;
|
|
11
|
+
case 'vec3':
|
|
12
|
+
case 'bvec3':
|
|
13
|
+
return 3;
|
|
14
|
+
case 'vec4':
|
|
15
|
+
case 'bvec4':
|
|
16
|
+
return 4;
|
|
17
|
+
default:
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
3
21
|
/**
|
|
4
22
|
* Abstract base class for graph nodes
|
|
5
23
|
*
|
|
@@ -178,10 +196,19 @@ import { Observable } from '@zephyr3d/base';
|
|
|
178
196
|
if (input.required && !input.inputNode) {
|
|
179
197
|
return `Missing required argument: input[${i}]`;
|
|
180
198
|
}
|
|
199
|
+
if (input.inputNode) {
|
|
200
|
+
const type = this._inputs[i].inputNode.getOutputType(this._inputs[i].inputId);
|
|
201
|
+
if (!type) {
|
|
202
|
+
return `Cannot determine type of argument ${i}`;
|
|
203
|
+
}
|
|
204
|
+
if (!this._inputs[i].type.includes(type)) {
|
|
205
|
+
return `Invalid input type ${type} for argument ${i}`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
181
208
|
}
|
|
182
209
|
return '';
|
|
183
210
|
}
|
|
184
211
|
}
|
|
185
212
|
|
|
186
|
-
export { BaseGraphNode };
|
|
213
|
+
export { BaseGraphNode, getNodeTypeComponents };
|
|
187
214
|
//# sourceMappingURL=node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sources":["../../../src/utility/blueprint/node.ts"],"sourcesContent":["import { Observable, type IEventTarget } from '@zephyr3d/base';\r\n\r\n/**\r\n * Represents a connection between two nodes\r\n *\r\n * @remarks\r\n * Defines the complete information for connecting from an output slot of one node\r\n * to an input slot of another node.\r\n *\r\n * @example\r\n * ```typescript\r\n * const connection: NodeConnection = {\r\n * targetNodeId: 42,\r\n * startSlotId: 0, // Output slot of source node\r\n * endSlotId: 1 // Input slot of target node\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport interface NodeConnection {\r\n targetNodeId: number;\r\n startSlotId: number;\r\n endSlotId: number;\r\n}\r\n\r\n/**\r\n * Adjacency list representation of the graph structure\r\n *\r\n * @remarks\r\n * Uses forward and backward adjacency lists to efficiently store and query\r\n * connections between nodes:\r\n * - Forward adjacency list for finding all output connections from a node\r\n * - Backward adjacency list for finding all input connections to a node\r\n *\r\n * @public\r\n */\r\nexport interface GraphStructure {\r\n /**\r\n * Forward adjacency list: nodeId -\\> all output connections from this node\r\n * @remarks Used to quickly find which nodes a given node connects to\r\n */\r\n outgoing: Record<number, NodeConnection[]>;\r\n /**\r\n * Backward adjacency list: nodeId -\\> all input connections to this node\r\n * @remarks Used to quickly find which nodes provide data to a given node\r\n */\r\n incoming: Record<number, NodeConnection[]>;\r\n}\r\n\r\n/**\r\n * Complete representation of a Blueprint Directed Acyclic Graph (DAG)\r\n *\r\n * @remarks\r\n * Contains all structural information of the node graph:\r\n * - Node mapping table\r\n * - Root nodes list (nodes with no inputs)\r\n * - Graph structure (adjacency lists)\r\n * - Topological sort order (for executing nodes in dependency order)\r\n *\r\n * @example\r\n * ```typescript\r\n * const dag: BlueprintDAG = {\r\n * nodeMap: { 1: node1, 2: node2, 3: node3 },\r\n * roots: [1], // node1 is a root node\r\n * graph: { outgoing: {...}, incoming: {...} },\r\n * order: [1, 2, 3] // Topological sort result\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport interface BlueprintDAG {\r\n /** Mapping from node ID to node instance */\r\n nodeMap: Record<number, IGraphNode>;\r\n /**\r\n * List of root node IDs\r\n * @remarks Root nodes are nodes with no input connections, typically constants or parameter nodes\r\n */\r\n roots: number[];\r\n /** The adjacency list structure of the graph */\r\n graph: GraphStructure;\r\n /**\r\n * Topological sort order of nodes\r\n * @remarks List of node IDs sorted by dependency relationships, used for correct execution order\r\n */\r\n order: number[];\r\n}\r\n\r\n/**\r\n * Input slot definition for a graph node\r\n *\r\n * @remarks\r\n * Describes an input connection point on a node, including its type constraints,\r\n * connected source node, default value, and validation requirements.\r\n *\r\n * @example\r\n * ```typescript\r\n * const input: GraphNodeInput = {\r\n * id: 0,\r\n * name: 'value',\r\n * type: ['float', 'vec2', 'vec3'], // Accepts multiple types\r\n * required: true,\r\n * defaultValue: 0.0\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport type GraphNodeInput = {\r\n /** Unique identifier for this input slot */\r\n id: number;\r\n /** Display name of the input */\r\n name: string;\r\n /**\r\n * Array of accepted type names\r\n * @remarks Multiple types indicate the input can accept any of these types\r\n */\r\n type: string[];\r\n /**\r\n * The source node connected to this input\r\n * @remarks Undefined if no connection exists\r\n */\r\n inputNode?: IGraphNode;\r\n /**\r\n * The output slot ID of the connected source node\r\n * @remarks Only valid when inputNode is defined\r\n */\r\n inputId?: number;\r\n /**\r\n * Default value when no connection exists\r\n * @remarks Can be a single number or an array of numbers for vector types\r\n */\r\n defaultValue?: number[] | number;\r\n /**\r\n * Whether this input must be connected\r\n * @remarks If true, validation will fail if no connection exists\r\n * @defaultValue false\r\n */\r\n required?: boolean;\r\n /**\r\n * Original type name before any type casting\r\n * @remarks Used for tracking type conversions and compatibility checking\r\n */\r\n originType?: string;\r\n};\r\n\r\n/**\r\n * Output slot definition for a graph node\r\n *\r\n * @remarks\r\n * Describes an output connection point on a node, including optional swizzling\r\n * and type casting information.\r\n *\r\n * @example\r\n * ```typescript\r\n * const output: GraphNodeOutput = {\r\n * id: 0,\r\n * name: 'result',\r\n * swizzle: 'xyz', // Extract only xyz components from a vec4\r\n * cast: 2 // Cast to type at index 2\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport type GraphNodeOutput = {\r\n /** Unique identifier for this output slot */\r\n id: number;\r\n /** Display name of the output */\r\n name: string;\r\n /**\r\n * Swizzle mask for vector component extraction\r\n * @remarks E.g., 'xyz', 'xy', 'r', 'rgba' for accessing specific components\r\n * @example 'xyz' extracts first 3 components from vec4\r\n */\r\n swizzle?: string;\r\n /**\r\n * Type cast index\r\n * @remarks Index into a type array for automatic type conversion\r\n */\r\n cast?: number;\r\n};\r\n\r\n/**\r\n * Interface for a graph node in the material blueprint system\r\n *\r\n * @remarks\r\n * Defines the contract that all graph nodes must implement, including:\r\n * - Input and output slot management\r\n * - Type information retrieval\r\n * - Error state tracking\r\n * - Validation logic\r\n * - Change notification through events\r\n *\r\n * @example\r\n * ```typescript\r\n * class AddNode implements IGraphNode {\r\n * readonly inputs = [\r\n * { id: 0, name: 'a', type: ['float'] },\r\n * { id: 1, name: 'b', type: ['float'] }\r\n * ];\r\n * readonly outputs = [\r\n * { id: 0, name: 'result' }\r\n * ];\r\n * // ... implement other methods\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport interface IGraphNode extends IEventTarget<{ changed: [] }> {\r\n /** Array of input slot definitions */\r\n readonly inputs: GraphNodeInput[];\r\n /** Array of output slot definitions */\r\n readonly outputs: GraphNodeOutput[];\r\n /** Whether this node has uniform value */\r\n isUniform: boolean;\r\n /** Uniform parameter name */\r\n paramName: string;\r\n /** Current error message, empty string if no error */\r\n error: string;\r\n /**\r\n * Gets the output type for a specific output slot\r\n *\r\n * @param id - The output slot ID\r\n * @returns The type name of the output (e.g., 'float', 'vec3', 'mat4')\r\n *\r\n * @example\r\n * ```typescript\r\n * const outputType = node.getOutputType(0); // 'vec3'\r\n * ```\r\n */\r\n getOutputType(id: number): string;\r\n /**\r\n * Generates a string representation of the node\r\n *\r\n * @remarks\r\n * Typically used for code generation or debugging purposes.\r\n * Should return valid shader code or a meaningful description.\r\n *\r\n * @returns String representation of the node's operation\r\n *\r\n * @example\r\n * ```typescript\r\n * node.toString(); // Returns: \"float result = a + b;\"\r\n * ```\r\n */\r\n toString(): string;\r\n /**\r\n * Validates the node's current state\r\n *\r\n * @remarks\r\n * Checks if all required inputs are connected and if type constraints are satisfied.\r\n * Sets the `error` property if validation fails.\r\n * Should be called after any connection changes.\r\n *\r\n * @example\r\n * ```typescript\r\n * node.check();\r\n * if (node.error) {\r\n * console.error('Validation failed:', node.error);\r\n * }\r\n * ```\r\n */\r\n check(): void;\r\n /**\r\n * Resets the node's error state\r\n *\r\n * @remarks\r\n * Clears any error messages. Typically called before revalidation.\r\n */\r\n reset(): void;\r\n}\r\n\r\n/**\r\n * Abstract base class for graph nodes\r\n *\r\n * @remarks\r\n * Provides common functionality for all graph node types:\r\n * - Input/output slot storage\r\n * - Error state management\r\n * - Basic validation logic\r\n * - Change event emission\r\n *\r\n * Subclasses must implement:\r\n * - `getType()`: Define output type logic\r\n * - Optionally override `validate()` for custom validation\r\n * - Optionally override `toString()` for code generation\r\n *\r\n * @example\r\n * ```typescript\r\n * class MultiplyNode extends BaseGraphNode {\r\n * constructor() {\r\n * super();\r\n * this._inputs = [\r\n * { id: 0, name: 'a', type: ['float', 'vec2', 'vec3'], required: true },\r\n * { id: 1, name: 'b', type: ['float', 'vec2', 'vec3'], required: true }\r\n * ];\r\n * this._outputs = [\r\n * { id: 0, name: 'result' }\r\n * ];\r\n * }\r\n *\r\n * protected getType(id?: number): string {\r\n * // Return type based on input types\r\n * return this._inputs[0].inputNode?.getOutputType(0) ?? 'float';\r\n * }\r\n *\r\n * toString(): string {\r\n * return `${this.getType()} result = a * b;`;\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport abstract class BaseGraphNode extends Observable<{ changed: [] }> implements IGraphNode {\r\n /** Internal storage for input slot definitions */\r\n protected _inputs: GraphNodeInput[];\r\n /** Internal storage for output slot definitions */\r\n protected _outputs: GraphNodeOutput[];\r\n /** Internal storage for error message */\r\n protected _error: string;\r\n /**\r\n * Creates a new BaseGraphNode instance\r\n *\r\n * @remarks\r\n * Initializes empty input/output arrays and error state.\r\n * Subclasses should populate `_inputs` and `_outputs` in their constructor.\r\n */\r\n constructor() {\r\n super();\r\n this._inputs = [];\r\n this._outputs = [];\r\n this._error = '';\r\n }\r\n /**\r\n * Whether this node contains uniform value/texture\r\n */\r\n get isUniform() {\r\n return false;\r\n }\r\n /**\r\n * Uniform parameter name\r\n */\r\n get paramName() {\r\n return '';\r\n }\r\n /**\r\n * Gets the output type for a specific output slot\r\n *\r\n * @param id - The output slot ID\r\n * @returns The type name of the output\r\n *\r\n * @remarks\r\n * Default implementation delegates to the abstract `getType()` method.\r\n * Can be overridden for more complex type logic.\r\n */\r\n getOutputType(id: number) {\r\n return this.getType(id);\r\n }\r\n /** Gets the input slot definitions array */\r\n get inputs() {\r\n return this._inputs;\r\n }\r\n /** Gets the output slot definitions array */\r\n get outputs() {\r\n return this._outputs;\r\n }\r\n /** Gets the current error message */\r\n get error() {\r\n return this._error;\r\n }\r\n set error(str: string) {\r\n this._error = str;\r\n }\r\n /**\r\n * Generates a string representation of the node\r\n *\r\n * @returns Empty string by default\r\n *\r\n * @remarks\r\n * Subclasses should override this to return valid shader code\r\n * or a meaningful description of the node's operation.\r\n */\r\n toString() {\r\n return '';\r\n }\r\n /**\r\n * Validates the node and updates error state\r\n *\r\n * @remarks\r\n * Calls the `validate()` method and stores the result in `_error`.\r\n * Emits a 'changed' event if the error state changes.\r\n */\r\n check() {\r\n this._error = this.validate();\r\n }\r\n /**\r\n * Clears the error state\r\n *\r\n * @remarks\r\n * Sets `_error` to an empty string.\r\n */\r\n reset() {\r\n this._error = '';\r\n }\r\n /**\r\n * Connects an input slot to another node's output\r\n *\r\n * @param id - The input slot ID to connect\r\n * @param node - The source node to connect from\r\n * @param inputId - The output slot ID of the source node\r\n *\r\n * @throws Error if the input slot with the given ID doesn't exist\r\n *\r\n * @example\r\n * ```typescript\r\n * const addNode = new AddNode();\r\n * const constantNode = new ConstantNode(5.0);\r\n *\r\n * // Connect constantNode's output 0 to addNode's input 0\r\n * addNode.setInput(0, constantNode, 0);\r\n * ```\r\n */\r\n setInput(id: number, node: BaseGraphNode, inputId: number) {\r\n const input = this._inputs.find((input) => input.id === id);\r\n if (!input) {\r\n throw new Error(`Input with id ${id} not found`);\r\n }\r\n input.inputNode = node;\r\n input.inputId = inputId;\r\n }\r\n /**\r\n * Gets the type name for a specific output slot\r\n *\r\n * @param _id - The output slot ID (optional)\r\n * @returns The type name (e.g., 'float', 'vec3', 'mat4')\r\n *\r\n * @remarks\r\n * Must be implemented by subclasses to define type resolution logic.\r\n * The type may depend on connected input types.\r\n *\r\n * @example\r\n * ```typescript\r\n * protected getType(_id?: number): string {\r\n * // Return type based on first input\r\n * const inputType = this._inputs[0]?.inputNode?.getOutputType(this._inputs[0].inputId ?? 0);\r\n * return inputType ?? 'float';\r\n * }\r\n * ```\r\n */\r\n protected abstract getType(_id?: number): string;\r\n /**\r\n * Validates the node's current state\r\n *\r\n * @returns Error message string, or empty string if valid\r\n *\r\n * @remarks\r\n * Default implementation checks if all required inputs are connected.\r\n * Subclasses can override to add custom validation logic like:\r\n * - Type compatibility checking\r\n * - Value range validation\r\n * - Configuration validation\r\n *\r\n * @example\r\n * ```typescript\r\n * protected validate(): string {\r\n * const baseError = super.validate();\r\n * if (baseError) return baseError;\r\n *\r\n * // Custom validation\r\n * const type1 = this._inputs[0].inputNode?.getOutputType(0);\r\n * const type2 = this._inputs[1].inputNode?.getOutputType(0);\r\n * if (type1 !== type2) {\r\n * return 'Input types must match';\r\n * }\r\n *\r\n * return '';\r\n * }\r\n * ```\r\n */\r\n protected validate(): string {\r\n for (let i = 0; i < this._inputs.length; i++) {\r\n const input = this._inputs[i];\r\n if (input.required && !input.inputNode) {\r\n return `Missing required argument: input[${i}]`;\r\n }\r\n }\r\n return '';\r\n }\r\n}\r\n"],"names":["BaseGraphNode","Observable","_inputs","_outputs","_error","isUniform","paramName","getOutputType","id","getType","inputs","outputs","error","str","toString","check","validate","reset","setInput","node","inputId","input","find","Error","inputNode","i","length","required"],"mappings":";;AAmRA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0CO,MAAeA,aAAsBC,SAAAA,UAAAA,CAAAA;uDAE1C,OAAoC;wDAEpC,QAAsC;8CAEtC,MAAyB;AACzB;;;;;;AAMC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;QACL,IAAI,CAACC,OAAO,GAAG,EAAE;QACjB,IAAI,CAACC,QAAQ,GAAG,EAAE;QAClB,IAAI,CAACC,MAAM,GAAG,EAAA;AAChB;AACA;;AAEC,MACD,IAAIC,SAAY,GAAA;QACd,OAAO,KAAA;AACT;AACA;;A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IAAI,CAACvB,OAAO,CAACwB,MAAM,EAAED,CAAK,EAAA,CAAA;AAC5C,YAAA,MAAMJ,KAAQ,GAAA,IAAI,CAACnB,OAAO,CAACuB,CAAE,CAAA;AAC7B,YAAA,IAAIJ,MAAMM,QAAQ,IAAI,CAACN,KAAAA,CAAMG,SAAS,EAAE;AACtC,gBAAA,OAAO,CAAC,iCAAiC,EAAEC,CAAAA,CAAE,CAAC,CAAC;AACjD;AACF;QACA,OAAO,EAAA;AACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"node.js","sources":["../../../src/utility/blueprint/node.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { Observable, type IEventTarget } from '@zephyr3d/base';\r\n\r\n/** @internal */\r\nexport function getNodeTypeComponents(type: string) {\r\n switch (type) {\r\n case 'float':\r\n case 'bool':\r\n return 1;\r\n case 'vec2':\r\n case 'bvec2':\r\n return 2;\r\n case 'vec3':\r\n case 'bvec3':\r\n return 3;\r\n case 'vec4':\r\n case 'bvec4':\r\n return 4;\r\n default:\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Represents a connection between two nodes\r\n *\r\n * @remarks\r\n * Defines the complete information for connecting from an output slot of one node\r\n * to an input slot of another node.\r\n *\r\n * @example\r\n * ```typescript\r\n * const connection: NodeConnection = {\r\n * targetNodeId: 42,\r\n * startSlotId: 0, // Output slot of source node\r\n * endSlotId: 1 // Input slot of target node\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport interface NodeConnection {\r\n targetNodeId: number;\r\n startSlotId: number;\r\n endSlotId: number;\r\n}\r\n\r\n/**\r\n * Adjacency list representation of the graph structure\r\n *\r\n * @remarks\r\n * Uses forward and backward adjacency lists to efficiently store and query\r\n * connections between nodes:\r\n * - Forward adjacency list for finding all output connections from a node\r\n * - Backward adjacency list for finding all input connections to a node\r\n *\r\n * @public\r\n */\r\nexport interface GraphStructure {\r\n /**\r\n * Forward adjacency list: nodeId -\\> all output connections from this node\r\n * @remarks Used to quickly find which nodes a given node connects to\r\n */\r\n outgoing: Record<number, NodeConnection[]>;\r\n /**\r\n * Backward adjacency list: nodeId -\\> all input connections to this node\r\n * @remarks Used to quickly find which nodes provide data to a given node\r\n */\r\n incoming: Record<number, NodeConnection[]>;\r\n}\r\n\r\n/**\r\n * Complete representation of a Blueprint Directed Acyclic Graph (DAG)\r\n *\r\n * @remarks\r\n * Contains all structural information of the node graph:\r\n * - Node mapping table\r\n * - Root nodes list (nodes with no inputs)\r\n * - Graph structure (adjacency lists)\r\n * - Topological sort order (for executing nodes in dependency order)\r\n *\r\n * @example\r\n * ```typescript\r\n * const dag: BlueprintDAG = {\r\n * nodeMap: { 1: node1, 2: node2, 3: node3 },\r\n * roots: [1], // node1 is a root node\r\n * graph: { outgoing: {...}, incoming: {...} },\r\n * order: [1, 2, 3] // Topological sort result\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport interface BlueprintDAG {\r\n /** Mapping from node ID to node instance */\r\n nodeMap: Record<number, IGraphNode>;\r\n /**\r\n * List of root node IDs\r\n * @remarks Root nodes are nodes with no input connections, typically constants or parameter nodes\r\n */\r\n roots: number[];\r\n /** The adjacency list structure of the graph */\r\n graph: GraphStructure;\r\n /**\r\n * Topological sort order of nodes\r\n * @remarks List of node IDs sorted by dependency relationships, used for correct execution order\r\n */\r\n order: number[];\r\n}\r\n\r\n/**\r\n * Input slot definition for a graph node\r\n *\r\n * @remarks\r\n * Describes an input connection point on a node, including its type constraints,\r\n * connected source node, default value, and validation requirements.\r\n *\r\n * @example\r\n * ```typescript\r\n * const input: GraphNodeInput = {\r\n * id: 0,\r\n * name: 'value',\r\n * type: ['float', 'vec2', 'vec3'], // Accepts multiple types\r\n * required: true,\r\n * defaultValue: 0.0\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport type GraphNodeInput = {\r\n /** Unique identifier for this input slot */\r\n id: number;\r\n /** Display name of the input */\r\n name: string;\r\n /**\r\n * Array of accepted type names\r\n * @remarks Multiple types indicate the input can accept any of these types\r\n */\r\n type: string[];\r\n /**\r\n * The source node connected to this input\r\n * @remarks Undefined if no connection exists\r\n */\r\n inputNode?: Nullable<IGraphNode>;\r\n /**\r\n * The output slot ID of the connected source node\r\n * @remarks Only valid when inputNode is defined\r\n */\r\n inputId?: Nullable<number>;\r\n /**\r\n * Default value when no connection exists\r\n * @remarks Can be a single number or an array of numbers for vector types\r\n */\r\n defaultValue?: number[];\r\n /**\r\n * Whether this input must be connected\r\n * @remarks If true, validation will fail if no connection exists\r\n * @defaultValue false\r\n */\r\n required?: boolean;\r\n /**\r\n * Original type name before any type casting\r\n * @remarks Used for tracking type conversions and compatibility checking\r\n */\r\n originType?: string;\r\n};\r\n\r\n/**\r\n * Output slot definition for a graph node\r\n *\r\n * @remarks\r\n * Describes an output connection point on a node, including optional swizzling\r\n * and type casting information.\r\n *\r\n * @example\r\n * ```typescript\r\n * const output: GraphNodeOutput = {\r\n * id: 0,\r\n * name: 'result',\r\n * swizzle: 'xyz', // Extract only xyz components from a vec4\r\n * cast: 2 // Cast to type at index 2\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport type GraphNodeOutput = {\r\n /** Unique identifier for this output slot */\r\n id: number;\r\n /** Display name of the output */\r\n name: string;\r\n /**\r\n * Swizzle mask for vector component extraction\r\n * @remarks E.g., 'xyz', 'xy', 'r', 'rgba' for accessing specific components\r\n * @example 'xyz' extracts first 3 components from vec4\r\n */\r\n swizzle?: string;\r\n};\r\n\r\n/**\r\n * Interface for a graph node in the material blueprint system\r\n *\r\n * @remarks\r\n * Defines the contract that all graph nodes must implement, including:\r\n * - Input and output slot management\r\n * - Type information retrieval\r\n * - Error state tracking\r\n * - Validation logic\r\n * - Change notification through events\r\n *\r\n * @example\r\n * ```typescript\r\n * class AddNode implements IGraphNode {\r\n * readonly inputs = [\r\n * { id: 0, name: 'a', type: ['float'] },\r\n * { id: 1, name: 'b', type: ['float'] }\r\n * ];\r\n * readonly outputs = [\r\n * { id: 0, name: 'result' }\r\n * ];\r\n * // ... implement other methods\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport interface IGraphNode extends IEventTarget<{ changed: [] }> {\r\n /** Array of input slot definitions */\r\n readonly inputs: GraphNodeInput[];\r\n /** Array of output slot definitions */\r\n readonly outputs: GraphNodeOutput[];\r\n /** Whether this node has uniform value */\r\n isUniform: boolean;\r\n /** Uniform parameter name */\r\n paramName: string;\r\n /** Current error message, empty string if no error */\r\n error: string;\r\n /**\r\n * Gets the output type for a specific output slot\r\n *\r\n * @param id - The output slot ID\r\n * @returns The type name of the output (e.g., 'float', 'vec3', 'mat4')\r\n *\r\n * @example\r\n * ```typescript\r\n * const outputType = node.getOutputType(0); // 'vec3'\r\n * ```\r\n */\r\n getOutputType(id: number): string;\r\n /**\r\n * Generates a string representation of the node\r\n *\r\n * @remarks\r\n * Typically used for code generation or debugging purposes.\r\n * Should return valid shader code or a meaningful description.\r\n *\r\n * @returns String representation of the node's operation\r\n *\r\n * @example\r\n * ```typescript\r\n * node.toString(); // Returns: \"float result = a + b;\"\r\n * ```\r\n */\r\n toString(): string;\r\n /**\r\n * Validates the node's current state\r\n *\r\n * @remarks\r\n * Checks if all required inputs are connected and if type constraints are satisfied.\r\n * Sets the `error` property if validation fails.\r\n * Should be called after any connection changes.\r\n *\r\n * @example\r\n * ```typescript\r\n * node.check();\r\n * if (node.error) {\r\n * console.error('Validation failed:', node.error);\r\n * }\r\n * ```\r\n */\r\n check(): void;\r\n /**\r\n * Resets the node's error state\r\n *\r\n * @remarks\r\n * Clears any error messages. Typically called before revalidation.\r\n */\r\n reset(): void;\r\n}\r\n\r\n/**\r\n * Abstract base class for graph nodes\r\n *\r\n * @remarks\r\n * Provides common functionality for all graph node types:\r\n * - Input/output slot storage\r\n * - Error state management\r\n * - Basic validation logic\r\n * - Change event emission\r\n *\r\n * Subclasses must implement:\r\n * - `getType()`: Define output type logic\r\n * - Optionally override `validate()` for custom validation\r\n * - Optionally override `toString()` for code generation\r\n *\r\n * @example\r\n * ```typescript\r\n * class MultiplyNode extends BaseGraphNode {\r\n * constructor() {\r\n * super();\r\n * this._inputs = [\r\n * { id: 0, name: 'a', type: ['float', 'vec2', 'vec3'], required: true },\r\n * { id: 1, name: 'b', type: ['float', 'vec2', 'vec3'], required: true }\r\n * ];\r\n * this._outputs = [\r\n * { id: 0, name: 'result' }\r\n * ];\r\n * }\r\n *\r\n * protected getType(id?: number): string {\r\n * // Return type based on input types\r\n * return this._inputs[0].inputNode?.getOutputType(0) ?? 'float';\r\n * }\r\n *\r\n * toString(): string {\r\n * return `${this.getType()} result = a * b;`;\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport abstract class BaseGraphNode extends Observable<{ changed: [] }> implements IGraphNode {\r\n /** Internal storage for input slot definitions */\r\n protected _inputs: GraphNodeInput[];\r\n /** Internal storage for output slot definitions */\r\n protected _outputs: GraphNodeOutput[];\r\n /** Internal storage for error message */\r\n protected _error: string;\r\n /**\r\n * Creates a new BaseGraphNode instance\r\n *\r\n * @remarks\r\n * Initializes empty input/output arrays and error state.\r\n * Subclasses should populate `_inputs` and `_outputs` in their constructor.\r\n */\r\n constructor() {\r\n super();\r\n this._inputs = [];\r\n this._outputs = [];\r\n this._error = '';\r\n }\r\n /**\r\n * Whether this node contains uniform value/texture\r\n */\r\n get isUniform() {\r\n return false;\r\n }\r\n /**\r\n * Uniform parameter name\r\n */\r\n get paramName() {\r\n return '';\r\n }\r\n /**\r\n * Gets the output type for a specific output slot\r\n *\r\n * @param id - The output slot ID\r\n * @returns The type name of the output\r\n *\r\n * @remarks\r\n * Default implementation delegates to the abstract `getType()` method.\r\n * Can be overridden for more complex type logic.\r\n */\r\n getOutputType(id: number) {\r\n return this.getType(id);\r\n }\r\n /** Gets the input slot definitions array */\r\n get inputs() {\r\n return this._inputs;\r\n }\r\n /** Gets the output slot definitions array */\r\n get outputs() {\r\n return this._outputs;\r\n }\r\n /** Gets the current error message */\r\n get error() {\r\n return this._error;\r\n }\r\n set error(str: string) {\r\n this._error = str;\r\n }\r\n /**\r\n * Generates a string representation of the node\r\n *\r\n * @returns Empty string by default\r\n *\r\n * @remarks\r\n * Subclasses should override this to return valid shader code\r\n * or a meaningful description of the node's operation.\r\n */\r\n toString() {\r\n return '';\r\n }\r\n /**\r\n * Validates the node and updates error state\r\n *\r\n * @remarks\r\n * Calls the `validate()` method and stores the result in `_error`.\r\n * Emits a 'changed' event if the error state changes.\r\n */\r\n check() {\r\n this._error = this.validate();\r\n }\r\n /**\r\n * Clears the error state\r\n *\r\n * @remarks\r\n * Sets `_error` to an empty string.\r\n */\r\n reset() {\r\n this._error = '';\r\n }\r\n /**\r\n * Connects an input slot to another node's output\r\n *\r\n * @param id - The input slot ID to connect\r\n * @param node - The source node to connect from\r\n * @param inputId - The output slot ID of the source node\r\n *\r\n * @throws Error if the input slot with the given ID doesn't exist\r\n *\r\n * @example\r\n * ```typescript\r\n * const addNode = new AddNode();\r\n * const constantNode = new ConstantNode(5.0);\r\n *\r\n * // Connect constantNode's output 0 to addNode's input 0\r\n * addNode.setInput(0, constantNode, 0);\r\n * ```\r\n */\r\n setInput(id: number, node: BaseGraphNode, inputId: number) {\r\n const input = this._inputs.find((input) => input.id === id);\r\n if (!input) {\r\n throw new Error(`Input with id ${id} not found`);\r\n }\r\n input.inputNode = node;\r\n input.inputId = inputId;\r\n }\r\n /**\r\n * Gets the type name for a specific output slot\r\n *\r\n * @param _id - The output slot ID (optional)\r\n * @returns The type name (e.g., 'float', 'vec3', 'mat4')\r\n *\r\n * @remarks\r\n * Must be implemented by subclasses to define type resolution logic.\r\n * The type may depend on connected input types.\r\n *\r\n * @example\r\n * ```typescript\r\n * protected getType(_id?: number): string {\r\n * // Return type based on first input\r\n * const inputType = this._inputs[0]?.inputNode?.getOutputType(this._inputs[0].inputId ?? 0);\r\n * return inputType ?? 'float';\r\n * }\r\n * ```\r\n */\r\n protected abstract getType(_id?: number): string;\r\n /**\r\n * Validates the node's current state\r\n *\r\n * @returns Error message string, or empty string if valid\r\n *\r\n * @remarks\r\n * Default implementation checks if all required inputs are connected.\r\n * Subclasses can override to add custom validation logic like:\r\n * - Type compatibility checking\r\n * - Value range validation\r\n * - Configuration validation\r\n *\r\n * @example\r\n * ```typescript\r\n * protected validate(): string {\r\n * const baseError = super.validate();\r\n * if (baseError) return baseError;\r\n *\r\n * // Custom validation\r\n * const type1 = this._inputs[0].inputNode?.getOutputType(0);\r\n * const type2 = this._inputs[1].inputNode?.getOutputType(0);\r\n * if (type1 !== type2) {\r\n * return 'Input types must match';\r\n * }\r\n *\r\n * return '';\r\n * }\r\n * ```\r\n */\r\n protected validate() {\r\n for (let i = 0; i < this._inputs.length; i++) {\r\n const input = this._inputs[i];\r\n if (input.required && !input.inputNode) {\r\n return `Missing required argument: input[${i}]`;\r\n }\r\n if (input.inputNode) {\r\n const type = this._inputs[i].inputNode!.getOutputType(this._inputs[i].inputId!);\r\n if (!type) {\r\n return `Cannot determine type of argument ${i}`;\r\n }\r\n if (!this._inputs[i].type.includes(type)) {\r\n return `Invalid input type ${type} for argument ${i}`;\r\n }\r\n }\r\n }\r\n return '';\r\n }\r\n}\r\n"],"names":["getNodeTypeComponents","type","BaseGraphNode","Observable","_inputs","_outputs","_error","isUniform","paramName","getOutputType","id","getType","inputs","outputs","error","str","toString","check","validate","reset","setInput","node","inputId","input","find","Error","inputNode","i","length","required","includes"],"mappings":";;AAGA,iBACO,SAASA,qBAAAA,CAAsBC,IAAY,EAAA;IAChD,OAAQA,IAAAA;QACN,KAAK,OAAA;QACL,KAAK,MAAA;YACH,OAAO,CAAA;QACT,KAAK,MAAA;QACL,KAAK,OAAA;YACH,OAAO,CAAA;QACT,KAAK,MAAA;QACL,KAAK,OAAA;YACH,OAAO,CAAA;QACT,KAAK,MAAA;QACL,KAAK,OAAA;YACH,OAAO,CAAA;AACT,QAAA;YACE,OAAO,CAAA;AACX;AACF;AA8QA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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["import type { Vector3, Matrix4x4, Plane } from '@zephyr3d/base';\r\nimport { Frustum, AABB, ClipState } from '@zephyr3d/base';\r\n\r\n/**\r\n * Base interface for any kind of bounding volumes\r\n * @public\r\n */\r\nexport interface BoundingVolume {\r\n /**\r\n * Creates a new bounding volume by copying from this bounding volume\r\n */\r\n clone(): BoundingVolume;\r\n /**\r\n * Creates a new bounding volume by tranforming this bounding volume by a matrix\r\n * @param matrix - The transform matrix\r\n * @returns The created bounding volume\r\n */\r\n transform(matrix: Matrix4x4): BoundingVolume;\r\n /**\r\n * Check if this bounding volume is behind a plane\r\n * @param plane - The plane to check\r\n * @returns true if the bounding volume behinds the plane, false otherwise\r\n */\r\n behindPlane(plane: Plane): boolean;\r\n /**\r\n * Check if this bounding volume is outside a frustum\r\n * @param frustum - The frustum to check\r\n * @returns true if the bounding volume outsides the frustum, false otherwise\r\n */\r\n outsideFrustum(frustum: Frustum | Matrix4x4): boolean;\r\n /**\r\n * Gets the minimum AABB that contains the bounding volume\r\n * @returns The mimimum AABB that contains the bounding volume\r\n */\r\n toAABB(): AABB;\r\n}\r\n\r\n/**\r\n * The bounding box class\r\n * @public\r\n */\r\nexport class BoundingBox extends AABB implements BoundingVolume {\r\n /**\r\n * Creates an empty bounding box\r\n */\r\n constructor();\r\n /**\r\n * Creates a bounding box from an AABB\r\n * @param box - The AABB\r\n */\r\n constructor(box: AABB);\r\n /**\r\n * Creates a bounding box from the min point and the max point\r\n * @param minPoint - Min point of the box\r\n * @param maxPoint - Max point of the box\r\n */\r\n constructor(minPoint: Vector3, maxPoint: Vector3);\r\n constructor(arg0?: Vector3 | AABB, arg1?: Vector3) {\r\n super(arg0 as any, arg1);\r\n }\r\n /** {@inheritDoc BoundingVolume.behindPlane} */\r\n behindPlane(plane: Plane): boolean {\r\n return this.toAABB().behindPlane(plane);\r\n }\r\n /** {@inheritDoc BoundingVolume.clone} */\r\n clone()
|
|
1
|
+
{"version":3,"file":"bounding_volume.js","sources":["../../src/utility/bounding_volume.ts"],"sourcesContent":["import type { Vector3, Matrix4x4, Plane } from '@zephyr3d/base';\r\nimport { Frustum, AABB, ClipState } from '@zephyr3d/base';\r\n\r\n/**\r\n * Base interface for any kind of bounding volumes\r\n * @public\r\n */\r\nexport interface BoundingVolume {\r\n /**\r\n * Creates a new bounding volume by copying from this bounding volume\r\n */\r\n clone(): BoundingVolume;\r\n /**\r\n * Creates a new bounding volume by tranforming this bounding volume by a matrix\r\n * @param matrix - The transform matrix\r\n * @returns The created bounding volume\r\n */\r\n transform(matrix: Matrix4x4): BoundingVolume;\r\n /**\r\n * Check if this bounding volume is behind a plane\r\n * @param plane - The plane to check\r\n * @returns true if the bounding volume behinds the plane, false otherwise\r\n */\r\n behindPlane(plane: Plane): boolean;\r\n /**\r\n * Check if this bounding volume is outside a frustum\r\n * @param frustum - The frustum to check\r\n * @returns true if the bounding volume outsides the frustum, false otherwise\r\n */\r\n outsideFrustum(frustum: Frustum | Matrix4x4): boolean;\r\n /**\r\n * Gets the minimum AABB that contains the bounding volume\r\n * @returns The mimimum AABB that contains the bounding volume\r\n */\r\n toAABB(): AABB;\r\n}\r\n\r\n/**\r\n * The bounding box class\r\n * @public\r\n */\r\nexport class BoundingBox extends AABB implements BoundingVolume {\r\n /**\r\n * Creates an empty bounding box\r\n */\r\n constructor();\r\n /**\r\n * Creates a bounding box from an AABB\r\n * @param box - The AABB\r\n */\r\n constructor(box: AABB);\r\n /**\r\n * Creates a bounding box from the min point and the max point\r\n * @param minPoint - Min point of the box\r\n * @param maxPoint - Max point of the box\r\n */\r\n constructor(minPoint: Vector3, maxPoint: Vector3);\r\n constructor(arg0?: Vector3 | AABB, arg1?: Vector3) {\r\n super(arg0 as any, arg1!);\r\n }\r\n /** {@inheritDoc BoundingVolume.behindPlane} */\r\n behindPlane(plane: Plane): boolean {\r\n return this.toAABB().behindPlane(plane);\r\n }\r\n /** {@inheritDoc BoundingVolume.clone} */\r\n clone() {\r\n return new BoundingBox(this);\r\n }\r\n /** {@inheritDoc BoundingVolume.transform} */\r\n transform(matrix: Matrix4x4) {\r\n return new BoundingBox(AABB.transform(this, matrix));\r\n }\r\n /** {@inheritDoc BoundingVolume.outsideFrustum} */\r\n outsideFrustum(frustum: Frustum | Matrix4x4) {\r\n return (\r\n (frustum instanceof Frustum ? this.getClipStateWithFrustum(frustum) : this.getClipState(frustum)) ===\r\n ClipState.NOT_CLIPPED\r\n );\r\n }\r\n /** {@inheritDoc BoundingVolume.toAABB} */\r\n toAABB() {\r\n return this;\r\n }\r\n}\r\n"],"names":["BoundingBox","AABB","arg0","arg1","behindPlane","plane","toAABB","clone","transform","matrix","outsideFrustum","frustum","Frustum","getClipStateWithFrustum","getClipState","ClipState","NOT_CLIPPED"],"mappings":";;AAqCA;;;IAIO,MAAMA,WAAoBC,SAAAA,IAAAA,CAAAA;IAgB/B,WAAYC,CAAAA,IAAqB,EAAEC,IAAc,CAAE;AACjD,QAAA,KAAK,CAACD,IAAaC,EAAAA,IAAAA,CAAAA;AACrB;oDAEAC,WAAYC,CAAAA,KAAY,EAAW;AACjC,QAAA,OAAO,IAAI,CAACC,MAAM,EAAA,CAAGF,WAAW,CAACC,KAAAA,CAAAA;AACnC;AACA,8CACAE,KAAQ,GAAA;QACN,OAAO,IAAIP,YAAY,IAAI,CAAA;AAC7B;kDAEAQ,SAAUC,CAAAA,MAAiB,EAAE;AAC3B,QAAA,OAAO,IAAIT,WAAYC,CAAAA,IAAAA,CAAKO,SAAS,CAAC,IAAI,EAAEC,MAAAA,CAAAA,CAAAA;AAC9C;uDAEAC,cAAeC,CAAAA,OAA4B,EAAE;AAC3C,QAAA,OACE,CAACA,OAAAA,YAAmBC,OAAU,GAAA,IAAI,CAACC,uBAAuB,CAACF,OAAW,CAAA,GAAA,IAAI,CAACG,YAAY,CAACH,OAAO,CAAA,MAC/FI,UAAUC,WAAW;AAEzB;AACA,+CACAV,MAAS,GAAA;AACP,QAAA,OAAO,IAAI;AACb;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sources":["../../src/utility/debug.ts"],"sourcesContent":["import type { BaseTexture, FrameBuffer } from '@zephyr3d/device';\r\nimport { copyTexture, fetchSampler } from './misc';\r\n\r\nconst debugFrameBuffer: Record<string, FrameBuffer> = {};\r\n\r\n/**\r\n * Copies texture to an intermidate texture for debugging with inspector\r\n * @param tex - The texture to debug\r\n * @param label - Label for the intermidate texture\r\n * @internal\r\n */\r\nexport function debugTexture(tex: BaseTexture, label: string) {\r\n let fb = debugFrameBuffer[label];\r\n if (!fb || fb.getWidth() !== tex.width || fb.getHeight() !== tex.height) {\r\n fb?.getColorAttachments()[0]?.dispose();\r\n fb?.dispose();\r\n fb = tex.device.createFrameBuffer(\r\n [\r\n tex.device.createTexture2D(tex.format, tex.width, tex.height, {\r\n mipmapping: false\r\n })
|
|
1
|
+
{"version":3,"file":"debug.js","sources":["../../src/utility/debug.ts"],"sourcesContent":["import type { BaseTexture, FrameBuffer } from '@zephyr3d/device';\r\nimport { copyTexture, fetchSampler } from './misc';\r\n\r\nconst debugFrameBuffer: Record<string, FrameBuffer> = {};\r\n\r\n/**\r\n * Copies texture to an intermidate texture for debugging with inspector\r\n * @param tex - The texture to debug\r\n * @param label - Label for the intermidate texture\r\n * @internal\r\n */\r\nexport function debugTexture(tex: BaseTexture, label: string) {\r\n let fb = debugFrameBuffer[label];\r\n if (!fb || fb.getWidth() !== tex.width || fb.getHeight() !== tex.height) {\r\n fb?.getColorAttachments()[0]?.dispose();\r\n fb?.dispose();\r\n fb = tex.device.createFrameBuffer(\r\n [\r\n tex.device.createTexture2D(tex.format, tex.width, tex.height, {\r\n mipmapping: false\r\n })!\r\n ],\r\n null\r\n );\r\n fb.getColorAttachments()[0].name = label ?? 'Debug';\r\n debugFrameBuffer[label] = fb;\r\n }\r\n copyTexture(tex, fb, fetchSampler('clamp_nearest_nomip'));\r\n}\r\n"],"names":["debugFrameBuffer","debugTexture","tex","label","fb","getWidth","width","getHeight","height","getColorAttachments","dispose","device","createFrameBuffer","createTexture2D","format","mipmapping","name","copyTexture","fetchSampler"],"mappings":";;AAGA,MAAMA,mBAAgD,EAAC;AAEvD;;;;;AAKC,IACM,SAASC,YAAaC,CAAAA,GAAgB,EAAEC,KAAa,EAAA;IAC1D,IAAIC,EAAAA,GAAKJ,gBAAgB,CAACG,KAAM,CAAA;AAChC,IAAA,IAAI,CAACC,EAAAA,IAAMA,EAAGC,CAAAA,QAAQ,EAAOH,KAAAA,GAAAA,CAAII,KAAK,IAAIF,EAAGG,CAAAA,SAAS,EAAOL,KAAAA,GAAAA,CAAIM,MAAM,EAAE;QACvEJ,EAAIK,EAAAA,mBAAAA,EAAqB,CAAC,CAAA,CAAE,EAAEC,OAAAA,EAAAA;QAC9BN,EAAIM,EAAAA,OAAAA,EAAAA;AACJN,QAAAA,EAAAA,GAAKF,GAAIS,CAAAA,MAAM,CAACC,iBAAiB,CAC/B;AACEV,YAAAA,GAAAA,CAAIS,MAAM,CAACE,eAAe,CAACX,GAAIY,CAAAA,MAAM,EAAEZ,GAAAA,CAAII,KAAK,EAAEJ,GAAIM,CAAAA,MAAM,EAAE;gBAC5DO,UAAY,EAAA;AACd,aAAA;SACD,EACD,IAAA,CAAA;AAEFX,QAAAA,EAAAA,CAAGK,mBAAmB,EAAE,CAAC,EAAE,CAACO,IAAI,GAAGb,KAAS,IAAA,OAAA;QAC5CH,gBAAgB,CAACG,MAAM,GAAGC,EAAAA;AAC5B;IACAa,WAAYf,CAAAA,GAAAA,EAAKE,IAAIc,YAAa,CAAA,qBAAA,CAAA,CAAA;AACpC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decoder.js","sources":["../../../src/utility/draco/decoder.ts"],"sourcesContent":["import type { TypedArray, TypedArrayConstructor } from '@zephyr3d/base';\r\nimport type { Decoder, Mesh, DecoderModule, DataType } from 'draco3d';\r\n\r\n/** @public */\r\nexport class DracoMeshDecoder {\r\n private readonly _module: DecoderModule;\r\n private readonly _decoder: Decoder;\r\n private readonly _mesh: Mesh;\r\n constructor(data: Int8Array<ArrayBuffer>, decoderModule: DecoderModule) {\r\n this._module = decoderModule;\r\n this._decoder = new this._module.Decoder();\r\n const buffer = new this._module.DecoderBuffer();\r\n buffer.Init(data, data.byteLength);\r\n const geometryType = this._decoder.GetEncodedGeometryType(buffer);\r\n if (geometryType !== this._module.TRIANGULAR_MESH) {\r\n this._module.destroy(buffer);\r\n this._module.destroy(this._decoder);\r\n this._decoder = null;\r\n throw new Error(`Unsupported geometry type: ${geometryType}`);\r\n }\r\n this._mesh = new this._module.Mesh();\r\n const status = this._decoder.DecodeBufferToMesh(buffer, this._mesh);\r\n this._module.destroy(buffer);\r\n if (!status.ok() || this._mesh.ptr === 0) {\r\n this._module.destroy(this._decoder);\r\n this._decoder = null;\r\n this._module.destroy(this._mesh);\r\n this._mesh = null;\r\n throw new Error(status.error_msg());\r\n }\r\n }\r\n getIndexBuffer() {\r\n if (!this._decoder || !this._mesh) {\r\n return null;\r\n }\r\n const numFaces = this._mesh.num_faces();\r\n const numIndices = numFaces * 3;\r\n // Uint32\r\n const indexBuffer = new Uint32Array(numIndices);\r\n const ptr = this._module._malloc(indexBuffer.byteLength);\r\n this._decoder.GetTrianglesUInt32Array(this._mesh, indexBuffer.byteLength, ptr);\r\n const tmpBuffer = new Uint32Array(this._module.HEAPU32.buffer, ptr, numIndices);\r\n indexBuffer.set(tmpBuffer);\r\n this._module._free(ptr);\r\n return indexBuffer;\r\n }\r\n getAttributeBuffer(id: number, buffer: TypedArray) {\r\n if (!this._decoder || !this._mesh) {\r\n return null;\r\n }\r\n const attribute = this._decoder.GetAttributeByUniqueId(this._mesh, id);\r\n if (!attribute) {\r\n return null;\r\n }\r\n const numComponents = attribute.num_components();\r\n const numPoints = this._mesh.num_points();\r\n const numValues = numPoints * numComponents;\r\n if (buffer.length !== numValues) {\r\n console.error(`getAttributeBuffer(): buffer length must be ${numValues}`);\r\n return null;\r\n }\r\n const ptr = this._module._malloc(buffer.byteLength);\r\n this._decoder.GetAttributeDataArrayForAllPoints(\r\n this._mesh,\r\n attribute,\r\n this.getDracoDataType(buffer),\r\n buffer.byteLength,\r\n ptr\r\n );\r\n const tmpBuffer = new (buffer.constructor as TypedArrayConstructor)(\r\n this.getDracoHeap(buffer).buffer,\r\n ptr,\r\n numValues\r\n );\r\n buffer.set(tmpBuffer);\r\n this._module._free(ptr);\r\n return buffer;\r\n }\r\n private getDracoDataType(buffer: TypedArray): DataType {\r\n if (buffer instanceof Float32Array) {\r\n return this._module.DT_FLOAT32;\r\n }\r\n if (buffer instanceof Int8Array) {\r\n return this._module.DT_INT8;\r\n }\r\n if (buffer instanceof Int16Array) {\r\n return this._module.DT_INT16;\r\n }\r\n if (buffer instanceof Int32Array) {\r\n return this._module.DT_INT32;\r\n }\r\n if (buffer instanceof Uint8Array) {\r\n return this._module.DT_UINT8;\r\n }\r\n if (buffer instanceof Uint16Array) {\r\n return this._module.DT_UINT16;\r\n }\r\n if (buffer instanceof Uint32Array) {\r\n return this._module.DT_UINT32;\r\n }\r\n throw new Error(`getDracoDataType(): invalid buffer type`);\r\n }\r\n private getDracoHeap(buffer: TypedArray): TypedArray {\r\n if (buffer instanceof Float32Array) {\r\n return this._module.HEAPF32 as TypedArray;\r\n }\r\n if (buffer instanceof Int8Array) {\r\n return this._module.HEAP8 as TypedArray;\r\n }\r\n if (buffer instanceof Int16Array) {\r\n return this._module.HEAP16 as TypedArray;\r\n }\r\n if (buffer instanceof Int32Array) {\r\n return this._module.HEAP32 as TypedArray;\r\n }\r\n if (buffer instanceof Uint8Array) {\r\n return this._module.HEAPU8 as TypedArray;\r\n }\r\n if (buffer instanceof Uint16Array) {\r\n return this._module.HEAPU16 as TypedArray;\r\n }\r\n if (buffer instanceof Uint32Array) {\r\n return this._module.HEAPU32 as TypedArray;\r\n }\r\n throw new Error(`getDracoHeap(): invalid buffer type`);\r\n }\r\n}\r\n"],"names":["DracoMeshDecoder","_module","_decoder","_mesh","data","decoderModule","Decoder","buffer","DecoderBuffer","Init","byteLength","geometryType","GetEncodedGeometryType","TRIANGULAR_MESH","destroy","Error","Mesh","status","DecodeBufferToMesh","ok","ptr","error_msg","getIndexBuffer","numFaces","num_faces","numIndices","indexBuffer","Uint32Array","_malloc","GetTrianglesUInt32Array","tmpBuffer","HEAPU32","set","_free","getAttributeBuffer","id","attribute","GetAttributeByUniqueId","numComponents","num_components","numPoints","num_points","numValues","length","console","error","GetAttributeDataArrayForAllPoints","getDracoDataType","getDracoHeap","Float32Array","DT_FLOAT32","Int8Array","DT_INT8","Int16Array","DT_INT16","Int32Array","DT_INT32","Uint8Array","DT_UINT8","Uint16Array","DT_UINT16","DT_UINT32","HEAPF32","HEAP8","HEAP16","HEAP32","HEAPU8","HEAPU16"],"mappings":"AAGA,eACO,MAAMA,gBAAAA,CAAAA;IACMC,OAAuB;IACvBC,QAAkB;IAClBC,KAAY;IAC7B,WAAYC,CAAAA,IAA4B,EAAEC,aAA4B,CAAE;QACtE,IAAI,CAACJ,OAAO,GAAGI,aAAAA;QACf,IAAI,CAACH,QAAQ,GAAG,IAAI,IAAI,CAACD,OAAO,CAACK,OAAO,EAAA;AACxC,QAAA,MAAMC,SAAS,IAAI,IAAI,CAACN,OAAO,CAACO,aAAa,EAAA;AAC7CD,QAAAA,MAAAA,CAAOE,IAAI,CAACL,IAAMA,EAAAA,IAAAA,CAAKM,UAAU,CAAA;AACjC,QAAA,MAAMC,eAAe,IAAI,CAACT,QAAQ,CAACU,sBAAsB,CAACL,MAAAA,CAAAA;AAC1D,QAAA,IAAII,iBAAiB,IAAI,CAACV,OAAO,CAACY,eAAe,EAAE;AACjD,YAAA,IAAI,CAACZ,OAAO,CAACa,OAAO,CAACP,MAAAA,CAAAA;AACrB,YAAA,IAAI,CAACN,OAAO,CAACa,OAAO,CAAC,IAAI,CAACZ,QAAQ,CAAA;YAClC,IAAI,CAACA,QAAQ,GAAG,IAAA;AAChB,YAAA,MAAM,IAAIa,KAAAA,CAAM,CAAC,2BAA2B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B,YAAA,OAAO,IAAI,CAAClD,OAAO,CAAC8D,KAAK;AAC3B;AACA,QAAA,IAAIxD,kBAAkB8C,UAAY,EAAA;AAChC,YAAA,OAAO,IAAI,CAACpD,OAAO,CAAC+D,MAAM;AAC5B;AACA,QAAA,IAAIzD,kBAAkBgD,UAAY,EAAA;AAChC,YAAA,OAAO,IAAI,CAACtD,OAAO,CAACgE,MAAM;AAC5B;AACA,QAAA,IAAI1D,kBAAkBkD,UAAY,EAAA;AAChC,YAAA,OAAO,IAAI,CAACxD,OAAO,CAACiE,MAAM;AAC5B;AACA,QAAA,IAAI3D,kBAAkBoD,WAAa,EAAA;AACjC,YAAA,OAAO,IAAI,CAAC1D,OAAO,CAACkE,OAAO;AAC7B;AACA,QAAA,IAAI5D,kBAAkBoB,WAAa,EAAA;AACjC,YAAA,OAAO,IAAI,CAAC1B,OAAO,CAAC8B,OAAO;AAC7B;AACA,QAAA,MAAM,IAAIhB,KAAAA,CAAM,CAAC,mCAAmC,CAAC,CAAA;AACvD;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"decoder.js","sources":["../../../src/utility/draco/decoder.ts"],"sourcesContent":["import type { Nullable, TypedArray, TypedArrayConstructor } from '@zephyr3d/base';\r\nimport type { Decoder, Mesh, DecoderModule, DataType } from 'draco3d';\r\n\r\n/** @public */\r\nexport class DracoMeshDecoder {\r\n private readonly _module: DecoderModule;\r\n private readonly _decoder: Nullable<Decoder>;\r\n private readonly _mesh: Nullable<Mesh>;\r\n constructor(data: Int8Array<ArrayBuffer>, decoderModule: DecoderModule) {\r\n this._module = decoderModule;\r\n this._decoder = new this._module.Decoder();\r\n const buffer = new this._module.DecoderBuffer();\r\n buffer.Init(data, data.byteLength);\r\n const geometryType = this._decoder.GetEncodedGeometryType(buffer);\r\n if (geometryType !== this._module.TRIANGULAR_MESH) {\r\n this._module.destroy(buffer);\r\n this._module.destroy(this._decoder);\r\n this._decoder = null;\r\n throw new Error(`Unsupported geometry type: ${geometryType}`);\r\n }\r\n this._mesh = new this._module.Mesh();\r\n const status = this._decoder.DecodeBufferToMesh(buffer, this._mesh);\r\n this._module.destroy(buffer);\r\n if (!status.ok() || this._mesh.ptr === 0) {\r\n this._module.destroy(this._decoder);\r\n this._decoder = null;\r\n this._module.destroy(this._mesh);\r\n this._mesh = null;\r\n throw new Error(status.error_msg());\r\n }\r\n }\r\n getIndexBuffer() {\r\n if (!this._decoder || !this._mesh) {\r\n return null;\r\n }\r\n const numFaces = this._mesh.num_faces();\r\n const numIndices = numFaces * 3;\r\n // Uint32\r\n const indexBuffer = new Uint32Array(numIndices);\r\n const ptr = this._module._malloc(indexBuffer.byteLength);\r\n this._decoder.GetTrianglesUInt32Array(this._mesh, indexBuffer.byteLength, ptr);\r\n const tmpBuffer = new Uint32Array(this._module.HEAPU32.buffer, ptr, numIndices);\r\n indexBuffer.set(tmpBuffer);\r\n this._module._free(ptr);\r\n return indexBuffer;\r\n }\r\n getAttributeBuffer(id: number, buffer: TypedArray) {\r\n if (!this._decoder || !this._mesh) {\r\n return null;\r\n }\r\n const attribute = this._decoder.GetAttributeByUniqueId(this._mesh, id);\r\n if (!attribute) {\r\n return null;\r\n }\r\n const numComponents = attribute.num_components();\r\n const numPoints = this._mesh.num_points();\r\n const numValues = numPoints * numComponents;\r\n if (buffer.length !== numValues) {\r\n console.error(`getAttributeBuffer(): buffer length must be ${numValues}`);\r\n return null;\r\n }\r\n const ptr = this._module._malloc(buffer.byteLength);\r\n this._decoder.GetAttributeDataArrayForAllPoints(\r\n this._mesh,\r\n attribute,\r\n this.getDracoDataType(buffer),\r\n buffer.byteLength,\r\n ptr\r\n );\r\n const tmpBuffer = new (buffer.constructor as TypedArrayConstructor)(\r\n this.getDracoHeap(buffer).buffer,\r\n ptr,\r\n numValues\r\n );\r\n buffer.set(tmpBuffer);\r\n this._module._free(ptr);\r\n return buffer;\r\n }\r\n private getDracoDataType(buffer: TypedArray): DataType {\r\n if (buffer instanceof Float32Array) {\r\n return this._module.DT_FLOAT32;\r\n }\r\n if (buffer instanceof Int8Array) {\r\n return this._module.DT_INT8;\r\n }\r\n if (buffer instanceof Int16Array) {\r\n return this._module.DT_INT16;\r\n }\r\n if (buffer instanceof Int32Array) {\r\n return this._module.DT_INT32;\r\n }\r\n if (buffer instanceof Uint8Array) {\r\n return this._module.DT_UINT8;\r\n }\r\n if (buffer instanceof Uint16Array) {\r\n return this._module.DT_UINT16;\r\n }\r\n if (buffer instanceof Uint32Array) {\r\n return this._module.DT_UINT32;\r\n }\r\n throw new Error(`getDracoDataType(): invalid buffer type`);\r\n }\r\n private getDracoHeap(buffer: TypedArray): TypedArray {\r\n if (buffer instanceof Float32Array) {\r\n return this._module.HEAPF32 as TypedArray;\r\n }\r\n if (buffer instanceof Int8Array) {\r\n return this._module.HEAP8 as TypedArray;\r\n }\r\n if (buffer instanceof Int16Array) {\r\n return this._module.HEAP16 as TypedArray;\r\n }\r\n if (buffer instanceof Int32Array) {\r\n return this._module.HEAP32 as TypedArray;\r\n }\r\n if (buffer instanceof Uint8Array) {\r\n return this._module.HEAPU8 as TypedArray;\r\n }\r\n if (buffer instanceof Uint16Array) {\r\n return this._module.HEAPU16 as TypedArray;\r\n }\r\n if (buffer instanceof Uint32Array) {\r\n return this._module.HEAPU32 as TypedArray;\r\n }\r\n throw new Error(`getDracoHeap(): invalid buffer type`);\r\n }\r\n}\r\n"],"names":["DracoMeshDecoder","_module","_decoder","_mesh","data","decoderModule","Decoder","buffer","DecoderBuffer","Init","byteLength","geometryType","GetEncodedGeometryType","TRIANGULAR_MESH","destroy","Error","Mesh","status","DecodeBufferToMesh","ok","ptr","error_msg","getIndexBuffer","numFaces","num_faces","numIndices","indexBuffer","Uint32Array","_malloc","GetTrianglesUInt32Array","tmpBuffer","HEAPU32","set","_free","getAttributeBuffer","id","attribute","GetAttributeByUniqueId","numComponents","num_components","numPoints","num_points","numValues","length","console","error","GetAttributeDataArrayForAllPoints","getDracoDataType","getDracoHeap","Float32Array","DT_FLOAT32","Int8Array","DT_INT8","Int16Array","DT_INT16","Int32Array","DT_INT32","Uint8Array","DT_UINT8","Uint16Array","DT_UINT16","DT_UINT32","HEAPF32","HEAP8","HEAP16","HEAP32","HEAPU8","HEAPU16"],"mappings":"AAGA,eACO,MAAMA,gBAAAA,CAAAA;IACMC,OAAuB;IACvBC,QAA4B;IAC5BC,KAAsB;IACvC,WAAYC,CAAAA,IAA4B,EAAEC,aAA4B,CAAE;QACtE,IAAI,CAACJ,OAAO,GAAGI,aAAAA;QACf,IAAI,CAACH,QAAQ,GAAG,IAAI,IAAI,CAACD,OAAO,CAACK,OAAO,EAAA;AACxC,QAAA,MAAMC,SAAS,IAAI,IAAI,CAACN,OAAO,CAACO,aAAa,EAAA;AAC7CD,QAAAA,MAAAA,CAAOE,IAAI,CAACL,IAAMA,EAAAA,IAAAA,CAAKM,UAAU,CAAA;AACjC,QAAA,MAAMC,eAAe,IAAI,CAACT,QAAQ,CAACU,sBAAsB,CAACL,MAAAA,CAAAA;AAC1D,QAAA,IAAII,iBAAiB,IAAI,CAACV,OAAO,CAACY,eAAe,EAAE;AACjD,YAAA,IAAI,CAACZ,OAAO,CAACa,OAAO,CAACP,MAAAA,CAAAA;AACrB,YAAA,IAAI,CAACN,OAAO,CAACa,OAAO,CAAC,IAAI,CAACZ,QAAQ,CAAA;YAClC,IAAI,CAACA,QAAQ,GAAG,IAAA;AAChB,YAAA,MAAM,IAAIa,KAAAA,CAAM,CAAC,2BAA2B,EAAEJ,YAAc,CAAA,CAAA,CAAA;AAC9D;QACA,IAAI,CAACR,KAAK,GAAG,IAAI,IAAI,CAACF,OAAO,CAACe,IAAI,EAAA;QAClC,MAAMC,MAAAA,GAAS,IAAI,CAACf,QAAQ,CAACgB,kBAAkB,CAACX,MAAAA,EAAQ,IAAI,CAACJ,KAAK,CAAA;AAClE,QAAA,IAAI,CAACF,OAAO,CAACa,OAAO,CAACP,MAAAA,CAAAA;QACrB,IAAI,CAACU,MAAOE,CAAAA,EAAE,EAAM,IAAA,IAAI,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ACiE,MAAM;AAC5B;AACA,QAAA,IAAI3D,kBAAkBoD,WAAa,EAAA;AACjC,YAAA,OAAO,IAAI,CAAC1D,OAAO,CAACkE,OAAO;AAC7B;AACA,QAAA,IAAI5D,kBAAkBoB,WAAa,EAAA;AACjC,YAAA,OAAO,IAAI,CAAC1B,OAAO,CAAC8B,OAAO;AAC7B;AACA,QAAA,MAAM,IAAIhB,KAAAA,CAAM,CAAC,mCAAmC,CAAC,CAAA;AACvD;AACF;;;;"}
|
package/dist/utility/misc.js
CHANGED
package/dist/utility/misc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.js","sources":["../../src/utility/misc.ts"],"sourcesContent":["import type {\r\n BaseTexture,\r\n FrameBuffer,\r\n RenderStateSet,\r\n SamplerOptions,\r\n TextureSampler\r\n} from '@zephyr3d/device';\r\nimport { CopyBlitter } from '../blitter/copy';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * Metadata interface for storing additional information\r\n * @public\r\n */\r\nexport interface Metadata {\r\n [key: string]:\r\n | string\r\n | number\r\n | boolean\r\n | null\r\n | Metadata\r\n | Array<string | number | boolean | null | undefined | Metadata>;\r\n}\r\n\r\n/**\r\n * Sampler types\r\n * @public\r\n */\r\nexport type SamplerType =\r\n | 'clamp_linear'\r\n | 'clamp_linear_nomip'\r\n | 'clamp_nearest'\r\n | 'clamp_nearest_nomip'\r\n | 'repeat_linear'\r\n | 'repeat_linear_nomip'\r\n | 'repeat_nearest'\r\n | 'repeat_nearest_nomip';\r\n\r\nconst samplerOptions: Record<SamplerType, SamplerOptions> = {\r\n clamp_linear: {\r\n addressU: 'clamp',\r\n addressV: 'clamp',\r\n magFilter: 'linear',\r\n minFilter: 'linear',\r\n mipFilter: 'linear'\r\n },\r\n clamp_linear_nomip: {\r\n addressU: 'clamp',\r\n addressV: 'clamp',\r\n magFilter: 'linear',\r\n minFilter: 'linear',\r\n mipFilter: 'none'\r\n },\r\n clamp_nearest: {\r\n addressU: 'clamp',\r\n addressV: 'clamp',\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'nearest'\r\n },\r\n clamp_nearest_nomip: {\r\n addressU: 'clamp',\r\n addressV: 'clamp',\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'none'\r\n },\r\n repeat_linear: {\r\n addressU: 'repeat',\r\n addressV: 'repeat',\r\n magFilter: 'linear',\r\n minFilter: 'linear',\r\n mipFilter: 'linear'\r\n },\r\n repeat_linear_nomip: {\r\n addressU: 'repeat',\r\n addressV: 'repeat',\r\n magFilter: 'linear',\r\n minFilter: 'linear',\r\n mipFilter: 'none'\r\n },\r\n repeat_nearest: {\r\n addressU: 'repeat',\r\n addressV: 'repeat',\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'nearest'\r\n },\r\n repeat_nearest_nomip: {\r\n addressU: 'repeat',\r\n addressV: 'repeat',\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'none'\r\n }\r\n};\r\n\r\nconst samplers: Partial<Record<SamplerType, TextureSampler>> = {};\r\nlet copyBlitter: CopyBlitter = null;\r\nlet defaultCopyRenderState: RenderStateSet = null;\r\n\r\n/**\r\n * Fetch a sampler by type\r\n * @param type - The sampler type to fetch\r\n * @returns The sampler for the given type\r\n * @public\r\n */\r\nexport function fetchSampler(type: SamplerType)
|
|
1
|
+
{"version":3,"file":"misc.js","sources":["../../src/utility/misc.ts"],"sourcesContent":["import type {\r\n BaseTexture,\r\n FrameBuffer,\r\n RenderStateSet,\r\n SamplerOptions,\r\n TextureSampler\r\n} from '@zephyr3d/device';\r\nimport { CopyBlitter } from '../blitter/copy';\r\nimport { getDevice } from '../app/api';\r\nimport type { Nullable } from '@zephyr3d/base';\r\n\r\n/**\r\n * Metadata interface for storing additional information\r\n * @public\r\n */\r\nexport interface Metadata {\r\n [key: string]:\r\n | string\r\n | number\r\n | boolean\r\n | null\r\n | Metadata\r\n | Array<string | number | boolean | null | undefined | Metadata>;\r\n}\r\n\r\n/**\r\n * Sampler types\r\n * @public\r\n */\r\nexport type SamplerType =\r\n | 'clamp_linear'\r\n | 'clamp_linear_nomip'\r\n | 'clamp_nearest'\r\n | 'clamp_nearest_nomip'\r\n | 'repeat_linear'\r\n | 'repeat_linear_nomip'\r\n | 'repeat_nearest'\r\n | 'repeat_nearest_nomip';\r\n\r\nconst samplerOptions: Record<SamplerType, SamplerOptions> = {\r\n clamp_linear: {\r\n addressU: 'clamp',\r\n addressV: 'clamp',\r\n magFilter: 'linear',\r\n minFilter: 'linear',\r\n mipFilter: 'linear'\r\n },\r\n clamp_linear_nomip: {\r\n addressU: 'clamp',\r\n addressV: 'clamp',\r\n magFilter: 'linear',\r\n minFilter: 'linear',\r\n mipFilter: 'none'\r\n },\r\n clamp_nearest: {\r\n addressU: 'clamp',\r\n addressV: 'clamp',\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'nearest'\r\n },\r\n clamp_nearest_nomip: {\r\n addressU: 'clamp',\r\n addressV: 'clamp',\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'none'\r\n },\r\n repeat_linear: {\r\n addressU: 'repeat',\r\n addressV: 'repeat',\r\n magFilter: 'linear',\r\n minFilter: 'linear',\r\n mipFilter: 'linear'\r\n },\r\n repeat_linear_nomip: {\r\n addressU: 'repeat',\r\n addressV: 'repeat',\r\n magFilter: 'linear',\r\n minFilter: 'linear',\r\n mipFilter: 'none'\r\n },\r\n repeat_nearest: {\r\n addressU: 'repeat',\r\n addressV: 'repeat',\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'nearest'\r\n },\r\n repeat_nearest_nomip: {\r\n addressU: 'repeat',\r\n addressV: 'repeat',\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'none'\r\n }\r\n};\r\n\r\nconst samplers: Partial<Record<SamplerType, TextureSampler>> = {};\r\nlet copyBlitter: Nullable<CopyBlitter> = null;\r\nlet defaultCopyRenderState: Nullable<RenderStateSet> = null;\r\n\r\n/**\r\n * Fetch a sampler by type\r\n * @param type - The sampler type to fetch\r\n * @returns The sampler for the given type\r\n * @public\r\n */\r\nexport function fetchSampler(type: SamplerType) {\r\n let sampler = samplers[type];\r\n if (!sampler) {\r\n const opt = samplerOptions[type];\r\n if (opt) {\r\n sampler = getDevice().createSampler(opt);\r\n samplers[type] = sampler;\r\n }\r\n }\r\n return sampler ?? null;\r\n}\r\n\r\n/**\r\n * Utility function to copy a texture\r\n * @param src - Source texture to copy from\r\n * @param dest - Destination texture to copy to\r\n * @param sampler - Sampler object use to sample the source texture\r\n * @param renderState - RenderStateSet object used to copy texture\r\n * @param layer - Texture layer to copy\r\n * @param srgbOut - true if output color in sRGB color space\r\n * @internal\r\n */\r\nexport function copyTexture(\r\n src: BaseTexture,\r\n dest: BaseTexture | FrameBuffer,\r\n sampler: Nullable<TextureSampler> = null,\r\n renderState: Nullable<RenderStateSet> = null,\r\n layer = 0,\r\n srgbOut = false\r\n) {\r\n if (!renderState && !defaultCopyRenderState) {\r\n defaultCopyRenderState = src.device.createRenderStateSet();\r\n defaultCopyRenderState.useDepthState().enableTest(false).enableWrite(false);\r\n defaultCopyRenderState.useRasterizerState().setCullMode('none');\r\n }\r\n if (!copyBlitter) {\r\n copyBlitter = new CopyBlitter();\r\n }\r\n copyBlitter.renderStates = renderState ?? defaultCopyRenderState;\r\n copyBlitter.srgbOut = srgbOut;\r\n copyBlitter.blit(src, dest, layer, sampler);\r\n}\r\n"],"names":["samplerOptions","clamp_linear","addressU","addressV","magFilter","minFilter","mipFilter","clamp_linear_nomip","clamp_nearest","clamp_nearest_nomip","repeat_linear","repeat_linear_nomip","repeat_nearest","repeat_nearest_nomip","samplers","copyBlitter","defaultCopyRenderState","fetchSampler","type","sampler","opt","getDevice","createSampler","copyTexture","src","dest","renderState","layer","srgbOut","device","createRenderStateSet","useDepthState","enableTest","enableWrite","useRasterizerState","set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AAA,OAAAA,CAAAA;AACrC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panorama.js","sources":["../../src/utility/panorama.ts"],"sourcesContent":["import { Vector3 } from '@zephyr3d/base';\r\nimport type {\r\n Texture2D,\r\n BindGroup,\r\n GPUProgram,\r\n RenderStateSet,\r\n TextureCube,\r\n VertexLayout\r\n} from '@zephyr3d/device';\r\nimport { gammaToLinear } from '../shaders/misc';\r\nimport { getDevice } from '../app/api';\r\n\r\nlet vertexLayout: VertexLayout = null;\r\nlet renderStates: RenderStateSet = null;\r\nlet panoramaToCubemapProgram: GPUProgram = null;\r\nlet panoramaToCubemapBindGroup: BindGroup = null;\r\nlet panoramaToCubemapProgramRGBM: GPUProgram = null;\r\nlet panoramaToCubemapBindGroupRGBM: BindGroup = null;\r\nconst faceDirections = [\r\n [new Vector3(0, 0, -1), new Vector3(0, -1, 0), new Vector3(1, 0, 0)],\r\n [new Vector3(0, 0, 1), new Vector3(0, -1, 0), new Vector3(-1, 0, 0)],\r\n [new Vector3(1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)],\r\n [new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector3(0, -1, 0)],\r\n [new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1)],\r\n [new Vector3(-1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, -1)]\r\n];\r\n\r\nfunction init() {\r\n const device = getDevice();\r\n const vertices = new Float32Array([1, 1, -1, 1, -1, -1, 1, -1]);\r\n const indices = new Uint16Array([0, 1, 2, 0, 2, 3]);\r\n vertexLayout = device.createVertexLayout({\r\n vertexBuffers: [\r\n {\r\n buffer: device.createVertexBuffer('position_f32x2', vertices)\r\n }\r\n ],\r\n indexBuffer: device.createIndexBuffer(indices)\r\n });\r\n renderStates = device.createRenderStateSet();\r\n renderStates.useRasterizerState().setCullMode('none');\r\n renderStates.useDepthState().enableTest(false).enableWrite(false);\r\n panoramaToCubemapProgram = createPanoramaToCubemapProgram(false);\r\n panoramaToCubemapBindGroup = device.createBindGroup(panoramaToCubemapProgram.bindGroupLayouts[0]);\r\n panoramaToCubemapProgramRGBM = createPanoramaToCubemapProgram(true);\r\n panoramaToCubemapBindGroupRGBM = device.createBindGroup(panoramaToCubemapProgramRGBM.bindGroupLayouts[0]);\r\n}\r\n\r\nfunction createPanoramaToCubemapProgram(rgbm: boolean): GPUProgram {\r\n const device = getDevice();\r\n const pb = device;\r\n const program = pb.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.pos = pb.vec2().attrib('position');\r\n this.up = pb.vec3().uniform(0);\r\n this.right = pb.vec3().uniform(0);\r\n this.front = pb.vec3().uniform(0);\r\n pb.main(function () {\r\n this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);\r\n this.$outputs.direction = pb.mul(\r\n pb.mat3(this.up, this.right, this.front),\r\n pb.vec3(this.$inputs.pos, 1)\r\n );\r\n if (pb.getDevice().type === 'webgpu') {\r\n this.$builtins.position.y = pb.neg(this.$builtins.position.y);\r\n }\r\n });\r\n },\r\n fragment(pb) {\r\n this.u_panoramaTexture = pb.tex2D().uniform(0);\r\n this.$outputs.outcolor = pb.vec4();\r\n pb.func('dirToUV', [pb.vec3('dir')], function () {\r\n this.$l.x = pb.add(0.5, pb.div(pb.atan2(this.dir.z, this.dir.x), 2 * Math.PI));\r\n this.$l.y = pb.div(pb.acos(this.dir.y), Math.PI);\r\n this.$return(pb.vec2(this.x, this.y));\r\n });\r\n pb.main(function () {\r\n this.$l.uv = this.dirToUV(pb.normalize(this.$inputs.direction));\r\n this.$l.color = pb.textureSampleLevel(this.u_panoramaTexture, this.uv, 0);\r\n if (rgbm) {\r\n this.$l.rgb = pb.mul(this.color.rgb, this.color.a, 6);\r\n this.rgb = gammaToLinear(this, this.rgb);\r\n this.$outputs.outcolor = pb.vec4(this.rgb, 1);\r\n } else {\r\n this.$outputs.outcolor = pb.vec4(this.color.rgb, 1);\r\n }\r\n });\r\n }\r\n });\r\n program.name = rgbm ? '@PanoramaToCubemap_RGBM' : '@PanoramaToCubemap';\r\n return program;\r\n}\r\n\r\nfunction doConvertPanoramaToCubemap(srcTexture: Texture2D, dstTexture: TextureCube) {\r\n const device = getDevice();\r\n const rgbm = srcTexture.format === 'rgba8unorm';\r\n const program = rgbm ? panoramaToCubemapProgramRGBM : panoramaToCubemapProgram;\r\n const bindgroup = rgbm ? panoramaToCubemapBindGroupRGBM : panoramaToCubemapBindGroup;\r\n const framebuffer = device.createFrameBuffer([dstTexture], null);\r\n device.pushDeviceStates();\r\n device.setFramebuffer(framebuffer);\r\n for (let i = 0; i < 6; i++) {\r\n framebuffer.setColorAttachmentCubeFace(0, i);\r\n device.setVertexLayout(vertexLayout);\r\n device.setRenderStates(renderStates);\r\n device.setProgram(program);\r\n device.setBindGroup(0, bindgroup);\r\n bindgroup.setValue('up', faceDirections[i][0]);\r\n bindgroup.setValue('right', faceDirections[i][1]);\r\n bindgroup.setValue('front', faceDirections[i][2]);\r\n bindgroup.setTexture('u_panoramaTexture', srcTexture);\r\n device.draw('triangle-list', 0, 6);\r\n }\r\n device.popDeviceStates();\r\n}\r\n\r\n/**\r\n * Converts an equirectangular image to cubemap\r\n *\r\n * @param tex - The equirectangular image to be converted\r\n * @param textureSize - cubemap size\r\n * @returns The converted cubemap\r\n *\r\n * @public\r\n */\r\nexport function panoramaToCubemap(tex: Texture2D, outputCubeMap: TextureCube): void {\r\n const device = getDevice();\r\n if (!vertexLayout) {\r\n init();\r\n }\r\n device.pushDeviceStates();\r\n doConvertPanoramaToCubemap(tex, outputCubeMap);\r\n device.popDeviceStates();\r\n}\r\n"],"names":["vertexLayout","renderStates","panoramaToCubemapProgram","panoramaToCubemapBindGroup","panoramaToCubemapProgramRGBM","panoramaToCubemapBindGroupRGBM","faceDirections","Vector3","init","device","getDevice","vertices","Float32Array","indices","Uint16Array","createVertexLayout","vertexBuffers","buffer","createVertexBuffer","indexBuffer","createIndexBuffer","createRenderStateSet","useRasterizerState","setCullMode","useDepthState","enableTest","enableWrite","createPanoramaToCubemapProgram","createBindGroup","bindGroupLayouts","rgbm","pb","program","buildRenderProgram","vertex","$inputs","pos","vec2","attrib","up","vec3","uniform","right","front","main","$builtins","position","vec4","$outputs","direction","mul","mat3","type","y","neg","fragment","u_panoramaTexture","tex2D","outcolor","func","$l","x","add","div","atan2","dir","z","Math","PI","acos","$return","uv","dirToUV","normalize","color","textureSampleLevel","rgb","a","gammaToLinear","name","doConvertPanoramaToCubemap","srcTexture","dstTexture","format","bindgroup","framebuffer","createFrameBuffer","pushDeviceStates","setFramebuffer","i","setColorAttachmentCubeFace","setVertexLayout","setRenderStates","setProgram","setBindGroup","setValue","setTexture","draw","popDeviceStates","panoramaToCubemap","tex","outputCubeMap"],"mappings":";;;;AAYA,IAAIA,YAA6B,GAAA,IAAA;AACjC,IAAIC,YAA+B,GAAA,IAAA;AACnC,IAAIC,wBAAuC,GAAA,IAAA;AAC3C,IAAIC,0BAAwC,GAAA,IAAA;AAC5C,IAAIC,4BAA2C,GAAA,IAAA;AAC/C,IAAIC,8BAA4C,GAAA,IAAA;AAChD,MAAMC,cAAiB,GAAA;AACrB,IAAA;QAAC,IAAIC,OAAAA,CAAQ,CAAG,EAAA,CAAA,EAAG,EAAC,CAAA;QAAI,IAAIA,OAAAA,CAAQ,CAAG,EAAA,EAAI,EAAA,CAAA,CAAA;QAAI,IAAIA,OAAAA,CAAQ,GAAG,CAAG,EAAA,CAAA;AAAG,KAAA;AACpE,IAAA;QAAC,IAAIA,OAAAA,CAAQ,GAAG,CAAG,EAAA,CAAA,CAAA;QAAI,IAAIA,OAAAA,CAAQ,CAAG,EAAA,EAAI,EAAA,CAAA,CAAA;QAAI,IAAIA,OAAAA,CAAQ,EAAC,EAAG,CAAG,EAAA,CAAA;AAAG,KAAA;AACpE,IAAA;QAAC,IAAIA,OAAAA,CAAQ,GAAG,CAAG,EAAA,CAAA,CAAA;QAAI,IAAIA,OAAAA,CAAQ,GAAG,C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AAc,CAACmF,CAAAA,CAAE,CAAC,CAAE,CAAA,CAAA;AAC7CL,QAAAA,SAAAA,CAAUW,QAAQ,CAAC,OAAA,EAASzF,cAAc,CAACmF,CAAAA,CAAE,CAAC,CAAE,CAAA,CAAA;AAChDL,QAAAA,SAAAA,CAAUW,QAAQ,CAAC,OAAA,EAASzF,cAAc,CAACmF,CAAAA,CAAE,CAAC,CAAE,CAAA,CAAA;QAChDL,SAAUY,CAAAA,UAAU,CAAC,mBAAqBf,EAAAA,UAAAA,CAAAA;QAC1CxE,MAAOwF,CAAAA,IAAI,CAAC,eAAA,EAAiB,CAAG,EAAA,CAAA,CAAA;AAClC;AACAxF,IAAAA,MAAAA,CAAOyF,eAAe,EAAA;AACxB;AAEA;;;;;;;;AAQC,IACM,SAASC,iBAAkBC,CAAAA,GAAc,EAAEC,aAA0B,EAAA;AAC1E,IAAA,MAAM5F,MAASC,GAAAA,SAAAA,EAAAA;AACf,IAAA,IAAI,CAACV,YAAc,EAAA;AACjBQ,QAAAA,IAAAA,EAAAA;AACF;AACAC,IAAAA,MAAAA,CAAO8E,gBAAgB,EAAA;AACvBP,IAAAA,0BAAAA,CAA2BoB,GAAKC,EAAAA,aAAAA,CAAAA;AAChC5F,IAAAA,MAAAA,CAAOyF,eAAe,EAAA;AACxB;;;;"}
|
|
1
|
+
{"version":3,"file":"panorama.js","sources":["../../src/utility/panorama.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { Vector3 } from '@zephyr3d/base';\r\nimport type {\r\n Texture2D,\r\n BindGroup,\r\n GPUProgram,\r\n RenderStateSet,\r\n TextureCube,\r\n VertexLayout\r\n} from '@zephyr3d/device';\r\nimport { gammaToLinear } from '../shaders/misc';\r\nimport { getDevice } from '../app/api';\r\n\r\nlet vertexLayout: Nullable<VertexLayout> = null;\r\nlet renderStates: Nullable<RenderStateSet> = null;\r\nlet panoramaToCubemapProgram: Nullable<GPUProgram> = null;\r\nlet panoramaToCubemapBindGroup: Nullable<BindGroup> = null;\r\nlet panoramaToCubemapProgramRGBM: Nullable<GPUProgram> = null;\r\nlet panoramaToCubemapBindGroupRGBM: Nullable<BindGroup> = null;\r\nconst faceDirections = [\r\n [new Vector3(0, 0, -1), new Vector3(0, -1, 0), new Vector3(1, 0, 0)],\r\n [new Vector3(0, 0, 1), new Vector3(0, -1, 0), new Vector3(-1, 0, 0)],\r\n [new Vector3(1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)],\r\n [new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector3(0, -1, 0)],\r\n [new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1)],\r\n [new Vector3(-1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, -1)]\r\n];\r\n\r\nfunction init() {\r\n const device = getDevice();\r\n const vertices = new Float32Array([1, 1, -1, 1, -1, -1, 1, -1]);\r\n const indices = new Uint16Array([0, 1, 2, 0, 2, 3]);\r\n vertexLayout = device.createVertexLayout({\r\n vertexBuffers: [\r\n {\r\n buffer: device.createVertexBuffer('position_f32x2', vertices)!\r\n }\r\n ],\r\n indexBuffer: device.createIndexBuffer(indices)\r\n });\r\n renderStates = device.createRenderStateSet();\r\n renderStates.useRasterizerState().setCullMode('none');\r\n renderStates.useDepthState().enableTest(false).enableWrite(false);\r\n panoramaToCubemapProgram = createPanoramaToCubemapProgram(false);\r\n panoramaToCubemapBindGroup = device.createBindGroup(panoramaToCubemapProgram.bindGroupLayouts[0]);\r\n panoramaToCubemapProgramRGBM = createPanoramaToCubemapProgram(true);\r\n panoramaToCubemapBindGroupRGBM = device.createBindGroup(panoramaToCubemapProgramRGBM.bindGroupLayouts[0]);\r\n}\r\n\r\nfunction createPanoramaToCubemapProgram(rgbm: boolean) {\r\n const device = getDevice();\r\n const pb = device;\r\n const program = pb.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.pos = pb.vec2().attrib('position');\r\n this.up = pb.vec3().uniform(0);\r\n this.right = pb.vec3().uniform(0);\r\n this.front = pb.vec3().uniform(0);\r\n pb.main(function () {\r\n this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);\r\n this.$outputs.direction = pb.mul(\r\n pb.mat3(this.up, this.right, this.front),\r\n pb.vec3(this.$inputs.pos, 1)\r\n );\r\n if (pb.getDevice().type === 'webgpu') {\r\n this.$builtins.position.y = pb.neg(this.$builtins.position.y);\r\n }\r\n });\r\n },\r\n fragment(pb) {\r\n this.u_panoramaTexture = pb.tex2D().uniform(0);\r\n this.$outputs.outcolor = pb.vec4();\r\n pb.func('dirToUV', [pb.vec3('dir')], function () {\r\n this.$l.x = pb.add(0.5, pb.div(pb.atan2(this.dir.z, this.dir.x), 2 * Math.PI));\r\n this.$l.y = pb.div(pb.acos(this.dir.y), Math.PI);\r\n this.$return(pb.vec2(this.x, this.y));\r\n });\r\n pb.main(function () {\r\n this.$l.uv = this.dirToUV(pb.normalize(this.$inputs.direction));\r\n this.$l.color = pb.textureSampleLevel(this.u_panoramaTexture, this.uv, 0);\r\n if (rgbm) {\r\n this.$l.rgb = pb.mul(this.color.rgb, this.color.a, 6);\r\n this.rgb = gammaToLinear(this, this.rgb);\r\n this.$outputs.outcolor = pb.vec4(this.rgb, 1);\r\n } else {\r\n this.$outputs.outcolor = pb.vec4(this.color.rgb, 1);\r\n }\r\n });\r\n }\r\n })!;\r\n program.name = rgbm ? '@PanoramaToCubemap_RGBM' : '@PanoramaToCubemap';\r\n return program;\r\n}\r\n\r\nfunction doConvertPanoramaToCubemap(srcTexture: Texture2D, dstTexture: TextureCube) {\r\n const device = getDevice();\r\n const rgbm = srcTexture.format === 'rgba8unorm';\r\n const program = rgbm ? panoramaToCubemapProgramRGBM! : panoramaToCubemapProgram!;\r\n const bindgroup = rgbm ? panoramaToCubemapBindGroupRGBM! : panoramaToCubemapBindGroup!;\r\n const framebuffer = device.createFrameBuffer([dstTexture], null);\r\n device.pushDeviceStates();\r\n device.setFramebuffer(framebuffer);\r\n for (let i = 0; i < 6; i++) {\r\n framebuffer.setColorAttachmentCubeFace(0, i);\r\n device.setVertexLayout(vertexLayout);\r\n device.setRenderStates(renderStates);\r\n device.setProgram(program);\r\n device.setBindGroup(0, bindgroup);\r\n bindgroup.setValue('up', faceDirections[i][0]);\r\n bindgroup.setValue('right', faceDirections[i][1]);\r\n bindgroup.setValue('front', faceDirections[i][2]);\r\n bindgroup.setTexture('u_panoramaTexture', srcTexture);\r\n device.draw('triangle-list', 0, 6);\r\n }\r\n device.popDeviceStates();\r\n}\r\n\r\n/**\r\n * Converts an equirectangular image to cubemap\r\n *\r\n * @param tex - The equirectangular image to be converted\r\n * @param textureSize - cubemap size\r\n * @returns The converted cubemap\r\n *\r\n * @public\r\n */\r\nexport function panoramaToCubemap(tex: Texture2D, outputCubeMap: TextureCube) {\r\n const device = getDevice();\r\n if (!vertexLayout) {\r\n init();\r\n }\r\n device.pushDeviceStates();\r\n doConvertPanoramaToCubemap(tex, outputCubeMap);\r\n device.popDeviceStates();\r\n}\r\n"],"names":["vertexLayout","renderStates","panoramaToCubemapProgram","panoramaToCubemapBindGroup","panoramaToCubemapProgramRGBM","panoramaToCubemapBindGroupRGBM","faceDirections","Vector3","init","device","getDevice","vertices","Float32Array","indices","Uint16Array","createVertexLayout","vertexBuffers","buffer","createVertexBuffer","indexBuffer","createIndexBuffer","createRenderStateSet","useRasterizerState","setCullMode","useDepthState","enableTest","enableWrite","createPanoramaToCubemapProgram","createBindGroup","bindGroupLayouts","rgbm","pb","program","buildRenderProgram","vertex","$inputs","pos","vec2","attrib","up","vec3","uniform","right","front","main","$builtins","position","vec4","$outputs","direction","mul","mat3","type","y","neg","fragment","u_panoramaTexture","tex2D","outcolor","func","$l","x","add","div","atan2","dir","z","Math","PI","acos","$return","uv","dirToUV","normalize","color","textureSampleLevel","rgb","a","gammaToLinear","name","doConvertPanoramaToCubemap","srcTexture","dstTexture","format","bindgroup","framebuffer","createFrameBuffer","pushDeviceStates","setFramebuffer","i","setColorAttachmentCubeFace","setVertex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