@babylonjs/lite 1.4.0 → 1.6.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.
Files changed (152) hide show
  1. package/dist/index.js +512 -512
  2. package/dist/index.js.map +1 -1
  3. package/index.d.ts +829 -28
  4. package/lib/audio/analyzer.js +65 -0
  5. package/lib/audio/analyzer.js.map +1 -0
  6. package/lib/audio/audio-bus.js +38 -0
  7. package/lib/audio/audio-bus.js.map +1 -0
  8. package/lib/audio/audio-engine.js +188 -0
  9. package/lib/audio/audio-engine.js.map +1 -0
  10. package/lib/audio/audio-fetch.js +18 -0
  11. package/lib/audio/audio-fetch.js.map +1 -0
  12. package/lib/audio/audio-param.js +96 -0
  13. package/lib/audio/audio-param.js.map +1 -0
  14. package/lib/audio/audio-signal.js +46 -0
  15. package/lib/audio/audio-signal.js.map +1 -0
  16. package/lib/audio/bus.js +33 -0
  17. package/lib/audio/bus.js.map +1 -0
  18. package/lib/audio/host-types.js +2 -0
  19. package/lib/audio/host-types.js.map +1 -0
  20. package/lib/audio/index.js +12 -0
  21. package/lib/audio/index.js.map +1 -0
  22. package/lib/audio/sound-buffer.js +59 -0
  23. package/lib/audio/sound-buffer.js.map +1 -0
  24. package/lib/audio/sound-source.js +57 -0
  25. package/lib/audio/sound-source.js.map +1 -0
  26. package/lib/audio/sound-sub-graph.js +72 -0
  27. package/lib/audio/sound-sub-graph.js.map +1 -0
  28. package/lib/audio/spatial.js +466 -0
  29. package/lib/audio/spatial.js.map +1 -0
  30. package/lib/audio/static-sound.js +313 -0
  31. package/lib/audio/static-sound.js.map +1 -0
  32. package/lib/audio/stereo.js +40 -0
  33. package/lib/audio/stereo.js.map +1 -0
  34. package/lib/audio/streaming-sound.js +377 -0
  35. package/lib/audio/streaming-sound.js.map +1 -0
  36. package/lib/audio/unmute-ui.js +72 -0
  37. package/lib/audio/unmute-ui.js.map +1 -0
  38. package/lib/audio/visualizer.js +101 -0
  39. package/lib/audio/visualizer.js.map +1 -0
  40. package/lib/camera/geospatial-camera-controls.js +22 -0
  41. package/lib/camera/geospatial-camera-controls.js.map +1 -1
  42. package/lib/camera/geospatial-camera-fly.js +2 -1
  43. package/lib/camera/geospatial-camera-fly.js.map +1 -1
  44. package/lib/effect/effect-renderer.js +1 -1
  45. package/lib/effect/effect-renderer.js.map +1 -1
  46. package/lib/engine/engine.js +1 -1
  47. package/lib/index.js +15 -1
  48. package/lib/index.js.map +1 -1
  49. package/lib/light/types.js.map +1 -1
  50. package/lib/loader-gltf/animation-pointer-basecolor.js +25 -0
  51. package/lib/loader-gltf/animation-pointer-basecolor.js.map +1 -0
  52. package/lib/loader-gltf/animation-pointer-ext.js +244 -0
  53. package/lib/loader-gltf/animation-pointer-ext.js.map +1 -0
  54. package/lib/loader-gltf/animation-pointer-lights.js +46 -0
  55. package/lib/loader-gltf/animation-pointer-lights.js.map +1 -0
  56. package/lib/loader-gltf/animation-pointer.js +4 -1
  57. package/lib/loader-gltf/animation-pointer.js.map +1 -1
  58. package/lib/loader-gltf/gltf-animation.js +5 -3
  59. package/lib/loader-gltf/gltf-animation.js.map +1 -1
  60. package/lib/loader-gltf/gltf-color-normalize.js +10 -1
  61. package/lib/loader-gltf/gltf-color-normalize.js.map +1 -1
  62. package/lib/loader-gltf/gltf-feature-animation-pointer.js +67 -47
  63. package/lib/loader-gltf/gltf-feature-animation-pointer.js.map +1 -1
  64. package/lib/loader-gltf/gltf-feature-lights-punctual.js +51 -9
  65. package/lib/loader-gltf/gltf-feature-lights-punctual.js.map +1 -1
  66. package/lib/loader-gltf/gltf-feature-primitive.js +20 -0
  67. package/lib/loader-gltf/gltf-feature-primitive.js.map +1 -0
  68. package/lib/loader-gltf/gltf-feature-registry.js +25 -0
  69. package/lib/loader-gltf/gltf-feature-registry.js.map +1 -1
  70. package/lib/loader-gltf/gltf-feature-skeleton.js +18 -3
  71. package/lib/loader-gltf/gltf-feature-skeleton.js.map +1 -1
  72. package/lib/loader-gltf/gltf-interleave.js +3 -2
  73. package/lib/loader-gltf/gltf-interleave.js.map +1 -1
  74. package/lib/loader-gltf/gltf-light-pointer-state.js +18 -0
  75. package/lib/loader-gltf/gltf-light-pointer-state.js.map +1 -0
  76. package/lib/loader-gltf/gltf-parser.js +7 -1
  77. package/lib/loader-gltf/gltf-parser.js.map +1 -1
  78. package/lib/loader-gltf/gltf-pbr-builder-ext.js +1 -1
  79. package/lib/loader-gltf/gltf-pbr-builder-ext.js.map +1 -1
  80. package/lib/loader-gltf/gltf-pbr-builder.js +1 -1
  81. package/lib/loader-gltf/gltf-pbr-builder.js.map +1 -1
  82. package/lib/loader-gltf/gltf-sampler-denorm.js +20 -0
  83. package/lib/loader-gltf/gltf-sampler-denorm.js.map +1 -0
  84. package/lib/loader-gltf/gltf-sampler-desc.js +11 -2
  85. package/lib/loader-gltf/gltf-sampler-desc.js.map +1 -1
  86. package/lib/loader-gltf/gltf-uv-denorm.js +28 -0
  87. package/lib/loader-gltf/gltf-uv-denorm.js.map +1 -0
  88. package/lib/loader-gltf/load-gltf.js +15 -6
  89. package/lib/loader-gltf/load-gltf.js.map +1 -1
  90. package/lib/material/material-rebuild.js +4 -0
  91. package/lib/material/material-rebuild.js.map +1 -1
  92. package/lib/material/mesh-features.js +8 -1
  93. package/lib/material/mesh-features.js.map +1 -1
  94. package/lib/material/pbr/fragments/reflectance-fragment.js +1 -1
  95. package/lib/material/pbr/fragments/reflectance-fragment.js.map +1 -1
  96. package/lib/material/pbr/fragments/refraction-rtt-fragment.js +1 -1
  97. package/lib/material/pbr/fragments/refraction-rtt-fragment.js.map +1 -1
  98. package/lib/material/pbr/pbr-pipeline.js +7 -3
  99. package/lib/material/pbr/pbr-pipeline.js.map +1 -1
  100. package/lib/material/pbr/pbr-primitive-resolver.js +34 -0
  101. package/lib/material/pbr/pbr-primitive-resolver.js.map +1 -0
  102. package/lib/material/pbr/pbr-renderable.js +1 -1
  103. package/lib/material/pbr/pbr-renderable.js.map +1 -1
  104. package/lib/material/shader/shader-material.js +9 -5
  105. package/lib/material/shader/shader-material.js.map +1 -1
  106. package/lib/material/shader/shader-thin-instance.js +1 -1
  107. package/lib/material/shader/shader-thin-instance.js.map +1 -1
  108. package/lib/material/standard/standard-renderable.js +1 -1
  109. package/lib/material/standard/standard-renderable.js.map +1 -1
  110. package/lib/mesh/mesh-dispose.js +1 -0
  111. package/lib/mesh/mesh-dispose.js.map +1 -1
  112. package/lib/mesh/thin-instance-cull-binding.js +15 -6
  113. package/lib/mesh/thin-instance-cull-binding.js.map +1 -1
  114. package/lib/post-process/taa.js +193 -0
  115. package/lib/post-process/taa.js.map +1 -0
  116. package/lib/scene/scene-core.js +1 -0
  117. package/lib/scene/scene-core.js.map +1 -1
  118. package/lib/scene/scene-material-swap.js +2 -0
  119. package/lib/scene/scene-material-swap.js.map +1 -1
  120. package/lib/shadow/csm-shadow-task-hooks.js +67 -9
  121. package/lib/shadow/csm-shadow-task-hooks.js.map +1 -1
  122. package/lib/sprite/billboard-custom-shader.js +32 -32
  123. package/lib/sprite/billboard-custom-shader.js.map +1 -1
  124. package/lib/sprite/billboard-pipeline.js +54 -56
  125. package/lib/sprite/billboard-pipeline.js.map +1 -1
  126. package/lib/sprite/custom-shader-core.js +1 -1
  127. package/lib/sprite/custom-shader-core.js.map +1 -1
  128. package/lib/sprite/shared/sprite-atlas.js +2 -2
  129. package/lib/sprite/shared/sprite-atlas.js.map +1 -1
  130. package/lib/sprite/sprite-2d-coverage-gamma.js +58 -0
  131. package/lib/sprite/sprite-2d-coverage-gamma.js.map +1 -0
  132. package/lib/sprite/sprite-2d-uvscroll.js +39 -0
  133. package/lib/sprite/sprite-2d-uvscroll.js.map +1 -0
  134. package/lib/sprite/sprite-2d.js +6 -36
  135. package/lib/sprite/sprite-2d.js.map +1 -1
  136. package/lib/sprite/sprite-coverage-gamma-hook.js +10 -0
  137. package/lib/sprite/sprite-coverage-gamma-hook.js.map +1 -0
  138. package/lib/sprite/sprite-custom-shader.js +2 -2
  139. package/lib/sprite/sprite-custom-shader.js.map +1 -1
  140. package/lib/sprite/sprite-pipeline.js +61 -73
  141. package/lib/sprite/sprite-pipeline.js.map +1 -1
  142. package/lib/sprite/sprite-renderable.js +5 -5
  143. package/lib/sprite/sprite-renderable.js.map +1 -1
  144. package/lib/sprite/sprite-renderer.js +4 -4
  145. package/lib/sprite/sprite-renderer.js.map +1 -1
  146. package/lib/sprite/sprite-scene.js +1 -1
  147. package/lib/sprite/sprite-scene.js.map +1 -1
  148. package/lib/text/_gpu/text-pipeline.js +1 -1
  149. package/lib/text/_gpu/text-pipeline.js.map +1 -1
  150. package/lib/text/text-renderer.js +3 -1
  151. package/lib/text/text-renderer.js.map +1 -1
  152. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"effect-renderer.js","sources":["../../../src/effect/effect-renderer.ts"],"sourcesContent":["import { U8 } from \"../engine/typed-arrays.js\";\nimport { BU, SS } from \"../engine/gpu-flags.js\";\nimport { registerRenderingContext, unregisterRenderingContext } from \"../engine/engine.js\";\nimport type { EngineContext, RenderingContext } from \"../engine/engine.js\";\nimport type { SurfaceContext } from \"../engine/surface.js\";\nimport type { RenderTarget, RenderTargetSignature } from \"../engine/render-target.js\";\nimport { buildRenderTarget, createRenderTarget, disposeRenderTarget, targetSignatureKey } from \"../engine/render-target.js\";\nimport type { SceneContext } from \"../scene/scene-core.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport type { Task } from \"../frame-graph/task.js\";\n\nconst DEFAULT_VERTEX_WGSL = `struct EffectVertexOutput{@builtin(position) position:vec4<f32>,@location(0) uv:vec2<f32>};\n@vertex fn effectFullscreenVertex(@builtin(vertex_index) vertexIndex:u32)->EffectVertexOutput{var positions=array<vec2<f32>,3>(vec2<f32>(-1.0,-1.0),vec2<f32>(3.0,-1.0),vec2<f32>(-1.0,3.0));let p=positions[vertexIndex];var out:EffectVertexOutput;out.position=vec4<f32>(p,0.0,1.0);out.uv=p*0.5+vec2<f32>(0.5,0.5);return out;}`;\n\n/** Kind of GPU binding an effect exposes: a uniform buffer, a sampled texture, or a sampler. */\nexport type EffectBindingKind = \"uniform\" | \"texture\" | \"sampler\";\n\n/** Describes a single bind-group entry (binding slot, kind, and type details) for an effect wrapper. */\nexport interface EffectBindingLayout {\n name?: string;\n binding: number;\n kind: EffectBindingKind;\n visibility?: GPUShaderStageFlags;\n uniformByteLength?: number;\n textureSampleType?: GPUTextureSampleType;\n samplerType?: GPUSamplerBindingType;\n textureBinding?: string | number;\n}\n\n/** Configuration for `createEffectWrapper`: the fullscreen fragment shader plus optional vertex shader, bindings, and blend state. */\nexport interface EffectWrapperOptions {\n name?: string;\n fragmentWGSL: string;\n vertexWGSL?: string;\n bindings?: EffectBindingLayout[];\n blend?: GPUBlendState;\n}\n\ninterface EffectUniformSlot {\n readonly layout: EffectBindingLayout;\n buffer: GPUBuffer;\n byteLength: number;\n}\n\ninterface EffectTextureSlot {\n readonly layout: EffectBindingLayout;\n texture: Texture2D | null;\n}\n\n/** A reusable fullscreen effect: owns its shader module, bind-group layout, pipelines, and uniform/texture slots. */\nexport interface EffectWrapper {\n readonly name: string;\n readonly options: EffectWrapperOptions;\n}\n\ninterface EffectWrapperInternal extends EffectWrapper {\n _engine: EngineContext;\n _shader: GPUShaderModule | null;\n _bindGroupLayout: GPUBindGroupLayout | null;\n _pipelineLayout: GPUPipelineLayout | null;\n _bindGroup: GPUBindGroup | null;\n _bindGroupDirty: boolean;\n _pipelines: Map<string, GPURenderPipeline> | null;\n _uniforms: EffectUniformSlot[];\n _textures: EffectTextureSlot[];\n}\n\n/** Configuration for `createEffectRenderTask`: the effect to draw, its render target, and optional clear state. */\nexport interface EffectRenderTaskConfig {\n name: string;\n effect: EffectWrapper;\n target: RenderTarget;\n clear?: boolean;\n clearColor?: GPUColorDict;\n}\n\n/** A frame-graph task that renders an `EffectWrapper` as a fullscreen pass into an offscreen `RenderTarget`. */\nexport interface EffectRenderTask extends Task {\n readonly name: string;\n /** @internal */\n readonly _config: EffectRenderTaskConfig;\n /** @internal */\n readonly _rt: RenderTarget;\n}\n\ninterface EffectRenderTaskInternal extends EffectRenderTask {\n _targetSignature: RenderTargetSignature;\n _renderPassDescriptor: GPURenderPassDescriptor;\n _colorAttachment: GPURenderPassColorAttachment;\n _pipeline: GPURenderPipeline | null;\n _bindGroup: GPUBindGroup | null;\n}\n\n// ─── Direct swapchain renderer (no scene / frame graph required) ─────────────\n\n/** Options for `createEffectRenderer`. */\nexport interface EffectRendererOptions {\n /** Label for GPU resources. Defaults to the effect's own name. */\n name?: string;\n /** Whether to clear the swapchain before drawing. Defaults to `true`. */\n clear?: boolean;\n /** Clear colour. Defaults to opaque black. */\n clearColor?: GPUColorDict;\n /**\n * Per-frame callback invoked just before the effect is drawn, receiving the\n * frame delta in milliseconds. Use it to update uniforms (e.g. time, animation\n * state). This is the effect-path equivalent of a scene's `onBeforeRender`.\n */\n update?: (deltaMs: number) => void;\n}\n\n/**\n * `EffectRenderer` — a fullscreen-effect `RenderingContext` that draws\n * directly to the swapchain without a `SceneContext` or frame-graph task.\n * Use `registerEffectRenderer` / `unregisterEffectRenderer` to attach it to\n * an engine, then call `startEngine` as usual.\n *\n * For offscreen render-to-texture workflows (effect result consumed by a\n * scene material) continue to use `createEffectRenderTask` inside a scene\n * frame graph.\n */\nexport interface EffectRenderer extends RenderingContext {\n readonly name: string;\n}\n\ninterface EffectRendererInternal extends EffectRenderer {\n _surface: SurfaceContext;\n _effect: EffectWrapperInternal;\n _clear: boolean;\n _rt: RenderTarget;\n _targetSignature: RenderTargetSignature;\n _renderPassDescriptor: GPURenderPassDescriptor;\n _colorAttachment: GPURenderPassColorAttachment;\n _pipeline: GPURenderPipeline | null;\n _bindGroup: GPUBindGroup | null;\n _disposed: boolean;\n}\n\n/**\n * Create an `EffectWrapper` for the given engine, allocating uniform buffers and\n * texture slots from `options.bindings`.\n * @param engine - The engine that owns the GPU resources.\n * @param options - Shader source and binding layout for the effect.\n * @returns The new effect wrapper.\n */\nexport function createEffectWrapper(engine: EngineContext, options: EffectWrapperOptions): EffectWrapper {\n const eng = engine as EngineContext;\n const wrapper: EffectWrapperInternal = {\n name: options.name ?? \"effect-wrapper\",\n options,\n _engine: eng,\n _shader: null,\n _bindGroupLayout: null,\n _pipelineLayout: null,\n _bindGroup: null,\n _bindGroupDirty: true,\n _pipelines: null,\n _uniforms: [],\n _textures: [],\n };\n createBindingSlots(wrapper);\n return wrapper;\n}\n\n/**\n * Write data into the effect's uniform buffer(s). Pass a single buffer to write the\n * wrapper's only uniform slot, or a record keyed by binding name/index to write specific slots.\n * @param wrapper - The effect wrapper to update.\n * @param data - The uniform bytes, or a map of binding key to uniform bytes.\n */\nexport function setEffectUniforms(wrapper: EffectWrapper, data: ArrayBuffer | ArrayBufferView | Record<string | number, ArrayBuffer | ArrayBufferView>): void {\n const internal = wrapper as EffectWrapperInternal;\n if (isBufferData(data)) {\n const slot = internal._uniforms[0];\n if (!slot) {\n throw new Error(\"setEffectUniforms: wrapper has no uniform binding.\");\n }\n writeUniformSlot(internal, slot, data);\n return;\n }\n for (const key of Object.keys(data)) {\n const slot = findUniformSlot(internal, key);\n if (!slot) {\n throw new Error(`setEffectUniforms: unknown uniform binding \"${key}\".`);\n }\n writeUniformSlot(internal, slot, data[key]!);\n }\n}\n\n/**\n * Bind a texture to one of the effect's texture slots, marking the bind group dirty so it is rebuilt.\n * @param wrapper - The effect wrapper to update.\n * @param bindingNameOrIndex - The texture binding's name or numeric index.\n * @param texture - The texture to bind.\n */\nexport function setEffectTexture(wrapper: EffectWrapper, bindingNameOrIndex: string | number, texture: Texture2D): void {\n const internal = wrapper as EffectWrapperInternal;\n const slot = findTextureSlot(internal, bindingNameOrIndex);\n if (!slot) {\n throw new Error(`setEffectTexture: unknown texture binding \"${String(bindingNameOrIndex)}\".`);\n }\n slot.texture = texture;\n internal._bindGroupDirty = true;\n}\n\n/**\n * Create a frame-graph task that draws an effect as a fullscreen pass into `config.target`.\n * @param config - The effect, target, and clear settings.\n * @param engine - The owning engine.\n * @param scene - Optional owning scene. Omit for scene-less standalone frame graphs.\n * @returns The render task to add to a frame graph.\n */\nexport function createEffectRenderTask(config: EffectRenderTaskConfig, engine: EngineContext, scene?: SceneContext): EffectRenderTask {\n const eng = engine as EngineContext;\n const effect = config.effect as EffectWrapperInternal;\n const rt = config.target;\n config.clearColor ??= { r: 0, g: 0, b: 0, a: 1 };\n const sampleCount = rt._descriptor.samples ?? 1;\n const targetSignature: RenderTargetSignature = {\n _colorFormat: rt._descriptor.format,\n _sampleCount: sampleCount,\n };\n const colorAttachment = { loadOp: \"clear\", storeOp: \"store\" } as GPURenderPassColorAttachment;\n const task: EffectRenderTaskInternal = {\n name: config.name,\n _config: config,\n engine: eng,\n scene,\n _passes: [],\n _rt: rt,\n _targetSignature: targetSignature,\n _renderPassDescriptor: { label: config.name, colorAttachments: [colorAttachment] },\n _colorAttachment: colorAttachment,\n _pipeline: null,\n _bindGroup: null,\n record(): void {\n buildRenderTarget(rt, eng);\n task._pipeline = getEffectPipeline(effect, task._targetSignature);\n task._bindGroup = getEffectBindGroup(effect);\n },\n execute(): number {\n const pipeline = task._pipeline;\n if (!pipeline) {\n throw new Error(`EffectRenderTask \"${task.name}\" executed before record().`);\n }\n task._bindGroup = getEffectBindGroup(effect);\n applyColorAttachmentState(task._colorAttachment, rt, undefined, task._config.clear !== false, task._config.clearColor!);\n const pass = eng._currentEncoder.beginRenderPass(task._renderPassDescriptor);\n pass.setPipeline(pipeline);\n if (task._bindGroup) {\n pass.setBindGroup(0, task._bindGroup);\n }\n pass.draw(3);\n pass.end();\n return 1;\n },\n dispose(): void {\n task._passes.length = 0;\n disposeRenderTarget(task._rt);\n task._pipeline = null;\n task._bindGroup = null;\n },\n };\n return task;\n}\n\n/** Destroy the uniform buffers and clear the cached pipelines, bind groups, and slots owned by the effect wrapper. */\nexport function disposeEffectWrapper(wrapper: EffectWrapper): void {\n const internal = wrapper as EffectWrapperInternal;\n for (const slot of internal._uniforms) {\n slot.buffer.destroy();\n }\n internal._uniforms.length = 0;\n internal._textures.length = 0;\n internal._pipelines?.clear();\n internal._pipelines = null;\n internal._shader = null;\n internal._bindGroupLayout = null;\n internal._pipelineLayout = null;\n internal._bindGroup = null;\n internal._bindGroupDirty = true;\n}\n\n/**\n * Create an `EffectRenderer` that draws `effect` as a fullscreen pass to the\n * swapchain each frame. The renderer owns a swapchain `RenderTarget` and\n * implements `RenderingContext` directly — no `SceneContext` is needed.\n *\n * Call `registerEffectRenderer` to start rendering, `unregisterEffectRenderer`\n * to pause, and `disposeEffectRenderer` to free GPU resources.\n */\nexport function createEffectRenderer(surface: SurfaceContext, effect: EffectWrapper, options?: EffectRendererOptions): EffectRenderer {\n const eng = surface.engine;\n const ew = effect as EffectWrapperInternal;\n const name = options?.name ?? effect.name;\n const clear = options?.clear !== false;\n const clearColor: GPUColorDict = options?.clearColor ?? { r: 0, g: 0, b: 0, a: 1 };\n const update = options?.update;\n\n // No MSAA → render straight into the single-sample surface scRT; MSAA →\n // render into an MSAA colour RT and resolve into the scRT at end-of-pass.\n const useMsaa = surface.msaaSamples > 1;\n const rt = useMsaa ? createRenderTarget({ lbl: `${name}-msaa`, format: surface.format, samples: surface.msaaSamples, size: surface }) : surface.scRT;\n const resolveRt = useMsaa ? surface.scRT : undefined;\n\n const targetSignature: RenderTargetSignature = {\n _colorFormat: rt._descriptor.format,\n _sampleCount: rt._descriptor.samples ?? 1,\n };\n\n const colorAttachment: GPURenderPassColorAttachment = {\n view: undefined!,\n loadOp: \"clear\",\n storeOp: \"store\",\n };\n const renderPassDescriptor: GPURenderPassDescriptor = { label: name, colorAttachments: [colorAttachment] };\n\n const er: EffectRendererInternal = {\n name,\n clearColor,\n _drawCallsPre: 0,\n _surface: surface,\n _effect: ew,\n _clear: clear,\n _rt: rt,\n _targetSignature: targetSignature,\n _renderPassDescriptor: renderPassDescriptor,\n _colorAttachment: colorAttachment,\n _pipeline: null,\n _bindGroup: null,\n _disposed: false,\n _update(): void {\n update?.(eng._currentDelta);\n },\n _record(): number {\n if (er._disposed) {\n return 0;\n }\n ensureRtCanvasSize(er._rt);\n applyColorAttachmentState(er._colorAttachment, er._rt, resolveRt, er._clear, er.clearColor);\n const encoder = er._surface.engine._currentEncoder;\n if (!encoder) {\n return 0;\n }\n const pipeline = er._pipeline;\n if (!pipeline) {\n throw new Error(`EffectRenderer \"${er.name}\" recorded before registerEffectRenderer().`);\n }\n const pass = encoder.beginRenderPass(er._renderPassDescriptor);\n pass.setPipeline(pipeline);\n if (er._bindGroup) {\n pass.setBindGroup(0, er._bindGroup);\n }\n pass.draw(3);\n pass.end();\n return 1;\n },\n _resize(): void {\n if (er._disposed) {\n return;\n }\n buildRenderTarget(er._rt, er._surface.engine);\n },\n };\n return er;\n}\n\n/** Register the effect renderer with its surface. Idempotent — a second call is a no-op. */\nexport function registerEffectRenderer(er: EffectRenderer): void {\n const internal = er as EffectRendererInternal;\n prepareEffectRenderer(internal);\n registerRenderingContext(internal._surface, er);\n}\n\n/** Unregister the effect renderer from its surface. No-op if not registered. */\nexport function unregisterEffectRenderer(er: EffectRenderer): void {\n unregisterRenderingContext((er as EffectRendererInternal)._surface, er);\n}\n\n/** Unregister and free all GPU resources owned by the renderer. */\nexport function disposeEffectRenderer(er: EffectRenderer): void {\n const internal = er as EffectRendererInternal;\n if (internal._disposed) {\n return;\n }\n unregisterEffectRenderer(er);\n disposeRenderTarget(internal._rt);\n internal._disposed = true;\n}\n\nfunction createBindingSlots(wrapper: EffectWrapperInternal): void {\n const layouts = [...(wrapper.options.bindings ?? [])].sort((a, b) => a.binding - b.binding);\n const seen = new Set<number>();\n for (const layout of layouts) {\n if (seen.has(layout.binding)) {\n throw new Error(`createEffectWrapper: duplicate binding ${layout.binding}.`);\n }\n seen.add(layout.binding);\n if (layout.kind === \"uniform\") {\n const byteLength = align4(layout.uniformByteLength ?? 16);\n const buffer = wrapper._engine._device.createBuffer({\n label: `${wrapper.name}-${layout.name ?? layout.binding}-ubo`,\n size: byteLength,\n usage: BU.UNIFORM | BU.COPY_DST,\n });\n wrapper._uniforms.push({ layout, buffer, byteLength });\n } else if (layout.kind === \"texture\") {\n wrapper._textures.push({ layout, texture: null });\n }\n }\n}\n\nfunction applyColorAttachmentState(att: GPURenderPassColorAttachment, rt: RenderTarget, resolveRt: RenderTarget | undefined, clear: boolean, clearColor: GPUColorDict): void {\n att.clearValue = clearColor;\n att.loadOp = clear ? \"clear\" : \"load\";\n // Re-read each frame so a swapchain target (used as `rt` when single-sample, or as\n // the MSAA `resolveRt`) picks up its fresh per-frame view.\n att.view = rt._colorView!;\n att.resolveTarget = resolveRt?._colorView ?? undefined;\n}\n\nfunction ensureRtCanvasSize(rt: RenderTarget): void {\n const size = rt._descriptor.size;\n if (!(\"canvas\" in size)) {\n return;\n }\n // Surface-sized RT: rebuild when the surface's canvas backing-store has resized.\n const canvas = size.canvas;\n if (rt._width === canvas.width && rt._height === canvas.height) {\n return;\n }\n buildRenderTarget(rt, size.engine);\n}\n\nfunction getEffectPipeline(wrapper: EffectWrapperInternal, targetSignature: RenderTargetSignature): GPURenderPipeline {\n const key = targetSignatureKey(targetSignature);\n if (!wrapper._pipelines) {\n wrapper._pipelines = new Map();\n }\n const hit = wrapper._pipelines.get(key);\n if (hit) {\n return hit;\n }\n const device = wrapper._engine._device;\n const pipeline = device.createRenderPipeline({\n label: `${wrapper.name}-${key}`,\n layout: getPipelineLayout(wrapper),\n vertex: { module: getShaderModule(wrapper), entryPoint: \"effectFullscreenVertex\" },\n fragment: {\n module: getShaderModule(wrapper),\n entryPoint: \"effectFragment\",\n targets: [{ format: targetSignature._colorFormat!, blend: wrapper.options.blend }],\n },\n primitive: { topology: \"triangle-list\" },\n multisample: { count: targetSignature._sampleCount },\n });\n wrapper._pipelines.set(key, pipeline);\n return pipeline;\n}\n\nfunction getShaderModule(wrapper: EffectWrapperInternal): GPUShaderModule {\n if (!wrapper._shader) {\n wrapper._shader = wrapper._engine._device.createShaderModule({\n label: wrapper.name,\n code: `${wrapper.options.vertexWGSL ?? DEFAULT_VERTEX_WGSL}\\n${wrapper.options.fragmentWGSL}`,\n });\n }\n return wrapper._shader;\n}\n\nfunction getPipelineLayout(wrapper: EffectWrapperInternal): GPUPipelineLayout {\n if (!wrapper._pipelineLayout) {\n wrapper._pipelineLayout = wrapper._engine._device.createPipelineLayout({\n label: `${wrapper.name}-pipeline-layout`,\n bindGroupLayouts: [getBindGroupLayout(wrapper)],\n });\n }\n return wrapper._pipelineLayout;\n}\n\nfunction getBindGroupLayout(wrapper: EffectWrapperInternal): GPUBindGroupLayout {\n if (!wrapper._bindGroupLayout) {\n const entries = (wrapper.options.bindings ?? [])\n .slice()\n .sort((a, b) => a.binding - b.binding)\n .map((layout) => bindingLayoutEntry(layout));\n wrapper._bindGroupLayout = wrapper._engine._device.createBindGroupLayout({\n label: `${wrapper.name}-bgl`,\n entries,\n });\n }\n return wrapper._bindGroupLayout;\n}\n\nfunction bindingLayoutEntry(layout: EffectBindingLayout): GPUBindGroupLayoutEntry {\n const visibility = layout.visibility ?? SS.FRAGMENT;\n if (layout.kind === \"uniform\") {\n return { binding: layout.binding, visibility, buffer: { type: \"uniform\" } };\n }\n if (layout.kind === \"texture\") {\n return { binding: layout.binding, visibility, texture: { sampleType: layout.textureSampleType ?? \"float\" } };\n }\n return { binding: layout.binding, visibility, sampler: { type: layout.samplerType ?? \"filtering\" } };\n}\n\nfunction getEffectBindGroup(wrapper: EffectWrapperInternal): GPUBindGroup | null {\n const bindings = wrapper.options.bindings ?? [];\n if (bindings.length === 0) {\n return null;\n }\n if (!wrapper._bindGroupDirty && wrapper._bindGroup) {\n return wrapper._bindGroup;\n }\n const entries = bindings\n .slice()\n .sort((a, b) => a.binding - b.binding)\n .map((layout) => bindGroupEntry(wrapper, layout));\n wrapper._bindGroup = wrapper._engine._device.createBindGroup({\n label: `${wrapper.name}-bg`,\n layout: getBindGroupLayout(wrapper),\n entries,\n });\n wrapper._bindGroupDirty = false;\n return wrapper._bindGroup;\n}\n\nfunction prepareEffectRenderer(er: EffectRendererInternal): void {\n er._pipeline ??= getEffectPipeline(er._effect, er._targetSignature);\n er._bindGroup = getEffectBindGroup(er._effect);\n}\n\nfunction bindGroupEntry(wrapper: EffectWrapperInternal, layout: EffectBindingLayout): GPUBindGroupEntry {\n if (layout.kind === \"uniform\") {\n const slot = findUniformSlot(wrapper, layout.binding);\n if (!slot) {\n throw new Error(`Effect \"${wrapper.name}\" missing uniform binding ${layout.binding}.`);\n }\n return { binding: layout.binding, resource: { buffer: slot.buffer, size: slot.byteLength } };\n }\n if (layout.kind === \"texture\") {\n const slot = findTextureSlot(wrapper, layout.binding);\n if (!slot?.texture) {\n throw new Error(`Effect \"${wrapper.name}\" missing texture binding ${layout.binding}.`);\n }\n return { binding: layout.binding, resource: slot.texture.view };\n }\n const textureSlot = layout.textureBinding != null ? findTextureSlot(wrapper, layout.textureBinding) : wrapper._textures[0];\n if (!textureSlot?.texture) {\n throw new Error(`Effect \"${wrapper.name}\" missing texture for sampler binding ${layout.binding}.`);\n }\n return { binding: layout.binding, resource: textureSlot.texture.sampler };\n}\n\nfunction findUniformSlot(wrapper: EffectWrapperInternal, bindingNameOrIndex: string | number): EffectUniformSlot | undefined {\n return wrapper._uniforms.find((slot) => matchesBinding(slot.layout, bindingNameOrIndex));\n}\n\nfunction findTextureSlot(wrapper: EffectWrapperInternal, bindingNameOrIndex: string | number): EffectTextureSlot | undefined {\n return wrapper._textures.find((slot) => matchesBinding(slot.layout, bindingNameOrIndex));\n}\n\nfunction matchesBinding(layout: EffectBindingLayout, bindingNameOrIndex: string | number): boolean {\n if (typeof bindingNameOrIndex === \"number\") {\n return layout.binding === bindingNameOrIndex;\n }\n return layout.name === bindingNameOrIndex || String(layout.binding) === bindingNameOrIndex;\n}\n\nfunction writeUniformSlot(wrapper: EffectWrapperInternal, slot: EffectUniformSlot, data: ArrayBuffer | ArrayBufferView): void {\n const bytes = toBytes(data);\n if (bytes.byteLength > slot.byteLength) {\n throw new Error(`writeUniformSlot: ${bytes.byteLength} bytes exceeds uniform binding ${slot.layout.binding} size ${slot.byteLength}.`);\n }\n wrapper._engine._device.queue.writeBuffer(slot.buffer, 0, bytes.buffer, bytes.byteOffset, bytes.byteLength);\n}\n\nfunction toBytes(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n if (data instanceof ArrayBuffer) {\n return new U8(data);\n }\n return new U8(data.buffer, data.byteOffset, data.byteLength);\n}\n\nfunction isBufferData(data: ArrayBuffer | ArrayBufferView | Record<string | number, ArrayBuffer | ArrayBufferView>): data is ArrayBuffer | ArrayBufferView {\n return data instanceof ArrayBuffer || ArrayBuffer.isView(data);\n}\n\nfunction align4(value: number): number {\n return (value + 3) & ~3;\n}\n"],"names":[],"mappings":";;;;;AAWA,MAAM,mBAAA,GAAsB,CAAA;AAAA,mUAAA,CAAA;AAsIrB,SAAS,mBAAA,CAAoB,QAAuB,OAAA,EAA8C;AACrG,EAAA,MAAM,GAAA,GAAM,MAAA;AACZ,EAAA,MAAM,OAAA,GAAiC;AAAA,IACnC,IAAA,EAAM,QAAQ,IAAA,IAAQ,gBAAA;AAAA,IACtB,OAAA;AAAA,IACA,OAAA,EAAS,GAAA;AAAA,IACT,OAAA,EAAS,IAAA;AAAA,IACT,gBAAA,EAAkB,IAAA;AAAA,IAClB,eAAA,EAAiB,IAAA;AAAA,IACjB,UAAA,EAAY,IAAA;AAAA,IACZ,eAAA,EAAiB,IAAA;AAAA,IACjB,UAAA,EAAY,IAAA;AAAA,IACZ,WAAW,EAAC;AAAA,IACZ,WAAW;AAAC,GAChB;AACA,EAAA,kBAAA,CAAmB,OAAO,CAAA;AAC1B,EAAA,OAAO,OAAA;AACX;AAQO,SAAS,iBAAA,CAAkB,SAAwB,IAAA,EAAoG;AAC1J,EAAA,MAAM,QAAA,GAAW,OAAA;AACjB,EAAA,IAAI,YAAA,CAAa,IAAI,CAAA,EAAG;AACpB,IAAA,MAAM,IAAA,GAAO,QAAA,CAAS,SAAA,CAAU,CAAC,CAAA;AACjC,IAAA,IAAI,CAAC,IA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,IAAI,EAAA,CAAG,IAAA,CAAK,QAAQ,IAAA,CAAK,UAAA,EAAY,KAAK,UAAU,CAAA;AAC/D;AAEA,SAAS,aAAa,IAAA,EAAqI;AACvJ,EAAA,OAAO,IAAA,YAAgB,WAAA,IAAe,WAAA,CAAY,MAAA,CAAO,IAAI,CAAA;AACjE;AAEA,SAAS,OAAO,KAAA,EAAuB;AACnC,EAAA,OAAQ,KAAA,GAAQ,IAAK,EAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"effect-renderer.js","sources":["../../../src/effect/effect-renderer.ts"],"sourcesContent":["import { U8 } from \"../engine/typed-arrays.js\";\nimport { BU, SS } from \"../engine/gpu-flags.js\";\nimport { registerRenderingContext, unregisterRenderingContext } from \"../engine/engine.js\";\nimport type { EngineContext, RenderingContext } from \"../engine/engine.js\";\nimport type { SurfaceContext } from \"../engine/surface.js\";\nimport type { RenderTarget, RenderTargetSignature } from \"../engine/render-target.js\";\nimport { buildRenderTarget, createRenderTarget, disposeRenderTarget, targetSignatureKey } from \"../engine/render-target.js\";\nimport type { SceneContext } from \"../scene/scene-core.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport type { Task } from \"../frame-graph/task.js\";\n\nconst DEFAULT_VERTEX_WGSL = `struct EffectVertexOutput{@builtin(position) position:vec4<f32>,@location(0) uv:vec2<f32>};\n@vertex fn effectFullscreenVertex(@builtin(vertex_index) vertexIndex:u32)->EffectVertexOutput{var positions=array<vec2<f32>,3>(vec2<f32>(-1.0,-1.0),vec2<f32>(3.0,-1.0),vec2<f32>(-1.0,3.0));let p=positions[vertexIndex];var out:EffectVertexOutput;out.position=vec4<f32>(p,0.0,1.0);out.uv=p*0.5+vec2<f32>(0.5,0.5);return out;}`;\n\n/** Kind of GPU binding an effect exposes: a uniform buffer, a sampled texture, or a sampler. */\nexport type EffectBindingKind = \"uniform\" | \"texture\" | \"sampler\";\n\n/** Describes a single bind-group entry (binding slot, kind, and type details) for an effect wrapper. */\nexport interface EffectBindingLayout {\n name?: string;\n binding: number;\n kind: EffectBindingKind;\n visibility?: GPUShaderStageFlags;\n uniformByteLength?: number;\n textureSampleType?: GPUTextureSampleType;\n /** Texture view dimension for a `texture` binding (default `\"2d\"`). Set `\"2d-array\"`/`\"cube\"`/… so a\n * fullscreen effect can sample an array/cube texture (e.g. the CSM cascade depth array). */\n viewDimension?: GPUTextureViewDimension;\n samplerType?: GPUSamplerBindingType;\n textureBinding?: string | number;\n}\n\n/** Configuration for `createEffectWrapper`: the fullscreen fragment shader plus optional vertex shader, bindings, and blend state. */\nexport interface EffectWrapperOptions {\n name?: string;\n fragmentWGSL: string;\n vertexWGSL?: string;\n bindings?: EffectBindingLayout[];\n blend?: GPUBlendState;\n}\n\ninterface EffectUniformSlot {\n readonly layout: EffectBindingLayout;\n buffer: GPUBuffer;\n byteLength: number;\n}\n\ninterface EffectTextureSlot {\n readonly layout: EffectBindingLayout;\n texture: Texture2D | null;\n}\n\n/** A reusable fullscreen effect: owns its shader module, bind-group layout, pipelines, and uniform/texture slots. */\nexport interface EffectWrapper {\n readonly name: string;\n readonly options: EffectWrapperOptions;\n}\n\ninterface EffectWrapperInternal extends EffectWrapper {\n _engine: EngineContext;\n _shader: GPUShaderModule | null;\n _bindGroupLayout: GPUBindGroupLayout | null;\n _pipelineLayout: GPUPipelineLayout | null;\n _bindGroup: GPUBindGroup | null;\n _bindGroupDirty: boolean;\n _pipelines: Map<string, GPURenderPipeline> | null;\n _uniforms: EffectUniformSlot[];\n _textures: EffectTextureSlot[];\n}\n\n/** Configuration for `createEffectRenderTask`: the effect to draw, its render target, and optional clear state. */\nexport interface EffectRenderTaskConfig {\n name: string;\n effect: EffectWrapper;\n target: RenderTarget;\n clear?: boolean;\n clearColor?: GPUColorDict;\n}\n\n/** A frame-graph task that renders an `EffectWrapper` as a fullscreen pass into an offscreen `RenderTarget`. */\nexport interface EffectRenderTask extends Task {\n readonly name: string;\n /** @internal */\n readonly _config: EffectRenderTaskConfig;\n /** @internal */\n readonly _rt: RenderTarget;\n}\n\ninterface EffectRenderTaskInternal extends EffectRenderTask {\n _targetSignature: RenderTargetSignature;\n _renderPassDescriptor: GPURenderPassDescriptor;\n _colorAttachment: GPURenderPassColorAttachment;\n _pipeline: GPURenderPipeline | null;\n _bindGroup: GPUBindGroup | null;\n}\n\n// ─── Direct swapchain renderer (no scene / frame graph required) ─────────────\n\n/** Options for `createEffectRenderer`. */\nexport interface EffectRendererOptions {\n /** Label for GPU resources. Defaults to the effect's own name. */\n name?: string;\n /** Whether to clear the swapchain before drawing. Defaults to `true`. */\n clear?: boolean;\n /** Clear colour. Defaults to opaque black. */\n clearColor?: GPUColorDict;\n /**\n * Per-frame callback invoked just before the effect is drawn, receiving the\n * frame delta in milliseconds. Use it to update uniforms (e.g. time, animation\n * state). This is the effect-path equivalent of a scene's `onBeforeRender`.\n */\n update?: (deltaMs: number) => void;\n}\n\n/**\n * `EffectRenderer` — a fullscreen-effect `RenderingContext` that draws\n * directly to the swapchain without a `SceneContext` or frame-graph task.\n * Use `registerEffectRenderer` / `unregisterEffectRenderer` to attach it to\n * an engine, then call `startEngine` as usual.\n *\n * For offscreen render-to-texture workflows (effect result consumed by a\n * scene material) continue to use `createEffectRenderTask` inside a scene\n * frame graph.\n */\nexport interface EffectRenderer extends RenderingContext {\n readonly name: string;\n}\n\ninterface EffectRendererInternal extends EffectRenderer {\n _surface: SurfaceContext;\n _effect: EffectWrapperInternal;\n _clear: boolean;\n _rt: RenderTarget;\n _targetSignature: RenderTargetSignature;\n _renderPassDescriptor: GPURenderPassDescriptor;\n _colorAttachment: GPURenderPassColorAttachment;\n _pipeline: GPURenderPipeline | null;\n _bindGroup: GPUBindGroup | null;\n _disposed: boolean;\n}\n\n/**\n * Create an `EffectWrapper` for the given engine, allocating uniform buffers and\n * texture slots from `options.bindings`.\n * @param engine - The engine that owns the GPU resources.\n * @param options - Shader source and binding layout for the effect.\n * @returns The new effect wrapper.\n */\nexport function createEffectWrapper(engine: EngineContext, options: EffectWrapperOptions): EffectWrapper {\n const eng = engine as EngineContext;\n const wrapper: EffectWrapperInternal = {\n name: options.name ?? \"effect-wrapper\",\n options,\n _engine: eng,\n _shader: null,\n _bindGroupLayout: null,\n _pipelineLayout: null,\n _bindGroup: null,\n _bindGroupDirty: true,\n _pipelines: null,\n _uniforms: [],\n _textures: [],\n };\n createBindingSlots(wrapper);\n return wrapper;\n}\n\n/**\n * Write data into the effect's uniform buffer(s). Pass a single buffer to write the\n * wrapper's only uniform slot, or a record keyed by binding name/index to write specific slots.\n * @param wrapper - The effect wrapper to update.\n * @param data - The uniform bytes, or a map of binding key to uniform bytes.\n */\nexport function setEffectUniforms(wrapper: EffectWrapper, data: ArrayBuffer | ArrayBufferView | Record<string | number, ArrayBuffer | ArrayBufferView>): void {\n const internal = wrapper as EffectWrapperInternal;\n if (isBufferData(data)) {\n const slot = internal._uniforms[0];\n if (!slot) {\n throw new Error(\"setEffectUniforms: wrapper has no uniform binding.\");\n }\n writeUniformSlot(internal, slot, data);\n return;\n }\n for (const key of Object.keys(data)) {\n const slot = findUniformSlot(internal, key);\n if (!slot) {\n throw new Error(`setEffectUniforms: unknown uniform binding \"${key}\".`);\n }\n writeUniformSlot(internal, slot, data[key]!);\n }\n}\n\n/**\n * Bind a texture to one of the effect's texture slots, marking the bind group dirty so it is rebuilt.\n * @param wrapper - The effect wrapper to update.\n * @param bindingNameOrIndex - The texture binding's name or numeric index.\n * @param texture - The texture to bind.\n */\nexport function setEffectTexture(wrapper: EffectWrapper, bindingNameOrIndex: string | number, texture: Texture2D): void {\n const internal = wrapper as EffectWrapperInternal;\n const slot = findTextureSlot(internal, bindingNameOrIndex);\n if (!slot) {\n throw new Error(`setEffectTexture: unknown texture binding \"${String(bindingNameOrIndex)}\".`);\n }\n slot.texture = texture;\n internal._bindGroupDirty = true;\n}\n\n/**\n * Create a frame-graph task that draws an effect as a fullscreen pass into `config.target`.\n * @param config - The effect, target, and clear settings.\n * @param engine - The owning engine.\n * @param scene - Optional owning scene. Omit for scene-less standalone frame graphs.\n * @returns The render task to add to a frame graph.\n */\nexport function createEffectRenderTask(config: EffectRenderTaskConfig, engine: EngineContext, scene?: SceneContext): EffectRenderTask {\n const eng = engine as EngineContext;\n const effect = config.effect as EffectWrapperInternal;\n const rt = config.target;\n config.clearColor ??= { r: 0, g: 0, b: 0, a: 1 };\n const sampleCount = rt._descriptor.samples ?? 1;\n const targetSignature: RenderTargetSignature = {\n _colorFormat: rt._descriptor.format,\n _sampleCount: sampleCount,\n };\n const colorAttachment = { loadOp: \"clear\", storeOp: \"store\" } as GPURenderPassColorAttachment;\n const task: EffectRenderTaskInternal = {\n name: config.name,\n _config: config,\n engine: eng,\n scene,\n _passes: [],\n _rt: rt,\n _targetSignature: targetSignature,\n _renderPassDescriptor: { label: config.name, colorAttachments: [colorAttachment] },\n _colorAttachment: colorAttachment,\n _pipeline: null,\n _bindGroup: null,\n record(): void {\n buildRenderTarget(rt, eng);\n task._pipeline = getEffectPipeline(effect, task._targetSignature);\n task._bindGroup = getEffectBindGroup(effect);\n },\n execute(): number {\n const pipeline = task._pipeline;\n if (!pipeline) {\n throw new Error(`EffectRenderTask \"${task.name}\" executed before record().`);\n }\n task._bindGroup = getEffectBindGroup(effect);\n applyColorAttachmentState(task._colorAttachment, rt, undefined, task._config.clear !== false, task._config.clearColor!);\n const pass = eng._currentEncoder.beginRenderPass(task._renderPassDescriptor);\n pass.setPipeline(pipeline);\n if (task._bindGroup) {\n pass.setBindGroup(0, task._bindGroup);\n }\n pass.draw(3);\n pass.end();\n return 1;\n },\n dispose(): void {\n task._passes.length = 0;\n disposeRenderTarget(task._rt);\n task._pipeline = null;\n task._bindGroup = null;\n },\n };\n return task;\n}\n\n/** Destroy the uniform buffers and clear the cached pipelines, bind groups, and slots owned by the effect wrapper. */\nexport function disposeEffectWrapper(wrapper: EffectWrapper): void {\n const internal = wrapper as EffectWrapperInternal;\n for (const slot of internal._uniforms) {\n slot.buffer.destroy();\n }\n internal._uniforms.length = 0;\n internal._textures.length = 0;\n internal._pipelines?.clear();\n internal._pipelines = null;\n internal._shader = null;\n internal._bindGroupLayout = null;\n internal._pipelineLayout = null;\n internal._bindGroup = null;\n internal._bindGroupDirty = true;\n}\n\n/**\n * Create an `EffectRenderer` that draws `effect` as a fullscreen pass to the\n * swapchain each frame. The renderer owns a swapchain `RenderTarget` and\n * implements `RenderingContext` directly — no `SceneContext` is needed.\n *\n * Call `registerEffectRenderer` to start rendering, `unregisterEffectRenderer`\n * to pause, and `disposeEffectRenderer` to free GPU resources.\n */\nexport function createEffectRenderer(surface: SurfaceContext, effect: EffectWrapper, options?: EffectRendererOptions): EffectRenderer {\n const eng = surface.engine;\n const ew = effect as EffectWrapperInternal;\n const name = options?.name ?? effect.name;\n const clear = options?.clear !== false;\n const clearColor: GPUColorDict = options?.clearColor ?? { r: 0, g: 0, b: 0, a: 1 };\n const update = options?.update;\n\n // No MSAA → render straight into the single-sample surface scRT; MSAA →\n // render into an MSAA colour RT and resolve into the scRT at end-of-pass.\n const useMsaa = surface.msaaSamples > 1;\n const rt = useMsaa ? createRenderTarget({ lbl: `${name}-msaa`, format: surface.format, samples: surface.msaaSamples, size: surface }) : surface.scRT;\n const resolveRt = useMsaa ? surface.scRT : undefined;\n\n const targetSignature: RenderTargetSignature = {\n _colorFormat: rt._descriptor.format,\n _sampleCount: rt._descriptor.samples ?? 1,\n };\n\n const colorAttachment: GPURenderPassColorAttachment = {\n view: undefined!,\n loadOp: \"clear\",\n storeOp: \"store\",\n };\n const renderPassDescriptor: GPURenderPassDescriptor = { label: name, colorAttachments: [colorAttachment] };\n\n const er: EffectRendererInternal = {\n name,\n clearColor,\n _drawCallsPre: 0,\n _surface: surface,\n _effect: ew,\n _clear: clear,\n _rt: rt,\n _targetSignature: targetSignature,\n _renderPassDescriptor: renderPassDescriptor,\n _colorAttachment: colorAttachment,\n _pipeline: null,\n _bindGroup: null,\n _disposed: false,\n _update(): void {\n update?.(eng._currentDelta);\n },\n _record(): number {\n if (er._disposed) {\n return 0;\n }\n ensureRtCanvasSize(er._rt);\n applyColorAttachmentState(er._colorAttachment, er._rt, resolveRt, er._clear, er.clearColor);\n const encoder = er._surface.engine._currentEncoder;\n if (!encoder) {\n return 0;\n }\n const pipeline = er._pipeline;\n if (!pipeline) {\n throw new Error(`EffectRenderer \"${er.name}\" recorded before registerEffectRenderer().`);\n }\n const pass = encoder.beginRenderPass(er._renderPassDescriptor);\n pass.setPipeline(pipeline);\n if (er._bindGroup) {\n pass.setBindGroup(0, er._bindGroup);\n }\n pass.draw(3);\n pass.end();\n return 1;\n },\n _resize(): void {\n if (er._disposed) {\n return;\n }\n buildRenderTarget(er._rt, er._surface.engine);\n },\n };\n return er;\n}\n\n/** Register the effect renderer with its surface. Idempotent — a second call is a no-op. */\nexport function registerEffectRenderer(er: EffectRenderer): void {\n const internal = er as EffectRendererInternal;\n prepareEffectRenderer(internal);\n registerRenderingContext(internal._surface, er);\n}\n\n/** Unregister the effect renderer from its surface. No-op if not registered. */\nexport function unregisterEffectRenderer(er: EffectRenderer): void {\n unregisterRenderingContext((er as EffectRendererInternal)._surface, er);\n}\n\n/** Unregister and free all GPU resources owned by the renderer. */\nexport function disposeEffectRenderer(er: EffectRenderer): void {\n const internal = er as EffectRendererInternal;\n if (internal._disposed) {\n return;\n }\n unregisterEffectRenderer(er);\n disposeRenderTarget(internal._rt);\n internal._disposed = true;\n}\n\nfunction createBindingSlots(wrapper: EffectWrapperInternal): void {\n const layouts = [...(wrapper.options.bindings ?? [])].sort((a, b) => a.binding - b.binding);\n const seen = new Set<number>();\n for (const layout of layouts) {\n if (seen.has(layout.binding)) {\n throw new Error(`createEffectWrapper: duplicate binding ${layout.binding}.`);\n }\n seen.add(layout.binding);\n if (layout.kind === \"uniform\") {\n const byteLength = align4(layout.uniformByteLength ?? 16);\n const buffer = wrapper._engine._device.createBuffer({\n label: `${wrapper.name}-${layout.name ?? layout.binding}-ubo`,\n size: byteLength,\n usage: BU.UNIFORM | BU.COPY_DST,\n });\n wrapper._uniforms.push({ layout, buffer, byteLength });\n } else if (layout.kind === \"texture\") {\n wrapper._textures.push({ layout, texture: null });\n }\n }\n}\n\nfunction applyColorAttachmentState(att: GPURenderPassColorAttachment, rt: RenderTarget, resolveRt: RenderTarget | undefined, clear: boolean, clearColor: GPUColorDict): void {\n att.clearValue = clearColor;\n att.loadOp = clear ? \"clear\" : \"load\";\n // Re-read each frame so a swapchain target (used as `rt` when single-sample, or as\n // the MSAA `resolveRt`) picks up its fresh per-frame view.\n att.view = rt._colorView!;\n att.resolveTarget = resolveRt?._colorView ?? undefined;\n}\n\nfunction ensureRtCanvasSize(rt: RenderTarget): void {\n const size = rt._descriptor.size;\n if (!(\"canvas\" in size)) {\n return;\n }\n // Surface-sized RT: rebuild when the surface's canvas backing-store has resized.\n const canvas = size.canvas;\n if (rt._width === canvas.width && rt._height === canvas.height) {\n return;\n }\n buildRenderTarget(rt, size.engine);\n}\n\nfunction getEffectPipeline(wrapper: EffectWrapperInternal, targetSignature: RenderTargetSignature): GPURenderPipeline {\n const key = targetSignatureKey(targetSignature);\n if (!wrapper._pipelines) {\n wrapper._pipelines = new Map();\n }\n const hit = wrapper._pipelines.get(key);\n if (hit) {\n return hit;\n }\n const device = wrapper._engine._device;\n const pipeline = device.createRenderPipeline({\n label: `${wrapper.name}-${key}`,\n layout: getPipelineLayout(wrapper),\n vertex: { module: getShaderModule(wrapper), entryPoint: \"effectFullscreenVertex\" },\n fragment: {\n module: getShaderModule(wrapper),\n entryPoint: \"effectFragment\",\n targets: [{ format: targetSignature._colorFormat!, blend: wrapper.options.blend }],\n },\n primitive: { topology: \"triangle-list\" },\n multisample: { count: targetSignature._sampleCount },\n });\n wrapper._pipelines.set(key, pipeline);\n return pipeline;\n}\n\nfunction getShaderModule(wrapper: EffectWrapperInternal): GPUShaderModule {\n if (!wrapper._shader) {\n wrapper._shader = wrapper._engine._device.createShaderModule({\n label: wrapper.name,\n code: `${wrapper.options.vertexWGSL ?? DEFAULT_VERTEX_WGSL}\\n${wrapper.options.fragmentWGSL}`,\n });\n }\n return wrapper._shader;\n}\n\nfunction getPipelineLayout(wrapper: EffectWrapperInternal): GPUPipelineLayout {\n if (!wrapper._pipelineLayout) {\n wrapper._pipelineLayout = wrapper._engine._device.createPipelineLayout({\n label: `${wrapper.name}-pipeline-layout`,\n bindGroupLayouts: [getBindGroupLayout(wrapper)],\n });\n }\n return wrapper._pipelineLayout;\n}\n\nfunction getBindGroupLayout(wrapper: EffectWrapperInternal): GPUBindGroupLayout {\n if (!wrapper._bindGroupLayout) {\n const entries = (wrapper.options.bindings ?? [])\n .slice()\n .sort((a, b) => a.binding - b.binding)\n .map((layout) => bindingLayoutEntry(layout));\n wrapper._bindGroupLayout = wrapper._engine._device.createBindGroupLayout({\n label: `${wrapper.name}-bgl`,\n entries,\n });\n }\n return wrapper._bindGroupLayout;\n}\n\nfunction bindingLayoutEntry(layout: EffectBindingLayout): GPUBindGroupLayoutEntry {\n const visibility = layout.visibility ?? SS.FRAGMENT;\n if (layout.kind === \"uniform\") {\n return { binding: layout.binding, visibility, buffer: { type: \"uniform\" } };\n }\n if (layout.kind === \"texture\") {\n return { binding: layout.binding, visibility, texture: { sampleType: layout.textureSampleType ?? \"float\", viewDimension: layout.viewDimension ?? \"2d\" } };\n }\n return { binding: layout.binding, visibility, sampler: { type: layout.samplerType ?? \"filtering\" } };\n}\n\nfunction getEffectBindGroup(wrapper: EffectWrapperInternal): GPUBindGroup | null {\n const bindings = wrapper.options.bindings ?? [];\n if (bindings.length === 0) {\n return null;\n }\n if (!wrapper._bindGroupDirty && wrapper._bindGroup) {\n return wrapper._bindGroup;\n }\n const entries = bindings\n .slice()\n .sort((a, b) => a.binding - b.binding)\n .map((layout) => bindGroupEntry(wrapper, layout));\n wrapper._bindGroup = wrapper._engine._device.createBindGroup({\n label: `${wrapper.name}-bg`,\n layout: getBindGroupLayout(wrapper),\n entries,\n });\n wrapper._bindGroupDirty = false;\n return wrapper._bindGroup;\n}\n\nfunction prepareEffectRenderer(er: EffectRendererInternal): void {\n er._pipeline ??= getEffectPipeline(er._effect, er._targetSignature);\n er._bindGroup = getEffectBindGroup(er._effect);\n}\n\nfunction bindGroupEntry(wrapper: EffectWrapperInternal, layout: EffectBindingLayout): GPUBindGroupEntry {\n if (layout.kind === \"uniform\") {\n const slot = findUniformSlot(wrapper, layout.binding);\n if (!slot) {\n throw new Error(`Effect \"${wrapper.name}\" missing uniform binding ${layout.binding}.`);\n }\n return { binding: layout.binding, resource: { buffer: slot.buffer, size: slot.byteLength } };\n }\n if (layout.kind === \"texture\") {\n const slot = findTextureSlot(wrapper, layout.binding);\n if (!slot?.texture) {\n throw new Error(`Effect \"${wrapper.name}\" missing texture binding ${layout.binding}.`);\n }\n return { binding: layout.binding, resource: slot.texture.view };\n }\n const textureSlot = layout.textureBinding != null ? findTextureSlot(wrapper, layout.textureBinding) : wrapper._textures[0];\n if (!textureSlot?.texture) {\n throw new Error(`Effect \"${wrapper.name}\" missing texture for sampler binding ${layout.binding}.`);\n }\n return { binding: layout.binding, resource: textureSlot.texture.sampler };\n}\n\nfunction findUniformSlot(wrapper: EffectWrapperInternal, bindingNameOrIndex: string | number): EffectUniformSlot | undefined {\n return wrapper._uniforms.find((slot) => matchesBinding(slot.layout, bindingNameOrIndex));\n}\n\nfunction findTextureSlot(wrapper: EffectWrapperInternal, bindingNameOrIndex: string | number): EffectTextureSlot | undefined {\n return wrapper._textures.find((slot) => matchesBinding(slot.layout, bindingNameOrIndex));\n}\n\nfunction matchesBinding(layout: EffectBindingLayout, bindingNameOrIndex: string | number): boolean {\n if (typeof bindingNameOrIndex === \"number\") {\n return layout.binding === bindingNameOrIndex;\n }\n return layout.name === bindingNameOrIndex || String(layout.binding) === bindingNameOrIndex;\n}\n\nfunction writeUniformSlot(wrapper: EffectWrapperInternal, slot: EffectUniformSlot, data: ArrayBuffer | ArrayBufferView): void {\n const bytes = toBytes(data);\n if (bytes.byteLength > slot.byteLength) {\n throw new Error(`writeUniformSlot: ${bytes.byteLength} bytes exceeds uniform binding ${slot.layout.binding} size ${slot.byteLength}.`);\n }\n wrapper._engine._device.queue.writeBuffer(slot.buffer, 0, bytes.buffer, bytes.byteOffset, bytes.byteLength);\n}\n\nfunction toBytes(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n if (data instanceof ArrayBuffer) {\n return new U8(data);\n }\n return new U8(data.buffer, data.byteOffset, data.byteLength);\n}\n\nfunction isBufferData(data: ArrayBuffer | ArrayBufferView | Record<string | number, ArrayBuffer | ArrayBufferView>): data is ArrayBuffer | ArrayBufferView {\n return data instanceof ArrayBuffer || ArrayBuffer.isView(data);\n}\n\nfunction align4(value: number): number {\n return (value + 3) & ~3;\n}\n"],"names":[],"mappings":";;;;;AAWA,MAAM,mBAAA,GAAsB,CAAA;AAAA,mUAAA,CAAA;AAyIrB,SAAS,mBAAA,CAAoB,QAAuB,OAAA,EAA8C;AACrG,EAAA,MAAM,GAAA,GAAM,MAAA;AACZ,EAAA,MAAM,OAAA,GAAiC;AAAA,IACnC,IAAA,EAAM,QAAQ,IAAA,IAAQ,gBAAA;AAAA,IACtB,OAAA;AAAA,IACA,OAAA,EAAS,GAAA;AAAA,IACT,OAAA,EAAS,IAAA;AAAA,IACT,gBAAA,EAAkB,IAAA;AAAA,IAClB,eAAA,EAAiB,IAAA;AAAA,IACjB,UAAA,EAAY,IAAA;AAAA,IACZ,eAAA,EAAiB,IAAA;AAAA,IACjB,UAAA,EAAY,IAAA;AAAA,IACZ,WAAW,EAAC;AAAA,IACZ,WAAW;AAAC,GAChB;AACA,EAAA,kBAAA,CAAmB,OAAO,CAAA;AAC1B,EAAA,OAAO,OAAA;AACX;AAQO,SAAS,iBAAA,CAAkB,SAAwB,IAAA,EAAoG;AAC1J,EAAA,MAAM,QAAA,GAAW,OAAA;AACjB,EAAA,IAAI,YAAA,CAAa,IAAI,CAAA,EAAG;AACpB,IAAA,MAAM,IAAA,GAAO,QAAA,CAAS,SAAA,CAAU,CAAC,CAAA;AACjC,IAAA,IAAI,C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AI,CAAA;AAAA,EACtB;AACA,EAAA,OAAO,IAAI,EAAA,CAAG,IAAA,CAAK,QAAQ,IAAA,CAAK,UAAA,EAAY,KAAK,UAAU,CAAA;AAC/D;AAEA,SAAS,aAAa,IAAA,EAAqI;AACvJ,EAAA,OAAO,IAAA,YAAgB,WAAA,IAAe,WAAA,CAAY,MAAA,CAAO,IAAI,CAAA;AACjE;AAEA,SAAS,OAAO,KAAA,EAAuB;AACnC,EAAA,OAAQ,KAAA,GAAQ,IAAK,EAAC;AAC1B;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { _setHpmAllocator } from '../math/_matrix-allocator.js';
2
2
  import { isDomCanvas, _buildSurface, resizeSurface, _refreshScRT, setSurfaceSize } from './surface.js';
3
3
 
4
- const VERSION = /* @__PURE__ */ (() => "1.4.0" )();
4
+ const VERSION = /* @__PURE__ */ (() => "1.6.0" )();
5
5
  let _vis = 0;
6
6
  function bumpVisibilityEpoch() {
7
7
  _vis = _vis + 1 | 0;
package/lib/index.js CHANGED
@@ -30,6 +30,7 @@ export { createChromaticAberrationPostProcessTask } from './post-process/chromat
30
30
  export { createCircleOfConfusionPostProcessTask } from './post-process/circle-of-confusion.js';
31
31
  export { createBloomPostProcessTask } from './post-process/bloom.js';
32
32
  export { DepthOfFieldBlurLevel, createDepthOfFieldPostProcessTask } from './post-process/depth-of-field.js';
33
+ export { createTaaPostProcessTask } from './post-process/taa.js';
33
34
  export { createArcRotateCamera } from './camera/arc-rotate.js';
34
35
  export { attachControl, setCameraLimits } from './camera/arc-rotate-controls.js';
35
36
  export { createFreeCamera } from './camera/free-camera.js';
@@ -163,7 +164,9 @@ export { attachBoundingBoxGizmoToNode, createBoundingBoxGizmo, disposeBoundingBo
163
164
  export { createGridSpriteAtlas, loadSpriteAtlas } from './sprite/shared/sprite-atlas.js';
164
165
  export { appendSpriteAtlasFrames, createSpriteAtlasFromFrames } from './sprite/shared/sprite-atlas-packer.js';
165
166
  export { spriteBlendAdditive, spriteBlendAlpha, spriteBlendMultiply, spriteBlendPremultiplied } from './sprite/sprite-blend.js';
166
- export { addSprite2DIndex, clearSprite2DLayer, createSprite2DLayer, removeSprite2DIndex, setSprite2DFrameIndex, setSprite2DShaderParams, setSprite2DUvOffset, updateSprite2DIndex } from './sprite/sprite-2d.js';
167
+ export { addSprite2DIndex, clearSprite2DLayer, createSprite2DLayer, removeSprite2DIndex, setSprite2DFrameIndex, setSprite2DShaderParams, updateSprite2DIndex } from './sprite/sprite-2d.js';
168
+ export { setSprite2DCoverageGamma } from './sprite/sprite-2d-coverage-gamma.js';
169
+ export { setSprite2DUvOffset } from './sprite/sprite-2d-uvscroll.js';
167
170
  export { createSprite2DCustomShader } from './sprite/sprite-custom-shader.js';
168
171
  export { addSprite2D, getSprite2DHandleIndex, isSprite2DHandleAlive, removeSprite2D, setSprite2DFrame, updateSprite2D } from './sprite/sprite-2d-handle.js';
169
172
  export { addDepthHostedSpriteLayer } from './sprite/sprite-scene.js';
@@ -194,4 +197,15 @@ export { onPhysicsTrigger, setPhysicsShapeIsTrigger } from './physics/havok-trig
194
197
  export { createPhysicsViewer, disposePhysicsViewer, hidePhysicsBody, showPhysicsBody, showPhysicsConstraint } from './physics/physics-viewer.js';
195
198
  export { CharacterCollisionObservable, CharacterSupportedState, PhysicsCharacterController, createPhysicsCharacterController } from './physics/character-controller.js';
196
199
  export { addAgent, addBoxObstacle, addCylinderObstacle, agentGoto, computePath, createDebugNavMeshGeometry, createNavCrowd, createNavMesh, createNavMeshFromSources, createNavigationPluginAsync, disposeNavigationPlugin, findRandomPoint, findRandomPointAroundCircle, getAgentPosition, getAgentVelocity, getClosestPoint, getNavigationRandomSeed, raycast, removeObstacle, setNavigationRandomSeed, updateNavCrowd, updateNavMeshObstacles } from './navigation/navigation.js';
200
+ export { createAudioEngineAsync, disposeAudioEngine, getMasterVolume, setMasterVolume, unlockAudioEngineAsync } from './audio/audio-engine.js';
201
+ export { SoundState, createSoundAsync, disposeSound, pauseSound, playSound, resumeSound, setSoundVolume, stopSound } from './audio/static-sound.js';
202
+ export { createStreamingSoundAsync, disposeStreamingSound, pauseStreamingSound, playStreamingSound, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, resumeStreamingSound, setStreamingSoundVolume, stopStreamingSound } from './audio/streaming-sound.js';
203
+ export { createAudioBusAsync, disposeAudioBus, setBusVolume } from './audio/audio-bus.js';
204
+ export { attachSpatialTarget, detachSpatialTarget, enableSpatial, setSpatialAutoUpdate, setSpatialListener, setSpatialListenerPosition, setSpatialOrientation, setSpatialPosition, updateSpatialAudio } from './audio/spatial.js';
205
+ export { enableStereo, setStereoPan } from './audio/stereo.js';
206
+ export { enableAnalyzer, getByteFrequencyData, getByteTimeDomainData, getFloatFrequencyData, getFloatTimeDomainData } from './audio/analyzer.js';
207
+ export { createMicrophoneSoundSourceAsync, createSoundSourceAsync, disposeSoundSource, setSoundSourceVolume } from './audio/sound-source.js';
208
+ export { createUnmuteUI, disposeUnmuteUI, setUnmuteUIEnabled } from './audio/unmute-ui.js';
209
+ export { createAudioVisualizer, disposeAudioVisualizer, renderAudioVisualizerFrame, startAudioVisualizer, stopAudioVisualizer } from './audio/visualizer.js';
210
+ export { createSoundBufferAsync } from './audio/sound-buffer.js';
197
211
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/light/types.ts"],"sourcesContent":["/** Light extension types and registry.\n *\n * Each light type provides pipeline integration callbacks.\n * PBR + Standard both consume the shared lights UBO (render/lights-ubo.ts);\n * light type is encoded in vLightData.w (1=dir, 2=spot, 3=hemi, other=point). */\n\nimport type { Mat4 } from \"../math/types.js\";\nimport type { IWorldMatrixProvider, IParentable } from \"../scene/parentable.js\";\nimport type { SceneNode } from \"../scene/scene-node.js\";\n\n/** Shared base for all light types.\n * Provides pipeline integration callbacks so render pipelines are light-agnostic. */\nexport interface LightBase extends IWorldMatrixProvider, IParentable {\n readonly lightType: string;\n children: SceneNode[];\n /** Mesh IDs excluded from this light. If set, these meshes are NOT lit by this light. */\n excludedMeshIds?: ReadonlySet<string>;\n /** If non-empty, ONLY these mesh IDs are lit by this light. Takes priority over excludedMeshIds. */\n includedOnlyMeshIds?: ReadonlySet<string>;\n /** Shadow generator attached to this light. Set this to make the light cast shadows. */\n shadowGenerator?: import(\"../shadow/shadow-generator.js\").ShadowGenerator;\n\n parent: IWorldMatrixProvider | null;\n readonly worldMatrix: Mat4;\n readonly worldMatrixVersion: number;\n /** @internal Write this light's 64-byte entry into the shared lights UBO.\n * Positions are written precision-only (raw world space); under floating\n * origin the active-camera offset is subtracted afterwards by\n * `engine._applyLightFoOffset`, which is kept out of non-LWR bundles. */\n readonly _writeLightUbo?: ((data: Float32Array, offset: number) => void) | undefined;\n /** @internal Monotonically increasing version — bumped when any UBO-relevant property changes. */\n readonly _lightVersion: number;\n}\n\n/** Maximum number of scene lights packed into the shared lights UBO.\n * Babylon.js defaults to 4 lights per material; Babylon Lite's cap is scene-wide\n * because all materials index the same group-0 lights buffer. Raise via\n * `setMaxLights(n)` before creating any scene / loading any asset that needs\n * more lights (e.g. the glTF loader auto-raises this when an asset declares\n * more KHR_lights_punctual lights than the current cap). */\nexport let MAX_LIGHTS = 16;\n\n/** Raise (or lower) the maximum number of scene lights in the shared lights UBO.\n * Must be called BEFORE scene pipelines are compiled — existing pipelines\n * and UBOs bake the cap into their WGSL/layout. */\nexport function setMaxLights(n: number): void {\n if (!Number.isFinite(n) || n < 1) {\n throw new Error(`setMaxLights: expected positive integer, got ${n}`);\n }\n MAX_LIGHTS = n | 0;\n}\n\n/** Bytes per light entry in the lights UBO (4 × vec4 = 64 bytes). */\nexport const LIGHT_ENTRY_FLOATS = 16;\n"],"names":[],"mappings":"AAwCO,IAAI,UAAA,GAAa;AAKjB,SAAS,aAAa,CAAA,EAAiB;AAC1C,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,CAAC,CAAA,IAAK,IAAI,CAAA,EAAG;AAC9B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,6CAAA,EAAgD,CAAC,CAAA,CAAE,CAAA;AAAA,EACvE;AACA,EAAA,UAAA,GAAa,CAAA,GAAI,CAAA;AACrB;AAGO,MAAM,kBAAA,GAAqB;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/light/types.ts"],"sourcesContent":["/** Light extension types and registry.\n *\n * Each light type provides pipeline integration callbacks.\n * PBR + Standard both consume the shared lights UBO (render/lights-ubo.ts);\n * light type is encoded in vLightData.w (1=dir, 2=spot, 3=hemi, other=point). */\n\nimport type { Mat4 } from \"../math/types.js\";\nimport type { IWorldMatrixProvider, IParentable } from \"../scene/parentable.js\";\nimport type { SceneNode } from \"../scene/scene-node.js\";\n\n/** Shared base for all light types.\n * Provides pipeline integration callbacks so render pipelines are light-agnostic. */\nexport interface LightBase extends IWorldMatrixProvider, IParentable {\n readonly lightType: string;\n children: SceneNode[];\n /** Mesh IDs excluded from this light. If set, these meshes are NOT lit by this light. */\n excludedMeshIds?: ReadonlySet<string>;\n /** If non-empty, ONLY these mesh IDs are lit by this light. Takes priority over excludedMeshIds. */\n includedOnlyMeshIds?: ReadonlySet<string>;\n /** Shadow generator attached to this light. Set this to make the light cast shadows. */\n shadowGenerator?: import(\"../shadow/shadow-generator.js\").ShadowGenerator;\n\n parent: IWorldMatrixProvider | null;\n readonly worldMatrix: Mat4;\n readonly worldMatrixVersion: number;\n /** @internal Write this light's 64-byte entry into the shared lights UBO.\n * Positions are written precision-only (raw world space); under floating\n * origin the active-camera offset is subtracted afterwards by\n * `engine._applyLightFoOffset`, which is kept out of non-LWR bundles. */\n readonly _writeLightUbo?: ((data: Float32Array, offset: number) => void) | undefined;\n /** @internal Monotonically increasing version — bumped when any UBO-relevant property changes. */\n readonly _lightVersion: number;\n /** @internal Bumps `_lightVersion` after direct mutation of scalar/array light fields. */\n readonly _bumpLightVersion?: (() => void) | undefined;\n}\n\n/** Maximum number of scene lights packed into the shared lights UBO.\n * Babylon.js defaults to 4 lights per material; Babylon Lite's cap is scene-wide\n * because all materials index the same group-0 lights buffer. Raise via\n * `setMaxLights(n)` before creating any scene / loading any asset that needs\n * more lights (e.g. the glTF loader auto-raises this when an asset declares\n * more KHR_lights_punctual lights than the current cap). */\nexport let MAX_LIGHTS = 16;\n\n/** Raise (or lower) the maximum number of scene lights in the shared lights UBO.\n * Must be called BEFORE scene pipelines are compiled — existing pipelines\n * and UBOs bake the cap into their WGSL/layout. */\nexport function setMaxLights(n: number): void {\n if (!Number.isFinite(n) || n < 1) {\n throw new Error(`setMaxLights: expected positive integer, got ${n}`);\n }\n MAX_LIGHTS = n | 0;\n}\n\n/** Bytes per light entry in the lights UBO (4 × vec4 = 64 bytes). */\nexport const LIGHT_ENTRY_FLOATS = 16;\n"],"names":[],"mappings":"AA0CO,IAAI,UAAA,GAAa;AAKjB,SAAS,aAAa,CAAA,EAAiB;AAC1C,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,CAAC,CAAA,IAAK,IAAI,CAAA,EAAG;AAC9B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,6CAAA,EAAgD,CAAC,CAAA,CAAE,CAAA;AAAA,EACvE;AACA,EAAA,UAAA,GAAa,CAAA,GAAI,CAAA;AACrB;AAGO,MAAM,kBAAA,GAAqB;;;;"}
@@ -0,0 +1,25 @@
1
+ let _animBaseColorDefs = null;
2
+ function collectBaseColorDefs(json) {
3
+ for (const anim of json.animations ?? []) {
4
+ for (const ch of anim.channels ?? []) {
5
+ const ptr = ch.target?.extensions?.KHR_animation_pointer?.pointer;
6
+ const m = ptr && /^\/materials\/(\d+)\/pbrMetallicRoughness\/baseColorFactor$/.exec(ptr);
7
+ const def = m && json.materials?.[+m[1]];
8
+ if (def) {
9
+ (_animBaseColorDefs ??= /* @__PURE__ */ new WeakSet()).add(def);
10
+ }
11
+ }
12
+ }
13
+ }
14
+ function whiteFallback(mat) {
15
+ if (mat._rawMatDef && _animBaseColorDefs?.has(mat._rawMatDef) && !mat._baseColorImage) {
16
+ const f = mat._baseColorFactor;
17
+ const real = [f[0], f[1], f[2], f[3]];
18
+ mat._baseColorFactor = [1, 1, 1, 1];
19
+ return { baseColorFactor: real };
20
+ }
21
+ return null;
22
+ }
23
+
24
+ export { collectBaseColorDefs, whiteFallback };
25
+ //# sourceMappingURL=animation-pointer-basecolor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation-pointer-basecolor.js","sources":["../../../src/loader-gltf/animation-pointer-basecolor.ts"],"sourcesContent":["/** KHR_animation_pointer — animated baseColorFactor white-fallback handling.\n *\n * Dynamic-imported by the animation-pointer feature ONLY when a channel targets a\n * material's pbrMetallicRoughness/baseColorFactor, so scenes that animate just node\n * visibility / TRS / lights / UV transforms (e.g. scene34) never pay for it. */\nimport type { GltfMaterialData } from \"./gltf-material.js\";\nimport type { PbrMaterialProps } from \"../material/pbr/pbr-material.js\";\n\n// Raw glTF material defs (json.materials[i] objects) whose baseColorFactor is animated.\n// Lazy-init (not a module-level allocation) so this module stays tree-shakable per GUIDANCE.\nlet _animBaseColorDefs: WeakSet<object> | null = null;\n\n/** Record every material def targeted by a baseColorFactor pointer so the white-fallback\n * below can recognise it during material assembly. */\nexport function collectBaseColorDefs(json: any): void {\n for (const anim of json.animations ?? []) {\n for (const ch of anim.channels ?? []) {\n const ptr = ch.target?.extensions?.KHR_animation_pointer?.pointer as string | undefined;\n const m = ptr && /^\\/materials\\/(\\d+)\\/pbrMetallicRoughness\\/baseColorFactor$/.exec(ptr);\n const def = m && json.materials?.[+m[1]!];\n if (def) {\n (_animBaseColorDefs ??= new WeakSet<object>()).add(def);\n }\n }\n }\n}\n\n/** For an UNTEXTURED material whose baseColorFactor is animated, the loader would bake the\n * (initial) factor into the 1×1 base-colour fallback AND multiply the animated factor in\n * the shader — doubling colour and alpha. Bake a WHITE fallback instead and route the\n * factor through the (animatable) baseColorFactor uniform. */\nexport function whiteFallback(mat: GltfMaterialData): Partial<PbrMaterialProps> | null {\n if (mat._rawMatDef && _animBaseColorDefs?.has(mat._rawMatDef) && !mat._baseColorImage) {\n const f = mat._baseColorFactor;\n const real: [number, number, number, number] = [f[0]!, f[1]!, f[2]!, f[3]!];\n mat._baseColorFactor = [1, 1, 1, 1];\n return { baseColorFactor: real };\n }\n return null;\n}\n"],"names":[],"mappings":"AAUA,IAAI,kBAAA,GAA6C,IAAA;AAI1C,SAAS,qBAAqB,IAAA,EAAiB;AAClD,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,UAAA,IAAc,EAAC,EAAG;AACtC,IAAA,KAAA,MAAW,EAAA,IAAM,IAAA,CAAK,QAAA,IAAY,EAAC,EAAG;AAClC,MAAA,MAAM,GAAA,GAAM,EAAA,CAAG,MAAA,EAAQ,UAAA,EAAY,qBAAA,EAAuB,OAAA;AAC1D,MAAA,MAAM,CAAA,GAAI,GAAA,IAAO,6DAAA,CAA8D,IAAA,CAAK,GAAG,CAAA;AACvF,MAAA,MAAM,MAAM,CAAA,IAAK,IAAA,CAAK,YAAY,CAAC,CAAA,CAAE,CAAC,CAAE,CAAA;AACxC,MAAA,IAAI,GAAA,EAAK;AACL,QAAA,CAAC,kBAAA,qBAAuB,IAAI,OAAA,EAAgB,EAAG,IAAI,GAAG,CAAA;AAAA,MAC1D;AAAA,IACJ;AAAA,EACJ;AACJ;AAMO,SAAS,cAAc,GAAA,EAAyD;AACnF,EAAA,IAAI,GAAA,CAAI,cAAc,kBAAA,EAAoB,GAAA,CAAI,IAAI,UAAU,CAAA,IAAK,CAAC,GAAA,CAAI,eAAA,EAAiB;AACnF,IAAA,MAAM,IAAI,GAAA,CAAI,gBAAA;AACd,IAAA,MAAM,IAAA,GAAyC,CAAC,CAAA,CAAE,CAAC,CAAA,EAAI,CAAA,CAAE,CAAC,CAAA,EAAI,CAAA,CAAE,CAAC,CAAA,EAAI,CAAA,CAAE,CAAC,CAAE,CAAA;AAC1E,IAAA,GAAA,CAAI,gBAAA,GAAmB,CAAC,CAAA,EAAG,CAAA,EAAG,GAAG,CAAC,CAAA;AAClC,IAAA,OAAO,EAAE,iBAAiB,IAAA,EAAK;AAAA,EACnC;AACA,EAAA,OAAO,IAAA;AACX;;;;"}
@@ -0,0 +1,244 @@
1
+ import { _appendPointerHandlers } from './animation-pointer.js';
2
+
3
+ function iorToF0Factor(ior) {
4
+ return ((ior - 1) / (ior + 1)) ** 2 / 0.04;
5
+ }
6
+ function bump(mat) {
7
+ mat._uboVersion++;
8
+ }
9
+ const _extHandlers = [
10
+ // BJS 9.5 registers the glTF metallicFactor pointer twice, with the second
11
+ // entry overwriting the first to animate PBRMaterial.roughness. Match that
12
+ // behavior for parity; roughnessFactor itself is not registered by BJS.
13
+ [
14
+ /^\/materials\/(\d+)\/pbrMetallicRoughness\/metallicFactor$/,
15
+ (m, ctx) => {
16
+ const mat = ctx.materials?.[+m[1]];
17
+ if (!mat) {
18
+ return null;
19
+ }
20
+ return {
21
+ arity: 1,
22
+ writer: (out, off) => {
23
+ mat.roughnessFactor = out[off];
24
+ mat._uboVersion++;
25
+ }
26
+ };
27
+ }
28
+ ],
29
+ // /materials/{m}/normalTexture/scale — scalar glTF normal-map strength. The
30
+ // shader scale mod is provided by the lazy pbr-template-ext (loaded for materials
31
+ // that already carry a UV transform / vertex colour / UV2), so this writer only
32
+ // updates the existing `normalScale` UBO slot — no core shader path is added.
33
+ [
34
+ /^\/materials\/(\d+)\/normalTexture\/scale$/,
35
+ (m, ctx) => {
36
+ const mat = ctx.materials?.[+m[1]];
37
+ if (!mat) {
38
+ return null;
39
+ }
40
+ return {
41
+ arity: 1,
42
+ writer: (out, off) => {
43
+ mat.normalTextureScale = out[off];
44
+ mat._uboVersion++;
45
+ }
46
+ };
47
+ }
48
+ ],
49
+ // /materials/{m}/extensions/KHR_materials_transmission/transmissionFactor
50
+ [
51
+ /^\/materials\/(\d+)\/extensions\/KHR_materials_transmission\/transmissionFactor$/,
52
+ (m, ctx) => {
53
+ const mat = ctx.materials?.[+m[1]];
54
+ const refr = mat?.subsurface?.refraction;
55
+ if (!mat || !refr) {
56
+ return null;
57
+ }
58
+ return {
59
+ arity: 1,
60
+ writer: (out, off) => {
61
+ mat.transmissive = true;
62
+ refr.intensity = out[off];
63
+ bump(mat);
64
+ }
65
+ };
66
+ }
67
+ ],
68
+ // /materials/{m}/extensions/KHR_materials_ior/ior
69
+ [
70
+ /^\/materials\/(\d+)\/extensions\/KHR_materials_ior\/ior$/,
71
+ (m, ctx) => {
72
+ const mat = ctx.materials?.[+m[1]];
73
+ if (!mat) {
74
+ return null;
75
+ }
76
+ return {
77
+ arity: 1,
78
+ writer: (out, off) => {
79
+ const ior = out[off];
80
+ if (mat.subsurface?.refraction) {
81
+ mat.subsurface.refraction.indexOfRefraction = ior;
82
+ }
83
+ mat.metallicF0Factor = iorToF0Factor(ior);
84
+ mat.specularWeight = 1;
85
+ mat._hasReflExt = true;
86
+ bump(mat);
87
+ }
88
+ };
89
+ }
90
+ ],
91
+ // /materials/{m}/extensions/KHR_materials_volume/{thicknessFactor|attenuationDistance|attenuationColor}
92
+ [
93
+ /^\/materials\/(\d+)\/extensions\/KHR_materials_volume\/(thicknessFactor|attenuationDistance|attenuationColor)$/,
94
+ (m, ctx) => {
95
+ const mat = ctx.materials?.[+m[1]];
96
+ if (!mat?.subsurface) {
97
+ return null;
98
+ }
99
+ return {
100
+ arity: m[2] === "attenuationColor" ? 3 : 1,
101
+ writer: (out, off) => {
102
+ const ss = mat.subsurface;
103
+ if (m[2] === "thicknessFactor") {
104
+ ss.thickness ??= { min: 0, max: 0, useGlTFChannel: true };
105
+ ss.thickness.max = out[off];
106
+ if (ss.refraction) {
107
+ ss.refraction.useThicknessAsDepth = true;
108
+ }
109
+ } else {
110
+ ss.tint ??= { color: [1, 1, 1], atDistance: 1 };
111
+ if (m[2] === "attenuationDistance") {
112
+ ss.tint.atDistance = out[off];
113
+ } else {
114
+ ss.tint.color = [out[off], out[off + 1], out[off + 2]];
115
+ }
116
+ }
117
+ bump(mat);
118
+ }
119
+ };
120
+ }
121
+ ],
122
+ // /materials/{m}/extensions/KHR_materials_iridescence/{iridescenceFactor|iridescenceIor|iridescenceThicknessMaximum}
123
+ [
124
+ /^\/materials\/(\d+)\/extensions\/KHR_materials_iridescence\/(iridescenceFactor|iridescenceIor|iridescenceThicknessMaximum)$/,
125
+ (m, ctx) => {
126
+ const mat = ctx.materials?.[+m[1]];
127
+ const iri = mat?.iridescence;
128
+ if (!mat || !iri) {
129
+ return null;
130
+ }
131
+ return {
132
+ arity: 1,
133
+ writer: (out, off) => {
134
+ const v = out[off];
135
+ if (m[2] === "iridescenceFactor") {
136
+ iri.intensity = v;
137
+ } else if (m[2] === "iridescenceIor") {
138
+ iri.indexOfRefraction = v;
139
+ } else {
140
+ iri.maximumThickness = v;
141
+ }
142
+ bump(mat);
143
+ }
144
+ };
145
+ }
146
+ ],
147
+ // /materials/{m}/occlusionTexture/strength — scalar ambient-occlusion strength.
148
+ // The occlusion mix (mix(1, orm.r, strength)) is supplied by the lazy reflectance
149
+ // ext, which the animation feature activates via `_hasReflExt`; this writer only
150
+ // updates the `occlusionStrength` UBO slot that ext owns — zero core shader cost.
151
+ [
152
+ /^\/materials\/(\d+)\/occlusionTexture\/strength$/,
153
+ (m, ctx) => {
154
+ const mat = ctx.materials?.[+m[1]];
155
+ if (!mat) {
156
+ return null;
157
+ }
158
+ return {
159
+ arity: 1,
160
+ writer: (out, off) => {
161
+ mat.occlusionStrength = out[off];
162
+ mat._uboVersion++;
163
+ }
164
+ };
165
+ }
166
+ ]
167
+ ];
168
+ _appendPointerHandlers(_extHandlers);
169
+ function seedExtMaterials(json, map) {
170
+ const occlusionStrengthAnimated = /* @__PURE__ */ new Set();
171
+ const transmissionAnimated = /* @__PURE__ */ new Set();
172
+ const iorAnimated = /* @__PURE__ */ new Set();
173
+ const volumeThicknessAnimated = /* @__PURE__ */ new Set();
174
+ const volumeTintAnimated = /* @__PURE__ */ new Set();
175
+ for (const anim of json.animations ?? []) {
176
+ for (const ch of anim.channels ?? []) {
177
+ const ptr = ch.target?.extensions?.KHR_animation_pointer?.pointer;
178
+ const os = ptr && /^\/materials\/(\d+)\/occlusionTexture\/strength$/.exec(ptr);
179
+ if (os) {
180
+ occlusionStrengthAnimated.add(+os[1]);
181
+ }
182
+ const tr = ptr && /^\/materials\/(\d+)\/extensions\/KHR_materials_transmission\/transmissionFactor$/.exec(ptr);
183
+ if (tr) {
184
+ transmissionAnimated.add(+tr[1]);
185
+ }
186
+ const ior = ptr && /^\/materials\/(\d+)\/extensions\/KHR_materials_ior\/ior$/.exec(ptr);
187
+ if (ior) {
188
+ iorAnimated.add(+ior[1]);
189
+ }
190
+ const vt = ptr && /^\/materials\/(\d+)\/extensions\/KHR_materials_volume\/thicknessFactor$/.exec(ptr);
191
+ if (vt) {
192
+ volumeThicknessAnimated.add(+vt[1]);
193
+ }
194
+ const vc = ptr && /^\/materials\/(\d+)\/extensions\/KHR_materials_volume\/(attenuationColor|attenuationDistance)$/.exec(ptr);
195
+ if (vc) {
196
+ volumeTintAnimated.add(+vc[1]);
197
+ }
198
+ }
199
+ }
200
+ for (let matIdx = 0; matIdx < map.length; matIdx++) {
201
+ const pm = map[matIdx];
202
+ if (!pm) {
203
+ continue;
204
+ }
205
+ const def = json.materials?.[matIdx];
206
+ if (occlusionStrengthAnimated.has(matIdx)) {
207
+ pm.occlusionStrength = def?.occlusionTexture?.strength ?? 1;
208
+ pm._hasReflExt = true;
209
+ pm._occlStrengthAnimated = true;
210
+ }
211
+ if (transmissionAnimated.has(matIdx)) {
212
+ pm.transmissive = true;
213
+ pm.subsurface ??= {};
214
+ pm.subsurface.refraction ??= {
215
+ intensity: def?.extensions?.KHR_materials_transmission?.transmissionFactor ?? 0,
216
+ indexOfRefraction: def?.extensions?.KHR_materials_ior?.ior ?? 1.5
217
+ };
218
+ }
219
+ if (iorAnimated.has(matIdx)) {
220
+ pm.subsurface ??= {};
221
+ pm.subsurface.refraction ??= { intensity: 0, indexOfRefraction: def?.extensions?.KHR_materials_ior?.ior ?? 1.5 };
222
+ const ior = def?.extensions?.KHR_materials_ior?.ior ?? 1.5;
223
+ pm.metallicF0Factor = iorToF0Factor(ior);
224
+ pm.specularWeight = 1;
225
+ pm._hasReflExt = true;
226
+ }
227
+ if (volumeThicknessAnimated.has(matIdx) || volumeTintAnimated.has(matIdx)) {
228
+ pm.subsurface ??= {};
229
+ const eVol = def?.extensions?.KHR_materials_volume;
230
+ if (volumeThicknessAnimated.has(matIdx)) {
231
+ pm.subsurface.thickness ??= { min: 0, max: eVol?.thicknessFactor ?? 0, useGlTFChannel: true };
232
+ if (pm.subsurface.refraction) {
233
+ pm.subsurface.refraction.useThicknessAsDepth = true;
234
+ }
235
+ }
236
+ if (volumeTintAnimated.has(matIdx)) {
237
+ pm.subsurface.tint ??= { color: eVol?.attenuationColor ?? [1, 1, 1], atDistance: eVol?.attenuationDistance ?? 1 };
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ export { seedExtMaterials };
244
+ //# sourceMappingURL=animation-pointer-ext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation-pointer-ext.js","sources":["../../../src/loader-gltf/animation-pointer-ext.ts"],"sourcesContent":["/** KHR_animation_pointer — material factor / extension pointer writers + seeding.\n *\n * Holds the metallic / normalScale / occlusion / transmission / IOR / volume /\n * iridescence pointer writers and the load-time material seeding they need. This\n * module is dynamic-imported by the animation-pointer feature ONLY when a channel\n * targets one of these material pointers, so scenes that animate just node TRS /\n * visibility / base-color / UV transforms / lights never pay for it. On import it\n * appends its handlers to the shared resolver registry. */\nimport { _appendPointerHandlers, type PointerFactory, type PointerMaterial } from \"./animation-pointer.js\";\n\nfunction iorToF0Factor(ior: number): number {\n return ((ior - 1) / (ior + 1)) ** 2 / 0.04;\n}\n\nfunction bump(mat: PointerMaterial): void {\n mat._uboVersion++;\n}\n\nconst _extHandlers: [RegExp, PointerFactory][] = [\n // BJS 9.5 registers the glTF metallicFactor pointer twice, with the second\n // entry overwriting the first to animate PBRMaterial.roughness. Match that\n // behavior for parity; roughnessFactor itself is not registered by BJS.\n [\n /^\\/materials\\/(\\d+)\\/pbrMetallicRoughness\\/metallicFactor$/,\n (m, ctx) => {\n const mat = ctx.materials?.[+m[1]!];\n if (!mat) {\n return null;\n }\n return {\n arity: 1,\n writer: (out, off) => {\n mat.roughnessFactor = out[off]!;\n mat._uboVersion++;\n },\n };\n },\n ],\n // /materials/{m}/normalTexture/scale — scalar glTF normal-map strength. The\n // shader scale mod is provided by the lazy pbr-template-ext (loaded for materials\n // that already carry a UV transform / vertex colour / UV2), so this writer only\n // updates the existing `normalScale` UBO slot — no core shader path is added.\n [\n /^\\/materials\\/(\\d+)\\/normalTexture\\/scale$/,\n (m, ctx) => {\n const mat = ctx.materials?.[+m[1]!];\n if (!mat) {\n return null;\n }\n return {\n arity: 1,\n writer: (out, off) => {\n mat.normalTextureScale = out[off]!;\n mat._uboVersion++;\n },\n };\n },\n ],\n // /materials/{m}/extensions/KHR_materials_transmission/transmissionFactor\n [\n /^\\/materials\\/(\\d+)\\/extensions\\/KHR_materials_transmission\\/transmissionFactor$/,\n (m, ctx) => {\n const mat = ctx.materials?.[+m[1]!];\n const refr = mat?.subsurface?.refraction;\n if (!mat || !refr) {\n return null;\n }\n return {\n arity: 1,\n writer: (out, off) => {\n mat.transmissive = true;\n refr.intensity = out[off]!;\n bump(mat);\n },\n };\n },\n ],\n // /materials/{m}/extensions/KHR_materials_ior/ior\n [\n /^\\/materials\\/(\\d+)\\/extensions\\/KHR_materials_ior\\/ior$/,\n (m, ctx) => {\n const mat = ctx.materials?.[+m[1]!];\n if (!mat) {\n return null;\n }\n return {\n arity: 1,\n writer: (out, off) => {\n const ior = out[off]!;\n if (mat.subsurface?.refraction) {\n mat.subsurface.refraction.indexOfRefraction = ior;\n }\n mat.metallicF0Factor = iorToF0Factor(ior);\n mat.specularWeight = 1.0;\n mat._hasReflExt = true;\n bump(mat);\n },\n };\n },\n ],\n // /materials/{m}/extensions/KHR_materials_volume/{thicknessFactor|attenuationDistance|attenuationColor}\n [\n /^\\/materials\\/(\\d+)\\/extensions\\/KHR_materials_volume\\/(thicknessFactor|attenuationDistance|attenuationColor)$/,\n (m, ctx) => {\n const mat = ctx.materials?.[+m[1]!];\n if (!mat?.subsurface) {\n return null;\n }\n return {\n arity: m[2] === \"attenuationColor\" ? 3 : 1,\n writer: (out, off) => {\n const ss = mat.subsurface!;\n if (m[2] === \"thicknessFactor\") {\n ss.thickness ??= { min: 0, max: 0, useGlTFChannel: true };\n ss.thickness.max = out[off]!;\n if (ss.refraction) {\n ss.refraction.useThicknessAsDepth = true;\n }\n } else {\n ss.tint ??= { color: [1, 1, 1], atDistance: 1 };\n if (m[2] === \"attenuationDistance\") {\n ss.tint.atDistance = out[off]!;\n } else {\n ss.tint.color = [out[off]!, out[off + 1]!, out[off + 2]!];\n }\n }\n bump(mat);\n },\n };\n },\n ],\n // /materials/{m}/extensions/KHR_materials_iridescence/{iridescenceFactor|iridescenceIor|iridescenceThicknessMaximum}\n [\n /^\\/materials\\/(\\d+)\\/extensions\\/KHR_materials_iridescence\\/(iridescenceFactor|iridescenceIor|iridescenceThicknessMaximum)$/,\n (m, ctx) => {\n const mat = ctx.materials?.[+m[1]!];\n const iri = mat?.iridescence;\n if (!mat || !iri) {\n return null;\n }\n return {\n arity: 1,\n writer: (out, off) => {\n const v = out[off]!;\n if (m[2] === \"iridescenceFactor\") {\n iri.intensity = v;\n } else if (m[2] === \"iridescenceIor\") {\n iri.indexOfRefraction = v;\n } else {\n iri.maximumThickness = v;\n }\n bump(mat);\n },\n };\n },\n ],\n // /materials/{m}/occlusionTexture/strength — scalar ambient-occlusion strength.\n // The occlusion mix (mix(1, orm.r, strength)) is supplied by the lazy reflectance\n // ext, which the animation feature activates via `_hasReflExt`; this writer only\n // updates the `occlusionStrength` UBO slot that ext owns — zero core shader cost.\n [\n /^\\/materials\\/(\\d+)\\/occlusionTexture\\/strength$/,\n (m, ctx) => {\n const mat = ctx.materials?.[+m[1]!];\n if (!mat) {\n return null;\n }\n return {\n arity: 1,\n writer: (out, off) => {\n mat.occlusionStrength = out[off]!;\n mat._uboVersion++;\n },\n };\n },\n ],\n];\n\n_appendPointerHandlers(_extHandlers);\n\n/** Seed load-time material state so the material-extension pointer writers above have\n * something to drive. A material whose transmission / IOR / volume / occlusion-strength\n * is animated from its default (e.g. transmissionFactor 0, occlusionStrength 1) would\n * otherwise compile without the relevant shader path, so the animation would write a\n * value nothing samples. Called by the feature's materialMap once this module is loaded;\n * `map` is indexed by glTF material index. */\nexport function seedExtMaterials(json: any, map: (PointerMaterial | undefined)[]): void {\n const occlusionStrengthAnimated = new Set<number>();\n const transmissionAnimated = new Set<number>();\n const iorAnimated = new Set<number>();\n const volumeThicknessAnimated = new Set<number>();\n const volumeTintAnimated = new Set<number>();\n for (const anim of json.animations ?? []) {\n for (const ch of anim.channels ?? []) {\n const ptr = ch.target?.extensions?.KHR_animation_pointer?.pointer as string | undefined;\n const os = ptr && /^\\/materials\\/(\\d+)\\/occlusionTexture\\/strength$/.exec(ptr);\n if (os) {\n occlusionStrengthAnimated.add(+os[1]!);\n }\n const tr = ptr && /^\\/materials\\/(\\d+)\\/extensions\\/KHR_materials_transmission\\/transmissionFactor$/.exec(ptr);\n if (tr) {\n transmissionAnimated.add(+tr[1]!);\n }\n const ior = ptr && /^\\/materials\\/(\\d+)\\/extensions\\/KHR_materials_ior\\/ior$/.exec(ptr);\n if (ior) {\n iorAnimated.add(+ior[1]!);\n }\n const vt = ptr && /^\\/materials\\/(\\d+)\\/extensions\\/KHR_materials_volume\\/thicknessFactor$/.exec(ptr);\n if (vt) {\n volumeThicknessAnimated.add(+vt[1]!);\n }\n const vc = ptr && /^\\/materials\\/(\\d+)\\/extensions\\/KHR_materials_volume\\/(attenuationColor|attenuationDistance)$/.exec(ptr);\n if (vc) {\n volumeTintAnimated.add(+vc[1]!);\n }\n }\n }\n for (let matIdx = 0; matIdx < map.length; matIdx++) {\n const pm = map[matIdx];\n if (!pm) {\n continue;\n }\n const def = json.materials?.[matIdx];\n // An animated occlusionTexture.strength is applied through the lazy reflectance\n // ext (mix(1, orm.r, strength)). Route the material to it via `_hasReflExt` and\n // force activation even though the load-time strength may still be its default 1.0\n // (the ext's default-factor F0 path is identical to the base template).\n if (occlusionStrengthAnimated.has(matIdx)) {\n pm.occlusionStrength = def?.occlusionTexture?.strength ?? 1;\n pm._hasReflExt = true;\n (pm as { _occlStrengthAnimated?: boolean })._occlStrengthAnimated = true;\n }\n if (transmissionAnimated.has(matIdx)) {\n pm.transmissive = true;\n pm.subsurface ??= {};\n pm.subsurface.refraction ??= {\n intensity: def?.extensions?.KHR_materials_transmission?.transmissionFactor ?? 0,\n indexOfRefraction: def?.extensions?.KHR_materials_ior?.ior ?? 1.5,\n };\n }\n if (iorAnimated.has(matIdx)) {\n pm.subsurface ??= {};\n pm.subsurface.refraction ??= { intensity: 0, indexOfRefraction: def?.extensions?.KHR_materials_ior?.ior ?? 1.5 };\n const ior = def?.extensions?.KHR_materials_ior?.ior ?? 1.5;\n pm.metallicF0Factor = iorToF0Factor(ior);\n pm.specularWeight = 1.0;\n pm._hasReflExt = true;\n }\n if (volumeThicknessAnimated.has(matIdx) || volumeTintAnimated.has(matIdx)) {\n pm.subsurface ??= {};\n const eVol = def?.extensions?.KHR_materials_volume;\n if (volumeThicknessAnimated.has(matIdx)) {\n pm.subsurface.thickness ??= { min: 0, max: eVol?.thicknessFactor ?? 0, useGlTFChannel: true };\n if (pm.subsurface.refraction) {\n pm.subsurface.refraction.useThicknessAsDepth = true;\n }\n }\n if (volumeTintAnimated.has(matIdx)) {\n pm.subsurface.tint ??= { color: eVol?.attenuationColor ?? [1, 1, 1], atDistance: eVol?.attenuationDistance ?? 1 };\n }\n }\n }\n}\n"],"names":[],"mappings":";;AAUA,SAAS,cAAc,GAAA,EAAqB;AACxC,EAAA,OAAA,CAAA,CAAS,GAAA,GAAM,CAAA,KAAM,GAAA,GAAM,CAAA,CAAA,KAAO,CAAA,GAAI,IAAA;AAC1C;AAEA,SAAS,KAAK,GAAA,EAA4B;AACtC,EAAA,GAAA,CAAI,WAAA,EAAA;AACR;AAEA,MAAM,YAAA,GAA2C;AAAA;AAAA;AAAA;AAAA,EAI7C;AAAA,IACI,4DAAA;AAAA,IACA,CAAC,GAAG,GAAA,KAAQ;AACR,MAAA,MAAM,MAAM,GAAA,CAAI,SAAA,GAAY,CAAC,CAAA,CAAE,CAAC,CAAE,CAAA;AAClC,MAAA,IAAI,CAAC,GAAA,EAAK;AACN,QAAA,OAAO,IAAA;AAAA,MACX;AACA,MAAA,OAAO;AAAA,QACH,KAAA,EAAO,CAAA;AAAA,QACP,MAAA,EAAQ,CAAC,GAAA,EAAK,GAAA,KAAQ;AAClB,UAAA,GAAA,CAAI,eAAA,GAAkB,IAAI,GAAG,CAAA;AAC7B,UAAA,GAAA,CAAI,WAAA,EAAA;AAAA,QACR;AAAA,OACJ;AAAA,IACJ;AAAA,GACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,IACI,4CAAA;AAA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ACvE,MAAA,EAAA,CAAG,eAAe,EAAC;AACnB,MAAA,MAAM,IAAA,GAAO,KAAK,UAAA,EAAY,oBAAA;AAC9B,MAAA,IAAI,uBAAA,CAAwB,GAAA,CAAI,MAAM,CAAA,EAAG;AACrC,QAAA,EAAA,CAAG,UAAA,CAAW,SAAA,KAAc,EAAE,GAAA,EAAK,CAAA,EAAG,KAAK,IAAA,EAAM,eAAA,IAAmB,CAAA,EAAG,cAAA,EAAgB,IAAA,EAAK;AAC5F,QAAA,IAAI,EAAA,CAAG,WAAW,UAAA,EAAY;AAC1B,UAAA,EAAA,CAAG,UAAA,CAAW,WAAW,mBAAA,GAAsB,IAAA;AAAA,QACnD;AAAA,MACJ;AACA,MAAA,IAAI,kBAAA,CAAmB,GAAA,CAAI,MAAM,CAAA,EAAG;AAChC,QAAA,EAAA,CAAG,UAAA,CAAW,IAAA,KAAS,EAAE,KAAA,EAAO,MAAM,gBAAA,IAAoB,CAAC,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,UAAA,EAAY,IAAA,EAAM,uBAAuB,CAAA,EAAE;AAAA,MACpH;AAAA,IACJ;AAAA,EACJ;AACJ;;;;"}
@@ -0,0 +1,46 @@
1
+ import { getGltfPunctualLight } from './gltf-light-pointer-state.js';
2
+ import { _appendPointerHandlers } from './animation-pointer.js';
3
+
4
+ const _lightHandlers = [
5
+ // /extensions/KHR_lights_punctual/lights/{l}/{color|intensity|range|spot/outerConeAngle}
6
+ [
7
+ /^\/extensions\/KHR_lights_punctual\/lights\/(\d+)\/(color|intensity|range|spot\/outerConeAngle)$/,
8
+ (m, ctx) => {
9
+ const lightIdx = +m[1];
10
+ const field = m[2];
11
+ const getLight = () => {
12
+ return getGltfPunctualLight(ctx._json, lightIdx) ?? null;
13
+ };
14
+ return {
15
+ arity: field === "color" ? 3 : 1,
16
+ writer: (out, off) => {
17
+ const light = getLight();
18
+ if (!light) {
19
+ return;
20
+ }
21
+ if (field === "color") {
22
+ if (light.diffuse) {
23
+ light.diffuse[0] = out[off];
24
+ light.diffuse[1] = out[off + 1];
25
+ light.diffuse[2] = out[off + 2];
26
+ }
27
+ if (light.specular) {
28
+ light.specular[0] = out[off];
29
+ light.specular[1] = out[off + 1];
30
+ light.specular[2] = out[off + 2];
31
+ }
32
+ } else if (field === "intensity") {
33
+ light.intensity = out[off];
34
+ } else if (field === "range") {
35
+ light.range = out[off];
36
+ } else if (light.lightType === "spot") {
37
+ light.angle = out[off] * 2;
38
+ }
39
+ light._bumpLightVersion?.();
40
+ }
41
+ };
42
+ }
43
+ ]
44
+ ];
45
+ _appendPointerHandlers(_lightHandlers);
46
+ //# sourceMappingURL=animation-pointer-lights.js.map