@roomle/web-sdk 7.0.0-alpha.2 → 7.0.0-alpha.3

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 (66) hide show
  1. package/THIRD-PARTY-NOTICES.txt +2 -2
  2. package/lib/ConfiguratorKernel.js +2 -2
  3. package/lib/ConfiguratorKernel.wasm +0 -0
  4. package/lib/RoomleCore.js +2 -2
  5. package/lib/RoomleCore.wasm +0 -0
  6. package/lib/RoomleToolsCore.wasm +0 -0
  7. package/lib/{api-DOHbOr7K.mjs → api-B_Mu7Mg1.mjs} +2 -2
  8. package/lib/{api-DOHbOr7K.mjs.map → api-B_Mu7Mg1.mjs.map} +1 -1
  9. package/lib/asset-loader.worker-Bdvb-pt7.mjs.map +1 -1
  10. package/lib/budgeteer.sw-ByZxiRBr.mjs.map +1 -1
  11. package/lib/{configuration-operations-DJD9A1xP.mjs → configuration-operations-C5rnDS8e.mjs} +10 -4
  12. package/lib/configuration-operations-C5rnDS8e.mjs.map +1 -0
  13. package/lib/{configurator-DCynrn7X.mjs → configurator-BeDJ8jD1.mjs} +3 -3
  14. package/lib/{configurator-DCynrn7X.mjs.map → configurator-BeDJ8jD1.mjs.map} +1 -1
  15. package/lib/{configurator-capabilities-BfSMwdWh.mjs → configurator-capabilities-C3TQUu_S.mjs} +2 -2
  16. package/lib/{configurator-capabilities-BfSMwdWh.mjs.map → configurator-capabilities-C3TQUu_S.mjs.map} +1 -1
  17. package/lib/configurator-capabilities-C42HYCCb.mjs +3 -0
  18. package/lib/{configurator-mcp-tools-D00ndjOy.mjs → configurator-mcp-tools-D7vZ7ozM.mjs} +3 -3
  19. package/lib/configurator-mcp-tools-D7vZ7ozM.mjs.map +1 -0
  20. package/lib/configurator-yctV6IDY.mjs +3 -0
  21. package/lib/{glb-viewer-BhiCqjpE.mjs → glb-viewer-BkU2Z-HJ.mjs} +3 -3
  22. package/lib/{glb-viewer-BhiCqjpE.mjs.map → glb-viewer-BkU2Z-HJ.mjs.map} +1 -1
  23. package/lib/glb-viewer-jt9mrYrF.mjs +3 -0
  24. package/lib/{homag-intelligence-DuFtYgdG.mjs → homag-intelligence-DboRA-Yd.mjs} +6 -3
  25. package/lib/homag-intelligence-DboRA-Yd.mjs.map +1 -0
  26. package/lib/kernel-2ku6lFfE.mjs.map +1 -1
  27. package/lib/{material-viewer-uEDqIbCx.mjs → material-viewer-BkaTt8Sn.mjs} +3 -3
  28. package/lib/{material-viewer-uEDqIbCx.mjs.map → material-viewer-BkaTt8Sn.mjs.map} +1 -1
  29. package/lib/{packages-DOCmEOxI.mjs → packages-DZzpY6V8.mjs} +5 -5
  30. package/lib/{packages-DOCmEOxI.mjs.map → packages-DZzpY6V8.mjs.map} +1 -1
  31. package/lib/planner-C7kZ9SKV.mjs +3 -0
  32. package/lib/{planner-D8UVNfkJ.mjs → planner-CuZaTB-P.mjs} +3 -3
  33. package/lib/{planner-D8UVNfkJ.mjs.map → planner-CuZaTB-P.mjs.map} +1 -1
  34. package/lib/roomle-headless.d.ts +130 -2
  35. package/lib/roomle-headless.js +8 -8
  36. package/lib/{roomle-sdk-C0YpFZdj.mjs → roomle-sdk-CSH3WHXV.mjs} +263 -235
  37. package/lib/roomle-sdk-CSH3WHXV.mjs.map +1 -0
  38. package/lib/roomle-sdk.d.ts +130 -2
  39. package/lib/roomle-sdk.js +6 -6
  40. package/lib/{roomle-webgpu-renderer-DZ9LaZfc.mjs → roomle-webgpu-renderer-D43bHxhT.mjs} +2 -2
  41. package/lib/{roomle-webgpu-renderer-DZ9LaZfc.mjs.map → roomle-webgpu-renderer-D43bHxhT.mjs.map} +1 -1
  42. package/lib/{runtime-Bz0u5ckH.mjs → runtime-D5zrHj-e.mjs} +181 -78
  43. package/lib/runtime-D5zrHj-e.mjs.map +1 -0
  44. package/lib/{script-loader-jRBMP-ca.mjs → script-loader-O8x5UOnP.mjs} +2 -2
  45. package/lib/{script-loader-jRBMP-ca.mjs.map → script-loader-O8x5UOnP.mjs.map} +1 -1
  46. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
  47. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.d.ts +8 -0
  48. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.js.map +1 -1
  49. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.js +2 -2
  50. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
  51. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.js +2 -2
  52. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
  53. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
  54. package/lib/{tools-core-k93qrqfB.mjs → tools-core-DJvn2gR6.mjs} +3 -3
  55. package/lib/{tools-core-k93qrqfB.mjs.map → tools-core-DJvn2gR6.mjs.map} +1 -1
  56. package/package.json +2 -2
  57. package/sbom.cdx.json +5 -5
  58. package/lib/configuration-operations-DJD9A1xP.mjs.map +0 -1
  59. package/lib/configurator-D5Ehj649.mjs +0 -3
  60. package/lib/configurator-capabilities-DAJuxSTw.mjs +0 -3
  61. package/lib/configurator-mcp-tools-D00ndjOy.mjs.map +0 -1
  62. package/lib/glb-viewer-BrggGLte.mjs +0 -3
  63. package/lib/homag-intelligence-DuFtYgdG.mjs.map +0 -1
  64. package/lib/planner-B9GbQLSB.mjs +0 -3
  65. package/lib/roomle-sdk-C0YpFZdj.mjs.map +0 -1
  66. package/lib/runtime-Bz0u5ckH.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"roomle-webgpu-renderer-DZ9LaZfc.mjs","names":["_quadMesh","_size","_rendererState","uv","_size","_quadMesh","_size","_rendererState","uv","uv","_quadMesh","_size","_rendererState","uv","_box","_size","_rendererState","uv"],"sources":["../../../../node_modules/three/examples/jsm/tsl/display/OutlineNode.js","../../packages/common-core/src/webgpu/passes/roomle-webgpu-render-pass.ts","../../packages/common-core/src/webgpu/passes/outline-render-pass.ts","../../../../node_modules/three/examples/jsm/inspector/RendererInspector.js","../../../../node_modules/three/examples/jsm/inspector/ui/Style.js","../../../../node_modules/three/examples/jsm/inspector/ui/Graph.js","../../../../node_modules/three/examples/jsm/inspector/Storage.js","../../../../node_modules/three/examples/jsm/inspector/ui/Profiler.js","../../../../node_modules/three/examples/jsm/inspector/ui/Tab.js","../../../../node_modules/three/examples/jsm/inspector/ui/List.js","../../../../node_modules/three/examples/jsm/inspector/ui/Item.js","../../../../node_modules/three/examples/jsm/inspector/ui/utils.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Performance.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Memory.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Console.js","../../../../node_modules/three/examples/jsm/inspector/ui/Values.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Parameters.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Settings.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Viewer.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Timeline.js","../../../../node_modules/three/examples/jsm/inspector/Inspector.js","../../../../node_modules/three/examples/jsm/tsl/display/SSGINode.js","../../../../node_modules/three/examples/jsm/tsl/display/DenoiseNode.js","../../packages/common-core/src/webgpu/passes/ssgi-render-pass.ts","../../../../node_modules/three/examples/jsm/tsl/utils/TAAUtils.js","../../../../node_modules/three/examples/jsm/tsl/display/TRAANode.js","../../packages/common-core/src/webgpu/passes/traa-render-pass.ts","../../packages/common-core/src/webgpu/roomle-webgpu-renderer-quality-levels.ts","../../packages/common-core/src/webgpu/roomle-webgpu-quality-manager.ts","../../packages/common-core/src/webgpu/passes/fog-render-pass.ts","../../packages/common-core/src/webgpu/passes/debug-render-pass.ts","../../../../node_modules/three/examples/jsm/lighting/vxgi/VXGISceneCollector.js","../../../../node_modules/three/examples/jsm/lighting/vxgi/VXGIConeTracer.js","../../../../node_modules/three/examples/jsm/lighting/vxgi/VXGIVolume.js","../../../../node_modules/three/examples/jsm/lighting/vxgi/VXGINode.js","../../packages/common-core/src/webgpu/passes/vxgi-render-pass.ts","../../packages/common-core/src/webgpu/roomle-webgpu-renderer.ts"],"sourcesContent":["import { DepthTexture, FloatType, RenderTarget, Vector2, Node, QuadMesh, NodeMaterial, SpriteNodeMaterial, RendererUtils, NodeUpdateType } from 'three/webgpu';\nimport { Loop, int, exp, min, float, mul, uv, vec2, vec3, Fn, textureSize, orthographicDepthToViewZ, screenUV, nodeObject, uniform, vec4, passTexture, texture, perspectiveDepthToViewZ, positionView, reference, color } from 'three/tsl';\n\nconst _quadMesh = /*@__PURE__*/ new QuadMesh();\nconst _size = /*@__PURE__*/ new Vector2();\nconst _BLUR_DIRECTION_X = /*@__PURE__*/ new Vector2( 1.0, 0.0 );\nconst _BLUR_DIRECTION_Y = /*@__PURE__*/ new Vector2( 0.0, 1.0 );\n\nlet _rendererState;\n\n/**\n * Post processing node for rendering outlines around selected objects. The node\n * gives you great flexibility in composing the final outline look depending on\n * your requirements.\n * ```js\n * const renderPipeline = new THREE.RenderPipeline( renderer );\n *\n * const scenePass = pass( scene, camera );\n *\n * // outline parameter\n *\n * const edgeStrength = uniform( 3.0 );\n * const edgeGlow = uniform( 0.0 );\n * const edgeThickness = uniform( 1.0 );\n * const visibleEdgeColor = uniform( new THREE.Color( 0xffffff ) );\n * const hiddenEdgeColor = uniform( new THREE.Color( 0x4e3636 ) );\n *\n * outlinePass = outline( scene, camera, {\n * \tselectedObjects,\n * \tedgeGlow,\n * \tedgeThickness\n * } );\n *\n * // compose custom outline\n *\n * const { visibleEdge, hiddenEdge } = outlinePass;\n * const outlineColor = visibleEdge.mul( visibleEdgeColor ).add( hiddenEdge.mul( hiddenEdgeColor ) ).mul( edgeStrength );\n *\n * renderPipeline.outputNode = outlineColor.add( scenePass );\n * ```\n *\n * @augments Node\n * @three_import import { outline } from 'three/addons/tsl/display/OutlineNode.js';\n */\nclass OutlineNode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'OutlineNode';\n\n\t}\n\n\t/**\n\t * Constructs a new outline node.\n\t *\n\t * @param {Scene} scene - A reference to the scene.\n\t * @param {Camera} camera - The camera the scene is rendered with.\n\t * @param {Object} params - The configuration parameters.\n\t * @param {Array<Object3D>} [params.selectedObjects] - An array of selected objects.\n\t * @param {Node<float>} [params.edgeThickness=float(1)] - The thickness of the edges.\n\t * @param {Node<float>} [params.edgeGlow=float(0)] - Can be used for an animated glow/pulse effects.\n\t * @param {number} [params.downSampleRatio=2] - The downsample ratio.\n\t */\n\tconstructor( scene, camera, params = {} ) {\n\n\t\tsuper( 'vec4' );\n\n\t\tconst {\n\t\t\tselectedObjects = [],\n\t\t\tedgeThickness = float( 1 ),\n\t\t\tedgeGlow = float( 0 ),\n\t\t\tdownSampleRatio = 2\n\t\t} = params;\n\n\t\t/**\n\t\t * A reference to the scene.\n\t\t *\n\t\t * @type {Scene}\n\t\t */\n\t\tthis.scene = scene;\n\n\t\t/**\n\t\t * The camera the scene is rendered with.\n\t\t *\n\t\t * @type {Camera}\n\t\t */\n\t\tthis.camera = camera;\n\n\t\t/**\n\t\t * An array of selected objects.\n\t\t *\n\t\t * @type {Array<Object3D>}\n\t\t */\n\t\tthis.selectedObjects = selectedObjects;\n\n\t\t/**\n\t\t * The thickness of the edges.\n\t\t *\n\t\t * @type {Node<float>}\n\t\t */\n\t\tthis.edgeThicknessNode = nodeObject( edgeThickness );\n\n\t\t/**\n\t\t * Can be used for an animated glow/pulse effect.\n\t\t *\n\t\t * @type {Node<float>}\n\t\t */\n\t\tthis.edgeGlowNode = nodeObject( edgeGlow );\n\n\t\t/**\n\t\t * The downsample ratio.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 2\n\t\t */\n\t\tthis.downSampleRatio = downSampleRatio;\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders\n\t\t * its effect once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t// render targets\n\n\t\t/**\n\t\t * The render target for the depth pre-pass.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetDepthBuffer = new RenderTarget();\n\t\tthis._renderTargetDepthBuffer.depthTexture = new DepthTexture();\n\t\tthis._renderTargetDepthBuffer.depthTexture.type = FloatType;\n\n\t\t/**\n\t\t * The render target for the mask pass.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetMaskBuffer = new RenderTarget();\n\n\t\t/**\n\t\t * The render target for the mask downsample.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetMaskDownSampleBuffer = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The first render target for the edge detection.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetEdgeBuffer1 = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The second render target for the edge detection.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetEdgeBuffer2 = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The first render target for the blur pass.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetBlurBuffer1 = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The second render target for the blur pass.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetBlurBuffer2 = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The render target for the final composite.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetComposite = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t// uniforms\n\n\t\t/**\n\t\t * Represents the near value of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {ReferenceNode<float>}\n\t\t */\n\t\tthis._cameraNear = reference( 'near', 'float', camera );\n\n\t\t/**\n\t\t * Represents the far value of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {ReferenceNode<float>}\n\t\t */\n\t\tthis._cameraFar = reference( 'far', 'float', camera );\n\n\t\t/**\n\t\t * Uniform that represents the blur direction of the pass.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._blurDirection = uniform( new Vector2() );\n\n\t\t/**\n\t\t * Texture node that holds the data from the depth pre-pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._depthTextureUniform = texture( this._renderTargetDepthBuffer.depthTexture );\n\n\t\t/**\n\t\t * Texture node that holds the data from the mask pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._maskTextureUniform = texture( this._renderTargetMaskBuffer.texture );\n\n\t\t/**\n\t\t * Texture node that holds the data from the mask downsample pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._maskTextureDownsSampleUniform = texture( this._renderTargetMaskDownSampleBuffer.texture );\n\n\t\t/**\n\t\t * Texture node that holds the data from the first edge detection pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._edge1TextureUniform = texture( this._renderTargetEdgeBuffer1.texture );\n\n\t\t/**\n\t\t * Texture node that holds the data from the second edge detection pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._edge2TextureUniform = texture( this._renderTargetEdgeBuffer2.texture );\n\n\t\t/**\n\t\t * Texture node that holds the current blurred color data.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._blurColorTextureUniform = texture( this._renderTargetEdgeBuffer1.texture );\n\n\t\t// constants\n\n\t\t/**\n\t\t * Visible edge color.\n\t\t *\n\t\t * @private\n\t\t * @type {Node<vec3>}\n\t\t */\n\t\tthis._visibleEdgeColor = vec3( 1, 0, 0 );\n\n\t\t/**\n\t\t * Hidden edge color.\n\t\t *\n\t\t * @private\n\t\t * @type {Node<vec3>}\n\t\t */\n\t\tthis._hiddenEdgeColor = vec3( 0, 1, 0 );\n\n\t\t// materials\n\n\t\t/**\n\t\t * The material for the depth pre-pass.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._depthMaterial = new NodeMaterial();\n\t\tthis._depthMaterial.colorNode = color( 0, 0, 0 );\n\t\tthis._depthMaterial.name = 'OutlineNode.depth';\n\n\t\tthis._depthSpriteMaterial = new SpriteNodeMaterial();\n\t\tthis._depthSpriteMaterial.colorNode = color( 0, 0, 0 );\n\t\tthis._depthSpriteMaterial.name = 'OutlineNode.depthSprite';\n\n\t\t/**\n\t\t * The material for preparing the mask.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._prepareMaskMaterial = new NodeMaterial();\n\t\tthis._prepareMaskMaterial.name = 'OutlineNode.prepareMask';\n\n\t\tthis._prepareMaskSpriteMaterial = new SpriteNodeMaterial();\n\t\tthis._prepareMaskSpriteMaterial.name = 'OutlineNode.prepareMaskSprite';\n\n\t\t/**\n\t\t * The copy material\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._materialCopy = new NodeMaterial();\n\t\tthis._materialCopy.name = 'OutlineNode.copy';\n\n\t\t/**\n\t\t * The edge detection material.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._edgeDetectionMaterial = new NodeMaterial();\n\t\tthis._edgeDetectionMaterial.name = 'OutlineNode.edgeDetection';\n\n\t\t/**\n\t\t * The material that is used to render in the blur pass.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._separableBlurMaterial = new NodeMaterial();\n\t\tthis._separableBlurMaterial.name = 'OutlineNode.separableBlur';\n\n\t\t/**\n\t\t * The material that is used to render in the blur pass.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._separableBlurMaterial2 = new NodeMaterial();\n\t\tthis._separableBlurMaterial2.name = 'OutlineNode.separableBlur2';\n\n\t\t/**\n\t\t * The final composite material.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._compositeMaterial = new NodeMaterial();\n\t\tthis._compositeMaterial.name = 'OutlineNode.composite';\n\n\t\t/**\n\t\t * An internal cache for depth materials.\n\t\t *\n\t\t * @private\n\t\t * @type {Map<Material, NodeMaterial>}\n\t\t */\n\t\tthis._depthMaterialCache = new Map();\n\n\t\t/**\n\t\t * An internal cache for mask materials.\n\t\t *\n\t\t * @private\n\t\t * @type {Map<Material, NodeMaterial>}\n\t\t */\n\t\tthis._prepareMaskMaterialCache = new Map();\n\n\t\t/**\n\t\t * Disposes the pass materials of a disposed material.\n\t\t *\n\t\t * @private\n\t\t * @type {Function}\n\t\t */\n\t\tthis._onMaterialDispose = ( event ) => {\n\n\t\t\tconst originalMaterial = event.target;\n\n\t\t\toriginalMaterial.removeEventListener( 'dispose', this._onMaterialDispose );\n\n\t\t\tfor ( const cache of [ this._depthMaterialCache, this._prepareMaskMaterialCache ] ) {\n\n\t\t\t\tconst passMaterial = cache.get( originalMaterial );\n\n\t\t\t\tif ( passMaterial !== undefined ) {\n\n\t\t\t\t\tpassMaterial.dispose();\n\t\t\t\t\tcache.delete( originalMaterial );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\t/**\n\t\t * A set to cache selected objects in the scene.\n\t\t *\n\t\t * @private\n\t\t * @type {Set<Object3D>}\n\t\t */\n\t\tthis._selectionCache = new Set();\n\n\t\t/**\n\t\t * The number of selected objects from the previous frame. Used to detect\n\t\t * the transition to an empty selection so the composite render target can\n\t\t * be cleared once and avoid leaving a stale outline on screen.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._lastSelectionCount = 0;\n\n\t\t/**\n\t\t * The result of the effect is represented as a separate texture node.\n\t\t *\n\t\t * @private\n\t\t * @type {PassTextureNode}\n\t\t */\n\t\tthis._textureNode = passTexture( this, this._renderTargetComposite.texture );\n\n\t}\n\n\t/**\n\t * A mask value that represents the visible edge.\n\t *\n\t * @return {Node<float>} The visible edge.\n\t */\n\tget visibleEdge() {\n\n\t\treturn this.r;\n\n\t}\n\n\t/**\n\t * A mask value that represents the hidden edge.\n\t *\n\t * @return {Node<float>} The hidden edge.\n\t */\n\tget hiddenEdge() {\n\n\t\treturn this.g;\n\n\t}\n\n\t/**\n\t * Returns the result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the result of the effect.\n\t */\n\tgetTextureNode() {\n\n\t\treturn this._textureNode;\n\n\t}\n\n\t/**\n\t * Sets the size of the effect.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetSize( width, height ) {\n\n\t\tthis._renderTargetDepthBuffer.setSize( width, height );\n\t\tthis._renderTargetMaskBuffer.setSize( width, height );\n\t\tthis._renderTargetComposite.setSize( width, height );\n\n\t\t// downsample 1\n\n\t\tlet resx = Math.round( width / this.downSampleRatio );\n\t\tlet resy = Math.round( height / this.downSampleRatio );\n\n\t\tthis._renderTargetMaskDownSampleBuffer.setSize( resx, resy );\n\t\tthis._renderTargetEdgeBuffer1.setSize( resx, resy );\n\t\tthis._renderTargetBlurBuffer1.setSize( resx, resy );\n\n\t\t// downsample 2\n\n\t\tresx = Math.round( resx / 2 );\n\t\tresy = Math.round( resy / 2 );\n\n\t\tthis._renderTargetEdgeBuffer2.setSize( resx, resy );\n\t\tthis._renderTargetBlurBuffer2.setSize( resx, resy );\n\n\t}\n\n\t/**\n\t * This method is used to render the effect once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore( frame ) {\n\n\t\tconst { renderer } = frame;\n\t\tconst { camera, scene } = this;\n\n\t\tthis._updateSelectionCache();\n\n\t\t// If no objects are selected, all subsequent passes can be skipped since\n\t\t// the outline would be empty anyway. The composite render target is cleared\n\t\t// once when transitioning to an empty selection so a previously rendered\n\t\t// outline does not linger on screen.\n\n\t\tif ( this._selectionCache.size === 0 ) {\n\n\t\t\tif ( this._lastSelectionCount > 0 ) {\n\n\t\t\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t\t\trenderer.setRenderTarget( this._renderTargetComposite );\n\t\t\t\trenderer.setClearColor( 0x000000, 0 );\n\t\t\t\trenderer.clear();\n\n\t\t\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t\t\t\tthis._lastSelectionCount = 0;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tthis._lastSelectionCount = this._selectionCache.size;\n\n\t\t_rendererState = RendererUtils.resetRendererAndSceneState( renderer, scene, _rendererState );\n\n\t\t//\n\n\t\tconst size = renderer.getDrawingBufferSize( _size );\n\t\tthis.setSize( size.width, size.height );\n\n\t\t//\n\n\t\trenderer.setClearColor( 0xffffff, 1 );\n\n\t\tconst currentSceneName = scene.name;\n\n\t\t// 1. Draw non-selected objects in the depth buffer\n\n\t\trenderer.setRenderTarget( this._renderTargetDepthBuffer );\n\t\trenderer.setRenderObjectFunction( ( object, scene, camera, geometry, material, group, lightsNode, clippingContext ) => {\n\n\t\t\tif ( this._selectionCache.has( object ) === false ) {\n\n\t\t\t\tconst baseMaterial = object.isSprite ? this._depthSpriteMaterial : this._depthMaterial;\n\t\t\t\tconst overrideMaterial = this._getPassMaterial( this._depthMaterialCache, baseMaterial, material );\n\n\t\t\t\trenderer.renderObject( object, scene, camera, geometry, overrideMaterial, group, lightsNode, clippingContext );\n\n\t\t\t}\n\n\t\t} );\n\n\t\tscene.name = 'Outline [ Non-Selected Objects Pass ]';\n\t\trenderer.render( scene, camera );\n\n\t\t// 2. Draw only the selected objects by comparing the depth buffer of non-selected objects\n\n\t\trenderer.setRenderTarget( this._renderTargetMaskBuffer );\n\t\trenderer.setRenderObjectFunction( ( object, scene, camera, geometry, material, group, lightsNode, clippingContext ) => {\n\n\t\t\tif ( this._selectionCache.has( object ) === true ) {\n\n\t\t\t\tconst baseMaterial = object.isSprite ? this._prepareMaskSpriteMaterial : this._prepareMaskMaterial;\n\t\t\t\tconst overrideMaterial = this._getPassMaterial( this._prepareMaskMaterialCache, baseMaterial, material );\n\n\t\t\t\trenderer.renderObject( object, scene, camera, geometry, overrideMaterial, group, lightsNode, clippingContext );\n\n\t\t\t}\n\n\t\t} );\n\n\t\tscene.name = 'Outline [ Selected Objects Pass ]';\n\t\trenderer.render( scene, camera );\n\n\t\t//\n\n\t\trenderer.setRenderObjectFunction( _rendererState.renderObjectFunction );\n\n\t\tthis._selectionCache.clear();\n\n\t\tscene.name = currentSceneName;\n\n\t\t// 3. Downsample to (at least) half resolution\n\n\t\t_quadMesh.material = this._materialCopy;\n\t\t_quadMesh.name = 'Outline [ Downsample ]';\n\t\trenderer.setRenderTarget( this._renderTargetMaskDownSampleBuffer );\n\t\t_quadMesh.render( renderer );\n\n\t\t// 4. Perform edge detection (half resolution)\n\n\t\t_quadMesh.material = this._edgeDetectionMaterial;\n\t\t_quadMesh.name = 'Outline [ Edge Detection ]';\n\t\trenderer.setRenderTarget( this._renderTargetEdgeBuffer1 );\n\t\t_quadMesh.render( renderer );\n\n\t\t// 5. Apply blur (half resolution)\n\n\t\tthis._blurColorTextureUniform.value = this._renderTargetEdgeBuffer1.texture;\n\t\tthis._blurDirection.value.copy( _BLUR_DIRECTION_X );\n\n\t\t_quadMesh.material = this._separableBlurMaterial;\n\t\t_quadMesh.name = 'Outline [ Blur Half Resolution ]';\n\t\trenderer.setRenderTarget( this._renderTargetBlurBuffer1 );\n\t\t_quadMesh.render( renderer );\n\n\t\tthis._blurColorTextureUniform.value = this._renderTargetBlurBuffer1.texture;\n\t\tthis._blurDirection.value.copy( _BLUR_DIRECTION_Y );\n\n\t\trenderer.setRenderTarget( this._renderTargetEdgeBuffer1 );\n\t\t_quadMesh.render( renderer );\n\n\t\t// 6. Apply blur (quarter resolution)\n\n\t\tthis._blurColorTextureUniform.value = this._renderTargetEdgeBuffer1.texture;\n\t\tthis._blurDirection.value.copy( _BLUR_DIRECTION_X );\n\n\t\t_quadMesh.material = this._separableBlurMaterial2;\n\t\t_quadMesh.name = 'Outline [ Blur Quarter Resolution ]';\n\t\trenderer.setRenderTarget( this._renderTargetBlurBuffer2 );\n\t\t_quadMesh.render( renderer );\n\n\t\tthis._blurColorTextureUniform.value = this._renderTargetBlurBuffer2.texture;\n\t\tthis._blurDirection.value.copy( _BLUR_DIRECTION_Y );\n\n\t\trenderer.setRenderTarget( this._renderTargetEdgeBuffer2 );\n\t\t_quadMesh.render( renderer );\n\n\t\t// 7. Composite\n\n\t\t_quadMesh.material = this._compositeMaterial;\n\t\t_quadMesh.name = 'Outline [ Blur Quarter Resolution ]';\n\t\trenderer.setRenderTarget( this._renderTargetComposite );\n\t\t_quadMesh.render( renderer );\n\n\t\t// restore\n\n\t\tRendererUtils.restoreRendererAndSceneState( renderer, scene, _rendererState );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {PassTextureNode}\n\t */\n\tsetup() {\n\n\t\t// prepare mask material\n\n\t\tconst prepareMask = () => {\n\n\t\t\tconst depth = this._depthTextureUniform.sample( screenUV );\n\n\t\t\tlet viewZNode;\n\n\t\t\tif ( this.camera.isPerspectiveCamera ) {\n\n\t\t\t\tviewZNode = perspectiveDepthToViewZ( depth, this._cameraNear, this._cameraFar );\n\n\t\t\t} else {\n\n\t\t\t\tviewZNode = orthographicDepthToViewZ( depth, this._cameraNear, this._cameraFar );\n\n\t\t\t}\n\n\t\t\tconst depthTest = positionView.z.lessThanEqual( viewZNode ).select( 1, 0 );\n\t\t\treturn vec3( 0.0, depthTest, 1.0 );\n\n\t\t};\n\n\t\tthis._prepareMaskMaterial.colorNode = prepareMask();\n\t\tthis._prepareMaskMaterial.needsUpdate = true;\n\n\t\tthis._prepareMaskSpriteMaterial.colorNode = prepareMask();\n\t\tthis._prepareMaskSpriteMaterial.needsUpdate = true;\n\n\t\t// copy material\n\n\t\tthis._materialCopy.fragmentNode = this._maskTextureUniform;\n\t\tthis._materialCopy.needsUpdate = true;\n\n\t\t// edge detection material\n\n\t\tconst edgeDetection = Fn( () => {\n\n\t\t\tconst resolution = textureSize( this._maskTextureDownsSampleUniform );\n\t\t\tconst invSize = vec2( 1 ).div( resolution ).toVar();\n\t\t\tconst uvOffset = vec4( 1.0, 0.0, 0.0, 1.0 ).mul( vec4( invSize, invSize ) );\n\n\t\t\tconst uvNode = uv();\n\t\t\tconst c1 = this._maskTextureDownsSampleUniform.sample( uvNode.add( uvOffset.xy ) ).toVar();\n\t\t\tconst c2 = this._maskTextureDownsSampleUniform.sample( uvNode.sub( uvOffset.xy ) ).toVar();\n\t\t\tconst c3 = this._maskTextureDownsSampleUniform.sample( uvNode.add( uvOffset.yw ) ).toVar();\n\t\t\tconst c4 = this._maskTextureDownsSampleUniform.sample( uvNode.sub( uvOffset.yw ) ).toVar();\n\n\t\t\tconst diff1 = mul( c1.r.sub( c2.r ), 0.5 );\n\t\t\tconst diff2 = mul( c3.r.sub( c4.r ), 0.5 );\n\t\t\tconst d = vec2( diff1, diff2 ).length();\n\t\t\tconst a1 = min( c1.g, c2.g );\n\t\t\tconst a2 = min( c3.g, c4.g );\n\t\t\tconst visibilityFactor = min( a1, a2 );\n\t\t\tconst edgeColor = visibilityFactor.oneMinus().greaterThan( 0.001 ).select( this._visibleEdgeColor, this._hiddenEdgeColor );\n\t\t\treturn vec4( edgeColor, 1 ).mul( d );\n\n\t\t} );\n\n\t\tthis._edgeDetectionMaterial.fragmentNode = edgeDetection();\n\t\tthis._edgeDetectionMaterial.needsUpdate = true;\n\n\t\t// separable blur material\n\n\t\tconst MAX_RADIUS = 4;\n\n\t\tconst gaussianPdf = Fn( ( [ x, sigma ] ) => {\n\n\t\t\treturn float( 0.39894 ).mul( exp( float( - 0.5 ).mul( x ).mul( x ).div( sigma.mul( sigma ) ) ).div( sigma ) );\n\n\t\t} );\n\n\t\tconst separableBlur = Fn( ( [ kernelRadius ] ) => {\n\n\t\t\tconst resolution = textureSize( this._maskTextureDownsSampleUniform );\n\t\t\tconst invSize = vec2( 1 ).div( resolution ).toVar();\n\t\t\tconst uvNode = uv();\n\n\t\t\tconst sigma = kernelRadius.div( 2 ).toVar();\n\t\t\tconst weightSum = gaussianPdf( 0, sigma ).toVar();\n\t\t\tconst diffuseSum = this._blurColorTextureUniform.sample( uvNode ).mul( weightSum ).toVar();\n\t\t\tconst delta = this._blurDirection.mul( invSize ).mul( kernelRadius ).div( MAX_RADIUS ).toVar();\n\n\t\t\tconst uvOffset = delta.toVar();\n\n\t\t\tLoop( { start: int( 1 ), end: int( MAX_RADIUS ), type: 'int', condition: '<=' }, ( { i } ) => {\n\n\t\t\t\tconst x = kernelRadius.mul( float( i ) ).div( MAX_RADIUS );\n\t\t\t\tconst w = gaussianPdf( x, sigma );\n\t\t\t\tconst sample1 = this._blurColorTextureUniform.sample( uvNode.add( uvOffset ) );\n\t\t\t\tconst sample2 = this._blurColorTextureUniform.sample( uvNode.sub( uvOffset ) );\n\n\t\t\t\tdiffuseSum.addAssign( sample1.add( sample2 ).mul( w ) );\n\t\t\t\tweightSum.addAssign( w.mul( 2 ) );\n\t\t\t\tuvOffset.addAssign( delta );\n\n\t\t\t} );\n\n\t\t\treturn diffuseSum.div( weightSum );\n\n\t\t} );\n\n\t\tthis._separableBlurMaterial.fragmentNode = separableBlur( this.edgeThicknessNode );\n\t\tthis._separableBlurMaterial.needsUpdate = true;\n\n\t\tthis._separableBlurMaterial2.fragmentNode = separableBlur( MAX_RADIUS );\n\t\tthis._separableBlurMaterial2.needsUpdate = true;\n\n\t\t// composite material\n\n\t\tconst composite = Fn( () => {\n\n\t\t\tconst edgeValue1 = this._edge1TextureUniform;\n\t\t\tconst edgeValue2 = this._edge2TextureUniform;\n\t\t\tconst maskColor = this._maskTextureUniform;\n\n\t\t\tconst edgeValue = edgeValue1.add( edgeValue2.mul( this.edgeGlowNode ) );\n\n\t\t\treturn maskColor.r.mul( edgeValue );\n\n\t\t} );\n\n\t\tthis._compositeMaterial.fragmentNode = composite();\n\t\tthis._compositeMaterial.needsUpdate = true;\n\n\t\treturn this._textureNode;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis.selectedObjects.length = 0;\n\n\t\tthis._renderTargetDepthBuffer.dispose();\n\t\tthis._renderTargetMaskBuffer.dispose();\n\t\tthis._renderTargetMaskDownSampleBuffer.dispose();\n\t\tthis._renderTargetEdgeBuffer1.dispose();\n\t\tthis._renderTargetEdgeBuffer2.dispose();\n\t\tthis._renderTargetBlurBuffer1.dispose();\n\t\tthis._renderTargetBlurBuffer2.dispose();\n\t\tthis._renderTargetComposite.dispose();\n\n\t\tthis._depthMaterial.dispose();\n\t\tthis._depthSpriteMaterial.dispose();\n\t\tthis._prepareMaskMaterial.dispose();\n\t\tthis._prepareMaskSpriteMaterial.dispose();\n\t\tthis._materialCopy.dispose();\n\t\tthis._edgeDetectionMaterial.dispose();\n\t\tthis._separableBlurMaterial.dispose();\n\t\tthis._separableBlurMaterial2.dispose();\n\t\tthis._compositeMaterial.dispose();\n\n\t\tfor ( const cache of [ this._depthMaterialCache, this._prepareMaskMaterialCache ] ) {\n\n\t\t\tfor ( const [ originalMaterial, passMaterial ] of cache ) {\n\n\t\t\t\toriginalMaterial.removeEventListener( 'dispose', this._onMaterialDispose );\n\n\t\t\t\tpassMaterial.dispose();\n\n\t\t\t}\n\n\t\t\tcache.clear();\n\n\t\t}\n\n\t}\n\n\t/**\n\t * Updates the selection cache based on the selected objects.\n\t *\n\t * @private\n\t */\n\t_updateSelectionCache() {\n\n\t\tfor ( let i = 0; i < this.selectedObjects.length; i ++ ) {\n\n\t\t\tconst selectedObject = this.selectedObjects[ i ];\n\t\t\tselectedObject.traverse( ( object ) => {\n\n\t\t\t\tif ( object.isMesh || object.isSprite ) this._selectionCache.add( object );\n\n\t\t\t} );\n\n\t\t}\n\n\t}\n\n\t/**\n\t * For the given material, this method returns the corresponding pass material.\n\t *\n\t * @private\n\t * @param {Map<Material, NodeMaterial>} cache - The material cache of the pass.\n\t * @param {NodeMaterial} baseMaterial - The pass material to derive from.\n\t * @param {Material} originalMaterial - The object's material.\n\t * @return {NodeMaterial} The pass material.\n\t */\n\t_getPassMaterial( cache, baseMaterial, originalMaterial ) {\n\n\t\tif ( ! originalMaterial.positionNode ) return baseMaterial; // early out if there are no node modifications\n\n\t\tlet force = false;\n\t\tlet passMaterial = cache.get( originalMaterial );\n\n\t\t// create\n\n\t\tif ( passMaterial === undefined ) {\n\n\t\t\tpassMaterial = baseMaterial.clone();\n\n\t\t\tcache.set( originalMaterial, passMaterial );\n\n\t\t\toriginalMaterial.addEventListener( 'dispose', this._onMaterialDispose );\n\n\t\t\tforce = true;\n\n\t\t}\n\n\t\t// update\n\n\t\tif ( passMaterial.version !== originalMaterial.version || force === true ) {\n\n\t\t\tpassMaterial.positionNode = originalMaterial.positionNode || null;\n\t\t\tpassMaterial.version = originalMaterial.version;\n\n\t\t}\n\n\t\treturn passMaterial;\n\n\t}\n\n}\n\nexport default OutlineNode;\n\n/**\n * TSL function for creating an outline effect around selected objects.\n *\n * @tsl\n * @function\n * @param {Scene} scene - A reference to the scene.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @param {Object} params - The configuration parameters.\n * @param {Array<Object3D>} [params.selectedObjects] - An array of selected objects.\n * @param {Node<float>} [params.edgeThickness=float(1)] - The thickness of the edges.\n * @param {Node<float>} [params.edgeGlow=float(0)] - Can be used for animated glow/pulse effects.\n * @param {number} [params.downSampleRatio=2] - The downsample ratio.\n * @returns {OutlineNode}\n */\nexport const outline = ( scene, camera, params ) => new OutlineNode( scene, camera, params );\n","import type { Node, PassNode } from 'three/webgpu';\nimport type { Camera, Scene } from 'three';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\nexport abstract class RoomleWebGPURenderPass {\n abstract readonly passId: string;\n\n /**\n * Combines this effect with the passed basePassNode\n */\n abstract assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'>;\n\n /**\n * mutates the gui by adding the relevant pass settings to it\n */\n abstract addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void;\n}\n","import type { Camera, ColorRepresentation, Object3D, Scene } from 'three';\nimport { SRGBColorSpace } from 'three';\nimport type { Node, UniformNode, PassNode } from 'three/webgpu';\nimport { Color } from 'three';\nimport { uniform, vec4 } from 'three/tsl';\nimport { outline } from 'three/addons/tsl/display/OutlineNode.js';\nimport { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\nexport interface OutlinePassParameters {\n selectedObjects: Object3D[];\n visibleEdgeColor: ColorRepresentation;\n hiddenEdgeColor: ColorRepresentation;\n edgeStrength: number;\n edgeGlow: number;\n edgeThickness: number;\n}\n\nexport class OutlineRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'OutlineRenderPass';\n override readonly passId = OutlineRenderPass.passId;\n private readonly selectedObjects: Object3D[];\n private readonly edgeStrength: UniformNode<'float', number>;\n private readonly edgeGlow: UniformNode<'float', number>;\n private readonly edgeThickness: UniformNode<'float', number>;\n private readonly visibleEdgeColor: UniformNode<'color', Color>;\n private readonly hiddenEdgeColor: UniformNode<'color', Color>;\n\n constructor(params: OutlinePassParameters) {\n super();\n this.selectedObjects = params.selectedObjects;\n this.edgeStrength = uniform(params.edgeStrength);\n this.edgeGlow = uniform(params.edgeGlow);\n this.edgeThickness = uniform(params.edgeThickness);\n this.visibleEdgeColor = uniform(new Color(params.visibleEdgeColor));\n this.hiddenEdgeColor = uniform(new Color(params.hiddenEdgeColor));\n }\n\n public highlightObjects(selectedMeshes: Object3D[]): void {\n this.selectedObjects.splice(\n 0,\n this.selectedObjects.length,\n ...selectedMeshes,\n );\n }\n\n public setOutlineColors(\n visibleEdgeColor: ColorRepresentation,\n hiddenEdgeColor: ColorRepresentation,\n ): void {\n this.visibleEdgeColor.value = new Color(visibleEdgeColor);\n this.hiddenEdgeColor.value = new Color(hiddenEdgeColor);\n }\n\n override assemble(\n _basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n const outlinePass = outline(scene, camera, {\n selectedObjects: this.selectedObjects,\n edgeThickness: this.edgeThickness,\n edgeGlow: this.edgeGlow,\n });\n\n const { visibleEdge, hiddenEdge } = outlinePass;\n\n const finalOutline = vec4(\n visibleEdge\n .mul(this.visibleEdgeColor)\n .add(hiddenEdge.mul(this.hiddenEdgeColor))\n .mul(this.edgeStrength),\n 0,\n ).toInspector('Outline / Composite');\n\n if (debugMode === 'outline') {\n return vec4(0, 0, 0, 0).add(finalOutline);\n }\n\n return currentNode.add(finalOutline);\n }\n\n override addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const gui = renderPassSettings.addFolder('Outline Settings');\n gui\n .add(this.edgeStrength, 'value', 0.01, 10)\n .name('edgeStrength')\n .onChange(() => updateCallback());\n gui\n .add(this.edgeGlow, 'value', 0.0, 1)\n .name('edgeGlow')\n .onChange(() => updateCallback());\n gui\n .add(this.edgeThickness, 'value', 1, 4)\n .name('edgeThickness')\n .onChange(() => updateCallback());\n gui\n .addColor(\n { color: this.visibleEdgeColor.value.getHex(SRGBColorSpace) },\n 'color',\n )\n .name('visibleEdgeColor')\n .onChange((value) => {\n this.visibleEdgeColor.value.set(value);\n updateCallback();\n });\n gui\n .addColor(\n { color: this.hiddenEdgeColor.value.getHex(SRGBColorSpace) },\n 'color',\n )\n .name('hiddenEdgeColor')\n .onChange((value) => {\n this.hiddenEdgeColor.value.set(value);\n updateCallback();\n });\n }\n}\n","\nimport { InspectorBase, TimestampQuery, warnOnce, RendererUtils, MeshBasicNodeMaterial, AdditiveBlending, NoToneMapping, LinearSRGBColorSpace } from 'three/webgpu';\nimport { vec3 } from 'three/tsl';\n\nclass ObjectStats {\n\n\tconstructor( uid, name ) {\n\n\t\tthis.uid = uid;\n\t\tthis.cid = uid.match( /^(.*):f(\\d+)$/ )[ 1 ]; // call id\n\t\tthis.name = name;\n\t\tthis.timestamp = 0;\n\t\tthis.cpu = 0;\n\t\tthis.gpu = 0;\n\t\tthis.fps = 0;\n\n\t\tthis.children = [];\n\t\tthis.parent = null;\n\n\t}\n\n}\n\nclass RenderStats extends ObjectStats {\n\n\tconstructor( uid, scene, camera, renderTarget ) {\n\n\t\tlet name = scene.name;\n\n\t\tif ( name === '' ) {\n\n\t\t\tif ( scene.isScene ) {\n\n\t\t\t\tname = 'Scene';\n\n\t\t\t} else if ( scene.isQuadMesh ) {\n\n\t\t\t\tname = 'QuadMesh';\n\n\t\t\t}\n\n\t\t}\n\n\t\tsuper( uid, name );\n\n\t\tthis.scene = scene;\n\t\tthis.camera = camera;\n\t\tthis.renderTarget = renderTarget;\n\n\t\tthis.isRenderStats = true;\n\n\t}\n\n}\n\nclass ComputeStats extends ObjectStats {\n\n\tconstructor( uid, computeNode ) {\n\n\t\tconst name = computeNode.name || ( computeNode.isComputeNode ? 'Compute' : 'Compute Group' );\n\n\t\tsuper( uid, name );\n\n\t\tthis.computeNode = computeNode;\n\n\t\tthis.isComputeStats = true;\n\n\t}\n\n}\n\n// returns true if the frame of the animation loop rendered or computed\n\nfunction isRenderedFrame( frame ) {\n\n\treturn frame.renders.length > 0 || frame.computes.length > 0;\n\n}\n\nexport class RendererInspector extends InspectorBase {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.currentFrame = null;\n\t\tthis.currentContext = null;\n\t\tthis.currentRender = null;\n\t\tthis.currentCompute = null;\n\t\tthis.currentNodes = null;\n\t\tthis.lastFrame = null;\n\n\t\tthis.frames = [];\n\t\tthis.framesLib = {};\n\t\tthis.maxFrames = 512;\n\n\t\tthis._lastFinishTime = 0;\n\t\tthis._lastRenderedFinishTime = 0;\n\t\tthis._resolveTimestampPromise = null;\n\t\tthis._rAFId = null;\n\n\t\tthis.overdraw = false;\n\t\tthis._overdrawMaterial = null;\n\t\tthis._renderingOverdraw = false;\n\n\t\tthis.isRendererInspector = true;\n\n\t}\n\n\tgetParent() {\n\n\t\treturn this.currentContext || this.getFrame();\n\n\t}\n\n\tbegin() {\n\n\t\tsuper.begin();\n\n\t\tthis.currentFrame = this._createFrame();\n\t\tthis.currentContext = this.currentFrame;\n\t\tthis.currentRender = null;\n\t\tthis.currentCompute = null;\n\t\tthis.currentNodes = [];\n\n\t}\n\n\tfinish() {\n\n\t\tsuper.finish();\n\n\t\tconst now = performance.now();\n\n\t\tconst frame = this.currentFrame;\n\t\tframe.finishTime = now;\n\n\t\t// frames of the animation loop which didn't render or compute, like frames skipped by the application\n\t\t// while the GPU is busy, are not frames of the application: the time is measured since the last frame\n\t\t// which rendered\n\n\t\tif ( isRenderedFrame( frame ) ) {\n\n\t\t\tframe.deltaTime = now - ( this._lastRenderedFinishTime > 0 ? this._lastRenderedFinishTime : now );\n\n\t\t\tthis._lastRenderedFinishTime = now;\n\n\t\t} else {\n\n\t\t\tframe.deltaTime = now - ( this._lastFinishTime > 0 ? this._lastFinishTime : now );\n\n\t\t}\n\n\t\tthis.addFrame( frame );\n\n\t\tthis.fps = this._getFPS();\n\n\t\tthis.lastFrame = frame;\n\n\t\tthis.currentFrame = null;\n\t\tthis.currentContext = null;\n\t\tthis.currentRender = null;\n\t\tthis.currentCompute = null;\n\t\tthis.currentNodes = null;\n\n\t\tthis._lastFinishTime = now;\n\n\t}\n\n\t_renderOverdraw() {\n\n\t\tconst primaryPass = this.getPrimaryPass();\n\n\t\tif ( primaryPass === null ) return;\n\n\t\tconst renderer = this.getRenderer();\n\n\t\tif ( this._overdrawMaterial === null ) {\n\n\t\t\t// additive constant, so each pixel sums the depth-passing fragments it shaded\n\n\t\t\tthis._overdrawMaterial = new MeshBasicNodeMaterial( {\n\t\t\t\tcolorNode: vec3( 0.25 ),\n\t\t\t\tblending: AdditiveBlending,\n\t\t\t\tdepthTest: true,\n\t\t\t\tdepthWrite: true\n\t\t\t} );\n\n\t\t}\n\n\t\tconst { scene, camera } = primaryPass;\n\n\t\t// raw render against black with no tone mapping, so the count stays linear\n\n\t\tconst state = RendererUtils.resetRendererAndSceneState( renderer, scene );\n\n\t\trenderer.toneMapping = NoToneMapping;\n\t\trenderer.outputColorSpace = LinearSRGBColorSpace;\n\n\t\tscene.overrideMaterial = this._overdrawMaterial;\n\n\t\tthis._renderingOverdraw = true;\n\n\t\trenderer.render( scene, camera );\n\n\t\tthis._renderingOverdraw = false;\n\n\t\tRendererUtils.restoreRendererAndSceneState( renderer, scene, state );\n\n\t}\n\n\t_getFPS() {\n\n\t\t// only the frames which rendered or computed are counted, within the last second\n\n\t\tlet frameSum = 0;\n\t\tlet timeSum = 0;\n\n\t\tfor ( let i = this.frames.length - 1; i >= 0; i -- ) {\n\n\t\t\tconst frame = this.frames[ i ];\n\n\t\t\tif ( isRenderedFrame( frame ) === false ) continue;\n\n\t\t\tframeSum ++;\n\t\t\ttimeSum += frame.deltaTime;\n\n\t\t\tif ( timeSum >= 1000 ) break;\n\n\t\t}\n\n\t\treturn timeSum > 0 ? ( frameSum * 1000 ) / timeSum : 0;\n\n\t}\n\n\t_createFrame() {\n\n\t\treturn {\n\t\t\tframeId: this.nodeFrame.frameId,\n\t\t\tresolvedCompute: false,\n\t\t\tresolvedRender: false,\n\t\t\tdeltaTime: 0,\n\t\t\tstartTime: performance.now(),\n\t\t\tfinishTime: 0,\n\t\t\tmiscellaneous: 0,\n\t\t\tchildren: [],\n\t\t\trenders: [],\n\t\t\tcomputes: []\n\t\t};\n\n\t}\n\n\tgetPrimaryPass() {\n\n\t\tconst frame = this.getFrame();\n\n\t\t// first scene render of the frame; nested shadow / RTT passes come after\n\n\t\tlet primary = null;\n\n\t\tfor ( const render of frame.renders ) {\n\n\t\t\tif ( render.scene.isScene === true ) {\n\n\t\t\t\tprimary = render;\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn primary;\n\n\t}\n\n\tgetFrame() {\n\n\t\treturn this.currentFrame || this.lastFrame;\n\n\t}\n\n\tgetFrameById( frameId ) {\n\n\t\treturn this.framesLib[ frameId ] || null;\n\n\t}\n\n\tupdateTabs() { }\n\n\tresolveFrame( /*frame*/ ) { }\n\n\tasync resolveTimestamp() {\n\n\t\tif ( this._resolveTimestampPromise !== null ) {\n\n\t\t\treturn this._resolveTimestampPromise;\n\n\t\t}\n\n\t\tthis._resolveTimestampPromise = new Promise( ( resolve ) => {\n\n\t\t\tthis._rAFId = requestAnimationFrame( async () => {\n\n\t\t\t\tthis._rAFId = null;\n\n\t\t\t\tconst renderer = this.getRenderer();\n\n\t\t\t\tif ( renderer === null ) {\n\n\t\t\t\t\tthis._resolveTimestampPromise = null;\n\t\t\t\t\tresolve();\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( renderer.backend.hasTimestamp ) {\n\n\t\t\t\t\tawait renderer.resolveTimestampsAsync( TimestampQuery.COMPUTE );\n\t\t\t\t\tawait renderer.resolveTimestampsAsync( TimestampQuery.RENDER );\n\n\t\t\t\t\tif ( renderer !== this.getRenderer() ) {\n\n\t\t\t\t\t\tthis._resolveTimestampPromise = null;\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst computeFrames = renderer.backend.getTimestampFrames( TimestampQuery.COMPUTE );\n\t\t\t\t\tconst renderFrames = renderer.backend.getTimestampFrames( TimestampQuery.RENDER );\n\n\t\t\t\t\tconst frameIds = [ ...new Set( [ ...computeFrames, ...renderFrames ] ) ];\n\n\t\t\t\t\tfor ( const frameId of frameIds ) {\n\n\t\t\t\t\t\tconst frame = this.getFrameById( frameId );\n\n\t\t\t\t\t\tif ( frame !== null ) {\n\n\t\t\t\t\t\t\t// resolve compute timestamps\n\n\t\t\t\t\t\t\tif ( frame.resolvedCompute === false ) {\n\n\t\t\t\t\t\t\t\tif ( frame.computes.length > 0 ) {\n\n\t\t\t\t\t\t\t\t\tif ( computeFrames.includes( frameId ) ) {\n\n\t\t\t\t\t\t\t\t\t\tfor ( const stats of frame.computes ) {\n\n\t\t\t\t\t\t\t\t\t\t\tif ( renderer.backend.hasTimestampQuery( stats.uid ) ) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpu = renderer.backend.getTimestamp( stats.uid );\n\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpu = 0;\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpuNotAvailable = true;\n\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tframe.resolvedCompute = true;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\tframe.resolvedCompute = true;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// resolve render timestamps\n\n\t\t\t\t\t\t\tif ( frame.resolvedRender === false ) {\n\n\t\t\t\t\t\t\t\tif ( frame.renders.length > 0 ) {\n\n\t\t\t\t\t\t\t\t\tif ( renderFrames.includes( frameId ) ) {\n\n\t\t\t\t\t\t\t\t\t\tfor ( const stats of frame.renders ) {\n\n\t\t\t\t\t\t\t\t\t\t\tif ( renderer.backend.hasTimestampQuery( stats.uid ) ) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpu = renderer.backend.getTimestamp( stats.uid );\n\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpu = 0;\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpuNotAvailable = true;\n\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tframe.resolvedRender = true;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\tframe.resolvedRender = true;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( frame.resolvedCompute === true && frame.resolvedRender === true ) {\n\n\t\t\t\t\t\t\t\tthis.resolveFrame( frame );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tfor ( const frame of this.frames ) {\n\n\t\t\t\t\t\tif ( frame.resolvedCompute === true && frame.resolvedRender === true ) {\n\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst previousFrame = this.getFrameById( frame.frameId - 1 );\n\n\t\t\t\t\t\tif ( previousFrame === null ) continue;\n\n\t\t\t\t\t\tif ( frame.resolvedCompute === false ) {\n\n\t\t\t\t\t\t\tfor ( const stats of frame.computes ) {\n\n\t\t\t\t\t\t\t\tstats.gpu = 0;\n\t\t\t\t\t\t\t\tstats.gpuNotAvailable = true;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tframe.resolvedCompute = true;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( frame.resolvedRender === false ) {\n\n\t\t\t\t\t\t\tfor ( const stats of frame.renders ) {\n\n\t\t\t\t\t\t\t\tstats.gpu = 0;\n\t\t\t\t\t\t\t\tstats.gpuNotAvailable = true;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tframe.resolvedRender = true;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( frame.resolvedCompute === true && frame.resolvedRender === true ) {\n\n\t\t\t\t\t\t\tthis.resolveFrame( frame );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis._resolveTimestampPromise = null;\n\n\t\t\t\tresolve();\n\n\t\t\t} );\n\n\t\t} );\n\n\t\treturn this._resolveTimestampPromise;\n\n\t}\n\n\tget isAvailable() {\n\n\t\tconst renderer = this.getRenderer();\n\n\t\treturn renderer !== null;\n\n\t}\n\n\taddFrame( frame ) {\n\n\t\t// Limit to max frames.\n\n\t\tif ( this.frames.length >= this.maxFrames ) {\n\n\t\t\tconst removedFrame = this.frames.shift();\n\t\t\tdelete this.framesLib[ removedFrame.frameId ];\n\n\t\t}\n\n\t\tthis.frames.push( frame );\n\t\tthis.framesLib[ frame.frameId ] = frame;\n\n\t\tif ( this.isAvailable ) {\n\n\t\t\tthis.updateTabs();\n\t\t\tthis.resolveTimestamp();\n\n\t\t}\n\n\t}\n\n\tinspect( node ) {\n\n\t\tif ( this.enabled === false ) return;\n\n\t\tconst currentNodes = this.currentNodes;\n\n\t\tif ( currentNodes !== null ) {\n\n\t\t\tcurrentNodes.push( node );\n\n\t\t} else {\n\n\t\t\twarnOnce( 'RendererInspector: Unable to inspect node outside of frame scope. Use \"renderer.setAnimationLoop()\".' );\n\n\t\t}\n\n\t}\n\n\tbeginCompute( uid, computeNode ) {\n\n\t\tconst frame = this.getFrame();\n\n\t\tif ( ! frame ) return;\n\n\t\tconst currentCompute = new ComputeStats( uid, computeNode );\n\t\tcurrentCompute.timestamp = performance.now();\n\t\tcurrentCompute.parent = this.getParent();\n\n\t\tframe.computes.push( currentCompute );\n\t\tcurrentCompute.parent.children.push( currentCompute );\n\n\t\tthis.currentCompute = currentCompute;\n\t\tthis.currentContext = currentCompute;\n\n\t}\n\n\tfinishCompute() {\n\n\t\tconst frame = this.getFrame();\n\n\t\tif ( ! frame ) return;\n\n\t\tconst currentCompute = this.currentCompute;\n\t\tcurrentCompute.cpu = performance.now() - currentCompute.timestamp;\n\n\t\tthis.currentContext = currentCompute.parent;\n\t\tthis.currentCompute = currentCompute.parent && currentCompute.parent.isComputeStats ? currentCompute.parent : null;\n\n\t}\n\n\tbeginRender( uid, scene, camera, renderTarget ) {\n\n\t\tconst frame = this.getFrame();\n\n\t\tif ( ! frame ) return;\n\n\t\tconst currentRender = new RenderStats( uid, scene, camera, renderTarget );\n\t\tcurrentRender.timestamp = performance.now();\n\t\tcurrentRender.parent = this.getParent();\n\n\t\tframe.renders.push( currentRender );\n\t\tcurrentRender.parent.children.push( currentRender );\n\n\t\tthis.currentRender = currentRender;\n\t\tthis.currentContext = currentRender;\n\n\t}\n\n\tfinishRender() {\n\n\t\tconst frame = this.getFrame();\n\n\t\tif ( ! frame ) return;\n\n\t\tconst currentRender = this.currentRender;\n\t\tcurrentRender.cpu = performance.now() - currentRender.timestamp;\n\n\t\tthis.currentContext = currentRender.parent;\n\t\tthis.currentRender = currentRender.parent && currentRender.parent.isRenderStats ? currentRender.parent : null;\n\n\t\t// draw over each top-level render to the canvas, the frame finishes only at the start of the next one\n\n\t\tif ( this.overdraw === true && this._renderingOverdraw === false && currentRender.parent === frame && this.getRenderer().getRenderTarget() === null ) {\n\n\t\t\tthis._renderOverdraw();\n\n\t\t}\n\n\t}\n\n\tdispose() {\n\n\t\tif ( this._rAFId !== null ) {\n\n\t\t\tcancelAnimationFrame( this._rAFId );\n\t\t\tthis._rAFId = null;\n\n\t\t}\n\n\t\tthis._resolveTimestampPromise = null;\n\n\t\tif ( this._overdrawMaterial !== null ) {\n\n\t\t\tthis._overdrawMaterial.dispose();\n\t\t\tthis._overdrawMaterial = null;\n\n\t\t}\n\n\t\tsuper.dispose();\n\n\t}\n\n}\n","export class Style {\n\n\tstatic init( container, nonce = null ) {\n\n\t\tconst css = /* css */`\n@scope (.three-inspector) {\n\n\t:scope {\n\t\t--profiler-background: #1e1e24f5;\n\t\t--profiler-header-background: #2a2a33aa;\n\t\t--profiler-header: #2a2a33;\n\t\t--profiler-border: #4a4a5a;\n\t\t--text-primary: #e0e0e0;\n\t\t--text-secondary: #9a9aab;\n\t\t--color-accent: #00aaff;\n\t\t--color-green: #4caf50;\n\t\t--color-yellow: #ffc107;\n\t\t--color-red: #f44336;\n\t\t--color-fps: rgb(63, 81, 181);\n\t\t--color-call: rgba(255, 185, 34, 1);\n\t\t--font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\t\t--font-mono: 'Courier New', Courier, monospace;\n\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tpointer-events: none;\n\t\tz-index: 1000;\n\t\toverflow: hidden;\n\t\tcolor-scheme: dark;\n\t}\n\n\t:scope * {\n\t\tpointer-events: auto;\n\t}\n\n\t.profiler-panel, .profiler-toggle, .detached-tab-panel,\n\t.profiler-panel *, .profiler-toggle *, .detached-tab-panel * {\n\t\ttext-transform: initial;\n\t\tline-height: normal;\n\t\tbox-sizing: border-box;\n\t\t-webkit-font-smoothing: antialiased;\n\t\t-moz-osx-font-smoothing: grayscale;\n\t\t-webkit-tap-highlight-color: transparent;\n\t}\n\n\t.profiler-toggle {\n\t\tposition: absolute;\n\t\ttop: 15px;\n\t\tright: 15px;\n\t\tbackground-color: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid #4a4a5a54;\n\t\tborder-radius: 12px 6px 6px 12px;\n\t\tcolor: var(--text-primary);\n\t\tcursor: pointer;\n\t\tz-index: 1002;\n\t\ttransition: all 0.2s ease-in-out;\n\t\t/*font-size: 14px;*/\n\t\tfont-size: 15px;\n\t\tbackdrop-filter: blur(8px);\n\t\tbox-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);\n\t\tdisplay: flex;\n\t\talign-items: stretch;\n\t\tpadding: 0;\n\t\toverflow: hidden;\n\t\tfont-family: var(--font-family);\n\t}\n\n\t.profiler-toggle-graph {\n\t\tposition: absolute;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tz-index: 0;\n\t\tpointer-events: none;\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tborder-radius: inherit;\n\t\topacity: 0.5;\n\t}\n\n\t.profiler-toggle.toggle-left {\n\t\tright: auto;\n\t\tleft: 15px;\n\t\tborder-radius: 6px 12px 12px 6px;\n\t\tflex-direction: row-reverse;\n\t}\n\n\t.profiler-toggle.toggle-left .builtin-tabs-container {\n\t\tborder-right: none;\n\t\tborder-left: 1px solid #262636;\n\t}\n\n\t.profiler-toggle:hover {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.profiler-toggle.panel-open .toggle-icon {\n\t\tbackground-color: rgba(0, 170, 255, 0.2);\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.toggle-icon {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\twidth: 40px;\n\t\tfont-size: 20px;\n\t\ttransition: background-color 0.2s;\n\t}\n\n\t.console-badge-container {\n\t\tposition: absolute;\n\t\ttop: 2px;\n\t\tright: 2px;\n\t\tdisplay: flex;\n\t\tgap: 2px;\n\t\tpointer-events: none;\n\t}\n\n\t.console-badge,\n\t.tab-badge {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tmin-width: 14px;\n\t\theight: 14px;\n\t\tpadding: 0 4px;\n\t\tborder-radius: 7px;\n\t\tfont-size: 9px;\n\t\tfont-weight: bold;\n\t\tcolor: #ffffff;\n\t\tline-height: 1;\n\t\tbox-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);\n\t\tborder: 1px solid rgba(0, 0, 0, 0.2);\n\t}\n\n\t.tab-badge-container {\n\t\tposition: absolute;\n\t\ttop: 1px;\n\t\tright: 3px;\n\t\tdisplay: flex;\n\t\tgap: 2px;\n\t\tpointer-events: none;\n\t}\n\n\t.console-badge.error,\n\t.tab-badge.error {\n\t\tbackground-color: var(--color-red);\n\t}\n\n\t.console-badge.warn,\n\t.tab-badge.warn {\n\t\tbackground-color: var(--color-yellow);\n\t\tcolor: #111111;\n\t}\n\n\t.profiler-toggle:hover .toggle-icon {\n\t\tbackground-color: rgba(255, 255, 255, 0.05);\n\t}\n\n\t.profiler-toggle.panel-open:hover .toggle-icon {\n\t\tbackground-color: rgba(0, 170, 255, 0.3);\n\t}\n\n\t.toggle-separator {\n\t\twidth: 1px;\n\t\tbackground-color: var(--profiler-border);\n\t}\n\n\t.toggle-text {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tdisplay: flex;\n\t\talign-items: baseline;\n\t\tpadding: 8px 14px;\n\t\tmin-width: 80px;\n\t\tjustify-content: right;\n\t}\n\n\t.toggle-text .fps-label {\n\t\tfont-size: 0.7em;\n\t\tmargin-left: 10px;\n\t\tcolor: #999;\n\t}\n\n\t.builtin-tabs-container {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tdisplay: flex;\n\t\talign-items: stretch;\n\t\tgap: 0;\n\t\tborder-right: 1px solid #262636;\n\t\torder: -1;\n\t}\n\n\t.builtin-tab-btn {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tcolor: var(--text-secondary);\n\t\tcursor: pointer;\n\t\tpadding: 8px 14px;\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 13px;\n\t\tfont-weight: 600;\n\t\ttransition: all 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tmin-width: 32px;\n\t\tposition: relative;\n\t}\n\n\t.builtin-tab-btn svg {\n\t\twidth: 20px;\n\t\theight: 20px;\n\t\tstroke: currentColor;\n\t}\n\n\t.builtin-tab-btn:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.08);\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.builtin-tab-btn:active {\n\t\tbackground-color: rgba(255, 255, 255, 0.12);\n\t}\n\n\t.builtin-tab-btn.active {\n\t\tbackground-color: rgba(0, 170, 255, 0.2);\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.builtin-tab-btn.active:hover {\n\t\tbackground-color: rgba(0, 170, 255, 0.3);\n\t}\n\n\t.profiler-mini-panel {\n\t\tposition: absolute;\n\t\ttop: 60px;\n\t\tright: 15px;\n\t\tbackground-color: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid #4a4a5a54;\n\t\tborder-radius: 8px;\n\t\tcolor: var(--text-primary);\n\t\tz-index: 9999;\n\t\tbackdrop-filter: blur(8px);\n\t\tbox-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 11px;\n\t\twidth: 350px;\n\t\tmax-width: calc(100vw - 30px);\n\t\tmin-width: 170px;\n\t\tmax-height: calc(100vh - 100px);\n\t\toverflow-y: auto;\n\t\toverflow-x: hidden;\n\t\tdisplay: none;\n\t\topacity: 0;\n\t\ttransform: translateY(-10px) scale(0.98);\n\t\ttransition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), \n\t\t\t\t\ttransform 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.profiler-mini-panel.toggle-left {\n\t\tright: auto;\n\t\tleft: 15px;\n\t}\n\n\t.profiler-mini-panel.visible {\n\t\tdisplay: block;\n\t\topacity: 1;\n\t\ttransform: translateY(0) scale(1);\n\t}\n\n\t.profiler-toggle.toggle-bottom {\n\t\ttop: auto;\n\t\tbottom: 15px;\n\t}\n\n\t.profiler-mini-panel.toggle-bottom {\n\t\ttop: auto;\n\t\tbottom: 60px;\n\t}\n\n\t.profiler-mini-panel::-webkit-scrollbar {\n\t\twidth: 6px;\n\t}\n\n\t.profiler-mini-panel::-webkit-scrollbar-track {\n\t\tbackground: transparent;\n\t}\n\n\t.profiler-mini-panel::-webkit-scrollbar-thumb {\n\t\tbackground: rgba(255, 255, 255, 0.15);\n\t\tborder-radius: 3px;\n\t\ttransition: background 0.2s;\n\t}\n\n\t.profiler-mini-panel::-webkit-scrollbar-thumb:hover {\n\t\tbackground: rgba(255, 255, 255, 0.25);\n\t}\n\n\t.mini-panel-content {\n\t\tpadding: 0;\n\t\tfont-size: 11px;\n\t\tline-height: 1.5;\n\t\tfont-family: var(--font-mono);\n\t\tletter-spacing: 0.3px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.mini-panel-content .profiler-content {\n\t\tdisplay: block !important;\n\t\tbackground: transparent;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper {\n\t\tmax-height: calc(100vh - 120px);\n\t\toverflow-y: auto;\n\t\toverflow-x: hidden;\n\t\twidth: 100%;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar {\n\t\twidth: 4px;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-track {\n\t\tbackground: transparent;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-thumb {\n\t\tbackground: rgba(255, 255, 255, 0.1);\n\t\tborder-radius: 2px;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-thumb:hover {\n\t\tbackground: rgba(255, 255, 255, 0.2);\n\t}\n\n\t.mini-panel-content .parameters {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tbox-shadow: none;\n\t\tpadding: 4px;\n\t}\n\n\t@media screen and (max-width: 340px) {\n\n\t\t.mini-panel-content .parameters {\n\t\t\tmin-width: 0 !important;\n\t\t}\n\n\t}\n\n\t.mini-panel-content .list-container.parameters {\n\t\tpadding: 2px 6px 0px 6px !important;\n\t}\n\n\t.mini-panel-content .list-header {\n\t\tdisplay: none;\n\t\tpadding: 2px 4px;\n\t\tfont-size: 11px;\n\t\tfont-weight: 600;\n\t\ttext-transform: uppercase;\n\t\tletter-spacing: 0.5px;\n\t}\n\n\t.mini-panel-content .list-item {\n\t\tborder-bottom: 1px solid rgba(74, 74, 90, 0.2);\n\t\ttransition: background-color 0.15s;\n\t}\n\n\t.mini-panel-content .list-item:last-child {\n\t\tborder-bottom: none;\n\t}\n\n\t.mini-panel-content .list-item:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.04);\n\t}\n\n\t.mini-panel-content .list-item.actionable:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.06);\n\t\tcursor: pointer;\n\t}\n\n\t.info-icon {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tborder-radius: 50%;\n\t\tbackground-color: rgba(255, 255, 255, 0.1);\n\t\tcolor: var(--text-secondary);\n\t\tfont-size: 10px;\n\t\tfont-style: italic;\n\t\tmargin-left: 6px;\n\t\tcursor: help;\n\t\tposition: relative;\n\t\tvertical-align: middle;\n\t\ttop: -1px;\n\t}\n\n\t.info-icon.active {\n\t\tbackground-color: var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t@media (hover: hover) {\n\t\t.info-icon:hover {\n\t\t\tbackground-color: var(--color-accent);\n\t\t\tcolor: white;\n\t\t}\n\t}\n\n\t.info-tooltip {\n\t\tposition: fixed;\n\t\ttransform: translate(-50%, -100%);\n\t\tbackground-color: rgba(30, 30, 36, 0.95);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tborder-radius: 6px;\n\t\tpadding: 10px 14px;\n\t\tcolor: var(--text-primary);\n\t\tfont-size: 12px;\n\t\twidth: max-content;\n\t\tmax-width: 250px;\n\t\tbox-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);\n\t\topacity: 0;\n\t\tvisibility: hidden;\n\t\ttransition: opacity 0.2s, visibility 0.2s;\n\t\tz-index: 999999;\n\t\tfont-style: normal;\n\t\tfont-family: var(--font-family);\n\t\ttext-align: left;\n\t\twhite-space: normal;\n\t}\n\n\t.info-tooltip h3 {\n\t\tmargin: 0 0 6px 0;\n\t\tfont-size: 13px;\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.info-tooltip strong {\n\t\tfont-weight: 600;\n\t\tcolor: white;\n\t}\n\n\t/* Style adjustments for lil-gui look */\n\t.mini-panel-content .item-row {\n\t\tpadding: 3px 8px;\n\t\tmin-height: 24px;\n\t}\n\n\t.mini-panel-content .list-item-row {\n\t\tpadding: 1px 4px;\n\t\tgap: 8px;\n\t\tmin-height: 21px;\n\t\talign-items: center;\n\t}\n\n\t.mini-panel-content input[type=\"checkbox\"] {\n\t\twidth: 12px;\n\t\theight: 12px;\n\t}\n\n\t.mini-panel-content input[type=\"range\"] {\n\t\theight: 18px;\n\t}\n\n\t.mini-panel-content .value-number input,\n\t.mini-panel-content .value-slider input {\n\t\tbackground-color: rgba(0, 0, 0, 0.3);\n\t\tborder: 1px solid rgba(74, 74, 90, 0.5);\n\t\tfont-size: 10px;\n\t}\n\n\t.mini-panel-content .value-number input:focus,\n\t.mini-panel-content .value-slider input:focus {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.mini-panel-content .value-slider {\n\t\tgap: 6px;\n\t}\n\n\t/* Compact nested items */\n\t.mini-panel-content .list-item .list-item {\n\t\tmargin-left: 8px;\n\t}\n\n\t.mini-panel-content .list-item .list-item .item-row,\n\t.mini-panel-content .list-item .list-item .list-item-row {\n\t\tpadding: 2px 6px;\n\t\tmin-height: 22px;\n\t}\n\n\t/* Compact collapsible headers */\n\t.mini-panel-content .collapsible .item-row,\n\t.mini-panel-content .list-item-row.collapsible {\n\t\tpadding: 2px 8px;\n\t\tfont-weight: 600;\n\t\tmin-height: 16px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tline-height: 1;\n\t}\n\n\t.mini-panel-content .collapsible-icon {\n\t\tfont-size: 10px;\n\t\twidth: 14px;\n\t\theight: 14px;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"range\"] {\n\t\theight: 12px;\n\t\tmargin-top: 1px;\n\t\tpadding-top: 5px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t\toutline: none;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"range\"]::-webkit-slider-thumb {\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tmargin-top: -5px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"range\"]::-moz-range-thumb {\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tuser-select: none;\n\t\t-moz-user-select: none;\n\t}\n\n\t.mini-panel-content .list-children-container {\n\t\tpadding-left: 0;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"number\"] {\n\t\tflex-basis: 60px !important;\n\t}\n\n\t.mini-panel-content .param-control {\n\t\talign-items: center;\n\t}\n\n\t.mini-panel-content .param-control select {\n\t\tfont-size: 11px;\n\t}\n\n\t.mini-panel-content .list-item-wrapper {\n\t\tmargin-top: 0;\n\t\tmargin-bottom: 0;\n\t}\n\n\t.profiler-panel {\n\t\tposition: absolute;\n\t\tz-index: 1001 !important;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\tright: 0;\n\t\theight: 350px;\n\t\tbackground-color: var(--profiler-background);\n\t\tbackdrop-filter: blur(8px);\n\t\tborder-top: 2px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tz-index: 1000;\n\t\t/*box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.5);*/\n\t\ttransform: translateY(100%);\n\t\ttransition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), height 0.3s ease-out, width 0.3s ease-out;\n\t\tfont-family: var(--font-mono);\n\t}\n\n\t.profiler-panel.resizing,\n\t.profiler-panel.dragging {\n\t\ttransition: none;\n\t}\n\n\t.profiler-panel.visible {\n\t\ttransform: translateY(0);\n\t}\n\n\t.profiler-panel.maximized {\n\t\theight: 100%;\n\t\tz-index: 10000 !important;\n\t}\n\n\t/* Position-specific styles */\n\t.profiler-panel.position-top {\n\t\tbottom: auto;\n\t\ttop: 0;\n\t\tborder-top: none;\n\t\tborder-bottom: 2px solid var(--profiler-border);\n\t\ttransform: translateY(-100%);\n\t}\n\n\t.profiler-panel.position-top.visible {\n\t\ttransform: translateY(0);\n\t}\n\n\t.profiler-panel.position-bottom {\n\t\t/* Default position - already defined above */\n\t}\n\n\t.profiler-panel.position-left {\n\t\ttop: 0;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\tright: auto;\n\t\twidth: 350px;\n\t\theight: 100%;\n\t\tborder-top: none;\n\t\tborder-right: 2px solid var(--profiler-border);\n\t\ttransform: translateX(-100%);\n\t}\n\n\t.profiler-panel.position-left.visible {\n\t\ttransform: translateX(0);\n\t}\n\n\t.profiler-panel.position-right {\n\t\ttop: 0;\n\t\tbottom: 0;\n\t\tleft: auto;\n\t\tright: 0;\n\t\twidth: 350px;\n\t\theight: 100%;\n\t\tborder-top: none;\n\t\tborder-left: 2px solid var(--profiler-border);\n\t\ttransform: translateX(100%);\n\t}\n\n\t.profiler-panel.position-right.visible {\n\t\ttransform: translateX(0);\n\t}\n\n\t.profiler-panel.position-floating {\n\t\tborder: 2px solid var(--profiler-border);\n\t\tborder-radius: 8px;\n\t\tbox-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);\n\t\ttransform: none !important;\n\t\toverflow: hidden;\n\t}\n\n\t.profiler-panel.position-floating.visible {\n\t\ttransform: none !important;\n\t}\n\n\t.profiler-panel.position-floating .profiler-header {\n\t\tborder-radius: 6px 6px 0 0;\n\t}\n\n\t.profiler-panel.position-floating .panel-resizer {\n\t\tbottom: 0;\n\t\tright: 0;\n\t\ttop: auto;\n\t\tleft: auto;\n\t\twidth: 16px;\n\t\theight: 16px;\n\t\tcursor: nwse-resize;\n\t\tborder-radius: 0 0 6px 0;\n\t}\n\n\t.profiler-panel.position-floating .panel-resizer::after {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tright: 2px;\n\t\tbottom: 2px;\n\t\twidth: 10px;\n\t\theight: 10px;\n\t\tbackground: linear-gradient(135deg, transparent 0%, transparent 45%, var(--profiler-border) 45%, var(--profiler-border) 55%, transparent 55%);\n\t}\n\n\n\t.panel-resizer {\n\t\tposition: absolute;\n\t\ttop: -2px;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 5px;\n\t\tcursor: ns-resize;\n\t\tz-index: 1001;\n\t\ttouch-action: none;\n\t}\n\n\t.profiler-panel.position-top .panel-resizer {\n\t\ttop: auto;\n\t\tbottom: -2px;\n\t}\n\n\t.profiler-panel.position-left .panel-resizer {\n\t\ttop: 0;\n\t\tleft: auto;\n\t\tright: -2px;\n\t\twidth: 5px;\n\t\theight: 100%;\n\t\tcursor: ew-resize;\n\t}\n\n\t.profiler-panel.position-right .panel-resizer {\n\t\ttop: 0;\n\t\tleft: -2px;\n\t\tright: auto;\n\t\twidth: 5px;\n\t\theight: 100%;\n\t\tcursor: ew-resize;\n\t}\n\n\t.profiler-header {\n\t\tdisplay: flex;\n\t\tbackground-color: var(--profiler-header-background);\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t\tflex-shrink: 0;\n\t\tjustify-content: space-between;\n\t\talign-items: stretch;\n\n\t\toverflow-x: auto;\n\t\toverflow-y: hidden;\n\t\twidth: calc(100% - 120px);\n\t\theight: 32px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.profiler-panel.has-horizontal-scroll .profiler-header {\n\t\theight: 38px;\n\t}\n\n\t/* Adjust header width based on panel position */\n\t.profiler-panel.position-right .profiler-header,\n\t.profiler-panel.position-left .profiler-header {\n\t\twidth: calc(100% - 120px);\n\t}\n\n\t.profiler-panel.position-bottom .profiler-header,\n\t.profiler-panel.position-top .profiler-header {\n\t\twidth: calc(100% - 120px);\n\t}\n\n\t/* Adjust header width when position toggle button is hidden (mobile) */\n\t.profiler-panel.hide-position-toggle .profiler-header {\n\t\twidth: calc(100% - 80px);\n\t}\n\n\t/* Adjust header width when maximized (floating position toggle button is hidden) */\n\t.profiler-panel.maximized .profiler-header {\n\t\twidth: calc(100% - 80px);\n\t}\n\n\t/* ===== RULES FOR WHEN THERE ARE NO TABS ===== */\n\n\t/* Horizontal mode (bottom/top) without tabs */\n\t.profiler-panel.position-bottom.no-tabs:not(.maximized),\n\t.profiler-panel.position-top.no-tabs:not(.maximized) {\n\t\theight: 32px !important;\n\t\tmin-height: 32px !important;\n\t}\n\n\t.profiler-panel.position-bottom.no-tabs .profiler-header,\n\t.profiler-panel.position-top.no-tabs .profiler-header {\n\t\twidth: 100%;\n\t\theight: 32px;\n\t\tborder-bottom: none;\n\t}\n\n\t.profiler-panel.position-bottom.no-tabs .profiler-content-wrapper,\n\t.profiler-panel.position-top.no-tabs .profiler-content-wrapper {\n\t\tdisplay: none;\n\t}\n\n\t.profiler-panel.position-bottom.no-tabs .panel-resizer,\n\t.profiler-panel.position-top.no-tabs .panel-resizer {\n\t\tdisplay: none;\n\t}\n\n\t/* Vertical mode (right/left) without tabs */\n\t.profiler-panel.position-right.no-tabs:not(.maximized),\n\t.profiler-panel.position-left.no-tabs:not(.maximized) {\n\t\twidth: 40px !important;\n\t\tmin-width: 40px !important;\n\t}\n\n\t/* Vertical layout for header when no tabs */\n\t.profiler-panel.position-right.no-tabs .profiler-header,\n\t.profiler-panel.position-left.no-tabs .profiler-header {\n\t\twidth: 100%;\n\t\tflex-direction: column;\n\t\theight: 100%;\n\t\tborder-bottom: none;\n\t}\n\n\t/* Vertical layout for controls when no tabs */\n\t.profiler-panel.position-right.no-tabs .profiler-controls,\n\t.profiler-panel.position-left.no-tabs .profiler-controls {\n\t\tposition: static;\n\t\tflex-direction: column-reverse;\n\t\tjustify-content: flex-end;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tborder-bottom: none;\n\t\tborder-left: none;\n\t\tbackground: transparent;\n\t}\n\n\t.profiler-panel.position-right.no-tabs .profiler-controls button,\n\t.profiler-panel.position-left.no-tabs .profiler-controls button {\n\t\twidth: 100%;\n\t\theight: 40px;\n\t\tborder-left: none;\n\t\tborder-top: none;\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t}\n\n\t.profiler-panel.position-right.no-tabs .profiler-content-wrapper,\n\t.profiler-panel.position-left.no-tabs .profiler-content-wrapper {\n\t\tdisplay: none;\n\t}\n\n\t.profiler-panel.position-right.no-tabs .profiler-tabs,\n\t.profiler-panel.position-left.no-tabs .profiler-tabs {\n\t\tdisplay: none;\n\t\tpadding-left: 2px;\n\t}\n\n\t.profiler-panel.position-right.no-tabs .panel-resizer,\n\t.profiler-panel.position-left.no-tabs .panel-resizer {\n\t\tdisplay: none;\n\t}\n\n\t/* Hide position toggle on mobile without tabs */\n\t.profiler-panel.hide-position-toggle.position-right.no-tabs:not(.maximized),\n\t.profiler-panel.hide-position-toggle.position-left.no-tabs:not(.maximized) {\n\t\twidth: 40px !important;\n\t\tmin-width: 40px !important;\n\t}\n\n\t/* Hide drag indicator on mobile devices */\n\t.profiler-panel.is-mobile .tab-btn.active::before {\n\t\tdisplay: none;\n\t}\n\n\t.profiler-header::-webkit-scrollbar,\n\t.profiler-tabs::-webkit-scrollbar,\n\t.profiler-content::-webkit-scrollbar,\n\t.detached-tab-content::-webkit-scrollbar,\n\t.console-log::-webkit-scrollbar,\n\t.timelineTrack::-webkit-scrollbar,\n\t.list-scroll-wrapper::-webkit-scrollbar {\n\t\twidth: 4px;\n\t\theight: 4px;\n\t}\n\n\t.profiler-header::-webkit-scrollbar-track,\n\t.profiler-tabs::-webkit-scrollbar-track,\n\t.profiler-content::-webkit-scrollbar-track,\n\t.detached-tab-content::-webkit-scrollbar-track,\n\t.console-log::-webkit-scrollbar-track,\n\t.timelineTrack::-webkit-scrollbar-track,\n\t.list-scroll-wrapper::-webkit-scrollbar-track {\n\t\tbackground: transparent;\n\t}\n\n\t.profiler-header::-webkit-scrollbar-thumb,\n\t.profiler-tabs::-webkit-scrollbar-thumb,\n\t.profiler-content::-webkit-scrollbar-thumb,\n\t.detached-tab-content::-webkit-scrollbar-thumb,\n\t.console-log::-webkit-scrollbar-thumb,\n\t.timelineTrack::-webkit-scrollbar-thumb,\n\t.list-scroll-wrapper::-webkit-scrollbar-thumb {\n\t\tbackground-color: rgba(255, 255, 255, 0.15);\n\t\tborder-radius: 2px;\n\t}\n\n\t.profiler-header::-webkit-scrollbar-thumb:hover,\n\t.profiler-tabs::-webkit-scrollbar-thumb:hover,\n\t.profiler-content::-webkit-scrollbar-thumb:hover,\n\t.detached-tab-content::-webkit-scrollbar-thumb:hover,\n\t.console-log::-webkit-scrollbar-thumb:hover,\n\t.timelineTrack::-webkit-scrollbar-thumb:hover,\n\t.list-scroll-wrapper::-webkit-scrollbar-thumb:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.3);\n\t}\n\n\t.profiler-header::-webkit-scrollbar-corner,\n\t.profiler-tabs::-webkit-scrollbar-corner,\n\t.profiler-content::-webkit-scrollbar-corner,\n\t.detached-tab-content::-webkit-scrollbar-corner,\n\t.console-log::-webkit-scrollbar-corner,\n\t.timelineTrack::-webkit-scrollbar-corner,\n\t.list-scroll-wrapper::-webkit-scrollbar-corner {\n\t\tbackground: transparent;\n\t}\n\n\t.profiler-header,\n\t.profiler-tabs,\n\t.profiler-content,\n\t.detached-tab-content,\n\t.console-log,\n\t.timelineTrack,\n\t.list-scroll-wrapper {\n\t\tscrollbar-width: thin;\n\t\tscrollbar-color: rgba(255, 255, 255, 0.15) transparent;\n\t}\n\n\t.profiler-panel.dragging .profiler-header {\n\t\tcursor: grabbing !important;\n\t}\n\n\t.profiler-panel.dragging {\n\t\topacity: 0.8;\n\t}\n\n\t.profiler-tabs {\n\t\tdisplay: flex;\n\t\tcursor: grab;\n\t\tposition: relative;\n\t\tmargin-left: 2px;\n\t}\n\n\t.profiler-tabs:active {\n\t\tcursor: grabbing;\n\t}\n\n\n\t.profiler-controls {\n\t\tdisplay: flex;\n\t\tposition: absolute;\n\t\tright: 0;\n\t\ttop: 0;\n\t\theight: 32px;\n\t\tbackground: var(--profiler-header-background);\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t}\n\n\t.profiler-panel.has-horizontal-scroll .profiler-controls {\n\t\theight: 38px;\n\t}\n\n\t.tab-btn {\n\t\tposition: relative;\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\t/*border-right: 1px solid var(--profiler-border);*/\n\t\tcolor: var(--text-secondary);\n\t\tpadding: 0 15px 2px 15px;\n\t\theight: 100%;\n\t\tbox-sizing: border-box;\n\t\tcursor: default;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tfont-family: var(--font-family);\n\t\tfont-weight: 600;\n\t\tfont-size: 13px;\n\t\tuser-select: none;\n\t\ttransition: opacity 0.2s, transform 0.2s;\n\t\ttouch-action: pan-x;\n\t\twhite-space: nowrap;\n\t}\n\n\t.tab-btn.active {\n\t\tborder-bottom: 2px solid var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t.tab-btn.active::before {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tleft: 2px;\n\t\ttop: 50%;\n\t\ttransform: translateY(-50%);\n\t\twidth: 8px;\n\t\theight: 14px;\n\t\tbackground-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='8' height='14' viewBox='0 0 8 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='2' cy='3' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='2' cy='7' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='2' cy='11' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='6' cy='3' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='6' cy='7' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='6' cy='11' r='1' fill='%234a4a5a'/%3E%3C/svg%3E\");\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t\topacity: 0.6;\n\t}\n\n\t.tab-btn.no-detach.active::before {\n\t\tdisplay: none;\n\t}\n\n\t.floating-btn,\n\t.maximize-btn,\n\t.hide-panel-btn {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tborder-left: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-secondary);\n\t\twidth: 40px;\n\t\theight: 100%;\n\t\tcursor: pointer;\n\t\ttransition: all 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tflex-shrink: 0;\n\t}\n\n\t/* Disable transitions in vertical mode to avoid broken animations */\n\t.profiler-panel.position-right .floating-btn,\n\t.profiler-panel.position-right .maximize-btn,\n\t.profiler-panel.position-right .hide-panel-btn,\n\t.profiler-panel.position-left .floating-btn,\n\t.profiler-panel.position-left .maximize-btn,\n\t.profiler-panel.position-left .hide-panel-btn {\n\t\ttransition: background-color 0.2s, color 0.2s;\n\t}\n\n\t.floating-btn:hover,\n\t.maximize-btn:hover,\n\t.hide-panel-btn:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.1);\n\t\tcolor: var(--text-primary);\n\t}\n\n\t/* Hide maximize button when there are no tabs */\n\t.profiler-panel.position-right.no-tabs .maximize-btn,\n\t.profiler-panel.position-left.no-tabs .maximize-btn,\n\t.profiler-panel.position-bottom.no-tabs .maximize-btn,\n\t.profiler-panel.position-top.no-tabs .maximize-btn {\n\t\tdisplay: none !important;\n\t}\n\n\t/* Hide floating button when maximized */\n\t.profiler-panel.maximized .floating-btn {\n\t\tdisplay: none !important;\n\t}\n\n\t.profiler-content-wrapper {\n\t\tflex-grow: 1;\n\t\toverflow: hidden;\n\t\tposition: relative;\n\t}\n\n\t.profiler-content {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow-y: auto;\n\t\tfont-size: 13px;\n\t\tvisibility: hidden;\n\t\topacity: 0;\n\t\ttransition: opacity 0.2s, visibility 0.2s;\n\t\tbox-sizing: border-box;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.profiler-content.active {\n\t\tvisibility: visible;\n\t\topacity: 1;\n\t}\n\n\t.profiler-content {\n\t\toverflow: auto; /* make sure scrollbars can appear */\n\t}\n\n\n\t.list-item-row {\n\t\tdisplay: grid;\n\t\tgrid-template-columns: var(--list-grid-template, none);\n\t\talign-items: center;\n\t\tpadding: 4px 8px;\n\t\tborder-radius: 3px;\n\t\ttransition: background-color 0.2s;\n\t\tgap: 10px;\n\t\tborder-bottom: none;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.parameters .list-item-row {\n\t\tmin-height: 23px;\n\t}\n\n\t.mini-panel-content .parameters .list-item-row {\n\t\tmin-height: 21px;\n\t}\n\n\t.list-item-wrapper {\n\t\tmargin-top: 2px;\n\t\tmargin-bottom: 2px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.list-item-wrapper:has(> .list-item-row .graph-container) {\n\t\tmargin-left: -1.5em;\n\t}\n\n\t.list-item-wrapper:first-child {\n\t\t/*margin-top: 0;*/\n\t}\n\n\t.list-item-wrapper:not(.header-wrapper):nth-child(odd) > .list-item-row {\n\t\tbackground-color: rgba(0,0,0,0.1);\n\t}\n\n\t.list-item-wrapper.header-wrapper>.list-item-row {\n\t\tcolor: var(--color-accent);\n\t\tbackground-color: rgba(0, 170, 255, 0.1);\n\t}\n\n\t.list-item-wrapper.header-wrapper>.list-item-row>.list-item-cell:first-child {\n\t\tfont-weight: 600;\n\t}\n\n\t.list-item-row.collapsible,\n\t.list-item-row.actionable {\n\t\tcursor: pointer;\n\t}\n\n\t.list-item-row.collapsible {\n\t\tbackground-color: rgba(0, 170, 255, 0.15) !important;\n\t\tmin-height: 23px;\n\t}\n\n\t.list-item-row.collapsible.alert,\n\t.list-item-row.alert {\n\t\tbackground-color: rgba(244, 67, 54, 0.1) !important;\n\t}\n\n\t@media (hover: hover) {\n\n\t\t.list-item-row:hover:not(.collapsible):not(.no-hover),\n\t\t.list-item-row:hover:not(.no-hover),\n\t\t.list-item-row.actionable:hover,\n\t\t.list-item-row.collapsible.actionable:hover {\n\t\t\tbackground-color: rgba(255, 255, 255, 0.05) !important;\n\t\t}\n\n\t\t.list-item-row.collapsible:hover {\n\t\t\tbackground-color: rgba(0, 170, 255, 0.25) !important;\n\t\t}\n\n\t}\n\n\t.list-item-cell {\n\t\twhite-space: pre;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.list-item-cell:not(:first-child) {\n\t\tjustify-content: flex-end;\n\t\tfont-weight: 600;\n\t}\n\n\t.list-header {\n\t\tdisplay: grid;\n\t\tgrid-template-columns: var(--list-grid-template, none);\n\t\talign-items: center;\n\t\tpadding: 4px 8px;\n\t\tfont-weight: 600;\n\t\tcolor: var(--text-secondary);\n\t\tpadding-bottom: 6px;\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t\tmargin-bottom: 5px;\n\t\tgap: 10px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.list-item-wrapper.section-start {\n\t\tmargin-top: 5px;\n\t\tmargin-bottom: 5px;\n\t}\n\n\t.list-header .list-header-cell:not(:first-child) {\n\t\ttext-align: right;\n\t}\n\n\t.list-children-container {\n\t\tpadding-left: 1.5em;\n\t\toverflow: hidden;\n\t\ttransition: max-height 0.1s ease-out;\n\t\tmargin-top: 2px;\n\t}\n\n\t.list-children-container.closed {\n\t\tmax-height: 0;\n\t\tdisplay: none !important;\n\t}\n\n\t.item-toggler {\n\t\tdisplay: inline-block;\n\t\tmargin-right: 0.8em;\n\t\ttext-align: left;\n\t}\n\n\t.list-item-row.open .item-toggler::before {\n\t\tcontent: '-';\n\t}\n\n\t.list-item-row:not(.open) .item-toggler::before {\n\t\tcontent: '+';\n\t}\n\n\t.list-item-cell .value.good {\n\t\tcolor: var(--color-green);\n\t}\n\n\t.list-item-cell .value.warn {\n\t\tcolor: var(--color-yellow);\n\t}\n\n\t.list-item-cell .value.bad {\n\t\tcolor: var(--color-red);\n\t}\n\n\t.list-scroll-wrapper {\n\t\twidth: max-content;\n\t\tmin-width: 100%;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tmin-height: 100%;\n\t}\n\n\t.list-container.parameters .list-item-row:not(.collapsible) {\n\t}\n\n\t.graph-container {\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t\tpadding: 8px 0;\n\t\tposition: relative;\n\t}\n\n\t.graph-svg, .graph-canvas {\n\t\twidth: 0;\n\t\tmin-width: 100%;\n\t\theight: 80px;\n\t\tbackground-color: var(--profiler-header);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tborder-radius: 4px;\n\t\tdisplay: block;\n\t}\n\n\t.graph-path {\n\t\tstroke-width: 2;\n\t\tfill-opacity: 0.4;\n\t}\n\n\t.console-buttons-group {\n\t\tdisplay: flex;\n\t\tgap: 20px;\n\t}\n\n\t.console-filter-input {\n\t\tbackground-color: var(--profiler-background);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px 10px 2px 10px;\n\t\tfont-family: var(--font-mono);\n\t\tflex-grow: 1;\n\t\tmax-width: 300px;\n\t\tborder-radius: 15px;\n\t}\n\n\t.console-filter-input:focus {\n\t\toutline: none;\n\t\tborder-color: var(--text-secondary);\n\t}\n\n\t.console-copy-button {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tcolor: var(--text-secondary);\n\t\tcursor: pointer;\n\t\tpadding: 4px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tborder-radius: 4px;\n\t\ttransition: color 0.2s, background-color 0.2s;\n\t}\n\n\t.console-copy-button:hover {\n\t\tcolor: var(--text-primary);\n\t\tbackground-color: var(--profiler-hover);\n\t}\n\n\t.console-copy-button.copied {\n\t\tcolor: var(--color-green);\n\t}\n\n\t.console-log {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tgap: 4px;\n\t\tpadding: 10px;\n\t\toverflow-y: auto;\n\t\tflex-grow: 1;\n\t\tuser-select: text;\n\t\t-webkit-user-select: text;\n\t}\n\n\t.log-message {\n\t\tdisplay: flex;\n\t\talign-items: flex-start;\n\t\tgap: 6px;\n\t\tpadding: 3px 5px;\n\t\tborder-radius: 3px;\n\t\tline-height: 1.5 !important;\n\t}\n\n\t.log-count-badge {\n\t\tdisplay: inline-block;\n\t\ttext-align: center;\n\t\tmin-width: 14px;\n\t\theight: 14px;\n\t\tborder-radius: 7px;\n\t\tpadding: 0 3px;\n\t\tfont-size: 9px;\n\t\tfont-weight: bold;\n\t\tline-height: 14px;\n\t\tbox-sizing: border-box;\n\t\tmargin-top: 0;\n\t\tflex-shrink: 0;\n\t}\n\n\t.log-icon {\n\t\tdisplay: inline-block;\n\t\ttext-align: center;\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tfont-size: 11px;\n\t\tline-height: 14px;\n\t\tmargin-top: 0;\n\t\tflex-shrink: 0;\n\t}\n\n\t.log-body {\n\t\tflex-grow: 1;\n\t\twhite-space: pre-wrap;\n\t\tword-break: break-all;\n\t}\n\n\t.log-message.info .log-count-badge {\n\t\tbackground-color: rgba(255, 255, 255, 0.12);\n\t\tborder: 1px solid rgba(255, 255, 255, 0.2);\n\t\tcolor: var(--text-secondary);\n\t}\n\n\t.log-message.warn .log-count-badge {\n\t\tbackground-color: rgba(255, 193, 7, 0.18);\n\t\tborder: 1px solid rgba(255, 193, 7, 0.35);\n\t\tcolor: var(--color-yellow);\n\t}\n\n\t.log-message.error .log-count-badge {\n\t\tbackground-color: rgba(244, 67, 54, 0.18);\n\t\tborder: 1px solid rgba(244, 67, 54, 0.35);\n\t\tcolor: #ff8a80;\n\t}\n\n\t.log-message.hidden {\n\t\tdisplay: none;\n\t}\n\n\t.log-message.info {\n\t\tcolor: var(--text-primary);\n\t}\n\n\t.log-message.warn {\n\t\tcolor: var(--color-yellow);\n\t}\n\n\t.log-message.error {\n\t\tcolor: #f9dedc;\n\t\tbackground-color: rgba(244, 67, 54, 0.1);\n\t}\n\n\t.log-prefix {\n\t\tcolor: var(--text-secondary);\n\t\tmargin-right: 8px;\n\t}\n\n\t.log-code {\n\t\tbackground-color: rgba(255, 255, 255, 0.1);\n\t\tborder-radius: 3px;\n\t\tpadding: 1px 4px;\n\t}\n\n\t.thumbnail-container {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t}\n\n\t.thumbnail-svg {\n\t\twidth: 40px;\n\t\theight: 22.5px;\n\t\tflex-shrink: 0;\n\t\tmargin-right: 8px;\n\t}\n\n\t.param-control {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: flex-end;\n\t\tgap: 10px;\n\t\twidth: 100%;\n\t}\n\n\t.param-control input,\n\t.param-control select,\n\t.param-control button {\n\t\tbackground-color: var(--profiler-background);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px 6px;\n\t\tpadding-bottom: 2px;\n\t\tfont-family: var(--font-mono);\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t\tcolor-scheme: dark;\n\t}\n\n\t.param-control input:focus {\n\t\toutline: none;\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.param-control select {\n\t\tpadding-top: 3px;\n\t\tpadding-bottom: 1px;\n\t}\n\n\t.param-control input[type=\"number\"] {\n\t\tcursor: ns-resize;\n\t}\n\n\t.param-control input[type=\"color\"] {\n\t\tpadding: 2px;\n\t}\n\n\t.param-control button {\n\t\tcursor: pointer;\n\t\ttransition: background-color 0.2s;\n\t}\n\n\t.param-control button:hover {\n\t\tbackground-color: var(--profiler-header);\n\t}\n\n\t.param-control-vector {\n\t\tdisplay: flex;\n\t\tgap: 5px;\n\t}\n\n\t.custom-checkbox {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tcursor: pointer;\n\t\tgap: 8px;\n\t\twill-change: transform;\n\t\tfont-size: 12px;\n\t}\n\n\t.custom-checkbox input {\n\t\tdisplay: none;\n\t}\n\n\t.custom-checkbox .checkmark {\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tborder: 1px solid var(--color-accent);\n\t\tborder-radius: 3px;\n\t\tdisplay: inline-flex;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\t\ttransition: background-color 0.2s, border-color 0.2s;\n\t}\n\n\t.custom-checkbox .checkbox-text {\n\t\tfont-size: 12px;\n\t\tmargin-top: 1px;\n\t\tcolor: inherit;\n\t}\n\n\t.custom-checkbox .checkmark::after {\n\t\tcontent: '';\n\t\twidth: 6px;\n\t\theight: 6px;\n\t\tbackground-color: var(--color-accent);\n\t\tborder-radius: 1px;\n\t\tdisplay: block;\n\t\ttransform: scale(0);\n\t\ttransition: transform 0.2s;\n\t}\n\n\t.list-container .custom-checkbox .checkmark {\n\t\twidth: 13px;\n\t\theight: 13px;\n\t}\n\n\t.list-container .custom-checkbox .checkmark::after {\n\t\twidth: 7px;\n\t\theight: 7px;\n\t}\n\n\t.custom-checkbox input:checked+.checkmark {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.custom-checkbox input:checked+.checkmark::after {\n\t\ttransform: scale(1);\n\t}\n\n\t.param-control input[type=\"range\"] {\n\t\t-webkit-appearance: none;\n\t\tappearance: none;\n\t\twidth: 100%;\n\t\theight: 16px;\n\t\tbackground: var(--profiler-header);\n\t\tborder-radius: 5px;\n\t\tborder: 1px solid var(--profiler-border);\n\t\toutline: none;\n\t\tpadding: 0px;\n\t\tpadding-top: 8px;\n\t}\n\n\t.param-control input[type=\"range\"]::-webkit-slider-thumb {\n\t\t-webkit-appearance: none;\n\t\tappearance: none;\n\t\twidth: 18px;\n\t\theight: 18px;\n\t\tbackground: var(--profiler-background);\n\t\tborder: 1px solid var(--color-accent);\n\t\tborder-radius: 3px;\n\t\tcursor: pointer;\n\t\tmargin-top: -8px;\n\t}\n\n\t.param-control input[type=\"range\"]::-moz-range-thumb {\n\t\twidth: 18px;\n\t\theight: 18px;\n\t\tbackground: var(--profiler-background);\n\t\tborder: 2px solid var(--color-accent);\n\t\tborder-radius: 3px;\n\t\tcursor: pointer;\n\t}\n\n\t.param-control input[type=\"range\"]::-moz-range-track {\n\t\twidth: 100%;\n\t\theight: 16px;\n\t\tbackground: var(--profiler-header);\n\t\tborder-radius: 5px;\n\t\tborder: 1px solid var(--profiler-border);\n\t}\n\n\t/* Override .param-control styles for mini-panel-content */\n\t.mini-panel-content input,\n\t.mini-panel-content select,\n\t.mini-panel-content button {\n\t\tpadding: 2px 4px;\n\t\theight: 21px;\n\t\tline-height: 1.4;\n\t\tpadding-top: 4px;\n\t}\n\n\t.mini-panel-content .param-control input,\n\t.mini-panel-content .param-control select,\n\t.mini-panel-content .param-control button {\n\t\tbackground-color: #1e1e24c2;\n\t\tline-height: 1.0;\n\t}\n\n\t.mini-panel-content .param-control select {\n\t\tpadding: 2px 2px;\n\t\tpadding-top: 3px;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"number\"]::-webkit-outer-spin-button,\n\t.mini-panel-content .param-control input[type=\"number\"]::-webkit-inner-spin-button {\n\t\t-webkit-appearance: none;\n\t\tmargin: 0;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"number\"] {\n\t\t-moz-appearance: textfield;\n\t}\n\n\t.mini-panel-content .list-item-cell span {\n\t\tposition: relative;\n\t\ttop: 1px;\n\t\tmargin-left: 2px;\n\t}\n\n\t.list-container.parameters .list-item-cell:first-child .value {\n\t\toverflow: hidden;\n\t\ttext-overflow: ellipsis;\n\t\twhite-space: nowrap;\n\t}\n\n\t.list-container.parameters .list-item-cell:first-child .value:has(> .info-icon) {\n\t\tposition: relative;\n\t\tpadding-right: 20px;\n\t}\n\n\t.list-container.parameters .list-item-cell:first-child .value > .info-icon {\n\t\tposition: absolute;\n\t\ttop: calc(50% - 8px);\n\t\tright: 0;\n\t}\n\n\t.mini-panel-content .custom-checkbox .checkmark {\n\t\twidth: 11px;\n\t\theight: 11px;\n\t\tmargin-bottom: 2px;\n\t\twill-change: transform;\n\t}\n\n\t.mini-panel-content .list-container.parameters .list-item-row:not(.collapsible) {\n\t\tmargin-bottom: 2px;\n\t}\n\n\t.mini-panel-content .list-container.parameters .list-item-wrapper:has(> .list-children-container.closed) + .list-item-wrapper {\n\t\tmargin-top: 2px;\n\t}\n\n\t.mini-panel-content .list-container.parameters .list-children-container > .list-item-wrapper:first-child:has(> .list-item-row:not(.collapsible)) {\n\t\tmargin-top: 2px;\n\t}\n\n\t.mini-panel-content .list-container.parameters .list-children-container > .list-item-wrapper:last-child:has(> .list-item-row:not(.collapsible)) {\n\t\tmargin-bottom: 4px;\n\t}\n\n\t@media screen and (max-width: 450px) and (orientation: portrait) {\n\n\t\t.console-filter-input {\n\t\t\tmax-width: 100px;\n\t\t}\n\n\t}\n\n\t/* Touch device optimizations */\n\t@media (hover: none) and (pointer: coarse) {\n\n\t\t.panel-resizer {\n\t\t\ttop: -10px !important;\n\t\t\theight: 20px !important;\n\t\t}\n\n\t\t.profiler-panel.position-top .panel-resizer {\n\t\t\ttop: auto !important;\n\t\t\tbottom: -10px !important;\n\t\t\theight: 20px !important;\n\t\t}\n\n\t\t.profiler-panel.position-left .panel-resizer {\n\t\t\tright: -10px !important;\n\t\t\twidth: 20px !important;\n\t\t\theight: 100% !important;\n\t\t}\n\n\t\t.profiler-panel.position-right .panel-resizer {\n\t\t\tleft: -10px !important;\n\t\t\twidth: 20px !important;\n\t\t\theight: 100% !important;\n\t\t}\n\n\t\t.detached-tab-resizer-top,\n\t\t.detached-tab-resizer-bottom {\n\t\t\theight: 10px !important;\n\t\t}\n\n\t\t.detached-tab-resizer-left,\n\t\t.detached-tab-resizer-right {\n\t\t\twidth: 10px !important;\n\t\t}\n\n\t}\n\n\t.drag-preview-indicator {\n\t\tposition: absolute;\n\t\tbackground-color: rgba(0, 170, 255, 0.2);\n\t\tborder: 2px dashed var(--color-accent);\n\t\tz-index: 999;\n\t\tpointer-events: none;\n\t\ttransition: all 0.2s ease-out;\n\t}\n\n\t/* Detached Tab Windows */\n\t.detached-tab-panel {\n\t\tposition: absolute;\n\t\twidth: 500px;\n\t\theight: 400px;\n\t\tbackground: var(--profiler-background);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tborder-radius: 8px;\n\t\tbox-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);\n\t\tz-index: 1002;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tbackdrop-filter: blur(10px);\n\t\toverflow: hidden;\n\t\topacity: 1;\n\t\tvisibility: visible;\n\t\ttransition: opacity 0.2s, visibility 0.2s;\n\t\tfont-family: var(--font-mono);\n\t\tfont-size: 13px;\n\t}\n\n\n\t.detached-tab-header {\n\t\tbackground: var(--profiler-header-background);\n\t\tpadding: 0 3px 0 10px;\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 13px;\n\t\tcolor: var(--text-primary);\n\t\tfont-weight: 600;\n\t\tdisplay: flex;\n\t\tjustify-content: space-between;\n\t\talign-items: center;\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t\tcursor: grab;\n\t\tuser-select: none;\n\t\theight: 32px;\n\t\tflex-shrink: 0;\n\t\t-webkit-font-smoothing: antialiased;\n\t\t-moz-osx-font-smoothing: grayscale;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-header:active {\n\t\tcursor: grabbing;\n\t}\n\n\t.detached-header-controls {\n\t\tdisplay: flex;\n\t\tgap: 5px;\n\t}\n\n\t.detached-reattach-btn {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tcolor: var(--text-secondary);\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 18px;\n\t\tline-height: 1;\n\t\tcursor: pointer;\n\t\tpadding: 4px 8px;\n\t\tborder-radius: 4px;\n\t\ttransition: all 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\t-webkit-font-smoothing: antialiased;\n\t\t-moz-osx-font-smoothing: grayscale;\n\t}\n\n\t.detached-reattach-btn:hover {\n\t\tbackground: rgba(0, 170, 255, 0.2);\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.detached-tab-content {\n\t\tflex: 1;\n\t\toverflow: hidden;\n\t\tposition: relative;\n\t\tbackground: var(--profiler-background);\n\t}\n\n\n\t.detached-tab-content .profiler-content {\n\t\tdisplay: flex !important;\n\t\tflex-direction: column !important;\n\t\theight: 100%;\n\t\tvisibility: visible !important;\n\t\topacity: 1 !important;\n\t\tposition: relative !important;\n\t}\n\n\t.detached-tab-content .profiler-content > * {\n\t\tfont-family: var(--font-mono);\n\t\tcolor: var(--text-primary);\n\t}\n\n\t.detached-tab-resizer {\n\t\tposition: absolute;\n\t\tbottom: 0;\n\t\tright: 0;\n\t\twidth: 20px;\n\t\theight: 20px;\n\t\tcursor: nwse-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-resizer::after {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tbottom: 2px;\n\t\tright: 2px;\n\t\twidth: 12px;\n\t\theight: 12px;\n\t\tborder-right: 2px solid var(--profiler-border);\n\t\tborder-bottom: 2px solid var(--profiler-border);\n\t\tborder-bottom-right-radius: 6px;\n\t\topacity: 0.5;\n\t}\n\n\t.detached-tab-resizer:hover::after {\n\t\topacity: 1;\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t/* Edge resizers */\n\t.detached-tab-resizer-top {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\tright: 0;\n\t\theight: 5px;\n\t\tcursor: ns-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-resizer-right {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tright: 0;\n\t\tbottom: 0;\n\t\twidth: 5px;\n\t\tcursor: ew-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-resizer-bottom {\n\t\tposition: absolute;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\tright: 0;\n\t\theight: 5px;\n\t\tcursor: ns-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-resizer-left {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\tbottom: 0;\n\t\twidth: 5px;\n\t\tcursor: ew-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t/* Input number spin buttons - hide arrows */\n\t/* Chrome, Safari, Edge, Opera */\n\t.profiler-panel input[type=\"number\"]::-webkit-outer-spin-button,\n\t.profiler-panel input[type=\"number\"]::-webkit-inner-spin-button,\n\t.detached-tab-content input[type=\"number\"]::-webkit-outer-spin-button,\n\t.detached-tab-content input[type=\"number\"]::-webkit-inner-spin-button {\n\t\t-webkit-appearance: none;\n\t\tmargin: 0;\n\t}\n\n\t/* Firefox */\n\t.profiler-panel input[type=\"number\"],\n\t.detached-tab-content input[type=\"number\"] {\n\t\t-moz-appearance: textfield;\n\t}\n\n\t.panel-action-btn {\n\t\tbackground: transparent;\n\t\tcolor: var(--text-primary);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tborder-radius: 4px;\n\t\tpadding: 6px 12px;\n\t\tcursor: pointer;\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 12px;\n\t\ttransition: background-color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t}\n\n\t.panel-action-btn:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.05);\n\t}\n\n\t.node-canvas-wrapper {\n\t\ttouch-action: none;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-detach-btn {\n\t\tposition: absolute;\n\t\ttop: 5px;\n\t\tright: 5px;\n\t\tbackground: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px;\n\t\tcursor: pointer;\n\t\topacity: 1;\n\t\ttransition: background-color 0.2s, border-color 0.2s, color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tz-index: 10;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-detach-btn:hover {\n\t\tbackground-color: var(--color-accent);\n\t\tborder-color: var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-fullscreen-btn {\n\t\tposition: absolute;\n\t\tbottom: 5px;\n\t\tright: 5px;\n\t\tbackground: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px;\n\t\tcursor: pointer;\n\t\topacity: 1;\n\t\ttransition: background-color 0.2s, border-color 0.2s, color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tz-index: 10;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-fullscreen-btn:hover {\n\t\tbackground-color: var(--color-accent);\n\t\tborder-color: var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t.profiler-panel.maximized .node-canvas-fullscreen-btn {\n\t\tdisplay: none;\n\t}\n\n\t.toolbar {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: space-between;\n\t\theight: 32px;\n\t\tpadding: 4px 6px;\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t\tbackground: var(--profiler-header-background);\n\t\tflex-shrink: 0;\n\t\tbox-sizing: border-box;\n\t\tgap: 16px;\n\t}\n\n\t.toolbar span {\n\t\tcolor: var(--text-secondary);\n\t\tfont-size: 12px;\n\t\tfont-weight: 600;\n\t}\n\n\t.toolbar .custom-checkbox .checkmark {\n\t\twidth: 12px;\n\t\theight: 12px;\n\t\tborder-radius: 4px;\n\t}\n\n\t.viewer-content .toolbar {\n\t\tjustify-content: flex-end;\n\t}\n\n\t.viewer-back-btn {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tcolor: var(--text-secondary);\n\t\tcursor: pointer;\n\t\tfont-size: 16px;\n\t\tline-height: 1;\n\t\tpadding: 4px 8px;\n\t\tborder-radius: 4px;\n\t\tmargin-right: auto;\n\t\ttransition: color 0.2s, background-color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t}\n\n\t.viewer-back-btn:hover {\n\t\tcolor: var(--text-primary);\n\t\tbackground-color: rgba(255, 255, 255, 0.05);\n\t}\n\n\tselect {\n\t\tcolor-scheme: dark;\n\t}\n\n\tselect option,\n\toption {\n\t\tbackground-color: #1e1e24;\n\t\tcolor: var(--text-primary);\n\t}\n\n\t.select {\n\t\tbackground: var(--profiler-background);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px 16px 2px 6px;\n\t\tfont-family: var(--font-mono);\n\t\tfont-size: 12px;\n\t\toutline: none;\n\t\tcursor: pointer;\n\t\tcolor-scheme: dark;\n\t\tappearance: none;\n\t\t-webkit-appearance: none;\n\t\t-moz-appearance: none;\n\t\tbackground-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e0e0e0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\");\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: right 5px center;\n\t\tbackground-size: 10px;\n\t}\n\n\t.select:focus {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.full-viewer-container {\n\t\tdisplay: none;\n\t\tflex-grow: 1;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden;\n\t\tposition: relative;\n\t\ttouch-action: none;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-split-btn {\n\t\tposition: absolute;\n\t\ttop: 5px;\n\t\tleft: 5px;\n\t\tbackground: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px;\n\t\tcursor: pointer;\n\t\topacity: 1;\n\t\ttransition: background-color 0.2s, border-color 0.2s, color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tz-index: 10;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-split-btn:hover {\n\t\tbackground-color: var(--color-accent);\n\t\tborder-color: var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-split-btn.active,\n\t.node-canvas-wrapper .node-canvas-fullscreen-btn.active {\n\t\tbackground-color: var(--color-accent) !important;\n\t\tborder-color: var(--color-accent) !important;\n\t\tcolor: white !important;\n\t}\n\n\t.split-screen-overlay {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tpointer-events: none !important;\n\t\tz-index: 999;\n\t\ttouch-action: none;\n\t\toverflow: hidden;\n\t}\n\n\t.split-screen-line {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tbottom: 0;\n\t\twidth: 1px;\n\t\tleft: 50%;\n\t\tbackground-color: transparent;\n\t\t/*background-color: rgba(255, 255, 255, 0.25);\n\t\tbox-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);*/\n\t\tcursor: ew-resize;\n\t\tpointer-events: auto !important;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t\ttransition: background-color 0.15s ease-out;\n\t}\n\n\t.split-screen-line:hover,\n\t.split-screen-line:active,\n\t.split-screen-line.active {\n\t\tbackground-color: var(--color-accent);\n\t}\n\n\t.split-screen-line::before {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tbottom: 0;\n\t\tleft: -12px;\n\t\twidth: 25px;\n\t\tbackground: transparent;\n\t\tcursor: ew-resize;\n\t}\n\n\t/* Grid Mode styles for List component */\n\t.list-scroll-wrapper:has(> .list-container.grid-mode) {\n\t\twidth: 100% !important;\n\t}\n\n\t.list-container.grid-mode {\n\t\tmin-width: 0 !important;\n\t\twidth: 100% !important;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.list-container.grid-mode .list-header {\n\t\tdisplay: none !important;\n\t}\n\n\t.list-container.grid-mode .list-children-container {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\tgap: 15px;\n\t\tpadding-left: 0 !important;\n\t\tmargin-top: 10px;\n\t\tmargin-bottom: 15px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.list-container.grid-mode .list-children-container > .list-item-wrapper {\n\t\tdisplay: inline-block;\n\t\twidth: 160px;\n\t\tmargin: 0;\n\t}\n\n\t.list-container.grid-mode .list-children-container > .list-item-wrapper > .list-item-row {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\talign-items: center;\n\t\tjustify-content: flex-start;\n\t\t/*background-color: var(--profiler-header);\n\t\tborder: 1px solid var(--profiler-border);*/\n\t\tborder-radius: 6px;\n\t\tpadding: 8px;\n\t\tgap: 8px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t\tgrid-template-columns: none !important;\n\t}\n\n\t.list-container.grid-mode .list-children-container > .list-item-wrapper > .list-item-row > .list-item-cell:first-child {\n\t\twidth: 140px;\n\t\theight: 140px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tpadding: 0;\n\t}\n\n\t.list-container.grid-mode .list-children-container > .list-item-wrapper > .list-item-row > .list-item-cell:not(:first-child) {\n\t\twidth: 100%;\n\t\ttext-align: center !important;\n\t\tfont-size: 11px;\n\t\tfont-weight: 500;\n\t\tcolor: var(--text-primary);\n\t\twhite-space: normal;\n\t\tword-break: break-all;\n\t\tjustify-content: center !important;\n\t}\n\n\t/* Timeline Info & Details */\n\t.timeline-detail-block {\n\t\tfont-size: 11px;\n\t\tmargin-left: 8px;\n\t\tcolor: var(--text-secondary);\n\t\topacity: 1;\n\t}\n\n\t.timeline-detail-key,\n\t.timeline-detail-sep,\n\t.timeline-call-count {\n\t\topacity: 0.5;\n\t}\n\n\t.timeline-detail-value {\n\t\tcolor: var(--text-secondary);\n\t\topacity: 1;\n\t}\n\n\t.timeline-info-group {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tmargin-left: 12px;\n\t\tflex-shrink: 0;\n\t}\n\n\t.timeline-info-dot {\n\t\twidth: 6px;\n\t\theight: 6px;\n\t\tborder-radius: 50%;\n\t\tmargin-right: 6px;\n\t\tflex-shrink: 0;\n\t}\n\n\t.timeline-info-dot.fps {\n\t\tbackground-color: var(--color-fps);\n\t}\n\n\t.timeline-info-dot.call {\n\t\tbackground-color: var(--color-call);\n\t}\n\n\t.timeline-info-dot.red {\n\t\tbackground-color: var(--color-red);\n\t}\n\n}\n`;\n\n\t\tconst styleElement = document.createElement( 'style' );\n\n\t\tif ( nonce ) {\n\n\t\t\tstyleElement.nonce = nonce;\n\n\t\t}\n\n\t\tstyleElement.textContent = css;\n\n\t\tcontainer.appendChild( styleElement );\n\n\t}\n\n}\n","export class Graph {\n\n\tconstructor( maxPoints = 512 ) {\n\n\t\tthis.maxPoints = maxPoints;\n\t\tthis.lines = {};\n\t\tthis.limit = 0;\n\t\tthis.limitIndex = 0;\n\n\t\tthis.domElement = document.createElement( 'canvas' );\n\t\tthis.domElement.setAttribute( 'class', 'graph-canvas' );\n\n\t\tthis.ctx = this.domElement.getContext( '2d' );\n\n\t\tthis.width = 0;\n\t\tthis.height = 0;\n\t\tthis.devicePixelRatio = window.devicePixelRatio || 1;\n\n\t}\n\n\tresize( width, height ) {\n\n\t\tthis.width = width;\n\t\tthis.height = height;\n\n\t\tthis.devicePixelRatio = window.devicePixelRatio || 1;\n\t\tthis.domElement.width = width * this.devicePixelRatio;\n\t\tthis.domElement.height = height * this.devicePixelRatio;\n\n\t\tthis.draw();\n\n\t}\n\n\taddLine( id, color ) {\n\n\t\tthis.lines[ id ] = {\n\t\t\tcolor: color,\n\t\t\tresolved: null,\n\t\t\tpoints: []\n\t\t};\n\n\t}\n\n\taddPoint( lineId, value ) {\n\n\t\tconst line = this.lines[ lineId ];\n\t\tif ( ! line ) return;\n\n\t\tline.points.push( value );\n\t\tif ( line.points.length > this.maxPoints ) {\n\n\t\t\tline.points.shift();\n\n\t\t}\n\n\t\tif ( value > this.limit ) {\n\n\t\t\tthis.limit = value;\n\t\t\tthis.limitIndex = 0;\n\n\t\t}\n\n\t}\n\n\tresetLimit() {\n\n\t\tthis.limit = 0;\n\t\tthis.limitIndex = 0;\n\n\t}\n\n\tupdate() {\n\n\t\tconst width = this.domElement.clientWidth;\n\t\tconst height = this.domElement.clientHeight;\n\n\t\tif ( width === 0 || height === 0 ) return;\n\n\t\tif ( width !== this.width || height !== this.height ) {\n\n\t\t\tthis.resize( width, height );\n\n\t\t} else {\n\n\t\t\tthis.draw();\n\n\t\t}\n\n\t\tif ( this.limitIndex ++ > this.maxPoints ) {\n\n\t\t\tthis.resetLimit();\n\n\t\t}\n\n\t}\n\n\tdraw() {\n\n\t\tconst ctx = this.ctx;\n\t\tconst dpr = this.devicePixelRatio;\n\t\tconst width = this.width;\n\t\tconst height = this.height;\n\n\t\tctx.clearRect( 0, 0, width * dpr, height * dpr );\n\n\t\tif ( width === 0 || height === 0 ) return;\n\n\t\tctx.save();\n\t\tctx.scale( dpr, dpr );\n\n\t\tconst pointStep = width / ( this.maxPoints - 1 );\n\n\t\tfor ( const id in this.lines ) {\n\n\t\t\tconst line = this.lines[ id ];\n\t\t\tif ( line.points.length === 0 ) continue;\n\n\t\t\tif ( ! line.resolved ) {\n\n\t\t\t\tline.resolved = this._resolveColor( line.color );\n\n\t\t\t}\n\n\t\t\tconst resolved = line.resolved;\n\t\t\tconst drawColor = resolved ? resolved.color : '#ffffff';\n\t\t\tconst offset = width - ( ( line.points.length - 1 ) * pointStep );\n\n\t\t\t// 1. Draw fill (with opacity)\n\t\t\tlet fillStyle = drawColor;\n\n\t\t\tif ( height > 0 ) {\n\n\t\t\t\tconst gradient = ctx.createLinearGradient( 0, 0, 0, height );\n\t\t\t\tgradient.addColorStop( 0, drawColor );\n\t\t\t\tgradient.addColorStop( 1, ( resolved && resolved.transparent ) || 'rgba(0,0,0,0)' );\n\t\t\t\tfillStyle = gradient;\n\n\t\t\t}\n\n\t\t\tctx.fillStyle = fillStyle;\n\t\t\tctx.globalAlpha = 0.4;\n\t\t\tctx.beginPath();\n\t\t\tctx.moveTo( offset, height );\n\t\t\tfor ( let i = 0; i < line.points.length; i ++ ) {\n\n\t\t\t\tconst x = offset + i * pointStep;\n\t\t\t\tconst y = this.limit === 0 ? height : height - ( line.points[ i ] / this.limit ) * height;\n\t\t\t\tctx.lineTo( x, y );\n\n\t\t\t}\n\n\t\t\tctx.lineTo( offset + ( line.points.length - 1 ) * pointStep, height );\n\t\t\tctx.closePath();\n\t\t\tctx.fill();\n\n\t\t\t// 2. Draw stroke (full opacity)\n\t\t\tctx.strokeStyle = drawColor;\n\t\t\tctx.lineWidth = 2;\n\t\t\tctx.globalAlpha = 1.0;\n\t\t\tctx.beginPath();\n\t\t\tfor ( let i = 0; i < line.points.length; i ++ ) {\n\n\t\t\t\tconst x = offset + i * pointStep;\n\t\t\t\tconst y = this.limit === 0 ? height : height - ( line.points[ i ] / this.limit ) * height;\n\t\t\t\tif ( i === 0 ) {\n\n\t\t\t\t\tctx.moveTo( x, y );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tctx.lineTo( x, y );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tctx.stroke();\n\n\t\t}\n\n\t\tctx.restore();\n\n\t}\n\n\t_resolveColor( color ) {\n\n\t\tlet resolved = color;\n\n\t\tif ( color.startsWith( 'var(' ) ) {\n\n\t\t\tconst varName = color.slice( 4, - 1 ).trim();\n\t\t\tresolved = getComputedStyle( this.domElement ).getPropertyValue( varName ).trim();\n\n\t\t\tif ( ! resolved ) {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tlet transparentColor = 'rgba(0,0,0,0)';\n\n\t\tif ( resolved.startsWith( '#' ) ) {\n\n\t\t\tconst hex = resolved.substring( 0, 7 );\n\t\t\ttransparentColor = hex + '00';\n\n\t\t} else if ( resolved.startsWith( 'rgb' ) ) {\n\n\t\t\tconst match = resolved.match( /^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*[\\d.]+)?\\)$/ );\n\n\t\t\tif ( match ) {\n\n\t\t\t\ttransparentColor = `rgba(${match[ 1 ]}, ${match[ 2 ]}, ${match[ 3 ]}, 0)`;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn {\n\t\t\tcolor: resolved,\n\t\t\ttransparent: transparentColor\n\t\t};\n\n\t}\n\n\tdispose() {\n\n\t}\n\n}\n","import { REVISION } from 'three/webgpu';\n\nconst STORAGE_KEY = 'threejs-inspector';\n\nfunction getItem( id ) {\n\n\tif ( typeof localStorage === 'undefined' ) return {};\n\n\tconst data = JSON.parse( localStorage.getItem( STORAGE_KEY ) || '{}' );\n\n\tif ( data.version !== REVISION ||\n\t\t data.settings && ( data.settings.storage === 'url' && data.settings.url !== location.href ) ) {\n\n\t\tlocalStorage.removeItem( STORAGE_KEY );\n\n\t\treturn {};\n\n\t}\n\n\treturn data[ id ] || {};\n\n}\n\nfunction setItem( id, state ) {\n\n\tif ( typeof localStorage === 'undefined' ) return;\n\n\tconst data = JSON.parse( localStorage.getItem( STORAGE_KEY ) || '{}' );\n\n\tif ( state === null ) {\n\n\t\tdelete data[ id ];\n\n\t} else {\n\n\t\tdata[ id ] = state;\n\n\t}\n\n\tdata.settings = data.settings || {};\n\tdata.settings.url = data.settings.url || location.href;\n\tdata.settings.storage = data.settings.storage || 'url';\n\tdata.version = REVISION;\n\n\tlocalStorage.setItem( STORAGE_KEY, JSON.stringify( data ) );\n\n}\n\nexport { getItem, setItem };\n","import { EventDispatcher } from 'three';\nimport { Style } from './Style.js';\nimport { Graph } from './Graph.js';\nimport { getItem, setItem } from '../Storage.js';\n\nexport class Profiler extends EventDispatcher {\n\n\tconstructor( inspector, options = {} ) {\n\n\t\tsuper();\n\n\t\tthis.inspector = inspector;\n\t\tthis.nonce = options.nonce ?? inspector?.nonce ?? null;\n\t\tthis.tabs = {};\n\t\tthis.activeTabId = null;\n\t\tthis.isResizing = false;\n\t\tthis.lastHeightBottom = 350; // Height for bottom position\n\t\tthis.lastWidthRight = 450; // Width for right position\n\t\tthis.position = 'bottom'; // 'bottom' or 'right'\n\t\tthis.detachedWindows = []; // Array to store detached tab windows\n\t\tthis.maxZIndex = 1002; // Track the highest z-index for detached windows (starts at base z-index from CSS)\n\t\tthis.nextTabOriginalIndex = 0; // Track the original order of tabs as they are added\n\n\t\tthis.horizontalAlign = 'right'; // 'left' or 'right'\n\t\tthis.verticalAlign = 'top'; // 'top' or 'bottom'\n\n\t\tthis.setupShell();\n\t\tthis.setupResizing();\n\n\t\tStyle.init( this.domElement, this.nonce );\n\n\t\tthis.updateWidgetPosition();\n\n\t\t// Setup window resize listener and update mobile status\n\t\tthis.setupWindowResizeListener();\n\n\t\t// Setup orientation change listener for mobile devices\n\t\tthis.setupOrientationListener();\n\n\t\tthis.checkHeaderScroll();\n\n\t\tthis.panel.addEventListener( 'transitionend', ( e ) => {\n\n\t\t\tif ( e.target === this.panel && ( e.propertyName === 'width' || e.propertyName === 'height' || e.propertyName === 'transform' ) ) {\n\n\t\t\t\tthis.checkHeaderScroll();\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tgetSize() {\n\n\t\tif ( this.panel.classList.contains( 'visible' ) === false || this.panel.classList.contains( 'no-tabs' ) ) {\n\n\t\t\treturn { width: 0, height: 0 };\n\n\t\t}\n\n\t\tif ( this.position === 'right' ) {\n\n\t\t\treturn { width: this.panel.offsetWidth, height: 0 };\n\n\t\t} else {\n\n\t\t\treturn { width: 0, height: this.panel.offsetHeight };\n\n\t\t}\n\n\t}\n\n\tget isMobile() {\n\n\t\treturn this.detectMobile();\n\n\t}\n\n\tget isSmallScreen() {\n\n\t\treturn window.innerWidth <= 768;\n\n\t}\n\n\tdetectMobile() {\n\n\t\t// Check for mobile devices\n\t\tconst userAgent = navigator.userAgent || navigator.vendor || window.opera;\n\t\tconst isMobileUA = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test( userAgent );\n\t\tconst isTouchDevice = ( 'ontouchstart' in window ) || ( navigator.maxTouchPoints > 0 );\n\n\t\treturn isMobileUA || ( isTouchDevice && this.isSmallScreen );\n\n\t}\n\n\tsetupOrientationListener() {\n\n\t\tconst handleOrientationChange = () => {\n\n\t\t\tif ( ! this.isMobile ) return;\n\n\t\t\t// Check if device is in landscape or portrait mode\n\t\t\tconst isLandscape = window.innerWidth > window.innerHeight;\n\n\t\t\t// In landscape mode, use right position (vertical panel)\n\t\t\t// In portrait mode, use bottom position (horizontal panel)\n\t\t\tconst targetPosition = isLandscape ? 'right' : 'bottom';\n\n\t\t\tif ( this.position !== targetPosition ) {\n\n\t\t\t\tthis.setPosition( targetPosition );\n\n\t\t\t}\n\n\t\t};\n\n\t\t// Initial check\n\t\thandleOrientationChange();\n\n\t\t// Listen for orientation changes\n\t\twindow.addEventListener( 'orientationchange', handleOrientationChange );\n\t\twindow.addEventListener( 'resize', handleOrientationChange );\n\n\t}\n\n\tsetupWindowResizeListener() {\n\n\t\tconst constrainDetachedWindows = () => {\n\n\t\t\tthis.detachedWindows.forEach( detachedWindow => {\n\n\t\t\t\tthis.constrainWindowToBounds( detachedWindow.panel );\n\n\t\t\t} );\n\n\t\t};\n\n\t\tconst constrainMainPanel = () => {\n\n\t\t\t// Skip if panel is maximized (it should always fill the screen)\n\t\t\tif ( this.panel.classList.contains( 'maximized' ) ) return;\n\n\t\t\tconst windowWidth = window.innerWidth;\n\t\t\tconst windowHeight = window.innerHeight;\n\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tconst currentHeight = this.panel.offsetHeight;\n\t\t\t\tconst maxHeight = windowHeight - 50; // Leave 50px margin\n\n\t\t\t\tif ( currentHeight > maxHeight ) {\n\n\t\t\t\t\tthis.panel.style.height = `${ maxHeight }px`;\n\t\t\t\t\tthis.lastHeightBottom = maxHeight;\n\n\t\t\t\t}\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\tconst currentWidth = this.panel.offsetWidth;\n\t\t\t\tconst maxWidth = windowWidth - 50; // Leave 50px margin\n\n\t\t\t\tif ( currentWidth > maxWidth ) {\n\n\t\t\t\t\tthis.panel.style.width = `${ maxWidth }px`;\n\t\t\t\t\tthis.lastWidthRight = maxWidth;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\t// Listen for window resize events\n\t\twindow.addEventListener( 'resize', () => {\n\n\t\t\tif ( this.isSmallScreen ) {\n\n\t\t\t\tthis.floatingBtn.style.display = 'none';\n\t\t\t\tthis.panel.classList.add( 'hide-position-toggle' );\n\n\t\t\t} else {\n\n\t\t\t\tthis.floatingBtn.style.display = '';\n\t\t\t\tthis.panel.classList.remove( 'hide-position-toggle' );\n\n\t\t\t}\n\n\t\t\tif ( this.isMobile ) {\n\n\t\t\t\tthis.panel.classList.add( 'is-mobile' );\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.classList.remove( 'is-mobile' );\n\n\t\t\t}\n\n\t\t\tconstrainDetachedWindows();\n\t\t\tconstrainMainPanel();\n\t\t\tthis.checkHeaderScroll();\n\t\t\tthis.notifyLayoutChange();\n\n\t\t} );\n\n\t}\n\n\tconstrainWindowToBounds( windowPanel ) {\n\n\t\tconst windowWidth = window.innerWidth;\n\t\tconst windowHeight = window.innerHeight;\n\n\t\tconst panelWidth = windowPanel.offsetWidth;\n\t\tconst panelHeight = windowPanel.offsetHeight;\n\n\t\tlet left = parseFloat( windowPanel.style.left ) || windowPanel.offsetLeft || 0;\n\t\tlet top = parseFloat( windowPanel.style.top ) || windowPanel.offsetTop || 0;\n\n\t\t// Allow window to extend half its width/height outside the screen\n\t\tconst halfWidth = panelWidth / 2;\n\t\tconst halfHeight = panelHeight / 2;\n\n\t\t// Constrain horizontal position (allow half width to extend beyond right edge)\n\t\tif ( left + panelWidth > windowWidth + halfWidth ) {\n\n\t\t\tleft = windowWidth + halfWidth - panelWidth;\n\n\t\t}\n\n\t\t// Constrain horizontal position (allow half width to extend beyond left edge)\n\t\tif ( left < - halfWidth ) {\n\n\t\t\tleft = - halfWidth;\n\n\t\t}\n\n\t\t// Constrain vertical position (allow half height to extend beyond bottom edge)\n\t\tif ( top + panelHeight > windowHeight + halfHeight ) {\n\n\t\t\ttop = windowHeight + halfHeight - panelHeight;\n\n\t\t}\n\n\t\t// Constrain vertical position (allow half height to extend beyond top edge)\n\t\tif ( top < - halfHeight ) {\n\n\t\t\ttop = - halfHeight;\n\n\t\t}\n\n\t\t// Apply constrained position\n\t\twindowPanel.style.left = `${ left }px`;\n\t\twindowPanel.style.top = `${ top }px`;\n\n\t}\n\n\tsetupShell() {\n\n\t\tthis.domElement = document.createElement( 'div' );\n\n\t\tthis.domElement.classList.add( 'three-inspector' );\n\n\t\tthis.domElement.addEventListener( 'keydown', ( e ) => e.stopPropagation() );\n\t\tthis.domElement.addEventListener( 'keyup', ( e ) => e.stopPropagation() );\n\n\t\tthis.toggleButton = document.createElement( 'button' );\n\t\tthis.toggleButton.classList.add( 'profiler-toggle' );\n\t\tthis.toggleButton.innerHTML = `\n<span class=\"builtin-tabs-container\"></span>\n<span class=\"toggle-text\">\n\t<span class=\"fps-counter\">-</span>\n\t<span class=\"fps-label\">FPS</span>\n</span>\n<span class=\"toggle-icon\">\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"icon icon-tabler icons-tabler-outline icon-tabler-device-ipad-horizontal-search\"><path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M11.5 20h-6.5a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v5.5\" /><path d=\"M9 17h2\" /><path d=\"M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0\" /><path d=\"M20.2 20.2l1.8 1.8\" /></svg>\n\t<span class=\"console-badge-container\">\n\t\t<span class=\"console-badge error\">0</span>\n\t\t<span class=\"console-badge warn\">0</span>\n\t</span>\n</span>\n`;\n\t\tthis.toggleButton.onclick = () => this.togglePanel();\n\n\t\tconst errorBadge = this.toggleButton.querySelector( '.console-badge.error' );\n\t\terrorBadge.style.display = 'none';\n\n\t\tconst warnBadge = this.toggleButton.querySelector( '.console-badge.warn' );\n\t\twarnBadge.style.display = 'none';\n\n\t\tthis.builtinTabsContainer = this.toggleButton.querySelector( '.builtin-tabs-container' );\n\n\t\t// Create mini-panel for builtin tabs (shown when panel is hidden)\n\t\tthis.miniPanel = document.createElement( 'div' );\n\t\tthis.miniPanel.classList.add( 'profiler-mini-panel' );\n\t\tthis.miniPanel.className = 'profiler-mini-panel';\n\n\t\tthis.panel = document.createElement( 'div' );\n\t\tthis.panel.classList.add( 'profiler-panel' );\n\n\t\tconst header = document.createElement( 'div' );\n\t\theader.className = 'profiler-header';\n\n\t\t// Enable horizontal scrolling with vertical mouse wheel\n\t\theader.addEventListener( 'wheel', ( e ) => {\n\n\t\t\tif ( e.deltaY !== 0 ) {\n\n\t\t\t\te.preventDefault();\n\t\t\t\theader.scrollLeft += e.deltaY * .25;\n\n\t\t\t}\n\n\t\t}, { passive: false } );\n\n\t\tthis.tabsContainer = document.createElement( 'div' );\n\t\tthis.tabsContainer.className = 'profiler-tabs';\n\n\t\tconst controls = document.createElement( 'div' );\n\t\tcontrols.className = 'profiler-controls';\n\n\t\tthis.floatingBtn = document.createElement( 'button' );\n\t\tthis.floatingBtn.classList.add( 'floating-btn' );\n\t\tthis.floatingBtn.title = 'Switch to Right Side';\n\t\tthis.floatingBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><line x1=\"15\" y1=\"3\" x2=\"15\" y2=\"21\"></line></svg>';\n\t\tthis.floatingBtn.onclick = () => this.togglePosition();\n\n\t\t// Hide position toggle button on small screens\n\t\tif ( this.isSmallScreen ) {\n\n\t\t\tthis.floatingBtn.style.display = 'none';\n\t\t\tthis.panel.classList.add( 'hide-position-toggle' );\n\n\t\t}\n\n\t\tif ( this.isMobile ) {\n\n\t\t\tthis.panel.classList.add( 'is-mobile' );\n\n\t\t}\n\n\t\tthis.maximizeBtn = document.createElement( 'button' );\n\t\tthis.maximizeBtn.classList.add( 'maximize-btn' );\n\t\tthis.maximizeBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"/></svg>';\n\t\tthis.maximizeBtn.onclick = () => this.toggleMaximize();\n\n\t\tconst hideBtn = document.createElement( 'button' );\n\t\thideBtn.classList.add( 'hide-panel-btn' );\n\t\thideBtn.textContent = '-';\n\t\thideBtn.onclick = () => this.togglePanel();\n\n\t\tcontrols.append( this.floatingBtn, this.maximizeBtn, hideBtn );\n\t\theader.append( this.tabsContainer, controls );\n\n\t\tthis.contentWrapper = document.createElement( 'div' );\n\t\tthis.contentWrapper.className = 'profiler-content-wrapper';\n\n\t\tconst resizer = document.createElement( 'div' );\n\t\tresizer.className = 'panel-resizer';\n\n\t\tthis.panel.append( resizer, header, this.contentWrapper );\n\n\t\tthis.domElement.append( this.toggleButton, this.miniPanel, this.panel );\n\n\t\t// Set initial position class\n\t\tthis.panel.classList.add( `position-${this.position}` );\n\n\t\tif ( this.position === 'right' ) {\n\n\t\t\tthis.toggleButton.classList.add( 'position-right' );\n\t\t\tthis.miniPanel.classList.add( 'position-right' );\n\n\t\t}\n\n\t\t// Create a background performance graph for the toggle button\n\t\tthis.toggleGraph = new Graph( 80 );\n\t\tthis.toggleGraph.addLine( 'fps', '#4c4c6bff' );\n\t\tthis.toggleGraph.domElement.className = 'profiler-toggle-graph';\n\t\tthis.toggleButton.appendChild( this.toggleGraph.domElement );\n\n\t}\n\n\tsetupResizing() {\n\n\t\tconst resizer = this.panel.querySelector( '.panel-resizer' );\n\n\t\tconst onStart = ( e ) => {\n\n\t\t\tthis.isResizing = true;\n\t\t\tthis.panel.classList.add( 'resizing' );\n\t\t\tresizer.setPointerCapture( e.pointerId );\n\t\t\tconst startX = e.clientX;\n\t\t\tconst startY = e.clientY;\n\t\t\tconst startHeight = this.panel.offsetHeight;\n\t\t\tconst startWidth = this.panel.offsetWidth;\n\n\t\t\tconst onMove = ( moveEvent ) => {\n\n\t\t\t\tif ( ! this.isResizing ) return;\n\t\t\t\tmoveEvent.preventDefault();\n\t\t\t\tconst currentX = moveEvent.clientX;\n\t\t\t\tconst currentY = moveEvent.clientY;\n\n\t\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\t\t// Vertical resize for bottom position\n\t\t\t\t\tconst newHeight = startHeight - ( currentY - startY );\n\n\t\t\t\t\tif ( newHeight > 100 && newHeight < window.innerHeight - 50 ) {\n\n\t\t\t\t\t\tthis.panel.style.height = `${ newHeight }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\t\t// Horizontal resize for right position\n\t\t\t\t\tconst newWidth = startWidth - ( currentX - startX );\n\n\t\t\t\t\tif ( newWidth > 200 && newWidth < window.innerWidth - 50 ) {\n\n\t\t\t\t\t\tthis.panel.style.width = `${ newWidth }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis.dispatchEvent( { type: 'resize' } );\n\t\t\t\tthis.checkHeaderScroll();\n\n\t\t\t};\n\n\t\t\tconst onEnd = () => {\n\n\t\t\t\tthis.isResizing = false;\n\t\t\t\tthis.panel.classList.remove( 'resizing' );\n\t\t\t\tresizer.removeEventListener( 'pointermove', onMove );\n\t\t\t\tresizer.removeEventListener( 'pointerup', onEnd );\n\t\t\t\tresizer.removeEventListener( 'pointercancel', onEnd );\n\t\t\t\tif ( ! this.panel.classList.contains( 'maximized' ) ) {\n\n\t\t\t\t\t// Save dimensions based on current position\n\t\t\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\t\t\tthis.lastHeightBottom = this.panel.offsetHeight;\n\n\t\t\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\t\t\tthis.lastWidthRight = this.panel.offsetWidth;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Save layout after resize\n\t\t\t\t\tthis.saveLayout();\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t\tresizer.addEventListener( 'pointermove', onMove );\n\t\t\tresizer.addEventListener( 'pointerup', onEnd );\n\t\t\tresizer.addEventListener( 'pointercancel', onEnd );\n\n\t\t};\n\n\t\tresizer.addEventListener( 'pointerdown', onStart );\n\n\t}\n\n\ttoggleMaximize() {\n\n\t\tif ( this.panel.classList.contains( 'maximized' ) ) {\n\n\t\t\tthis.panel.classList.remove( 'maximized' );\n\t\t\tthis.domElement.classList.remove( 'maximized' );\n\n\t\t\t// Restore size based on current position\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tthis.panel.style.height = `${ this.lastHeightBottom }px`;\n\t\t\t\tthis.panel.style.width = '100%';\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\tthis.panel.style.height = '100%';\n\t\t\t\tthis.panel.style.width = `${ this.lastWidthRight }px`;\n\n\t\t\t}\n\n\t\t\tthis.maximizeBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"/></svg>';\n\n\t\t} else {\n\n\t\t\t// Save current size before maximizing\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tthis.lastHeightBottom = this.panel.offsetHeight;\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\tthis.lastWidthRight = this.panel.offsetWidth;\n\n\t\t\t}\n\n\t\t\tthis.panel.classList.add( 'maximized' );\n\t\t\tthis.domElement.classList.add( 'maximized' );\n\n\t\t\t// Maximize based on current position\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tthis.panel.style.height = '100%';\n\t\t\t\tthis.panel.style.width = '100%';\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\tthis.panel.style.height = '100%';\n\t\t\t\tthis.panel.style.width = '100%';\n\n\t\t\t}\n\n\t\t\tthis.maximizeBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"8\" y=\"8\" width=\"12\" height=\"12\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg>';\n\n\t\t}\n\n\t\tthis.updateWidgetPosition();\n\n\t\tthis.dispatchEvent( { type: 'resize' } );\n\n\t}\n\n\thide() {\n\n\t\tthis.miniPanel.classList.remove( 'visible' );\n\n\t\tthis.miniPanel.querySelectorAll( '.mini-panel-content' ).forEach( content => {\n\n\t\t\tcontent.style.display = 'none';\n\n\t\t} );\n\n\t\tthis.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ).forEach( btn => {\n\n\t\t\tbtn.classList.remove( 'active' );\n\n\t\t} );\n\n\t}\n\n\tshow( tab ) {\n\n\t\tthis.hide();\n\n\t\ttab.builtinButton.classList.add( 'active' );\n\n\t\tif ( ! tab.miniContent.firstChild ) {\n\n\t\t\twhile ( tab.content.firstChild ) {\n\n\t\t\t\ttab.miniContent.appendChild( tab.content.firstChild );\n\n\t\t\t}\n\n\t\t}\n\n\t\ttab.miniContent.style.display = 'block';\n\t\tthis.miniPanel.classList.add( 'visible' );\n\n\t}\n\n\taddTab( tab ) {\n\n\t\tthis.tabs[ tab.id ] = tab;\n\n\t\t// Assign a permanent original index to this tab\n\t\ttab.originalIndex = this.nextTabOriginalIndex ++;\n\n\t\t// Add visual indicator for tabs that cannot be detached\n\t\tif ( tab.allowDetach === false ) {\n\n\t\t\ttab.button.classList.add( 'no-detach' );\n\n\t\t}\n\n\t\t// Set visibility change callback\n\t\ttab.onVisibilityChange = () => this.updatePanelSize();\n\n\t\tthis.setupTabDragAndDrop( tab );\n\n\t\tif ( ! tab.builtin ) {\n\n\t\t\tthis.tabsContainer.appendChild( tab.button );\n\n\t\t}\n\n\t\tthis.contentWrapper.appendChild( tab.content );\n\n\t\t// Apply the current visibility state to the DOM elements\n\t\tif ( ! tab.isVisible ) {\n\n\t\t\ttab.button.style.display = 'none';\n\t\t\ttab.content.style.display = 'none';\n\n\t\t}\n\n\t\t// If tab is builtin, add it to the profiler-toggle button\n\t\tif ( tab.builtin ) {\n\n\t\t\tthis.addBuiltinTab( tab );\n\n\t\t}\n\n\t\t// Set profiler reference\n\t\ttab.profiler = this;\n\n\t\t// Update panel size when tabs change\n\t\tthis.updatePanelSize();\n\n\t\t// If newly added tab matches activeTabId from saved layout, activate it\n\t\tif ( this.activeTabId && tab.id === this.activeTabId ) {\n\n\t\t\tthis.setActiveTab( tab.id );\n\n\t\t}\n\n\t}\n\n\taddBuiltinTab( tab ) {\n\n\t\t// Create a button for the builtin tab in the profiler-toggle\n\t\tconst builtinButton = document.createElement( 'button' );\n\t\tbuiltinButton.className = 'builtin-tab-btn';\n\n\t\t// Use icon if provided, otherwise use first letter\n\t\tif ( tab.icon ) {\n\n\t\t\tbuiltinButton.innerHTML = tab.icon;\n\n\t\t} else {\n\n\t\t\tbuiltinButton.textContent = tab.button.textContent.charAt( 0 ).toUpperCase();\n\n\t\t}\n\n\t\tbuiltinButton.title = tab.button.textContent;\n\n\t\t// Create mini-panel content container for this tab\n\t\tconst miniContent = document.createElement( 'div' );\n\t\tminiContent.className = 'mini-panel-content';\n\t\tminiContent.style.display = 'none';\n\n\t\t// Store references in the tab object\n\t\ttab.builtinButton = builtinButton;\n\t\ttab.miniContent = miniContent;\n\n\t\tthis.miniPanel.appendChild( miniContent );\n\n\t\tbuiltinButton.onclick = ( e ) => {\n\n\t\t\te.stopPropagation(); // Prevent toggle panel from triggering\n\n\t\t\t// Toggle mini-panel for this tab\n\t\t\tconst isCurrentlyActive = miniContent.style.display !== 'none' && miniContent.children.length > 0;\n\n\t\t\tif ( isCurrentlyActive ) {\n\n\t\t\t\tthis.hide();\n\n\t\t\t} else {\n\n\t\t\t\tthis.show( tab );\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.builtinTabsContainer.appendChild( builtinButton );\n\n\t\t// Store references\n\t\ttab.builtinButton = builtinButton;\n\t\ttab.miniContent = miniContent;\n\n\t\t// If the tab was hidden before being added, hide the builtin button\n\t\tif ( ! tab.isVisible ) {\n\n\t\t\tbuiltinButton.style.display = 'none';\n\t\t\tminiContent.style.display = 'none';\n\n\t\t\t// Hide the builtin-tabs-container if all builtin buttons are hidden\n\t\t\tconst hasVisibleBuiltinButtons = Array.from( this.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ) )\n\t\t\t\t.some( btn => btn.style.display !== 'none' );\n\n\t\t\tif ( ! hasVisibleBuiltinButtons ) {\n\n\t\t\t\tthis.builtinTabsContainer.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tremoveTab( tab ) {\n\n\t\tif ( ! tab || this.tabs[ tab.id ] === undefined ) return;\n\n\t\tdelete this.tabs[ tab.id ];\n\n\t\tif ( tab.isDetached && tab.detachedWindow ) {\n\n\t\t\tif ( tab.detachedWindow.panel && tab.detachedWindow.panel.parentNode ) {\n\n\t\t\t\ttab.detachedWindow.panel.parentNode.removeChild( tab.detachedWindow.panel );\n\n\t\t\t}\n\n\t\t\tconst index = this.detachedWindows.indexOf( tab.detachedWindow );\n\n\t\t\tif ( index !== - 1 ) {\n\n\t\t\t\tthis.detachedWindows.splice( index, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( ! tab.builtin ) {\n\n\t\t\tif ( tab.button && tab.button.parentNode ) {\n\n\t\t\t\ttab.button.parentNode.removeChild( tab.button );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( tab.builtinButton && tab.builtinButton.parentNode ) {\n\n\t\t\t\ttab.builtinButton.parentNode.removeChild( tab.builtinButton );\n\n\t\t\t}\n\n\t\t\tif ( tab.miniContent && tab.miniContent.parentNode ) {\n\n\t\t\t\ttab.miniContent.parentNode.removeChild( tab.miniContent );\n\n\t\t\t}\n\n\t\t\t// Clean up builtin container if empty\n\t\t\tconst hasVisibleBuiltinButtons = Array.from( this.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ) )\n\t\t\t\t.some( btn => btn.style.display !== 'none' );\n\n\t\t\tif ( ! hasVisibleBuiltinButtons ) {\n\n\t\t\t\tthis.builtinTabsContainer.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( tab.content && tab.content.parentNode ) {\n\n\t\t\ttab.content.parentNode.removeChild( tab.content );\n\n\t\t}\n\n\t\tif ( this.activeTabId === tab.id ) {\n\n\t\t\tthis.activeTabId = null;\n\n\t\t\t// Try to activate another tab\n\t\t\tconst remainingTabs = Object.values( this.tabs ).filter( t => ! t.isDetached && t.isVisible );\n\n\t\t\tif ( remainingTabs.length > 0 ) {\n\n\t\t\t\tthis.setActiveTab( remainingTabs[ 0 ].id );\n\n\t\t\t} else {\n\n\t\t\t\tthis.updatePanelSize();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.updatePanelSize();\n\n\t\t}\n\n\t\ttab.onVisibilityChange = null;\n\t\ttab.profiler = null;\n\n\t}\n\n\tupdatePanelSize() {\n\n\t\t// Check if there are any visible tabs in the panel\n\t\tconst hasVisibleTabs = Object.values( this.tabs ).some( tab => ! tab.isDetached && tab.isVisible );\n\n\t\t// Add or remove CSS class to indicate no tabs state\n\t\tif ( ! hasVisibleTabs ) {\n\n\t\t\tthis.panel.classList.add( 'no-tabs' );\n\n\t\t\t// If maximized and no tabs, restore to normal size\n\t\t\tif ( this.panel.classList.contains( 'maximized' ) ) {\n\n\t\t\t\tthis.panel.classList.remove( 'maximized' );\n\t\t\t\tthis.domElement.classList.remove( 'maximized' );\n\t\t\t\tthis.maximizeBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"/></svg>';\n\n\t\t\t}\n\n\t\t\t// No tabs visible - set to minimum size\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tthis.panel.style.height = '32px';\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\t// 45px = width of one button column\n\t\t\t\tthis.panel.style.width = '45px';\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.panel.classList.remove( 'no-tabs' );\n\n\t\t\tif ( Object.keys( this.tabs ).length > 0 ) {\n\n\t\t\t\t// Has tabs - restore to saved size only if we had set it to minimum before\n\t\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\t\tconst currentHeight = parseInt( this.panel.style.height );\n\t\t\t\t\tif ( currentHeight === 32 || currentHeight === 38 ) {\n\n\t\t\t\t\t\tthis.panel.style.height = `${ this.lastHeightBottom }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\t\tconst currentWidth = parseInt( this.panel.style.width );\n\t\t\t\t\tif ( currentWidth === 45 ) {\n\n\t\t\t\t\t\tthis.panel.style.width = `${ this.lastWidthRight }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.dispatchEvent( { type: 'resize' } );\n\t\tthis.checkHeaderScroll();\n\n\t}\n\n\tcheckHeaderScroll() {\n\n\t\tconst header = this.panel.querySelector( '.profiler-header' );\n\n\t\tif ( header ) {\n\n\t\t\tconst hasScroll = header.scrollWidth > header.clientWidth + 1;\n\n\t\t\tif ( hasScroll ) {\n\n\t\t\t\tthis.panel.classList.add( 'has-horizontal-scroll' );\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.classList.remove( 'has-horizontal-scroll' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tsetupTabDragAndDrop( tab ) {\n\n\t\t// Always handle basic click\n\t\ttab.button.addEventListener( 'click', () => {\n\n\t\t\tif ( ! isDragging ) {\n\n\t\t\t\tthis.setActiveTab( tab.id );\n\n\t\t\t}\n\n\t\t} );\n\n\t\t// Disable drag and drop if tab doesn't allow detach\n\t\tif ( tab.allowDetach === false ) {\n\n\t\t\ttab.button.style.cursor = 'default';\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet isDragging = false;\n\t\tlet startX, startY;\n\t\tlet hasMoved = false;\n\t\tlet previewWindow = null;\n\t\tconst dragThreshold = 10; // pixels to move before starting drag\n\n\t\tconst onDragStart = ( e ) => {\n\n\t\t\tstartX = e.clientX;\n\t\t\tstartY = e.clientY;\n\t\t\tisDragging = false;\n\t\t\thasMoved = false;\n\t\t\ttab.button.setPointerCapture( e.pointerId );\n\n\t\t};\n\n\t\tconst onDragMove = ( e ) => {\n\n\t\t\tconst currentX = e.clientX;\n\t\t\tconst currentY = e.clientY;\n\n\t\t\tconst deltaX = Math.abs( currentX - startX );\n\t\t\tconst deltaY = Math.abs( currentY - startY );\n\n\t\t\tif ( ! isDragging && ( deltaX > dragThreshold || deltaY > dragThreshold ) ) {\n\n\t\t\t\tisDragging = true;\n\t\t\t\ttab.button.style.cursor = 'grabbing';\n\t\t\t\ttab.button.style.opacity = '0.5';\n\t\t\t\ttab.button.style.transform = 'scale(1.05)';\n\n\t\t\t\tpreviewWindow = this.createPreviewWindow( tab, currentX, currentY );\n\t\t\t\tpreviewWindow.style.opacity = '0.8';\n\n\t\t\t}\n\n\t\t\tif ( isDragging && previewWindow ) {\n\n\t\t\t\thasMoved = true;\n\t\t\t\te.preventDefault();\n\n\t\t\t\tpreviewWindow.style.left = `${ currentX - 200 }px`;\n\t\t\t\tpreviewWindow.style.top = `${ currentY - 20 }px`;\n\n\t\t\t}\n\n\t\t};\n\n\t\tconst onDragEnd = () => {\n\n\t\t\tif ( isDragging && hasMoved && previewWindow ) {\n\n\t\t\t\tconst finalX = parseInt( previewWindow.style.left ) + 200;\n\t\t\t\tconst finalY = parseInt( previewWindow.style.top ) + 20;\n\n\t\t\t\tif ( previewWindow.parentNode ) {\n\n\t\t\t\t\tpreviewWindow.parentNode.removeChild( previewWindow );\n\n\t\t\t\t}\n\n\t\t\t\tthis.detachTab( tab, finalX, finalY );\n\n\t\t\t} else if ( ! hasMoved ) {\n\n\t\t\t\tthis.setActiveTab( tab.id );\n\n\t\t\t\tif ( previewWindow && previewWindow.parentNode ) {\n\n\t\t\t\t\tpreviewWindow.parentNode.removeChild( previewWindow );\n\n\t\t\t\t}\n\n\t\t\t} else if ( previewWindow ) {\n\n\t\t\t\tif ( previewWindow.parentNode ) {\n\n\t\t\t\t\tpreviewWindow.parentNode.removeChild( previewWindow );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ttab.button.style.opacity = '';\n\t\t\ttab.button.style.transform = '';\n\t\t\ttab.button.style.cursor = '';\n\t\t\tisDragging = false;\n\t\t\thasMoved = false;\n\t\t\tpreviewWindow = null;\n\n\t\t\ttab.button.removeEventListener( 'pointermove', onDragMove );\n\t\t\ttab.button.removeEventListener( 'pointerup', onDragEnd );\n\t\t\ttab.button.removeEventListener( 'pointercancel', onDragEnd );\n\n\t\t};\n\n\t\ttab.button.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\tif ( this.isMobile && e.pointerType !== 'mouse' ) return;\n\n\t\t\tonDragStart( e );\n\t\t\ttab.button.addEventListener( 'pointermove', onDragMove );\n\t\t\ttab.button.addEventListener( 'pointerup', onDragEnd );\n\t\t\ttab.button.addEventListener( 'pointercancel', onDragEnd );\n\n\t\t} );\n\n\t\t// Set cursor to grab for tabs that can be detached\n\t\ttab.button.style.cursor = 'grab';\n\n\t}\n\n\tcreatePreviewWindow( tab, x, y ) {\n\n\t\tconst windowPanel = document.createElement( 'div' );\n\t\twindowPanel.className = 'detached-tab-panel';\n\t\twindowPanel.style.left = `${ x - 200 }px`;\n\t\twindowPanel.style.top = `${ y - 20 }px`;\n\t\twindowPanel.style.pointerEvents = 'none'; // Preview only\n\n\t\t// Set z-index for preview window to be on top\n\t\tthis.maxZIndex ++;\n\t\twindowPanel.style.setProperty( 'z-index', this.maxZIndex, 'important' );\n\n\t\tconst windowHeader = document.createElement( 'div' );\n\t\twindowHeader.className = 'detached-tab-header';\n\n\t\tconst title = document.createElement( 'span' );\n\t\ttitle.textContent = tab.button.textContent.replace( '⇱', '' ).trim();\n\t\twindowHeader.appendChild( title );\n\n\t\tconst headerControls = document.createElement( 'div' );\n\t\theaderControls.className = 'detached-header-controls';\n\n\t\tconst reattachBtn = document.createElement( 'button' );\n\t\treattachBtn.className = 'detached-reattach-btn';\n\t\treattachBtn.innerHTML = '↩';\n\t\theaderControls.appendChild( reattachBtn );\n\t\twindowHeader.appendChild( headerControls );\n\n\t\tconst windowContent = document.createElement( 'div' );\n\t\twindowContent.className = 'detached-tab-content';\n\n\t\tconst resizer = document.createElement( 'div' );\n\t\tresizer.className = 'detached-tab-resizer';\n\n\t\twindowPanel.appendChild( resizer );\n\t\twindowPanel.appendChild( windowHeader );\n\t\twindowPanel.appendChild( windowContent );\n\n\t\tthis.domElement.appendChild( windowPanel );\n\n\t\treturn windowPanel;\n\n\t}\n\n\tdetachTab( tab, x, y ) {\n\n\t\tif ( tab.isDetached ) return;\n\n\t\t// Check if tab allows detachment\n\t\tif ( tab.allowDetach === false ) return;\n\n\t\tconst allButtons = Array.from( this.tabsContainer.children );\n\n\t\tconst tabIdsInOrder = allButtons.map( btn => {\n\n\t\t\treturn Object.keys( this.tabs ).find( id => this.tabs[ id ].button === btn );\n\n\t\t} ).filter( id => id !== undefined );\n\n\t\tconst currentIndex = tabIdsInOrder.indexOf( tab.id );\n\n\t\tlet newActiveTab = null;\n\n\t\tif ( this.activeTabId === tab.id ) {\n\n\t\t\ttab.setActive( false );\n\n\t\t\tconst remainingTabs = tabIdsInOrder.filter( id =>\n\t\t\t\tid !== tab.id &&\n\t\t\t\t! this.tabs[ id ].isDetached &&\n\t\t\t\tthis.tabs[ id ].isVisible\n\t\t\t);\n\n\t\t\tif ( remainingTabs.length > 0 ) {\n\n\t\t\t\tfor ( let i = currentIndex - 1; i >= 0; i -- ) {\n\n\t\t\t\t\tif ( remainingTabs.includes( tabIdsInOrder[ i ] ) ) {\n\n\t\t\t\t\t\tnewActiveTab = tabIdsInOrder[ i ];\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! newActiveTab ) {\n\n\t\t\t\t\tfor ( let i = currentIndex + 1; i < tabIdsInOrder.length; i ++ ) {\n\n\t\t\t\t\t\tif ( remainingTabs.includes( tabIdsInOrder[ i ] ) ) {\n\n\t\t\t\t\t\t\tnewActiveTab = tabIdsInOrder[ i ];\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! newActiveTab ) {\n\n\t\t\t\t\tnewActiveTab = remainingTabs[ 0 ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( tab.button.parentNode ) {\n\n\t\t\ttab.button.parentNode.removeChild( tab.button );\n\n\t\t}\n\n\t\tif ( tab.content.parentNode ) {\n\n\t\t\ttab.content.parentNode.removeChild( tab.content );\n\n\t\t}\n\n\t\tconst detachedWindow = this.createDetachedWindow( tab, x, y );\n\t\tthis.detachedWindows.push( detachedWindow );\n\n\t\ttab.isDetached = true;\n\t\ttab.detachedWindow = detachedWindow;\n\n\t\tif ( newActiveTab ) {\n\n\t\t\tthis.setActiveTab( newActiveTab );\n\n\t\t} else if ( this.activeTabId === tab.id ) {\n\n\t\t\tthis.activeTabId = null;\n\n\t\t}\n\n\t\t// Update panel size after detaching\n\t\tthis.updatePanelSize();\n\n\t\tthis.saveLayout();\n\n\t}\n\n\tcreateDetachedWindow( tab, x, y ) {\n\n\t\t// Constrain initial position to window bounds\n\t\tconst windowWidth = window.innerWidth;\n\t\tconst windowHeight = window.innerHeight;\n\t\tconst estimatedWidth = 400; // Default detached window width\n\t\tconst estimatedHeight = 300; // Default detached window height\n\n\t\tlet constrainedX = x - 200;\n\t\tlet constrainedY = y - 20;\n\n\t\tif ( constrainedX + estimatedWidth > windowWidth ) {\n\n\t\t\tconstrainedX = windowWidth - estimatedWidth;\n\n\t\t}\n\n\t\tif ( constrainedX < 0 ) {\n\n\t\t\tconstrainedX = 0;\n\n\t\t}\n\n\t\tif ( constrainedY + estimatedHeight > windowHeight ) {\n\n\t\t\tconstrainedY = windowHeight - estimatedHeight;\n\n\t\t}\n\n\t\tif ( constrainedY < 0 ) {\n\n\t\t\tconstrainedY = 0;\n\n\t\t}\n\n\t\tconst windowPanel = document.createElement( 'div' );\n\t\twindowPanel.className = 'detached-tab-panel';\n\t\twindowPanel.style.left = `${ constrainedX }px`;\n\t\twindowPanel.style.top = `${ constrainedY }px`;\n\n\n\n\t\t// Hide detached window if tab is not visible\n\t\tif ( ! tab.isVisible ) {\n\n\t\t\twindowPanel.style.display = 'none';\n\n\t\t}\n\n\t\tconst windowHeader = document.createElement( 'div' );\n\t\twindowHeader.className = 'detached-tab-header';\n\n\t\tconst title = document.createElement( 'span' );\n\t\ttitle.textContent = tab.button.textContent.replace( '⇱', '' ).trim();\n\t\twindowHeader.appendChild( title );\n\n\t\tconst headerControls = document.createElement( 'div' );\n\t\theaderControls.className = 'detached-header-controls';\n\n\t\tconst reattachBtn = document.createElement( 'button' );\n\t\treattachBtn.className = 'detached-reattach-btn';\n\t\treattachBtn.innerHTML = '↩';\n\t\treattachBtn.title = 'Reattach to main panel';\n\t\treattachBtn.onclick = () => this.reattachTab( tab );\n\n\t\theaderControls.appendChild( reattachBtn );\n\t\twindowHeader.appendChild( headerControls );\n\n\t\tconst windowContent = document.createElement( 'div' );\n\t\twindowContent.className = 'detached-tab-content';\n\t\twindowContent.appendChild( tab.content );\n\n\t\t// Make sure content is visible\n\t\ttab.content.style.display = 'block';\n\t\ttab.content.classList.add( 'active' );\n\n\t\t// Create resize handles for all edges\n\t\tconst resizerTop = document.createElement( 'div' );\n\t\tresizerTop.className = 'detached-tab-resizer-top';\n\n\t\tconst resizerRight = document.createElement( 'div' );\n\t\tresizerRight.className = 'detached-tab-resizer-right';\n\n\t\tconst resizerBottom = document.createElement( 'div' );\n\t\tresizerBottom.className = 'detached-tab-resizer-bottom';\n\n\t\tconst resizerLeft = document.createElement( 'div' );\n\t\tresizerLeft.className = 'detached-tab-resizer-left';\n\n\t\tconst resizerCorner = document.createElement( 'div' );\n\t\tresizerCorner.className = 'detached-tab-resizer';\n\n\t\twindowPanel.appendChild( resizerTop );\n\t\twindowPanel.appendChild( resizerRight );\n\t\twindowPanel.appendChild( resizerBottom );\n\t\twindowPanel.appendChild( resizerLeft );\n\t\twindowPanel.appendChild( resizerCorner );\n\t\twindowPanel.appendChild( windowHeader );\n\t\twindowPanel.appendChild( windowContent );\n\n\t\tthis.domElement.appendChild( windowPanel );\n\n\t\t// Setup window dragging\n\t\tthis.setupDetachedWindowDrag( windowPanel, windowHeader, tab );\n\n\t\t// Setup window resizing\n\t\tthis.setupDetachedWindowResize( windowPanel, resizerTop, resizerRight, resizerBottom, resizerLeft, resizerCorner );\n\n\t\t// Use the same z-index that was set on the preview window\n\t\twindowPanel.style.setProperty( 'z-index', this.maxZIndex, 'important' );\n\n\t\treturn { panel: windowPanel, tab: tab };\n\n\t}\n\n\tbringWindowToFront( windowPanel ) {\n\n\t\t// Increment the max z-index and apply it to the clicked window\n\t\tthis.maxZIndex ++;\n\t\twindowPanel.style.setProperty( 'z-index', this.maxZIndex, 'important' );\n\n\t}\n\n\tsetupDetachedWindowDrag( windowPanel, header, tab ) {\n\n\t\tlet isDragging = false;\n\t\tlet startX, startY, startLeft, startTop;\n\n\t\t// Bring window to front when clicking anywhere on it\n\t\twindowPanel.addEventListener( 'pointerdown', () => {\n\n\t\t\tthis.bringWindowToFront( windowPanel );\n\n\t\t} );\n\n\t\tconst onDragStart = ( e ) => {\n\n\t\t\tif ( e.target.classList.contains( 'detached-reattach-btn' ) ) {\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\t// Bring window to front when starting to drag\n\t\t\tthis.bringWindowToFront( windowPanel );\n\n\t\t\tisDragging = true;\n\t\t\theader.style.cursor = 'grabbing';\n\t\t\theader.setPointerCapture( e.pointerId );\n\n\t\t\tstartX = e.clientX;\n\t\t\tstartY = e.clientY;\n\n\t\t\tconst rect = windowPanel.getBoundingClientRect();\n\t\t\tstartLeft = rect.left;\n\t\t\tstartTop = rect.top;\n\n\t\t};\n\n\t\tconst onDragMove = ( e ) => {\n\n\t\t\tif ( ! isDragging ) return;\n\n\t\t\te.preventDefault();\n\n\t\t\tconst currentX = e.clientX;\n\t\t\tconst currentY = e.clientY;\n\n\t\t\tconst deltaX = currentX - startX;\n\t\t\tconst deltaY = currentY - startY;\n\n\t\t\tlet newLeft = startLeft + deltaX;\n\t\t\tlet newTop = startTop + deltaY;\n\n\t\t\t// Constrain to window bounds (allow half width/height to extend outside)\n\t\t\tconst windowWidth = window.innerWidth;\n\t\t\tconst windowHeight = window.innerHeight;\n\t\t\tconst panelWidth = windowPanel.offsetWidth;\n\t\t\tconst panelHeight = windowPanel.offsetHeight;\n\t\t\tconst halfWidth = panelWidth / 2;\n\t\t\tconst halfHeight = panelHeight / 2;\n\n\t\t\t// Allow window to extend half its width beyond right edge\n\t\t\tif ( newLeft + panelWidth > windowWidth + halfWidth ) {\n\n\t\t\t\tnewLeft = windowWidth + halfWidth - panelWidth;\n\n\t\t\t}\n\n\t\t\t// Allow window to extend half its width beyond left edge\n\t\t\tif ( newLeft < - halfWidth ) {\n\n\t\t\t\tnewLeft = - halfWidth;\n\n\t\t\t}\n\n\t\t\t// Allow window to extend half its height beyond bottom edge\n\t\t\tif ( newTop + panelHeight > windowHeight + halfHeight ) {\n\n\t\t\t\tnewTop = windowHeight + halfHeight - panelHeight;\n\n\t\t\t}\n\n\t\t\t// Allow window to extend half its height beyond top edge\n\t\t\tif ( newTop < - halfHeight ) {\n\n\t\t\t\tnewTop = - halfHeight;\n\n\t\t\t}\n\n\t\t\twindowPanel.style.left = `${ newLeft }px`;\n\t\t\twindowPanel.style.top = `${ newTop }px`;\n\n\t\t\t// Check if cursor is over the inspector panel\n\t\t\tconst panelRect = this.panel.getBoundingClientRect();\n\t\t\tconst isOverPanel = currentX >= panelRect.left && currentX <= panelRect.right &&\n\t\t\t\t\t\t\t\tcurrentY >= panelRect.top && currentY <= panelRect.bottom;\n\n\t\t\tif ( isOverPanel ) {\n\n\t\t\t\twindowPanel.style.opacity = '0.5';\n\t\t\t\tthis.panel.style.outline = '2px solid var(--accent-color)';\n\n\t\t\t} else {\n\n\t\t\t\twindowPanel.style.opacity = '';\n\t\t\t\tthis.panel.style.outline = '';\n\n\t\t\t}\n\n\t\t};\n\n\t\tconst onDragEnd = ( e ) => {\n\n\t\t\tif ( ! isDragging ) return;\n\n\t\t\tisDragging = false;\n\t\t\theader.style.cursor = '';\n\t\t\twindowPanel.style.opacity = '';\n\t\t\tthis.panel.style.outline = '';\n\n\t\t\t// Check if dropped over the inspector panel\n\t\t\tconst currentX = e.clientX;\n\t\t\tconst currentY = e.clientY;\n\n\t\t\tif ( currentX !== undefined && currentY !== undefined ) {\n\n\t\t\t\tconst panelRect = this.panel.getBoundingClientRect();\n\t\t\t\tconst isOverPanel = currentX >= panelRect.left && currentX <= panelRect.right &&\n\t\t\t\t\t\t\t\t\tcurrentY >= panelRect.top && currentY <= panelRect.bottom;\n\n\t\t\t\tif ( isOverPanel && tab ) {\n\n\t\t\t\t\t// Reattach the tab\n\t\t\t\t\tthis.reattachTab( tab );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// Save layout after moving detached window\n\t\t\t\t\tthis.saveLayout();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\theader.removeEventListener( 'pointermove', onDragMove );\n\t\t\theader.removeEventListener( 'pointerup', onDragEnd );\n\t\t\theader.removeEventListener( 'pointercancel', onDragEnd );\n\n\t\t};\n\n\t\theader.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\tonDragStart( e );\n\t\t\theader.addEventListener( 'pointermove', onDragMove );\n\t\t\theader.addEventListener( 'pointerup', onDragEnd );\n\t\t\theader.addEventListener( 'pointercancel', onDragEnd );\n\n\t\t} );\n\n\t\theader.style.cursor = 'grab';\n\n\t}\n\n\tsetupDetachedWindowResize( windowPanel, resizerTop, resizerRight, resizerBottom, resizerLeft, resizerCorner ) {\n\n\t\tconst minWidth = 250;\n\t\tconst minHeight = 150;\n\n\t\tconst setupResizer = ( resizer, direction ) => {\n\n\t\t\tlet isResizing = false;\n\t\t\tlet startX, startY, startWidth, startHeight, startLeft, startTop;\n\n\t\t\tconst onResizeStart = ( e ) => {\n\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tisResizing = true;\n\n\t\t\t\t// Bring window to front when resizing\n\t\t\t\tthis.bringWindowToFront( windowPanel );\n\n\t\t\t\tresizer.setPointerCapture( e.pointerId );\n\n\t\t\t\tstartX = e.clientX;\n\t\t\t\tstartY = e.clientY;\n\t\t\t\tstartWidth = windowPanel.offsetWidth;\n\t\t\t\tstartHeight = windowPanel.offsetHeight;\n\t\t\t\tstartLeft = windowPanel.offsetLeft;\n\t\t\t\tstartTop = windowPanel.offsetTop;\n\n\t\t\t};\n\n\t\t\tconst onResizeMove = ( e ) => {\n\n\t\t\t\tif ( ! isResizing ) return;\n\n\t\t\t\te.preventDefault();\n\n\t\t\t\tconst currentX = e.clientX;\n\t\t\t\tconst currentY = e.clientY;\n\n\t\t\t\tconst deltaX = currentX - startX;\n\t\t\t\tconst deltaY = currentY - startY;\n\n\t\t\t\tconst windowWidth = window.innerWidth;\n\t\t\t\tconst windowHeight = window.innerHeight;\n\n\t\t\t\tif ( direction === 'right' || direction === 'corner' ) {\n\n\t\t\t\t\tconst newWidth = startWidth + deltaX;\n\t\t\t\t\tconst maxWidth = windowWidth - startLeft;\n\n\t\t\t\t\tif ( newWidth >= minWidth && newWidth <= maxWidth ) {\n\n\t\t\t\t\t\twindowPanel.style.width = `${ newWidth }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( direction === 'bottom' || direction === 'corner' ) {\n\n\t\t\t\t\tconst newHeight = startHeight + deltaY;\n\t\t\t\t\tconst maxHeight = windowHeight - startTop;\n\n\t\t\t\t\tif ( newHeight >= minHeight && newHeight <= maxHeight ) {\n\n\t\t\t\t\t\twindowPanel.style.height = `${ newHeight }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( direction === 'left' ) {\n\n\t\t\t\t\tconst newWidth = startWidth - deltaX;\n\t\t\t\t\tconst maxLeft = startLeft + startWidth - minWidth;\n\n\t\t\t\t\tif ( newWidth >= minWidth ) {\n\n\t\t\t\t\t\tconst newLeft = startLeft + deltaX;\n\n\t\t\t\t\t\tif ( newLeft >= 0 && newLeft <= maxLeft ) {\n\n\t\t\t\t\t\t\twindowPanel.style.width = `${ newWidth }px`;\n\t\t\t\t\t\t\twindowPanel.style.left = `${ newLeft }px`;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( direction === 'top' ) {\n\n\t\t\t\t\tconst newHeight = startHeight - deltaY;\n\t\t\t\t\tconst maxTop = startTop + startHeight - minHeight;\n\n\t\t\t\t\tif ( newHeight >= minHeight ) {\n\n\t\t\t\t\t\tconst newTop = startTop + deltaY;\n\n\t\t\t\t\t\tif ( newTop >= 0 && newTop <= maxTop ) {\n\n\t\t\t\t\t\t\twindowPanel.style.height = `${ newHeight }px`;\n\t\t\t\t\t\t\twindowPanel.style.top = `${ newTop }px`;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis.dispatchEvent( { type: 'resize' } );\n\n\t\t\t};\n\n\t\t\tconst onResizeEnd = () => {\n\n\t\t\t\tisResizing = false;\n\n\t\t\t\tresizer.removeEventListener( 'pointermove', onResizeMove );\n\t\t\t\tresizer.removeEventListener( 'pointerup', onResizeEnd );\n\t\t\t\tresizer.removeEventListener( 'pointercancel', onResizeEnd );\n\n\t\t\t\t// Save layout after resizing detached window\n\t\t\t\tthis.saveLayout();\n\n\t\t\t};\n\n\t\t\tresizer.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\t\tonResizeStart( e );\n\t\t\t\tresizer.addEventListener( 'pointermove', onResizeMove );\n\t\t\t\tresizer.addEventListener( 'pointerup', onResizeEnd );\n\t\t\t\tresizer.addEventListener( 'pointercancel', onResizeEnd );\n\n\t\t\t} );\n\n\t\t};\n\n\t\t// Setup all resizers\n\t\tsetupResizer( resizerTop, 'top' );\n\t\tsetupResizer( resizerRight, 'right' );\n\t\tsetupResizer( resizerBottom, 'bottom' );\n\t\tsetupResizer( resizerLeft, 'left' );\n\t\tsetupResizer( resizerCorner, 'corner' );\n\n\t}\n\n\treattachTab( tab ) {\n\n\t\tif ( ! tab.isDetached ) return;\n\n\t\tif ( tab.detachedWindow ) {\n\n\t\t\tconst index = this.detachedWindows.indexOf( tab.detachedWindow );\n\n\t\t\tif ( index > - 1 ) {\n\n\t\t\t\tthis.detachedWindows.splice( index, 1 );\n\n\t\t\t}\n\n\t\t\tif ( tab.detachedWindow.panel.parentNode ) {\n\n\t\t\t\ttab.detachedWindow.panel.parentNode.removeChild( tab.detachedWindow.panel );\n\n\t\t\t}\n\n\t\t\ttab.detachedWindow = null;\n\n\t\t}\n\n\t\ttab.isDetached = false;\n\n\t\t// Get all tabs and sort by their original index to determine the correct order\n\t\tconst allTabs = Object.values( this.tabs );\n\t\tconst allTabsSorted = allTabs\n\t\t\t.filter( t => t.originalIndex !== undefined && t.isVisible )\n\t\t\t.sort( ( a, b ) => a.originalIndex - b.originalIndex );\n\n\t\t// Get currently attached tab buttons\n\t\tconst currentButtons = Array.from( this.tabsContainer.children );\n\n\t\t// Find the correct position for this tab\n\t\tlet insertIndex = 0;\n\t\tfor ( const t of allTabsSorted ) {\n\n\t\t\tif ( t.id === tab.id ) {\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\t// Count only non-detached, non-builtin tabs that come before this one\n\t\t\tif ( ! t.isDetached && ! t.builtin ) {\n\n\t\t\t\tinsertIndex ++;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Insert the button at the correct position\n\t\tif ( insertIndex >= currentButtons.length || currentButtons.length === 0 ) {\n\n\t\t\t// If insert index is beyond current buttons, or no buttons exist, append at the end\n\t\t\tthis.tabsContainer.appendChild( tab.button );\n\n\t\t} else {\n\n\t\t\t// Insert before the button at the insert index\n\t\t\tthis.tabsContainer.insertBefore( tab.button, currentButtons[ insertIndex ] );\n\n\t\t}\n\n\t\tthis.contentWrapper.appendChild( tab.content );\n\n\t\tthis.setActiveTab( tab.id );\n\n\t\t// Update panel size after reattaching\n\t\tthis.updatePanelSize();\n\n\t\tthis.saveLayout();\n\n\t}\n\n\tsetActiveTab( id ) {\n\n\t\tif ( this.activeTabId && this.tabs[ this.activeTabId ] && ! this.tabs[ this.activeTabId ].isDetached ) {\n\n\t\t\tthis.tabs[ this.activeTabId ].setActive( false );\n\n\t\t}\n\n\t\tthis.activeTabId = id;\n\n\t\tif ( this.tabs[ id ] ) {\n\n\t\t\tconst tab = this.tabs[ id ];\n\n\t\t\tif ( ! tab.isVisible ) {\n\n\t\t\t\ttab.show();\n\n\t\t\t}\n\n\t\t\ttab.setActive( true );\n\n\t\t}\n\n\t\tthis.saveLayout();\n\t\tthis.checkHeaderScroll();\n\n\t}\n\n\ttogglePanel() {\n\n\t\tthis.panel.classList.toggle( 'visible' );\n\t\tthis.toggleButton.classList.toggle( 'panel-open' );\n\t\tthis.miniPanel.classList.toggle( 'panel-open' );\n\n\t\tconst isVisible = this.panel.classList.contains( 'visible' );\n\n\t\tif ( isVisible && this.activeTabId && this.tabs[ this.activeTabId ] ) {\n\n\t\t\tthis.tabs[ this.activeTabId ].setActive( true );\n\n\t\t}\n\n\t\tthis.updateWidgetPosition();\n\n\t\tthis.dispatchEvent( { type: 'resize' } );\n\n\t\tthis.saveLayout();\n\n\t}\n\n\ttogglePosition() {\n\n\t\tconst newPosition = this.position === 'bottom' ? 'right' : 'bottom';\n\t\tthis.setPosition( newPosition );\n\n\t}\n\n\tsetPosition( targetPosition ) {\n\n\t\tif ( this.position === targetPosition ) return;\n\n\t\tthis.panel.style.transition = 'none';\n\n\t\t// Check if panel is currently maximized\n\t\tconst isMaximized = this.panel.classList.contains( 'maximized' );\n\n\t\tif ( targetPosition === 'right' ) {\n\n\t\t\tthis.position = 'right';\n\t\t\tthis.floatingBtn.classList.add( 'active' );\n\t\t\tthis.floatingBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><path d=\"M3 15h18\"></path></svg>';\n\t\t\tthis.floatingBtn.title = 'Switch to Bottom';\n\n\t\t\t// Apply right position styles\n\t\t\tthis.panel.classList.remove( 'position-bottom' );\n\t\t\tthis.panel.classList.add( 'position-right' );\n\t\t\tthis.panel.style.bottom = '';\n\t\t\tthis.panel.style.top = '0';\n\t\t\tthis.panel.style.right = '0';\n\t\t\tthis.panel.style.left = '';\n\n\t\t\t// Apply size based on maximized state\n\t\t\tif ( isMaximized ) {\n\n\t\t\t\tthis.panel.style.width = '100%';\n\t\t\t\tthis.panel.style.height = '100%';\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.style.width = `${ this.lastWidthRight }px`;\n\t\t\t\tthis.panel.style.height = '100%';\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.position = 'bottom';\n\t\t\tthis.floatingBtn.classList.remove( 'active' );\n\t\t\tthis.floatingBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><line x1=\"15\" y1=\"3\" x2=\"15\" y2=\"21\"></line></svg>';\n\t\t\tthis.floatingBtn.title = 'Switch to Right Side';\n\n\t\t\t// Apply bottom position styles\n\t\t\tthis.panel.classList.remove( 'position-right' );\n\t\t\tthis.panel.classList.add( 'position-bottom' );\n\t\t\tthis.panel.style.top = '';\n\t\t\tthis.panel.style.right = '';\n\t\t\tthis.panel.style.bottom = '0';\n\t\t\tthis.panel.style.left = '0';\n\n\t\t\t// Apply size based on maximized state\n\t\t\tif ( isMaximized ) {\n\n\t\t\t\tthis.panel.style.width = '100%';\n\t\t\t\tthis.panel.style.height = '100%';\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.style.width = '100%';\n\t\t\t\tthis.panel.style.height = `${ this.lastHeightBottom }px`;\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.updateWidgetPosition();\n\n\t\t// Re-enable transition after a brief delay\n\t\tsetTimeout( () => {\n\n\t\t\tthis.panel.style.transition = '';\n\n\t\t}, 50 );\n\n\t\t// Update panel size based on visible tabs\n\t\tthis.updatePanelSize();\n\n\t\t// Save layout after position change\n\t\tthis.saveLayout();\n\n\t}\n\n\tsaveLayout() {\n\n\t\tif ( this.isLoadingLayout ) return;\n\n\t\tconst layout = {\n\t\t\tposition: this.position,\n\t\t\tlastHeightBottom: this.lastHeightBottom,\n\t\t\tlastWidthRight: this.lastWidthRight,\n\t\t\tactiveTabId: this.activeTabId,\n\t\t\tdetachedTabs: [],\n\t\t\tisVisible: this.panel.classList.contains( 'visible' )\n\t\t};\n\n\t\t// Save detached windows state\n\t\tthis.detachedWindows.forEach( detachedWindow => {\n\n\t\t\tconst tab = detachedWindow.tab;\n\t\t\tconst panel = detachedWindow.panel;\n\n\t\t\t// Get position values, ensuring they're valid numbers\n\t\t\tconst left = parseFloat( panel.style.left ) || panel.offsetLeft || 0;\n\t\t\tconst top = parseFloat( panel.style.top ) || panel.offsetTop || 0;\n\t\t\tconst width = panel.offsetWidth;\n\t\t\tconst height = panel.offsetHeight;\n\n\t\t\tlayout.detachedTabs.push( {\n\t\t\t\ttabId: tab.id,\n\t\t\t\toriginalIndex: tab.originalIndex !== undefined ? tab.originalIndex : 0,\n\t\t\t\tleft: left,\n\t\t\t\ttop: top,\n\t\t\t\twidth: width,\n\t\t\t\theight: height\n\t\t\t} );\n\n\t\t} );\n\n\t\ttry {\n\n\t\t\tsetItem( 'layout', layout );\n\n\t\t} catch ( e ) {\n\n\t\t\tconsole.warn( 'Failed to save profiler layout:', e );\n\n\t\t}\n\n\t}\n\n\tloadLayout() {\n\n\t\tthis.isLoadingLayout = true;\n\n\t\ttry {\n\n\t\t\tconst layout = getItem( 'layout' );\n\n\t\t\tif ( Object.keys( layout ).length === 0 ) return;\n\n\t\t\t// Constrain detached tabs positions to current screen bounds\n\t\t\tif ( layout.detachedTabs && layout.detachedTabs.length > 0 ) {\n\n\t\t\t\tconst windowWidth = window.innerWidth;\n\t\t\t\tconst windowHeight = window.innerHeight;\n\n\t\t\t\tlayout.detachedTabs = layout.detachedTabs.map( detachedTabData => {\n\n\t\t\t\t\tlet { left, top, width, height } = detachedTabData;\n\n\t\t\t\t\t// Ensure width and height are within bounds\n\t\t\t\t\tif ( width > windowWidth ) {\n\n\t\t\t\t\t\twidth = windowWidth - 100; // Leave some margin\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( height > windowHeight ) {\n\n\t\t\t\t\t\theight = windowHeight - 100; // Leave some margin\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Allow window to extend half its width/height outside the screen\n\t\t\t\t\tconst halfWidth = width / 2;\n\t\t\t\t\tconst halfHeight = height / 2;\n\n\t\t\t\t\t// Constrain horizontal position (allow half width to extend beyond right edge)\n\t\t\t\t\tif ( left + width > windowWidth + halfWidth ) {\n\n\t\t\t\t\t\tleft = windowWidth + halfWidth - width;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Constrain horizontal position (allow half width to extend beyond left edge)\n\t\t\t\t\tif ( left < - halfWidth ) {\n\n\t\t\t\t\t\tleft = - halfWidth;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Constrain vertical position (allow half height to extend beyond bottom edge)\n\t\t\t\t\tif ( top + height > windowHeight + halfHeight ) {\n\n\t\t\t\t\t\ttop = windowHeight + halfHeight - height;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Constrain vertical position (allow half height to extend beyond top edge)\n\t\t\t\t\tif ( top < - halfHeight ) {\n\n\t\t\t\t\t\ttop = - halfHeight;\n\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...detachedTabData,\n\t\t\t\t\t\tleft,\n\t\t\t\t\t\ttop,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\theight\n\t\t\t\t\t};\n\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t\t// Restore position and dimensions\n\t\t\tif ( layout.position ) {\n\n\t\t\t\tthis.position = layout.position;\n\n\t\t\t}\n\n\t\t\tif ( layout.lastHeightBottom ) {\n\n\t\t\t\tthis.lastHeightBottom = layout.lastHeightBottom;\n\n\t\t\t}\n\n\t\t\tif ( layout.lastWidthRight ) {\n\n\t\t\t\tthis.lastWidthRight = layout.lastWidthRight;\n\n\t\t\t}\n\n\t\t\t// Constrain saved dimensions to current screen bounds\n\t\t\tconst windowWidth = window.innerWidth;\n\t\t\tconst windowHeight = window.innerHeight;\n\n\t\t\tif ( this.lastHeightBottom > windowHeight - 50 ) {\n\n\t\t\t\tthis.lastHeightBottom = windowHeight - 50;\n\n\t\t\t}\n\n\t\t\tif ( this.lastWidthRight > windowWidth - 50 ) {\n\n\t\t\t\tthis.lastWidthRight = windowWidth - 50;\n\n\t\t\t}\n\n\t\t\t// Apply the saved position after shell is set up\n\t\t\tif ( this.position === 'right' ) {\n\n\t\t\t\tthis.floatingBtn.classList.add( 'active' );\n\t\t\t\tthis.floatingBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><path d=\"M3 15h18\"></path></svg>';\n\t\t\t\tthis.floatingBtn.title = 'Switch to Bottom';\n\n\t\t\t\tthis.panel.classList.remove( 'position-bottom' );\n\t\t\t\tthis.panel.classList.add( 'position-right' );\n\t\t\t\tthis.toggleButton.classList.add( 'position-right' );\n\t\t\t\tthis.miniPanel.classList.add( 'position-right' );\n\t\t\t\tthis.panel.style.bottom = '';\n\t\t\t\tthis.panel.style.top = '0';\n\t\t\t\tthis.panel.style.right = '0';\n\t\t\t\tthis.panel.style.left = '';\n\t\t\t\tthis.panel.style.width = `${ this.lastWidthRight }px`;\n\t\t\t\tthis.panel.style.height = '100%';\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.style.height = `${ this.lastHeightBottom }px`;\n\n\t\t\t}\n\n\t\t\tif ( layout.isVisible ) {\n\n\t\t\t\tthis.panel.classList.add( 'visible' );\n\t\t\t\tthis.toggleButton.classList.add( 'panel-open' );\n\n\t\t\t}\n\n\t\t\tif ( layout.activeTabId ) {\n\n\t\t\t\tthis.setActiveTab( layout.activeTabId );\n\n\t\t\t}\n\n\t\t\tif ( layout.detachedTabs && layout.detachedTabs.length > 0 ) {\n\n\t\t\t\tthis.pendingDetachedTabs = layout.detachedTabs;\n\t\t\t\tthis.restoreDetachedTabs();\n\n\t\t\t}\n\n\t\t\t// Update panel size after loading layout\n\t\t\tthis.updatePanelSize();\n\n\t\t\t// Update widget position (toggle and mini panel alignment)\n\t\t\tthis.updateWidgetPosition();\n\n\t\t\t// Ensure initial open state applies to mini panel as well\n\t\t\tif ( this.panel.classList.contains( 'visible' ) ) {\n\n\t\t\t\tthis.miniPanel.classList.add( 'panel-open' );\n\n\t\t\t}\n\n\t\t} catch ( e ) {\n\n\t\t\tconsole.warn( 'Failed to load profiler layout:', e );\n\n\t\t} finally {\n\n\t\t\tthis.isLoadingLayout = false;\n\n\t\t}\n\n\t}\n\n\trestoreDetachedTabs() {\n\n\t\tif ( ! this.pendingDetachedTabs || this.pendingDetachedTabs.length === 0 ) return;\n\n\t\tthis.pendingDetachedTabs.forEach( detachedTabData => {\n\n\t\t\tconst tab = this.tabs[ detachedTabData.tabId ];\n\n\t\t\tif ( ! tab || tab.isDetached ) return;\n\n\t\t\t// Restore originalIndex if saved\n\t\t\tif ( detachedTabData.originalIndex !== undefined ) {\n\n\t\t\t\ttab.originalIndex = detachedTabData.originalIndex;\n\n\t\t\t}\n\n\t\t\tif ( tab.button.parentNode ) {\n\n\t\t\t\ttab.button.parentNode.removeChild( tab.button );\n\n\t\t\t}\n\n\t\t\tif ( tab.content.parentNode ) {\n\n\t\t\t\ttab.content.parentNode.removeChild( tab.content );\n\n\t\t\t}\n\n\t\t\tconst detachedWindow = this.createDetachedWindow( tab, 0, 0 );\n\n\t\t\tdetachedWindow.panel.style.left = `${ detachedTabData.left }px`;\n\t\t\tdetachedWindow.panel.style.top = `${ detachedTabData.top }px`;\n\t\t\tdetachedWindow.panel.style.width = `${ detachedTabData.width }px`;\n\t\t\tdetachedWindow.panel.style.height = `${ detachedTabData.height }px`;\n\n\t\t\t// Constrain window to bounds after restoring position and size\n\t\t\tthis.constrainWindowToBounds( detachedWindow.panel );\n\n\t\t\tthis.detachedWindows.push( detachedWindow );\n\n\t\t\ttab.isDetached = true;\n\t\t\ttab.detachedWindow = detachedWindow;\n\n\t\t} );\n\n\t\tthis.pendingDetachedTabs = null;\n\n\t\t// Update maxZIndex to be higher than all existing windows\n\t\tthis.detachedWindows.forEach( detachedWindow => {\n\n\t\t\tconst currentZIndex = parseInt( getComputedStyle( detachedWindow.panel ).zIndex ) || 0;\n\t\t\tif ( currentZIndex > this.maxZIndex ) {\n\n\t\t\t\tthis.maxZIndex = currentZIndex;\n\n\t\t\t}\n\n\t\t} );\n\n\t\tconst needsNewActiveTab = ! this.activeTabId ||\n\t\t\t! this.tabs[ this.activeTabId ] ||\n\t\t\tthis.tabs[ this.activeTabId ].isDetached ||\n\t\t\t! this.tabs[ this.activeTabId ].isVisible;\n\n\t\tif ( needsNewActiveTab ) {\n\n\t\t\tconst tabIds = Object.keys( this.tabs );\n\t\t\tconst availableTabs = tabIds.filter( id =>\n\t\t\t\t! this.tabs[ id ].isDetached &&\n\t\t\t\tthis.tabs[ id ].isVisible\n\t\t\t);\n\n\t\t\tif ( availableTabs.length > 0 ) {\n\n\t\t\t\tconst buttons = Array.from( this.tabsContainer.children );\n\t\t\t\tconst orderedTabIds = buttons.map( btn => {\n\n\t\t\t\t\treturn Object.keys( this.tabs ).find( id => this.tabs[ id ].button === btn );\n\n\t\t\t\t} ).filter( id =>\n\t\t\t\t\tid !== undefined &&\n\t\t\t\t\t! this.tabs[ id ].isDetached &&\n\t\t\t\t\tthis.tabs[ id ].isVisible\n\t\t\t\t);\n\n\t\t\t\tthis.setActiveTab( orderedTabIds[ 0 ] || availableTabs[ 0 ] );\n\n\t\t\t} else {\n\n\t\t\t\tthis.activeTabId = null;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Update panel size after restoring detached tabs\n\t\tthis.updatePanelSize();\n\n\t}\n\n\tsetHorizontalAlign( value ) {\n\n\t\tthis.horizontalAlign = value;\n\t\tthis.updateWidgetPosition();\n\n\t\treturn this;\n\n\t}\n\n\tsetVerticalAlign( value ) {\n\n\t\tthis.verticalAlign = value;\n\t\tthis.updateWidgetPosition();\n\n\t\treturn this;\n\n\t}\n\n\tupdateWidgetPosition() {\n\n\t\tconst isVisible = this.panel.classList.contains( 'visible' );\n\t\tconst isMaximized = this.panel.classList.contains( 'maximized' );\n\t\tconst isRight = this.position === 'right';\n\n\t\tlet horizontal = this.horizontalAlign; // 'left' or 'right'\n\t\tlet vertical = this.verticalAlign; // 'top' or 'bottom'\n\n\t\tif ( isVisible ) {\n\n\t\t\tif ( isRight ) {\n\n\t\t\t\t// If panel is open on the right:\n\t\t\t\t// Toggle should be on the opposite side of 'right' if default is 'right' to avoid overlapping the panel.\n\t\t\t\tif ( this.horizontalAlign === 'right' ) {\n\n\t\t\t\t\thorizontal = 'left';\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// If panel is open at the bottom:\n\t\t\t\tif ( ! isMaximized ) {\n\n\t\t\t\t\t// If default is bottom, we must move to top to avoid overlapping the panel at the bottom.\n\t\t\t\t\tif ( this.verticalAlign === 'bottom' ) {\n\n\t\t\t\t\t\tvertical = 'top';\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// If maximized, move to the opposite vertical position to avoid overlap with header/tabs.\n\t\t\t\t\tvertical = this.verticalAlign === 'top' ? 'bottom' : 'top';\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Apply horizontal class\n\t\tif ( horizontal === 'left' ) {\n\n\t\t\tthis.toggleButton.classList.add( 'toggle-left' );\n\t\t\tthis.miniPanel.classList.add( 'toggle-left' );\n\n\t\t} else {\n\n\t\t\tthis.toggleButton.classList.remove( 'toggle-left' );\n\t\t\tthis.miniPanel.classList.remove( 'toggle-left' );\n\n\t\t}\n\n\t\t// Apply vertical class\n\t\tif ( vertical === 'bottom' ) {\n\n\t\t\tthis.toggleButton.classList.add( 'toggle-bottom' );\n\t\t\tthis.miniPanel.classList.add( 'toggle-bottom' );\n\n\t\t} else {\n\n\t\t\tthis.toggleButton.classList.remove( 'toggle-bottom' );\n\t\t\tthis.miniPanel.classList.remove( 'toggle-bottom' );\n\n\t\t}\n\n\t\tthis.notifyLayoutChange();\n\n\t}\n\n\tisVertical() {\n\n\t\treturn this.position === 'left' || this.position === 'right' ||\n\t\t\t( this.panel && ( this.panel.classList.contains( 'position-left' ) || this.panel.classList.contains( 'position-right' ) ) );\n\n\t}\n\n\tnotifyLayoutChange() {\n\n\t\tconst isVert = this.isVertical();\n\n\t\tthis.dispatchEvent( { type: 'orientationchange', position: this.position, isVertical: isVert } );\n\t\tthis.dispatchEvent( { type: 'layoutchange', position: this.position, isVertical: isVert } );\n\n\t}\n\n\tdispose() {\n\n\t\tfor ( const tab of Object.values( this.tabs ) ) {\n\n\t\t\ttab.dispose();\n\n\t\t}\n\n\t\tthis.domElement.remove();\n\n\t\tfor ( const detachedWindow of this.detachedWindows ) {\n\n\t\t\tdetachedWindow.panel.remove();\n\n\t\t}\n\n\t\tthis.toggleGraph.dispose();\n\n\t}\n\n}\n","import { EventDispatcher } from 'three';\n\n/**\n * Tab class\n * @param {string} title - The title of the tab\n * @param {Object} options - Options for the tab\n * @param {boolean} [options.allowDetach=true] - Whether the tab can be detached into a separate window\n * @param {boolean} [options.builtin=false] - Whether the tab should appear in the profiler-toggle button\n * @param {string} [options.icon] - SVG icon HTML for the builtin button\n *\n * @example\n * // Create a tab that can be detached (default behavior)\n * const tab1 = new Tab('My Tab');\n *\n * // Create a tab that cannot be detached\n * const tab2 = new Tab('Fixed Tab', { allowDetach: false });\n *\n * // Create a builtin tab that appears in the profiler-toggle\n * const tab3 = new Tab('Builtin Tab', { builtin: true });\n *\n * // Create a builtin tab with custom icon\n * const tab4 = new Tab('Settings', { builtin: true, icon: '<svg>...</svg>' });\n *\n * // Control builtin tab visibility\n * tab3.showBuiltin(); // Show the builtin button and mini-content\n * tab3.hideBuiltin(); // Hide the builtin button and mini-content\n */\nexport class Tab extends EventDispatcher {\n\n\tconstructor( title, options = {} ) {\n\n\t\tsuper();\n\n\t\tthis.id = title.toLowerCase().replace( /\\s+/g, '-' );\n\t\tthis.button = document.createElement( 'button' );\n\t\tthis.button.className = 'tab-btn';\n\t\tthis.button.textContent = title;\n\n\t\tthis.content = document.createElement( 'div' );\n\t\tthis.content.className = 'profiler-content';\n\t\tthis.content.classList.add( `${this.id}-content` );\n\n\t\tthis._isActive = false;\n\t\tthis.isVisible = true;\n\t\tthis.isDetached = false;\n\t\tthis.detachedWindow = null;\n\t\tthis.allowDetach = options.allowDetach !== undefined ? options.allowDetach : true;\n\t\tthis.builtin = options.builtin !== undefined ? options.builtin : false;\n\t\tthis.icon = options.icon || null;\n\t\tthis.builtinButton = null; // Reference to the builtin button in profiler-toggle\n\t\tthis.miniContent = null; // Reference to the mini-panel content container\n\t\tthis.profiler = null; // Reference to the profiler instance\n\t\tthis.onVisibilityChange = null; // Callback for visibility changes\n\n\t}\n\n\tget inspector() {\n\n\t\treturn this.profiler.inspector;\n\n\t}\n\n\tget isActive() {\n\n\t\tif ( this.isDetached && this.isVisible ) return true;\n\n\t\tconst isProfilerVisible = this.profiler && this.profiler.panel.classList.contains( 'visible' );\n\n\t\tif ( ! isProfilerVisible ) return false;\n\n\t\treturn this._isActive;\n\n\t}\n\n\tset isActive( value ) {\n\n\t\tthis._isActive = value;\n\n\t}\n\n\tinit( /*inspector*/ ) { }\n\n\tupdate( /*inspector*/ ) { }\n\n\tsetActive( isActive ) {\n\n\t\tthis.button.classList.toggle( 'active', isActive );\n\t\tthis.content.classList.toggle( 'active', isActive );\n\n\t\tthis.isActive = isActive;\n\n\t}\n\n\tshow() {\n\n\t\tthis.content.style.display = '';\n\t\tthis.button.style.display = '';\n\n\t\tthis.isVisible = true;\n\n\t\t// Show detached window if tab is detached\n\t\tif ( this.isDetached && this.detachedWindow ) {\n\n\t\t\tthis.detachedWindow.panel.style.display = '';\n\n\t\t}\n\n\t\t// Notify profiler of visibility change\n\t\tif ( this.onVisibilityChange ) {\n\n\t\t\tthis.onVisibilityChange();\n\n\t\t}\n\n\t\tthis.showBuiltin();\n\n\t}\n\n\thide() {\n\n\t\tthis.content.style.display = 'none';\n\t\tthis.button.style.display = 'none';\n\n\t\tthis.isVisible = false;\n\n\t\t// Hide detached window if tab is detached\n\t\tif ( this.isDetached && this.detachedWindow ) {\n\n\t\t\tthis.detachedWindow.panel.style.display = 'none';\n\n\t\t}\n\n\t\t// Notify profiler of visibility change\n\t\tif ( this.onVisibilityChange ) {\n\n\t\t\tthis.onVisibilityChange();\n\n\t\t}\n\n\t\tthis.hideBuiltin();\n\n\t}\n\n\tshowBuiltin() {\n\n\t\tif ( ! this.builtin ) return;\n\n\t\t// Show the builtin-tabs-container\n\t\tif ( this.profiler && this.profiler.builtinTabsContainer ) {\n\n\t\t\tthis.profiler.builtinTabsContainer.style.display = '';\n\n\t\t}\n\n\t\t// Show the button\n\t\tif ( this.builtinButton ) {\n\n\t\t\tthis.builtinButton.style.display = '';\n\n\t\t}\n\n\t\t// Show and activate the mini-panel with content\n\t\tif ( this.miniContent && this.profiler ) {\n\n\t\t\t// Hide all other mini-panel contents\n\t\t\tthis.profiler.miniPanel.querySelectorAll( '.mini-panel-content' ).forEach( content => {\n\n\t\t\t\tcontent.style.display = 'none';\n\n\t\t\t} );\n\n\t\t\t// Remove active state from all builtin buttons\n\t\t\tthis.profiler.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ).forEach( btn => {\n\n\t\t\t\tbtn.classList.remove( 'active' );\n\n\t\t\t} );\n\n\t\t\t// Activate this tab's button\n\t\t\tif ( this.builtinButton ) {\n\n\t\t\t\tthis.builtinButton.classList.add( 'active' );\n\n\t\t\t}\n\n\t\t\t// Move content to mini-panel if not already there\n\t\t\tif ( ! this.miniContent.firstChild ) {\n\n\t\t\t\twhile ( this.content.firstChild ) {\n\n\t\t\t\t\tthis.miniContent.appendChild( this.content.firstChild );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// Show the mini-panel and content\n\t\t\tthis.miniContent.style.display = 'block';\n\t\t\tthis.profiler.miniPanel.classList.add( 'visible' );\n\n\t\t}\n\n\t}\n\n\thideBuiltin() {\n\n\t\tif ( ! this.builtin ) return;\n\n\t\t// Hide the button\n\t\tif ( this.builtinButton ) {\n\n\t\t\tthis.builtinButton.style.display = 'none';\n\n\t\t}\n\n\t\t// Hide the mini-panel content\n\t\tif ( this.miniContent ) {\n\n\t\t\tthis.miniContent.style.display = 'none';\n\n\t\t\t// Move content back to main panel\n\t\t\tif ( this.miniContent.firstChild ) {\n\n\t\t\t\twhile ( this.miniContent.firstChild ) {\n\n\t\t\t\t\tthis.content.appendChild( this.miniContent.firstChild );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Deactivate button\n\t\tif ( this.builtinButton ) {\n\n\t\t\tthis.builtinButton.classList.remove( 'active' );\n\n\t\t}\n\n\t\t// Hide mini-panel if no content is visible\n\t\tif ( this.profiler ) {\n\n\t\t\tconst hasVisibleContent = Array.from( this.profiler.miniPanel.querySelectorAll( '.mini-panel-content' ) )\n\t\t\t\t.some( content => content.style.display !== 'none' );\n\n\t\t\tif ( ! hasVisibleContent ) {\n\n\t\t\t\tthis.profiler.miniPanel.classList.remove( 'visible' );\n\n\t\t\t}\n\n\t\t\t// Hide the builtin-tabs-container if all builtin buttons are hidden\n\t\t\tconst hasVisibleBuiltinButtons = Array.from( this.profiler.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ) )\n\t\t\t\t.some( btn => btn.style.display !== 'none' );\n\n\t\t\tif ( ! hasVisibleBuiltinButtons ) {\n\n\t\t\t\tthis.profiler.builtinTabsContainer.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tdispose() { }\n\n}\n","\nexport class List {\n\n\tconstructor( ...headers ) {\n\n\t\tthis.headers = headers;\n\t\tthis.children = [];\n\t\tthis.domElement = document.createElement( 'div' );\n\t\tthis.domElement.className = 'list-container';\n\t\tthis.domElement.style.padding = '5px 10px 10px 10px';\n\t\tthis.id = `list-${Math.random().toString( 36 ).slice( 2, 11 )}`;\n\t\tthis.domElement.dataset.listId = this.id;\n\n\t\tconst headerRow = document.createElement( 'div' );\n\t\theaderRow.className = 'list-header';\n\t\tthis.headers.forEach( headerText => {\n\n\t\t\tconst headerCell = document.createElement( 'div' );\n\t\t\theaderCell.className = 'list-header-cell';\n\t\t\theaderCell.textContent = headerText;\n\t\t\theaderRow.appendChild( headerCell );\n\n\t\t} );\n\t\tthis.domElement.appendChild( headerRow );\n\n\t}\n\n\tsetGridStyle( gridTemplate ) {\n\n\t\tthis.domElement.style.setProperty( '--list-grid-template', gridTemplate );\n\n\t}\n\n\tsetViewMode( mode ) {\n\n\t\tif ( mode === 'grid' ) {\n\n\t\t\tthis.domElement.classList.add( 'grid-mode' );\n\n\t\t} else {\n\n\t\t\tthis.domElement.classList.remove( 'grid-mode' );\n\n\t\t}\n\n\t}\n\n\tadd( item ) {\n\n\t\tif ( item.parent !== null ) {\n\n\t\t\titem.parent.remove( item );\n\n\t\t}\n\n\t\titem.domElement.classList.add( 'header-wrapper', 'section-start' );\n\t\titem.parent = this;\n\n\t\tthis.children.push( item );\n\t\tthis.domElement.appendChild( item.domElement );\n\n\t}\n\n\tremove( item ) {\n\n\t\tconst index = this.children.indexOf( item );\n\n\t\tif ( index !== - 1 ) {\n\n\t\t\tthis.children.splice( index, 1 );\n\t\t\tthis.domElement.removeChild( item.domElement );\n\n\t\t\titem.parent = null;\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n}\n","export class Item {\n\n\tconstructor( ...data ) {\n\n\t\tthis.children = [];\n\t\tthis.isOpen = true;\n\t\tthis.isCollapsible = false;\n\t\tthis.childrenContainer = null;\n\t\tthis.parent = null;\n\t\tthis.domElement = document.createElement( 'div' );\n\t\tthis.domElement.className = 'list-item-wrapper';\n\t\tthis.itemRow = document.createElement( 'div' );\n\t\tthis.itemRow.className = 'list-item-row';\n\n\t\tthis.userData = {};\n\n\t\tthis.data = [];\n\t\tdata.forEach( ( cellData, index ) => {\n\n\t\t\tconst cell = document.createElement( 'div' );\n\t\t\tcell.className = 'list-item-cell';\n\t\t\tthis.itemRow.appendChild( cell );\n\n\t\t\tthis.setValue( index, cellData );\n\n\t\t} );\n\n\t\tthis.domElement.appendChild( this.itemRow );\n\n\t\t// Bindings\n\n\t\tthis.onItemClick = this.onItemClick.bind( this );\n\n\t}\n\n\tonItemClick( e ) {\n\n\t\tif ( e.target.closest( 'button, a, input, label' ) ) return;\n\n\t\tthis.toggle();\n\n\t}\n\n\tadd( item, index = this.children.length ) {\n\n\t\tif ( item.parent !== null ) {\n\n\t\t\titem.parent.remove( item );\n\n\t\t}\n\n\t\titem.parent = this;\n\n\t\tthis.children.splice( index, 0, item );\n\n\t\tthis.itemRow.classList.add( 'collapsible' );\n\n\t\tif ( ! this.childrenContainer ) {\n\n\t\t\tthis.childrenContainer = document.createElement( 'div' );\n\t\t\tthis.childrenContainer.className = 'list-children-container';\n\t\t\tthis.childrenContainer.classList.toggle( 'closed', ! this.isOpen );\n\t\t\tthis.domElement.appendChild( this.childrenContainer );\n\t\t\tthis.itemRow.addEventListener( 'click', this.onItemClick );\n\n\t\t}\n\n\t\tthis.childrenContainer.insertBefore(\n\t\t\titem.domElement,\n\t\t\tthis.childrenContainer.children[ index ] || null\n\t\t);\n\n\t\tthis.updateToggler();\n\t\treturn this;\n\n\t}\n\n\tremove( item ) {\n\n\t\tconst index = this.children.indexOf( item );\n\n\t\tif ( index !== - 1 ) {\n\n\t\t\tthis.children.splice( index, 1 );\n\t\t\tthis.childrenContainer.removeChild( item.domElement );\n\n\t\t\titem.parent = null;\n\n\t\t\tif ( this.children.length === 0 ) {\n\n\t\t\t\tthis.itemRow.classList.remove( 'collapsible' );\n\t\t\t\tthis.itemRow.removeEventListener( 'click', this.onItemClick );\n\n\t\t\t\tthis.childrenContainer.remove();\n\t\t\t\tthis.childrenContainer = null;\n\n\t\t\t}\n\n\t\t\tthis.updateToggler();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tupdateToggler() {\n\n\t\tconst firstCell = this.itemRow.querySelector( '.list-item-cell:first-child' );\n\t\tlet toggler = this.itemRow.querySelector( '.item-toggler' );\n\n\t\tif ( this.children.length > 0 || this.isCollapsible ) {\n\n\t\t\tif ( ! toggler ) {\n\n\t\t\t\ttoggler = document.createElement( 'span' );\n\t\t\t\ttoggler.className = 'item-toggler';\n\t\t\t\tfirstCell.prepend( toggler );\n\n\t\t\t}\n\n\t\t\tif ( this.isOpen ) {\n\n\t\t\t\tthis.itemRow.classList.add( 'open' );\n\n\t\t\t}\n\n\t\t} else if ( toggler ) {\n\n\t\t\ttoggler.remove();\n\n\t\t}\n\n\t}\n\n\tsetCollapsible( collapsible ) {\n\n\t\tthis.isCollapsible = collapsible;\n\n\t\tif ( collapsible ) {\n\n\t\t\tthis.itemRow.classList.add( 'collapsible' );\n\n\t\t\tif ( ! this.childrenContainer ) {\n\n\t\t\t\tthis.childrenContainer = document.createElement( 'div' );\n\t\t\t\tthis.childrenContainer.className = 'list-children-container';\n\t\t\t\tthis.childrenContainer.classList.toggle( 'closed', ! this.isOpen );\n\t\t\t\tthis.domElement.appendChild( this.childrenContainer );\n\t\t\t\tthis.itemRow.addEventListener( 'click', this.onItemClick );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.itemRow.classList.remove( 'collapsible' );\n\n\t\t}\n\n\t\tthis.updateToggler();\n\n\t\treturn this;\n\n\t}\n\n\ttoggle() {\n\n\t\tthis.isOpen = ! this.isOpen;\n\t\tthis.itemRow.classList.toggle( 'open', this.isOpen );\n\n\t\tif ( this.childrenContainer ) {\n\n\t\t\tthis.childrenContainer.classList.toggle( 'closed', ! this.isOpen );\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tclose() {\n\n\t\tif ( this.isOpen ) {\n\n\t\t\tthis.toggle();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tshow() {\n\n\t\tthis.domElement.style.display = '';\n\n\t\treturn this;\n\n\t}\n\n\thide() {\n\n\t\tthis.domElement.style.display = 'none';\n\n\t\treturn this;\n\n\t}\n\n\tsetValue( index, value ) {\n\n\t\tthis.data[ index ] = value;\n\n\t\tconst cell = this.itemRow.children[ index ];\n\n\t\tif ( cell ) {\n\n\t\t\tconst toggler = cell.querySelector( '.item-toggler' );\n\n\t\t\tcell.innerHTML = '';\n\n\t\t\tif ( toggler ) {\n\n\t\t\t\tcell.appendChild( toggler );\n\n\t\t\t}\n\n\t\t\tif ( value instanceof HTMLElement ) {\n\n\t\t\t\tcell.appendChild( value );\n\n\t\t\t} else {\n\n\t\t\t\tcell.append( String( value ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tgetValue( index ) {\n\n\t\treturn this.data[ index ];\n\n\t}\n\n}\n","export function createValueSpan() {\n\n\tconst span = document.createElement( 'span' );\n\tspan.className = 'value';\n\n\treturn span;\n\n}\n\nexport function setText( element, text ) {\n\n\tif ( element && element.textContent !== text ) {\n\n\t\telement.textContent = text;\n\n\t}\n\n}\n\nexport function getText( element ) {\n\n\treturn element ? element.textContent : null;\n\n}\n\nexport function splitPath( fullPath ) {\n\n\tconst lastSlash = fullPath.lastIndexOf( '/' );\n\n\tif ( lastSlash === - 1 ) {\n\n\t\treturn {\n\t\t\tpath: '',\n\t\t\tname: fullPath.trim()\n\t\t};\n\n\t}\n\n\tconst path = fullPath.substring( 0, lastSlash ).trim();\n\tconst name = fullPath.substring( lastSlash + 1 ).trim();\n\n\treturn { path, name };\n\n}\n\nexport function splitCamelCase( str ) {\n\n\treturn str.replace( /([a-z0-9])([A-Z])/g, '$1 $2' ).trim();\n\n}\n\nexport function formatBytes( bytes, decimals = 2 ) {\n\n\tif ( bytes === 0 ) return '0 Bytes';\n\n\tconst k = 1024;\n\tconst dm = decimals < 0 ? 0 : decimals;\n\tconst sizes = [ 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ];\n\tconst i = Math.floor( Math.log( bytes ) / Math.log( k ) );\n\n\treturn parseFloat( ( bytes / Math.pow( k, i ) ).toFixed( dm ) ) + ' ' + sizes[ i ];\n\n}\n\nexport function info( parentNode, text ) {\n\n\tlet infoIcon = parentNode.querySelector( '.info-icon' );\n\n\tif ( ! infoIcon ) {\n\n\t\tinfoIcon = document.createElement( 'span' );\n\t\tinfoIcon.className = 'info-icon';\n\t\tinfoIcon.textContent = 'i';\n\t\tparentNode.appendChild( infoIcon );\n\n\t} else {\n\n\t\tconst newInfoIcon = infoIcon.cloneNode( true );\n\t\tinfoIcon.replaceWith( newInfoIcon );\n\t\tinfoIcon = newInfoIcon;\n\n\t}\n\n\tconst showTooltip = () => {\n\n\t\tconst container = infoIcon.closest( '.three-inspector' ) || document.body;\n\t\tlet tooltip = container.querySelector( '.three-inspector-info-tooltip' );\n\n\t\tif ( ! tooltip ) {\n\n\t\t\ttooltip = document.createElement( 'div' );\n\t\t\ttooltip.className = 'info-tooltip three-inspector-info-tooltip';\n\t\t\tcontainer.appendChild( tooltip );\n\n\t\t}\n\n\t\tconst html = text.trim().replace( /### (.*?)(?:\\r?\\n|$)/g, '<h3>$1</h3>' )\n\t\t\t\t\t .replace( /\\*\\*(.*?)\\*\\*/g, '<strong>$1</strong>' )\n\t\t\t\t\t .replace( /\\n/g, '<br/>' );\n\n\t\ttooltip.innerHTML = html;\n\n\t\tconst rect = infoIcon.getBoundingClientRect();\n\t\tconst tooltipWidth = tooltip.getBoundingClientRect().width;\n\n\t\t// keep the centered tooltip within the viewport so it isn't clipped near an edge\n\n\t\tconst margin = 8;\n\t\tconst half = tooltipWidth / 2;\n\t\tconst center = Math.max( margin + half, Math.min( window.innerWidth - margin - half, rect.left + rect.width / 2 ) );\n\n\t\ttooltip.style.left = center + 'px';\n\t\ttooltip.style.top = ( rect.top - 8 ) + 'px';\n\n\t\ttooltip.style.opacity = '1';\n\t\ttooltip.style.visibility = 'visible';\n\n\t};\n\n\tconst hideTooltip = () => {\n\n\t\tconst container = infoIcon.closest( '.three-inspector' ) || document.body;\n\t\tconst tooltip = container.querySelector( '.three-inspector-info-tooltip' );\n\t\tif ( tooltip ) {\n\n\t\t\ttooltip.style.opacity = '0';\n\t\t\ttooltip.style.visibility = 'hidden';\n\n\t\t}\n\n\t};\n\n\tlet isClickedOpen = false;\n\n\tconst onDocumentPointerDown = ( e ) => {\n\n\t\tif ( ! infoIcon.contains( e.target ) ) {\n\n\t\t\tisClickedOpen = false;\n\t\t\tinfoIcon.classList.remove( 'active' );\n\t\t\thideTooltip();\n\t\t\tdocument.removeEventListener( 'pointerdown', onDocumentPointerDown );\n\n\t\t}\n\n\t};\n\n\tinfoIcon.addEventListener( 'pointerenter', () => {\n\n\t\tshowTooltip();\n\n\t} );\n\n\tinfoIcon.addEventListener( 'pointerleave', () => {\n\n\t\tif ( ! isClickedOpen ) {\n\n\t\t\thideTooltip();\n\n\t\t}\n\n\t} );\n\n\tinfoIcon.addEventListener( 'click', ( e ) => {\n\n\t\te.stopPropagation();\n\n\t\tisClickedOpen = ! isClickedOpen;\n\n\t\tif ( isClickedOpen ) {\n\n\t\t\tinfoIcon.classList.add( 'active' );\n\t\t\tshowTooltip();\n\t\t\tdocument.addEventListener( 'pointerdown', onDocumentPointerDown );\n\n\t\t} else {\n\n\t\t\tinfoIcon.classList.remove( 'active' );\n\t\t\thideTooltip();\n\t\t\tdocument.removeEventListener( 'pointerdown', onDocumentPointerDown );\n\n\t\t}\n\n\t} );\n\n\treturn infoIcon;\n\n}\n\n","import { Tab } from '../ui/Tab.js';\nimport { List } from '../ui/List.js';\nimport { Graph } from '../ui/Graph.js';\nimport { Item } from '../ui/Item.js';\nimport { createValueSpan, setText } from '../ui/utils.js';\n\nclass Performance extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Performance', options );\n\n\t\tconst perfList = new List( 'Name', 'CPU', 'GPU', 'Total' );\n\t\tperfList.setGridStyle( 'minmax(200px, 2fr) 80px 80px 80px' );\n\t\tperfList.domElement.style.minWidth = '600px';\n\n\t\tconst scrollWrapper = document.createElement( 'div' );\n\t\tscrollWrapper.className = 'list-scroll-wrapper';\n\t\tscrollWrapper.appendChild( perfList.domElement );\n\t\tthis.content.appendChild( scrollWrapper );\n\n\t\t//\n\n\t\tconst graphContainer = document.createElement( 'div' );\n\t\tgraphContainer.className = 'graph-container';\n\n\t\tconst graph = new Graph();\n\t\tgraph.addLine( 'fps', 'var( --color-fps )' );\n\t\tgraph.addLine( 'cpu', 'var( --color-yellow )' );\n\t\tgraph.addLine( 'gpu', 'var( --color-green )' );\n\t\tgraphContainer.append( graph.domElement );\n\n\t\t//\n\n\t\t/*\n\t\tconst label = document.createElement( 'label' );\n\t\tlabel.className = 'custom-checkbox';\n\n\t\tconst checkbox = document.createElement( 'input' );\n\t\tcheckbox.type = 'checkbox';\n\n\t\tconst checkmark = document.createElement( 'span' );\n\t\tcheckmark.className = 'checkmark';\n\n\t\tlabel.appendChild( checkbox );\n\t\tlabel.appendChild( checkmark );\n\t\t*/\n\n\t\tthis.graphFpsCounter = createValueSpan();\n\t\tconst graphStats = new Item( 'Graph Stats', createValueSpan(), createValueSpan(), this.graphFpsCounter );\n\t\tperfList.add( graphStats );\n\n\t\tconst graphItem = new Item( graphContainer );\n\t\tgraphItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';\n\t\tgraphStats.add( graphItem );\n\n\t\t//\n\n\t\tconst frameStats = new Item( 'Frame Stats', createValueSpan(), createValueSpan(), createValueSpan() );\n\t\tperfList.add( frameStats );\n\n\t\tconst miscellaneous = new Item( 'Miscellaneous & Idle', createValueSpan(), createValueSpan(), createValueSpan() );\n\t\tmiscellaneous.domElement.firstChild.style.backgroundColor = '#00ff0b1a';\n\t\tmiscellaneous.domElement.firstChild.classList.add( 'no-hover' );\n\t\tframeStats.add( miscellaneous );\n\n\t\t//\n\n\t\tthis.notInUse = new Map();\n\t\tthis.frameStats = frameStats;\n\t\tthis.graphStats = graphStats;\n\t\tthis.graph = graph;\n\t\tthis.miscellaneous = miscellaneous;\n\n\t\t//\n\n\t\tthis.currentRender = null;\n\t\tthis.currentItem = null;\n\t\tthis.frameItems = new Map();\n\n\t}\n\n\tresolveStats( inspector, stats, budget = Infinity ) {\n\n\t\tconst data = inspector.getStatsData( stats.cid );\n\n\t\tlet item = data.item;\n\n\t\tif ( item === undefined ) {\n\n\t\t\titem = new Item( createValueSpan(), createValueSpan(), createValueSpan(), createValueSpan() );\n\n\t\t\tif ( stats.name ) {\n\n\t\t\t\tif ( stats.isComputeStats === true ) {\n\n\t\t\t\t\tstats.name = `${ stats.name } [ Compute ]`;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tstats.name = `Unnamed ${ stats.cid }`;\n\n\t\t\t}\n\n\t\t\titem.userData.name = stats.name;\n\n\t\t\tthis.currentItem.add( item );\n\t\t\tdata.item = item;\n\n\t\t} else {\n\n\t\t\titem.userData.name = stats.name;\n\n\t\t\tif ( this.notInUse.has( stats.cid ) ) {\n\n\t\t\t\titem.domElement.firstElementChild.classList.remove( 'alert' );\n\n\t\t\t\tthis.notInUse.delete( stats.cid );\n\n\t\t\t}\n\n\t\t\tconst statsIndex = stats.parent.children.indexOf( stats );\n\n\t\t\tif ( item.parent === null || item.parent.children.indexOf( item ) !== statsIndex ) {\n\n\t\t\t\tthis.currentItem.add( item, statsIndex );\n\n\t\t\t}\n\n\t\t}\n\n\t\tlet name = item.userData.name;\n\n\t\tif ( stats.isComputeStats ) {\n\n\t\t\tname += ' [ Compute ]';\n\n\t\t}\n\n\t\t// A row never shows more GPU time than its parent, see updateText()\n\n\t\tconst displayGpu = stats.gpuNotAvailable === true ? 0 : Math.min( data.gpu, budget );\n\t\tconst displayTotal = data.cpu + displayGpu;\n\n\t\tsetText( item.data[ 0 ], name );\n\t\tsetText( item.data[ 1 ], data.cpu.toFixed( 2 ) );\n\t\tsetText( item.data[ 2 ], stats.gpuNotAvailable === true ? '-' : displayGpu.toFixed( 2 ) );\n\t\tsetText( item.data[ 3 ], displayTotal.toFixed( 2 ) );\n\n\t\t//\n\n\t\tconst previousItem = this.currentItem;\n\n\t\tthis.currentItem = item;\n\n\t\tconst childBudget = stats.gpuNotAvailable === true ? budget : displayGpu;\n\n\t\tfor ( const child of stats.children ) {\n\n\t\t\tthis.resolveStats( inspector, child, childBudget );\n\n\t\t}\n\n\t\tthis.currentItem = previousItem;\n\n\t\tthis.frameItems.set( stats.cid, item );\n\n\t}\n\n\tupdateGraph( inspector, frame ) {\n\n\t\tconst fps = inspector.fps;\n\n\t\tthis.graph.addPoint( 'fps', fps );\n\n\t\tif ( frame ) {\n\n\t\t\tconst cpuValue = Math.min( ( ( frame.cpu || 0 ) * fps ) / 1000, 1.0 ) * fps;\n\t\t\tconst gpuValue = Math.min( ( ( frame.gpu || 0 ) * fps ) / 1000, 1.0 ) * fps;\n\n\t\t\tthis.graph.addPoint( 'cpu', cpuValue );\n\t\t\tthis.graph.addPoint( 'gpu', gpuValue );\n\n\t\t}\n\n\t\tthis.graph.update();\n\n\t}\n\n\taddNotInUse( cid, item ) {\n\n\t\titem.domElement.firstElementChild.classList.add( 'alert' );\n\n\t\tthis.notInUse.set( cid, {\n\t\t\titem,\n\t\t\ttime: performance.now()\n\t\t} );\n\n\t\tthis.updateNotInUse( cid );\n\n\t}\n\n\tupdateNotInUse( cid ) {\n\n\t\tconst { item, time } = this.notInUse.get( cid );\n\n\t\tconst current = performance.now();\n\t\tconst duration = 5;\n\t\tconst remaining = duration - Math.floor( ( current - time ) / 1000 );\n\n\t\tif ( remaining >= 0 ) {\n\n\t\t\tconst counter = '*'.repeat( Math.max( 0, remaining ) );\n\t\t\tconst element = item.domElement.querySelector( '.list-item-cell .value' );\n\n\t\t\tsetText( element, item.userData.name + ' (not in use) ' + counter );\n\n\t\t} else {\n\n\t\t\titem.domElement.firstElementChild.classList.remove( 'alert' );\n\t\t\titem.parent.remove( item );\n\n\t\t\tthis.notInUse.delete( cid );\n\n\t\t}\n\n\t}\n\n\tupdateText( inspector, frame ) {\n\n\t\tconst oldFrameItems = new Map( this.frameItems );\n\n\t\tthis.frameItems.clear();\n\n\t\t// GPU timestamps can sum to more than the frame time when the GPU overlaps passes, so cap the display at\n\t\t// the frame time, and cap each row at its parent's value\n\n\t\tconst hasTimestamp = inspector.getRenderer().backend.hasTimestamp;\n\t\tconst gpuBudget = hasTimestamp ? Math.min( frame.gpu, frame.deltaTime ) : 0;\n\t\tconst totalDisplay = frame.cpu + gpuBudget;\n\n\t\tthis.currentItem = this.frameStats;\n\n\t\tfor ( const child of frame.children ) {\n\n\t\t\tthis.resolveStats( inspector, child, gpuBudget );\n\n\t\t}\n\n\t\t// remove unused frame items\n\n\t\tfor ( const [ cid, item ] of oldFrameItems ) {\n\n\t\t\tif ( ! this.frameItems.has( cid ) ) {\n\n\t\t\t\tthis.addNotInUse( cid, item );\n\n\t\t\t\toldFrameItems.delete( cid );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// update not in use items\n\n\t\tfor ( const cid of this.notInUse.keys() ) {\n\n\t\t\tthis.updateNotInUse( cid );\n\n\t\t}\n\n\t\t//\n\n\t\tsetText( this.graphFpsCounter, inspector.fps.toFixed() + ' FPS' );\n\n\t\t//\n\n\t\tsetText( this.frameStats.data[ 1 ], frame.cpu.toFixed( 2 ) );\n\t\tsetText( this.frameStats.data[ 2 ], hasTimestamp ? gpuBudget.toFixed( 2 ) : '-' );\n\t\tsetText( this.frameStats.data[ 3 ], totalDisplay.toFixed( 2 ) );\n\n\t\t//\n\n\t\tsetText( this.miscellaneous.data[ 1 ], frame.miscellaneous.toFixed( 2 ) );\n\t\tsetText( this.miscellaneous.data[ 2 ], '-' );\n\t\tsetText( this.miscellaneous.data[ 3 ], frame.miscellaneous.toFixed( 2 ) );\n\n\t\t//\n\n\t\tthis.currentItem = null;\n\n\t}\n\n}\n\nexport { Performance };\n","import { Tab } from '../ui/Tab.js';\nimport { List } from '../ui/List.js';\nimport { Graph } from '../ui/Graph.js';\nimport { Item } from '../ui/Item.js';\nimport { createValueSpan, setText, formatBytes } from '../ui/utils.js';\n\nclass Memory extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Memory', options );\n\n\t\tconst memoryList = new List( 'Name', 'Count', 'Size' );\n\t\tmemoryList.setGridStyle( 'minmax(200px, 2fr) 60px 100px' );\n\t\tmemoryList.domElement.style.minWidth = '300px';\n\n\t\tconst scrollWrapper = document.createElement( 'div' );\n\t\tscrollWrapper.className = 'list-scroll-wrapper';\n\t\tscrollWrapper.appendChild( memoryList.domElement );\n\t\tthis.content.appendChild( scrollWrapper );\n\n\t\t// graph\n\n\t\tconst graphContainer = document.createElement( 'div' );\n\t\tgraphContainer.className = 'graph-container';\n\n\t\tconst graph = new Graph();\n\t\tgraph.addLine( 'total', 'var( --color-yellow )' );\n\t\tgraphContainer.append( graph.domElement );\n\n\t\t// stats\n\n\t\tconst graphStats = new Item( 'Graph Stats', '', '' );\n\t\tmemoryList.add( graphStats );\n\n\t\tconst graphItem = new Item( graphContainer );\n\t\tgraphItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';\n\t\tgraphStats.add( graphItem );\n\n\t\t// info\n\n\t\tthis.memoryStats = new Item( 'Renderer Info', '', createValueSpan() );\n\t\tthis.memoryStats.domElement.firstChild.classList.add( 'no-hover' );\n\t\tmemoryList.add( this.memoryStats );\n\n\t\tthis.attributes = new Item( 'Attributes', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.attributes );\n\n\t\tthis.geometries = new Item( 'Geometries', createValueSpan(), 'N/A' );\n\t\tthis.memoryStats.add( this.geometries );\n\n\t\tthis.indexAttributes = new Item( 'Index Attributes', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.indexAttributes );\n\n\t\tthis.indirectStorageAttributes = new Item( 'Indirect Storage Attributes', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.indirectStorageAttributes );\n\n\t\tthis.programs = new Item( 'Programs', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.programs );\n\n\t\tthis.readbackBuffers = new Item( 'Readback Buffers', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.readbackBuffers );\n\n\t\tthis.renderTargets = new Item( 'Render Targets', createValueSpan(), 'N/A' );\n\t\tthis.memoryStats.add( this.renderTargets );\n\n\t\tthis.storageAttributes = new Item( 'Storage Attributes', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.storageAttributes );\n\n\t\tthis.textures = new Item( 'Textures', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.textures );\n\n\t\tthis.uniformBuffers = new Item( 'Uniform Buffers', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.uniformBuffers );\n\n\t\tthis.graph = graph;\n\n\t}\n\n\tupdateGraph( inspector ) {\n\n\t\tconst renderer = inspector.getRenderer();\n\n\t\tconst memory = renderer.info.memory;\n\n\t\tthis.graph.addPoint( 'total', memory.total );\n\n\t\tif ( this.graph.limit === 0 ) this.graph.limit = 1;\n\n\t\tthis.graph.update();\n\n\t}\n\n\tupdateText( inspector ) {\n\n\t\tconst renderer = inspector.getRenderer();\n\n\t\tconst memory = renderer.info.memory;\n\n\t\tsetText( this.memoryStats.data[ 2 ], formatBytes( memory.total ) );\n\n\t\tsetText( this.attributes.data[ 1 ], memory.attributes.toString() );\n\t\tsetText( this.attributes.data[ 2 ], formatBytes( memory.attributesSize ) );\n\n\t\tsetText( this.geometries.data[ 1 ], memory.geometries.toString() );\n\n\t\tsetText( this.indexAttributes.data[ 1 ], memory.indexAttributes.toString() );\n\t\tsetText( this.indexAttributes.data[ 2 ], formatBytes( memory.indexAttributesSize ) );\n\n\t\tsetText( this.indirectStorageAttributes.data[ 1 ], memory.indirectStorageAttributes.toString() );\n\t\tsetText( this.indirectStorageAttributes.data[ 2 ], formatBytes( memory.indirectStorageAttributesSize ) );\n\n\t\tsetText( this.programs.data[ 1 ], memory.programs.toString() );\n\t\tsetText( this.programs.data[ 2 ], formatBytes( memory.programsSize ) );\n\n\t\tsetText( this.readbackBuffers.data[ 1 ], memory.readbackBuffers.toString() );\n\t\tsetText( this.readbackBuffers.data[ 2 ], formatBytes( memory.readbackBuffersSize ) );\n\n\t\tsetText( this.renderTargets.data[ 1 ], memory.renderTargets.toString() );\n\n\t\tsetText( this.storageAttributes.data[ 1 ], memory.storageAttributes.toString() );\n\t\tsetText( this.storageAttributes.data[ 2 ], formatBytes( memory.storageAttributesSize ) );\n\n\t\tsetText( this.textures.data[ 1 ], memory.textures.toString() );\n\t\tsetText( this.textures.data[ 2 ], formatBytes( memory.texturesSize ) );\n\n\t\tsetText( this.uniformBuffers.data[ 1 ], memory.uniformBuffers.toString() );\n\t\tsetText( this.uniformBuffers.data[ 2 ], formatBytes( memory.uniformBuffersSize ) );\n\n\t}\n\n}\n\nexport { Memory };\n","import { Tab } from '../ui/Tab.js';\n\nclass Console extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Console', options );\n\n\t\tthis.filters = { info: true, warn: true, error: true };\n\t\tthis.filterText = '';\n\n\t\tthis.unreadErrors = 0;\n\t\tthis.unreadWarns = 0;\n\n\t\tthis.tabBadgeContainer = document.createElement( 'span' );\n\t\tthis.tabBadgeContainer.className = 'tab-badge-container';\n\n\t\tthis.tabErrorBadge = document.createElement( 'span' );\n\t\tthis.tabErrorBadge.className = 'tab-badge error';\n\t\tthis.tabErrorBadge.style.display = 'none';\n\n\t\tthis.tabWarnBadge = document.createElement( 'span' );\n\t\tthis.tabWarnBadge.className = 'tab-badge warn';\n\t\tthis.tabWarnBadge.style.display = 'none';\n\n\t\tthis.tabBadgeContainer.appendChild( this.tabErrorBadge );\n\t\tthis.tabBadgeContainer.appendChild( this.tabWarnBadge );\n\t\tthis.button.appendChild( this.tabBadgeContainer );\n\n\t\tthis.buildHeader();\n\n\t\tthis.logContainer = document.createElement( 'div' );\n\t\tthis.logContainer.classList.add( 'console-log' );\n\t\tthis.content.appendChild( this.logContainer );\n\n\t\tthis.lastMessage = null;\n\n\t}\n\n\tbuildHeader() {\n\n\t\tconst header = document.createElement( 'div' );\n\t\theader.className = 'toolbar';\n\n\t\tconst filterInput = document.createElement( 'input' );\n\t\tfilterInput.type = 'text';\n\t\tfilterInput.className = 'console-filter-input';\n\t\tfilterInput.placeholder = 'Filter...';\n\t\tfilterInput.addEventListener( 'input', ( e ) => {\n\n\t\t\tthis.filterText = e.target.value.toLowerCase();\n\t\t\tthis.applyFilters();\n\n\t\t} );\n\n\t\tconst copyButton = document.createElement( 'button' );\n\t\tcopyButton.className = 'console-copy-button';\n\t\tcopyButton.title = 'Copy all';\n\t\tcopyButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"></rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"></path></svg>';\n\t\tcopyButton.addEventListener( 'click', () => this.copyAll( copyButton ) );\n\n\t\tconst buttonsGroup = document.createElement( 'div' );\n\t\tbuttonsGroup.className = 'console-buttons-group';\n\n\t\tObject.keys( this.filters ).forEach( type => {\n\n\t\t\tconst label = document.createElement( 'label' );\n\t\t\tlabel.className = 'custom-checkbox';\n\t\t\tlabel.style.color = `var(--${type === 'info' ? 'text-primary' : 'color-' + ( type === 'warn' ? 'yellow' : 'red' )})`;\n\n\t\t\tconst checkbox = document.createElement( 'input' );\n\t\t\tcheckbox.type = 'checkbox';\n\t\t\tcheckbox.checked = this.filters[ type ];\n\t\t\tcheckbox.dataset.type = type;\n\n\t\t\tconst checkmark = document.createElement( 'span' );\n\t\t\tcheckmark.className = 'checkmark';\n\n\t\t\tconst labelText = document.createElement( 'span' );\n\t\t\tlabelText.className = 'checkbox-text';\n\t\t\tlabelText.textContent = type.charAt( 0 ).toUpperCase() + type.slice( 1 );\n\n\t\t\tlabel.appendChild( checkbox );\n\t\t\tlabel.appendChild( checkmark );\n\t\t\tlabel.appendChild( labelText );\n\t\t\tbuttonsGroup.appendChild( label );\n\n\t\t} );\n\n\t\tbuttonsGroup.addEventListener( 'change', ( e ) => {\n\n\t\t\tconst type = e.target.dataset.type;\n\t\t\tif ( type in this.filters ) {\n\n\t\t\t\tthis.filters[ type ] = e.target.checked;\n\t\t\t\tthis.applyFilters();\n\n\t\t\t}\n\n\t\t} );\n\n\t\tbuttonsGroup.appendChild( copyButton );\n\n\t\theader.appendChild( filterInput );\n\t\theader.appendChild( buttonsGroup );\n\t\tthis.content.appendChild( header );\n\n\t}\n\n\tapplyFilters() {\n\n\t\tconst messages = this.logContainer.querySelectorAll( '.log-message' );\n\t\tmessages.forEach( msg => {\n\n\t\t\tconst type = msg.dataset.type;\n\t\t\tconst text = msg.dataset.rawText.toLowerCase();\n\n\t\t\tconst showByType = this.filters[ type ];\n\t\t\tconst showByText = text.includes( this.filterText );\n\n\t\t\tmsg.classList.toggle( 'hidden', ! ( showByType && showByText ) );\n\n\t\t} );\n\n\t}\n\n\tcopyAll( button ) {\n\n\t\tconst win = this.logContainer.ownerDocument.defaultView;\n\t\tconst selection = win.getSelection();\n\t\tconst selectedText = selection.toString();\n\t\tconst textInConsole = selectedText && this.logContainer.contains( selection.anchorNode );\n\n\t\tlet text;\n\t\tif ( textInConsole ) {\n\n\t\t\ttext = selectedText;\n\n\t\t} else {\n\n\t\t\tconst messages = this.logContainer.querySelectorAll( '.log-message:not(.hidden)' );\n\t\t\ttext = Array.from( messages ).map( msg => msg.dataset.rawText ).join( '\\n' );\n\n\t\t}\n\n\t\tnavigator.clipboard.writeText( text );\n\n\t\tbutton.classList.add( 'copied' );\n\t\tsetTimeout( () => button.classList.remove( 'copied' ), 350 );\n\n\t}\n\n\t_getIcon( type, subType ) {\n\n\t\tlet icon;\n\n\t\tif ( subType === 'tip' ) {\n\n\t\t\ticon = '💭';\n\n\t\t} else if ( subType === 'tsl' ) {\n\n\t\t\ticon = '✨';\n\n\t\t} else if ( subType === 'webgpurenderer' ) {\n\n\t\t\ticon = '🎨';\n\n\t\t} else if ( type === 'warn' ) {\n\n\t\t\ticon = '⚠️';\n\n\t\t} else if ( type === 'error' ) {\n\n\t\t\ticon = '🔴';\n\n\t\t} else if ( type === 'info' ) {\n\n\t\t\ticon = 'ℹ️';\n\n\t\t}\n\n\t\treturn icon;\n\n\t}\n\n\t_formatMessage( type, text ) {\n\n\t\tconst fragment = document.createDocumentFragment();\n\t\tconst prefixMatch = text.match( /^([\\w\\.]+:\\s)/ );\n\t\tlet content = text;\n\n\t\tif ( prefixMatch ) {\n\n\t\t\tconst fullPrefix = prefixMatch[ 0 ];\n\t\t\tconst parts = fullPrefix.slice( 0, - 2 ).split( '.' );\n\t\t\tconst shortPrefix = ( parts.length > 1 ? parts[ parts.length - 1 ] : parts[ 0 ] ) + ':';\n\n\t\t\tconst prefixSpan = document.createElement( 'span' );\n\t\t\tprefixSpan.className = 'log-prefix';\n\t\t\tprefixSpan.textContent = shortPrefix;\n\t\t\tfragment.appendChild( prefixSpan );\n\t\t\tcontent = text.substring( fullPrefix.length );\n\n\t\t}\n\n\t\tconst parts = content.split( /(\".*?\"|'.*?'|`.*?`)/g ).map( p => p.trim() ).filter( Boolean );\n\n\t\tparts.forEach( ( part, index ) => {\n\n\t\t\tif ( /^(\"|'|`)/.test( part ) ) {\n\n\t\t\t\tconst codeSpan = document.createElement( 'span' );\n\t\t\t\tcodeSpan.className = 'log-code';\n\t\t\t\tcodeSpan.textContent = part.slice( 1, - 1 );\n\t\t\t\tfragment.appendChild( codeSpan );\n\n\t\t\t} else {\n\n\t\t\t\tif ( index > 0 ) part = ' ' + part; // add space before parts except the first\n\t\t\t\tif ( index < parts.length - 1 ) part += ' '; // add space between parts\n\n\t\t\t\tfragment.appendChild( document.createTextNode( part ) );\n\n\t\t\t}\n\n\t\t} );\n\n\t\treturn fragment;\n\n\t}\n\n\tsetActive( isActive ) {\n\n\t\tsuper.setActive( isActive );\n\n\t\tif ( isActive ) {\n\n\t\t\tthis.clearUnread();\n\n\t\t}\n\n\t}\n\n\tclearUnread() {\n\n\t\tthis.unreadErrors = 0;\n\t\tthis.unreadWarns = 0;\n\t\tthis.updateBadges();\n\n\t}\n\n\tupdateBadges() {\n\n\t\tif ( ! this.profiler ) return;\n\n\t\tconst errorBadge = this.profiler.toggleButton.querySelector( '.console-badge.error' );\n\t\tconst warnBadge = this.profiler.toggleButton.querySelector( '.console-badge.warn' );\n\n\t\tif ( errorBadge ) {\n\n\t\t\tif ( this.unreadErrors > 0 ) {\n\n\t\t\t\terrorBadge.textContent = this.unreadErrors > 99 ? '+99' : this.unreadErrors;\n\t\t\t\terrorBadge.style.display = '';\n\n\t\t\t} else {\n\n\t\t\t\terrorBadge.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( warnBadge ) {\n\n\t\t\tif ( this.unreadWarns > 0 ) {\n\n\t\t\t\twarnBadge.textContent = this.unreadWarns > 99 ? '+99' : this.unreadWarns;\n\t\t\t\twarnBadge.style.display = '';\n\n\t\t\t} else {\n\n\t\t\t\twarnBadge.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.tabErrorBadge ) {\n\n\t\t\tif ( this.unreadErrors > 0 ) {\n\n\t\t\t\tthis.tabErrorBadge.textContent = this.unreadErrors > 99 ? '+99' : this.unreadErrors;\n\t\t\t\tthis.tabErrorBadge.style.display = '';\n\n\t\t\t} else {\n\n\t\t\t\tthis.tabErrorBadge.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.tabWarnBadge ) {\n\n\t\t\tif ( this.unreadWarns > 0 ) {\n\n\t\t\t\tthis.tabWarnBadge.textContent = this.unreadWarns > 99 ? '+99' : this.unreadWarns;\n\t\t\t\tthis.tabWarnBadge.style.display = '';\n\n\t\t\t} else {\n\n\t\t\t\tthis.tabWarnBadge.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\taddMessage( type, text ) {\n\n\t\tif ( this.lastMessage && this.lastMessage.type === type && this.lastMessage.text === text ) {\n\n\t\t\tthis.lastMessage.count ++;\n\t\t\tthis.lastMessage.countBadge.textContent = this.lastMessage.count;\n\t\t\tthis.lastMessage.countBadge.style.display = '';\n\n\t\t} else {\n\n\t\t\tconst msg = document.createElement( 'div' );\n\t\t\tmsg.className = `log-message ${type}`;\n\t\t\tmsg.dataset.type = type;\n\t\t\tmsg.dataset.rawText = text;\n\n\t\t\tconst countBadge = document.createElement( 'span' );\n\t\t\tcountBadge.className = 'log-count-badge';\n\t\t\tcountBadge.style.display = 'none';\n\t\t\tmsg.appendChild( countBadge );\n\n\t\t\tlet icon = null;\n\t\t\tconst prefixMatch = text.match( /^([\\w\\.]+:\\s)/ );\n\t\t\tif ( prefixMatch ) {\n\n\t\t\t\tconst fullPrefix = prefixMatch[ 0 ];\n\t\t\t\tconst parts = fullPrefix.slice( 0, - 2 ).split( '.' );\n\t\t\t\tconst shortPrefix = ( parts.length > 1 ? parts[ parts.length - 1 ] : parts[ 0 ] ) + ':';\n\t\t\t\ticon = this._getIcon( type, shortPrefix.split( ':' )[ 0 ].toLowerCase() );\n\n\t\t\t}\n\n\t\t\tif ( icon ) {\n\n\t\t\t\tconst iconSpan = document.createElement( 'span' );\n\t\t\t\ticonSpan.className = 'log-icon';\n\t\t\t\ticonSpan.textContent = icon;\n\t\t\t\tmsg.appendChild( iconSpan );\n\n\t\t\t}\n\n\t\t\tconst body = document.createElement( 'span' );\n\t\t\tbody.className = 'log-body';\n\t\t\tbody.appendChild( this._formatMessage( type, text ) );\n\t\t\tmsg.appendChild( body );\n\n\t\t\tconst showByType = this.filters[ type ];\n\t\t\tconst showByText = text.toLowerCase().includes( this.filterText );\n\t\t\tmsg.classList.toggle( 'hidden', ! ( showByType && showByText ) );\n\n\t\t\tthis.logContainer.appendChild( msg );\n\n\t\t\tif ( this.logContainer.children.length > 200 ) {\n\n\t\t\t\tconst firstChild = this.logContainer.firstChild;\n\t\t\t\tthis.logContainer.removeChild( firstChild );\n\t\t\t\tif ( this.lastMessage && this.lastMessage.element === firstChild ) {\n\n\t\t\t\t\tthis.lastMessage = null;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.lastMessage = {\n\t\t\t\ttype,\n\t\t\t\ttext,\n\t\t\t\tcount: 1,\n\t\t\t\telement: msg,\n\t\t\t\tcountBadge\n\t\t\t};\n\n\t\t}\n\n\t\tthis.logContainer.scrollTop = this.logContainer.scrollHeight;\n\n\t\t// Update unread counts if the console is not active/visible\n\t\tconst isUnread = ! this.isActive;\n\n\t\tif ( isUnread ) {\n\n\t\t\tif ( type === 'error' ) {\n\n\t\t\t\tthis.unreadErrors ++;\n\t\t\t\tthis.updateBadges();\n\n\t\t\t} else if ( type === 'warn' ) {\n\n\t\t\t\tthis.unreadWarns ++;\n\t\t\t\tthis.updateBadges();\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\nexport { Console };\n","import { EventDispatcher } from 'three';\n\nclass Value extends EventDispatcher {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.domElement = document.createElement( 'div' );\n\t\tthis.domElement.className = 'param-control';\n\n\t\tthis._onChangeFunction = null;\n\t\tthis._changeTimeout = null;\n\t\tthis._debounceTime = 0;\n\n\t\tthis.addEventListener( 'change', ( e ) => {\n\n\t\t\t// defer to avoid issues when changing multiple values in the same call stack\n\n\t\t\tclearTimeout( this._changeTimeout );\n\n\t\t\tthis._changeTimeout = setTimeout( () => {\n\n\t\t\t\tif ( this._onChangeFunction ) this._onChangeFunction( e.value );\n\n\t\t\t}, this._debounceTime );\n\n\t\t} );\n\n\t}\n\n\tsetValue( /*val*/ ) {\n\n\t\tthis.dispatchChange();\n\n\t\treturn this;\n\n\t}\n\n\tgetValue() {\n\n\t\treturn null;\n\n\t}\n\n\tdispatchChange() {\n\n\t\tthis.dispatchEvent( { type: 'change', value: this.getValue() } );\n\n\t}\n\n\tonChange( callback ) {\n\n\t\tthis._onChangeFunction = callback;\n\n\t\treturn this;\n\n\t}\n\n\tdebounce( time ) {\n\n\t\tthis._debounceTime = time;\n\n\t\treturn this;\n\n\t}\n\n\tshow() {\n\n\t\tthis.dispatchEvent( { type: 'show' } );\n\n\t\treturn this;\n\n\t}\n\n\thide() {\n\n\t\tthis.dispatchEvent( { type: 'hide' } );\n\n\t\treturn this;\n\n\t}\n\n}\n\nclass ValueNumber extends Value {\n\n\tconstructor( { value = 0, step = 0.1, min = - Infinity, max = Infinity } ) {\n\n\t\tsuper();\n\n\t\tthis.input = document.createElement( 'input' );\n\t\tthis.input.type = 'number';\n\t\tthis.input.value = value;\n\t\tthis.input.step = step;\n\t\tthis.input.min = min;\n\t\tthis.input.max = max;\n\t\tthis.input.addEventListener( 'change', this._onChangeValue.bind( this ) );\n\t\tthis.domElement.appendChild( this.input );\n\t\tthis.addDragHandler();\n\n\t}\n\n\t_onChangeValue() {\n\n\t\tconst value = parseFloat( this.input.value );\n\t\tconst min = parseFloat( this.input.min );\n\t\tconst max = parseFloat( this.input.max );\n\n\t\tif ( value > max ) {\n\n\t\t\tthis.input.value = max;\n\n\t\t} else if ( value < min ) {\n\n\t\t\tthis.input.value = min;\n\n\t\t} else if ( isNaN( value ) ) {\n\n\t\t\tthis.input.value = min;\n\n\t\t}\n\n\t\tthis.dispatchChange();\n\n\t}\n\n\taddDragHandler() {\n\n\t\tconst threshold = 2;\n\n\t\tlet isPressed = false;\n\t\tlet isDragging = false;\n\t\tlet startX, startY, startValue;\n\n\t\tthis.input.style.touchAction = 'none';\n\n\t\tthis.input.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\tisPressed = true;\n\t\t\tstartX = e.clientX;\n\t\t\tstartY = e.clientY;\n\t\t\tstartValue = parseFloat( this.input.value );\n\n\t\t} );\n\n\t\tdocument.addEventListener( 'pointermove', ( e ) => {\n\n\t\t\tif ( isPressed ) {\n\n\t\t\t\t// start dragging only after a vertical movement, a horizontal one selects text\n\n\t\t\t\tif ( Math.abs( e.clientY - startY ) > threshold ) {\n\n\t\t\t\t\tisPressed = false;\n\t\t\t\t\tisDragging = true;\n\t\t\t\t\tstartY = e.clientY;\n\t\t\t\t\tthis.input.blur();\n\t\t\t\t\tdocument.body.style.cursor = 'ns-resize';\n\n\t\t\t\t} else if ( Math.abs( e.clientX - startX ) > threshold ) {\n\n\t\t\t\t\tisPressed = false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( isDragging ) {\n\n\t\t\t\tconst deltaY = startY - e.clientY;\n\t\t\t\tconst step = parseFloat( this.input.step ) || 1;\n\t\t\t\tconst min = parseFloat( this.input.min );\n\t\t\t\tconst max = parseFloat( this.input.max );\n\n\t\t\t\tlet stepSize = step;\n\n\t\t\t\tif ( ! isNaN( max ) && isFinite( min ) ) {\n\n\t\t\t\t\tstepSize = ( max - min ) / 100;\n\n\t\t\t\t}\n\n\t\t\t\tconst change = deltaY * stepSize;\n\n\t\t\t\tlet newValue = startValue + change;\n\t\t\t\tnewValue = Math.max( min, Math.min( newValue, max ) );\n\n\t\t\t\tconst precision = ( String( step ).split( '.' )[ 1 ] || [] ).length;\n\t\t\t\tthis.input.value = newValue.toFixed( precision );\n\n\t\t\t\tthis.input.dispatchEvent( new Event( 'input' ) );\n\n\t\t\t\tthis.dispatchChange();\n\n\t\t\t}\n\n\t\t} );\n\n\t\tdocument.addEventListener( 'pointerup', () => {\n\n\t\t\tisPressed = false;\n\n\t\t\tif ( isDragging ) {\n\n\t\t\t\tisDragging = false;\n\t\t\t\tdocument.body.style.cursor = 'default';\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tthis.input.value = val;\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\treturn parseFloat( this.input.value );\n\n\t}\n\n}\n\nclass ValueCheckbox extends Value {\n\n\tconstructor( { value = false } ) {\n\n\t\tsuper();\n\n\t\tconst label = document.createElement( 'label' );\n\t\tlabel.className = 'custom-checkbox';\n\n\t\tconst checkbox = document.createElement( 'input' );\n\t\tcheckbox.type = 'checkbox';\n\t\tcheckbox.checked = value;\n\t\tthis.checkbox = checkbox;\n\n\t\tconst checkmark = document.createElement( 'span' );\n\t\tcheckmark.className = 'checkmark';\n\n\t\tlabel.appendChild( checkbox );\n\t\tlabel.appendChild( checkmark );\n\t\tthis.domElement.appendChild( label );\n\n\t\tcheckbox.addEventListener( 'change', () => {\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tthis.checkbox.checked = val;\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\treturn this.checkbox.checked;\n\n\t}\n\n}\n\nclass ValueSlider extends Value {\n\n\tconstructor( { value = 0, min = 0, max = 1, step = 0.01 } ) {\n\n\t\tsuper();\n\n\t\tthis.slider = document.createElement( 'input' );\n\t\tthis.slider.type = 'range';\n\t\tthis.slider.min = min;\n\t\tthis.slider.max = max;\n\t\tthis.slider.step = step;\n\n\t\tconst numberValue = new ValueNumber( { value, min, max, step } );\n\t\tthis.numberInput = numberValue.input;\n\t\tthis.numberInput.style.flexBasis = '80px';\n\t\tthis.numberInput.style.flexShrink = '0';\n\n\t\tthis.slider.value = value;\n\n\t\tthis.domElement.append( this.slider, this.numberInput );\n\n\t\tthis.slider.addEventListener( 'input', () => {\n\n\t\t\tthis.numberInput.value = this.slider.value;\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t\tnumberValue.addEventListener( 'change', () => {\n\n\t\t\tthis.slider.value = parseFloat( this.numberInput.value );\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tthis.slider.value = val;\n\t\tthis.numberInput.value = val;\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\treturn parseFloat( this.slider.value );\n\n\t}\n\n\tstep( value ) {\n\n\t\tthis.slider.step = value;\n\t\tthis.numberInput.step = value;\n\t\tthis.slider.value = parseFloat( this.numberInput.value );\n\n\t\treturn this;\n\n\t}\n\n}\n\nclass ValueSelect extends Value {\n\n\tconstructor( { options = [], value = '' } ) {\n\n\t\tsuper();\n\n\t\tconst select = document.createElement( 'select' );\n\n\t\tconst createOption = ( name, optionValue ) => {\n\n\t\t\tconst optionEl = document.createElement( 'option' );\n\t\t\toptionEl.value = name;\n\t\t\toptionEl.textContent = name;\n\n\t\t\tif ( optionValue == value ) optionEl.selected = true;\n\n\t\t\tselect.appendChild( optionEl );\n\n\t\t\treturn optionEl;\n\n\t\t};\n\n\t\tif ( Array.isArray( options ) ) {\n\n\t\t\toptions.forEach( opt => createOption( opt, opt ) );\n\n\t\t} else {\n\n\t\t\tObject.entries( options ).forEach( ( [ key, value ] ) => createOption( key, value ) );\n\n\t\t}\n\n\t\tthis.domElement.appendChild( select );\n\n\t\t//\n\n\t\tselect.addEventListener( 'change', () => {\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t\tthis.options = options;\n\t\tthis.select = select;\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tif ( Array.isArray( this.options ) ) {\n\n\t\t\tthis.select.value = val;\n\n\t\t} else {\n\n\t\t\tconst entry = Object.entries( this.options ).find( ( [ , v ] ) => v === val );\n\n\t\t\tif ( entry ) {\n\n\t\t\t\tthis.select.value = entry[ 0 ];\n\n\t\t\t} else {\n\n\t\t\t\tthis.select.value = val;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\tconst options = this.options;\n\n\t\tif ( Array.isArray( options ) ) {\n\n\t\t\treturn options[ this.select.selectedIndex ];\n\n\t\t} else {\n\n\t\t\treturn options[ this.select.value ];\n\n\t\t}\n\n\t}\n\n}\n\nclass ValueColor extends Value {\n\n\tconstructor( { value = '#ffffff' } ) {\n\n\t\tsuper();\n\n\t\tconst colorInput = document.createElement( 'input' );\n\t\tcolorInput.type = 'color';\n\t\tcolorInput.value = this._getColorHex( value );\n\t\tthis.colorInput = colorInput;\n\n\t\tthis._value = value;\n\n\t\tcolorInput.addEventListener( 'input', () => {\n\n\t\t\tconst colorValue = colorInput.value;\n\n\t\t\tif ( this._value.isColor ) {\n\n\t\t\t\tthis._value.setHex( parseInt( colorValue.slice( 1 ), 16 ) );\n\n\t\t\t} else {\n\n\t\t\t\tthis._value = colorValue;\n\n\t\t\t}\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t\tthis.domElement.appendChild( colorInput );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tconst colorHex = this._getColorHex( val );\n\n\t\tthis.colorInput.value = colorHex;\n\n\t\tif ( this._value && this._value.isColor ) {\n\n\t\t\tthis._value.setHex( parseInt( colorHex.slice( 1 ), 16 ) );\n\n\t\t} else {\n\n\t\t\tthis._value = val;\n\n\t\t}\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\t_getColorHex( color ) {\n\n\t\tif ( color && color.isColor ) {\n\n\t\t\tcolor = color.getHex();\n\n\t\t}\n\n\t\tif ( typeof color === 'number' ) {\n\n\t\t\tcolor = '#' + color.toString( 16 ).padStart( 6, '0' );\n\n\t\t} else if ( typeof color === 'string' && color[ 0 ] !== '#' ) {\n\n\t\t\tcolor = '#' + color;\n\n\t\t}\n\n\t\treturn color;\n\n\t}\n\n\tgetValue() {\n\n\t\tlet value = this._value;\n\n\t\tif ( typeof value === 'string' ) {\n\n\t\t\tvalue = parseInt( value.slice( 1 ), 16 );\n\n\t\t}\n\n\t\treturn value;\n\n\t}\n\n}\n\nclass ValueButton extends Value {\n\n\tconstructor( { text = 'Button', value = () => {} } ) {\n\n\t\tsuper();\n\n\t\tconst button = document.createElement( 'button' );\n\t\tbutton.textContent = text;\n\t\tbutton.onclick = value;\n\t\tthis.domElement.appendChild( button );\n\n\t}\n\n}\n\nclass ValueString extends Value {\n\n\tconstructor( { value = '' } ) {\n\n\t\tsuper();\n\n\t\tconst input = document.createElement( 'input' );\n\t\tinput.type = 'text';\n\t\tinput.value = value;\n\t\tthis.input = input;\n\n\t\tinput.addEventListener( 'input', () => {\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t\tthis.domElement.appendChild( input );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tthis.input.value = val;\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\treturn this.input.value;\n\n\t}\n\n}\n\nexport { Value, ValueNumber, ValueString, ValueCheckbox, ValueSlider, ValueSelect, ValueColor, ValueButton };\n","import { Tab } from '../ui/Tab.js';\nimport { List } from '../ui/List.js';\nimport { Item } from '../ui/Item.js';\nimport { createValueSpan, info } from '../ui/utils.js';\nimport { ValueString, ValueNumber, ValueSlider, ValueSelect, ValueCheckbox, ValueColor, ValueButton } from '../ui/Values.js';\n\nclass ParametersGroup {\n\n\tconstructor( parameters, name ) {\n\n\t\tthis.parameters = parameters;\n\n\t\tthis.paramList = new Item( name );\n\t\tthis.paramList.setCollapsible( true );\n\n\t\tthis.objects = [];\n\n\t}\n\n\tclose() {\n\n\t\tthis.paramList.close();\n\n\t\treturn this;\n\n\t}\n\n\tname( name ) {\n\n\t\tthis.paramList.setValue( 0, name );\n\n\t\treturn this;\n\n\t}\n\n\tshow() {\n\n\t\tthis.paramList.show();\n\n\t\treturn this;\n\n\t}\n\n\thide() {\n\n\t\tthis.paramList.hide();\n\n\t\treturn this;\n\n\t}\n\n\tadd( object, property, ...params ) {\n\n\t\tconst value = object[ property ];\n\t\tconst type = typeof value;\n\n\t\tlet item = null;\n\n\t\tif ( typeof params[ 0 ] === 'object' ) {\n\n\t\t\titem = this.addSelect( object, property, params[ 0 ] );\n\n\t\t} else if ( type === 'number' ) {\n\n\t\t\tif ( params.length >= 2 ) {\n\n\t\t\t\titem = this.addSlider( object, property, ...params );\n\n\t\t\t} else {\n\n\t\t\t\titem = this.addNumber( object, property, ...params );\n\n\t\t\t}\n\n\t\t} else if ( type === 'boolean' ) {\n\n\t\t\titem = this.addBoolean( object, property );\n\n\t\t} else if ( type === 'string' ) {\n\n\t\t\titem = this.addString( object, property );\n\n\t\t} else if ( type === 'function' ) {\n\n\t\t\titem = this.addButton( object, property, ...params );\n\n\t\t}\n\n\t\treturn item;\n\n\t}\n\n\t_addInfo( editor, itemNode ) {\n\n\t\teditor.info = ( text ) => {\n\n\t\t\tinfo( itemNode, text );\n\t\t\treturn editor;\n\n\t\t};\n\n\t}\n\n\t_addParameter( object, property, editor, subItem ) {\n\n\t\tsubItem.data[ 0 ].title = property;\n\n\t\teditor.name = ( name ) => {\n\n\t\t\tsubItem.data[ 0 ].title = name;\n\n\t\t\tif ( subItem.data[ 0 ].childNodes.length > 0 && subItem.data[ 0 ].firstChild.nodeType === 3 /* Node.TEXT_NODE */ ) {\n\n\t\t\t\tsubItem.data[ 0 ].firstChild.textContent = name;\n\n\t\t\t} else {\n\n\t\t\t\tsubItem.data[ 0 ].insertBefore( document.createTextNode( name ), subItem.data[ 0 ].firstChild );\n\n\t\t\t}\n\n\t\t\treturn editor;\n\n\t\t};\n\n\t\tthis._addInfo( editor, subItem.data[ 0 ] );\n\n\t\teditor.listen = () => {\n\n\t\t\tconst update = () => {\n\n\t\t\t\tconst value = editor.getValue();\n\t\t\t\tconst propertyValue = object[ property ];\n\n\t\t\t\tif ( value !== propertyValue ) {\n\n\t\t\t\t\teditor.setValue( propertyValue );\n\n\t\t\t\t}\n\n\t\t\t\trequestAnimationFrame( update );\n\n\t\t\t};\n\n\t\t\trequestAnimationFrame( update );\n\n\t\t\treturn editor;\n\n\t\t};\n\n\n\t\tthis._registerParameter( object, property, editor, subItem );\n\n\t}\n\n\t_registerParameter( object, property, editor, subItem ) {\n\n\t\tthis.objects.push( { object: object, key: property, editor: editor, subItem: subItem } );\n\n\t\teditor.addEventListener( 'show', () => subItem.show() );\n\t\teditor.addEventListener( 'hide', () => subItem.hide() );\n\n\t}\n\n\taddString( object, property ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueString( { value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddFolder( name ) {\n\n\t\tconst group = new ParametersGroup( this.parameters, name );\n\n\t\tthis.paramList.add( group.paramList );\n\n\t\treturn group;\n\n\t}\n\n\taddBoolean( object, property ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueCheckbox( { value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\t// extends logic to toggle checkbox when clicking on the row\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\n\t\titemRow.classList.add( 'actionable' );\n\t\titemRow.addEventListener( 'click', ( e ) => {\n\n\t\t\tif ( e.target.closest( 'label' ) ) return;\n\n\t\t\tconst checkbox = itemRow.querySelector( 'input[type=\"checkbox\"]' );\n\n\t\t\tif ( checkbox ) {\n\n\t\t\t\tcheckbox.checked = ! checkbox.checked;\n\t\t\t\tcheckbox.dispatchEvent( new Event( 'change' ) );\n\n\t\t\t}\n\n\t\t} );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddSelect( object, property, options ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueSelect( { options, value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddColor( object, property ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueColor( { value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddSlider( object, property, min = 0, max = 1, step = 0.01 ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueSlider( { value, min, max, step } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddNumber( object, property, ...params ) {\n\n\t\tconst value = object[ property ];\n\t\tconst [ min, max ] = params;\n\n\t\tconst editor = new ValueNumber( { value, min, max } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddButton( object, property ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueButton( { text: property, value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst subItem = new Item( editor.domElement );\n\t\tsubItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\teditor.name = ( name ) => {\n\n\t\t\tconst buttonNode = editor.domElement.childNodes[ 0 ];\n\n\t\t\tif ( buttonNode.childNodes.length > 0 && buttonNode.firstChild.nodeType === 3 /* Node.TEXT_NODE */ ) {\n\n\t\t\t\tbuttonNode.firstChild.textContent = name;\n\n\t\t\t} else {\n\n\t\t\t\tbuttonNode.insertBefore( document.createTextNode( name ), buttonNode.firstChild );\n\n\t\t\t}\n\n\t\t\treturn editor;\n\n\t\t};\n\n\t\tthis._addInfo( editor, editor.domElement.childNodes[ 0 ] );\n\n\t\tthis._registerParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n}\n\nclass Parameters extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( options.name || 'Parameters', options );\n\n\t\tconst paramList = new List( 'Property', 'Value' );\n\t\tparamList.domElement.classList.add( 'parameters' );\n\t\tparamList.setGridStyle( 'minmax(0, .5fr) minmax(0, 1fr)' );\n\t\tparamList.domElement.style.minWidth = '300px';\n\n\t\tconst scrollWrapper = document.createElement( 'div' );\n\t\tscrollWrapper.className = 'list-scroll-wrapper';\n\t\tscrollWrapper.appendChild( paramList.domElement );\n\t\tthis.content.appendChild( scrollWrapper );\n\n\t\tthis.paramList = paramList;\n\n\t\tthis.groups = [];\n\n\t}\n\n\tcreateGroup( name ) {\n\n\t\tconst group = new ParametersGroup( this, name );\n\n\t\tthis.paramList.add( group.paramList );\n\t\tthis.groups.push( group );\n\n\t\treturn group;\n\n\t}\n\n}\n\nexport { Parameters };\n","import { Parameters } from './Parameters.js';\nimport { WebGPURenderer, WebGLBackend, Node } from 'three/webgpu';\nimport { getItem, setItem } from '../Storage.js';\n\nconst _extensions = [\n\t{\n\t\tname: 'Color Grading',\n\t\turl: '../extensions/color-grading/ColorGrading.js'\n\t},\n\t{\n\t\tname: 'TSL Graph',\n\t\turl: '../extensions/tsl-graph/TSLGraphEditor.js'\n\t}\n];\n\nconst _init = WebGPURenderer.prototype.init;\n\nfunction forceWebGL( enable ) {\n\n\tif ( enable ) {\n\n\t\tWebGPURenderer.prototype.init = async function () {\n\n\t\t\tif ( this.backend.isWebGLBackend !== true ) {\n\n\t\t\t\tconst parameters = this.backend.parameters;\n\n\t\t\t\tthis.backend = new WebGLBackend( parameters );\n\n\t\t\t}\n\n\t\t\treturn _init.call( this );\n\n\t\t};\n\n\t} else {\n\n\t\tWebGPURenderer.prototype.init = _init;\n\n\t}\n\n}\n\nlet _state = null;\n\nfunction _loadState() {\n\n\tif ( _state !== null ) return _state;\n\n\tconst settings = getItem( 'settings' );\n\n\t_state = {\n\t\tforceWebGL: settings.forceWebGL !== undefined ? settings.forceWebGL : false,\n\t\tcaptureStackTrace: settings.captureStackTrace !== undefined ? settings.captureStackTrace : false,\n\t\tactiveExtensions: settings.activeExtensions !== undefined ? settings.activeExtensions : {},\n\t\tstorage: settings.storage !== undefined ? settings.storage : 'url'\n\t};\n\n\tif ( _state.forceWebGL ) {\n\n\t\tforceWebGL( true );\n\n\t}\n\n\tif ( _state.captureStackTrace ) {\n\n\t\tNode.captureStackTrace = true;\n\n\t}\n\n\treturn _state;\n\n}\n\nfunction _saveState() {\n\n\tsetItem( 'settings', {\n\t\tforceWebGL: _state.forceWebGL,\n\t\tcaptureStackTrace: _state.captureStackTrace,\n\t\tactiveExtensions: _state.activeExtensions,\n\t\tstorage: _state.storage\n\t} );\n\n}\n\n_loadState();\n\n//\n\nclass Settings extends Parameters {\n\n\tconstructor() {\n\n\t\tsuper( { name: 'Settings' } );\n\n\t\tthis.extensions = {};\n\n\t\tconst currentState = _loadState();\n\n\t\t// UI\n\n\t\tconst rendererGroup = this.createGroup( 'Renderer' );\n\n\t\trendererGroup.add( currentState, 'forceWebGL' ).name( 'Force WebGL' ).onChange( ( enable ) => {\n\n\t\t\tforceWebGL( enable );\n\t\t\t_saveState();\n\n\t\t\tlocation.reload();\n\n\t\t} );\n\n\t\trendererGroup.add( currentState, 'captureStackTrace' ).name( 'Capture Stack Trace' ).onChange( ( enable ) => {\n\n\t\t\tNode.captureStackTrace = enable;\n\t\t\t_saveState();\n\n\t\t\tlocation.reload();\n\n\t\t} );\n\n\t\t// Render Modes\n\n\t\tconst modesGroup = this.createGroup( 'Render Modes' );\n\n\t\tmodesGroup.add( { overdraw: false }, 'overdraw' ).name( 'Overdraw' ).onChange( ( enable ) => {\n\n\t\t\tthis.inspector.overdraw = enable;\n\n\t\t} ).info( 'Shows how many times each pixel is shaded.' );\n\n\t}\n\n\tinit() {\n\n\t\tconst extensionsGroup = this.createGroup( 'Extensions' );\n\n\t\tconst storageGroup = this.createGroup( 'Storage' );\n\n\t\tconst currentState = _loadState();\n\n\t\tstorageGroup.add( currentState, 'storage', { 'URL Session': 'url', 'Keep across Origin': 'origin' } )\n\t\t\t.name( 'Save Settings' )\n\t\t\t.onChange( () => {\n\n\t\t\t\t_saveState();\n\n\t\t\t} ).info( `\nDefines how the **Inspector** preferences and states are stored in the browser.\n\n**URL Session**\nSaves state based on the exact URL. It will reset the settings whenever the URL changes.\n\n**Keep across Origin**\nShares the same state across any page within the current origin.` );\n\n\t\tstorageGroup.add( {\n\t\t\tclear: () => {\n\n\t\t\t\tlocalStorage.removeItem( 'threejs-inspector' );\n\n\t\t\t\tlocation.reload();\n\n\t\t\t}\n\t\t}, 'clear' ).name( 'Clear Settings' );\n\n\t\tthis._getExtensions().then( extensions => {\n\n\t\t\tfor ( const extension of extensions ) {\n\n\t\t\t\textension.active = false;\n\t\t\t\textension.loaded = false;\n\t\t\t\textension.tab = null;\n\n\t\t\t\tthis.extensions[ extension.name ] = extension;\n\n\t\t\t\textension.ui = extensionsGroup.add( { [ extension.name ]: false }, extension.name ).onChange( async ( value ) => {\n\n\t\t\t\t\tthis.setActiveExtension( extension.name, value );\n\n\t\t\t\t\t// User preference\n\n\t\t\t\t\tif ( value ) {\n\n\t\t\t\t\t\t_state.activeExtensions[ extension.name ] = {\n\t\t\t\t\t\t\tname: extension.name,\n\t\t\t\t\t\t\turl: extension.url\n\t\t\t\t\t\t};\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tdelete _state.activeExtensions[ extension.name ];\n\n\n\t\t\t\t\t}\n\n\t\t\t\t\t//\n\n\t\t\t\t\tthis._updateExtensionUI( extension );\n\n\t\t\t\t\t_saveState();\n\n\t\t\t\t} );\n\n\t\t\t\t// Set user-defined state\n\n\t\t\t\tif ( _state.activeExtensions[ extension.name ] !== undefined ) {\n\n\t\t\t\t\textension.ui.setValue( true );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tasync setActiveExtension( name, value ) {\n\n\t\tconst extension = this.extensions[ name ];\n\t\tconst inspector = this.inspector;\n\n\t\tif ( extension ) {\n\n\t\t\tif ( value ) {\n\n\t\t\t\tawait this._loadExtension( inspector, extension );\n\n\t\t\t} else {\n\n\t\t\t\tawait this._unloadExtension( inspector, extension );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t_updateExtensionUI( extension ) {\n\n\t\tconst forceActive = extension.active && _state.activeExtensions[ extension.name ] === undefined;\n\n\t\tif ( forceActive ) {\n\n\t\t\textension.ui.checkbox.checked = true;\n\t\t\textension.ui.domElement.style.setProperty( '--accent-color', 'var(--color-green)' );\n\n\t\t} else {\n\n\t\t\textension.ui.domElement.style.removeProperty( '--accent-color' );\n\n\t\t}\n\n\t}\n\n\tasync _unloadExtension( inspector, extension ) {\n\n\t\tif ( extension.active === false ) return;\n\n\t\t//\n\n\t\tinspector.removeTab( extension.tab );\n\n\t\textension.active = false;\n\t\textension.loaded = false;\n\t\textension.tab = null;\n\n\t\tthis._updateExtensionUI( extension );\n\n\t\tthis.dispatchEvent( { type: 'extensionremoved', name: extension.name } );\n\n\t}\n\n\tasync _loadExtension( inspector, extension ) {\n\n\t\tif ( extension.active === true ) return;\n\n\t\t//\n\n\t\textension.active = true;\n\n\t\tconst extUrl = new URL( extension.url, import.meta.url ).href;\n\n\t\tconst module = await import( extUrl );\n\n\t\tconst keys = Object.keys( module );\n\t\tconst ExtensionClass = module[ keys[ 0 ] ];\n\t\tconst extensionTab = new ExtensionClass();\n\n\t\tinspector.addTab( extensionTab );\n\n\t\textension.loaded = true;\n\t\textension.tab = extensionTab;\n\n\t\tthis._updateExtensionUI( extension );\n\n\t\tthis.dispatchEvent( { type: 'extensionadded', name: extension.name, tab: extensionTab } );\n\n\t}\n\n\tasync _getExtensions() {\n\n\t\treturn _extensions;\n\n\t}\n\n}\n\nexport { Settings };\n","import { Tab } from '../ui/Tab.js';\nimport { List } from '../ui/List.js';\nimport { Item } from '../ui/Item.js';\nimport { splitPath, splitCamelCase } from '../ui/utils.js';\nimport { getItem, setItem } from '../Storage.js';\n\nimport { RendererUtils, NoToneMapping, LinearSRGBColorSpace, QuadMesh, NodeMaterial, CanvasTarget, Vector2, Color } from 'three/webgpu';\nimport { renderOutput, rtt, vec2, vec3, vec4, Fn, screenUV, step, OnMaterialUpdate, uniform, float } from 'three/tsl';\n\nconst _size = /*@__PURE__*/ new Vector2();\n\nconst splitIcon = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"12\" y1=\"1\" x2=\"12\" y2=\"23\"></line><polyline points=\"5 8 1 12 5 16\"></polyline><polyline points=\"19 8 23 12 19 16\"></polyline></svg>';\nconst fullscreenIcon = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"/></svg>';\nconst backIcon = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg>';\n\nconst aspectRatioUV = /*@__PURE__*/ Fn( ( [ uv, textureNode, canvasAspect ] ) => {\n\n\tconst textureAspect = uniform( 0 );\n\n\tOnMaterialUpdate( () => {\n\n\t\tconst { width, height } = textureNode.value;\n\n\t\ttextureAspect.value = width / height;\n\n\t} );\n\n\tconst ratio = canvasAspect.div( textureAspect );\n\n\tconst centered = uv.sub( 0.5 );\n\n\t// If canvasAspect > textureAspect:\n\tconst uvWide = vec2( centered.x.mul( ratio ), centered.y ).add( 0.5 );\n\n\t// If canvasAspect <= textureAspect:\n\tconst uvTall = vec2( centered.x, centered.y.div( ratio ) ).add( 0.5 );\n\n\tconst finalUV = canvasAspect.greaterThan( textureAspect ).select( uvWide, uvTall );\n\n\tconst inBounds = step( 0.0, finalUV.x ).mul( step( finalUV.x, 1.0 ) ).mul( step( 0.0, finalUV.y ) ).mul( step( finalUV.y, 1.0 ) );\n\n\treturn vec3( finalUV, inBounds );\n\n} );\n\nclass Viewer extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Viewer', options );\n\n\t\tthis.content.style.overflow = 'hidden';\n\t\tthis.maximizedByFullscreenButton = false;\n\n\t\t// Toolbar\n\t\tconst toolbar = document.createElement( 'div' );\n\t\ttoolbar.className = 'toolbar';\n\n\t\tconst backBtn = document.createElement( 'button' );\n\t\tbackBtn.className = 'viewer-back-btn';\n\t\tbackBtn.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line><polyline points=\"12 19 5 12 12 5\"></polyline></svg>';\n\t\tbackBtn.title = 'Back';\n\t\tbackBtn.style.display = 'none';\n\t\ttoolbar.appendChild( backBtn );\n\n\t\tconst label = document.createElement( 'span' );\n\t\tlabel.textContent = 'View:';\n\t\ttoolbar.appendChild( label );\n\n\t\tconst select = document.createElement( 'select' );\n\t\tselect.className = 'select';\n\t\tselect.style.width = '200px';\n\n\t\tconst defaultOption = document.createElement( 'option' );\n\t\tdefaultOption.value = 'list';\n\t\tdefaultOption.textContent = 'List';\n\t\tselect.appendChild( defaultOption );\n\n\t\ttoolbar.appendChild( select );\n\n\t\tconst nodeList = new List( 'Viewer', 'Name' );\n\t\tnodeList.setGridStyle( '150px minmax(200px, 2fr)' );\n\t\tnodeList.domElement.style.minWidth = '400px';\n\t\tthis.nodeList = nodeList;\n\n\t\tthis.content.appendChild( toolbar );\n\n\t\tconst scrollWrapper = document.createElement( 'div' );\n\t\tscrollWrapper.className = 'list-scroll-wrapper';\n\t\tscrollWrapper.style.flexGrow = '1';\n\t\tscrollWrapper.style.overflowY = 'auto';\n\t\tscrollWrapper.style.minHeight = '0';\n\t\tscrollWrapper.appendChild( nodeList.domElement );\n\t\tthis.content.appendChild( scrollWrapper );\n\n\t\t// Container for full screen view\n\t\tconst fullViewerContainer = document.createElement( 'div' );\n\t\tfullViewerContainer.className = 'full-viewer-container';\n\t\tfullViewerContainer.style.touchAction = 'none';\n\t\tthis.content.appendChild( fullViewerContainer );\n\n\t\tconst nodes = new Item( 'User Defined' );\n\t\tnodes.setCollapsible( true );\n\t\tnodeList.add( nodes );\n\n\t\t//\n\n\t\tthis.itemLibrary = new Map();\n\t\tthis.folderLibrary = new Map();\n\t\tthis.canvasNodes = new Map();\n\t\tthis.currentDataList = [];\n\t\tthis.nodes = nodes;\n\t\tthis.scrollWrapper = scrollWrapper;\n\t\tthis.fullViewerContainer = fullViewerContainer;\n\t\tthis.select = select;\n\t\tthis.backBtn = backBtn;\n\t\tthis.activeFullNodeId = null;\n\t\tthis.pendingRestoreView = true;\n\n\t\tthis.splitActive = false;\n\t\tthis.splitCanvasData = null;\n\t\tthis.splitOverlay = null;\n\t\tthis.splitLine = null;\n\t\tthis.splitQuad = null;\n\t\tthis.splitMaterial = null;\n\t\tthis.splitUniforms = null;\n\t\tthis.splitCanvas = null;\n\t\tthis.splitCanvasTarget = null;\n\n\t\tbackBtn.addEventListener( 'click', () => {\n\n\t\t\tif ( this.splitActive ) {\n\n\t\t\t\tthis.stopSplitMode();\n\n\t\t\t}\n\n\t\t\tselect.value = 'list';\n\t\t\tthis.showListView();\n\n\t\t\tif ( this.maximizedByFullscreenButton ) {\n\n\t\t\t\tif ( this.profiler && this.profiler.panel.classList.contains( 'maximized' ) ) {\n\n\t\t\t\t\tthis.profiler.toggleMaximize();\n\n\t\t\t\t}\n\n\t\t\t\tthis.maximizedByFullscreenButton = false;\n\n\t\t\t}\n\n\t\t\tthis.saveLastView();\n\n\t\t} );\n\n\t\tselect.addEventListener( 'change', () => {\n\n\t\t\tconst val = select.value;\n\n\t\t\tif ( val === 'list' ) {\n\n\t\t\t\tthis.showListView();\n\n\t\t\t} else {\n\n\t\t\t\tthis.showNodeView( val );\n\n\t\t\t}\n\n\t\t\tthis.saveLastView();\n\n\t\t} );\n\n\t\t// Event forwarding setup for OrbitControls\n\t\tthis.isDraggingThumbnail = false;\n\t\tthis.activeSourceCanvas = null;\n\t\tthis.activePointerIds = new Set();\n\n\t\tconst handleGlobalPointer = ( e ) => {\n\n\t\t\tif ( ! this.isDraggingThumbnail || ! this.activeSourceCanvas ) return;\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\tif ( e.isForwarded ) return;\n\n\t\t\t// Block native event from reaching other document-level listeners (OrbitControls)\n\t\t\te.stopImmediatePropagation();\n\t\t\te.preventDefault();\n\n\t\t\t// Project and dispatch forwarded event\n\t\t\tthis.forwardEvent( e, this.activeSourceCanvas, renderer.domElement );\n\n\t\t\tif ( e.type === 'pointerup' || e.type === 'pointercancel' ) {\n\n\t\t\t\tthis.activePointerIds.delete( e.pointerId );\n\n\t\t\t\tif ( this.activePointerIds.size === 0 ) {\n\n\t\t\t\t\tthis.isDraggingThumbnail = false;\n\t\t\t\t\tthis.activeSourceCanvas = null;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\twindow.addEventListener( 'pointermove', handleGlobalPointer, true );\n\t\twindow.addEventListener( 'pointerup', handleGlobalPointer, true );\n\t\twindow.addEventListener( 'pointercancel', handleGlobalPointer, true );\n\n\t}\n\n\tgetFolder( name ) {\n\n\t\tlet folder = this.folderLibrary.get( name );\n\n\t\tif ( folder === undefined ) {\n\n\t\t\tfolder = new Item( name );\n\t\t\tfolder.setCollapsible( true );\n\n\t\t\tthis.folderLibrary.set( name, folder );\n\t\t\tthis.nodeList.add( folder );\n\n\t\t}\n\n\t\treturn folder;\n\n\t}\n\n\thide() {\n\n\t\tsuper.hide();\n\t\tthis.maximizedByFullscreenButton = false;\n\t\tthis.isDraggingThumbnail = false;\n\t\tthis.activeSourceCanvas = null;\n\t\tthis.activePointerIds.clear();\n\n\t\tif ( this.splitActive ) {\n\n\t\t\tthis.stopSplitMode();\n\n\t\t}\n\n\t}\n\n\taddNodeItem( canvasData ) {\n\n\t\tlet item = this.itemLibrary.get( canvasData.id );\n\n\t\tif ( item === undefined ) {\n\n\t\t\tconst name = canvasData.name;\n\t\t\tconst domElement = canvasData.canvasTarget.domElement;\n\n\t\t\t// Create wrapper\n\t\t\tconst wrapper = document.createElement( 'div' );\n\t\t\twrapper.className = 'node-canvas-wrapper';\n\t\t\twrapper.style.position = 'relative';\n\t\t\twrapper.style.display = 'inline-block';\n\t\t\twrapper.style.width = '140px';\n\t\t\twrapper.style.height = '140px';\n\t\t\twrapper.style.touchAction = 'none';\n\n\t\t\t// View full screen button\n\t\t\tconst viewBtn = document.createElement( 'button' );\n\t\t\tviewBtn.className = 'node-canvas-detach-btn';\n\t\t\tviewBtn.title = 'View full size';\n\t\t\tviewBtn.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"7\" y1=\"17\" x2=\"17\" y2=\"7\"></line><polyline points=\"7 7 17 7 17 17\"></polyline></svg>';\n\n\t\t\tviewBtn.onclick = ( e ) => {\n\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tif ( this.splitActive ) {\n\n\t\t\t\t\tthis.stopSplitMode();\n\n\t\t\t\t}\n\n\t\t\t\tthis.select.value = canvasData.id;\n\t\t\t\tthis.showNodeView( canvasData.id );\n\t\t\t\tthis.saveLastView();\n\n\t\t\t};\n\n\t\t\t// Fullscreen and maximize button\n\t\t\tconst fullscreenBtn = document.createElement( 'button' );\n\t\t\tfullscreenBtn.className = 'node-canvas-fullscreen-btn';\n\t\t\tfullscreenBtn.title = 'Fullscreen view';\n\t\t\tfullscreenBtn.innerHTML = fullscreenIcon;\n\n\t\t\tfullscreenBtn.onclick = ( e ) => {\n\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tif ( this.splitActive && this.splitCanvasData === canvasData && this.splitFullscreen ) {\n\n\t\t\t\t\tthis.stopSplitMode();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis.splitFullscreen = true;\n\t\t\t\t\tthis.startSplitMode( canvasData );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t\t// Split screen button\n\t\t\tconst splitBtn = document.createElement( 'button' );\n\t\t\tsplitBtn.className = 'node-canvas-split-btn';\n\t\t\tsplitBtn.title = 'Interactive split screen';\n\t\t\tsplitBtn.innerHTML = splitIcon;\n\n\t\t\tsplitBtn.onclick = ( e ) => {\n\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tif ( this.splitActive && this.splitCanvasData === canvasData && ! this.splitFullscreen ) {\n\n\t\t\t\t\tthis.stopSplitMode();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis.splitFullscreen = false;\n\t\t\t\t\tthis.startSplitMode( canvasData );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t\twrapper.appendChild( domElement );\n\t\t\twrapper.appendChild( viewBtn );\n\t\t\twrapper.appendChild( fullscreenBtn );\n\t\t\twrapper.appendChild( splitBtn );\n\n\t\t\tthis.setupEventForwarding( domElement );\n\n\t\t\t// Store elements in canvasData for access\n\t\t\tcanvasData.domElement = domElement;\n\t\t\tcanvasData.wrapperElement = wrapper;\n\t\t\tcanvasData.splitBtn = splitBtn;\n\t\t\tcanvasData.fullscreenBtn = fullscreenBtn;\n\n\t\t\titem = new Item( wrapper, name );\n\t\t\titem.itemRow.children[ 1 ].style[ 'justify-content' ] = 'flex-start';\n\t\t\tthis.itemLibrary.set( canvasData.id, item );\n\n\t\t}\n\n\t\treturn item;\n\n\t}\n\n\tsetupEventForwarding( sourceCanvas ) {\n\n\t\tsourceCanvas.style.touchAction = 'none';\n\n\t\tconst onPointerDown = ( e ) => {\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\tif ( ! renderer || ! renderer.domElement ) return;\n\n\t\t\tconst targetCanvas = renderer.domElement;\n\n\t\t\tthis.isDraggingThumbnail = true;\n\t\t\tthis.activeSourceCanvas = sourceCanvas;\n\t\t\tthis.activePointerIds.add( e.pointerId );\n\n\t\t\t// Project and dispatch pointerdown\n\t\t\tthis.forwardEvent( e, sourceCanvas, targetCanvas );\n\n\t\t};\n\n\t\tsourceCanvas.addEventListener( 'pointerdown', onPointerDown );\n\n\t\t// Wheel event support for zooming\n\t\tconst onWheel = ( e ) => {\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\tif ( ! renderer || ! renderer.domElement ) return;\n\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\n\t\t\tthis.forwardEvent( e, sourceCanvas, renderer.domElement );\n\n\t\t};\n\n\t\tsourceCanvas.addEventListener( 'wheel', onWheel, { passive: false } );\n\n\t\t// Click, dblclick, contextmenu\n\t\tconst onMouseShortcut = ( e ) => {\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\tif ( ! renderer || ! renderer.domElement ) return;\n\n\t\t\te.stopPropagation();\n\n\t\t\tif ( e.type === 'contextmenu' ) {\n\n\t\t\t\te.preventDefault();\n\n\t\t\t}\n\n\t\t\tthis.forwardEvent( e, sourceCanvas, renderer.domElement );\n\n\t\t};\n\n\t\tsourceCanvas.addEventListener( 'click', onMouseShortcut );\n\t\tsourceCanvas.addEventListener( 'dblclick', onMouseShortcut );\n\t\tsourceCanvas.addEventListener( 'contextmenu', onMouseShortcut );\n\n\t}\n\n\tforwardEvent( event, sourceCanvas, targetCanvas ) {\n\n\t\tconst sourceRect = sourceCanvas.getBoundingClientRect();\n\t\tconst targetRect = targetCanvas.getBoundingClientRect();\n\n\t\tconst localX = ( event.clientX - sourceRect.left ) / sourceRect.width;\n\t\tconst localY = ( event.clientY - sourceRect.top ) / sourceRect.height;\n\n\t\tconst targetClientX = targetRect.left + localX * targetRect.width;\n\t\tconst targetClientY = targetRect.top + localY * targetRect.height;\n\t\tconst targetPageX = targetClientX + window.scrollX;\n\t\tconst targetPageY = targetClientY + window.scrollY;\n\n\t\tlet newEvent;\n\n\t\tconst eventInit = {\n\t\t\tbubbles: true,\n\t\t\tcancelable: true,\n\t\t\tview: window,\n\t\t\tclientX: targetClientX,\n\t\t\tclientY: targetClientY,\n\t\t\tscreenX: targetClientX + window.screenX,\n\t\t\tscreenY: targetClientY + window.screenY,\n\t\t\tpageX: targetPageX,\n\t\t\tpageY: targetPageY,\n\t\t\tctrlKey: event.ctrlKey,\n\t\t\tshiftKey: event.shiftKey,\n\t\t\taltKey: event.altKey,\n\t\t\tmetaKey: event.metaKey,\n\t\t\tbuttons: event.buttons,\n\t\t\tbutton: event.button\n\t\t};\n\n\t\tif ( event instanceof WheelEvent ) {\n\n\t\t\tnewEvent = new WheelEvent( event.type, {\n\t\t\t\t...eventInit,\n\t\t\t\tdeltaX: event.deltaX,\n\t\t\t\tdeltaY: event.deltaY,\n\t\t\t\tdeltaZ: event.deltaZ,\n\t\t\t\tdeltaMode: event.deltaMode\n\t\t\t} );\n\n\t\t} else if ( window.PointerEvent && event instanceof PointerEvent ) {\n\n\t\t\tnewEvent = new PointerEvent( event.type, {\n\t\t\t\t...eventInit,\n\t\t\t\tpointerId: event.pointerId,\n\t\t\t\twidth: event.width,\n\t\t\t\theight: event.height,\n\t\t\t\tpressure: event.pressure,\n\t\t\t\ttiltX: event.tiltX,\n\t\t\t\ttiltY: event.tiltY,\n\t\t\t\tpointerType: event.pointerType,\n\t\t\t\tisPrimary: event.isPrimary\n\t\t\t} );\n\n\t\t} else {\n\n\t\t\tnewEvent = new MouseEvent( event.type, eventInit );\n\n\t\t}\n\n\t\tnewEvent.isForwarded = true;\n\t\ttargetCanvas.dispatchEvent( newEvent );\n\n\t}\n\n\tinit( inspector ) {\n\n\t\tsuper.init( inspector );\n\n\t\tconst updateLayoutFromPosition = () => {\n\n\t\t\tconst position = inspector.profiler.position;\n\t\t\tconst isHorizontal = position === 'top' || position === 'bottom';\n\t\t\tthis.setViewMode( isHorizontal ? 'grid' : 'list' );\n\n\t\t};\n\n\t\tinspector.profiler.addEventListener( 'resize', updateLayoutFromPosition );\n\n\t\t// Run initially once\n\t\tupdateLayoutFromPosition();\n\n\t}\n\n\tsetViewMode( mode ) {\n\n\t\tif ( this.nodeList ) {\n\n\t\t\tif ( mode === 'grid' ) {\n\n\t\t\t\tthis.nodeList.domElement.style.minWidth = '0';\n\n\t\t\t} else {\n\n\t\t\t\tthis.nodeList.domElement.style.minWidth = '400px';\n\n\t\t\t}\n\n\t\t\tthis.nodeList.setViewMode( mode );\n\n\t\t}\n\n\t}\n\n\tshowListView() {\n\n\t\tif ( this.activeFullNodeId ) {\n\n\t\t\tconst canvasData = Array.from( this.canvasNodes.values() ).find( data => String( data.id ) === String( this.activeFullNodeId ) );\n\n\t\t\tif ( canvasData ) {\n\n\t\t\t\t// Move canvas back to wrapper\n\t\t\t\tcanvasData.wrapperElement.appendChild( canvasData.domElement );\n\n\t\t\t\t// Reset size\n\t\t\t\tcanvasData.domElement.style.width = '';\n\t\t\t\tcanvasData.domElement.style.height = '';\n\t\t\t\tcanvasData.canvasTarget.setSize( 140, 140 );\n\n\t\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\t\trenderer.backend.delete( canvasData.canvasTarget );\n\n\t\t\t}\n\n\t\t\tthis.activeFullNodeId = null;\n\n\t\t}\n\n\t\tthis.scrollWrapper.style.display = '';\n\t\tthis.fullViewerContainer.style.display = 'none';\n\t\tthis.backBtn.style.display = 'none';\n\n\t}\n\n\tshowNodeView( nodeId ) {\n\n\t\t// First restore previous full screen node if any\n\t\tif ( this.activeFullNodeId && String( this.activeFullNodeId ) !== String( nodeId ) ) {\n\n\t\t\tthis.showListView();\n\n\t\t}\n\n\t\tconst canvasData = Array.from( this.canvasNodes.values() ).find( data => String( data.id ) === String( nodeId ) );\n\n\t\tif ( canvasData ) {\n\n\t\t\tthis.addNodeItem( canvasData );\n\n\t\t\tthis.activeFullNodeId = nodeId;\n\t\t\tthis.backBtn.style.display = 'flex';\n\n\t\t\t// Hide list, show full screen container\n\t\t\tthis.scrollWrapper.style.display = 'none';\n\t\t\tthis.fullViewerContainer.style.display = 'flex';\n\n\t\t\t// Move canvas to the full viewer container\n\t\t\tthis.fullViewerContainer.appendChild( canvasData.domElement );\n\t\t\tcanvasData.domElement.style.width = '100%';\n\t\t\tcanvasData.domElement.style.height = '100%';\n\n\t\t\t// Resize canvas to fit full viewer container\n\t\t\tconst rect = this.fullViewerContainer.getBoundingClientRect();\n\t\t\tconst contentWidth = rect.width || this.content.clientWidth;\n\t\t\tconst contentHeight = rect.height || ( this.content.clientHeight - 38 ); // minus toolbar\n\t\t\tcanvasData.canvasTarget.setSize( contentWidth, contentHeight );\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\trenderer.backend.delete( canvasData.canvasTarget );\n\n\t\t}\n\n\t}\n\n\tget isActive() {\n\n\t\tif ( this.splitActive ) return true;\n\n\t\treturn super.isActive;\n\n\t}\n\n\tset isActive( value ) {\n\n\t\tsuper.isActive = value;\n\n\t}\n\n\tstartSplitMode( canvasData ) {\n\n\t\tif ( this.profiler && this.profiler.panel.classList.contains( 'visible' ) ) {\n\n\t\t\tthis.profiler.togglePanel();\n\n\t\t}\n\n\t\tthis.splitActive = true;\n\t\tthis.splitCanvasData = canvasData;\n\t\tthis.splitX = 0.5;\n\n\t\tconst renderer = this.inspector.getRenderer();\n\t\tconst mainCanvas = renderer.domElement;\n\t\tconst rect = mainCanvas.getBoundingClientRect();\n\t\tconst targetParent = document.fullscreenElement || this.profiler.domElement;\n\t\tconst parentRect = targetParent.getBoundingClientRect();\n\t\tconst localLeft = rect.left - parentRect.left;\n\t\tconst localTop = rect.top - parentRect.top;\n\n\t\t// Position target canvas on top of main canvas\n\t\tif ( ! this.splitCanvas ) {\n\n\t\t\tthis.splitCanvas = document.createElement( 'canvas' );\n\t\t\tthis.splitCanvas.style.position = 'absolute';\n\t\t\tthis.splitCanvas.style.pointerEvents = 'none';\n\t\t\tthis.splitCanvas.style.zIndex = '998';\n\n\t\t\tthis.splitCanvasTarget = new CanvasTarget( this.splitCanvas );\n\t\t\tthis.splitCanvasTarget.setPixelRatio( window.devicePixelRatio );\n\n\t\t}\n\n\t\tthis.splitCanvas.style.left = `${ localLeft }px`;\n\t\tthis.splitCanvas.style.top = `${ localTop }px`;\n\t\tthis.splitCanvas.style.width = `${ rect.width }px`;\n\t\tthis.splitCanvas.style.height = `${ rect.height }px`;\n\n\t\tthis.splitCanvasTarget.setSize( rect.width, rect.height );\n\t\trenderer.backend.delete( this.splitCanvasTarget );\n\n\t\ttargetParent.appendChild( this.splitCanvas );\n\n\t\t// Overlay divider line (only in split/non-fullscreen mode)\n\t\tif ( ! this.splitFullscreen ) {\n\n\t\t\tif ( ! this.splitOverlay ) {\n\n\t\t\t\tconst overlay = document.createElement( 'div' );\n\t\t\t\toverlay.className = 'split-screen-overlay three-inspector';\n\n\t\t\t\tconst line = document.createElement( 'div' );\n\t\t\t\tline.className = 'split-screen-line';\n\n\t\t\t\toverlay.appendChild( line );\n\n\t\t\t\tlet isDragging = false;\n\n\t\t\t\tconst onPointerDown = ( e ) => {\n\n\t\t\t\t\tisDragging = true;\n\t\t\t\t\tline.classList.add( 'active' );\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t};\n\n\t\t\t\tconst onPointerMove = ( e ) => {\n\n\t\t\t\t\tif ( ! isDragging ) return;\n\n\t\t\t\t\tconst r = mainCanvas.getBoundingClientRect();\n\t\t\t\t\tconst localX = e.clientX - r.left;\n\t\t\t\t\tconst pct = Math.max( 0, Math.min( 1, localX / r.width ) );\n\t\t\t\t\tthis.splitX = pct;\n\t\t\t\t\tline.style.left = `${ pct * 100 }%`;\n\n\t\t\t\t\tif ( this.splitUniforms && this.splitUniforms.splitX ) {\n\n\t\t\t\t\t\tthis.splitUniforms.splitX.value = pct;\n\n\t\t\t\t\t}\n\n\t\t\t\t};\n\n\t\t\t\tconst onPointerUp = () => {\n\n\t\t\t\t\tisDragging = false;\n\t\t\t\t\tline.classList.remove( 'active' );\n\n\t\t\t\t};\n\n\t\t\t\tline.addEventListener( 'pointerdown', onPointerDown );\n\t\t\t\twindow.addEventListener( 'pointermove', onPointerMove );\n\t\t\t\twindow.addEventListener( 'pointerup', onPointerUp );\n\n\t\t\t\tthis.splitOverlay = overlay;\n\t\t\t\tthis.splitLine = line;\n\n\t\t\t}\n\n\t\t\tthis.splitOverlay.style.left = `${ localLeft }px`;\n\t\t\tthis.splitOverlay.style.top = `${ localTop }px`;\n\t\t\tthis.splitOverlay.style.width = `${ rect.width }px`;\n\t\t\tthis.splitOverlay.style.height = `${ rect.height }px`;\n\t\t\tthis.splitLine.style.left = '50%';\n\n\t\t\ttargetParent.appendChild( this.splitOverlay );\n\n\t\t} else {\n\n\t\t\t// If we transitioned from split to fullscreen, remove the overlay slider\n\t\t\tif ( this.splitOverlay && this.splitOverlay.parentElement ) {\n\n\t\t\t\tthis.splitOverlay.parentElement.removeChild( this.splitOverlay );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( ! this.splitUniforms ) {\n\n\t\t\tthis.splitUniforms = {\n\t\t\t\tsplitX: uniform( 0.5 ),\n\t\t\t\tviewportWidth: uniform( rect.width )\n\t\t\t};\n\n\t\t}\n\n\t\tthis.splitUniforms.splitX.value = 0.5;\n\t\tthis.splitUniforms.viewportWidth.value = rect.width;\n\n\t\t// Recreate or setup material for split screen comparison\n\t\tconst target = canvasData.inspectNode.context( { getUV: () => screenUV } );\n\t\tconst targetColor = renderOutput( vec4( vec3( target ), 1 ), NoToneMapping, renderer.outputColorSpace );\n\n\t\tlet finalColor;\n\n\t\tif ( this.splitFullscreen ) {\n\n\t\t\tfinalColor = targetColor;\n\n\t\t} else {\n\n\t\t\tfinalColor = Fn( () => {\n\n\t\t\t\tscreenUV.x.lessThan( this.splitUniforms.splitX ).discard();\n\n\t\t\t\treturn targetColor;\n\n\t\t\t} )();\n\n\t\t}\n\n\t\tif ( this.splitMaterial ) {\n\n\t\t\tthis.splitMaterial.dispose();\n\n\t\t}\n\n\t\tthis.splitMaterial = new NodeMaterial();\n\t\tthis.splitMaterial.outputNode = finalColor;\n\t\tthis.splitMaterial.depthTest = false;\n\t\tthis.splitMaterial.depthWrite = false;\n\n\t\tif ( this.splitQuad ) {\n\n\t\t\tthis.splitQuad.material = this.splitMaterial;\n\n\t\t} else {\n\n\t\t\tthis.splitQuad = new QuadMesh( this.splitMaterial );\n\n\t\t}\n\n\t\tthis.updateSplitButtonsState();\n\n\t}\n\n\tstopSplitMode() {\n\n\t\tthis.splitActive = false;\n\t\tthis.splitCanvasData = null;\n\t\tthis.splitFullscreen = false;\n\n\t\tif ( this.splitOverlay && this.splitOverlay.parentElement ) {\n\n\t\t\tthis.splitOverlay.parentElement.removeChild( this.splitOverlay );\n\n\t\t}\n\n\t\tif ( this.splitCanvas && this.splitCanvas.parentElement ) {\n\n\t\t\tthis.splitCanvas.parentElement.removeChild( this.splitCanvas );\n\n\t\t}\n\n\t\tthis.updateSplitButtonsState();\n\n\t}\n\n\tupdateSplitButtonsState() {\n\n\t\tif ( this.splitActive ) {\n\n\t\t\tthis.backBtn.style.display = '';\n\n\t\t} else {\n\n\t\t\tif ( this.select.value === 'list' ) {\n\n\t\t\t\tthis.backBtn.style.display = 'none';\n\n\t\t\t} else {\n\n\t\t\t\tthis.backBtn.style.display = '';\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( const canvasData of this.canvasNodes.values() ) {\n\n\t\t\tif ( ! canvasData.splitBtn || ! canvasData.fullscreenBtn ) continue;\n\n\t\t\tconst isSelected = this.splitActive && this.splitCanvasData === canvasData;\n\n\t\t\tif ( isSelected ) {\n\n\t\t\t\tif ( this.splitFullscreen ) {\n\n\t\t\t\t\tcanvasData.fullscreenBtn.classList.add( 'active' );\n\t\t\t\t\tcanvasData.fullscreenBtn.innerHTML = backIcon;\n\t\t\t\t\tcanvasData.fullscreenBtn.title = 'Exit Fullscreen';\n\n\t\t\t\t\tcanvasData.splitBtn.classList.remove( 'active' );\n\t\t\t\t\tcanvasData.splitBtn.innerHTML = splitIcon;\n\t\t\t\t\tcanvasData.splitBtn.title = 'Interactive split screen';\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcanvasData.splitBtn.classList.add( 'active' );\n\t\t\t\t\tcanvasData.splitBtn.innerHTML = backIcon;\n\t\t\t\t\tcanvasData.splitBtn.title = 'Exit Split Screen';\n\n\t\t\t\t\tcanvasData.fullscreenBtn.classList.remove( 'active' );\n\t\t\t\t\tcanvasData.fullscreenBtn.innerHTML = fullscreenIcon;\n\t\t\t\t\tcanvasData.fullscreenBtn.title = 'Fullscreen view';\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tcanvasData.splitBtn.classList.remove( 'active' );\n\t\t\t\tcanvasData.splitBtn.innerHTML = splitIcon;\n\t\t\t\tcanvasData.splitBtn.title = 'Interactive split screen';\n\n\t\t\t\tcanvasData.fullscreenBtn.classList.remove( 'active' );\n\t\t\t\tcanvasData.fullscreenBtn.innerHTML = fullscreenIcon;\n\t\t\t\tcanvasData.fullscreenBtn.title = 'Fullscreen view';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tgetCanvasDataByNode( renderer, node ) {\n\n\t\tlet canvasData = this.canvasNodes.get( node );\n\n\t\tif ( canvasData === undefined ) {\n\n\t\t\tconst canvas = document.createElement( 'canvas' );\n\n\t\t\tconst canvasTarget = new CanvasTarget( canvas );\n\t\t\tcanvasTarget.setPixelRatio( window.devicePixelRatio );\n\t\t\tcanvasTarget.setSize( 140, 140 );\n\n\t\t\tconst id = node.id;\n\n\t\t\tconst { path, name } = splitPath( splitCamelCase( node.getName() || '(unnamed)' ) );\n\n\t\t\tconst canvasAspect = uniform( 1 );\n\t\t\tconst mask = float( 1 );\n\n\t\t\tlet inspectNode = node.callback !== null ? node.callback( node.node ) : node.node;\n\t\t\tlet rttNode = null;\n\n\t\t\tif ( inspectNode.isTextureNode !== true && inspectNode.isPassNode !== true ) {\n\n\t\t\t\t// render other nodes in the resolution of the renderer, e.g. screen-space nodes\n\n\t\t\t\trttNode = rtt( inspectNode );\n\t\t\t\trttNode.uvNode = null; // use the aspect ratio corrected uv of the viewer\n\n\t\t\t\tinspectNode = rttNode;\n\n\t\t\t}\n\n\t\t\tconst target = inspectNode.context( { getUV: ( textureNode ) => {\n\n\t\t\t\tconst uvData = aspectRatioUV( screenUV, textureNode, canvasAspect );\n\t\t\t\tconst correctedUV = uvData.xy;\n\t\t\t\tmask.assign( uvData.z );\n\n\t\t\t\treturn correctedUV;\n\n\t\t\t} } );\n\n\t\t\tlet output = vec4( vec3( target ), 1 ).mul( mask );\n\t\t\toutput = renderOutput( output, NoToneMapping, renderer.outputColorSpace );\n\n\t\t\tconst material = new NodeMaterial();\n\t\t\tmaterial.outputNode = output;\n\n\t\t\tconst quad = new QuadMesh( material );\n\t\t\tquad.name = 'Viewer - ' + name;\n\n\t\t\tcanvasData = {\n\t\t\t\tid,\n\t\t\t\tname,\n\t\t\t\tpath,\n\t\t\t\tnode,\n\t\t\t\tinspectNode,\n\t\t\t\trttNode,\n\t\t\t\tquad,\n\t\t\t\tcanvasTarget,\n\t\t\t\tmaterial,\n\t\t\t\tcanvasAspect\n\t\t\t};\n\n\t\t\tthis.canvasNodes.set( node, canvasData );\n\n\t\t}\n\n\t\treturn canvasData;\n\n\t}\n\n\tupdate( inspector ) {\n\n\t\tconst renderer = inspector.getRenderer();\n\n\t\tif ( this.splitActive ) {\n\n\t\t\tconst mainCanvas = renderer.domElement;\n\t\t\tconst rect = mainCanvas.getBoundingClientRect();\n\n\t\t\tif ( rect.width <= 0 || rect.height <= 0 ) {\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tconst targetParent = document.fullscreenElement || this.profiler.domElement;\n\t\t\tconst parentRect = targetParent.getBoundingClientRect();\n\t\t\tconst localLeft = rect.left - parentRect.left;\n\t\t\tconst localTop = rect.top - parentRect.top;\n\n\t\t\tif ( this.splitCanvas.parentElement !== targetParent ) {\n\n\t\t\t\ttargetParent.appendChild( this.splitCanvas );\n\n\t\t\t}\n\n\t\t\tif ( this.splitOverlay && ! this.splitFullscreen && this.splitOverlay.parentElement !== targetParent ) {\n\n\t\t\t\ttargetParent.appendChild( this.splitOverlay );\n\n\t\t\t}\n\n\t\t\tthis.splitCanvas.style.left = `${ localLeft }px`;\n\t\t\tthis.splitCanvas.style.top = `${ localTop }px`;\n\t\t\tthis.splitCanvas.style.width = `${ rect.width }px`;\n\t\t\tthis.splitCanvas.style.height = `${ rect.height }px`;\n\n\t\t\tif ( this.splitOverlay && ! this.splitFullscreen ) {\n\n\t\t\t\tthis.splitOverlay.style.left = `${ localLeft }px`;\n\t\t\t\tthis.splitOverlay.style.top = `${ localTop }px`;\n\t\t\t\tthis.splitOverlay.style.width = `${ rect.width }px`;\n\t\t\t\tthis.splitOverlay.style.height = `${ rect.height }px`;\n\n\t\t\t}\n\n\t\t\tif ( this.splitCanvasTarget.width !== rect.width || this.splitCanvasTarget.height !== rect.height ) {\n\n\t\t\t\tthis.splitCanvasTarget.setSize( rect.width, rect.height );\n\n\t\t\t\tif ( this.splitUniforms && this.splitUniforms.viewportWidth ) {\n\n\t\t\t\t\tthis.splitUniforms.viewportWidth.value = rect.width;\n\n\t\t\t\t}\n\n\t\t\t\trenderer.backend.delete( this.splitCanvasTarget );\n\n\t\t\t}\n\n\t\t\t// Render the split quad to the splitCanvasTarget\n\t\t\tconst previousCanvasTarget = renderer.getCanvasTarget();\n\t\t\tconst previousClearColor = renderer.getClearColor( new Color() );\n\t\t\tconst previousClearAlpha = renderer.getClearAlpha();\n\n\t\t\tconst state = RendererUtils.resetRendererState( renderer );\n\n\t\t\trenderer.toneMapping = NoToneMapping;\n\t\t\trenderer.outputColorSpace = LinearSRGBColorSpace;\n\n\t\t\trenderer.setCanvasTarget( this.splitCanvasTarget );\n\t\t\trenderer.setClearColor( 0x000000, 0 );\n\n\t\t\tthis.splitQuad.render( renderer );\n\n\t\t\trenderer.setCanvasTarget( previousCanvasTarget );\n\t\t\trenderer.setClearColor( previousClearColor, previousClearAlpha );\n\n\t\t\tRendererUtils.restoreRendererState( renderer, state );\n\n\t\t}\n\n\t\tconst nodes = inspector.getNodes();\n\n\t\tif ( nodes.length > 0 ) {\n\n\t\t\tif ( ! renderer.backend.isWebGPUBackend ) {\n\n\t\t\t\t// Viewer is only available with WebGPU.\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( ! this.isVisible ) {\n\n\t\t\t\tthis.show();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( ! this.isActive ) return;\n\n\t\tconst canvasDataList = nodes.map( node => this.getCanvasDataByNode( renderer, node ) );\n\n\t\t// Check if the list of nodes has changed\n\t\tlet nodesChanged = canvasDataList.length !== this.currentDataList.length;\n\n\t\tif ( ! nodesChanged ) {\n\n\t\t\tfor ( let i = 0; i < canvasDataList.length; i ++ ) {\n\n\t\t\t\tif ( canvasDataList[ i ].id !== this.currentDataList[ i ].id ) {\n\n\t\t\t\t\tnodesChanged = true;\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( nodesChanged ) {\n\n\t\t\tconst currentSelectedValue = this.select.value;\n\n\t\t\t// Clear options except the first one ('list')\n\t\t\twhile ( this.select.options.length > 1 ) {\n\n\t\t\t\tthis.select.remove( 1 );\n\n\t\t\t}\n\n\t\t\t// Add options for each node in canvasDataList\n\t\t\tfor ( const canvasData of canvasDataList ) {\n\n\t\t\t\tconst option = document.createElement( 'option' );\n\t\t\t\toption.value = canvasData.id;\n\t\t\t\toption.textContent = canvasData.path ? `${ canvasData.path } / ${ canvasData.name }` : canvasData.name;\n\t\t\t\tthis.select.appendChild( option );\n\n\t\t\t}\n\n\t\t\t// Try to restore from saved view first on initial load\n\t\t\tlet restored = false;\n\n\t\t\tif ( this.pendingRestoreView ) {\n\n\t\t\t\tconst savedView = getItem( 'viewerLastView' );\n\n\t\t\t\tif ( savedView !== 'list' ) {\n\n\t\t\t\t\tfor ( let i = 0; i < this.select.options.length; i ++ ) {\n\n\t\t\t\t\t\tif ( this.select.options[ i ].textContent === savedView ) {\n\n\t\t\t\t\t\t\tthis.select.selectedIndex = i;\n\t\t\t\t\t\t\tconst nodeId = this.select.options[ i ].value;\n\t\t\t\t\t\t\tthis.showNodeView( nodeId );\n\t\t\t\t\t\t\trestored = true;\n\t\t\t\t\t\t\tthis.pendingRestoreView = false;\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis.pendingRestoreView = false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( ! restored ) {\n\n\t\t\t\t// Restore selection if still valid\n\t\t\t\tlet hasSelectedValue = false;\n\n\t\t\t\tfor ( let i = 0; i < this.select.options.length; i ++ ) {\n\n\t\t\t\t\tif ( this.select.options[ i ].value === currentSelectedValue ) {\n\n\t\t\t\t\t\tthis.select.selectedIndex = i;\n\t\t\t\t\t\thasSelectedValue = true;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! hasSelectedValue ) {\n\n\t\t\t\t\tthis.select.value = 'list';\n\t\t\t\t\tthis.showListView();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Real-time resize of active full-screen node canvas target\n\t\tif ( this.activeFullNodeId ) {\n\n\t\t\tconst canvasData = canvasDataList.find( data => String( data.id ) === String( this.activeFullNodeId ) );\n\n\t\t\tif ( canvasData ) {\n\n\t\t\t\tconst rect = this.fullViewerContainer.getBoundingClientRect();\n\t\t\t\tconst contentWidth = rect.width || this.content.clientWidth;\n\t\t\t\tconst contentHeight = rect.height || ( this.content.clientHeight - 38 );\n\n\t\t\t\tif ( canvasData.canvasTarget.domElement.width !== contentWidth || canvasData.canvasTarget.domElement.height !== contentHeight ) {\n\n\t\t\t\t\tcanvasData.canvasTarget.setSize( contentWidth, contentHeight );\n\n\t\t\t\t\trenderer.backend.delete( canvasData.canvasTarget );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tconst previousDataList = [ ...this.currentDataList ];\n\n\t\t// remove old\n\n\t\tfor ( const canvasData of previousDataList ) {\n\n\t\t\tif ( this.itemLibrary.has( canvasData.id ) && canvasDataList.indexOf( canvasData ) === - 1 ) {\n\n\t\t\t\tconst item = this.itemLibrary.get( canvasData.id );\n\t\t\t\tconst parent = item.parent;\n\n\t\t\t\tparent.remove( item );\n\n\t\t\t\tif ( this.folderLibrary.has( parent.data[ 0 ] ) && parent.children.length === 0 ) {\n\n\t\t\t\t\tparent.parent.remove( parent );\n\n\t\t\t\t\tthis.folderLibrary.delete( parent.data[ 0 ] );\n\n\t\t\t\t}\n\n\t\t\t\tthis.itemLibrary.delete( canvasData.id );\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tconst indexes = {};\n\n\t\tfor ( const canvasData of canvasDataList ) {\n\n\t\t\tconst item = this.addNodeItem( canvasData );\n\t\t\tconst previousCanvasTarget = renderer.getCanvasTarget();\n\n\t\t\tconst path = canvasData.path;\n\n\t\t\tif ( path ) {\n\n\t\t\t\tconst folder = this.getFolder( path );\n\n\t\t\t\tif ( indexes[ path ] === undefined ) {\n\n\t\t\t\t\tindexes[ path ] = 0;\n\n\t\t\t\t}\n\n\t\t\t\tif ( folder.parent === null || item.parent !== folder || folder.children.indexOf( item ) !== indexes[ path ] ) {\n\n\t\t\t\t\tfolder.add( item );\n\n\t\t\t\t}\n\n\t\t\t\tindexes[ path ] ++;\n\n\t\t\t} else {\n\n\t\t\t\tif ( ! item.parent ) {\n\n\t\t\t\t\tthis.nodes.add( item );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst rttNodes = [];\n\n\t\t\tconst mainSize = previousCanvasTarget.getDrawingBufferSize( _size );\n\n\t\t\tcanvasData.inspectNode.traverse( ( child ) => {\n\n\t\t\t\tif ( child.isRTTNode && child.autoResize === true ) {\n\n\t\t\t\t\tconst oldWidth = child.width;\n\t\t\t\t\tconst oldHeight = child.height;\n\n\t\t\t\t\tchild.width = mainSize.width;\n\t\t\t\t\tchild.height = mainSize.height;\n\n\t\t\t\t\tchild.setSize( mainSize.width, mainSize.height );\n\n\t\t\t\t\trttNodes.push( {\n\t\t\t\t\t\tnode: child,\n\t\t\t\t\t\toldWidth,\n\t\t\t\t\t\toldHeight\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t\tconst state = RendererUtils.resetRendererState( renderer );\n\n\t\t\trenderer.toneMapping = NoToneMapping;\n\t\t\trenderer.outputColorSpace = LinearSRGBColorSpace;\n\n\t\t\trenderer.setCanvasTarget( canvasData.canvasTarget );\n\n\t\t\tif ( canvasData.canvasAspect ) {\n\n\t\t\t\tcanvasData.canvasAspect.value = canvasData.canvasTarget.domElement.width / canvasData.canvasTarget.domElement.height;\n\n\t\t\t}\n\n\t\t\tcanvasData.quad.render( renderer );\n\n\t\t\trenderer.setCanvasTarget( previousCanvasTarget );\n\n\t\t\tRendererUtils.restoreRendererState( renderer, state );\n\n\t\t\tfor ( const rtt of rttNodes ) {\n\n\t\t\t\trtt.node.width = rtt.oldWidth;\n\t\t\t\trtt.node.height = rtt.oldHeight;\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.currentDataList = canvasDataList;\n\n\t}\n\n\tsetActive( isActive ) {\n\n\t\tsuper.setActive( isActive );\n\n\t}\n\n\tsaveLastView() {\n\n\t\tconst selectedValue = this.select.value;\n\n\t\tif ( selectedValue === 'list' ) {\n\n\t\t\tsetItem( 'viewerLastView', 'list' );\n\n\t\t} else {\n\n\t\t\tconst selectedOption = this.select.options[ this.select.selectedIndex ];\n\n\t\t\tif ( selectedOption ) {\n\n\t\t\t\tsetItem( 'viewerLastView', selectedOption.textContent );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tdispose() {\n\n\t\tif ( this.splitActive ) {\n\n\t\t\tthis.stopSplitMode();\n\n\t\t}\n\n\t\tif ( this.splitCanvas ) {\n\n\t\t\tif ( this.splitCanvas.parentElement ) {\n\n\t\t\t\tthis.splitCanvas.parentElement.removeChild( this.splitCanvas );\n\n\t\t\t}\n\n\t\t\tthis.splitCanvas = null;\n\n\t\t}\n\n\t\tif ( this.splitCanvasTarget ) {\n\n\t\t\tthis.splitCanvasTarget.dispose();\n\t\t\tthis.splitCanvasTarget = null;\n\n\t\t}\n\n\t\tif ( this.splitMaterial ) {\n\n\t\t\tthis.splitMaterial.dispose();\n\t\t\tthis.splitMaterial = null;\n\n\t\t}\n\n\t\tfor ( const canvasData of this.canvasNodes.values() ) {\n\n\t\t\tcanvasData.canvasTarget.dispose();\n\t\t\tcanvasData.material.dispose();\n\n\t\t\tif ( canvasData.rttNode !== null ) canvasData.rttNode.dispose();\n\n\t\t}\n\n\t\tthis.canvasNodes.clear();\n\n\t\tsuper.dispose();\n\n\t}\n\n}\n\nexport { Viewer };\n","import { Tab } from '../ui/Tab.js';\nimport { Graph } from '../ui/Graph.js';\nimport { getItem, setItem } from '../Storage.js';\nimport { info } from '../ui/utils.js';\nimport {\n\tByteType,\n\tFloatType,\n\tHalfFloatType,\n\tIntType,\n\tShortType,\n\tUnsignedByteType,\n\tUnsignedInt101111Type,\n\tUnsignedInt248Type,\n\tUnsignedInt5999Type,\n\tUnsignedIntType,\n\tUnsignedShort4444Type,\n\tUnsignedShort5551Type,\n\tUnsignedShortType,\n\tAlphaFormat,\n\tRGBFormat,\n\tRGBAFormat,\n\tDepthFormat,\n\tDepthStencilFormat,\n\tRedFormat,\n\tRedIntegerFormat,\n\tRGFormat,\n\tRGIntegerFormat,\n\tRGBIntegerFormat,\n\tRGBAIntegerFormat\n} from 'three';\n\nconst LIMIT = 500;\nconst TRIANGLES_GRAPH_LIMIT = 60;\n\nclass Timeline extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Timeline', options );\n\n\t\tthis.content.style.overflow = 'hidden';\n\t\tthis.isRecording = false;\n\t\tthis.frames = []; // Array of { id: number, calls: [] }\n\n\t\tthis.baseTriangles = 0;\n\t\tthis.currentFrame = null;\n\t\tthis.isHierarchicalView = true;\n\t\tthis.activeBlocks = new Map();\n\t\tthis.domPool = [];\n\t\tthis.originalBackend = null;\n\t\tthis.originalMethods = new Map();\n\t\tthis.renderer = null;\n\n\t\tthis.graph = new Graph( LIMIT ); // Accommodate standard graph points\n\t\t// Make lines in timeline graph\n\t\tthis.graph.addLine( 'fps', 'var( --color-fps )' );\n\t\tthis.graph.addLine( 'calls', 'var( --color-call )' );\n\t\tthis.graph.addLine( 'triangles', 'var( --color-red )' );\n\n\t\tthis.buildHeader();\n\t\tthis.buildUI();\n\n\t\t// Bind window resize to update graph bounds\n\t\twindow.addEventListener( 'resize', () => {\n\n\t\t\tif ( this.isActive && ! this.isRecording && this.frames.length > 0 ) {\n\n\t\t\t\tthis.renderSlider();\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tinit( inspector ) {\n\n\t\tsuper.init( inspector );\n\n\t\tthis.profiler.addEventListener( 'resize', () => {\n\n\t\t\tif ( this.isActive && ! this.isRecording && this.frames.length > 0 ) {\n\n\t\t\t\tthis.renderSlider();\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tsetActive( isActive ) {\n\n\t\tsuper.setActive( isActive );\n\n\t\tif ( isActive && ! this.isRecording && this.frames.length > 0 ) {\n\n\t\t\tthis.renderSlider();\n\n\t\t}\n\n\t}\n\n\tbuildHeader() {\n\n\t\tconst header = document.createElement( 'div' );\n\t\theader.className = 'toolbar';\n\n\t\tthis.recordButton = document.createElement( 'button' );\n\t\tthis.recordButton.className = 'console-copy-button'; // Reusing style\n\t\tthis.recordButton.title = 'Record';\n\t\tthis.recordButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"></circle><circle cx=\"12\" cy=\"12\" r=\"4\" fill=\"currentColor\"></circle></svg>';\n\t\tthis.recordButton.style.padding = '0 10px';\n\t\tthis.recordButton.style.lineHeight = '24px'; // Match other buttons height\n\t\tthis.recordButton.style.display = 'flex';\n\t\tthis.recordButton.style.alignItems = 'center';\n\t\tthis.recordButton.addEventListener( 'click', () => this.toggleRecording() );\n\n\t\tconst clearButton = document.createElement( 'button' );\n\t\tclearButton.className = 'console-copy-button';\n\t\tclearButton.title = 'Clear';\n\t\tclearButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"3 6 5 6 21 6\"></polyline><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\"></path><line x1=\"10\" y1=\"11\" x2=\"10\" y2=\"17\"></line><line x1=\"14\" y1=\"11\" x2=\"14\" y2=\"17\"></line></svg>';\n\t\tclearButton.style.padding = '0 10px';\n\t\tclearButton.style.lineHeight = '24px';\n\t\tclearButton.style.display = 'flex';\n\t\tclearButton.style.alignItems = 'center';\n\t\tclearButton.addEventListener( 'click', () => this.clear() );\n\n\t\tthis.viewModeSelect = document.createElement( 'select' );\n\t\tthis.viewModeSelect.className = 'select';\n\t\tthis.viewModeSelect.style.width = '120px';\n\t\tthis.viewModeSelect.style.marginRight = '10px';\n\n\t\tconst hierarchyOption = document.createElement( 'option' );\n\t\thierarchyOption.value = 'hierarchy';\n\t\thierarchyOption.textContent = 'Hierarchy';\n\t\tthis.viewModeSelect.appendChild( hierarchyOption );\n\n\t\tconst countsOption = document.createElement( 'option' );\n\t\tcountsOption.value = 'counts';\n\t\tcountsOption.textContent = 'Count';\n\t\tthis.viewModeSelect.appendChild( countsOption );\n\n\t\tthis.viewModeSelect.value = this.isHierarchicalView ? 'hierarchy' : 'counts';\n\n\t\tthis.viewModeSelect.addEventListener( 'change', () => {\n\n\t\t\tthis.isHierarchicalView = this.viewModeSelect.value === 'hierarchy';\n\n\t\t\tif ( this.selectedFrameIndex !== undefined && this.selectedFrameIndex !== - 1 ) {\n\n\t\t\t\tthis.selectFrame( this.selectedFrameIndex );\n\n\t\t\t}\n\n\t\t} );\n\n\t\tthis.recordRefreshButton = document.createElement( 'button' );\n\t\tthis.recordRefreshButton.className = 'console-copy-button'; // Reusing style\n\t\tthis.recordRefreshButton.title = 'Refresh & Record';\n\t\tthis.recordRefreshButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\"></path><path d=\"M21 3v5h-5\"></path><circle cx=\"12\" cy=\"12\" r=\"3\" fill=\"currentColor\"></circle></svg>';\n\t\tthis.recordRefreshButton.style.padding = '0 10px';\n\t\tthis.recordRefreshButton.style.lineHeight = '24px';\n\t\tthis.recordRefreshButton.style.display = 'flex';\n\t\tthis.recordRefreshButton.style.alignItems = 'center';\n\t\tthis.recordRefreshButton.addEventListener( 'click', () => {\n\n\t\t\tconst timelineSettings = getItem( 'timeline' );\n\t\t\ttimelineSettings.recording = true;\n\t\t\tsetItem( 'timeline', timelineSettings );\n\n\t\t\twindow.location.reload();\n\n\t\t} );\n\n\t\tthis.exportButton = document.createElement( 'button' );\n\t\tthis.exportButton.className = 'console-copy-button';\n\t\tthis.exportButton.title = 'Export';\n\t\tthis.exportButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"></path><polyline points=\"7 10 12 15 17 10\"></polyline><line x1=\"12\" y1=\"15\" x2=\"12\" y2=\"3\"></line></svg>';\n\t\tthis.exportButton.style.padding = '0 10px';\n\t\tthis.exportButton.style.lineHeight = '24px';\n\t\tthis.exportButton.style.display = 'flex';\n\t\tthis.exportButton.style.alignItems = 'center';\n\t\tthis.exportButton.addEventListener( 'click', () => this.exportData() );\n\n\t\tconst buttonsGroup = document.createElement( 'div' );\n\t\tbuttonsGroup.className = 'console-buttons-group';\n\t\tbuttonsGroup.appendChild( this.recordButton );\n\t\tbuttonsGroup.appendChild( this.recordRefreshButton );\n\t\tbuttonsGroup.appendChild( this.exportButton );\n\t\tbuttonsGroup.appendChild( clearButton );\n\n\t\tconst titleElement = document.createElement( 'div' );\n\t\ttitleElement.style.display = 'flex';\n\t\ttitleElement.style.alignItems = 'center';\n\t\ttitleElement.style.color = 'var(--text-primary)';\n\t\ttitleElement.style.alignSelf = 'center';\n\n\t\tthis.frameInfo = document.createElement( 'span' );\n\t\tthis.frameInfo.style.display = 'inline-flex';\n\t\tthis.frameInfo.style.alignItems = 'center';\n\t\tthis.frameInfo.style.marginLeft = '5px';\n\t\tthis.frameInfo.style.fontFamily = 'monospace';\n\t\tthis.frameInfo.style.color = 'var(--text-secondary)';\n\t\tthis.frameInfo.style.fontSize = '12px';\n\n\t\ttitleElement.appendChild( this.viewModeSelect );\n\t\ttitleElement.appendChild( this.frameInfo );\n\n\t\theader.appendChild( titleElement );\n\t\theader.appendChild( buttonsGroup );\n\t\tthis.content.appendChild( header );\n\n\t}\n\n\tbuildUI() {\n\n\t\tconst container = document.createElement( 'div' );\n\t\tcontainer.style.display = 'flex';\n\t\tcontainer.style.flexDirection = 'column';\n\t\tcontainer.style.flex = '1';\n\t\tcontainer.style.minHeight = '0';\n\t\tcontainer.style.marginTop = '10px';\n\t\tcontainer.style.width = '100%';\n\n\t\t// Top Player/Graph Slider using Graph.js SVG\n\t\tconst graphContainer = document.createElement( 'div' );\n\t\tgraphContainer.style.height = '60px';\n\t\tgraphContainer.style.minHeight = '60px';\n\t\tgraphContainer.style.borderBottom = '1px solid var(--border-color)';\n\t\tgraphContainer.style.backgroundColor = 'var(--background-color)';\n\n\t\tthis.graphSlider = document.createElement( 'div' );\n\t\tthis.graphSlider.style.height = '100%';\n\t\tthis.graphSlider.style.margin = '0 10px';\n\t\tthis.graphSlider.style.position = 'relative';\n\t\tthis.graphSlider.style.cursor = 'crosshair';\n\t\tthis.graphSlider.style.touchAction = 'none';\n\n\t\tgraphContainer.appendChild( this.graphSlider );\n\n\t\t// Setup SVG from Graph\n\t\tthis.graph.domElement.style.width = '0';\n\t\tthis.graph.domElement.style.minWidth = '100%';\n\t\tthis.graph.domElement.style.height = '100%';\n\t\tthis.graphSlider.appendChild( this.graph.domElement );\n\n\t\t// Hover indicator\n\t\tthis.hoverIndicator = document.createElement( 'div' );\n\t\tthis.hoverIndicator.style.position = 'absolute';\n\t\tthis.hoverIndicator.style.top = '0';\n\t\tthis.hoverIndicator.style.bottom = '0';\n\t\tthis.hoverIndicator.style.width = '1px';\n\t\tthis.hoverIndicator.style.backgroundColor = 'rgba(255, 255, 255, 0.3)';\n\t\tthis.hoverIndicator.style.pointerEvents = 'none';\n\t\tthis.hoverIndicator.style.display = 'none';\n\t\tthis.hoverIndicator.style.zIndex = '9';\n\t\tthis.hoverIndicator.style.transform = 'translateX(-50%)';\n\t\tthis.graphSlider.appendChild( this.hoverIndicator );\n\n\t\t// Playhead indicator (vertical line)\n\t\tthis.playhead = document.createElement( 'div' );\n\t\tthis.playhead.style.position = 'absolute';\n\t\tthis.playhead.style.top = '0';\n\t\tthis.playhead.style.bottom = '0';\n\t\tthis.playhead.style.width = '2px';\n\t\tthis.playhead.style.backgroundColor = 'var(--color-red)';\n\t\tthis.playhead.style.boxShadow = '0 0 4px rgba(255,0,0,0.5)';\n\t\tthis.playhead.style.pointerEvents = 'none';\n\t\tthis.playhead.style.display = 'none';\n\t\tthis.playhead.style.zIndex = '10';\n\t\tthis.playhead.style.transform = 'translateX(-50%)';\n\t\tthis.graphSlider.appendChild( this.playhead );\n\n\t\t// Playhead handle (triangle/pointer)\n\t\tconst playheadHandle = document.createElement( 'div' );\n\t\tplayheadHandle.style.position = 'absolute';\n\t\tplayheadHandle.style.top = '0';\n\t\tplayheadHandle.style.left = '50%';\n\t\tplayheadHandle.style.transform = 'translate(-50%, 0)';\n\t\tplayheadHandle.style.width = '0';\n\t\tplayheadHandle.style.height = '0';\n\t\tplayheadHandle.style.borderLeft = '6px solid transparent';\n\t\tplayheadHandle.style.borderRight = '6px solid transparent';\n\t\tplayheadHandle.style.borderTop = '8px solid var(--color-red)';\n\t\tthis.playhead.appendChild( playheadHandle );\n\n\t\t// Make it focusable to accept keyboard events\n\t\tthis.graphSlider.tabIndex = 0;\n\t\tthis.graphSlider.style.outline = 'none';\n\n\t\t// Pointer interactivity on the graph\n\t\tlet isDragging = false;\n\n\t\tconst updatePlayheadFromEvent = ( e ) => {\n\n\t\t\tif ( this.isRecording || this.frames.length === 0 ) return;\n\n\t\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\t\tlet x = e.clientX - rect.left;\n\n\t\t\t// Clamp\n\t\t\tx = Math.max( 0, Math.min( x, rect.width ) );\n\n\t\t\tthis.fixedScreenX = x;\n\n\t\t\t// The graph stretches its points across the width\n\t\t\t// Find closest frame index based on exact point coordinates\n\t\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\t\t\tif ( pointCount === 0 ) return;\n\n\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\n\t\t\tlet localFrameIndex = Math.round( ( x - offset ) / pointStep );\n\t\t\tlocalFrameIndex = Math.max( 0, Math.min( localFrameIndex, pointCount - 1 ) );\n\n\t\t\tif ( localFrameIndex >= pointCount - 2 ) {\n\n\t\t\t\tthis.isTrackingLatest = true;\n\n\t\t\t} else {\n\n\t\t\t\tthis.isTrackingLatest = false;\n\n\t\t\t}\n\n\t\t\tlet frameIndex = localFrameIndex;\n\n\t\t\tif ( this.frames.length > pointCount ) {\n\n\t\t\t\tframeIndex += this.frames.length - pointCount;\n\n\t\t\t}\n\n\t\t\tthis.playhead.style.display = 'block';\n\t\t\tthis.selectFrame( frameIndex );\n\n\t\t};\n\n\t\tthis.graphSlider.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\tif ( this.isRecording ) return;\n\n\t\t\tisDragging = true;\n\t\t\tthis.isManualScrubbing = true;\n\t\t\tthis.graphSlider.focus();\n\t\t\tupdatePlayheadFromEvent( e );\n\n\t\t} );\n\n\t\tthis.graphSlider.addEventListener( 'pointerenter', () => {\n\n\t\t\tif ( this.frames.length > 0 && ! this.isRecording ) {\n\n\t\t\t\tthis.hoverIndicator.style.display = 'block';\n\n\t\t\t}\n\n\t\t} );\n\n\t\tthis.graphSlider.addEventListener( 'pointerleave', () => {\n\n\t\t\tthis.hoverIndicator.style.display = 'none';\n\n\t\t} );\n\n\t\tthis.graphSlider.addEventListener( 'pointermove', ( e ) => {\n\n\t\t\tif ( this.frames.length === 0 || this.isRecording ) return;\n\n\t\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\t\tlet x = e.clientX - rect.left;\n\t\t\tx = Math.max( 0, Math.min( x, rect.width ) );\n\n\t\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\t\t\tif ( pointCount > 0 ) {\n\n\t\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\t\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\n\t\t\t\tlet localFrameIndex = Math.round( ( x - offset ) / pointStep );\n\t\t\t\tlocalFrameIndex = Math.max( 0, Math.min( localFrameIndex, pointCount - 1 ) );\n\n\t\t\t\tlet snappedX = offset + localFrameIndex * pointStep;\n\t\t\t\tsnappedX = Math.max( 1, Math.min( snappedX, rect.width - 1 ) );\n\t\t\t\tthis.hoverIndicator.style.left = snappedX + 'px';\n\n\t\t\t} else {\n\n\t\t\t\tconst clampedX = Math.max( 1, Math.min( x, rect.width - 1 ) );\n\t\t\t\tthis.hoverIndicator.style.left = clampedX + 'px';\n\n\t\t\t}\n\n\t\t} );\n\n\t\tthis.graphSlider.addEventListener( 'keydown', ( e ) => {\n\n\t\t\tif ( this.frames.length === 0 || this.isRecording ) return;\n\n\t\t\tlet newIndex = this.selectedFrameIndex;\n\n\t\t\tif ( e.key === 'ArrowLeft' ) {\n\n\t\t\t\tnewIndex = Math.max( 0, this.selectedFrameIndex - 1 );\n\t\t\t\te.preventDefault();\n\n\t\t\t} else if ( e.key === 'ArrowRight' ) {\n\n\t\t\t\tnewIndex = Math.min( this.frames.length - 1, this.selectedFrameIndex + 1 );\n\t\t\t\te.preventDefault();\n\n\t\t\t}\n\n\t\t\tif ( newIndex !== this.selectedFrameIndex ) {\n\n\t\t\t\tthis.selectFrame( newIndex );\n\n\t\t\t\t// Update playhead tracking state\n\t\t\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\t\t\t\tif ( pointCount > 0 ) {\n\n\t\t\t\t\tlet localIndex = newIndex;\n\t\t\t\t\tif ( this.frames.length > pointCount ) {\n\n\t\t\t\t\t\tlocalIndex = newIndex - ( this.frames.length - pointCount );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( localIndex >= pointCount - 2 ) {\n\n\t\t\t\t\t\tthis.isTrackingLatest = true;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tthis.isTrackingLatest = false;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\t\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\t\t\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\t\t\t\t\tthis.fixedScreenX = offset + localIndex * pointStep;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\twindow.addEventListener( 'pointermove', ( e ) => {\n\n\t\t\tif ( isDragging ) {\n\n\t\t\t\tupdatePlayheadFromEvent( e );\n\n\t\t\t\t// Also move hover indicator to match playback\n\t\t\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\t\t\tlet x = e.clientX - rect.left;\n\t\t\t\tx = Math.max( 0, Math.min( x, rect.width ) );\n\n\t\t\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\t\t\t\tif ( pointCount > 0 ) {\n\n\t\t\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\t\t\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\n\t\t\t\t\tlet localFrameIndex = Math.round( ( x - offset ) / pointStep );\n\t\t\t\t\tlocalFrameIndex = Math.max( 0, Math.min( localFrameIndex, pointCount - 1 ) );\n\n\t\t\t\t\tlet snappedX = offset + localFrameIndex * pointStep;\n\t\t\t\t\tsnappedX = Math.max( 1, Math.min( snappedX, rect.width - 1 ) );\n\t\t\t\t\tthis.hoverIndicator.style.left = snappedX + 'px';\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst clampedX = Math.max( 1, Math.min( x, rect.width - 1 ) );\n\t\t\t\t\tthis.hoverIndicator.style.left = clampedX + 'px';\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\twindow.addEventListener( 'pointerup', () => {\n\n\t\t\tisDragging = false;\n\t\t\tthis.isManualScrubbing = false;\n\n\t\t} );\n\n\t\tcontainer.appendChild( graphContainer );\n\n\t\t// Bottom Main Area (Timeline Sequence)\n\t\tconst mainArea = document.createElement( 'div' );\n\t\tmainArea.style.flex = '1';\n\t\tmainArea.style.display = 'flex';\n\t\tmainArea.style.flexDirection = 'column';\n\t\tmainArea.style.overflow = 'hidden';\n\n\t\t// Timeline Track\n\t\tthis.timelineTrack = document.createElement( 'div' );\n\t\tthis.timelineTrack.style.flex = '1';\n\t\tthis.timelineTrack.style.overflowY = 'auto';\n\t\tthis.timelineTrack.style.margin = '10px';\n\t\tthis.timelineTrack.style.marginTop = '8px';\n\t\tthis.timelineTrack.style.backgroundColor = 'var(--background-color)';\n\t\tthis.timelineTrack.style.position = 'relative';\n\t\tmainArea.appendChild( this.timelineTrack );\n\n\t\tthis.timelineContent = document.createElement( 'div' );\n\t\tthis.timelineContent.style.position = 'relative';\n\t\tthis.timelineContent.style.width = '100%';\n\t\tthis.timelineTrack.appendChild( this.timelineContent );\n\n\t\tthis.timelineTrack.addEventListener( 'scroll', () => {\n\n\t\t\tif ( ! this.isRecording && this.frames.length > 0 ) {\n\n\t\t\t\tthis.updateVisibleBlocks();\n\n\t\t\t}\n\n\t\t} );\n\n\t\tcontainer.appendChild( mainArea );\n\t\tthis.content.appendChild( container );\n\n\t}\n\n\tsetRenderer( renderer ) {\n\n\t\tthis.renderer = renderer;\n\n\t\tconst timelineSettings = getItem( 'timeline' );\n\n\t\tif ( timelineSettings.recording ) {\n\n\t\t\ttimelineSettings.recording = false;\n\t\t\tsetItem( 'timeline', timelineSettings );\n\n\t\t\tthis.toggleRecording();\n\n\t\t}\n\n\t}\n\n\ttoggleRecording() {\n\n\t\tif ( ! this.renderer ) {\n\n\t\t\tconsole.warn( 'Timeline: No renderer defined.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tthis.isRecording = ! this.isRecording;\n\n\t\tif ( this.isRecording ) {\n\n\t\t\tthis.recordButton.title = 'Stop';\n\t\t\tthis.recordButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect></svg>';\n\t\t\tthis.recordButton.style.color = 'var(--color-red)';\n\t\t\tthis.startRecording();\n\n\t\t} else {\n\n\t\t\tthis.recordButton.title = 'Record';\n\t\t\tthis.recordButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"></circle><circle cx=\"12\" cy=\"12\" r=\"4\" fill=\"currentColor\"></circle></svg>';\n\t\t\tthis.recordButton.style.color = '';\n\t\t\tthis.stopRecording();\n\t\t\tthis.renderSlider();\n\n\t\t}\n\n\t}\n\n\tstartRecording() {\n\n\t\tthis.frames = [];\n\t\tthis.currentFrame = null;\n\t\tthis.selectedFrameIndex = - 1;\n\t\tthis.fixedScreenX = 0;\n\t\tthis.isTrackingLatest = true;\n\t\tthis.isManualScrubbing = false;\n\t\tthis.clear();\n\t\tthis.frameInfo.textContent = 'Recording...';\n\n\t\tconst backend = this.renderer.backend;\n\t\tconst methods = Object.getOwnPropertyNames( Object.getPrototypeOf( backend ) ).filter( prop => prop !== 'constructor' );\n\n\t\tfor ( const prop of methods ) {\n\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor( Object.getPrototypeOf( backend ), prop );\n\n\t\t\tif ( descriptor && ( descriptor.get || descriptor.set ) ) continue;\n\n\t\t\tconst originalFunc = backend[ prop ];\n\n\t\t\tif ( typeof originalFunc === 'function' && typeof prop === 'string' ) {\n\n\t\t\t\tthis.originalMethods.set( prop, originalFunc );\n\n\t\t\t\tbackend[ prop ] = ( ...args ) => {\n\n\t\t\t\t\tif ( prop.toLowerCase().includes( 'timestamp' ) || prop.startsWith( 'get' ) || prop.startsWith( 'set' ) || prop.startsWith( 'has' ) || prop.startsWith( '_' ) || prop.startsWith( 'needs' ) ) {\n\n\t\t\t\t\t\treturn originalFunc.apply( backend, args );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check for frame change\n\t\t\t\t\tconst frameNumber = this.renderer.info.frame;\n\n\t\t\t\t\tif ( ! this.currentFrame || this.currentFrame.id !== frameNumber ) {\n\n\t\t\t\t\t\tif ( this.currentFrame ) {\n\n\t\t\t\t\t\t\tthis.resolveIndirectTriangles( this.currentFrame );\n\n\t\t\t\t\t\t\tthis.currentFrame.fps = this.renderer.inspector ? this.renderer.inspector.fps : 0;\n\n\t\t\t\t\t\t\tif ( ! isFinite( this.currentFrame.fps ) ) {\n\n\t\t\t\t\t\t\t\tthis.currentFrame.fps = 0;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst t = this.currentFrame.triangles || 0;\n\n\t\t\t\t\t\t\tif ( t > this.baseTriangles ) {\n\n\t\t\t\t\t\t\t\tconst oldBase = this.baseTriangles;\n\t\t\t\t\t\t\t\tthis.baseTriangles = t;\n\n\t\t\t\t\t\t\t\tif ( oldBase > 0 ) {\n\n\t\t\t\t\t\t\t\t\tconst ratio = oldBase / this.baseTriangles;\n\t\t\t\t\t\t\t\t\tconst points = this.graph.lines[ 'triangles' ].points;\n\n\t\t\t\t\t\t\t\t\tfor ( let i = 0; i < points.length; i ++ ) {\n\n\t\t\t\t\t\t\t\t\t\tpoints[ i ] *= ratio;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst normalizedTriangles = this.baseTriangles > 0 ? ( t / this.baseTriangles ) * TRIANGLES_GRAPH_LIMIT : 0;\n\n\t\t\t\t\t\t\tthis.graph.addPoint( 'calls', this.currentFrame.calls.length );\n\t\t\t\t\t\t\tthis.graph.addPoint( 'fps', this.currentFrame.fps );\n\t\t\t\t\t\t\tthis.graph.addPoint( 'triangles', normalizedTriangles );\n\t\t\t\t\t\t\tthis.graph.update();\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.currentFrame = { id: frameNumber, calls: [], fps: 0, triangles: 0, indirectDraws: [] };\n\t\t\t\t\t\tthis.frames.push( this.currentFrame );\n\n\t\t\t\t\t\tif ( this.frames.length > LIMIT ) {\n\n\t\t\t\t\t\t\tthis.frames.shift();\n\n\t\t\t\t\t\t}\n\n\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst call = { method: prop, target: args[ 0 ] };\n\t\t\t\t\tconst details = this.getCallDetail( prop, args );\n\n\t\t\t\t\tif ( details ) {\n\n\t\t\t\t\t\tcall.details = details;\n\n\t\t\t\t\t\tif ( details.triangles !== undefined ) {\n\n\t\t\t\t\t\t\tthis.currentFrame.triangles += details.triangles;\n\n\t\t\t\t\t\t} else if ( details.indirect === true ) {\n\n\t\t\t\t\t\t\tconst renderObject = args[ 0 ];\n\n\t\t\t\t\t\t\tthis.currentFrame.indirectDraws.push( {\n\t\t\t\t\t\t\t\tdetails,\n\t\t\t\t\t\t\t\tattribute: renderObject.getIndirect(),\n\t\t\t\t\t\t\t\toffset: renderObject.getIndirectOffset()\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.currentFrame.calls.push( call );\n\n\t\t\t\t\treturn originalFunc.apply( backend, args );\n\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tstopRecording() {\n\n\t\tif ( this.originalMethods.size > 0 ) {\n\n\t\t\tconst backend = this.renderer.backend;\n\n\t\t\tfor ( const [ prop, originalFunc ] of this.originalMethods.entries() ) {\n\n\t\t\t\tbackend[ prop ] = originalFunc;\n\n\t\t\t}\n\n\t\t\tthis.originalMethods.clear();\n\n\t\t\tif ( this.currentFrame ) {\n\n\t\t\t\tthis.resolveIndirectTriangles( this.currentFrame );\n\n\t\t\t\tthis.currentFrame.fps = this.renderer.inspector ? this.renderer.inspector.fps : 0;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tresolveIndirectTriangles( frame ) {\n\n\t\tconst draws = frame.indirectDraws;\n\n\t\tif ( ! draws || draws.length === 0 ) return;\n\n\t\tframe.indirectDraws = null;\n\n\t\t// the draw arguments live on the GPU: [ vertexCount | indexCount, instanceCount, ... ]. the buffer is read\n\t\t// once per frame, after the frame was submitted and before the next one changes it\n\n\t\tconst readbacks = new Map();\n\n\t\tfor ( const draw of draws ) {\n\n\t\t\tif ( readbacks.has( draw.attribute ) === false ) {\n\n\t\t\t\treadbacks.set( draw.attribute, this.renderer.getArrayBufferAsync( draw.attribute ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\tPromise.all( draws.map( ( draw ) => readbacks.get( draw.attribute ) ) ).then( ( buffers ) => {\n\n\t\t\tfor ( let i = 0; i < draws.length; i ++ ) {\n\n\t\t\t\tconst draw = draws[ i ];\n\t\t\t\tconst data = new Uint32Array( buffers[ i ] );\n\t\t\t\tconst offsets = Array.isArray( draw.offset ) ? draw.offset : [ draw.offset ];\n\n\t\t\t\tlet triangles = 0;\n\n\t\t\t\tfor ( const offset of offsets ) {\n\n\t\t\t\t\tconst index = offset / 4;\n\n\t\t\t\t\ttriangles += Math.floor( data[ index ] / 3 ) * data[ index + 1 ];\n\n\t\t\t\t}\n\n\t\t\t\tdraw.details.triangles = triangles;\n\t\t\t\tframe.triangles += triangles;\n\n\t\t\t}\n\n\t\t\tif ( this.isRecording === false && this.frames.includes( frame ) ) this.renderSlider();\n\n\t\t} );\n\n\t}\n\n\tclear() {\n\n\t\tthis.frames = [];\n\t\tthis.clearActiveBlocks();\n\t\tthis.timelineContent.innerHTML = '';\n\t\tthis.timelineContent.style.height = '0px';\n\t\tthis.playhead.style.display = 'none';\n\t\tthis.frameInfo.textContent = '';\n\t\tthis.baseTriangles = 0;\n\t\tthis.graph.lines[ 'calls' ].points = [];\n\t\tthis.graph.lines[ 'fps' ].points = [];\n\t\tthis.graph.lines[ 'triangles' ].points = [];\n\t\tthis.graph.resetLimit();\n\t\tthis.graph.update();\n\n\t}\n\n\texportData() {\n\n\t\tif ( this.frames.length === 0 ) return;\n\n\t\tconst data = JSON.stringify( this.frames, null, '\\t' );\n\t\tconst blob = new Blob( [ data ], { type: 'application/json' } );\n\t\tconst url = URL.createObjectURL( blob );\n\t\tconst a = document.createElement( 'a' );\n\t\ta.href = url;\n\t\ta.download = 'threejs-timeline.json';\n\t\ta.click();\n\t\tURL.revokeObjectURL( url );\n\n\t}\n\n\tgetRenderTargetDetails( renderTarget ) {\n\n\t\tconst textures = renderTarget.textures;\n\t\tconst attachments = [];\n\n\t\tconst getBPC = ( texture ) => {\n\n\t\t\tswitch ( texture.type ) {\n\n\t\t\t\tcase ByteType:\n\t\t\t\tcase UnsignedByteType:\n\t\t\t\t\treturn '8';\n\t\t\t\tcase ShortType:\n\t\t\t\tcase UnsignedShortType:\n\t\t\t\tcase HalfFloatType:\n\t\t\t\tcase UnsignedShort4444Type:\n\t\t\t\tcase UnsignedShort5551Type:\n\t\t\t\t\treturn '16';\n\t\t\t\tcase IntType:\n\t\t\t\tcase UnsignedIntType:\n\t\t\t\tcase FloatType:\n\t\t\t\tcase UnsignedInt248Type:\n\t\t\t\tcase UnsignedInt5999Type:\n\t\t\t\tcase UnsignedInt101111Type:\n\t\t\t\t\treturn '32';\n\t\t\t\tdefault:\n\t\t\t\t\treturn '?';\n\n\t\t\t}\n\n\t\t};\n\n\t\tconst getFormat = ( texture ) => {\n\n\t\t\tswitch ( texture.format ) {\n\n\t\t\t\tcase AlphaFormat:\n\t\t\t\t\treturn 'a';\n\t\t\t\tcase RedFormat:\n\t\t\t\tcase RedIntegerFormat:\n\t\t\t\t\treturn 'r';\n\t\t\t\tcase RGFormat:\n\t\t\t\tcase RGIntegerFormat:\n\t\t\t\t\treturn 'rg';\n\t\t\t\tcase RGBFormat:\n\t\t\t\tcase RGBIntegerFormat:\n\t\t\t\t\treturn 'rgb';\n\t\t\t\tcase DepthFormat:\n\t\t\t\t\treturn 'depth';\n\t\t\t\tcase DepthStencilFormat:\n\t\t\t\t\treturn 'depth-stencil';\n\t\t\t\tcase RGBAFormat:\n\t\t\t\tcase RGBAIntegerFormat:\n\t\t\t\tdefault:\n\t\t\t\t\treturn 'rgba';\n\n\t\t\t}\n\n\t\t};\n\n\t\tfor ( let i = 0; i < textures.length; i ++ ) {\n\n\t\t\tconst texture = textures[ i ];\n\n\t\t\tconst bpc = getBPC( texture );\n\t\t\tconst format = getFormat( texture );\n\n\t\t\tlet description = `[${ i }]`;\n\n\t\t\tif ( texture.name && ! ( texture.isDepthTexture && texture.name === 'depth' ) ) {\n\n\t\t\t\tdescription += ` ${ texture.name }`;\n\n\t\t\t}\n\n\t\t\tdescription += ` ${ format } ${ bpc } bpc`;\n\n\t\t\tattachments.push( description );\n\n\t\t}\n\n\t\tconst details = {\n\t\t\ttarget: renderTarget.name || 'RenderTarget',\n\t\t\t[ `attachments(${ textures.length })` ]: '\\n' + attachments.join( '\\n' )\n\t\t};\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\tdetails.depth = `${ getBPC( renderTarget.depthTexture ) } bpc`;\n\n\t\t}\n\n\t\treturn details;\n\n\t}\n\n\tgetCallDetail( method, args ) {\n\n\t\tswitch ( method ) {\n\n\t\t\tcase 'draw': {\n\n\t\t\t\tconst renderObject = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tobject: renderObject.object.name || renderObject.object.type,\n\t\t\t\t\tmaterial: renderObject.material.name || renderObject.material.type,\n\t\t\t\t\tgeometry: renderObject.geometry.name || renderObject.geometry.type\n\t\t\t\t};\n\n\t\t\t\tif ( renderObject.getDrawParameters ) {\n\n\t\t\t\t\tconst drawParams = renderObject.getDrawParameters();\n\n\t\t\t\t\tif ( drawParams ) {\n\n\t\t\t\t\t\tif ( renderObject.object.isMesh || renderObject.object.isSprite ) {\n\n\t\t\t\t\t\t\t// the WebGL backend doesn't support indirect draws, it draws with the parameters of the geometry\n\n\t\t\t\t\t\t\tif ( this.renderer.backend.isWebGPUBackend === true && renderObject.getIndirect() !== null ) {\n\n\t\t\t\t\t\t\t\tdetails.indirect = true;\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tdetails.triangles = drawParams.vertexCount / 3;\n\n\t\t\t\t\t\t\t\tif ( renderObject.object.count > 1 ) {\n\n\t\t\t\t\t\t\t\t\tdetails.instance = renderObject.object.count;\n\n\t\t\t\t\t\t\t\t\tdetails[ 'triangles per instance' ] = details.triangles;\n\t\t\t\t\t\t\t\t\tdetails.triangles *= details.instance;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'beginRender': {\n\n\t\t\t\tconst renderContext = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tscene: this.renderer.inspector.currentRender.name || 'unknown',\n\t\t\t\t\tcamera: renderContext.camera.name || renderContext.camera.type\n\t\t\t\t};\n\n\t\t\t\tif ( renderContext.renderTarget && ! renderContext.renderTarget.isPostProcessingRenderTarget ) {\n\n\t\t\t\t\tObject.assign( details, this.getRenderTargetDetails( renderContext.renderTarget ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdetails.target = 'CanvasTarget';\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'beginCompute': {\n\n\t\t\t\tconst details = {\n\t\t\t\t\tcompute: this.renderer.inspector.currentCompute.name || 'unknown'\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'compute': {\n\n\t\t\t\tconst computeNode = args[ 1 ];\n\t\t\t\tconst bindings = args[ 2 ];\n\t\t\t\tconst dispatchSize = args[ 4 ] || computeNode.dispatchSize || computeNode.count;\n\n\t\t\t\tconst node = computeNode.name || computeNode.type || 'unknown';\n\n\t\t\t\t// bindings\n\n\t\t\t\tlet bindingsCount = 0;\n\n\t\t\t\tif ( bindings ) {\n\n\t\t\t\t\tbindingsCount = bindings.length;\n\n\t\t\t\t}\n\n\t\t\t\t// dispatch\n\n\t\t\t\tlet dispatch;\n\n\t\t\t\tif ( dispatchSize.isIndirectStorageBufferAttribute ) {\n\n\t\t\t\t\tdispatch = 'indirect';\n\n\t\t\t\t} else if ( Array.isArray( dispatchSize ) ) {\n\n\t\t\t\t\tdispatch = dispatchSize.join( ', ' );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdispatch = dispatchSize;\n\n\t\t\t\t}\n\n\t\t\t\t// details\n\n\t\t\t\treturn {\n\t\t\t\t\tnode,\n\t\t\t\t\tbindings: bindingsCount,\n\t\t\t\t\tdispatch\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tcase 'updateBinding': {\n\n\t\t\t\tconst binding = args[ 0 ];\n\n\t\t\t\treturn { group: binding.name || 'unknown' };\n\n\t\t\t}\n\n\t\t\tcase 'clear': {\n\n\t\t\t\tconst renderContext = args[ 3 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tcolor: args[ 0 ],\n\t\t\t\t\tdepth: args[ 1 ],\n\t\t\t\t\tstencil: args[ 2 ]\n\t\t\t\t};\n\n\t\t\t\tif ( renderContext.renderTarget && ! renderContext.renderTarget.isPostProcessingRenderTarget ) {\n\n\t\t\t\t\tconst renderTargetDetails = this.getRenderTargetDetails( renderContext.renderTarget );\n\n\t\t\t\t\tif ( renderTargetDetails.depth ) {\n\n\t\t\t\t\t\trenderTargetDetails[ 'depth texture' ] = renderTargetDetails.depth;\n\n\t\t\t\t\t\tdelete renderTargetDetails.depth;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tObject.assign( details, renderTargetDetails );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdetails.target = 'CanvasTarget';\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'updateViewport': {\n\n\t\t\t\tconst renderContext = args[ 0 ];\n\t\t\t\tconst { x, y, width, height } = renderContext.viewportValue;\n\n\t\t\t\treturn { x, y, width, height };\n\n\t\t\t}\n\n\t\t\tcase 'updateScissor': {\n\n\t\t\t\tconst renderContext = args[ 0 ];\n\t\t\t\tconst { x, y, width, height } = renderContext.scissorValue;\n\n\t\t\t\treturn { x, y, width, height };\n\n\t\t\t}\n\n\t\t\tcase 'createProgram':\n\t\t\tcase 'destroyProgram': {\n\n\t\t\t\tconst program = args[ 0 ];\n\t\t\t\treturn { stage: program.stage, name: program.name || 'unknown' };\n\n\t\t\t}\n\n\t\t\tcase 'createRenderPipeline': {\n\n\t\t\t\tconst renderObject = args[ 0 ];\n\t\t\t\tconst details = {\n\t\t\t\t\tobject: renderObject.object ? ( renderObject.object.name || renderObject.object.type || 'unknown' ) : 'unknown',\n\t\t\t\t\tmaterial: renderObject.material ? ( renderObject.material.name || renderObject.material.type || 'unknown' ) : 'unknown'\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'createComputePipeline':\n\t\t\tcase 'destroyComputePipeline': {\n\n\t\t\t\tconst pipeline = args[ 0 ];\n\t\t\t\treturn { name: pipeline.name || 'unknown' };\n\n\t\t\t}\n\n\t\t\tcase 'createBindings':\n\t\t\tcase 'updateBindings': {\n\n\t\t\t\tconst bindGroup = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tgroup: bindGroup.name || 'unknown',\n\t\t\t\t\tcount: bindGroup.bindings.length\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'createUniformBuffer':\n\t\t\tcase 'destroyUniformBuffer': {\n\n\t\t\t\tconst binding = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tgroup: binding.groupNode.name || 'unknown',\n\t\t\t\t\tsize: binding.byteLength + ' bytes'\n\t\t\t\t};\n\n\t\t\t\tif ( binding.name !== details.group ) {\n\n\t\t\t\t\tdetails.name = binding.name;\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'createNodeBuilder': {\n\n\t\t\t\tconst object = args[ 0 ];\n\t\t\t\tconst details = { object: object.name || object.type || 'unknown' };\n\n\t\t\t\tif ( object.material ) {\n\n\t\t\t\t\tdetails.material = object.material.name || object.material.type || 'unknown';\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'createAttribute':\n\t\t\tcase 'createIndexAttribute':\n\t\t\tcase 'createStorageAttribute':\n\t\t\tcase 'destroyAttribute':\n\t\t\tcase 'destroyIndexAttribute':\n\t\t\tcase 'destroyStorageAttribute': {\n\n\t\t\t\tconst attribute = args[ 0 ];\n\t\t\t\tconst details = {};\n\n\t\t\t\tif ( attribute.name ) details.name = attribute.name;\n\t\t\t\tif ( attribute.count !== undefined ) details.count = attribute.count;\n\t\t\t\tif ( attribute.itemSize !== undefined ) details.itemSize = attribute.itemSize;\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'copyFramebufferToTexture': {\n\n\t\t\t\tconst target = args[ 0 ];\n\t\t\t\tconst rectangle = args[ 2 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\ttarget: this.getTextureName( target ),\n\t\t\t\t\twidth: rectangle.z,\n\t\t\t\t\theight: rectangle.w\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'copyTextureToTexture': {\n\n\t\t\t\tconst srcTexture = args[ 0 ];\n\t\t\t\tconst dstTexture = args[ 1 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tsource: this.getTextureName( srcTexture ),\n\t\t\t\t\tdestination: this.getTextureName( dstTexture )\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'updateSampler': {\n\n\t\t\t\tconst texture = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tmagFilter: this.getTextureFilterName( texture.magFilter ),\n\t\t\t\t\tminFilter: this.getTextureFilterName( texture.minFilter ),\n\t\t\t\t\twrapS: this.getTextureWrapName( texture.wrapS ),\n\t\t\t\t\twrapT: this.getTextureWrapName( texture.wrapT ),\n\t\t\t\t\tanisotropy: texture.anisotropy\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'updateTexture':\n\t\t\tcase 'generateMipmaps':\n\t\t\tcase 'createTexture':\n\t\t\tcase 'destroyTexture': {\n\n\t\t\t\tconst texture = args[ 0 ];\n\t\t\t\tconst name = this.getTextureName( texture );\n\t\t\t\tconst details = { texture: name };\n\n\t\t\t\tif ( texture.image ) {\n\n\t\t\t\t\tif ( texture.image.width !== undefined ) details.width = texture.image.width;\n\t\t\t\t\tif ( texture.image.height !== undefined ) details.height = texture.image.height;\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn null;\n\n\t}\n\n\tgetTextureName( texture ) {\n\n\t\tif ( texture.name ) return texture.name;\n\n\t\tconst types = [\n\t\t\t'isFramebufferTexture', 'isDepthTexture', 'isDataArrayTexture',\n\t\t\t'isData3DTexture', 'isDataTexture', 'isCompressedArrayTexture',\n\t\t\t'isCompressedTexture', 'isCubeTexture', 'isVideoTexture',\n\t\t\t'isCanvasTexture', 'isTexture'\n\t\t];\n\n\t\tfor ( const type of types ) {\n\n\t\t\tif ( texture[ type ] ) return type.replace( 'is', '' );\n\n\t\t}\n\n\t\treturn 'Texture';\n\n\t}\n\n\tgetTextureFilterName( filter ) {\n\n\t\tconst filters = {\n\t\t\t1003: 'Nearest',\n\t\t\t1004: 'NearestMipmapNearest',\n\t\t\t1005: 'NearestMipmapLinear',\n\t\t\t1006: 'Linear',\n\t\t\t1007: 'LinearMipmapNearest',\n\t\t\t1008: 'LinearMipmapLinear'\n\t\t};\n\n\t\treturn filters[ filter ] || filter;\n\n\t}\n\n\tgetTextureWrapName( wrap ) {\n\n\t\tconst wrappings = {\n\t\t\t1000: 'Repeat',\n\t\t\t1001: 'ClampToEdge',\n\t\t\t1002: 'MirroredRepeat'\n\t\t};\n\n\t\treturn wrappings[ wrap ] || wrap;\n\n\t}\n\n\tformatDetails( details ) {\n\n\t\tconst parts = [];\n\n\t\tfor ( const key in details ) {\n\n\t\t\tif ( details[ key ] !== undefined ) {\n\n\t\t\t\tparts.push( `<span class=\"timeline-detail-key\">${key}:</span> <span class=\"timeline-detail-value\">${details[ key ]}</span>` );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( parts.length === 0 ) return '';\n\n\t\treturn `<span class=\"timeline-detail-block\">{ ${parts.join( '<span class=\"timeline-detail-sep\">, </span>' )} }</span>`;\n\n\t}\n\n\trenderSlider() {\n\n\t\tif ( this.frames.length === 0 ) {\n\n\t\t\tthis.playhead.style.display = 'none';\n\t\t\tthis.frameInfo.textContent = '';\n\t\t\treturn;\n\n\t\t}\n\n\t\t// Reset graph safely to fit recorded frames exactly up to maxPoints\n\t\tthis.graph.lines[ 'calls' ].points = [];\n\t\tthis.graph.lines[ 'fps' ].points = [];\n\t\tthis.graph.lines[ 'triangles' ].points = [];\n\t\tthis.graph.resetLimit();\n\n\t\t// If recorded frames exceed SVG Graph maxPoints, we sample/slice it\n\t\t// (Graph.js inherently handles shifting for real-time,\n\t\t// but statically we want to visualize as much up to max bounds)\n\t\tlet framesToRender = this.frames;\n\t\tif ( framesToRender.length > this.graph.maxPoints ) {\n\n\t\t\tframesToRender = framesToRender.slice( - this.graph.maxPoints );\n\t\t\tthis.frames = framesToRender; // Adjust our internal array to match what's visible\n\n\t\t}\n\n\t\tlet maxTriangles = 0;\n\n\t\tfor ( let i = 0; i < framesToRender.length; i ++ ) {\n\n\t\t\tconst t = framesToRender[ i ].triangles || 0;\n\t\t\tif ( t > maxTriangles ) {\n\n\t\t\t\tmaxTriangles = t;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let i = 0; i < framesToRender.length; i ++ ) {\n\n\t\t\tconst t = framesToRender[ i ].triangles || 0;\n\t\t\tconst normalizedTriangles = maxTriangles > 0 ? ( t / maxTriangles ) * TRIANGLES_GRAPH_LIMIT : 0;\n\n\t\t\t// Adding calls length to the Graph SVG to visualize workload geometry\n\t\t\tthis.graph.addPoint( 'calls', framesToRender[ i ].calls.length );\n\t\t\tthis.graph.addPoint( 'fps', framesToRender[ i ].fps || 0 );\n\t\t\tthis.graph.addPoint( 'triangles', normalizedTriangles );\n\n\t\t}\n\n\t\tthis.graph.update();\n\n\t\tthis.playhead.style.display = 'block';\n\n\t\t// Select the previously selected frame, or the last one if tracking, or 0\n\t\tlet targetFrame = 0;\n\t\tif ( this.selectedFrameIndex !== - 1 && this.selectedFrameIndex < this.frames.length ) {\n\n\t\t\ttargetFrame = this.selectedFrameIndex;\n\n\t\t} else if ( this.frames.length > 0 ) {\n\n\t\t\ttargetFrame = this.frames.length - 1;\n\n\t\t}\n\n\t\tthis.selectFrame( targetFrame );\n\n\t}\n\n\tselectFrame( index ) {\n\n\t\tif ( this.isRecording ) return;\n\n\t\tif ( index < 0 || index >= this.frames.length ) return;\n\n\t\tthis.selectedFrameIndex = index;\n\n\t\tconst frame = this.frames[ index ];\n\t\tthis.renderTimelineTrack( frame );\n\n\t\t// Update UI texts\n\t\tconst panelWidth = this.content.offsetWidth;\n\n\t\tconst isCompact = panelWidth < 800;\n\t\tconst frameLabel = isCompact ? '' : 'Frame: ';\n\t\tconst fpsSuffix = isCompact ? '' : ' FPS';\n\t\tconst callsSuffix = isCompact ? '' : ' calls';\n\t\tconst trianglesSuffix = isCompact ? '' : ' triangles';\n\n\t\tconst group = ( type, text ) => `<span class=\"timeline-info-group\"><span class=\"timeline-info-dot ${type}\"></span>${text}</span>`;\n\t\tconst maxTriangles = Math.max( this.baseTriangles, frame.triangles || 0 );\n\t\tconst trianglesText = isCompact ? ( frame.triangles || 0 ) : ( frame.triangles || 0 ) + ' / ' + maxTriangles + trianglesSuffix;\n\t\tthis.frameInfo.innerHTML = frameLabel + frame.id + group( 'fps', ( frame.fps || 0 ).toFixed( 1 ) + fpsSuffix ) + group( 'call', frame.calls.length + callsSuffix ) + group( 'red', trianglesText );\n\n\t\t// Update playhead position\n\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\n\t\tif ( pointCount > 0 ) {\n\n\t\t\t// Calculate point width step\n\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\n\t\t\tlet localIndex = index;\n\n\t\t\tif ( this.frames.length > pointCount ) {\n\n\t\t\t\tlocalIndex = index - ( this.frames.length - pointCount );\n\n\t\t\t}\n\n\t\t\t// x offset calculation from SVG update logic\n\t\t\t// The graph translates (slides) back if points length < maxPoints\n\t\t\t// which means point 0 is at offset\n\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\t\t\tlet xPos = offset + ( localIndex * pointStep );\n\t\t\txPos = Math.max( 1, Math.min( xPos, rect.width - 1 ) );\n\n\t\t\tthis.playhead.style.left = xPos + 'px';\n\t\t\tthis.playhead.style.display = 'block';\n\n\t\t}\n\n\t}\n\n\tcreateBlock() {\n\n\t\tconst block = document.createElement( 'div' );\n\t\tblock.style.display = 'flex';\n\t\tblock.style.alignItems = 'center';\n\t\tblock.style.padding = '4px 8px';\n\t\tblock.style.backgroundColor = 'rgba(255, 255, 255, 0.03)';\n\t\tblock.style.fontFamily = 'monospace';\n\t\tblock.style.fontSize = '12px';\n\t\tblock.style.color = 'var(--text-primary)';\n\t\tblock.style.overflow = 'hidden';\n\t\tblock.style.position = 'absolute';\n\t\tblock.style.left = '0';\n\t\tblock.style.right = '0';\n\t\tblock.style.height = '24px';\n\t\tblock.style.boxSizing = 'border-box';\n\n\t\tblock.arrow = document.createElement( 'span' );\n\t\tblock.arrow.style.fontSize = '10px';\n\t\tblock.arrow.style.marginRight = '8px';\n\t\tblock.arrow.style.cursor = 'pointer';\n\t\tblock.arrow.style.width = '35px';\n\t\tblock.arrow.style.textAlign = 'center';\n\t\tblock.arrow.style.flexShrink = '0';\n\t\tblock.arrow.style.whiteSpace = 'nowrap';\n\t\tblock.appendChild( block.arrow );\n\n\t\tblock.titleSpan = document.createElement( 'span' );\n\t\tblock.titleSpan.style.flex = '1';\n\t\tblock.titleSpan.style.minWidth = '0';\n\t\tblock.titleSpan.style.overflow = 'hidden';\n\t\tblock.titleSpan.style.textOverflow = 'ellipsis';\n\t\tblock.titleSpan.style.whiteSpace = 'nowrap';\n\t\tblock.appendChild( block.titleSpan );\n\n\t\tblock.addEventListener( 'click', ( e ) => {\n\n\t\t\tif ( ! block._groupId ) return;\n\n\t\t\te.stopPropagation();\n\n\t\t\tif ( this.collapsedGroups.has( block._groupId ) ) {\n\n\t\t\t\tthis.collapsedGroups.delete( block._groupId );\n\n\t\t\t} else {\n\n\t\t\t\tthis.collapsedGroups.add( block._groupId );\n\n\t\t\t}\n\n\t\t\tthis.renderTimelineTrack( this.frames[ this.selectedFrameIndex ] );\n\n\t\t} );\n\n\t\treturn block;\n\n\t}\n\n\tclearActiveBlocks() {\n\n\t\tif ( this.activeBlocks ) {\n\n\t\t\tfor ( const block of this.activeBlocks.values() ) {\n\n\t\t\t\tblock.remove();\n\t\t\t\tthis.domPool.push( block );\n\n\t\t\t}\n\n\t\t\tthis.activeBlocks.clear();\n\n\t\t}\n\n\t}\n\n\tupdateVisibleBlocks() {\n\n\t\tif ( ! this.flatList || this.flatList.length === 0 ) {\n\n\t\t\tthis.clearActiveBlocks();\n\t\t\treturn;\n\n\t\t}\n\n\t\tconst ROW_HEIGHT = 26;\n\t\tconst BUFFER_ROWS = 5;\n\n\t\tconst scrollTop = this.timelineTrack.scrollTop;\n\t\tconst viewportHeight = this.timelineTrack.clientHeight;\n\n\t\tlet startIndex = Math.floor( scrollTop / ROW_HEIGHT ) - BUFFER_ROWS;\n\t\tlet endIndex = Math.ceil( ( scrollTop + viewportHeight ) / ROW_HEIGHT ) + BUFFER_ROWS;\n\n\t\tstartIndex = Math.max( 0, startIndex );\n\t\tendIndex = Math.min( this.flatList.length - 1, endIndex );\n\n\t\tconst nextActiveBlocks = new Map();\n\n\t\tfor ( const [ index, block ] of this.activeBlocks.entries() ) {\n\n\t\t\tif ( index < startIndex || index > endIndex ) {\n\n\t\t\t\tblock.remove();\n\t\t\t\tthis.domPool.push( block );\n\n\t\t\t} else {\n\n\t\t\t\tnextActiveBlocks.set( index, block );\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.activeBlocks = nextActiveBlocks;\n\n\t\tfor ( let i = startIndex; i <= endIndex; i ++ ) {\n\n\t\t\tlet block = this.activeBlocks.get( i );\n\n\t\t\tif ( ! block ) {\n\n\t\t\t\tblock = this.domPool.pop() || this.createBlock();\n\t\t\t\tthis.timelineContent.appendChild( block );\n\t\t\t\tthis.activeBlocks.set( i, block );\n\n\t\t\t}\n\n\t\t\tconst item = this.flatList[ i ];\n\t\t\tconst call = item.call;\n\n\t\t\tblock.style.top = ( i * ROW_HEIGHT ) + 'px';\n\t\t\tblock.style.marginLeft = ( item.indent * 24 ) + 'px';\n\t\t\tblock.style.borderLeft = '4px solid ' + this.getColorForMethod( call.method );\n\t\t\tblock._groupId = item.groupId;\n\n\t\t\tconst directInfoIcon = block.querySelector( ':scope > .info-icon' );\n\t\t\tif ( directInfoIcon ) {\n\n\t\t\t\tdirectInfoIcon.remove();\n\n\t\t\t}\n\n\t\t\tblock.titleSpan.textContent = '';\n\n\t\t\tconst methodSpan = document.createElement( 'span' );\n\t\t\tmethodSpan.textContent = call.method;\n\t\t\tblock.titleSpan.appendChild( methodSpan );\n\n\t\t\tif ( call.details ) {\n\n\t\t\t\tlet tooltipText = `### ${call.method}\\n`;\n\t\t\t\tfor ( const key in call.details ) {\n\n\t\t\t\t\tif ( call.details[ key ] !== undefined ) {\n\n\t\t\t\t\t\ttooltipText += `**${key}**: ${call.details[ key ]}\\n`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tconst infoIcon = info( block.titleSpan, tooltipText );\n\t\t\t\tinfoIcon.style.flexShrink = '0';\n\t\t\t\tinfoIcon.style.marginLeft = '6px';\n\t\t\t\tinfoIcon.style.display = 'inline-flex';\n\t\t\t\tinfoIcon.style.verticalAlign = 'middle';\n\n\t\t\t}\n\n\t\t\tconst detailsAndCountSpan = document.createElement( 'span' );\n\t\t\tlet detailsAndCountHTML = ( call.formatedDetails ? call.formatedDetails : '' );\n\t\t\tif ( call.count > 1 ) {\n\n\t\t\t\tdetailsAndCountHTML += ` <span class=\"timeline-call-count\">( ${call.count} )</span>`;\n\n\t\t\t}\n\n\t\t\tif ( detailsAndCountHTML ) {\n\n\t\t\t\tdetailsAndCountSpan.innerHTML = detailsAndCountHTML;\n\t\t\t\tblock.titleSpan.appendChild( detailsAndCountSpan );\n\n\t\t\t}\n\n\t\t\tif ( item.groupId ) {\n\n\t\t\t\tblock.style.cursor = 'pointer';\n\t\t\t\tblock.arrow.style.display = 'inline-block';\n\t\t\t\tblock.arrow.textContent = item.isCollapsed ? '[ + ]' : '[ - ]';\n\n\t\t\t} else {\n\n\t\t\t\tblock.style.cursor = 'default';\n\t\t\t\tblock.arrow.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\trenderTimelineTrack( frame ) {\n\n\t\tif ( this.isRecording ) return;\n\n\t\tthis.flatList = [];\n\n\t\tif ( ! frame || frame.calls.length === 0 ) {\n\n\t\t\tthis.clearActiveBlocks();\n\t\t\tthis.timelineContent.innerHTML = '';\n\t\t\tthis.timelineContent.style.height = '0px';\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( ! this.collapsedGroups ) {\n\n\t\t\tthis.collapsedGroups = new Set();\n\n\t\t}\n\n\t\tif ( this.isHierarchicalView ) {\n\n\t\t\tconst groupedCalls = [];\n\t\t\tlet currentGroup = null;\n\n\t\t\tfor ( let i = 0; i < frame.calls.length; i ++ ) {\n\n\t\t\t\tconst call = frame.calls[ i ];\n\t\t\t\tconst isStructural = call.method.startsWith( 'begin' ) || call.method.startsWith( 'finish' );\n\t\t\t\tconst formatedDetails = call.details ? this.formatDetails( call.details ) : '';\n\n\t\t\t\tif ( currentGroup && currentGroup.method === call.method && currentGroup.formatedDetails === formatedDetails && ! isStructural ) {\n\n\t\t\t\t\tcurrentGroup.count ++;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcurrentGroup = { method: call.method, count: 1, formatedDetails, target: call.target, details: call.details };\n\t\t\t\t\tgroupedCalls.push( currentGroup );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tlet currentIndent = 0;\n\t\t\tconst elementStack = [ { isCollapsed: false, id: '', beginCount: 0 } ];\n\t\t\tconst instanceCounts = new WeakMap();\n\n\t\t\tfor ( let i = 0; i < groupedCalls.length; i ++ ) {\n\n\t\t\t\tconst call = groupedCalls[ i ];\n\t\t\t\tlet instanceIndex = 0;\n\n\t\t\t\tif ( call.target && typeof call.target === 'object' ) {\n\n\t\t\t\t\tinstanceIndex = instanceCounts.get( call.target ) || 0;\n\t\t\t\t\tinstanceCounts.set( call.target, instanceIndex + 1 );\n\n\t\t\t\t}\n\n\t\t\t\tconst currentParent = elementStack[ elementStack.length - 1 ];\n\n\t\t\t\tlet groupId = null;\n\t\t\t\tlet isCollapsed = false;\n\n\t\t\t\tif ( call.method.startsWith( 'begin' ) ) {\n\n\t\t\t\t\tconst beginIndex = currentParent.beginCount ++;\n\t\t\t\t\tgroupId = currentParent.id + '/' + call.method + '-' + beginIndex;\n\t\t\t\t\tisCollapsed = this.collapsedGroups.has( groupId );\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! currentParent.isCollapsed ) {\n\n\t\t\t\t\tthis.flatList.push( {\n\t\t\t\t\t\tcall,\n\t\t\t\t\t\tindent: currentIndent,\n\t\t\t\t\t\tgroupId,\n\t\t\t\t\t\tisCollapsed,\n\t\t\t\t\t\tinstanceIndex\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t\tif ( call.method.startsWith( 'begin' ) ) {\n\n\t\t\t\t\tcurrentIndent ++;\n\t\t\t\t\telementStack.push( { isCollapsed: currentParent.isCollapsed || isCollapsed, id: groupId, beginCount: 0 } );\n\n\t\t\t\t} else if ( call.method.startsWith( 'finish' ) ) {\n\n\t\t\t\t\tcurrentIndent = Math.max( 0, currentIndent - 1 );\n\t\t\t\t\telementStack.pop();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst callCounts = {};\n\n\t\t\tfor ( let i = 0; i < frame.calls.length; i ++ ) {\n\n\t\t\t\tconst method = frame.calls[ i ].method;\n\n\t\t\t\tif ( method.startsWith( 'finish' ) ) continue;\n\n\t\t\t\tcallCounts[ method ] = ( callCounts[ method ] || 0 ) + 1;\n\n\t\t\t}\n\n\t\t\tconst sortedCalls = Object.keys( callCounts ).map( method => ( { method, count: callCounts[ method ] } ) );\n\t\t\tsortedCalls.sort( ( a, b ) => b.count - a.count );\n\n\t\t\tfor ( let i = 0; i < sortedCalls.length; i ++ ) {\n\n\t\t\t\tconst call = sortedCalls[ i ];\n\n\t\t\t\tthis.flatList.push( {\n\t\t\t\t\tcall,\n\t\t\t\t\tindent: 0,\n\t\t\t\t\tgroupId: null,\n\t\t\t\t\tisCollapsed: false,\n\t\t\t\t\tinstanceIndex: 0\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst ROW_HEIGHT = 26;\n\t\tthis.timelineContent.style.height = ( this.flatList.length * ROW_HEIGHT ) + 'px';\n\t\tthis.updateVisibleBlocks();\n\n\t}\n\n\tgetColorForMethod( method ) {\n\n\t\tif ( method.startsWith( 'begin' ) ) return 'var(--color-green)';\n\t\tif ( method.startsWith( 'finish' ) || method.startsWith( 'destroy' ) ) return 'var(--color-red)';\n\t\tif ( method.startsWith( 'draw' ) || method.startsWith( 'compute' ) || method.startsWith( 'create' ) || method.startsWith( 'generate' ) ) return 'var(--color-yellow)';\n\t\treturn 'var(--text-secondary)';\n\n\t}\n\n}\n\nexport { Timeline };\n","\nimport { RendererInspector } from './RendererInspector.js';\nimport { Profiler } from './ui/Profiler.js';\nimport { Performance } from './tabs/Performance.js';\nimport { Memory } from './tabs/Memory.js';\nimport { Console } from './tabs/Console.js';\nimport { Parameters } from './tabs/Parameters.js';\nimport { Settings } from './tabs/Settings.js';\nimport { Viewer } from './tabs/Viewer.js';\nimport { Timeline } from './tabs/Timeline.js';\nimport { setText } from './ui/utils.js';\nimport { getItem, setItem } from './Storage.js';\n\nimport { setConsoleFunction, getConsoleFunction, REVISION } from 'three/webgpu';\n\nclass Inspector extends RendererInspector {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper();\n\n\t\tconst {\n\t\t\tnonce = null\n\t\t} = options;\n\n\t\tthis.nonce = nonce;\n\n\t\t// init profiler\n\n\t\tconst profiler = new Profiler( this, options );\n\t\tprofiler.addEventListener( 'resize', ( e ) => this.dispatchEvent( e ) );\n\t\tprofiler.addEventListener( 'orientationchange', ( e ) => this.dispatchEvent( e ) );\n\t\tprofiler.addEventListener( 'layoutchange', ( e ) => this.dispatchEvent( e ) );\n\n\t\tconst parameters = new Parameters( {\n\t\t\tbuiltin: true,\n\t\t\ticon: '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0\" /><path d=\"M4 6l8 0\" /><path d=\"M16 6l4 0\" /><path d=\"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0\" /><path d=\"M4 12l2 0\" /><path d=\"M10 12l10 0\" /><path d=\"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0\" /><path d=\"M4 18l11 0\" /><path d=\"M19 18l1 0\" /></svg>'\n\t\t} );\n\t\tparameters.hide();\n\t\tprofiler.addTab( parameters );\n\n\t\tconst viewer = new Viewer();\n\t\tviewer.hide();\n\t\tprofiler.addTab( viewer );\n\n\t\tconst performance = new Performance();\n\t\tprofiler.addTab( performance );\n\n\t\tconst memory = new Memory();\n\t\tprofiler.addTab( memory );\n\n\t\tconst timeline = new Timeline();\n\t\tprofiler.addTab( timeline );\n\n\t\tconst consoleTab = new Console();\n\t\tprofiler.addTab( consoleTab );\n\n\t\tconst settings = new Settings();\n\t\tprofiler.addTab( settings );\n\n\t\tprofiler.loadLayout();\n\n\t\tif ( ! profiler.activeTabId ) {\n\n\t\t\tprofiler.setActiveTab( performance.id );\n\n\t\t}\n\n\t\tthis.statsData = new Map();\n\t\tthis.profiler = profiler;\n\t\tthis.performance = performance;\n\t\tthis.memory = memory;\n\t\tthis.console = consoleTab;\n\t\tthis.parameters = parameters;\n\t\tthis.viewer = viewer;\n\t\tthis.timeline = timeline;\n\t\tthis.settings = settings;\n\t\tthis.once = {};\n\t\tthis.extensionsData = new WeakMap();\n\t\tthis.previousConsoleFunction = null;\n\t\tthis._domObserver = null;\n\n\t\tthis.displayCycle = {\n\t\t\ttext: {\n\t\t\t\tneedsUpdate: false,\n\t\t\t\tduration: .25,\n\t\t\t\ttime: 0\n\t\t\t},\n\t\t\tgraph: {\n\t\t\t\tneedsUpdate: false,\n\t\t\t\tduration: .02,\n\t\t\t\ttime: 0\n\t\t\t},\n\t\t\ttoggleGraph: {\n\t\t\t\tneedsUpdate: false,\n\t\t\t\tduration: .02,\n\t\t\t\ttime: 0\n\t\t\t}\n\t\t};\n\n\t}\n\n\tget domElement() {\n\n\t\treturn this.profiler.domElement;\n\n\t}\n\n\tisVertical() {\n\n\t\treturn this.profiler ? this.profiler.isVertical() : false;\n\n\t}\n\n\tonExtension( name, callback ) {\n\n\t\tconst extensionAdded = ( e ) => {\n\n\t\t\tif ( e.name === name ) {\n\n\t\t\t\tcallback( e.tab );\n\n\t\t\t\tthis.settings.removeEventListener( 'extensionadded', extensionAdded );\n\n\t\t\t}\n\n\t\t};\n\n\t\tif ( this.settings.extensions[ name ] && this.settings.extensions[ name ].loaded ) {\n\n\t\t\tcallback( this.settings.extensions[ name ] );\n\n\t\t} else {\n\n\t\t\tthis.settings.addEventListener( 'extensionadded', extensionAdded );\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\thide() {\n\n\t\tthis.profiler.hide();\n\n\t}\n\n\tshow() {\n\n\t\tthis.profiler.show();\n\n\t}\n\n\tsetVisible( value ) {\n\n\t\tthis.domElement.style.display = value ? '' : 'none';\n\n\t\treturn this;\n\n\t}\n\n\tgetVisible() {\n\n\t\treturn this.domElement.style.display !== 'none';\n\n\t}\n\n\tgetSize() {\n\n\t\treturn this.profiler.getSize();\n\n\t}\n\n\tsetActiveTab( tab ) {\n\n\t\tthis.profiler.setActiveTab( tab.id );\n\n\t\treturn this;\n\n\t}\n\n\tsetHorizontalAlign( value ) {\n\n\t\tthis.profiler.setHorizontalAlign( value );\n\n\t\treturn this;\n\n\t}\n\n\tsetVerticalAlign( value ) {\n\n\t\tthis.profiler.setVerticalAlign( value );\n\n\t\treturn this;\n\n\t}\n\n\taddTab( tab ) {\n\n\t\tthis.profiler.addTab( tab );\n\n\t\treturn this;\n\n\t}\n\n\tremoveTab( tab ) {\n\n\t\ttab.dispose();\n\n\t\tthis.profiler.removeTab( tab );\n\n\t\treturn this;\n\n\t}\n\n\tsetActiveExtension( name, value ) {\n\n\t\tthis.settings.setActiveExtension( name, value );\n\n\t\treturn this;\n\n\t}\n\n\tresolveConsoleOnce( type, message ) {\n\n\t\tconst key = type + message;\n\n\t\tif ( this.once[ key ] !== true ) {\n\n\t\t\tthis.resolveConsole( type, message );\n\t\t\tthis.once[ key ] = true;\n\n\t\t}\n\n\t}\n\n\tresolveConsole( type, message, stackTrace = null ) {\n\n\t\tswitch ( type ) {\n\n\t\t\tcase 'log':\n\n\t\t\t\tthis.console.addMessage( 'info', message );\n\n\t\t\t\tconsole.log( message );\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'warn':\n\n\t\t\t\tthis.console.addMessage( 'warn', message );\n\n\t\t\t\tif ( stackTrace && stackTrace.isStackTrace ) {\n\n\t\t\t\t\tconsole.warn( stackTrace.getError( message ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( message );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'error':\n\n\t\t\t\tthis.console.addMessage( 'error', message );\n\n\t\t\t\tif ( stackTrace && stackTrace.isStackTrace ) {\n\n\t\t\t\t\tconsole.error( stackTrace.getError( message ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.error( message );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tsetRenderer( renderer ) {\n\n\t\tsuper.setRenderer( renderer );\n\n\t\tif ( renderer !== null ) {\n\n\t\t\tconst previousConsoleFunction = getConsoleFunction();\n\n\t\t\tthis.previousConsoleFunction = previousConsoleFunction;\n\n\t\t\tsetConsoleFunction( ( type, message, ...params ) => {\n\n\t\t\t\tif ( previousConsoleFunction ) {\n\n\t\t\t\t\tpreviousConsoleFunction( type, message, ...params );\n\n\t\t\t\t}\n\n\t\t\t\tthis.resolveConsole( type, message, ...params );\n\n\t\t\t} );\n\n\t\t\tif ( this.isAvailable ) {\n\n\t\t\t\tconst init = async () => {\n\n\t\t\t\t\tif ( renderer.hasInitialized() === false ) await renderer.init();\n\n\t\t\t\t\trenderer.backend.trackTimestamp = true;\n\n\t\t\t\t\tif ( renderer.hasFeature( 'timestamp-query' ) !== true ) {\n\n\t\t\t\t\t\tthis.console.addMessage( 'error', 'THREE.Inspector: GPU Timestamp Queries not available.' );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tlet sign = `THREE.WebGPURenderer: ${ REVISION } [ \"`;\n\n\t\t\t\t\tif ( renderer.backend.isWebGPUBackend ) {\n\n\t\t\t\t\t\tsign += 'WebGPU';\n\n\t\t\t\t\t} else if ( renderer.backend.isWebGLBackend ) {\n\n\t\t\t\t\t\tsign += 'WebGL2';\n\n\t\t\t\t\t}\n\n\t\t\t\t\tsign += '\" ]';\n\n\t\t\t\t\tthis.console.addMessage( 'info', sign );\n\n\t\t\t\t\t//\n\n\t\t\t\t\tconst domElement = this.domElement;\n\n\t\t\t\t\tif ( domElement.parentElement === null ) {\n\n\t\t\t\t\t\tif ( renderer.domElement.parentElement !== null ) {\n\n\t\t\t\t\t\t\trenderer.domElement.parentElement.appendChild( domElement );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tif ( this._domObserver !== null ) {\n\n\t\t\t\t\t\t\t\tthis._domObserver.disconnect();\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthis._domObserver = new MutationObserver( () => {\n\n\t\t\t\t\t\t\t\tif ( renderer.domElement && renderer.domElement.parentElement !== null ) {\n\n\t\t\t\t\t\t\t\t\trenderer.domElement.parentElement.appendChild( domElement );\n\n\t\t\t\t\t\t\t\t\tif ( this._domObserver !== null ) {\n\n\t\t\t\t\t\t\t\t\t\tthis._domObserver.disconnect();\n\t\t\t\t\t\t\t\t\t\tthis._domObserver = null;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tthis._domObserver.observe( document.body || document.documentElement, { childList: true, subtree: true } );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t};\n\n\t\t\t\tinit();\n\n\t\t\t\tthis.timeline.setRenderer( renderer );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( this.previousConsoleFunction ) {\n\n\t\t\t\tsetConsoleFunction( this.previousConsoleFunction );\n\t\t\t\tthis.previousConsoleFunction = undefined;\n\n\t\t\t}\n\n\t\t\tif ( this._domObserver !== null ) {\n\n\t\t\t\tthis._domObserver.disconnect();\n\t\t\t\tthis._domObserver = null;\n\n\t\t\t}\n\n\t\t\tthis.profiler.dispose();\n\n\t\t\tthis.statsData.clear();\n\n\t\t\tsuper.dispose();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tcreateParameters( name ) {\n\n\t\tif ( this.parameters.isVisible === false ) {\n\n\t\t\tthis.parameters.show();\n\n\t\t}\n\n\t\treturn this.parameters.createGroup( name );\n\n\t}\n\n\tgetStatsData( cid ) {\n\n\t\tlet data = this.statsData.get( cid );\n\n\t\tif ( data === undefined ) {\n\n\t\t\tdata = {};\n\n\t\t\tthis.statsData.set( cid, data );\n\n\t\t}\n\n\t\treturn data;\n\n\t}\n\n\tresolveStats( stats ) {\n\n\t\tconst data = this.getStatsData( stats.cid );\n\n\t\tif ( data.initialized !== true ) {\n\n\t\t\tdata.cpu = stats.cpu;\n\t\t\tdata.gpu = stats.gpu;\n\t\t\tdata.stats = [];\n\n\t\t\tdata.initialized = true;\n\n\t\t}\n\n\t\t// store stats\n\n\t\tif ( data.stats.length > this.maxFrames ) {\n\n\t\t\tdata.stats.shift();\n\n\t\t}\n\n\t\tdata.stats.push( stats );\n\n\t\t// compute averages\n\n\t\tdata.cpu = this.getAverageDeltaTime( data, 'cpu' );\n\t\tdata.gpu = this.getAverageDeltaTime( data, 'gpu' );\n\n\t\t// children: the CPU time of a render or compute call includes the calls nested in it, the GPU time of each\n\t\t// pass is measured separately\n\n\t\tfor ( const child of stats.children ) {\n\n\t\t\tthis.resolveStats( child );\n\n\t\t\tconst childData = this.getStatsData( child.cid );\n\n\t\t\tdata.gpu += childData.gpu;\n\n\t\t}\n\n\t\tdata.total = data.cpu + data.gpu;\n\n\t}\n\n\tgetNodes() {\n\n\t\treturn this.currentNodes;\n\n\t}\n\n\tgetAverageDeltaTime( statsData, property, frames = this.fps ) {\n\n\t\tconst statsArray = statsData.stats;\n\n\t\tlet sum = 0;\n\t\tlet count = 0;\n\n\t\tfor ( let i = statsArray.length - 1; i >= 0 && count < frames; i -- ) {\n\n\t\t\tconst stats = statsArray[ i ];\n\t\t\tconst value = stats[ property ];\n\n\t\t\tif ( value > 0 ) {\n\n\t\t\t\t// ignore invalid values\n\n\t\t\t\tsum += value;\n\t\t\t\tcount ++;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn count > 0 ? sum / count : 0;\n\n\t}\n\n\tupdateTabs() {\n\n\t\t// tabs\n\n\t\tconst tabs = Object.values( this.profiler.tabs );\n\n\t\tfor ( const tab of tabs ) {\n\n\t\t\tlet tabData = this.extensionsData.get( tab );\n\n\t\t\tif ( tabData === undefined ) {\n\n\t\t\t\ttab.init( this );\n\n\t\t\t\ttabData = {};\n\n\t\t\t\tthis.extensionsData.set( tab, tabData );\n\n\t\t\t}\n\n\t\t\ttab.update( this );\n\n\t\t}\n\n\t}\n\n\tresolveFrame( frame ) {\n\n\t\tconst previousFrame = this.getFrameById( frame.frameId - 1 );\n\n\t\tif ( ! previousFrame ) return;\n\n\t\tframe.cpu = 0;\n\t\tframe.gpu = 0;\n\t\tframe.total = 0;\n\n\t\tfor ( const stats of frame.children ) {\n\n\t\t\tthis.resolveStats( stats );\n\n\t\t\tconst data = this.getStatsData( stats.cid );\n\n\t\t\tframe.cpu += data.cpu;\n\t\t\tframe.gpu += data.gpu;\n\t\t\tframe.total += data.total;\n\n\t\t}\n\n\t\t// the time since the last frame which rendered, see RendererInspector.finish()\n\n\t\tframe.miscellaneous = frame.deltaTime - frame.total;\n\n\t\tif ( frame.miscellaneous < 0 ) {\n\n\t\t\t// Frame desync, probably due to async GPU timing.\n\n\t\t\tframe.miscellaneous = 0;\n\n\t\t}\n\n\t\t//\n\n\t\tthis.updateCycle( this.displayCycle.text );\n\t\tthis.updateCycle( this.displayCycle.graph );\n\t\tthis.updateCycle( this.displayCycle.toggleGraph );\n\n\t\tif ( this.displayCycle.text.needsUpdate ) {\n\n\t\t\tsetText( this.profiler.toggleButton.querySelector( '.fps-counter' ), this.fps.toFixed() );\n\n\t\t\tthis.performance.updateText( this, frame );\n\t\t\tthis.memory.updateText( this );\n\n\t\t}\n\n\t\tif ( this.displayCycle.toggleGraph.needsUpdate ) {\n\n\t\t\tif ( this.profiler.toggleGraph ) {\n\n\t\t\t\tthis.profiler.toggleGraph.addPoint( 'fps', this.fps );\n\t\t\t\tthis.profiler.toggleGraph.update();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.displayCycle.graph.needsUpdate ) {\n\n\t\t\tthis.performance.updateGraph( this, frame );\n\t\t\tthis.memory.updateGraph( this );\n\n\t\t}\n\n\t\tthis.displayCycle.text.needsUpdate = false;\n\t\tthis.displayCycle.graph.needsUpdate = false;\n\t\tthis.displayCycle.toggleGraph.needsUpdate = false;\n\n\t}\n\n\tupdateCycle( cycle ) {\n\n\t\tcycle.time += this.nodeFrame.deltaTime;\n\n\t\tif ( cycle.time >= cycle.duration ) {\n\n\t\t\tcycle.needsUpdate = true;\n\t\t\tcycle.time = 0;\n\n\t\t}\n\n\t}\n\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis.setRenderer( null );\n\n\t}\n\n}\n\nexport { Inspector, getItem, setItem };\n","import { RenderTarget, Vector2, Node, QuadMesh, NodeMaterial, RendererUtils, MathUtils, RGBFormat, RedFormat, UnsignedInt101111Type, UnsignedByteType } from 'three/webgpu';\nimport { clamp, normalize, reference, Fn, NodeUpdateType, uniform, vec4, passTexture, uv, getViewPosition, screenCoordinate, float, sub, fract, dot, vec2, rand, vec3, Loop, mul, PI, cos, sin, uint, cross, acos, sign, pow, luminance, If, max, abs, Break, sqrt, HALF_PI, div, ceil, shiftRight, convertToTexture, bool, getNormalFromDepth, countOneBits, interleavedGradientNoise, property, outputStruct, context, isBackgroundDepth, min, projectionDepth } from 'three/tsl';\n\nconst _quadMesh = /*@__PURE__*/ new QuadMesh();\nconst _size = /*@__PURE__*/ new Vector2();\n\n// From Activision GTAO paper: https://www.activision.com/cdn/research/s2016_pbs_activision_occlusion.pptx\nconst _temporalRotations = [ 60, 300, 180, 240, 120, 0 ];\nconst _spatialOffsets = [ 0, 0.5, 0.25, 0.75 ];\n\nlet _rendererState;\n\n/**\n * Post processing node for applying Screen Space Global Illumination (SSGI) to a scene.\n *\n * References:\n * - {@link https://github.com/cdrinmatane/SSRT3}.\n * - {@link https://cdrinmatane.github.io/posts/ssaovb-code/}.\n * - {@link https://cdrinmatane.github.io/cgspotlight-slides/ssilvb_slides.pdf}.\n *\n * The quality and performance of the effect mainly depend on `sliceCount` and `stepCount`.\n * The total number of samples taken per pixel is `sliceCount` * `stepCount` * `2`. Here are some\n * recommended presets depending on whether temporal filtering is used or not.\n *\n * With temporal filtering (recommended):\n *\n * - Low: `sliceCount` of `1`, `stepCount` of `12`.\n * - Medium: `sliceCount` of `2`, `stepCount` of `8`.\n * - High: `sliceCount` of `3`, `stepCount` of `16`.\n *\n * Use for a higher slice count if you notice temporal instabilities like flickering. Reduce the sample\n * count then to mitigate the performance lost.\n *\n * Without temporal filtering:\n *\n * - Low: `sliceCount` of `2`, `stepCount` of `6`.\n * - Medium: `sliceCount` of `3`, `stepCount` of `8`.\n * - High: `sliceCount` of `4`, `stepCount` of `12`.\n *\n * @augments Node\n * @three_import import { ssgi } from 'three/addons/tsl/display/SSGINode.js';\n */\nclass SSGINode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'SSGINode';\n\n\t}\n\n\t/**\n\t * Constructs a new SSGI node.\n\t *\n\t * @param {TextureNode} beautyNode - A texture node that represents the beauty or scene pass.\n\t * @param {TextureNode} depthNode - A texture node that represents the scene's depth.\n\t * @param {TextureNode} normalNode - A texture node that represents the scene's normals.\n\t * @param {PerspectiveCamera} camera - The camera the scene is rendered with.\n\t */\n\tconstructor( beautyNode, depthNode, normalNode, camera ) {\n\n\t\tsuper( 'vec4' );\n\n\t\t/**\n\t\t * A texture node that represents the beauty or scene pass.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.beautyNode = beautyNode;\n\n\t\t/**\n\t\t * A node that represents the scene's depth.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.depthNode = depthNode;\n\n\t\t/**\n\t\t * A node that represents the scene's normals. If no normals are passed to the\n\t\t * constructor (because MRT is not available), normals can be automatically\n\t\t * reconstructed from depth values in the shader.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.normalNode = normalNode;\n\n\t\t/**\n\t\t * The resolution scale. Values towards `0.5` noticeably increase noise, so it's\n\t\t * recommended to lower the renderer's pixel ratio first. Use this property only\n\t\t * for fine-tuning performance.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 1\n\t\t */\n\t\tthis.resolutionScale = 1;\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders\n\t\t * its effect once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t/**\n\t\t * Number of per-pixel hemisphere slices. This has a big performance cost and should be kept as low as possible.\n\t\t * Should be in the range `[1, 4]`.\n\t\t *\n\t\t * @type {UniformNode<uint>}\n\t\t * @default 1\n\t\t */\n\t\tthis.sliceCount = uniform( 1, 'uint' );\n\n\t\t/**\n\t\t * Number of samples taken along one side of a given hemisphere slice. This has a big performance cost and should\n\t\t * be kept as low as possible. Should be in the range `[1, 32]`.\n\t\t *\n\t\t * @type {UniformNode<uint>}\n\t\t * @default 12\n\t\t */\n\t\tthis.stepCount = uniform( 12, 'uint' );\n\n\t\t/**\n\t\t * Power function applied to AO to make it appear darker/lighter. Should be in the range `[0, 4]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.aoIntensity = uniform( 1, 'float' );\n\n\t\t/**\n\t\t * Intensity of the indirect diffuse light. Should be in the range `[0, 100]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 10\n\t\t */\n\t\tthis.giIntensity = uniform( 10, 'float' );\n\n\t\t/**\n\t\t * Effective sampling radius in world space. AO and GI can only have influence within that radius.\n\t\t * Should be in the range `[1, 25]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 12\n\t\t */\n\t\tthis.radius = uniform( 12, 'float' );\n\n\t\t/**\n\t\t * Makes the sample distance in screen space instead of world-space (helps having more detail up close).\n\t\t *\n\t\t * @type {UniformNode<bool>}\n\t\t * @default true\n\t\t */\n\t\tthis.useScreenSpaceSampling = uniform( true, 'bool' );\n\n\t\t/**\n\t\t * Controls samples distribution. It's an exponent applied at each step get increasing step size over the distance.\n\t\t * Should be in the range `[1, 3]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 2\n\t\t */\n\t\tthis.expFactor = uniform( 2, 'float' );\n\n\t\t/**\n\t\t * Constant thickness value of objects on the screen in world units. Allows light to pass behind surfaces past that thickness value.\n\t\t * Should be in the range `[0.01, 10]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.thickness = uniform( 1, 'float' );\n\n\t\t/**\n\t\t * Whether to increase thickness linearly over distance or not (avoid losing detail over the distance).\n\t\t *\n\t\t * @type {UniformNode<bool>}\n\t\t * @default false\n\t\t */\n\t\tthis.useLinearThickness = uniform( false, 'bool' );\n\n\t\t/**\n\t\t * How much light backface surfaces emit.\n\t\t * Should be in the range `[0, 1]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0\n\t\t */\n\t\tthis.backfaceLighting = uniform( 0, 'float' );\n\n\t\t/**\n\t\t * Whether to use temporal filtering or not. Setting this property to\n\t\t * `true` requires the usage of `TRAANode`. This will help to reduce noise\n\t\t * although it introduces typical TAA artifacts like ghosting and temporal\n\t\t * instabilities.\n\t\t *\n\t\t * If setting this property to `false`, a manual denoise via `DenoiseNode`\n\t\t * is required.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.useTemporalFiltering = true;\n\n\t\t// private uniforms\n\n\t\t/**\n\t\t * The resolution of the effect.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._resolution = uniform( new Vector2() );\n\n\t\t/**\n\t\t * Used to compute the effective step radius when viewSpaceSampling is `false`.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._halfProjScale = uniform( 1 );\n\n\t\t/**\n\t\t * Temporal direction that influences the rotation angle for each slice.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis._temporalDirection = uniform( 0 );\n\n\t\t/**\n\t\t * Temporal offset added to the initial ray step.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis._temporalOffset = uniform( 0 );\n\n\t\t/**\n\t\t * Resolution scale uniform.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis._resolutionScale = uniform( 0 );\n\n\t\t/**\n\t\t * Represents the projection matrix of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraProjectionMatrix = uniform( camera.projectionMatrix );\n\n\t\t/**\n\t\t * Represents the inverse projection matrix of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraProjectionMatrixInverse = uniform( camera.projectionMatrixInverse );\n\n\t\t/**\n\t\t * Represents the near value of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {ReferenceNode<float>}\n\t\t */\n\t\tthis._cameraNear = reference( 'near', 'float', camera );\n\n\t\t/**\n\t\t * Represents the far value of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {ReferenceNode<float>}\n\t\t */\n\t\tthis._cameraFar = reference( 'far', 'float', camera );\n\n\t\t/**\n\t\t * A reference to the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {PerspectiveCamera}\n\t\t */\n\t\tthis._camera = camera;\n\n\t\t/**\n\t\t * The render target the effect is rendered into. The first texture holds the GI,\n\t\t * the second one the AO.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._ssgiRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, count: 2 } );\n\n\t\tconst aoTexture = this._ssgiRenderTarget.textures[ 0 ];\n\t\taoTexture.name = 'SSGI.AO';\n\t\taoTexture.type = UnsignedByteType;\n\t\taoTexture.format = RedFormat;\n\n\t\tconst giTexture = this._ssgiRenderTarget.textures[ 1 ];\n\t\tgiTexture.name = 'SSGI.GI';\n\t\tgiTexture.type = UnsignedInt101111Type;\n\t\tgiTexture.format = RGBFormat;\n\n\t\t/**\n\t\t * The material that is used to render the effect.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._material = new NodeMaterial();\n\t\tthis._material.name = 'SSGI';\n\n\t\t/**\n\t\t * The AO result of the effect is represented as a separate texture node.\n\t\t *\n\t\t * @private\n\t\t * @type {PassTextureNode}\n\t\t */\n\t\tthis._aoNode = passTexture( this, this._ssgiRenderTarget.textures[ 0 ] );\n\n\t\t/**\n\t\t * The GI result of the effect is represented as a separate texture node.\n\t\t *\n\t\t * @private\n\t\t * @type {PassTextureNode}\n\t\t */\n\t\tthis._giNode = passTexture( this, this._ssgiRenderTarget.textures[ 1 ] );\n\n\t}\n\n\t/**\n\t * Returns the AO result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the AO result of the effect.\n\t */\n\tgetAONode() {\n\n\t\treturn this._aoNode;\n\n\t}\n\n\t/**\n\t * Returns the GI result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the GI result of the effect.\n\t */\n\tgetGINode() {\n\n\t\treturn this._giNode;\n\n\t}\n\n\t/**\n\t * Sets the size of the effect.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetSize( width, height ) {\n\n\t\twidth = Math.round( this.resolutionScale * width );\n\t\theight = Math.round( this.resolutionScale * height );\n\n\t\tthis._resolutionScale.value = this.resolutionScale;\n\t\tthis._resolution.value.set( width, height );\n\t\tthis._ssgiRenderTarget.setSize( width, height );\n\n\t\tthis._halfProjScale.value = height / ( Math.tan( this._camera.fov * MathUtils.DEG2RAD * 0.5 ) * 2 ) * 0.5;\n\n\t}\n\n\t/**\n\t * This method is used to render the effect once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore( frame ) {\n\n\t\tconst { renderer } = frame;\n\n\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t//\n\n\t\tconst size = renderer.getDrawingBufferSize( _size );\n\t\tthis.setSize( size.width, size.height );\n\n\t\t// update temporal uniforms\n\n\t\tif ( this.useTemporalFiltering === true ) {\n\n\t\t\tconst frameId = frame.frameId;\n\n\t\t\tthis._temporalDirection.value = _temporalRotations[ frameId % 6 ] / 360;\n\t\t\tthis._temporalOffset.value = _spatialOffsets[ frameId % 4 ];\n\n\t\t} else {\n\n\t\t\tthis._temporalDirection.value = 1;\n\t\t\tthis._temporalOffset.value = 1;\n\n\t\t}\n\n\t\t//\n\n\t\t_quadMesh.material = this._material;\n\t\t_quadMesh.name = 'SSGI';\n\n\t\t// clear (white for the AO attachement)\n\n\t\trenderer.setClearColor( 0xffffff, 1 );\n\n\t\t// gi\n\n\t\trenderer.setRenderTarget( this._ssgiRenderTarget );\n\t\t_quadMesh.render( renderer );\n\n\t\t// restore\n\n\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {PassTextureNode}\n\t */\n\tsetup( builder ) {\n\n\t\tconst renderer = builder.renderer;\n\n\t\tif ( renderer.backend.isWebGPUBackend === true && renderer.hasFeature( 'rg11b10ufloat-renderable' ) === false ) {\n\n\t\t\tconsole.error( 'THREE.SSGINode: The device does not support the \"rg11b10ufloat-renderable\" feature which is required for SSGI.' );\n\n\t\t}\n\n\t\tconst uvNode = uv();\n\t\tconst MAX_RAY = uint( 32 );\n\t\tconst globalOccludedBitfield = uint( 0 );\n\n\t\tconst sampleDepth = ( uv ) => projectionDepth( this.depthNode.sample( uv ).r, this._cameraNear, this._cameraFar );\n\n\t\tconst sampleCenterDepth = ( uv ) => {\n\n\t\t\t// Sidestep the nearest-rounding during depth access for the unjittered center pixel to avoid banding\n\n\t\t\tconst g = this.depthNode.gather().sample( uv );\n\t\t\tconst depth = builder.renderer.reversedDepthBuffer === true ? max( max( g.x, g.y ), max( g.z, g.w ) ) : min( min( g.x, g.y ), min( g.z, g.w ) );\n\n\t\t\treturn projectionDepth( depth, this._cameraNear, this._cameraFar );\n\n\t\t};\n\n\t\tconst sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.sample( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );\n\t\tconst sampleBeauty = ( uv ) => this.beautyNode.sample( uv );\n\n\t\t// From Activision GTAO paper: https://www.activision.com/cdn/research/s2016_pbs_activision_occlusion.pptx\n\n\t\tconst spatialOffsets = Fn( ( [ position ] ) => {\n\n\t\t\treturn float( 0.25 ).mul( sub( position.y, position.x ).bitAnd( 3 ) );\n\n\t\t}, { position: 'vec2', return: 'float' } );\n\n\t\tconst GTAOFastAcos = Fn( ( [ value ] ) => {\n\n\t\t\tconst outVal = abs( value ).mul( float( - 0.156583 ) ).add( HALF_PI );\n\t\t\toutVal.mulAssign( sqrt( abs( value ).oneMinus() ) );\n\n\t\t\tconst x = value.x.greaterThanEqual( 0 ).select( outVal.x, PI.sub( outVal.x ) );\n\t\t\tconst y = value.y.greaterThanEqual( 0 ).select( outVal.y, PI.sub( outVal.y ) );\n\n\t\t\treturn vec2( x, y );\n\n\t\t}, { value: 'vec2', return: 'vec2' } );\n\n\t\tconst horizonSampling = Fn( ( [ directionIsRight, stepRadius, radiusVS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ] ) => {\n\n\t\t\tconst STEP_COUNT = this.stepCount.toConst();\n\t\t\tconst EXP_FACTOR = this.expFactor.toConst();\n\t\t\tconst THICKNESS = this.thickness.toConst();\n\t\t\tconst BACKFACE_LIGHTING = this.backfaceLighting.toConst();\n\n\t\t\tconst uvDirection = directionIsRight.select( vec2( 1, - 1 ), vec2( - 1, 1 ) ); // Port note: Because of different uv conventions, uv-y has a different sign\n\t\t\tconst samplingDirection = directionIsRight.select( 1, - 1 );\n\n\t\t\tconst color = vec3( 0 );\n\n\t\t\tLoop( { start: uint( 0 ), end: STEP_COUNT, type: 'uint', condition: '<' }, ( { i } ) => {\n\n\t\t\t\tconst offset = pow( abs( mul( stepRadius, float( i ).add( initialRayStep ) ).div( radiusVS ) ), EXP_FACTOR ).mul( radiusVS ).toConst();\n\t\t\t\tconst uvOffset = slideDirTexelSize.mul( max( offset, float( i ).add( 1 ) ) ).toConst();\n\t\t\t\tconst sampleUV = uvNode.add( uvOffset.mul( uvDirection ) ).toConst();\n\n\t\t\t\tIf( sampleUV.x.lessThanEqual( 0 ).or( sampleUV.y.lessThanEqual( 0 ) ).or( sampleUV.x.greaterThanEqual( 1 ) ).or( sampleUV.y.greaterThanEqual( 1 ) ), () => {\n\n\t\t\t\t\tBreak();\n\n\t\t\t\t} );\n\n\t\t\t\tconst sampleViewPosition = getViewPosition( sampleUV, sampleDepth( sampleUV ), this._cameraProjectionMatrixInverse ).toConst();\n\t\t\t\tconst pixelToSample = sampleViewPosition.sub( viewPosition ).normalize().toConst();\n\t\t\t\tconst linearThicknessMultiplier = this.useLinearThickness.select( sampleViewPosition.z.negate().div( this._cameraFar ).clamp().mul( 100 ), float( 1 ) );\n\t\t\t\tconst pixelToSampleBackface = normalize( sampleViewPosition.sub( linearThicknessMultiplier.mul( viewDir ).mul( THICKNESS ) ).sub( viewPosition ) );\n\n\t\t\t\tlet frontBackHorizon = vec2( dot( pixelToSample, viewDir ), dot( pixelToSampleBackface, viewDir ) );\n\t\t\t\tfrontBackHorizon = GTAOFastAcos( clamp( frontBackHorizon, - 1, 1 ) );\n\t\t\t\tfrontBackHorizon = clamp( div( mul( samplingDirection, frontBackHorizon.negate() ).sub( n.sub( HALF_PI ) ), PI ) ); // Port note: subtract half pi instead of adding it\n\t\t\t\tfrontBackHorizon = directionIsRight.select( frontBackHorizon.yx, frontBackHorizon.xy ); // Front/Back get inverted depending on angle\n\n\t\t\t\t// inline ComputeOccludedBitfield() for easier debugging\n\n\t\t\t\tconst minHorizon = frontBackHorizon.x.toConst();\n\t\t\t\tconst maxHorizon = frontBackHorizon.y.toConst();\n\n\t\t\t\tconst startHorizonInt = uint( frontBackHorizon.mul( float( MAX_RAY ) ) ).toConst();\n\t\t\t\tconst angleHorizonInt = uint( ceil( maxHorizon.sub( minHorizon ).mul( float( MAX_RAY ) ) ) ).toConst();\n\t\t\t\tconst angleHorizonBitfield = angleHorizonInt.greaterThan( uint( 0 ) ).select( uint( shiftRight( uint( 0xFFFFFFFF ), uint( 32 ).sub( MAX_RAY ).add( MAX_RAY.sub( angleHorizonInt ) ) ) ), uint( 0 ) ).toConst();\n\t\t\t\tlet currentOccludedBitfield = angleHorizonBitfield.shiftLeft( startHorizonInt );\n\t\t\t\tcurrentOccludedBitfield = currentOccludedBitfield.bitAnd( globalOccludedBitfield.bitNot() );\n\n\t\t\t\tglobalOccludedBitfield.assign( globalOccludedBitfield.bitOr( currentOccludedBitfield ) );\n\t\t\t\tconst numOccludedZones = countOneBits( currentOccludedBitfield );\n\n\t\t\t\t//\n\n\t\t\t\tIf( numOccludedZones.greaterThan( 0 ), () => { // If a ray hit the sample, that sample is visible from shading point\n\n\t\t\t\t\tconst lightColor = sampleBeauty( sampleUV );\n\n\t\t\t\t\tIf( luminance( lightColor ).greaterThan( 0.001 ), () => { // Continue if there is light at that location (intensity > 0)\n\n\t\t\t\t\t\tconst lightDirectionVS = normalize( pixelToSample );\n\t\t\t\t\t\tconst normalDotLightDirection = clamp( dot( viewNormal, lightDirectionVS ) );\n\n\t\t\t\t\t\tIf( normalDotLightDirection.greaterThan( 0.001 ), () => { // Continue if light is facing surface normal\n\n\t\t\t\t\t\t\tconst lightNormalVS = sampleNormal( sampleUV );\n\n\t\t\t\t\t\t\t// Intensity of outgoing light in the direction of the shading point\n\n\t\t\t\t\t\t\tlet lightNormalDotLightDirection = dot( lightNormalVS, lightDirectionVS.negate() );\n\n\t\t\t\t\t\t\tconst d = sign( lightNormalDotLightDirection ).lessThan( 0 ).select( abs( lightNormalDotLightDirection ).mul( BACKFACE_LIGHTING ), abs( lightNormalDotLightDirection ) );\n\t\t\t\t\t\t\tlightNormalDotLightDirection = BACKFACE_LIGHTING.greaterThan( 0 ).and( dot( lightNormalVS, viewDir ).greaterThan( 0 ) ).select( d, clamp( lightNormalDotLightDirection ) );\n\n\t\t\t\t\t\t\tcolor.rgb.addAssign( float( numOccludedZones ).div( float( MAX_RAY ) ).mul( lightColor ).mul( normalDotLightDirection ).mul( lightNormalDotLightDirection ) );\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} );\n\n\t\t\t\t} );\n\n\t\t\t} );\n\n\t\t\treturn color;\n\n\t\t} );\n\n\t\tconst aoField = property( 'float' );\n\t\tconst giField = property( 'vec3' );\n\n\t\tconst outputNode = outputStruct( aoField, giField );\n\n\t\tconst gi = Fn( () => {\n\n\t\t\tconst depth = this._resolutionScale.lessThan( 1 ).select( sampleCenterDepth( uvNode ), sampleDepth( uvNode ) ).toConst();\n\n\t\t\tisBackgroundDepth( depth ).discard();\n\n\t\t\tconst viewPosition = getViewPosition( uvNode, depth, this._cameraProjectionMatrixInverse ).toVar();\n\t\t\tconst viewNormal = sampleNormal( uvNode ).toVar();\n\t\t\tconst viewDir = normalize( viewPosition.xyz.negate() ).toVar();\n\n\t\t\t//\n\n\t\t\tconst noiseOffset = spatialOffsets( screenCoordinate );\n\t\t\tconst noiseDirection = interleavedGradientNoise( screenCoordinate );\n\t\t\tconst noiseJitterIdx = this._temporalDirection.mul( 0.02 ); // Port: Add noiseJitterIdx here for slightly better noise convergence with TRAA (see #31890 for more details)\n\t\t\tconst initialRayStep = fract( noiseOffset.add( this._temporalOffset ) ).add( rand( uvNode.add( noiseJitterIdx ).mul( 2 ).sub( 1 ) ) );\n\n\t\t\tconst ao = float( 0 );\n\t\t\tconst color = vec3( 0 );\n\n\t\t\tconst ROTATION_COUNT = this.sliceCount.toConst();\n\t\t\tconst STEP_COUNT = this.stepCount.toConst();\n\t\t\tconst AO_INTENSITY = this.aoIntensity.toConst();\n\t\t\tconst GI_INTENSITY = this.giIntensity.toConst();\n\t\t\tconst RADIUS = this.radius.toConst();\n\n\t\t\tconst stepRadius = float( 0 ).toVar();\n\n\t\t\tIf( this.useScreenSpaceSampling, () => {\n\n\t\t\t\tstepRadius.assign( RADIUS.mul( this._resolution.x.div( 2 ) ).div( float( 16 ) ) ); // SSRT3 has a bug where stepRadius is divided by STEP_COUNT twice; fix here\n\n\t\t\t} ).Else( () => {\n\n\t\t\t\tstepRadius.assign( max( RADIUS.mul( this._halfProjScale ).div( viewPosition.z.negate() ), float( STEP_COUNT ) ) ); // Port note: viewZ is negative so a negate is required\n\n\t\t\t} );\n\n\t\t\tstepRadius.divAssign( float( STEP_COUNT ).add( 1 ) );\n\t\t\tconst radiusVS = max( 1, float( STEP_COUNT.sub( 1 ) ) ).mul( stepRadius ).toConst();\n\n\t\t\t//\n\n\t\t\tLoop( { start: uint( 0 ), end: ROTATION_COUNT, type: 'uint', condition: '<' }, ( { i } ) => {\n\n\t\t\t\tconst rotationAngle = mul( float( i ).add( noiseDirection ).add( this._temporalDirection ), PI.div( float( ROTATION_COUNT ) ) ).toConst();\n\t\t\t\tconst sliceDir = vec3( vec2( cos( rotationAngle ), sin( rotationAngle ) ), 0 ).toConst();\n\t\t\t\tconst slideDirTexelSize = sliceDir.xy.mul( float( 1 ).div( this._resolution ) ).toConst();\n\n\t\t\t\tconst planeNormal = normalize( cross( sliceDir, viewDir ) ).toConst();\n\t\t\t\tconst tangent = cross( viewDir, planeNormal ).toConst();\n\t\t\t\tconst projectedNormal = viewNormal.sub( planeNormal.mul( dot( viewNormal, planeNormal ) ) ).toConst();\n\t\t\t\tconst projectedNormalNormalized = normalize( projectedNormal ).toConst();\n\n\t\t\t\tconst cos_n = clamp( dot( projectedNormalNormalized, viewDir ), - 1, 1 ).toConst();\n\t\t\t\tconst n = sign( dot( projectedNormal, tangent ) ).negate().mul( acos( cos_n ) ).toConst();\n\n\t\t\t\tglobalOccludedBitfield.assign( 0 );\n\n\t\t\t\tcolor.addAssign( horizonSampling( bool( true ), stepRadius, radiusVS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ) );\n\t\t\t\tcolor.addAssign( horizonSampling( bool( false ), stepRadius, radiusVS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ) );\n\n\t\t\t\tao.addAssign( float( countOneBits( globalOccludedBitfield ) ).div( float( MAX_RAY ) ) );\n\n\t\t\t} );\n\n\t\t\tao.divAssign( float( ROTATION_COUNT ) );\n\t\t\tao.assign( pow( ao.clamp().oneMinus(), AO_INTENSITY ).clamp() );\n\n\t\t\tcolor.divAssign( float( ROTATION_COUNT ) );\n\t\t\tcolor.mulAssign( GI_INTENSITY );\n\n\t\t\t// scale color based on luminance\n\n\t\t\tconst maxLuminance = float( 7 ).toConst(); // 7 represent a HDR luminance value\n\t\t\tconst currentLuminance = luminance( color );\n\n\t\t\tconst scale = currentLuminance.greaterThan( maxLuminance ).select( maxLuminance.div( currentLuminance ), float( 1 ) );\n\t\t\tcolor.mulAssign( scale );\n\n\t\t\taoField.assign( ao );\n\t\t\tgiField.assign( color );\n\n\t\t\treturn vec4( 0 );\n\n\t\t} );\n\n\t\tthis._material.contextNode = context( builder.getSharedContext() );\n\t\tthis._material.colorNode = gi();\n\t\tthis._material.outputNode = outputNode;\n\t\tthis._material.needsUpdate = true;\n\n\t\t//\n\n\t\treturn this._aoNode;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis._ssgiRenderTarget.dispose();\n\n\t\tthis._material.dispose();\n\n\t}\n\n}\n\nexport default SSGINode;\n\n/**\n * TSL function for creating a SSGI effect.\n *\n * @tsl\n * @function\n * @param {TextureNode} beautyNode - The texture node that represents the input of the effect.\n * @param {TextureNode} depthNode - A texture node that represents the scene's depth.\n * @param {TextureNode} normalNode - A texture node that represents the scene's normals.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @returns {SSGINode}\n */\nexport const ssgi = ( beautyNode, depthNode, normalNode, camera ) => new SSGINode( convertToTexture( beautyNode ), depthNode, normalNode, camera );\n","import { DataTexture, RepeatWrapping, Vector2, Vector3, Node } from 'three/webgpu';\nimport { texture, getNormalFromDepth, getViewPosition, convertToTexture, nodeObject, Fn, float, NodeUpdateType, uv, uniform, Loop, luminance, vec2, vec3, vec4, uniformArray, int, dot, max, pow, abs, If, textureSize, sin, cos, mat2, PI, property, isBackgroundDepth } from 'three/tsl';\nimport { SimplexNoise } from '../../math/SimplexNoise.js';\n\n/**\n * Post processing node for denoising data like raw screen-space ambient occlusion output.\n * Denoise can noticeably improve the quality of ambient occlusion but also add quite some\n * overhead to the post processing setup. It's best to make its usage optional (e.g. via\n * graphic settings).\n *\n * Reference: {@link https://openaccess.thecvf.com/content/WACV2021/papers/Khademi_Self-Supervised_Poisson-Gaussian_Denoising_WACV_2021_paper.pdf}.\n *\n * @augments Node\n * @three_import import { denoise } from 'three/addons/tsl/display/DenoiseNode.js';\n */\nclass DenoiseNode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'DenoiseNode';\n\n\t}\n\n\t/**\n\t * Constructs a new denoise node.\n\t *\n\t * @param {TextureNode} textureNode - The texture node that represents the input of the effect (e.g. AO).\n\t * @param {Node<float>} depthNode - A node that represents the scene's depth.\n\t * @param {?Node<vec3>} normalNode - A node that represents the scene's normals.\n\t * @param {Camera} camera - The camera the scene is rendered with.\n\t */\n\tconstructor( textureNode, depthNode, normalNode, camera ) {\n\n\t\tsuper( 'vec4' );\n\n\t\t/**\n\t\t * The texture node that represents the input of the effect (e.g. AO).\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.textureNode = textureNode;\n\n\t\t/**\n\t\t * A node that represents the scene's depth.\n\t\t *\n\t\t * @type {Node<float>}\n\t\t */\n\t\tthis.depthNode = depthNode;\n\n\t\t/**\n\t\t * A node that represents the scene's normals. If no normals are passed to the\n\t\t * constructor (because MRT is not available), normals can be automatically\n\t\t * reconstructed from depth values in the shader.\n\t\t *\n\t\t * @type {?Node<vec3>}\n\t\t */\n\t\tthis.normalNode = normalNode;\n\n\t\t/**\n\t\t * The internal noise texture.\n\t\t *\n\t\t * @private\n\t\t * @type {DataTexture}\n\t\t */\n\t\tthis._noiseTexture = generateDefaultNoise();\n\n\t\t/**\n\t\t * The node represents the internal noise texture.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.noiseNode = texture( this._noiseTexture );\n\n\t\t/**\n\t\t * The luma Phi value.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.lumaPhi = uniform( 5 );\n\n\t\t/**\n\t\t * The depth Phi value.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.depthPhi = uniform( 5 );\n\n\t\t/**\n\t\t * The normal Phi value.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.normalPhi = uniform( 5 );\n\n\t\t/**\n\t\t * The radius.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.radius = uniform( 5 );\n\n\t\t/**\n\t\t * The index.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.index = uniform( 0 );\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node updates\n\t\t * its internal uniforms once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t/**\n\t\t * The resolution of the effect.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._resolution = uniform( new Vector2() );\n\n\t\t/**\n\t\t * An array of sample vectors.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformArrayNode<vec3>}\n\t\t */\n\t\tthis._sampleVectors = uniformArray( generateDenoiseSamples( 16, 2, 1 ) );\n\n\t\t/**\n\t\t * Represents the inverse projection matrix of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraProjectionMatrixInverse = uniform( camera.projectionMatrixInverse );\n\n\t}\n\n\t/**\n\t * This method is used to update internal uniforms once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore() {\n\n\t\tconst map = this.textureNode.value;\n\n\t\tthis._resolution.value.set( map.image.width, map.image.height );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {ShaderCallNodeInternal}\n\t */\n\tsetup( /* builder */ ) {\n\n\t\tconst uvNode = uv();\n\n\t\tconst sampleTexture = ( uv ) => this.textureNode.sample( uv );\n\t\tconst sampleDepth = ( uv ) => this.depthNode.sample( uv ).x;\n\t\tconst sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.sample( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );\n\t\tconst sampleNoise = ( uv ) => this.noiseNode.sample( uv );\n\n\t\tconst denoiseSample = Fn( ( [ center, viewNormal, viewPosition, sampleUv ] ) => {\n\n\t\t\tconst texel = sampleTexture( sampleUv ).toVar();\n\t\t\tconst depth = sampleDepth( sampleUv ).toVar();\n\t\t\tconst normal = sampleNormal( sampleUv ).toVar();\n\t\t\tconst neighborColor = texel.rgb;\n\t\t\tconst viewPos = getViewPosition( sampleUv, depth, this._cameraProjectionMatrixInverse ).toVar();\n\n\t\t\tconst normalDiff = dot( viewNormal, normal ).toVar();\n\t\t\tconst normalSimilarity = pow( max( normalDiff, 0 ), this.normalPhi ).toVar();\n\t\t\tconst lumaDiff = abs( luminance( neighborColor ).sub( luminance( center ) ) ).toVar();\n\t\t\tconst lumaSimilarity = max( float( 1.0 ).sub( lumaDiff.div( this.lumaPhi ) ), 0 ).toVar();\n\t\t\tconst depthDiff = abs( dot( viewPosition.sub( viewPos ), viewNormal ) ).toVar();\n\t\t\tconst depthSimilarity = max( float( 1.0 ).sub( depthDiff.div( this.depthPhi ) ), 0 );\n\t\t\tconst w = lumaSimilarity.mul( depthSimilarity ).mul( normalSimilarity );\n\n\t\t\treturn vec4( neighborColor.mul( w ), w );\n\n\t\t} );\n\n\t\tconst denoise = Fn( ( [ uvNode ] ) => {\n\n\t\t\tconst depth = sampleDepth( uvNode ).toVar();\n\t\t\tconst viewNormal = sampleNormal( uvNode ).toVar();\n\n\t\t\tconst texel = sampleTexture( uvNode ).toVar();\n\t\t\tconst result = property( 'vec4' );\n\n\t\t\tIf( isBackgroundDepth( depth ).or( dot( viewNormal, viewNormal ).equal( 0.0 ) ), () => {\n\n\t\t\t\tresult.assign( texel );\n\n\t\t\t} ).Else( () => {\n\n\t\t\t\tconst center = vec3( texel.rgb );\n\n\t\t\t\tconst viewPosition = getViewPosition( uvNode, depth, this._cameraProjectionMatrixInverse ).toConst();\n\n\t\t\t\tconst noiseResolution = textureSize( this.noiseNode, 0 );\n\t\t\t\tlet noiseUv = vec2( uvNode.x, uvNode.y.oneMinus() );\n\t\t\t\tnoiseUv = noiseUv.mul( this._resolution.div( noiseResolution ) );\n\t\t\t\tconst noiseTexel = sampleNoise( noiseUv ).toVar();\n\n\t\t\t\tconst x = sin( noiseTexel.element( this.index.mod( 4 ).mul( 2 ).mul( PI ) ) );\n\t\t\t\tconst y = cos( noiseTexel.element( this.index.mod( 4 ).mul( 2 ).mul( PI ) ) );\n\n\t\t\t\tconst noiseVec = vec2( x, y );\n\t\t\t\tconst rotationMatrix = mat2( noiseVec.x, noiseVec.y.negate(), noiseVec.x, noiseVec.y );\n\n\t\t\t\tconst totalWeight = float( 1.0 ).toVar();\n\t\t\t\tconst denoised = vec3( texel.rgb ).toVar();\n\n\t\t\t\tLoop( { start: int( 0 ), end: int( 16 ), type: 'int', condition: '<' }, ( { i } ) => {\n\n\t\t\t\t\tconst sampleDir = this._sampleVectors.element( i );\n\t\t\t\t\tconst offset = rotationMatrix.mul( sampleDir.xy.mul( float( 1.0 ).add( sampleDir.z.mul( this.radius.sub( 1 ) ) ) ) ).div( this._resolution );\n\t\t\t\t\tconst sampleUv = uvNode.add( offset );\n\n\t\t\t\t\tconst sampleResult = denoiseSample( center, viewNormal, viewPosition, sampleUv );\n\n\t\t\t\t\tdenoised.addAssign( sampleResult.xyz );\n\t\t\t\t\ttotalWeight.addAssign( sampleResult.w );\n\n\t\t\t\t} );\n\n\t\t\t\tIf( totalWeight.greaterThan( float( 0 ) ), () => {\n\n\t\t\t\t\tdenoised.divAssign( totalWeight );\n\n\t\t\t\t} );\n\n\t\t\t\tresult.assign( vec4( denoised, texel.a ) );\n\n\t\t\t} );\n\n\t\t\treturn result;\n\n\t\t}/*, { uv: 'vec2', return: 'vec4' }*/ );\n\n\t\tconst output = Fn( () => {\n\n\t\t\treturn denoise( uvNode );\n\n\t\t} );\n\n\t\tconst outputNode = output();\n\n\t\treturn outputNode;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis._noiseTexture.dispose();\n\n\t}\n\n}\n\nexport default DenoiseNode;\n\n/**\n * Generates denoise samples based on the given parameters.\n *\n * @private\n * @param {number} numSamples - The number of samples.\n * @param {number} numRings - The number of rings.\n * @param {number} radiusExponent - The radius exponent.\n * @return {Array<Vector3>} The denoise samples.\n */\nfunction generateDenoiseSamples( numSamples, numRings, radiusExponent ) {\n\n\tconst samples = [];\n\n\tfor ( let i = 0; i < numSamples; i ++ ) {\n\n\t\tconst angle = 2 * Math.PI * numRings * i / numSamples;\n\t\tconst radius = Math.pow( i / ( numSamples - 1 ), radiusExponent );\n\t\tsamples.push( new Vector3( Math.cos( angle ), Math.sin( angle ), radius ) );\n\n\t}\n\n\treturn samples;\n\n}\n\n/**\n * Generates a default noise texture for the given size.\n *\n * @private\n * @param {number} [size=64] - The texture size.\n * @return {DataTexture} The generated noise texture.\n */\nfunction generateDefaultNoise( size = 64 ) {\n\n\tconst simplex = new SimplexNoise();\n\n\tconst arraySize = size * size * 4;\n\tconst data = new Uint8Array( arraySize );\n\n\tfor ( let i = 0; i < size; i ++ ) {\n\n\t\tfor ( let j = 0; j < size; j ++ ) {\n\n\t\t\tconst x = i;\n\t\t\tconst y = j;\n\n\t\t\tdata[ ( i * size + j ) * 4 ] = ( simplex.noise( x, y ) * 0.5 + 0.5 ) * 255;\n\t\t\tdata[ ( i * size + j ) * 4 + 1 ] = ( simplex.noise( x + size, y ) * 0.5 + 0.5 ) * 255;\n\t\t\tdata[ ( i * size + j ) * 4 + 2 ] = ( simplex.noise( x, y + size ) * 0.5 + 0.5 ) * 255;\n\t\t\tdata[ ( i * size + j ) * 4 + 3 ] = ( simplex.noise( x + size, y + size ) * 0.5 + 0.5 ) * 255;\n\n\t\t}\n\n\t}\n\n\tconst noiseTexture = new DataTexture( data, size, size );\n\tnoiseTexture.wrapS = RepeatWrapping;\n\tnoiseTexture.wrapT = RepeatWrapping;\n\tnoiseTexture.needsUpdate = true;\n\n\treturn noiseTexture;\n\n}\n\n/**\n * TSL function for creating a denoise effect.\n *\n * @tsl\n * @function\n * @param {Node} node - The node that represents the input of the effect (e.g. AO).\n * @param {Node<float>} depthNode - A node that represents the scene's depth.\n * @param {?Node<vec3>} normalNode - A node that represents the scene's normals.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @returns {DenoiseNode}\n */\nexport const denoise = ( node, depthNode, normalNode, camera ) => new DenoiseNode( convertToTexture( node ), nodeObject( depthNode ), nodeObject( normalNode ), camera );\n","import { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { Camera, Scene } from 'three';\nimport { PerspectiveCamera } from 'three';\nimport type { Node, UniformNode } from 'three/webgpu';\nimport type { PassNode } from 'three/webgpu';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\nimport { add, unpackRGBToNormal, sample, vec3, vec4, uniform } from 'three/tsl';\nimport { ssgi } from 'three/addons/tsl/display/SSGINode.js';\nimport { denoise } from 'three/addons/tsl/display/DenoiseNode.js';\n\nexport interface SsgiPassParameters {\n sliceCount: number;\n stepCount: number;\n radius: number;\n expFactor: number;\n thickness: number;\n backfaceLighting: number;\n aoIntensity: number;\n giIntensity: number;\n aoDenoiseRadius: number;\n giDenoiseRadius: number;\n useLinearThickness: boolean;\n useScreenSpaceSampling: boolean;\n useTemporalFiltering: boolean;\n}\n\nexport interface SsgiPerformanceParameters {\n sliceCount: number;\n stepCount: number;\n}\n\nexport class SsgiRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'SsgiRenderPass';\n override readonly passId = SsgiRenderPass.passId;\n private readonly sliceCount: UniformNode<'uint', number>;\n private readonly stepCount: UniformNode<'uint', number>;\n private readonly radius: UniformNode<'float', number>;\n private readonly expFactor: UniformNode<'float', number>;\n private readonly thickness: UniformNode<'float', number>;\n private readonly backfaceLighting: UniformNode<'float', number>;\n private readonly aoIntensity: UniformNode<'float', number>;\n private readonly giIntensity: UniformNode<'float', number>;\n private readonly useLinearThickness: UniformNode<'bool', boolean>;\n private readonly useScreenSpaceSampling: UniformNode<'bool', boolean>;\n private readonly giDenoiseRadius: UniformNode<'float', number>;\n private readonly aoDenoiseRadius: UniformNode<'float', number>;\n private readonly useTemporalFiltering: boolean;\n\n constructor(params: SsgiPassParameters) {\n super();\n this.sliceCount = uniform(params.sliceCount, 'uint');\n this.stepCount = uniform(params.stepCount, 'uint');\n this.radius = uniform(params.radius);\n this.expFactor = uniform(params.expFactor);\n this.thickness = uniform(params.thickness);\n this.backfaceLighting = uniform(params.backfaceLighting);\n this.aoIntensity = uniform(params.aoIntensity);\n this.giIntensity = uniform(params.giIntensity);\n this.useLinearThickness = uniform(params.useLinearThickness);\n this.useScreenSpaceSampling = uniform(params.useScreenSpaceSampling);\n this.giDenoiseRadius = uniform(params.giDenoiseRadius);\n this.aoDenoiseRadius = uniform(params.aoDenoiseRadius);\n this.useTemporalFiltering = params.useTemporalFiltering;\n }\n\n public updatePerformanceParameters(params: SsgiPerformanceParameters): void {\n this.sliceCount.value = params.sliceCount;\n this.stepCount.value = params.stepCount;\n }\n\n override addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const gui = renderPassSettings.addFolder('SSGI Settings');\n gui\n .add(this.sliceCount, 'value', 1, 4, 1)\n .name('slice count')\n .onChange(() => updateCallback());\n gui\n .add(this.stepCount, 'value', 1, 32, 1)\n .name('step count')\n .onChange(() => updateCallback());\n gui\n .add(this.radius, 'value', 1, 25)\n .name('radius')\n .onChange(() => updateCallback());\n gui\n .add(this.expFactor, 'value', 1, 3)\n .name('exp factor')\n .onChange(() => updateCallback());\n gui\n .add(this.thickness, 'value', 0.01, 10)\n .name('thickness')\n .onChange(() => updateCallback());\n gui\n .add(this.backfaceLighting, 'value', 0, 1)\n .name('backface lighting')\n .onChange(() => updateCallback());\n gui\n .add(this.aoIntensity, 'value', 0, 4)\n .name('AO intensity')\n .onChange(() => updateCallback());\n gui\n .add(this.giIntensity, 'value', 0, 100)\n .name('GI intensity')\n .onChange(() => updateCallback());\n gui\n .add(this.useLinearThickness, 'value')\n .name('use linear thickness')\n .onChange(() => updateCallback());\n gui\n .add(this.useScreenSpaceSampling, 'value')\n .name('use screen-space sampling')\n .onChange(() => updateCallback());\n gui\n .add(this.aoDenoiseRadius, 'value', 0, 20)\n .name('AO denoise radius')\n .onChange(() => updateCallback());\n gui\n .add(this.giDenoiseRadius, 'value', 0, 20)\n .name('GI denoise radius')\n .onChange(() => updateCallback());\n }\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n _scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n if (!(camera instanceof PerspectiveCamera)) {\n return currentNode; // no ssgi for orthographic camera\n }\n if (this.sliceCount.value === 0 || this.stepCount.value === 0) {\n return currentNode; // SSGINode does division by these values\n }\n\n const scenePassColor = basePassNode.getTextureNode('output');\n const scenePassDiffuse = basePassNode.getTextureNode('diffuseColor');\n const scenePassDepth = basePassNode.getTextureNode('depth');\n const scenePassNormal = basePassNode.getTextureNode('normal');\n\n const sceneNormal = sample((uv) => {\n return unpackRGBToNormal(scenePassNormal.sample(uv));\n });\n\n const giPass = ssgi(scenePassColor, scenePassDepth, sceneNormal, camera);\n giPass.sliceCount = this.sliceCount;\n giPass.stepCount = this.stepCount;\n giPass.radius = this.radius;\n giPass.expFactor = this.expFactor;\n giPass.thickness = this.thickness;\n giPass.backfaceLighting = this.backfaceLighting;\n giPass.aoIntensity = this.aoIntensity;\n giPass.giIntensity = this.giIntensity;\n giPass.useLinearThickness = this.useLinearThickness;\n giPass.useScreenSpaceSampling = this.useScreenSpaceSampling;\n giPass.useTemporalFiltering = this.useTemporalFiltering;\n\n let gi = giPass.getGINode().toInspector('SSGI / GI');\n let ao = giPass.getAONode().toInspector('SSGI / AO');\n const denoisedGI = denoise(\n gi,\n scenePassDepth,\n sceneNormal,\n camera,\n ).toInspector('SSGI / GI Denoised');\n denoisedGI.radius = this.giDenoiseRadius;\n const denoisedAO = denoise(\n ao,\n scenePassDepth,\n sceneNormal,\n camera,\n ).toInspector('SSGI / AO Denoised');\n denoisedAO.radius = this.aoDenoiseRadius;\n\n const compositePass = vec4(\n add(\n // @ts-ignore -- three-types messed this one up, works fine but shows an error\n scenePassColor.rgb.mul(denoisedAO.r),\n // @ts-ignore -- three-types messed this one up, works fine but shows an error\n scenePassDiffuse.rgb.mul(denoisedGI.rgb),\n ),\n scenePassColor.a,\n );\n compositePass.name = 'Ssgi Composite';\n\n if (debugMode === 'ao only') {\n return vec4(vec3(ao.r), 1);\n } else if (debugMode === 'gi only') {\n return vec4(gi.rgb, 1);\n } else if (debugMode === 'denoised ao only') {\n // @ts-ignore -- three-types messed this one up, works fine but shows an error\n return vec4(vec3(denoisedAO.r), 1);\n } else if (debugMode === 'denoised gi only') {\n // @ts-ignore -- three-types messed this one up, works fine but shows an error\n return vec4(denoisedGI.rgb, 1);\n } else if (debugMode === 'without denoise') {\n return vec4(\n add(scenePassColor.rgb.mul(ao.r), scenePassDiffuse.rgb.mul(gi.rgb)),\n scenePassColor.a,\n );\n }\n\n return compositePass;\n }\n}\n","import { add, float, Fn, If, luminance, max, struct, vec2, vec4, getViewPosition, logarithmicDepthToViewZ, viewZToOrthographicDepth, viewZToPerspectiveDepth } from 'three/tsl';\n\n/**\n * Optimized version of AABB clipping.\n *\n * Reference: {@link https://github.com/playdeadgames/temporal}\n *\n * @tsl\n * @private\n * @function\n * @param {Node<vec4>} currentColor - The current color.\n * @param {Node<vec4>} historyColor - The history color.\n * @param {Node<vec4>} minColor - The minimum color of the AABB.\n * @param {Node<vec4>} maxColor - The maximum color of the AABB.\n * @return {Node<vec4>} The clipped history color.\n */\nexport const clipAABB = Fn( ( [ currentColor, historyColor, minColor, maxColor ] ) => {\n\n\tconst pClip = maxColor.rgb.add( minColor.rgb ).mul( 0.5 ).toConst();\n\tconst eClip = maxColor.rgb.sub( minColor.rgb ).mul( 0.5 ).add( 1e-7 ).toConst();\n\tconst vClip = historyColor.sub( vec4( pClip, currentColor.a ) ).toConst();\n\tconst vUnit = vClip.xyz.div( eClip ).toConst();\n\tconst absUnit = vUnit.abs().toConst();\n\tconst maxUnit = max( absUnit.x, absUnit.y, absUnit.z ).toConst();\n\treturn maxUnit.greaterThan( 1 ).select(\n\t\tvec4( pClip, currentColor.a ).add( vClip.div( maxUnit ) ),\n\t\thistoryColor\n\t);\n\n}, {\n\tcurrentColor: 'vec4',\n\thistoryColor: 'vec4',\n\tminColor: 'vec4',\n\tmaxColor: 'vec4',\n\treturn: 'vec4'\n} );\n\n/**\n * Blends the current and history color with a flicker reduction based on luminance weighing.\n *\n * @tsl\n * @private\n * @function\n * @param {Node<vec4>} currentColor - The current color.\n * @param {Node<vec4>} historyColor - The history color.\n * @param {Node<float>} currentWeight - The weight of the current color.\n * @return {Node<vec4>} The blended color.\n */\nexport const flickerReduction = Fn( ( [ currentColor, historyColor, currentWeight ] ) => {\n\n\tconst compressedCurrent = currentColor.mul( float( 1 ).div( ( max( currentColor.r, currentColor.g, currentColor.b ).add( 1 ) ) ) ).toConst();\n\tconst compressedHistory = historyColor.mul( float( 1 ).div( ( max( historyColor.r, historyColor.g, historyColor.b ).add( 1 ) ) ) ).toConst();\n\n\tconst luminanceCurrent = luminance( compressedCurrent.rgb ).toConst();\n\tconst luminanceHistory = luminance( compressedHistory.rgb ).toConst();\n\n\tconst weightCurrent = currentWeight.div( luminanceCurrent.add( 1 ) ).toConst();\n\tconst weightHistory = currentWeight.oneMinus().div( luminanceHistory.add( 1 ) ).toConst();\n\n\treturn add( currentColor.mul( weightCurrent ), historyColor.mul( weightHistory ) ).div( max( weightCurrent.add( weightHistory ), 0.00001 ) );\n\n} );\n\n/**\n * Samples the 3×3 neighborhood of the given texel position in the depth buffer and returns\n * the closest depth, its texel position and the farthest depth. Reversed and logarithmic depth\n * values are converted to perspective depth.\n *\n * @tsl\n * @private\n * @function\n * @param {TextureNode} depthNode - The depth buffer.\n * @param {Node<vec2>} positionTexel - The texel position.\n * @param {Node<vec2>} cameraNearFar - The camera's near and far.\n * @return {Node<struct>} A struct with the members `closestDepth`, `closestPositionTexel` and `farthestDepth`.\n */\nexport const sampleCurrentDepth = Fn( ( [ depthNode, positionTexel, cameraNearFar ], builder ) => {\n\n\tconst closestDepth = float( 2 ).toVar();\n\tconst closestPositionTexel = vec2( 0 ).toVar();\n\tconst farthestDepth = float( - 1 ).toVar();\n\n\tfor ( let x = - 1; x <= 1; ++ x ) {\n\n\t\tfor ( let y = - 1; y <= 1; ++ y ) {\n\n\t\t\tconst neighbor = positionTexel.add( vec2( x, y ) ).toVar();\n\t\t\tlet depth = depthNode.load( neighbor ).r;\n\t\t\tif ( builder.renderer.reversedDepthBuffer ) depth = depth.oneMinus();\n\t\t\tif ( builder.renderer.logarithmicDepthBuffer ) depth = logarithmicToPerspectiveDepth( depth, cameraNearFar );\n\t\t\tdepth = depth.toVar();\n\n\t\t\tIf( depth.lessThan( closestDepth ), () => {\n\n\t\t\t\tclosestDepth.assign( depth );\n\t\t\t\tclosestPositionTexel.assign( neighbor );\n\n\t\t\t} );\n\n\t\t\tIf( depth.greaterThan( farthestDepth ), () => {\n\n\t\t\t\tfarthestDepth.assign( depth );\n\n\t\t\t} );\n\n\t\t}\n\n\t}\n\n\treturn currentDepthStruct( closestDepth, closestPositionTexel, farthestDepth );\n\n} );\n\n/**\n * Samples the previous depth buffer and reprojects the depth into the current view.\n *\n * @tsl\n * @private\n * @function\n * @param {TextureNode} previousDepthNode - The previous depth buffer.\n * @param {Node<vec2>} uv - The uv coordinates.\n * @param {Node<mat4>} previousCameraProjectionMatrixInverse - The previous camera projection matrix inverse.\n * @param {Node<mat4>} previousCameraWorldMatrix - The previous camera world matrix.\n * @param {Node<mat4>} cameraWorldMatrixInverse - The current camera world matrix inverse.\n * @param {Node<vec2>} cameraNearFar - The camera's near and far.\n * @param {Camera} camera - The camera.\n * @return {Node<float>} The reprojected depth.\n */\nexport const samplePreviousDepth = Fn( ( [ previousDepthNode, uv, previousCameraProjectionMatrixInverse, previousCameraWorldMatrix, cameraWorldMatrixInverse, cameraNearFar, camera ], builder ) => {\n\n\tlet depth = previousDepthNode.sample( uv ).r;\n\tif ( builder.renderer.logarithmicDepthBuffer ) depth = logarithmicToPerspectiveDepth( depth, cameraNearFar );\n\tconst positionView = getViewPosition( uv, depth, previousCameraProjectionMatrixInverse );\n\tconst positionWorld = previousCameraWorldMatrix.mul( vec4( positionView, 1 ) ).xyz;\n\tconst viewZ = cameraWorldMatrixInverse.mul( vec4( positionWorld, 1 ) ).z;\n\treturn camera.isOrthographicCamera\n\t\t? viewZToOrthographicDepth( viewZ, cameraNearFar.x, cameraNearFar.y )\n\t\t: viewZToPerspectiveDepth( viewZ, cameraNearFar.x, cameraNearFar.y );\n\n} );\n\n/**\n * Computes a sequence of Halton(2, 3) jitter offsets in the range [0, 1].\n *\n * @private\n * @function\n * @param {number} length - The number of offsets.\n * @return {Array<Array<number>>} The jitter offsets.\n */\nexport function computeHaltonOffsets( length ) {\n\n\treturn Array.from( { length }, ( _, index ) => [ halton( index + 1, 2 ), halton( index + 1, 3 ) ] );\n\n}\n\nconst currentDepthStruct = struct( {\n\tclosestDepth: 'float',\n\tclosestPositionTexel: 'vec2',\n\tfarthestDepth: 'float'\n} );\n\nconst logarithmicToPerspectiveDepth = ( depth, cameraNearFar ) => {\n\n\tconst { x: near, y: far } = cameraNearFar;\n\tconst viewZ = logarithmicDepthToViewZ( depth, near, far );\n\treturn viewZToPerspectiveDepth( viewZ, near, far );\n\n};\n\nfunction halton( index, base ) {\n\n\tlet fraction = 1;\n\tlet result = 0;\n\twhile ( index > 0 ) {\n\n\t\tfraction /= base;\n\t\tresult += fraction * ( index % base );\n\t\tindex = Math.floor( index / base );\n\n\t}\n\n\treturn result;\n\n}\n","import { HalfFloatType, Vector2, RenderTarget, RendererUtils, QuadMesh, NodeMaterial, Node, NodeUpdateType, Matrix4, DepthTexture } from 'three/webgpu';\nimport { float, Fn, max, texture, uniform, uv, vec2, convertToTexture, passTexture, velocity, ivec2, mix, context, OnBeforeRenderPipeline, OnAfterRenderPipeline } from 'three/tsl';\nimport { clipAABB, computeHaltonOffsets, flickerReduction, sampleCurrentDepth, samplePreviousDepth } from '../utils/TAAUtils.js';\n\nconst _quadMesh = /*@__PURE__*/ new QuadMesh();\nconst _size = /*@__PURE__*/ new Vector2();\n\nlet _rendererState;\n\n\n/**\n * A special node that applies TRAA (Temporal Reprojection Anti-Aliasing).\n *\n * References:\n * - {@link https://alextardif.com/TAA.html}\n * - {@link https://www.elopezr.com/temporal-aa-and-the-quest-for-the-holy-trail/}\n *\n * Note: MSAA must be disabled when TRAA is in use.\n *\n * @augments Node\n * @three_import import { traa } from 'three/addons/tsl/display/TRAANode.js';\n */\nclass TRAANode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'TRAANode';\n\n\t}\n\n\t/**\n\t * Constructs a new TRAA node.\n\t *\n\t * @param {TextureNode} beautyNode - The texture node that represents the input of the effect.\n\t * @param {TextureNode} depthNode - A node that represents the scene's depth.\n\t * @param {TextureNode} velocityNode - A node that represents the scene's velocity.\n\t * @param {Camera} camera - The camera the scene is rendered with.\n\t */\n\tconstructor( beautyNode, depthNode, velocityNode, camera ) {\n\n\t\tsuper( 'vec4' );\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isTRAANode = true;\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders\n\t\t * its effect once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t/**\n\t\t * The texture node that represents the input of the effect.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.beautyNode = beautyNode;\n\n\t\t/**\n\t\t * A node that represents the scene's velocity.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.depthNode = depthNode;\n\n\t\t/**\n\t\t * A node that represents the scene's velocity.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.velocityNode = velocityNode;\n\n\t\t/**\n\t\t * The camera the scene is rendered with.\n\t\t *\n\t\t * @type {Camera}\n\t\t */\n\t\tthis.camera = camera;\n\n\t\t/**\n\t\t * When the difference between the current and previous depth goes above this threshold,\n\t\t * the history is considered invalid.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0.0005\n\t\t */\n\t\tthis.depthThreshold = 0.0005;\n\n\t\t/**\n\t\t * The depth difference within the 3×3 neighborhood to consider a pixel as an edge.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0.001\n\t\t */\n\t\tthis.edgeDepthDiff = 0.001;\n\n\t\t/**\n\t\t * The history becomes invalid as the pixel length of the velocity approaches this value.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 128\n\t\t */\n\t\tthis.maxVelocityLength = 128;\n\n\t\t/**\n\t\t * Whether to decrease the weight on the current frame when the velocity is more subpixel.\n\t\t * This reduces blurriness under motion, but can introduce a square pattern artifact.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.useSubpixelCorrection = true;\n\n\t\t/**\n\t\t * The jitter index selects the current camera offset value.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._jitterIndex = 0;\n\n\t\t/**\n\t\t * A uniform node holding the inverse resolution value.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._invSize = uniform( new Vector2() );\n\n\t\t/**\n\t\t * The render target that represents the history of frame data.\n\t\t *\n\t\t * @private\n\t\t * @type {?RenderTarget}\n\t\t */\n\t\tthis._historyRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType, depthTexture: new DepthTexture() } );\n\t\tthis._historyRenderTarget.texture.name = 'TRAANode.history';\n\n\t\t/**\n\t\t * The render target for the resolve.\n\t\t *\n\t\t * @private\n\t\t * @type {?RenderTarget}\n\t\t */\n\t\tthis._resolveRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );\n\t\tthis._resolveRenderTarget.texture.name = 'TRAANode.resolve';\n\n\t\t/**\n\t\t * Material used for the resolve step.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._resolveMaterial = new NodeMaterial();\n\t\tthis._resolveMaterial.name = 'TRAA.resolve';\n\n\t\t/**\n\t\t * The result of the effect is represented as a separate texture node.\n\t\t *\n\t\t * @private\n\t\t * @type {PassTextureNode}\n\t\t */\n\t\tthis._textureNode = passTexture( this, this._resolveRenderTarget.texture );\n\n\t\t/**\n\t\t * Used to save the original/unjittered projection matrix.\n\t\t *\n\t\t * @private\n\t\t * @type {Matrix4}\n\t\t */\n\t\tthis._originalProjectionMatrix = new Matrix4();\n\n\t\t/**\n\t\t * A uniform node holding the camera's near and far.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._cameraNearFar = uniform( new Vector2() );\n\n\t\t/**\n\t\t * A uniform node holding the camera world matrix.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraWorldMatrix = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A uniform node holding the camera world matrix inverse.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraWorldMatrixInverse = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A uniform node holding the camera projection matrix inverse.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraProjectionMatrixInverse = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A uniform node holding the previous frame's view matrix.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._previousCameraWorldMatrix = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A uniform node holding the previous frame's projection matrix inverse.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._previousCameraProjectionMatrixInverse = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A texture node for the previous depth buffer.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._previousDepthNode = texture( this._historyRenderTarget.depthTexture );\n\n\t\t/**\n\t\t * The node used to render the scene's velocity.\n\t\t *\n\t\t * @private\n\t\t * @type {?VelocityNode}\n\t\t */\n\t\tthis._velocityNode = null;\n\n\t}\n\n\t/**\n\t * Returns the result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the result of the effect.\n\t */\n\tgetTextureNode() {\n\n\t\treturn this._textureNode;\n\n\t}\n\n\t/**\n\t * Sets the size of the effect.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetSize( width, height ) {\n\n\t\tthis._historyRenderTarget.setSize( width, height );\n\t\tthis._resolveRenderTarget.setSize( width, height );\n\n\t\tthis._invSize.value.set( 1 / width, 1 / height );\n\n\t}\n\n\t/**\n\t * Defines the TRAA's current jitter as a view offset\n\t * to the scene's camera.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetViewOffset( width, height ) {\n\n\t\t// save original/unjittered projection matrix for velocity pass\n\n\t\tthis.camera.updateProjectionMatrix();\n\t\tthis._originalProjectionMatrix.copy( this.camera.projectionMatrix );\n\n\t\tthis._velocityNode.setProjectionMatrix( this._originalProjectionMatrix );\n\n\t\t//\n\n\t\tconst viewOffset = {\n\n\t\t\tfullWidth: width,\n\t\t\tfullHeight: height,\n\t\t\toffsetX: 0,\n\t\t\toffsetY: 0,\n\t\t\twidth: width,\n\t\t\theight: height\n\n\t\t};\n\n\t\tconst jitterOffset = _haltonOffsets[ this._jitterIndex ];\n\n\t\tthis.camera.setViewOffset(\n\n\t\t\tviewOffset.fullWidth, viewOffset.fullHeight,\n\n\t\t\tviewOffset.offsetX + jitterOffset[ 0 ] - 0.5, viewOffset.offsetY + jitterOffset[ 1 ] - 0.5,\n\n\t\t\tviewOffset.width, viewOffset.height\n\n\t\t);\n\n\t}\n\n\t/**\n\t * Clears the view offset from the scene's camera.\n\t */\n\tclearViewOffset() {\n\n\t\tthis.camera.clearViewOffset();\n\n\t\tthis._velocityNode.setProjectionMatrix( null );\n\n\t\t// update jitter index\n\n\t\tthis._jitterIndex ++;\n\t\tthis._jitterIndex = this._jitterIndex % _haltonOffsets.length;\n\n\t}\n\n\t/**\n\t * This method is used to render the effect once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore( frame ) {\n\n\t\tconst { renderer } = frame;\n\n\t\t// store previous frame matrices before updating current ones\n\n\t\tthis._previousCameraWorldMatrix.value.copy( this._cameraWorldMatrix.value );\n\t\tthis._previousCameraProjectionMatrixInverse.value.copy( this._cameraProjectionMatrixInverse.value );\n\n\t\t// update camera matrices uniforms\n\n\t\tthis._cameraNearFar.value.set( this.camera.near, this.camera.far );\n\t\tthis._cameraWorldMatrix.value.copy( this.camera.matrixWorld );\n\t\tthis._cameraWorldMatrixInverse.value.copy( this.camera.matrixWorldInverse );\n\t\tthis._cameraProjectionMatrixInverse.value.copy( this.camera.projectionMatrixInverse );\n\n\t\t// keep the TRAA in sync with the dimensions of the beauty node\n\n\t\tconst beautyRenderTarget = ( this.beautyNode.isRTTNode ) ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget;\n\n\t\tconst width = beautyRenderTarget.texture.width;\n\t\tconst height = beautyRenderTarget.texture.height;\n\n\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t//\n\n\t\tconst needsRestart = this._historyRenderTarget.width !== width || this._historyRenderTarget.height !== height;\n\t\tthis.setSize( width, height );\n\n\t\t// every time when the dimensions change we need fresh history data\n\n\t\tif ( needsRestart === true ) {\n\n\t\t\t// make sure to reset the history with the contents of the beauty buffer otherwise subsequent frames after the\n\t\t\t// resize will fade from a darker color to the correct one because the history was cleared with black.\n\n\t\t\trenderer.copyTextureToTexture( beautyRenderTarget.texture, this._historyRenderTarget.texture );\n\n\t\t}\n\n\t\t// resolve\n\n\t\trenderer.setRenderTarget( this._resolveRenderTarget );\n\t\t_quadMesh.material = this._resolveMaterial;\n\t\t_quadMesh.name = 'TRAA';\n\t\t_quadMesh.render( renderer );\n\t\trenderer.setRenderTarget( null );\n\n\t\t// update history\n\n\t\trenderer.copyTextureToTexture( this._resolveRenderTarget.texture, this._historyRenderTarget.texture );\n\n\t\t// Copy current depth to previous depth buffer\n\n\t\tconst size = renderer.getDrawingBufferSize( _size );\n\n\t\t// only allow the depth copy if the dimensions of the history render target match with the drawing\n\t\t// render buffer and thus the depth texture of the scene. For some reasons, there are timing issues\n\t\t// with WebGPU resulting in different size of the drawing buffer and the beauty render target when\n\t\t// resizing the browser window. This does not happen with the WebGL backend\n\n\t\tif ( this._historyRenderTarget.height === size.height && this._historyRenderTarget.width === size.width ) {\n\n\t\t\tconst currentDepth = this.depthNode.value;\n\t\t\trenderer.copyTextureToTexture( currentDepth, this._historyRenderTarget.depthTexture );\n\n\t\t}\n\n\t\t// restore\n\n\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's render targets and TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {PassTextureNode}\n\t */\n\tsetup( builder ) {\n\n\t\tthis.depthNode.build( builder );\n\t\tthis.velocityNode.build( builder );\n\t\tthis.beautyNode.build( builder );\n\n\t\tif ( builder.renderPipeline && ! builder.context.renderPipelineState.viewOffsetOwner ) {\n\n\t\t\tbuilder.context.renderPipelineState.viewOffsetOwner = this;\n\n\t\t\tOnBeforeRenderPipeline( () => {\n\n\t\t\t\tconst size = builder.renderer.getDrawingBufferSize( _size );\n\t\t\t\tthis.setViewOffset( size.width, size.height );\n\n\t\t\t} );\n\n\t\t\tOnAfterRenderPipeline( () => {\n\n\t\t\t\tthis.clearViewOffset();\n\n\t\t\t} );\n\n\t\t}\n\n\t\tthis._historyRenderTarget.depthTexture.format = this.depthNode.value.format;\n\t\tthis._historyRenderTarget.depthTexture.type = this.depthNode.value.type;\n\n\t\tif ( builder.context.velocity !== undefined ) {\n\n\t\t\tthis._velocityNode = builder.context.velocity;\n\n\t\t} else {\n\n\t\t\tthis._velocityNode = velocity;\n\n\t\t}\n\n\t\t// Performs variance clipping.\n\t\t// See: https://developer.download.nvidia.com/gameworks/events/GDC2016/msalvi_temporal_supersampling.pdf\n\t\tconst varianceClipping = Fn( ( [ positionTexel, currentColor, historyColor, gamma ] ) => {\n\n\t\t\tconst offsets = [\n\t\t\t\t[ - 1, - 1 ],\n\t\t\t\t[ - 1, 1 ],\n\t\t\t\t[ 1, - 1 ],\n\t\t\t\t[ 1, 1 ],\n\t\t\t\t[ 1, 0 ],\n\t\t\t\t[ 0, - 1 ],\n\t\t\t\t[ 0, 1 ],\n\t\t\t\t[ - 1, 0 ]\n\t\t\t];\n\n\t\t\tconst moment1 = currentColor.toVar();\n\t\t\tconst moment2 = currentColor.pow2().toVar();\n\n\t\t\tfor ( const [ x, y ] of offsets ) {\n\n\t\t\t\t// Use max() to prevent NaN values from propagating.\n\t\t\t\tconst neighbor = this.beautyNode.offset( ivec2( x, y ) ).load( positionTexel ).max( 0 );\n\t\t\t\tmoment1.addAssign( neighbor );\n\t\t\t\tmoment2.addAssign( neighbor.pow2() );\n\n\t\t\t}\n\n\t\t\tconst N = float( offsets.length + 1 );\n\t\t\tconst mean = moment1.div( N );\n\t\t\tconst variance = moment2.div( N ).sub( mean.pow2() ).max( 0 ).sqrt().mul( gamma );\n\t\t\tconst minColor = mean.sub( variance );\n\t\t\tconst maxColor = mean.add( variance );\n\n\t\t\treturn clipAABB( mean.clamp( minColor, maxColor ), historyColor, minColor, maxColor );\n\n\t\t} );\n\n\t\t// Returns the amount of subpixel (expressed within [0, 1]) in the velocity.\n\t\tconst subpixelCorrection = Fn( ( [ velocityUV, textureSize ] ) => {\n\n\t\t\tconst velocityTexel = velocityUV.mul( textureSize );\n\t\t\tconst phase = velocityTexel.fract().abs();\n\t\t\tconst weight = max( phase, phase.oneMinus() );\n\t\t\treturn weight.x.mul( weight.y ).oneMinus().div( 0.75 );\n\n\t\t}, { velocityUV: 'vec2', textureSize: 'ivec2', return: 'float' } );\n\n\t\tconst historyNode = texture( this._historyRenderTarget.texture );\n\n\t\tconst resolve = Fn( () => {\n\n\t\t\tconst uvNode = uv();\n\t\t\tconst textureSize = this.beautyNode.size(); // Assumes all the buffers share the same size.\n\t\t\tconst positionTexel = uvNode.mul( textureSize );\n\n\t\t\t// sample the closest and farthest depths in the current buffer\n\n\t\t\tconst currentDepth = sampleCurrentDepth( this.depthNode, positionTexel, this._cameraNearFar );\n\t\t\tconst closestDepth = currentDepth.get( 'closestDepth' );\n\t\t\tconst closestPositionTexel = currentDepth.get( 'closestPositionTexel' );\n\t\t\tconst farthestDepth = currentDepth.get( 'farthestDepth' );\n\n\t\t\t// convert the NDC offset to UV offset\n\n\t\t\tconst offsetUV = this.velocityNode.load( closestPositionTexel ).xy.mul( vec2( 0.5, - 0.5 ) );\n\n\t\t\t// sample the previous depth\n\n\t\t\tconst historyUV = uvNode.sub( offsetUV );\n\t\t\tconst previousDepth = samplePreviousDepth( this._previousDepthNode, historyUV, this._previousCameraProjectionMatrixInverse, this._previousCameraWorldMatrix, this._cameraWorldMatrixInverse, this._cameraNearFar, this.camera );\n\n\t\t\t// history is considered valid when the UV is in range and there's no disocclusion except on edges\n\n\t\t\tconst isValidUV = historyUV.greaterThanEqual( 0 ).all().and( historyUV.lessThanEqual( 1 ).all() );\n\t\t\tconst isEdge = farthestDepth.sub( closestDepth ).greaterThan( this.edgeDepthDiff );\n\t\t\tconst isDisocclusion = closestDepth.sub( previousDepth ).greaterThan( this.depthThreshold );\n\t\t\tconst hasValidHistory = isValidUV.and( isEdge.or( isDisocclusion.not() ) );\n\n\t\t\t// sample the current and previous colors\n\n\t\t\tconst currentColor = this.beautyNode.sample( uvNode );\n\t\t\tconst historyColor = historyNode.sample( historyUV );\n\n\t\t\t// increase the weight towards the current frame under motion\n\n\t\t\tconst motionFactor = uvNode.sub( historyUV ).mul( textureSize ).length().div( this.maxVelocityLength ).saturate();\n\t\t\tconst currentWeight = float( 0.05 ).toVar(); // A minimum weight\n\n\t\t\tif ( this.useSubpixelCorrection ) {\n\n\t\t\t\t// Increase the minimum weight towards the current frame when the velocity is more subpixel.\n\t\t\t\tcurrentWeight.addAssign( subpixelCorrection( offsetUV, textureSize ).mul( 0.25 ) );\n\n\t\t\t}\n\n\t\t\tcurrentWeight.assign( hasValidHistory.select( currentWeight.add( motionFactor ).saturate(), 1 ) );\n\n\t\t\t// Perform neighborhood clipping/clamping. We use variance clipping here.\n\n\t\t\tconst varianceGamma = mix( 0.5, 1, motionFactor.oneMinus().pow2() ); // Reasonable gamma range is [0.75, 2]\n\t\t\tconst clippedHistoryColor = varianceClipping( positionTexel, currentColor, historyColor, varianceGamma );\n\n\t\t\t// flicker reduction based on luminance weighing\n\n\t\t\tconst output = flickerReduction( currentColor, clippedHistoryColor, currentWeight );\n\n\t\t\treturn output;\n\n\t\t} );\n\n\t\t// materials\n\n\t\tthis._resolveMaterial.contextNode = context( builder.getSharedContext() );\n\t\tthis._resolveMaterial.colorNode = resolve();\n\n\t\treturn this._textureNode;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis._historyRenderTarget.dispose();\n\t\tthis._resolveRenderTarget.dispose();\n\n\t\tthis._resolveMaterial.dispose();\n\n\t}\n\n}\n\nexport default TRAANode;\n\nconst _haltonOffsets = /*@__PURE__*/ computeHaltonOffsets( 32 );\n\n/**\n * TSL function for creating a TRAA node for Temporal Reprojection Anti-Aliasing.\n *\n * @tsl\n * @function\n * @param {TextureNode} beautyNode - The texture node that represents the input of the effect.\n * @param {TextureNode} depthNode - A node that represents the scene's depth.\n * @param {TextureNode} velocityNode - A node that represents the scene's velocity.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @returns {TRAANode}\n */\nexport const traa = ( beautyNode, depthNode, velocityNode, camera ) => new TRAANode( convertToTexture( beautyNode ), depthNode, velocityNode, camera );\n","import type { Camera, Scene } from 'three';\nimport { PerspectiveCamera } from 'three';\nimport type { Node, PassNode } from 'three/webgpu';\nimport { traa } from 'three/addons/tsl/display/TRAANode.js';\nimport { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\nexport class TraaRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'TraaRenderPass';\n override readonly passId = TraaRenderPass.passId;\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n _scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n if (!(camera instanceof PerspectiveCamera)) {\n return currentNode; // no ssgi/traa for orthographic camera\n }\n const scenePassDepth = basePassNode.getTextureNode('depth');\n const scenePassVelocity = basePassNode.getTextureNode('velocity');\n\n const traaPass = traa(\n currentNode,\n scenePassDepth,\n scenePassVelocity,\n camera,\n );\n\n if (debugMode === 'velocity') {\n return traaPass.velocityNode;\n }\n\n return traaPass;\n }\n\n override addParametersToGUI(\n _renderPassSettings: ParametersGroup,\n _updateCallback: () => void,\n ): void {\n return;\n }\n}\n","import type { SsgiPerformanceParameters } from './passes/ssgi-render-pass';\nimport type { VxgiPerformanceParameters } from './passes/vxgi-render-pass';\n\nexport interface WebGPUQualityParameters {\n maxDevicePixelRatio: number;\n maxPixelRatioMultiplier: number;\n ssgiPerformanceParameters: SsgiPerformanceParameters;\n vxgiPerformanceParameters: VxgiPerformanceParameters;\n}\n\nexport const WEBGPU_QUALITY_LEVELS = {\n HIGHEST: 'highest',\n HIGHER: 'higher',\n HIGH: 'high',\n MEDIUM: 'medium',\n LOW: 'low',\n LOWEST: 'lowest',\n} as const;\n\nexport type WebGPUQualityLevel =\n (typeof WEBGPU_QUALITY_LEVELS)[keyof typeof WEBGPU_QUALITY_LEVELS];\n\nexport type WebGPUQualityMap = Map<WebGPUQualityLevel, WebGPUQualityParameters>;\n\nexport const WEBGPU_QUALITY_LEVEL_ORDER: WebGPUQualityLevel[] = [\n WEBGPU_QUALITY_LEVELS.HIGHEST,\n WEBGPU_QUALITY_LEVELS.HIGHER,\n WEBGPU_QUALITY_LEVELS.HIGH,\n WEBGPU_QUALITY_LEVELS.MEDIUM,\n WEBGPU_QUALITY_LEVELS.LOW,\n WEBGPU_QUALITY_LEVELS.LOWEST,\n];\n\nexport const WEBGPU_MAX_QUALITY_LEVEL = WEBGPU_QUALITY_LEVEL_ORDER[0];\nexport const WEBGPU_MIN_QUALITY_LEVEL =\n WEBGPU_QUALITY_LEVEL_ORDER[WEBGPU_QUALITY_LEVEL_ORDER.length - 1];\n\nexport const DEFAULT_WEBGPU_QUALITY_LEVEL: WebGPUQualityLevel =\n WEBGPU_QUALITY_LEVELS.HIGHEST;\n\nexport const defaultWebGPUQualityLevelMap: WebGPUQualityMap = new Map([\n [\n WEBGPU_QUALITY_LEVELS.HIGHEST,\n {\n maxDevicePixelRatio: 1.5,\n maxPixelRatioMultiplier: 2,\n ssgiPerformanceParameters: { sliceCount: 3, stepCount: 16 },\n vxgiPerformanceParameters: { coneCount: 4, coneAngle: 40 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.HIGHER,\n {\n maxDevicePixelRatio: 1.5,\n maxPixelRatioMultiplier: 2,\n ssgiPerformanceParameters: { sliceCount: 2, stepCount: 8 },\n vxgiPerformanceParameters: { coneCount: 3, coneAngle: 40 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.HIGH,\n {\n maxDevicePixelRatio: 1.5,\n maxPixelRatioMultiplier: 2,\n ssgiPerformanceParameters: { sliceCount: 1, stepCount: 12 },\n vxgiPerformanceParameters: { coneCount: 3, coneAngle: 50 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.MEDIUM,\n {\n maxDevicePixelRatio: 1.25,\n maxPixelRatioMultiplier: 1.5,\n ssgiPerformanceParameters: { sliceCount: 1, stepCount: 12 },\n vxgiPerformanceParameters: { coneCount: 2, coneAngle: 60 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.LOW,\n {\n maxDevicePixelRatio: 1,\n maxPixelRatioMultiplier: 1,\n ssgiPerformanceParameters: { sliceCount: 1, stepCount: 8 },\n vxgiPerformanceParameters: { coneCount: 2, coneAngle: 70 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.LOWEST,\n {\n maxDevicePixelRatio: 1,\n maxPixelRatioMultiplier: 1,\n ssgiPerformanceParameters: { sliceCount: 0, stepCount: 0 },\n vxgiPerformanceParameters: { coneCount: 0, coneAngle: 70 },\n },\n ],\n]);\n\nconst benchmarkFpsRangeMap = [\n { min: 70, max: Infinity, value: WEBGPU_QUALITY_LEVELS.HIGHEST },\n { min: 55, max: 69, value: WEBGPU_QUALITY_LEVELS.HIGHER },\n { min: 40, max: 54, value: WEBGPU_QUALITY_LEVELS.HIGH },\n { min: 30, max: 39, value: WEBGPU_QUALITY_LEVELS.MEDIUM },\n { min: 20, max: 29, value: WEBGPU_QUALITY_LEVELS.LOW },\n { min: 0, max: 19, value: WEBGPU_QUALITY_LEVELS.LOWEST },\n];\n\nexport const benchmarkFpsToQualityLevel = (fps: number): WebGPUQualityLevel => {\n const match = benchmarkFpsRangeMap.find(\n (range) => fps >= range.min && fps <= range.max,\n );\n return match!.value;\n};\n","import type { Inspector } from 'three/examples/jsm/inspector/Inspector.js';\nimport FpsCounter from '../utils/fps-counter';\nimport type {\n WebGPUQualityLevel,\n WebGPUQualityMap,\n WebGPUQualityParameters,\n} from './roomle-webgpu-renderer-quality-levels';\nimport {\n benchmarkFpsToQualityLevel,\n DEFAULT_WEBGPU_QUALITY_LEVEL,\n defaultWebGPUQualityLevelMap,\n WEBGPU_MAX_QUALITY_LEVEL,\n WEBGPU_MIN_QUALITY_LEVEL,\n WEBGPU_QUALITY_LEVEL_ORDER,\n} from './roomle-webgpu-renderer-quality-levels';\n\n// freeze-frame on quality change to avoid black flicker\nexport const FREEZE_FRAMES_ON_QUALITY_CHANGE = 6;\n\n// how long the fps has to stay beyond a threshold before the quality level is adjusted\nexport const QUALITY_CHANGE_DEBOUNCE_MS = 800;\n\ntype QualityChangeDirection = 'increment' | 'decrement';\n\ntype ApplyQualityParametersCallback = (\n qualityParameters: WebGPUQualityParameters,\n freezeFrames: number,\n) => void;\n\nexport class RoomleWebGPUQualityManager {\n private qualityLevel: WebGPUQualityLevel = DEFAULT_WEBGPU_QUALITY_LEVEL;\n private qualityMap: WebGPUQualityMap = defaultWebGPUQualityLevelMap;\n private fpsCounter = new FpsCounter();\n private qualityChangePendingSince: number | undefined;\n private qualityChangePendingDirection: QualityChangeDirection | undefined;\n private readonly applyQualityParametersCallback: ApplyQualityParametersCallback;\n\n constructor(applyQualityParametersCallback: ApplyQualityParametersCallback) {\n this.applyQualityParametersCallback = applyQualityParametersCallback;\n }\n\n public getQualityLevel(): WebGPUQualityLevel {\n return this.qualityLevel;\n }\n\n public manageQualitySettings(minFps: number, maxFps: number): void {\n this.fpsCounter.update();\n const fps = this.fpsCounter.getFps();\n const shouldDecrementQualityLevel =\n fps > 0 && fps < minFps && this.qualityLevel !== WEBGPU_MIN_QUALITY_LEVEL;\n const shouldIncrementQualityLevel =\n fps > maxFps && this.qualityLevel !== WEBGPU_MAX_QUALITY_LEVEL;\n\n const qualityChangeDirection = shouldDecrementQualityLevel\n ? 'decrement'\n : shouldIncrementQualityLevel\n ? 'increment'\n : undefined;\n\n if (qualityChangeDirection === undefined) {\n this.qualityChangePendingSince = undefined;\n this.qualityChangePendingDirection = undefined;\n return;\n }\n\n const now = (performance || Date).now();\n if (\n this.qualityChangePendingDirection !== qualityChangeDirection ||\n this.qualityChangePendingSince === undefined\n ) {\n this.qualityChangePendingDirection = qualityChangeDirection;\n this.qualityChangePendingSince = now;\n return;\n }\n\n if (now - this.qualityChangePendingSince < QUALITY_CHANGE_DEBOUNCE_MS) {\n return;\n }\n\n if (qualityChangeDirection === 'decrement') {\n this.decrementQualityLevel();\n } else {\n this.incrementQualityLevel();\n }\n\n console.log(`fps at ${fps}, setting quality level to ${this.qualityLevel}`);\n this.qualityChangePendingSince = undefined;\n this.qualityChangePendingDirection = undefined;\n this.fpsCounter.reset();\n }\n\n public incrementQualityLevel(): void {\n const currentIndex = WEBGPU_QUALITY_LEVEL_ORDER.indexOf(this.qualityLevel);\n this.setQualityLevelByOrderIndex(currentIndex - 1);\n }\n\n public decrementQualityLevel(): void {\n const currentIndex = WEBGPU_QUALITY_LEVEL_ORDER.indexOf(this.qualityLevel);\n this.setQualityLevelByOrderIndex(currentIndex + 1);\n }\n\n public setQualityLevel(qualityLevel: WebGPUQualityLevel): void {\n if (this.qualityLevel === qualityLevel) {\n return;\n }\n this.qualityLevel = qualityLevel;\n this.applyCurrentQualityLevel();\n }\n\n public addGUI(inspector: Inspector, updateCallback: () => void): void {\n const qualitySettings = inspector.createParameters('Quality Settings');\n const qualityLevels = Object.fromEntries(\n WEBGPU_QUALITY_LEVEL_ORDER.map((level) => [level, level]),\n ) as Record<string, WebGPUQualityLevel>;\n const params = {\n qualityLevel: this.qualityLevel,\n };\n\n qualitySettings\n .add(params, 'qualityLevel', qualityLevels)\n .onChange((qualityLevel: WebGPUQualityLevel) => {\n this.setQualityLevel(qualityLevel);\n updateCallback();\n });\n }\n\n private setQualityLevelByOrderIndex(index: number): void {\n const clampedIndex = Math.min(\n Math.max(index, 0),\n WEBGPU_QUALITY_LEVEL_ORDER.length - 1,\n );\n this.setQualityLevel(WEBGPU_QUALITY_LEVEL_ORDER[clampedIndex]);\n }\n\n public applyCurrentQualityLevel(\n freezeFrames = FREEZE_FRAMES_ON_QUALITY_CHANGE,\n ): void {\n const qualityParameters = this.qualityMap.get(this.qualityLevel);\n if (!qualityParameters) {\n return;\n }\n this.applyQualityParametersCallback(qualityParameters, freezeFrames);\n }\n\n public async autoDetectInitialQualityLevel(): Promise<void> {\n const { getGPUTier } = await import('@pmndrs/detect-gpu');\n const gpuBenchmark = await getGPUTier({\n benchmarksURL: './benchmarks',\n });\n if (!gpuBenchmark || !gpuBenchmark.fps) {\n console.info(\n 'Could not autodetect performance - no benchmark for graphics hardware. Defaulting to HIGHEST',\n );\n this.qualityLevel = DEFAULT_WEBGPU_QUALITY_LEVEL;\n return;\n }\n this.qualityLevel = benchmarkFpsToQualityLevel(gpuBenchmark.fps);\n console.info(\n `The initial quality setting has been set to ${this.qualityLevel} based on a benchmark performance of ${gpuBenchmark.fps}fps of the graphics hardware.`,\n );\n }\n}\n","import type { Camera, ColorRepresentation, Material, Scene } from 'three';\nimport {\n Color,\n DoubleSide,\n MeshBasicMaterial,\n PerspectiveCamera,\n SRGBColorSpace,\n} from 'three';\nimport type { Node, PassNode, UniformNode, TextureNode } from 'three/webgpu';\nimport {\n fog,\n mix,\n screenUV,\n vec4,\n uniform,\n min,\n positionWorld,\n depthPass,\n} from 'three/tsl';\nimport { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\nexport interface FogPassParameters {\n color: ColorRepresentation;\n nearBlend: number;\n farBlend: number;\n}\n\nexport class FogRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'FogRenderPass';\n override readonly passId = FogRenderPass.passId;\n private readonly fogColor: UniformNode<'color', Color>;\n private readonly fogNearBlend: UniformNode<'float', number>;\n private readonly fogFarBlend: UniformNode<'float', number>;\n private sceneWithFog: Scene | undefined = undefined;\n\n // separate depth only pass for transparent objects\n // which do not write to the normal depth buffer\n private transparentObjectsDepthPass: PassNode | undefined = undefined;\n private readonly depthOverrideMaterial: Material;\n\n constructor(params: FogPassParameters) {\n super();\n this.fogColor = uniform(new Color(params.color));\n this.fogNearBlend = uniform(params.nearBlend);\n this.fogFarBlend = uniform(params.farBlend);\n this.depthOverrideMaterial = new MeshBasicMaterial({ side: DoubleSide });\n }\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n // no fog for orthographic camera\n if (\n !(camera instanceof PerspectiveCamera) ||\n debugMode === 'no fog' ||\n debugMode === 'depth'\n ) {\n this.removeSceneFog();\n return currentNode;\n }\n\n const scenePassDepth = basePassNode.getTextureNode('depth');\n const transparentObjectsDepth = this.getTransparentObjectsDepthPassTexture(\n scene,\n camera,\n );\n // nearest of opaque scene depth and transparent (ghost) depth\n const depth = min(scenePassDepth.r, transparentObjectsDepth.r);\n\n const cameraProjectionMatrixInverse = uniform(\n camera.projectionMatrixInverse,\n );\n const cameraWorldMatrix = uniform(camera.matrixWorld);\n const cameraFar = uniform(camera.far).onRenderUpdate(() => camera.far);\n const fogFar = min(cameraFar, 50).sub(this.fogFarBlend);\n const fogNear = fogFar.sub(this.fogNearBlend);\n\n // map to clip space [-1, 1]^2\n const clipX = screenUV.x.mul(2.0).sub(1.0);\n const clipY = screenUV.y.mul(2.0).sub(1.0);\n const ndc = vec4(clipX, clipY, depth, 1.0);\n\n const viewSpacePosition = cameraProjectionMatrixInverse.mul(ndc);\n const viewSpacePositionNormalizedXYZ = viewSpacePosition.xyz.div(\n viewSpacePosition.w,\n );\n\n const worldPosition = cameraWorldMatrix.mul(\n vec4(viewSpacePositionNormalizedXYZ, 1.0),\n ).xyz;\n const xzDistanceToOrigin = worldPosition.xz.length();\n\n const fogFactor = fogFar\n .sub(xzDistanceToOrigin)\n .div(fogFar.sub(fogNear))\n .clamp(0.0, 1.0)\n .toInspector('Fog / Factor');\n\n this.addSceneFog(scene, fogNear, fogFar);\n\n return mix(vec4(this.fogColor, 1), currentNode, fogFactor).toInspector(\n 'Fog / Composite',\n );\n }\n\n // add basically the same fog again but in the scene fogNode\n // to make it also show in e.g. transmissive materials\n private addSceneFog(\n scene: Scene,\n fogNear: Node<'float'>,\n fogFar: Node<'float'>,\n ) {\n const distance = positionWorld.xz.length();\n\n const fogFactor = fogFar\n .sub(distance)\n .div(fogFar.sub(fogNear))\n .clamp(0.0, 1.0)\n .oneMinus();\n\n scene.fogNode = fog(this.fogColor, fogFactor);\n this.sceneWithFog = scene;\n }\n\n private getTransparentObjectsDepthPassTexture(\n scene: Scene,\n camera: Camera,\n ): TextureNode {\n this.transparentObjectsDepthPass?.dispose();\n this.transparentObjectsDepthPass = depthPass(scene, camera);\n // only draw non-opaque objects, but force them to write only depth\n this.transparentObjectsDepthPass.opaque = false;\n this.transparentObjectsDepthPass.overrideMaterial =\n this.depthOverrideMaterial;\n return this.transparentObjectsDepthPass.getTextureNode('depth');\n }\n\n public removeSceneFog() {\n if (this.sceneWithFog) {\n this.sceneWithFog.fogNode = null;\n this.sceneWithFog = undefined;\n }\n this.transparentObjectsDepthPass?.dispose();\n this.transparentObjectsDepthPass = undefined;\n }\n\n override addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const gui = renderPassSettings.addFolder('Fog Settings');\n gui\n .add(this.fogNearBlend, 'value', 0, 30, 0.1)\n .name('near blend')\n .onChange(() => updateCallback());\n gui\n .add(this.fogFarBlend, 'value', 0, 30, 0.1)\n .name('far blend')\n .onChange(() => updateCallback());\n gui\n .addColor({ color: this.fogColor.value.getHex(SRGBColorSpace) }, 'color')\n .name('color')\n .onChange((value) => {\n this.fogColor.value.set(value);\n updateCallback();\n });\n }\n}\n","import type { Camera, Scene } from 'three';\nimport type { Node, PassNode } from 'three/webgpu';\nimport { context, vec3, vec4 } from 'three/tsl';\nimport { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\n// should be applied last and unconditionally\nexport class DebugRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'DebugRenderPass';\n override readonly passId = DebugRenderPass.passId;\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n _scene: Scene,\n _camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n if (debugMode === 'depth') {\n const scenePassDepth = basePassNode.getTextureNode('depth');\n return vec4(vec3(scenePassDepth.r), 1.0);\n } else if (debugMode === 'direct lighting only') {\n basePassNode.contextNode = context();\n return basePassNode;\n }\n\n return currentNode;\n }\n\n override addParametersToGUI(\n _renderPassSettings: ParametersGroup,\n _updateCallback: () => void,\n ): void {\n // debug GUI is added in RoomleWebGPURenderer#addDebugGUI since it concerns all passes\n return;\n }\n}\n","import { Box3, Color, MathUtils, Matrix4, Vector2, Vector3, BackSide, DoubleSide, FrontSide, SRGBColorSpace } from 'three/webgpu';\n\nconst _matrix = /*@__PURE__*/ new Matrix4();\nconst _box = /*@__PURE__*/ new Box3();\nconst _va = /*@__PURE__*/ new Vector3();\nconst _vb = /*@__PURE__*/ new Vector3();\nconst _vc = /*@__PURE__*/ new Vector3();\nconst _uva = /*@__PURE__*/ new Vector2();\nconst _uvb = /*@__PURE__*/ new Vector2();\nconst _uvc = /*@__PURE__*/ new Vector2();\nconst _uv = /*@__PURE__*/ new Vector2();\nconst _color = /*@__PURE__*/ new Color();\nconst _albedo = /*@__PURE__*/ new Color();\nconst _emissive = /*@__PURE__*/ new Color();\nconst _columns = /*@__PURE__*/ new Map();\n\nconst IMAGE_SAMPLE_SIZE = 64;\nconst POSITION_QUANTIZATION = 131072;\n\n/**\n * Number of floats per triangle record: three positions (vec4 each, w unused),\n * albedo (rgb + side flag) and emissive (rgb + unused).\n */\nexport const TRIANGLE_STRIDE = 20;\n\nconst _srgbLUT = new Float32Array( 256 );\n\nfor ( let i = 0; i < 256; i ++ ) {\n\n\tconst c = i / 255;\n\t_srgbLUT[ i ] = ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n}\n\nclass GrowableFloat32Array {\n\n\tconstructor( initialSize ) {\n\n\t\tthis.array = new Float32Array( initialSize );\n\t\tthis.length = 0;\n\n\t}\n\n\tensure( count ) {\n\n\t\tif ( this.length + count > this.array.length ) {\n\n\t\t\tlet size = this.array.length * 2;\n\t\t\twhile ( size < this.length + count ) size *= 2;\n\n\t\t\tconst array = new Float32Array( size );\n\t\t\tarray.set( this.array );\n\t\t\tthis.array = array;\n\n\t\t}\n\n\t}\n\n\tpush4( x, y, z, w ) {\n\n\t\tconst a = this.array, i = this.length;\n\t\ta[ i ] = x; a[ i + 1 ] = y; a[ i + 2 ] = z; a[ i + 3 ] = w;\n\t\tthis.length += 4;\n\n\t}\n\n\tresult() {\n\n\t\treturn this.array.slice( 0, this.length );\n\n\t}\n\n}\n\n/**\n * Downscales a texture image into a small pixel buffer so triangle colors can be\n * looked up on the CPU. Returns `null` for images that cannot be read.\n *\n * @private\n * @param {Texture} texture - The texture.\n * @param {Map<string, ?Object>} cache - Cache keyed by texture uuid.\n * @return {?{data: Uint8ClampedArray, width: number, height: number, srgb: boolean}} The image sampler.\n */\nfunction getImageSampler( texture, cache ) {\n\n\tif ( cache.has( texture.uuid ) ) return cache.get( texture.uuid );\n\n\tlet sampler = null;\n\tconst image = texture.image;\n\n\tif ( image && texture.isCompressedTexture !== true ) {\n\n\t\tconst srgb = texture.colorSpace === SRGBColorSpace;\n\n\t\tif ( image.data !== undefined && image.width !== undefined ) {\n\n\t\t\t// DataTexture (RGBA 8-bit only)\n\n\t\t\tif ( image.data.length === image.width * image.height * 4 && image.data.BYTES_PER_ELEMENT === 1 ) {\n\n\t\t\t\tsampler = { data: image.data, width: image.width, height: image.height, srgb };\n\n\t\t\t}\n\n\t\t} else if ( image.width > 0 && image.height > 0 ) {\n\n\t\t\ttry {\n\n\t\t\t\tconst size = IMAGE_SAMPLE_SIZE;\n\t\t\t\tconst canvas = ( typeof OffscreenCanvas !== 'undefined' ) ? new OffscreenCanvas( size, size ) : document.createElement( 'canvas' );\n\t\t\t\tcanvas.width = size;\n\t\t\t\tcanvas.height = size;\n\n\t\t\t\tconst context = canvas.getContext( '2d', { willReadFrequently: true } );\n\t\t\t\tcontext.imageSmoothingEnabled = true;\n\t\t\t\tcontext.imageSmoothingQuality = 'high';\n\t\t\t\tcontext.drawImage( image, 0, 0, size, size );\n\n\t\t\t\tsampler = { data: context.getImageData( 0, 0, size, size ).data, width: size, height: size, srgb };\n\n\t\t\t} catch ( e ) {\n\n\t\t\t\tsampler = null;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tcache.set( texture.uuid, sampler );\n\n\treturn sampler;\n\n}\n\n/**\n * Samples the given texture at the given uv coordinates. The result is written\n * into `target` (linear rgb) and the alpha is returned.\n *\n * @private\n */\nfunction sampleTexture( texture, sampler, uv, target ) {\n\n\t_uv.copy( uv );\n\ttexture.transformUv( _uv );\n\n\tconst x = Math.min( sampler.width - 1, Math.max( 0, Math.floor( _uv.x * sampler.width ) ) );\n\tconst y = Math.min( sampler.height - 1, Math.max( 0, Math.floor( _uv.y * sampler.height ) ) );\n\tconst i = ( y * sampler.width + x ) * 4;\n\tconst data = sampler.data;\n\n\tif ( sampler.srgb ) {\n\n\t\ttarget.setRGB( _srgbLUT[ data[ i ] ], _srgbLUT[ data[ i + 1 ] ], _srgbLUT[ data[ i + 2 ] ] );\n\n\t} else {\n\n\t\ttarget.setRGB( data[ i ] / 255, data[ i + 1 ] / 255, data[ i + 2 ] / 255 );\n\n\t}\n\n\treturn data[ i + 3 ] / 255;\n\n}\n\nfunction getMaterialInfo( material, cache, imageCache ) {\n\n\tif ( cache.has( material ) ) return cache.get( material );\n\n\tconst unlit = material.isMeshBasicMaterial === true || material.isMeshBasicNodeMaterial === true;\n\n\tconst info = {\n\t\tunlit,\n\t\tside: material.side === BackSide ? 1 : ( material.side === DoubleSide ? 2 : 0 ),\n\t\topacity: material.transparent === true ? material.opacity : 1,\n\t\talphaTest: material.alphaTest || 0,\n\t\tcolor: material.color ? material.color : null,\n\t\temissive: ( ! unlit && material.emissive ) ? material.emissive : null,\n\t\temissiveIntensity: material.emissiveIntensity !== undefined ? material.emissiveIntensity : 1,\n\t\tmap: null,\n\t\tmapSampler: null,\n\t\temissiveMap: null,\n\t\temissiveMapSampler: null\n\t};\n\n\tif ( material.map && material.map.isTexture ) {\n\n\t\tinfo.mapSampler = getImageSampler( material.map, imageCache );\n\t\tif ( info.mapSampler !== null ) info.map = material.map;\n\n\t}\n\n\tif ( ! unlit && material.emissiveMap && material.emissiveMap.isTexture ) {\n\n\t\tinfo.emissiveMapSampler = getImageSampler( material.emissiveMap, imageCache );\n\t\tif ( info.emissiveMapSampler !== null ) info.emissiveMap = material.emissiveMap;\n\n\t}\n\n\t// the uv transform is normally updated by the renderer\n\n\tif ( info.map !== null && info.map.matrixAutoUpdate === true ) info.map.updateMatrix();\n\tif ( info.emissiveMap !== null && info.emissiveMap.matrixAutoUpdate === true ) info.emissiveMap.updateMatrix();\n\n\tcache.set( material, info );\n\n\treturn info;\n\n}\n\n/**\n * Returns `true` if the object should contribute geometry to the voxel volume.\n *\n * @private\n */\nfunction isVoxelizable( object, layers, exclude ) {\n\n\treturn object.isMesh === true && object.isSkyMesh !== true && object.isBatchedMesh !== true &&\n\t\tlayers.test( object.layers ) === true && exclude.has( object ) === false && object.geometry !== undefined;\n\n}\n\n/**\n * Computes the world-space bounding box of all voxelizable meshes.\n *\n * @param {Scene} scene - The scene.\n * @param {Layers} layers - Only objects that pass the layer test are considered.\n * @param {Set<Object3D>} exclude - Objects to skip.\n * @param {Box3} target - The target box.\n * @return {Box3} The bounding box.\n */\nexport function computeSceneBounds( scene, layers, exclude, target ) {\n\n\ttarget.makeEmpty();\n\n\tscene.traverseVisible( ( object ) => {\n\n\t\tif ( isVoxelizable( object, layers, exclude ) ) {\n\n\t\t\ttarget.expandByObject( object, true );\n\n\t\t}\n\n\t} );\n\n\treturn target;\n\n}\n\n/**\n * Collects the triangles of all meshes in the scene as flat, world-space records suitable\n * for GPU voxelization. Per-triangle albedo and emissive colors are resolved on the CPU\n * (material color multiplied with a texture lookup at the triangle's centroid). Large\n * triangles are subdivided so every record covers a bounded number of voxels.\n *\n * @param {Scene} scene - The scene.\n * @param {Object} options - Options.\n * @param {Box3} options.bounds - Triangles outside these bounds are skipped.\n * @param {Layers} options.layers - Objects must pass this layer test.\n * @param {Set<Object3D>} options.exclude - Objects to skip.\n * @param {number} options.subVoxelSize - Size of a sub-voxel in world units.\n * @param {number} options.maxEdge - Maximum triangle edge length in sub-voxels before subdivision.\n * @param {number} options.minOpacity - Triangles with lower opacity are skipped.\n * @return {{data: Float32Array, count: number}} The triangle records and triangle count.\n */\nexport function collectSceneTriangles( scene, options ) {\n\n\tconst { bounds, layers, exclude, subVoxelSize, maxEdge, minOpacity } = options;\n\n\tconst materialCache = new Map();\n\tconst imageCache = new Map();\n\tconst buffer = new GrowableFloat32Array( 1024 * TRIANGLE_STRIDE );\n\n\tconst maxEdgeSq = ( maxEdge * subVoxelSize ) * ( maxEdge * subVoxelSize );\n\n\t// triangle emission with subdivision of large triangles\n\n\tconst stack = [];\n\n\tfunction emit( a, b, c, albedo, emissive, side ) {\n\n\t\tstack.push( a.x, a.y, a.z, b.x, b.y, b.z, c.x, c.y, c.z );\n\n\t\twhile ( stack.length > 0 ) {\n\n\t\t\tconst cz = stack.pop(), cy = stack.pop(), cx = stack.pop();\n\t\t\tconst bz = stack.pop(), by = stack.pop(), bx = stack.pop();\n\t\t\tconst az = stack.pop(), ay = stack.pop(), ax = stack.pop();\n\n\t\t\tconst abSq = ( bx - ax ) ** 2 + ( by - ay ) ** 2 + ( bz - az ) ** 2;\n\t\t\tconst bcSq = ( cx - bx ) ** 2 + ( cy - by ) ** 2 + ( cz - bz ) ** 2;\n\t\t\tconst caSq = ( ax - cx ) ** 2 + ( ay - cy ) ** 2 + ( az - cz ) ** 2;\n\t\t\tconst longest = Math.max( abSq, bcSq, caSq );\n\n\t\t\tif ( longest > maxEdgeSq ) {\n\n\t\t\t\t// split along the longest edge\n\n\t\t\t\tif ( longest === abSq ) {\n\n\t\t\t\t\tconst mx = ( ax + bx ) * 0.5, my = ( ay + by ) * 0.5, mz = ( az + bz ) * 0.5;\n\t\t\t\t\tstack.push( ax, ay, az, mx, my, mz, cx, cy, cz );\n\t\t\t\t\tstack.push( mx, my, mz, bx, by, bz, cx, cy, cz );\n\n\t\t\t\t} else if ( longest === bcSq ) {\n\n\t\t\t\t\tconst mx = ( bx + cx ) * 0.5, my = ( by + cy ) * 0.5, mz = ( bz + cz ) * 0.5;\n\t\t\t\t\tstack.push( ax, ay, az, bx, by, bz, mx, my, mz );\n\t\t\t\t\tstack.push( ax, ay, az, mx, my, mz, cx, cy, cz );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst mx = ( cx + ax ) * 0.5, my = ( cy + ay ) * 0.5, mz = ( cz + az ) * 0.5;\n\t\t\t\t\tstack.push( ax, ay, az, bx, by, bz, mx, my, mz );\n\t\t\t\t\tstack.push( mx, my, mz, bx, by, bz, cx, cy, cz );\n\n\t\t\t\t}\n\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tbuffer.ensure( TRIANGLE_STRIDE );\n\t\t\tbuffer.push4( ax, ay, az, 0 );\n\t\t\tbuffer.push4( bx, by, bz, 0 );\n\t\t\tbuffer.push4( cx, cy, cz, 0 );\n\t\t\tbuffer.push4( albedo.r, albedo.g, albedo.b, side );\n\t\t\tbuffer.push4( emissive.r, emissive.g, emissive.b, 0 );\n\n\t\t}\n\n\t}\n\n\tfunction processMesh( mesh, matrixWorld ) {\n\n\t\tconst geometry = mesh.geometry;\n\t\tconst positionAttribute = geometry.getAttribute( 'position' );\n\n\t\tif ( positionAttribute === undefined ) return;\n\n\t\tconst index = geometry.index;\n\t\tconst materials = Array.isArray( mesh.material ) ? mesh.material : [ mesh.material ];\n\t\tconst vertexCount = index !== null ? index.count : positionAttribute.count;\n\n\t\tlet groups = geometry.groups;\n\n\t\tif ( Array.isArray( mesh.material ) === false || groups.length === 0 ) {\n\n\t\t\tgroups = [ { start: 0, count: vertexCount, materialIndex: 0 } ];\n\n\t\t}\n\n\t\tconst drawRange = geometry.drawRange;\n\t\tconst rangeStart = drawRange.start;\n\t\tconst rangeEnd = Math.min( vertexCount, drawRange.start + drawRange.count );\n\n\t\tfor ( const group of groups ) {\n\n\t\t\tconst material = materials[ group.materialIndex ];\n\n\t\t\tif ( material === undefined || material === null || material.visible === false ) continue;\n\n\t\t\tconst info = getMaterialInfo( material, materialCache, imageCache );\n\n\t\t\tif ( info.opacity < minOpacity ) continue;\n\n\t\t\tconst uvAttribute = info.map !== null ? geometry.getAttribute( info.map.channel > 0 ? 'uv' + info.map.channel : 'uv' ) : null;\n\t\t\tconst emissiveUVAttribute = info.emissiveMap !== null ? geometry.getAttribute( info.emissiveMap.channel > 0 ? 'uv' + info.emissiveMap.channel : 'uv' ) : null;\n\n\t\t\tconst start = Math.max( group.start, rangeStart );\n\t\t\tconst end = Math.min( group.start + group.count, rangeEnd );\n\n\t\t\tfor ( let i = start; i + 2 < end; i += 3 ) {\n\n\t\t\t\tconst ia = index !== null ? index.getX( i ) : i;\n\t\t\t\tconst ib = index !== null ? index.getX( i + 1 ) : i + 1;\n\t\t\t\tconst ic = index !== null ? index.getX( i + 2 ) : i + 2;\n\n\t\t\t\t_va.fromBufferAttribute( positionAttribute, ia ).applyMatrix4( matrixWorld );\n\t\t\t\t_vb.fromBufferAttribute( positionAttribute, ib ).applyMatrix4( matrixWorld );\n\t\t\t\t_vc.fromBufferAttribute( positionAttribute, ic ).applyMatrix4( matrixWorld );\n\n\t\t\t\t// skip triangles outside the volume\n\n\t\t\t\t_box.makeEmpty().expandByPoint( _va ).expandByPoint( _vb ).expandByPoint( _vc );\n\n\t\t\t\tif ( bounds.intersectsBox( _box ) === false ) continue;\n\n\t\t\t\t// skip degenerate triangles\n\n\t\t\t\tif ( _box.min.distanceToSquared( _box.max ) < 1e-14 ) continue;\n\n\t\t\t\t// resolve colors\n\n\t\t\t\tlet alpha = info.opacity;\n\n\t\t\t\tif ( info.color !== null ) _albedo.copy( info.color ); else _albedo.setRGB( 1, 1, 1 );\n\n\t\t\t\tif ( uvAttribute !== undefined && uvAttribute !== null ) {\n\n\t\t\t\t\t_uva.fromBufferAttribute( uvAttribute, ia );\n\t\t\t\t\t_uvb.fromBufferAttribute( uvAttribute, ib );\n\t\t\t\t\t_uvc.fromBufferAttribute( uvAttribute, ic );\n\t\t\t\t\t_uva.add( _uvb ).add( _uvc ).multiplyScalar( 1 / 3 );\n\n\t\t\t\t\talpha *= sampleTexture( info.map, info.mapSampler, _uva, _color );\n\t\t\t\t\t_albedo.multiply( _color );\n\n\t\t\t\t}\n\n\t\t\t\tif ( info.alphaTest > 0 && alpha < info.alphaTest ) continue;\n\t\t\t\tif ( alpha < minOpacity ) continue;\n\n\t\t\t\tif ( info.unlit ) {\n\n\t\t\t\t\t_emissive.copy( _albedo );\n\t\t\t\t\t_albedo.setRGB( 0, 0, 0 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tif ( info.emissive !== null ) {\n\n\t\t\t\t\t\t_emissive.copy( info.emissive ).multiplyScalar( info.emissiveIntensity );\n\n\t\t\t\t\t\tif ( emissiveUVAttribute !== undefined && emissiveUVAttribute !== null ) {\n\n\t\t\t\t\t\t\t_uva.fromBufferAttribute( emissiveUVAttribute, ia );\n\t\t\t\t\t\t\t_uvb.fromBufferAttribute( emissiveUVAttribute, ib );\n\t\t\t\t\t\t\t_uvc.fromBufferAttribute( emissiveUVAttribute, ic );\n\t\t\t\t\t\t\t_uva.add( _uvb ).add( _uvc ).multiplyScalar( 1 / 3 );\n\n\t\t\t\t\t\t\tsampleTexture( info.emissiveMap, info.emissiveMapSampler, _uva, _color );\n\t\t\t\t\t\t\t_emissive.multiply( _color );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t_emissive.setRGB( 0, 0, 0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\temit( _va, _vb, _vc, _albedo, _emissive, info.side );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tscene.traverseVisible( ( object ) => {\n\n\t\tif ( isVoxelizable( object, layers, exclude ) === false ) return;\n\n\t\tif ( object.isInstancedMesh === true ) {\n\n\t\t\tfor ( let i = 0; i < object.count; i ++ ) {\n\n\t\t\t\tobject.getMatrixAt( i, _matrix );\n\t\t\t\t_matrix.premultiply( object.matrixWorld );\n\t\t\t\tprocessMesh( object, _matrix );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tprocessMesh( object, object.matrixWorld );\n\n\t\t}\n\n\t} );\n\n\tconst data = buffer.result();\n\n\treturn { data, count: data.length / TRIANGLE_STRIDE };\n\n}\n\n/**\n * Marks the sub-voxels inside closed meshes, so cones starting within an object are blocked. Only meshes\n * with visible, opaque and single-sided materials whose geometry is closed and faces outwards are filled.\n *\n * @param {Scene} scene - The scene.\n * @param {Object} options - Options.\n * @param {Vector3} options.boundsMin - The minimum corner of the voxel grid.\n * @param {number} options.voxelSize - The size of a voxel in world units.\n * @param {Vector3} options.gridSize - The number of voxels per axis.\n * @param {Layers} options.layers - Objects must pass this layer test.\n * @param {Set<Object3D>} options.exclude - Objects to skip.\n * @param {Uint8Array} target - One byte per voxel that receives the 2x2x2 sub-voxel bits of the interiors.\n */\nexport function computeSolidVoxels( scene, options, target ) {\n\n\tconst { boundsMin, voxelSize, gridSize, layers, exclude } = options;\n\n\tconst closedGeometries = new Map();\n\n\tscene.traverseVisible( ( object ) => {\n\n\t\tif ( isVoxelizable( object, layers, exclude ) === false || hasSolidMaterials( object ) === false ) return;\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( closedGeometries.has( geometry ) === false ) closedGeometries.set( geometry, isClosed( geometry ) && facesOutwards( geometry ) );\n\n\t\tif ( closedGeometries.get( geometry ) === false ) return;\n\n\t\tif ( object.isInstancedMesh === true ) {\n\n\t\t\tfor ( let i = 0; i < object.count; i ++ ) {\n\n\t\t\t\tobject.getMatrixAt( i, _matrix );\n\t\t\t\t_matrix.premultiply( object.matrixWorld );\n\t\t\t\tfillInterior( geometry, _matrix, boundsMin, voxelSize, gridSize, target );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tfillInterior( geometry, object.matrixWorld, boundsMin, voxelSize, gridSize, target );\n\n\t\t}\n\n\t} );\n\n}\n\n/**\n * Returns `true` if all materials of the mesh render an opaque, single-sided surface.\n *\n * @private\n */\nfunction hasSolidMaterials( mesh ) {\n\n\tconst materials = Array.isArray( mesh.material ) ? mesh.material : [ mesh.material ];\n\n\tfor ( const material of materials ) {\n\n\t\tif ( material.visible === false || material.side !== FrontSide || material.transparent === true || material.alphaTest > 0 ) return false;\n\n\t}\n\n\treturn true;\n\n}\n\n/**\n * Returns `true` if every edge of the geometry is shared by an even number of triangles. Vertices with\n * the same position (e.g. at uv seams) are treated as one vertex.\n *\n * @private\n */\nfunction isClosed( geometry ) {\n\n\tconst position = geometry.getAttribute( 'position' );\n\n\tif ( position === undefined ) return false;\n\n\tconst index = geometry.index;\n\tconst indices = index !== null ? index.array : null;\n\tconst count = index !== null ? index.count : position.count;\n\n\t_box.setFromBufferAttribute( position );\n\n\tconst min = _box.min;\n\tconst size = _box.getSize( _vb );\n\tconst scaleX = POSITION_QUANTIZATION / Math.max( size.x, 1e-9 );\n\tconst scaleY = POSITION_QUANTIZATION / Math.max( size.y, 1e-9 );\n\tconst scaleZ = POSITION_QUANTIZATION / Math.max( size.z, 1e-9 );\n\n\tconst vertexMask = MathUtils.ceilPowerOfTwo( Math.max( position.count, 1 ) * 2 ) - 1;\n\tconst vertexKeys = new Int32Array( ( vertexMask + 1 ) * 3 );\n\tconst vertexSlots = new Int32Array( vertexMask + 1 ).fill( - 1 );\n\tconst vertexIds = new Int32Array( position.count );\n\tlet vertexCount = 0;\n\n\tfor ( let i = 0; i < position.count; i ++ ) {\n\n\t\tconst x = Math.round( ( position.getX( i ) - min.x ) * scaleX );\n\t\tconst y = Math.round( ( position.getY( i ) - min.y ) * scaleY );\n\t\tconst z = Math.round( ( position.getZ( i ) - min.z ) * scaleZ );\n\n\t\tlet slot = ( Math.imul( x, 73856093 ) ^ Math.imul( y, 19349663 ) ^ Math.imul( z, 83492791 ) ) & vertexMask;\n\n\t\twhile ( vertexSlots[ slot ] !== - 1 && ( vertexKeys[ slot * 3 ] !== x || vertexKeys[ slot * 3 + 1 ] !== y || vertexKeys[ slot * 3 + 2 ] !== z ) ) slot = ( slot + 1 ) & vertexMask;\n\n\t\tif ( vertexSlots[ slot ] === - 1 ) {\n\n\t\t\tvertexSlots[ slot ] = vertexCount ++;\n\t\t\tvertexKeys[ slot * 3 ] = x;\n\t\t\tvertexKeys[ slot * 3 + 1 ] = y;\n\t\t\tvertexKeys[ slot * 3 + 2 ] = z;\n\n\t\t}\n\n\t\tvertexIds[ i ] = vertexSlots[ slot ];\n\n\t}\n\n\tconst edgeMask = MathUtils.ceilPowerOfTwo( Math.max( count, 1 ) * 2 ) - 1;\n\tconst edgeKeys = new Int32Array( ( edgeMask + 1 ) * 2 ).fill( - 1 );\n\tconst edgeParity = new Uint8Array( edgeMask + 1 );\n\tlet openEdges = 0;\n\n\tconst toggleEdge = ( a, b ) => {\n\n\t\tif ( a > b ) {\n\n\t\t\tconst t = a; a = b; b = t;\n\n\t\t}\n\n\t\tlet slot = ( Math.imul( a, 73856093 ) ^ Math.imul( b, 19349663 ) ) & edgeMask;\n\n\t\twhile ( edgeKeys[ slot * 2 ] !== - 1 && ( edgeKeys[ slot * 2 ] !== a || edgeKeys[ slot * 2 + 1 ] !== b ) ) slot = ( slot + 1 ) & edgeMask;\n\n\t\tedgeKeys[ slot * 2 ] = a;\n\t\tedgeKeys[ slot * 2 + 1 ] = b;\n\t\tedgeParity[ slot ] ^= 1;\n\t\topenEdges += edgeParity[ slot ] === 1 ? 1 : - 1;\n\n\t};\n\n\tfor ( let i = 0; i + 2 < count; i += 3 ) {\n\n\t\tconst a = vertexIds[ indices !== null ? indices[ i ] : i ];\n\t\tconst b = vertexIds[ indices !== null ? indices[ i + 1 ] : i + 1 ];\n\t\tconst c = vertexIds[ indices !== null ? indices[ i + 2 ] : i + 2 ];\n\n\t\tif ( a === b || b === c || c === a ) continue;\n\n\t\ttoggleEdge( a, b );\n\t\ttoggleEdge( b, c );\n\t\ttoggleEdge( c, a );\n\n\t}\n\n\treturn openEdges === 0;\n\n}\n\n/**\n * Returns `true` if the triangles of the given closed geometry face outwards (positive signed volume).\n *\n * @private\n */\nfunction facesOutwards( geometry ) {\n\n\tconst position = geometry.getAttribute( 'position' );\n\tconst index = geometry.index;\n\tconst indices = index !== null ? index.array : null;\n\tconst count = index !== null ? index.count : position.count;\n\n\t_box.min.fromBufferAttribute( position, 0 );\n\n\tlet volume = 0;\n\n\tfor ( let i = 0; i + 2 < count; i += 3 ) {\n\n\t\t_va.fromBufferAttribute( position, indices !== null ? indices[ i ] : i ).sub( _box.min );\n\t\t_vb.fromBufferAttribute( position, indices !== null ? indices[ i + 1 ] : i + 1 ).sub( _box.min );\n\t\t_vc.fromBufferAttribute( position, indices !== null ? indices[ i + 2 ] : i + 2 ).sub( _box.min );\n\n\t\tvolume += _va.dot( _vb.cross( _vc ) );\n\n\t}\n\n\treturn volume > 0;\n\n}\n\n/**\n * Marks the sub-voxels between pairs of surface crossings along each sub-voxel column in x.\n *\n * @private\n */\nfunction fillInterior( geometry, matrix, boundsMin, voxelSize, gridSize, target ) {\n\n\tconst position = geometry.getAttribute( 'position' );\n\tconst index = geometry.index;\n\tconst count = index !== null ? index.count : position.count;\n\n\tconst invSubVoxel = 2 / voxelSize;\n\tconst columnsY = gridSize.y * 2, columnsZ = gridSize.z * 2, length = gridSize.x * 2;\n\n\t_columns.clear();\n\n\tfor ( let i = 0; i + 2 < count; i += 3 ) {\n\n\t\tconst a = _va.fromBufferAttribute( position, index !== null ? index.getX( i ) : i ).applyMatrix4( matrix ).sub( boundsMin ).multiplyScalar( invSubVoxel );\n\t\tlet b = _vb.fromBufferAttribute( position, index !== null ? index.getX( i + 1 ) : i + 1 ).applyMatrix4( matrix ).sub( boundsMin ).multiplyScalar( invSubVoxel );\n\t\tlet c = _vc.fromBufferAttribute( position, index !== null ? index.getX( i + 2 ) : i + 2 ).applyMatrix4( matrix ).sub( boundsMin ).multiplyScalar( invSubVoxel );\n\n\t\tconst area = edgeFunction( a, b, c.y, c.z );\n\n\t\tif ( area === 0 ) continue;\n\n\t\tif ( area < 0 ) {\n\n\t\t\tconst t = b; b = c; c = t;\n\n\t\t}\n\n\t\tconst j0 = Math.max( Math.ceil( Math.min( a.y, b.y, c.y ) - 0.5 ), 0 );\n\t\tconst j1 = Math.min( Math.floor( Math.max( a.y, b.y, c.y ) - 0.5 ), columnsY - 1 );\n\t\tconst k0 = Math.max( Math.ceil( Math.min( a.z, b.z, c.z ) - 0.5 ), 0 );\n\t\tconst k1 = Math.min( Math.floor( Math.max( a.z, b.z, c.z ) - 0.5 ), columnsZ - 1 );\n\n\t\tfor ( let k = k0; k <= k1; k ++ ) {\n\n\t\t\tfor ( let j = j0; j <= j1; j ++ ) {\n\n\t\t\t\tconst y = j + 0.5, z = k + 0.5;\n\n\t\t\t\tconst wa = edgeFunction( b, c, y, z );\n\t\t\t\tconst wb = edgeFunction( c, a, y, z );\n\t\t\t\tconst wc = edgeFunction( a, b, y, z );\n\n\t\t\t\tif ( isInside( wa, b, c ) && isInside( wb, c, a ) && isInside( wc, a, b ) ) {\n\n\t\t\t\t\tconst column = j + k * columnsY;\n\t\t\t\t\tlet crossings = _columns.get( column );\n\n\t\t\t\t\tif ( crossings === undefined ) {\n\n\t\t\t\t\t\tcrossings = [];\n\t\t\t\t\t\t_columns.set( column, crossings );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcrossings.push( ( wa * a.x + wb * b.x + wc * c.x ) / ( wa + wb + wc ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfor ( const [ column, crossings ] of _columns ) {\n\n\t\tif ( crossings.length % 2 !== 0 ) continue;\n\n\t\tcrossings.sort( ( p, q ) => p - q );\n\n\t\tconst j = column % columnsY, k = ( column - j ) / columnsY;\n\t\tconst offset = gridSize.x * ( ( j >> 1 ) + gridSize.y * ( k >> 1 ) );\n\t\tconst bitsYZ = ( ( j & 1 ) << 1 ) | ( ( k & 1 ) << 2 );\n\n\t\tfor ( let n = 0; n < crossings.length; n += 2 ) {\n\n\t\t\tconst i0 = Math.max( Math.ceil( crossings[ n ] - 0.5 ), 0 );\n\t\t\tconst i1 = Math.min( Math.ceil( crossings[ n + 1 ] - 0.5 ), length );\n\n\t\t\tfor ( let i = i0; i < i1; i ++ ) target[ offset + ( i >> 1 ) ] |= 1 << ( ( i & 1 ) | bitsYZ );\n\n\t\t}\n\n\t}\n\n}\n\n/**\n * Edge function of the edge from `a` to `b` at the given point in the yz plane. As in the watertight\n * ray/triangle test, the vertices are taken relative to the point, so a shared edge evaluates exactly\n * opposite for both of its triangles.\n *\n * @private\n */\nfunction edgeFunction( a, b, y, z ) {\n\n\treturn ( a.y - y ) * ( b.z - z ) - ( a.z - z ) * ( b.y - y );\n\n}\n\n/**\n * Inside test for an edge function value. Points on an edge belong to one triangle only (top-left rule).\n *\n * @private\n */\nfunction isInside( w, a, b ) {\n\n\tif ( w !== 0 ) return w > 0;\n\n\tconst dz = b.z - a.z;\n\n\treturn dz < 0 || ( dz === 0 && b.y > a.y );\n\n}\n","import { float, vec3, vec4, If, Loop, Break, max, min, abs, dot, cross, normalize, clamp, log2, exp2, fract, sqrt, cos, sin, select, EPSILON, PI } from 'three/tsl';\n\n/**\n * Emits the intersection of a ray with the bounds of the given volume.\n *\n * @param {VXGIVolume} volume - The volume.\n * @param {Node<vec3>} origin - The ray origin.\n * @param {Node<vec3>} direction - The normalized ray direction.\n * @return {{tEnter: Node<float>, tExit: Node<float>}} The entry and exit distances. The ray misses the volume if `tExit <= tEnter`.\n */\nexport function intersectVolume( volume, origin, direction ) {\n\n\tconst boundsMin = volume.boundsMinNode;\n\tconst boundsMax = boundsMin.add( volume.volumeSizeNode ).toConst();\n\n\tconst safeDirection = vec3(\n\t\tselect( abs( direction.x ).lessThan( EPSILON ), EPSILON, direction.x ),\n\t\tselect( abs( direction.y ).lessThan( EPSILON ), EPSILON, direction.y ),\n\t\tselect( abs( direction.z ).lessThan( EPSILON ), EPSILON, direction.z )\n\t).toConst();\n\n\tconst invDirection = float( 1 ).div( safeDirection ).toConst();\n\tconst t0 = boundsMin.sub( origin ).mul( invDirection ).toConst();\n\tconst t1 = boundsMax.sub( origin ).mul( invDirection ).toConst();\n\tconst tNear = min( t0, t1 ).toConst();\n\tconst tFar = max( t0, t1 ).toConst();\n\n\tconst tEnter = max( max( tNear.x, tNear.y ), max( tNear.z, 0 ) ).toConst();\n\tconst tExit = min( min( tFar.x, tFar.y ), tFar.z ).toConst();\n\n\treturn { tEnter, tExit };\n\n}\n\n/**\n * Emits a directional radiance lookup: for each axis the direction block facing the ray is\n * sampled from the directional texture and the three samples are blended with the squared\n * direction components. The block is selected arithmetically, so the lookup does not branch.\n *\n * @param {VXGIVolume} volume - The volume.\n * @param {Texture3DNode} directionalNode - The directional radiance texture node.\n * @param {Node<vec3>} uvw - The texture coordinates within the volume.\n * @param {Node<float>} level - The mip level of the directional texture.\n * @param {Node<vec3>} direction - The normalized ray direction.\n * @return {Node<vec4>} The premultiplied radiance and its weight.\n */\nexport function sampleDirectional( volume, directionalNode, uvw, level, direction ) {\n\n\tconst weights = direction.mul( direction ).toConst();\n\n\t// keep the lookup inside its block: clamp x by half a texel of the coarser blended level\n\n\tconst halfTexel = exp2( level.ceil() ).mul( 0.5 ).div( volume.directionalWidthNode ).toConst();\n\tconst u = uvw.x.clamp( halfTexel, halfTexel.oneMinus() ).toConst();\n\n\tconst result = vec4( 0 ).toVar();\n\n\tfor ( let axis = 0; axis < 3; axis ++ ) {\n\n\t\tconst component = [ 'x', 'y', 'z' ][ axis ];\n\t\tconst block = float( axis * 2 ).add( select( direction[ component ].lessThan( 0 ), 1, 0 ) );\n\t\tconst blockUVW = vec3( block.add( u ).div( 6 ), uvw.y, uvw.z );\n\n\t\tresult.addAssign( directionalNode.sample( blockUVW ).level( level ).mul( weights[ component ] ) );\n\n\t}\n\n\treturn result;\n\n}\n\n/**\n * Creates a cone tracing function for a {@link VXGIVolume}. The returned function emits\n * TSL code that marches a cone through the volume's opacity/radiance mip chain and returns the\n * gathered radiance, the accumulated occlusion and a distance-weighted occlusion for AO.\n *\n * Implements the approximate voxel cone tracing of Crassin et al. 2011: the cone is sampled at\n * the mip level matching its current diameter with quadrilinear interpolation, samples are\n * composited front-to-back with the emission-absorption model, the opacity of a sample is\n * corrected for the step size and the anisotropic opacity (and, if given, the directional\n * radiance) is interpolated from the three directional values closest to the cone direction.\n * Cones leaving the volume gather nothing.\n *\n * @param {VXGIVolume} volume - The volume to trace.\n * @param {Object} [options={}] - Options.\n * @param {?TextureNode} [options.radianceNode=null] - The radiance texture node to gather from. If `null`, only occlusion is computed.\n * @param {?Texture3DNode} [options.directionalNode=null] - The directional radiance texture node of the coarser levels, see {@link VXGIVolume#directionalRadiance}. If `null`, the coarser levels are gathered from the radiance node's mips.\n * @param {number} [options.maxSteps=128] - Upper bound of steps per cone.\n * @return {Function} A function `( origin, direction, tanHalfAngle, maxDistance, aoDistance = null ) => { color, alpha, ao }`. AO is only computed if `aoDistance` is given.\n */\nexport function createConeTracer( volume, options = {} ) {\n\n\tconst { radianceNode = null, directionalNode = null, maxSteps = 128 } = options;\n\n\tconst opacityNode = volume.opacityNode;\n\tconst boundsMin = volume.boundsMinNode;\n\tconst volumeSize = volume.volumeSizeNode;\n\tconst voxelSize = volume.voxelSizeNode;\n\tconst maxLevel = volume.maxLevelNode;\n\tconst stepScale = volume.stepScale;\n\n\treturn ( origin, direction, tanHalfAngle, maxDistance, aoDistance = null ) => {\n\n\t\tconst color = vec3( 0 ).toVar();\n\t\tconst alpha = float( 0 ).toVar();\n\t\tconst ao = float( 0 ).toVar();\n\n\t\tconst { tEnter, tExit } = intersectVolume( volume, origin, direction );\n\n\t\t// cones start one voxel away from their origin so the voxels the origin lies in are not sampled\n\n\t\tconst t = max( tEnter, voxelSize ).toVar();\n\t\tconst limit = min( tExit, maxDistance ).toConst();\n\n\t\t// interpolation weights of the three directional opacity values (sum to one)\n\n\t\tconst directionWeights = direction.mul( direction ).toConst();\n\n\t\t// AO falloff 1 / ( 1 + r / aoDistance )\n\n\t\tconst aoFalloff = aoDistance !== null ? select( aoDistance.greaterThan( 0 ), float( 1 ).div( max( aoDistance, EPSILON ) ), float( 0 ) ).toConst() : null;\n\n\t\tIf( tExit.greaterThan( t ), () => {\n\n\t\t\tLoop( { start: 0, end: maxSteps, type: 'int', condition: '<', name: 's' }, () => {\n\n\t\t\t\tIf( t.greaterThanEqual( limit ).or( alpha.greaterThanEqual( 0.98 ) ), () => {\n\n\t\t\t\t\tBreak();\n\n\t\t\t\t} );\n\n\t\t\t\tconst diameter = max( t.mul( 2 ).mul( tanHalfAngle ), voxelSize ).toConst();\n\t\t\t\tconst lod = clamp( log2( diameter.div( voxelSize ) ), 0, maxLevel ).toConst();\n\t\t\t\tconst position = origin.add( direction.mul( t ) ).toConst();\n\t\t\t\tconst uvw = position.sub( boundsMin ).div( volumeSize ).toConst();\n\n\t\t\t\tconst opacity = opacityNode.sample( uvw ).level( lod ).toConst();\n\n\t\t\t\t// directional opacity, corrected for a step that is a fraction of the texel size\n\n\t\t\t\tconst a = clamp( dot( opacity.xyz, directionWeights ), 0, 1 ).oneMinus().pow( stepScale ).oneMinus().toConst();\n\t\t\t\tconst weight = a.mul( alpha.oneMinus() ).toConst();\n\n\t\t\t\tif ( radianceNode !== null ) {\n\n\t\t\t\t\tlet radiance;\n\n\t\t\t\t\tif ( directionalNode === null ) {\n\n\t\t\t\t\t\tradiance = radianceNode.sample( uvw ).level( lod ).toConst();\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// the finest level is isotropic, coarser levels are stored directionally at half\n\t\t\t\t\t\t// resolution; their weight only counts the surfaces facing the ray\n\n\t\t\t\t\t\tradiance = vec4( 0 ).toVar();\n\n\t\t\t\t\t\tIf( lod.lessThan( 1 ), () => {\n\n\t\t\t\t\t\t\tradiance.assign( radianceNode.sample( uvw ).level( float( 0 ) ) );\n\n\t\t\t\t\t\t} ).Else( () => {\n\n\t\t\t\t\t\t\tradiance.assign( sampleDirectional( volume, directionalNode, uvw, lod.sub( 1 ), direction ) );\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcolor.addAssign( radiance.rgb.div( max( radiance.a, 1e-4 ) ).mul( weight ) );\n\n\t\t\t\t}\n\n\t\t\t\talpha.addAssign( weight );\n\n\t\t\t\tif ( aoFalloff !== null ) {\n\n\t\t\t\t\tao.addAssign( a.mul( ao.oneMinus() ).div( t.mul( aoFalloff ).add( 1 ) ) );\n\n\t\t\t\t}\n\n\t\t\t\tt.addAssign( voxelSize.mul( exp2( lod ) ).mul( stepScale ) );\n\n\t\t\t} );\n\n\t\t} );\n\n\t\treturn { color, alpha, ao };\n\n\t};\n\n}\n\n/**\n * Emits a diffuse gather: Traces stratified cosine-weighted cones around the normal and averages them.\n *\n * @param {Function} trace - The cone tracing function, see {@link createConeTracer}.\n * @param {Node<vec3>} origin - The origin of the cones.\n * @param {Node<vec3>} normal - The normalized surface normal.\n * @param {Node<uint>|number} coneCount - The number of cones.\n * @param {Node<float>} tanHalfAngle - The tangent of half the cone angle.\n * @param {Node<float>} maxDistance - The maximum trace distance.\n * @param {Node<float>|number} rotation - Rotation of the cones around the normal in `[0, 1)`.\n * @param {Node<float>|number} elevation - Offset of the cones within their elevation strata in `[0, 1)`.\n * @param {?Node<float>} [aoDistance=null] - The AO falloff distance. AO is only computed if given.\n * @return {{color: Node<vec3>, ao: Node<float>}} The mean radiance and the mean AO of the cones.\n */\nexport function gather( trace, origin, normal, coneCount, tanHalfAngle, maxDistance, rotation, elevation, aoDistance = null ) {\n\n\t// tangent frame\n\n\tconst up = select( abs( normal.y ).lessThan( 0.99 ), vec3( 0, 1, 0 ), vec3( 1, 0, 0 ) );\n\tconst tangent = normalize( cross( normal, up ) ).toConst();\n\tconst bitangent = cross( normal, tangent ).toConst();\n\n\tconst color = vec3( 0 ).toVar();\n\tconst ao = float( 0 ).toVar();\n\n\tLoop( { start: 0, end: coneCount, type: 'uint', condition: '<', name: 'c' }, ( { c } ) => {\n\n\t\t// stratified cosine-weighted directions\n\n\t\tconst u1 = float( c ).add( elevation ).div( float( coneCount ) ).toConst();\n\t\tconst u2 = fract( float( c ).mul( 0.618034 ).add( rotation ) ).toConst();\n\t\tconst sinTheta = sqrt( u1 ).toConst();\n\t\tconst cosTheta = sqrt( u1.oneMinus() ).toConst();\n\t\tconst phi = u2.mul( PI.mul( 2 ) ).toConst();\n\n\t\tconst direction = normalize( tangent.mul( cos( phi ).mul( sinTheta ) ).add( bitangent.mul( sin( phi ).mul( sinTheta ) ) ).add( normal.mul( cosTheta ) ) ).toConst();\n\n\t\tconst cone = trace( origin, direction, tanHalfAngle, maxDistance, aoDistance );\n\n\t\tcolor.addAssign( cone.color );\n\n\t\tif ( aoDistance !== null ) ao.addAssign( cone.ao );\n\n\t} );\n\n\treturn { color: color.div( float( coneCount ) ), ao: ao.div( float( coneCount ) ) };\n\n}\n","import { Box3, Vector3, Vector4, Matrix4, Layers, Storage3DTexture, StorageBufferAttribute, StorageTexture3DNode, RendererUtils, HalfFloatType, UnsignedByteType, RGBAFormat, LinearFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping, MathUtils } from 'three/webgpu';\nimport { Fn, If, Loop, uniform, uniformArray, storage, instanceIndex, textureStore, texture3D, texture, cubeTexture, float, int, uint, vec2, vec3, vec4, ivec3, uvec3, max, min, abs, dot, cross, normalize, floor, sign, select, countOneBits, atomicOr, smoothstep, hash, length, PI, getDistanceAttenuation, viewZToPerspectiveDepth, viewZToReversedPerspectiveDepth } from 'three/tsl';\n\nimport { collectSceneTriangles, computeSceneBounds, computeSolidVoxels, TRIANGLE_STRIDE } from './VXGISceneCollector.js';\nimport { createConeTracer, gather } from './VXGIConeTracer.js';\n\nconst _box = /*@__PURE__*/ new Box3();\nconst _size = /*@__PURE__*/ new Vector3();\nconst _position = /*@__PURE__*/ new Vector3();\nconst _target = /*@__PURE__*/ new Vector3();\n\nconst MAX_EDGE_SUBVOXELS = 16;\nconst BOUNCE_CONE_COUNT = 8;\n\n// the six directions a ray can travel, as (axis, sign) pairs\n\nconst DIRECTIONS = [[ 0, 1 ], [ 0, - 1 ], [ 1, 1 ], [ 1, - 1 ], [ 2, 1 ], [ 2, - 1 ]];\n\nlet _rendererState;\n\n/**\n * Storage texture node bound to a single mip level. Texture nodes normally share one binding\n * per texture; this node keys the binding by access and mip level so a kernel can read one\n * level while writing another.\n *\n * @private\n */\nclass MipStorageTexture3DNode extends StorageTexture3DNode {\n\n\tconstructor( value, access, mipLevel ) {\n\n\t\tsuper( value, null, null );\n\n\t\tthis.setAccess( access );\n\t\tthis.setMipLevel( mipLevel );\n\n\t}\n\n\tgetUniformHash() {\n\n\t\treturn `${ this.value.uuid }:${ this.access }:${ this.mipLevel }`;\n\n\t}\n\n}\n\n/**\n * Holds the voxel representation of a scene for {@link VXGINode}: an anisotropic opacity\n * mip chain, a direct radiance volume and a radiance volume with cached bounces.\n *\n * The representation is a dense variant of the pre-filtered voxel hierarchy of Crassin et al. 2011\n * (a dense mip chain instead of a sparse octree, which keeps cone samples to two texture fetches):\n * opacity stores visibility per major axis and is filtered directionally (volumetric integration\n * along the axis, averaging across it), radiance is stored opacity-premultiplied and indirect bounces\n * are cached in the volume via cone tracing. Only direct lights are injected.\n * Voxelization uses conservative rasterization along the dominant triangle axis in a compute shader.\n * The interiors of closed meshes are filled, so cones starting inside an object (e.g. near contact\n * points) are blocked.\n *\n * Direct light is injected per voxel instead of splatting photons from a light-view map as in the\n * paper: the shadow maps rendered by the renderer are the light-view maps, and every occupied voxel\n * pulls its visibility from them (2D maps for directional and spot lights, cube maps for point\n * lights) and evaluates its irradiance analytically. This reuses the existing shadow passes, makes\n * the injected shadows match the direct lighting exactly and needs neither atomics nor a\n * normalization by photon density. Lights without a shadow map fall back to a visibility cone\n * traced through the volume. The trade-off is a cost proportional to the number of occupied voxels\n * times lights rather than to the light-view resolution, and that only outgoing diffuse radiance\n * is stored (no incoming direction distribution for glossy cones).\n *\n * References:\n * - {@link https://research.nvidia.com/publication/2011-09_interactive-indirect-illumination-using-voxel-cone-tracing}:\n * Crassin et al., Interactive Indirect Illumination Using Voxel Cone Tracing, Pacific Graphics 2011.\n * - {@link https://developer.nvidia.com/content/basics-gpu-voxelization}: Basics of GPU voxelization.\n * - {@link https://doi.org/10.1145/1882261.1866201}: Schwarz and Seidel, Fast Parallel Surface and Solid\n * Voxelization on GPUs, ACM Transactions on Graphics 2010.\n *\n * Note: This class can only be used with `WebGPURenderer` and a WebGPU backend.\n *\n * @three_import import { VXGIVolume } from 'three/addons/lighting/vxgi/VXGIVolume.js';\n */\nclass VXGIVolume {\n\n\t/**\n\t * Constructs a new volume.\n\t *\n\t * @param {number} [resolution=128] - Number of voxels along the longest axis of the bounds. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer.\n\t */\n\tconstructor( resolution = 128 ) {\n\n\t\t/**\n\t\t * Number of voxels along the longest axis of the bounds. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 128\n\t\t */\n\t\tthis.resolution = resolution;\n\n\t\t/**\n\t\t * The requested world-space bounds of the volume. If empty (the default), the bounds are\n\t\t * computed from the scene at voxelization. See {@link VXGIVolume#worldBounds} for the\n\t\t * effective bounds.\n\t\t *\n\t\t * @type {Box3}\n\t\t */\n\t\tthis.bounds = new Box3();\n\n\t\t/**\n\t\t * The effective world-space bounds of the voxel grid, updated at voxelization.\n\t\t *\n\t\t * @type {Box3}\n\t\t * @readonly\n\t\t */\n\t\tthis.worldBounds = new Box3();\n\n\t\t/**\n\t\t * Only meshes that pass this layer test are voxelized.\n\t\t *\n\t\t * @type {Layers}\n\t\t */\n\t\tthis.layers = new Layers();\n\n\t\t/**\n\t\t * Number of cached indirect bounces stored in the volume. Should be in the range `[0, 2]`.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 1\n\t\t */\n\t\tthis.bounces = 1;\n\n\t\t/**\n\t\t * Triangles with a lower opacity are not voxelized.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0.1\n\t\t */\n\t\tthis.minOpacity = 0.1;\n\n\t\t/**\n\t\t * Whether the coarser radiance levels are filtered directionally: along each axis the finer\n\t\t * voxels are composited front to back using their surface normals, so a cone only gathers\n\t\t * the surfaces facing it. This reduces light bleeding through thin walls and floors (e.g. a\n\t\t * sunlit floor brightening the ceiling of the room below) at the cost of additional memory\n\t\t * and a more expensive radiance lookup. Changing it triggers a re-voxelization.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.directionalRadiance = false;\n\n\t\t/**\n\t\t * Maximum number of lights injected into the volume.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 8\n\t\t */\n\t\tthis.maxLights = 8;\n\n\t\t/**\n\t\t * Set to `true` to re-voxelize the scene in the next update.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsUpdate = true;\n\n\t\t/**\n\t\t * Set to `true` to re-inject lighting in the next update. Changes of the lights and of the\n\t\t * injection parameters are detected automatically, so this is rarely needed.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.lightingNeedsUpdate = true;\n\n\t\t/**\n\t\t * Maximum cone length in world units. `0` means unbounded.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0\n\t\t */\n\t\tthis.maxDistance = uniform( 0 );\n\n\t\t/**\n\t\t * Step size relative to the texel size of the sampled mip level.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0.5\n\t\t */\n\t\tthis.stepScale = uniform( 0.5 );\n\n\t\t/**\n\t\t * Aperture in degrees of the visibility cones traced towards lights that do not provide a\n\t\t * shadow map. Wider cones are cheaper but soften the injected shadows.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 10\n\t\t */\n\t\tthis.shadowConeAngle = uniform( 10 );\n\n\t\t/**\n\t\t * Aperture of the cones used for the cached bounces in degrees.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 60\n\t\t */\n\t\tthis.bounceConeAngle = uniform( 60 );\n\n\t\t/**\n\t\t * The minimum corner of the volume.\n\t\t *\n\t\t * @type {UniformNode<vec3>}\n\t\t */\n\t\tthis.boundsMinNode = uniform( new Vector3() );\n\n\t\t/**\n\t\t * The size of the volume.\n\t\t *\n\t\t * @type {UniformNode<vec3>}\n\t\t */\n\t\tthis.volumeSizeNode = uniform( new Vector3( 1, 1, 1 ) );\n\n\t\t/**\n\t\t * The size of a voxel.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.voxelSizeNode = uniform( 1 );\n\n\t\t/**\n\t\t * The highest valid mip level of the voxel textures.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.maxLevelNode = uniform( 0 );\n\n\t\t/**\n\t\t * The per-axis opacity of the scene (`xyz`) and the occupancy (`w`) as a mip chain.\n\t\t *\n\t\t * @type {Storage3DTexture}\n\t\t */\n\t\tthis.opacityTexture = this._createTexture( 'VXGI.Opacity', UnsignedByteType, true, 1, 1, 1 );\n\n\t\t/**\n\t\t * The radiance of the scene including cached bounces, premultiplied by occupancy, as a mip chain.\n\t\t * With {@link VXGIVolume#directionalRadiance} only the finest level is used and the coarser\n\t\t * levels live in {@link VXGIVolume#directionalTexture}.\n\t\t *\n\t\t * @type {Storage3DTexture}\n\t\t */\n\t\tthis.radianceTexture = this._createTexture( 'VXGI.Radiance', HalfFloatType, true, 1, 1, 1 );\n\n\t\t/**\n\t\t * Texture node of {@link VXGIVolume#opacityTexture}. Stays valid across re-allocations of the volume.\n\t\t *\n\t\t * @type {Texture3DNode}\n\t\t */\n\t\tthis.opacityNode = texture3D( this.opacityTexture );\n\n\t\t/**\n\t\t * Texture node of {@link VXGIVolume#radianceTexture}. Stays valid across re-allocations of the volume.\n\t\t *\n\t\t * @type {Texture3DNode}\n\t\t */\n\t\tthis.radianceNode = texture3D( this.radianceTexture );\n\n\t\t/**\n\t\t * The coarser radiance levels filtered directionally for the six directions a ray can travel\n\t\t * (+x, -x, +y, -y, +z, -z), only allocated with {@link VXGIVolume#directionalRadiance}. Each\n\t\t * texel holds the radiance of the surfaces facing the direction premultiplied by their weight\n\t\t * (`rgb`) and the weight (`a`); occlusion comes from the opacity mip chain. The six directions\n\t\t * are stored side by side along x in one half-resolution mip chain; level `n` of the volume is\n\t\t * its level `n - 1`.\n\t\t *\n\t\t * @type {Storage3DTexture}\n\t\t */\n\t\tthis.directionalTexture = this._createTexture( 'VXGI.Directional', HalfFloatType, true, 6, 1, 1 );\n\n\t\t/**\n\t\t * Texture node of {@link VXGIVolume#directionalTexture}. Stays valid across re-allocations of the volume.\n\t\t *\n\t\t * @type {Texture3DNode}\n\t\t */\n\t\tthis.directionalNode = texture3D( this.directionalTexture );\n\n\t\t/**\n\t\t * The width of one direction block of the directional texture in texels (at its level 0).\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.directionalWidthNode = uniform( 1 );\n\n\t\t// private\n\n\t\tthis._traceDistance = this.maxDistance.greaterThan( 0 ).select( this.maxDistance, float( 1e10 ) );\n\t\tthis._allocated = false;\n\n\t\tthis._gridSize = new Vector3();\n\t\tthis._levels = 1;\n\t\tthis._voxelCount = 0;\n\t\tthis._gridSizeNode = [ uniform( 1, 'uint' ), uniform( 1, 'uint' ), uniform( 1, 'uint' ) ];\n\t\tthis._voxelCountNode = uniform( 0, 'uint' );\n\n\t\tthis._pingPongTexture = null;\n\t\tthis._directTexture = null;\n\t\tthis._pingPongDirectionalTexture = null;\n\t\tthis._normalTexture = null;\n\t\tthis._directional = false;\n\n\t\tthis._occupancyAttribute = null;\n\t\tthis._triangleIdAttribute = null;\n\t\tthis._solidAttribute = null;\n\t\tthis._triangleAttribute = null;\n\t\tthis._trianglesNode = null;\n\t\tthis._triangleCount = 0;\n\t\tthis._triangleCountNode = uniform( 0, 'uint' );\n\n\t\tthis._kernels = null;\n\n\t\tthis._lightsArray = [];\n\t\tfor ( let i = 0; i < this.maxLights * 4; i ++ ) this._lightsArray.push( new Vector4() );\n\t\tthis._lightsNode = uniformArray( this._lightsArray, 'vec4' );\n\t\tthis._lightCountNode = uniform( 0, 'uint' );\n\t\tthis._lightKey = '';\n\n\t\t// per light slot: type, shadow map (2D depth or cube depth) and its matrix / bias / near / far\n\n\t\tthis._lightTypes = [];\n\t\tthis._lightShadows = [];\n\t\tthis._shadowMatrices = [];\n\t\tthis._shadowParams = [];\n\n\t\tfor ( let i = 0; i < this.maxLights; i ++ ) {\n\n\t\t\tthis._shadowMatrices.push( uniform( new Matrix4() ) );\n\t\t\tthis._shadowParams.push( uniform( new Vector4() ) );\n\n\t\t}\n\n\t\tthis._lightsKey = '';\n\n\n\t\tthis._exclude = new Set();\n\n\t}\n\n\t/**\n\t * The effective maximum cone length as a node.\n\t *\n\t * @type {Node<float>}\n\t */\n\tget traceDistanceNode() {\n\n\t\treturn this._traceDistance;\n\n\t}\n\n\t/**\n\t * Updates the volume if required. Voxelizes the scene when `needsUpdate` is set and re-injects\n\t * lighting when `lightingNeedsUpdate` is set or a light has changed.\n\t *\n\t * @param {Renderer} renderer - The renderer.\n\t * @param {Scene} scene - The scene.\n\t */\n\tupdate( renderer, scene ) {\n\n\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t// the volume might be updated before the scene was rendered for the first time\n\n\t\tif ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();\n\n\t\tif ( this.needsUpdate === true || this._allocated === false || this._directional !== this.directionalRadiance ) {\n\n\t\t\tthis._voxelize( renderer, scene );\n\n\t\t\tthis.needsUpdate = false;\n\t\t\tthis.lightingNeedsUpdate = true;\n\n\t\t}\n\n\t\tconst lightKey = this._collectLights( renderer, scene );\n\n\t\tif ( this.lightingNeedsUpdate === true || lightKey !== this._lightKey ) {\n\n\t\t\tthis._lightKey = lightKey;\n\t\t\tthis._updateLighting( renderer );\n\n\t\t\tthis.lightingNeedsUpdate = false;\n\n\t\t}\n\n\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t}\n\n\t/**\n\t * Frees internal resources.\n\t */\n\tdispose() {\n\n\t\tthis._disposeGrid();\n\n\t}\n\n\t// geometry\n\n\t_voxelize( renderer, scene ) {\n\n\t\tthis._exclude.clear();\n\n\t\tconst bounds = this.bounds.isEmpty() ? computeSceneBounds( scene, this.layers, this._exclude, _box ) : _box.copy( this.bounds );\n\n\t\tif ( bounds.isEmpty() ) bounds.min.set( - 1, - 1, - 1 ), bounds.max.set( 1, 1, 1 );\n\n\t\t// grid setup: the longest axis gets `resolution` voxels, all dimensions are padded by\n\t\t// one voxel and rounded up so every mip level has integer dimensions\n\n\t\tbounds.getSize( _size );\n\n\t\tconst resolution = Math.max( 8, this.resolution );\n\t\tconst voxelSize = Math.max( _size.x, _size.y, _size.z ) / resolution;\n\t\tlet levels = MathUtils.clamp( Math.floor( Math.log2( resolution ) ) - 2, 1, 8 );\n\t\tconst multiple = 2 ** ( levels - 1 );\n\n\t\tconst gridSize = _size.clone();\n\t\tgridSize.x = Math.ceil( ( Math.ceil( _size.x / voxelSize ) + 2 ) / multiple ) * multiple;\n\t\tgridSize.y = Math.ceil( ( Math.ceil( _size.y / voxelSize ) + 2 ) / multiple ) * multiple;\n\t\tgridSize.z = Math.ceil( ( Math.ceil( _size.z / voxelSize ) + 2 ) / multiple ) * multiple;\n\n\t\tlevels = Math.min( levels, Math.floor( Math.log2( Math.max( gridSize.x, gridSize.y ) ) ) + 1 );\n\n\t\tthis.boundsMinNode.value.copy( bounds.min ).subScalar( voxelSize );\n\t\tthis.volumeSizeNode.value.copy( gridSize ).multiplyScalar( voxelSize );\n\t\tthis.worldBounds.min.copy( this.boundsMinNode.value );\n\t\tthis.worldBounds.max.copy( this.boundsMinNode.value ).add( this.volumeSizeNode.value );\n\t\tthis.voxelSizeNode.value = voxelSize;\n\t\tthis.maxLevelNode.value = levels - 1;\n\n\t\tif ( this._allocated === false || gridSize.equals( this._gridSize ) === false || levels !== this._levels || this._directional !== this.directionalRadiance ) {\n\n\t\t\tthis._allocateGrid( gridSize, levels );\n\n\t\t}\n\n\t\t// collect triangles\n\n\t\t_box.min.copy( this.boundsMinNode.value );\n\t\t_box.max.copy( this.boundsMinNode.value ).add( this.volumeSizeNode.value );\n\n\t\tconst { data, count } = collectSceneTriangles( scene, {\n\t\t\tbounds: _box,\n\t\t\tlayers: this.layers,\n\t\t\texclude: this._exclude,\n\t\t\tsubVoxelSize: voxelSize * 0.5,\n\t\t\tmaxEdge: MAX_EDGE_SUBVOXELS,\n\t\t\tminOpacity: this.minOpacity\n\t\t} );\n\n\t\tthis._triangleCount = count;\n\t\tthis._triangleCountNode.value = count;\n\n\t\tif ( this._triangleAttribute !== null ) this._triangleAttribute.dispose();\n\n\t\tthis._triangleAttribute = new StorageBufferAttribute( count > 0 ? data : new Float32Array( TRIANGLE_STRIDE ), 4 );\n\t\tthis._trianglesNode = storage( this._triangleAttribute, 'vec4', this._triangleAttribute.count ).toReadOnly();\n\n\t\tconst solid = this._solidAttribute.array;\n\n\t\tsolid.fill( 0 );\n\t\tcomputeSolidVoxels( scene, { boundsMin: this.boundsMinNode.value, voxelSize, gridSize, layers: this.layers, exclude: this._exclude }, new Uint8Array( solid.buffer ) );\n\t\tthis._solidAttribute.needsUpdate = true;\n\n\t\t// kernels depend on the triangle buffer and grid\n\n\t\tthis._disposeKernels();\n\t\tconst kernels = this._getKernels();\n\n\t\trenderer.compute( kernels.clear );\n\n\t\tif ( count > 0 ) renderer.compute( kernels.voxelize );\n\n\t\trenderer.compute( kernels.resolve );\n\n\t\tfor ( const kernel of kernels.opacityMips ) renderer.compute( kernel );\n\n\t}\n\n\t_allocateGrid( gridSize, levels ) {\n\n\t\tthis._disposeGrid();\n\n\t\tconst { x, y, z } = gridSize;\n\n\t\tthis._gridSize.copy( gridSize );\n\t\tthis._levels = levels;\n\t\tthis._voxelCount = x * y * z;\n\t\tthis._gridSizeNode[ 0 ].value = x;\n\t\tthis._gridSizeNode[ 1 ].value = y;\n\t\tthis._gridSizeNode[ 2 ].value = z;\n\t\tthis._voxelCountNode.value = this._voxelCount;\n\n\t\tconst directional = this._directional = this.directionalRadiance;\n\n\t\tthis.opacityTexture = this._createTexture( 'VXGI.Opacity', UnsignedByteType, true, x, y, z );\n\t\tthis.radianceTexture = this._createTexture( 'VXGI.Radiance', HalfFloatType, directional === false, x, y, z );\n\t\tthis._pingPongTexture = this._createTexture( 'VXGI.RadiancePingPong', HalfFloatType, directional === false, x, y, z );\n\t\tthis._directTexture = this._createTexture( 'VXGI.Direct', HalfFloatType, false, x, y, z );\n\n\t\t// the directional levels start at level 1, i.e. at half resolution, six direction blocks along x\n\n\t\tif ( directional === true ) {\n\n\t\t\tconst hx = Math.ceil( x / 2 ), hy = Math.ceil( y / 2 ), hz = Math.ceil( z / 2 );\n\n\t\t\tthis.directionalTexture = this._createTexture( 'VXGI.Directional', HalfFloatType, true, 6 * hx, hy, hz );\n\t\t\tthis._pingPongDirectionalTexture = this._createTexture( 'VXGI.DirectionalPingPong', HalfFloatType, true, 6 * hx, hy, hz );\n\t\t\tthis._normalTexture = this._createTexture( 'VXGI.Normal', UnsignedByteType, false, x, y, z );\n\t\t\tthis.directionalWidthNode.value = hx;\n\n\t\t} else {\n\n\t\t\tthis.directionalTexture = this._createTexture( 'VXGI.Directional', HalfFloatType, true, 6, 1, 1 );\n\t\t\tthis.directionalWidthNode.value = 1;\n\n\t\t}\n\n\t\tthis.opacityNode.value = this.opacityTexture;\n\t\tthis.radianceNode.value = this.radianceTexture;\n\t\tthis.directionalNode.value = this.directionalTexture;\n\n\t\tthis._allocated = true;\n\n\t\tthis._occupancyAttribute = new StorageBufferAttribute( this._voxelCount, 1, Uint32Array );\n\t\tthis._triangleIdAttribute = new StorageBufferAttribute( this._voxelCount, 1, Uint32Array );\n\t\tthis._solidAttribute = new StorageBufferAttribute( Math.ceil( this._voxelCount / 4 ), 1, Uint32Array );\n\n\t}\n\n\t_createTexture( name, type, mipmaps, x, y, z ) {\n\n\t\tconst texture = new Storage3DTexture( x, y, z );\n\t\ttexture.name = name;\n\t\ttexture.type = type;\n\t\ttexture.format = RGBAFormat;\n\t\ttexture.generateMipmaps = mipmaps;\n\t\ttexture.mipmapsAutoUpdate = false;\n\t\ttexture.minFilter = mipmaps ? LinearMipmapLinearFilter : LinearFilter;\n\t\ttexture.magFilter = LinearFilter;\n\t\ttexture.wrapS = texture.wrapT = texture.wrapR = ClampToEdgeWrapping;\n\n\t\treturn texture;\n\n\t}\n\n\t_disposeGrid() {\n\n\t\tthis._disposeKernels();\n\n\t\tthis.opacityTexture.dispose();\n\t\tthis.radianceTexture.dispose();\n\t\tthis.directionalTexture.dispose();\n\n\t\tif ( this._pingPongTexture !== null ) {\n\n\t\t\tthis._pingPongTexture.dispose();\n\t\t\tthis._directTexture.dispose();\n\n\t\t\tthis._pingPongTexture = null;\n\t\t\tthis._directTexture = null;\n\n\t\t}\n\n\t\tif ( this._normalTexture !== null ) {\n\n\t\t\tthis._normalTexture.dispose();\n\t\t\tthis._pingPongDirectionalTexture.dispose();\n\n\t\t\tthis._normalTexture = null;\n\t\t\tthis._pingPongDirectionalTexture = null;\n\n\t\t}\n\n\t\tif ( this._occupancyAttribute !== null ) {\n\n\t\t\tthis._occupancyAttribute.dispose();\n\t\t\tthis._triangleIdAttribute.dispose();\n\t\t\tthis._solidAttribute.dispose();\n\n\t\t\tthis._occupancyAttribute = null;\n\t\t\tthis._triangleIdAttribute = null;\n\t\t\tthis._solidAttribute = null;\n\n\t\t}\n\n\t\tif ( this._triangleAttribute !== null ) {\n\n\t\t\tthis._triangleAttribute.dispose();\n\n\t\t\tthis._triangleAttribute = null;\n\t\t\tthis._trianglesNode = null;\n\n\t\t}\n\n\t\tthis._allocated = false;\n\n\t}\n\n\t// lighting\n\n\t_collectLights( renderer, scene ) {\n\n\t\tconst lights = this._lightsArray;\n\t\tlet count = 0;\n\t\tlet key = renderer.shadowMap.enabled ? 'S' : 'N';\n\n\t\tthis._lightTypes.length = 0;\n\t\tthis._lightShadows.length = 0;\n\n\t\tscene.traverseVisible( ( object ) => {\n\n\t\t\tif ( object.isLight !== true || count >= this.maxLights ) return;\n\n\t\t\tlet type;\n\n\t\t\tif ( object.isDirectionalLight === true ) type = 0;\n\t\t\telse if ( object.isSpotLight === true ) type = 2;\n\t\t\telse if ( object.isPointLight === true ) type = 1;\n\t\t\telse return;\n\n\t\t\tconst l0 = lights[ count * 4 ], l1 = lights[ count * 4 + 1 ], l2 = lights[ count * 4 + 2 ], l3 = lights[ count * 4 + 3 ];\n\n\t\t\t_position.setFromMatrixPosition( object.matrixWorld );\n\t\t\tl0.set( _position.x, _position.y, _position.z, type );\n\n\t\t\tif ( type === 0 || type === 2 ) {\n\n\t\t\t\t_target.setFromMatrixPosition( object.target.matrixWorld );\n\n\t\t\t\tif ( type === 0 ) {\n\n\t\t\t\t\t_target.subVectors( _position, _target ).normalize(); // direction towards the light\n\n\t\t\t\t} else {\n\n\t\t\t\t\t_target.subVectors( _target, _position ).normalize(); // spot axis\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_target.set( 0, 0, 0 );\n\n\t\t\t}\n\n\t\t\tl1.set( _target.x, _target.y, _target.z, object.distance || 0 );\n\n\t\t\tconst color = object.color, intensity = object.intensity;\n\t\t\tl2.set( color.r * intensity, color.g * intensity, color.b * intensity, object.decay !== undefined ? object.decay : 2 );\n\n\t\t\t// the light's shadow map is used for the injected visibility when available\n\n\t\t\tlet shadowTexture = null;\n\n\t\t\tif ( object.castShadow === true && renderer.shadowMap.enabled === true && object.shadow.map !== null && object.shadow.map.depthTexture !== undefined ) {\n\n\t\t\t\tconst shadow = object.shadow;\n\n\t\t\t\tshadowTexture = shadow.map.depthTexture;\n\t\t\t\tthis._shadowMatrices[ count ].value.copy( shadow.matrix );\n\t\t\t\tthis._shadowParams[ count ].value.set( shadow.bias, shadow.camera.near, shadow.camera.far, 0 );\n\n\t\t\t}\n\n\t\t\tthis._lightTypes.push( type );\n\t\t\tthis._lightShadows.push( shadowTexture );\n\n\t\t\tif ( type === 2 ) {\n\n\t\t\t\tl3.set( Math.cos( object.angle ), Math.cos( object.angle * ( 1 - object.penumbra ) ), 0, 0 );\n\n\t\t\t} else {\n\n\t\t\t\tl3.set( 0, 0, 0, 0 );\n\n\t\t\t}\n\n\t\t\tkey += `|${ type },${ l0.x.toFixed( 3 ) },${ l0.y.toFixed( 3 ) },${ l0.z.toFixed( 3 ) },${ l1.x.toFixed( 4 ) },${ l1.y.toFixed( 4 ) },${ l1.z.toFixed( 4 ) },${ l1.w },${ l2.x.toFixed( 3 ) },${ l2.y.toFixed( 3 ) },${ l2.z.toFixed( 3 ) },${ l2.w },${ l3.x.toFixed( 4 ) },${ l3.y.toFixed( 4 ) },${ shadowTexture !== null ? shadowTexture.uuid : '-' }`;\n\n\t\t\tcount ++;\n\n\t\t} );\n\n\t\tthis._lightCountNode.value = count;\n\n\t\t// injection parameters that are baked into the cached radiance\n\n\t\tkey += `|${ this.bounces },${ this.bounceConeAngle.value },${ this.shadowConeAngle.value },${ this.stepScale.value },${ this.maxDistance.value }`;\n\n\t\t// the inject kernels are specialized for the set of lights and their shadow maps\n\n\t\tthis._lightsKey = this._lightTypes.map( ( type, i ) => type + ':' + ( this._lightShadows[ i ] !== null ? this._lightShadows[ i ].uuid : '-' ) ).join( '|' );\n\n\t\treturn key;\n\n\t}\n\n\t_updateLighting( renderer ) {\n\n\t\tconst kernels = this._getKernels();\n\t\tconst bounces = Math.max( 0, Math.round( this.bounces ) );\n\n\t\t// the ping-pong order is chosen so the final result always ends up in `radianceTexture`\n\n\t\tlet index = bounces % 2;\n\n\t\tif ( kernels.inject[ index ] === null || kernels.injectKey[ index ] !== this._lightsKey ) {\n\n\t\t\tif ( kernels.inject[ index ] !== null ) kernels.inject[ index ].dispose();\n\n\t\t\tkernels.inject[ index ] = this._createInjectKernel( renderer, index );\n\t\t\tkernels.injectKey[ index ] = this._lightsKey;\n\n\t\t}\n\n\t\trenderer.compute( kernels.inject[ index ] );\n\n\t\tfor ( const kernel of kernels.radianceMips[ index ] ) renderer.compute( kernel );\n\n\t\tfor ( let i = 0; i < bounces; i ++ ) {\n\n\t\t\tconst target = 1 - index;\n\n\t\t\trenderer.compute( kernels.bounce[ target ] );\n\n\t\t\tfor ( const kernel of kernels.radianceMips[ target ] ) renderer.compute( kernel );\n\n\t\t\tindex = target;\n\n\t\t}\n\n\t}\n\n\t// kernels\n\n\t_getRadianceTexture( index ) {\n\n\t\treturn index === 0 ? this.radianceTexture : this._pingPongTexture;\n\n\t}\n\n\t_getDirectionalTexture( index ) {\n\n\t\treturn index === 0 ? this.directionalTexture : this._pingPongDirectionalTexture;\n\n\t}\n\n\t_getKernels() {\n\n\t\tif ( this._kernels !== null ) return this._kernels;\n\n\t\tconst kernels = {\n\t\t\tclear: this._createClearKernel(),\n\t\t\tvoxelize: this._createVoxelizeKernel(),\n\t\t\tresolve: this._createResolveKernel(),\n\t\t\topacityMips: [],\n\t\t\tradianceMips: [[], []],\n\t\t\tinject: [ null, null ],\n\t\t\tinjectKey: [ null, null ],\n\t\t\tbounce: [ null, null ]\n\t\t};\n\n\t\tfor ( let level = 1; level < this._levels; level ++ ) {\n\n\t\t\tkernels.opacityMips.push( this._createOpacityMipKernel( level ) );\n\n\t\t\t// the coarser radiance levels are either isotropic mips or directionally filtered\n\n\t\t\tfor ( let index = 0; index < 2; index ++ ) {\n\n\t\t\t\tkernels.radianceMips[ index ].push( this._directional === true ? this._createDirectionalKernel( index, level ) : this._createRadianceMipKernel( this._getRadianceTexture( index ), level ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\tkernels.bounce[ 0 ] = this._createBounceKernel( 0 );\n\t\tkernels.bounce[ 1 ] = this._createBounceKernel( 1 );\n\n\t\tthis._kernels = kernels;\n\n\t\treturn kernels;\n\n\t}\n\n\t_disposeKernels() {\n\n\t\tif ( this._kernels === null ) return;\n\n\t\tconst { clear, voxelize, resolve, opacityMips, radianceMips, inject, bounce } = this._kernels;\n\n\t\tfor ( const kernel of [ clear, voxelize, resolve, ...opacityMips, ...radianceMips.flat(), ...inject, ...bounce ] ) {\n\n\t\t\tif ( kernel !== null ) kernel.dispose();\n\n\t\t}\n\n\t\tthis._kernels = null;\n\n\t}\n\n\t_getLevelSize( level ) {\n\n\t\treturn [ this._gridSize.x >> level, this._gridSize.y >> level, this._gridSize.z >> level ];\n\n\t}\n\n\t/**\n\t * Returns the 3D coordinates of the given linear voxel index.\n\t *\n\t * @private\n\t */\n\t_coords( index, size ) {\n\n\t\tconst [ x, y ] = size;\n\n\t\treturn uvec3( index.mod( uint( x ) ), index.div( uint( x ) ).mod( uint( y ) ), index.div( uint( x * y ) ) );\n\n\t}\n\n\t_createClearKernel() {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount );\n\t\tconst triangleIds = storage( this._triangleIdAttribute, 'uint', this._voxelCount );\n\t\tconst voxelCount = this._voxelCountNode;\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( voxelCount ), () => {\n\n\t\t\t\toccupancy.element( instanceIndex ).assign( uint( 0 ) );\n\t\t\t\ttriangleIds.element( instanceIndex ).assign( uint( 0 ) );\n\n\t\t\t} );\n\n\t\t} )().compute( this._voxelCount ).setName( 'VXGI.Clear' );\n\n\t}\n\n\t_createVoxelizeKernel() {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount ).toAtomic();\n\t\tconst triangleIds = storage( this._triangleIdAttribute, 'uint', this._voxelCount );\n\t\tconst triangles = this._trianglesNode;\n\t\tconst triangleCount = this._triangleCountNode;\n\t\tconst boundsMin = this.boundsMinNode;\n\t\tconst invSubVoxel = float( 2 ).div( this.voxelSizeNode );\n\t\tconst [ gx, gy ] = this._gridSizeNode;\n\t\tconst subSize = vec3( this._gridSize.x * 2, this._gridSize.y * 2, this._gridSize.z * 2 );\n\n\t\treturn Fn( () => {\n\n\t\t\tconst triangleIndex = instanceIndex;\n\n\t\t\tIf( triangleIndex.lessThan( triangleCount ), () => {\n\n\t\t\t\tconst base = triangleIndex.mul( 5 ).toConst();\n\n\t\t\t\t// triangle in sub-voxel space\n\n\t\t\t\tconst p0 = triangles.element( base ).xyz.sub( boundsMin ).mul( invSubVoxel ).toConst();\n\t\t\t\tconst p1 = triangles.element( base.add( 1 ) ).xyz.sub( boundsMin ).mul( invSubVoxel ).toConst();\n\t\t\t\tconst p2 = triangles.element( base.add( 2 ) ).xyz.sub( boundsMin ).mul( invSubVoxel ).toConst();\n\n\t\t\t\tconst n = cross( p1.sub( p0 ), p2.sub( p0 ) ).toConst();\n\t\t\t\tconst an = abs( n ).toConst();\n\n\t\t\t\t// project along the dominant axis: swizzle so the dominant axis becomes z\n\n\t\t\t\tconst isZ = an.z.greaterThanEqual( an.x ).and( an.z.greaterThanEqual( an.y ) ).toConst();\n\t\t\t\tconst isY = isZ.not().and( an.y.greaterThanEqual( an.x ) ).toConst();\n\n\t\t\t\tconst swizzle = ( v ) => select( isZ, v.xyz, select( isY, v.zxy, v.yzx ) );\n\n\t\t\t\tconst q0 = swizzle( p0 ).toConst();\n\t\t\t\tconst q1 = swizzle( p1 ).toConst();\n\t\t\t\tconst q2 = swizzle( p2 ).toConst();\n\t\t\t\tconst nq = swizzle( n ).toConst();\n\t\t\t\tconst sd = swizzle( subSize ).toConst();\n\n\t\t\t\tconst qmin = min( q0, min( q1, q2 ) ).toConst();\n\t\t\t\tconst qmax = max( q0, max( q1, q2 ) ).toConst();\n\n\t\t\t\tconst i0 = int( floor( qmin.x ) ).max( 0 ).toConst();\n\t\t\t\tconst i1 = int( floor( qmax.x ) ).min( int( sd.x ).sub( 1 ) ).toConst();\n\t\t\t\tconst j0 = int( floor( qmin.y ) ).max( 0 ).toConst();\n\t\t\t\tconst j1 = int( floor( qmax.y ) ).min( int( sd.y ).sub( 1 ) ).toConst();\n\n\t\t\t\t// conservative edge functions\n\n\t\t\t\tconst areaSign = sign( nq.z ).toConst();\n\n\t\t\t\tconst edge = ( a, b ) => {\n\n\t\t\t\t\tconst normal = vec2( a.y.sub( b.y ), b.x.sub( a.x ) ).mul( areaSign ).toConst();\n\t\t\t\t\tconst bias = float( 0.5 ).mul( abs( normal.x ).add( abs( normal.y ) ) ).toConst();\n\n\t\t\t\t\treturn { a, normal, bias };\n\n\t\t\t\t};\n\n\t\t\t\tconst e0 = edge( q0.xy, q1.xy );\n\t\t\t\tconst e1 = edge( q1.xy, q2.xy );\n\t\t\t\tconst e2 = edge( q2.xy, q0.xy );\n\n\t\t\t\tconst halfExtent = float( 0.5 ).mul( abs( nq.x ).add( abs( nq.y ) ) ).div( abs( nq.z ) ).toConst();\n\n\t\t\t\tLoop( { start: i0, end: i1, type: 'int', condition: '<=', name: 'i' }, { start: j0, end: j1, type: 'int', condition: '<=', name: 'j' }, ( { i, j } ) => {\n\n\t\t\t\t\tconst c = vec2( float( i ).add( 0.5 ), float( j ).add( 0.5 ) ).toConst();\n\n\t\t\t\t\tconst inside = dot( e0.normal, c.sub( e0.a ) ).add( e0.bias ).greaterThanEqual( 0 )\n\t\t\t\t\t\t.and( dot( e1.normal, c.sub( e1.a ) ).add( e1.bias ).greaterThanEqual( 0 ) )\n\t\t\t\t\t\t.and( dot( e2.normal, c.sub( e2.a ) ).add( e2.bias ).greaterThanEqual( 0 ) );\n\n\t\t\t\t\tIf( inside, () => {\n\n\t\t\t\t\t\t// depth range of the triangle plane within this column\n\n\t\t\t\t\t\tconst wc = q0.z.sub( nq.x.mul( c.x.sub( q0.x ) ).add( nq.y.mul( c.y.sub( q0.y ) ) ).div( nq.z ) ).toConst();\n\n\t\t\t\t\t\tconst k0 = int( floor( max( wc.sub( halfExtent ), qmin.z ) ) ).max( 0 ).toConst();\n\t\t\t\t\t\tconst k1 = int( floor( min( wc.add( halfExtent ), qmax.z ) ) ).min( int( sd.z ).sub( 1 ) ).toConst();\n\n\t\t\t\t\t\tLoop( { start: k0, end: k1, type: 'int', condition: '<=', name: 'k' }, ( { k } ) => {\n\n\t\t\t\t\t\t\tconst s = select( isZ, ivec3( i, j, k ), select( isY, ivec3( j, k, i ), ivec3( k, i, j ) ) ).toConst();\n\n\t\t\t\t\t\t\tconst voxel = uvec3( s.div( 2 ) ).toConst();\n\t\t\t\t\t\t\tconst bit = uint( s.x.bitAnd( 1 ) ).bitOr( uint( s.y.bitAnd( 1 ) ).shiftLeft( uint( 1 ) ) ).bitOr( uint( s.z.bitAnd( 1 ) ).shiftLeft( uint( 2 ) ) ).toConst();\n\t\t\t\t\t\t\tconst voxelIndex = voxel.x.add( gx.mul( voxel.y.add( gy.mul( voxel.z ) ) ) ).toConst();\n\n\t\t\t\t\t\t\tatomicOr( occupancy.element( voxelIndex ), uint( 1 ).shiftLeft( bit ) );\n\t\t\t\t\t\t\ttriangleIds.element( voxelIndex ).assign( triangleIndex.add( 1 ) );\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} );\n\n\t\t\t\t} );\n\n\t\t\t} );\n\n\t\t} )().compute( this._triangleCount ).setName( 'VXGI.Voxelize' );\n\n\t}\n\n\t_createResolveKernel() {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst solid = storage( this._solidAttribute, 'uint', this._solidAttribute.count ).toReadOnly();\n\t\tconst opacityTexture = this.opacityTexture;\n\t\tconst voxelCount = this._voxelCountNode;\n\t\tconst size = this._getLevelSize( 0 );\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( voxelCount ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst solidBits = solid.element( instanceIndex.shiftRight( uint( 2 ) ) ).shiftRight( instanceIndex.bitAnd( uint( 3 ) ).mul( uint( 8 ) ) ).bitAnd( uint( 0xFF ) );\n\t\t\t\tconst bits = occupancy.element( instanceIndex ).bitOr( solidBits ).toConst();\n\n\t\t\t\t// per-axis coverage from the 2x2x2 sub-voxel occupancy\n\n\t\t\t\tconst coverage = ( m0, m1, m2, m3 ) => {\n\n\t\t\t\t\treturn select( bits.bitAnd( uint( m0 ) ).notEqual( uint( 0 ) ), 0.25, 0 )\n\t\t\t\t\t\t.add( select( bits.bitAnd( uint( m1 ) ).notEqual( uint( 0 ) ), 0.25, 0 ) )\n\t\t\t\t\t\t.add( select( bits.bitAnd( uint( m2 ) ).notEqual( uint( 0 ) ), 0.25, 0 ) )\n\t\t\t\t\t\t.add( select( bits.bitAnd( uint( m3 ) ).notEqual( uint( 0 ) ), 0.25, 0 ) );\n\n\t\t\t\t};\n\n\t\t\t\tconst opacityX = coverage( 0x03, 0x0C, 0x30, 0xC0 );\n\t\t\t\tconst opacityY = coverage( 0x05, 0x0A, 0x50, 0xA0 );\n\t\t\t\tconst opacityZ = coverage( 0x11, 0x22, 0x44, 0x88 );\n\t\t\t\tconst occupied = float( countOneBits( bits ) ).div( 8 );\n\n\t\t\t\ttextureStore( opacityTexture, coords, vec4( opacityX, opacityY, opacityZ, occupied ) );\n\n\t\t\t} );\n\n\t\t} )().compute( this._voxelCount ).setName( 'VXGI.Resolve' );\n\n\t}\n\n\t_createOpacityMipKernel( level ) {\n\n\t\tconst size = this._getLevelSize( level );\n\t\tconst count = size[ 0 ] * size[ 1 ] * size[ 2 ];\n\n\t\tconst source = new MipStorageTexture3DNode( this.opacityTexture, 'readOnly', level - 1 );\n\t\tconst target = new MipStorageTexture3DNode( this.opacityTexture, 'writeOnly', level );\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( uint( count ) ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst base = ivec3( coords.mul( uint( 2 ) ) ).toConst();\n\n\t\t\t\tconst children = [];\n\n\t\t\t\tfor ( let z = 0; z < 2; z ++ ) {\n\n\t\t\t\t\tfor ( let y = 0; y < 2; y ++ ) {\n\n\t\t\t\t\t\tfor ( let x = 0; x < 2; x ++ ) {\n\n\t\t\t\t\t\t\tchildren[ x + y * 2 + z * 4 ] = source.load( base.add( ivec3( x, y, z ) ) ).toConst();\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// along each axis the two children are combined, across the axis they are averaged\n\n\t\t\t\tconst child = ( x, y, z ) => children[ x + y * 2 + z * 4 ];\n\t\t\t\tconst combine = ( a, b ) => a.oneMinus().mul( b.oneMinus() ).oneMinus();\n\n\t\t\t\tlet opacityX = float( 0 ), opacityY = float( 0 ), opacityZ = float( 0 ), occupied = float( 0 );\n\n\t\t\t\tfor ( let a = 0; a < 2; a ++ ) {\n\n\t\t\t\t\tfor ( let b = 0; b < 2; b ++ ) {\n\n\t\t\t\t\t\topacityX = opacityX.add( combine( child( 0, a, b ).x, child( 1, a, b ).x ) );\n\t\t\t\t\t\topacityY = opacityY.add( combine( child( a, 0, b ).y, child( a, 1, b ).y ) );\n\t\t\t\t\t\topacityZ = opacityZ.add( combine( child( a, b, 0 ).z, child( a, b, 1 ).z ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tfor ( let i = 0; i < 8; i ++ ) occupied = occupied.add( children[ i ].w );\n\n\t\t\t\ttextureStore( target, coords, vec4( opacityX.mul( 0.25 ), opacityY.mul( 0.25 ), opacityZ.mul( 0.25 ), occupied.mul( 0.125 ) ) );\n\n\t\t\t} );\n\n\t\t} )().compute( count ).setName( 'VXGI.OpacityMip' + level );\n\n\t}\n\n\t_createRadianceMipKernel( radianceTexture, level ) {\n\n\t\tconst size = this._getLevelSize( level );\n\t\tconst count = size[ 0 ] * size[ 1 ] * size[ 2 ];\n\n\t\tconst source = new MipStorageTexture3DNode( radianceTexture, 'readOnly', level - 1 );\n\t\tconst target = new MipStorageTexture3DNode( radianceTexture, 'writeOnly', level );\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( uint( count ) ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst base = ivec3( coords.mul( uint( 2 ) ) ).toConst();\n\n\t\t\t\tlet sum = vec4( 0 );\n\n\t\t\t\tfor ( let z = 0; z < 2; z ++ ) {\n\n\t\t\t\t\tfor ( let y = 0; y < 2; y ++ ) {\n\n\t\t\t\t\t\tfor ( let x = 0; x < 2; x ++ ) {\n\n\t\t\t\t\t\t\tsum = sum.add( source.load( base.add( ivec3( x, y, z ) ) ) );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureStore( target, coords, sum.mul( 0.125 ) );\n\n\t\t\t} );\n\n\t\t} )().compute( count ).setName( 'VXGI.RadianceMip' + level );\n\n\t}\n\n\t/**\n\t * Creates the kernel that filters the six direction blocks of the directional texture at a\n\t * level from the next finer level: along the direction's axis the two finer voxels are\n\t * composited front to back with the front voxel's opacity along that axis, across the axis\n\t * they are averaged. Level 1 is filtered from the isotropic finest level, where a voxel only\n\t * contributes to the directions its surface faces against.\n\t *\n\t * @private\n\t */\n\t_createDirectionalKernel( index, level ) {\n\n\t\tconst size = this._getLevelSize( level );\n\t\tconst count = size[ 0 ] * size[ 1 ] * size[ 2 ];\n\t\tconst texture = this._getDirectionalTexture( index );\n\t\tconst opacity = texture3D( this.opacityTexture );\n\t\tconst radiance = texture3D( this._getRadianceTexture( index ) );\n\t\tconst normals = texture3D( this._normalTexture );\n\n\t\t// level n of the volume is level n - 1 of the half resolution directional texture\n\n\t\tconst source = level === 1 ? null : new MipStorageTexture3DNode( texture, 'readOnly', level - 2 );\n\t\tconst target = new MipStorageTexture3DNode( texture, 'writeOnly', level - 1 );\n\t\tconst blockWidth = size[ 0 ];\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( uint( count ) ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst base = ivec3( coords.mul( uint( 2 ) ) ).toConst();\n\n\t\t\t\tconst offset = ( i ) => ivec3( i & 1, ( i >> 1 ) & 1, ( i >> 2 ) & 1 );\n\n\t\t\t\tconst childOpacity = [];\n\t\t\t\tconst childNormal = [];\n\t\t\t\tconst childRadiance = [];\n\n\t\t\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\t\t\tchildOpacity.push( opacity.load( base.add( offset( i ) ) ).level( level - 1 ).toConst() );\n\n\t\t\t\t\tif ( level === 1 ) {\n\n\t\t\t\t\t\tchildNormal.push( normals.load( base.add( offset( i ) ) ).xyz.mul( 2 ).sub( 1 ).toConst() );\n\t\t\t\t\t\tchildRadiance.push( radiance.load( base.add( offset( i ) ) ).toConst() );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tfor ( let direction = 0; direction < 6; direction ++ ) {\n\n\t\t\t\t\tconst [ axis, sign ] = DIRECTIONS[ direction ];\n\t\t\t\t\tconst travel = vec3( axis === 0 ? sign : 0, axis === 1 ? sign : 0, axis === 2 ? sign : 0 );\n\t\t\t\t\tconst block = ivec3( direction * blockWidth * 2, 0, 0 ); // block offset in the finer level\n\n\t\t\t\t\t// a child holds the radiance of its surfaces facing the direction premultiplied by\n\t\t\t\t\t// their weight (rgb) and the weight (a); at the finest level a voxel only counts for a\n\t\t\t\t\t// direction if its surface faces against it, so a surface parallel to the axis does\n\t\t\t\t\t// not mix in. The front child hides the back child by its opacity along the axis.\n\n\t\t\t\t\tconst child = ( i ) => level === 1\n\t\t\t\t\t\t? childRadiance[ i ].mul( smoothstep( 0, 0.3, dot( childNormal[ i ], travel.negate() ) ) )\n\t\t\t\t\t\t: source.load( base.add( block ).add( offset( i ) ) );\n\t\t\t\t\tconst axisOpacity = ( i ) => [ childOpacity[ i ].x, childOpacity[ i ].y, childOpacity[ i ].z ][ axis ];\n\n\t\t\t\t\tlet sum = vec4( 0 );\n\n\t\t\t\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\t\t\t\t// each column along the axis is composited once, starting at its front voxel\n\n\t\t\t\t\t\tif ( ( ( i >> axis ) & 1 ) !== ( sign > 0 ? 0 : 1 ) ) continue;\n\n\t\t\t\t\t\tconst front = i;\n\t\t\t\t\t\tconst back = i ^ ( 1 << axis );\n\n\t\t\t\t\t\tsum = sum.add( child( front ) ).add( child( back ).mul( axisOpacity( front ).oneMinus() ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttextureStore( target, ivec3( coords ).add( ivec3( direction * blockWidth, 0, 0 ) ), sum.mul( 0.25 ) );\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t} )().compute( count ).setName( 'VXGI.Directional' + level );\n\n\t}\n\n\t/**\n\t * Emits the code for reading the surface data of the given voxel.\n\t *\n\t * @private\n\t */\n\t_surface( coords, triangleId ) {\n\n\t\tconst triangles = this._trianglesNode;\n\n\t\tconst base = triangleId.sub( 1 ).mul( 5 ).toConst();\n\t\tconst a = triangles.element( base ).xyz.toConst();\n\t\tconst b = triangles.element( base.add( 1 ) ).xyz.toConst();\n\t\tconst c = triangles.element( base.add( 2 ) ).xyz.toConst();\n\t\tconst albedo = triangles.element( base.add( 3 ) ).toConst();\n\t\tconst emissive = triangles.element( base.add( 4 ) ).xyz.toConst();\n\n\t\tconst normal = normalize( cross( b.sub( a ), c.sub( a ) ) ).toVar();\n\t\tnormal.assign( select( albedo.w.equal( 1 ), normal.negate(), normal ) ); // back side\n\n\t\tconst position = this.boundsMinNode.add( vec3( coords ).add( 0.5 ).mul( this.voxelSizeNode ) ).toConst();\n\n\t\treturn { position, normal, albedo: albedo.xyz, side: albedo.w, emissive };\n\n\t}\n\n\t_createInjectKernel( renderer, index ) {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst triangleIds = storage( this._triangleIdAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst voxelCount = this._voxelCountNode;\n\t\tconst size = this._getLevelSize( 0 );\n\t\tconst voxelSize = this.voxelSizeNode;\n\t\tconst lights = this._lightsNode;\n\n\t\tconst directTexture = this._directTexture;\n\t\tconst normalTexture = this._normalTexture;\n\t\tconst radianceTexture = this._getRadianceTexture( index );\n\n\t\tconst lightTypes = this._lightTypes.slice();\n\t\tconst lightShadows = this._lightShadows.slice();\n\t\tconst shadowMatrices = this._shadowMatrices;\n\t\tconst shadowParams = this._shadowParams;\n\t\tconst reversedDepth = renderer.reversedDepthBuffer === true;\n\t\tconst shadowTanHalfAngle = this.shadowConeAngle.mul( 0.5 ).radians().tan();\n\n\t\tconst trace = createConeTracer( this, { maxSteps: 256 } );\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( voxelCount ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst bits = occupancy.element( instanceIndex ).toConst();\n\t\t\t\tconst result = vec4( 0 ).toVar();\n\t\t\t\tconst encodedNormal = normalTexture !== null ? vec4( 0 ).toVar() : null;\n\n\t\t\t\tIf( bits.notEqual( uint( 0 ) ), () => {\n\n\t\t\t\t\tconst surface = this._surface( coords, triangleIds.element( instanceIndex ) );\n\t\t\t\t\tconst { position, normal, albedo, side, emissive } = surface;\n\n\t\t\t\t\tif ( encodedNormal !== null ) encodedNormal.assign( vec4( normal.mul( 0.5 ).add( 0.5 ), 1 ) );\n\n\t\t\t\t\tconst irradiance = vec3( 0 ).toVar();\n\n\t\t\t\t\t// one specialized block per light; the kernel is rebuilt when the light set changes\n\n\t\t\t\t\tfor ( let i = 0; i < lightTypes.length; i ++ ) {\n\n\t\t\t\t\t\tconst type = lightTypes[ i ];\n\t\t\t\t\t\tconst shadowTexture = lightShadows[ i ];\n\n\t\t\t\t\t\tconst l0 = lights.element( i * 4 ).toConst();\n\t\t\t\t\t\tconst l1 = lights.element( i * 4 + 1 ).toConst();\n\t\t\t\t\t\tconst l2 = lights.element( i * 4 + 2 ).toConst();\n\t\t\t\t\t\tconst l3 = lights.element( i * 4 + 3 ).toConst();\n\n\t\t\t\t\t\tconst lightDirection = vec3( 0 ).toVar();\n\t\t\t\t\t\tconst lightDistance = float( 1e10 ).toVar();\n\t\t\t\t\t\tconst attenuation = float( 1 ).toVar();\n\n\t\t\t\t\t\tif ( type === 0 ) {\n\n\t\t\t\t\t\t\tlightDirection.assign( l1.xyz );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tconst lightVector = l0.xyz.sub( position ).toConst();\n\t\t\t\t\t\t\tlightDistance.assign( length( lightVector ) );\n\t\t\t\t\t\t\tlightDirection.assign( lightVector.div( lightDistance ) );\n\t\t\t\t\t\t\tattenuation.assign( getDistanceAttenuation( { lightDistance, cutoffDistance: l1.w, decayExponent: l2.w } ) );\n\n\t\t\t\t\t\t\tif ( type === 2 ) {\n\n\t\t\t\t\t\t\t\tattenuation.mulAssign( smoothstep( l3.x, l3.y, dot( l1.xyz, lightDirection.negate() ) ) );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst ndl = dot( normal, lightDirection ).toVar();\n\t\t\t\t\t\tndl.assign( select( side.equal( 2 ), abs( ndl ), max( ndl, 0 ) ) );\n\n\t\t\t\t\t\tIf( ndl.greaterThan( 0 ).and( attenuation.greaterThan( 0 ) ), () => {\n\n\t\t\t\t\t\t\tconst visibility = float( 1 ).toVar();\n\t\t\t\t\t\t\tconst shadowPosition = position.add( normal.mul( voxelSize ) ).toConst();\n\n\t\t\t\t\t\t\tif ( shadowTexture === null ) {\n\n\t\t\t\t\t\t\t\t// no shadow map: trace a visibility cone through the volume\n\n\t\t\t\t\t\t\t\tconst origin = position.add( normal.mul( voxelSize.mul( 1.5 ) ) );\n\t\t\t\t\t\t\t\tconst occlusion = trace( origin, lightDirection, shadowTanHalfAngle, lightDistance.sub( voxelSize ) );\n\t\t\t\t\t\t\t\tvisibility.assign( occlusion.alpha.oneMinus() );\n\n\t\t\t\t\t\t\t} else if ( type === 1 ) {\n\n\t\t\t\t\t\t\t\t// point light: cube shadow map addressed by the light-to-voxel vector\n\n\t\t\t\t\t\t\t\tconst params = shadowParams[ i ];\n\t\t\t\t\t\t\t\tconst bias = params.x, near = params.y, far = params.z;\n\n\t\t\t\t\t\t\t\tconst lightToVoxel = shadowPosition.sub( l0.xyz ).toConst();\n\t\t\t\t\t\t\t\tconst absVector = abs( lightToVoxel ).toConst();\n\t\t\t\t\t\t\t\tconst viewZ = max( max( absVector.x, absVector.y ), absVector.z ).toConst();\n\n\t\t\t\t\t\t\t\tIf( viewZ.greaterThanEqual( near ).and( viewZ.lessThanEqual( far ) ), () => {\n\n\t\t\t\t\t\t\t\t\tconst depth = cubeTexture( shadowTexture, normalize( lightToVoxel ) ).r; // depth cubes need an integer level, which the compute path emits by default\n\n\t\t\t\t\t\t\t\t\tif ( reversedDepth ) {\n\n\t\t\t\t\t\t\t\t\t\tconst reference = viewZToReversedPerspectiveDepth( viewZ.negate(), near, far ).sub( bias );\n\t\t\t\t\t\t\t\t\t\tvisibility.assign( select( reference.greaterThanEqual( depth ), 1, 0 ) );\n\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\tconst reference = viewZToPerspectiveDepth( viewZ.negate(), near, far ).add( bias );\n\t\t\t\t\t\t\t\t\t\tvisibility.assign( select( reference.lessThanEqual( depth ), 1, 0 ) );\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t// directional and spot lights: 2D shadow map addressed by the shadow matrix\n\n\t\t\t\t\t\t\t\tconst bias = shadowParams[ i ].x;\n\n\t\t\t\t\t\t\t\tconst clip = shadowMatrices[ i ].mul( vec4( shadowPosition, 1 ) ).toConst();\n\t\t\t\t\t\t\t\tconst coord = clip.xyz.div( clip.w ).toConst();\n\t\t\t\t\t\t\t\tconst uv = vec2( coord.x, coord.y.oneMinus() ).toConst();\n\n\t\t\t\t\t\t\t\tconst inside = uv.x.greaterThanEqual( 0 ).and( uv.x.lessThanEqual( 1 ) ).and( uv.y.greaterThanEqual( 0 ) ).and( uv.y.lessThanEqual( 1 ) ).and( coord.z.greaterThanEqual( 0 ) ).and( coord.z.lessThanEqual( 1 ) ).toConst();\n\n\t\t\t\t\t\t\t\tIf( inside, () => {\n\n\t\t\t\t\t\t\t\t\tconst depth = texture( shadowTexture, uv ).r;\n\n\t\t\t\t\t\t\t\t\tif ( reversedDepth ) {\n\n\t\t\t\t\t\t\t\t\t\tvisibility.assign( select( coord.z.sub( bias ).greaterThanEqual( depth ), 1, 0 ) );\n\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\tvisibility.assign( select( coord.z.add( bias ).lessThanEqual( depth ), 1, 0 ) );\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tirradiance.addAssign( l2.xyz.mul( attenuation.mul( ndl ).mul( visibility ) ) );\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst radiance = albedo.mul( irradiance ).div( PI ).add( emissive );\n\t\t\t\t\tconst occupied = float( countOneBits( bits ) ).div( 8 );\n\n\t\t\t\t\tresult.assign( vec4( radiance.mul( occupied ), occupied ) );\n\n\t\t\t\t} );\n\n\t\t\t\ttextureStore( directTexture, coords, result );\n\t\t\t\ttextureStore( radianceTexture, coords, result );\n\n\t\t\t\tif ( encodedNormal !== null ) textureStore( normalTexture, coords, encodedNormal );\n\n\t\t\t} );\n\n\t\t} )().compute( this._voxelCount ).setName( 'VXGI.Inject' );\n\n\t}\n\n\t_createBounceKernel( index ) {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst triangleIds = storage( this._triangleIdAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst voxelCount = this._voxelCountNode;\n\t\tconst size = this._getLevelSize( 0 );\n\t\tconst voxelSize = this.voxelSizeNode;\n\n\t\tconst directTexture = this._directTexture;\n\t\tconst sourceTexture = this._getRadianceTexture( 1 - index );\n\t\tconst targetTexture = this._getRadianceTexture( index );\n\n\t\tconst trace = createConeTracer( this, {\n\t\t\tradianceNode: texture3D( sourceTexture ),\n\t\t\tdirectionalNode: this._directional === true ? texture3D( this._getDirectionalTexture( 1 - index ) ) : null\n\t\t} );\n\t\tconst traceDistance = this._traceDistance;\n\t\tconst tanHalfAngle = this.bounceConeAngle.mul( 0.5 ).radians().tan();\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( voxelCount ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst bits = occupancy.element( instanceIndex ).toConst();\n\t\t\t\tconst result = vec4( 0 ).toVar();\n\n\t\t\t\tIf( bits.notEqual( uint( 0 ) ), () => {\n\n\t\t\t\t\tconst { position, normal, albedo } = this._surface( coords, triangleIds.element( instanceIndex ) );\n\n\t\t\t\t\tconst direct = texture3D( directTexture, vec3( coords ).add( 0.5 ).div( vec3( size[ 0 ], size[ 1 ], size[ 2 ] ) ), float( 0 ) ).toConst();\n\n\t\t\t\t\tconst rotation = hash( instanceIndex ).toConst();\n\t\t\t\t\tconst origin = position.add( normal.mul( voxelSize.mul( 1.5 ) ) ).toConst();\n\n\t\t\t\t\tconst { color } = gather( trace, origin, normal, BOUNCE_CONE_COUNT, tanHalfAngle, traceDistance, rotation, 0.5 );\n\n\t\t\t\t\tconst bounce = albedo.mul( color );\n\n\t\t\t\t\tresult.assign( vec4( direct.rgb.add( bounce.mul( direct.a ) ), direct.a ) );\n\n\t\t\t\t} );\n\n\t\t\t\ttextureStore( targetTexture, coords, result );\n\n\t\t\t} );\n\n\t\t} )().compute( this._voxelCount ).setName( 'VXGI.Bounce' );\n\n\t}\n\n}\n\nexport { VXGIVolume };\n","import { RenderTarget, Vector2, Vector3, Node, QuadMesh, NodeMaterial, RendererUtils, HalfFloatType, RGBAFormat, RedFormat, UnsignedByteType } from 'three/webgpu';\nimport { Fn, NodeUpdateType, uniform, reference, vec2, vec4, float, uv, mix, passTexture, getViewPosition, getNormalFromDepth, screenCoordinate, interleavedGradientNoise, normalize, floor, exp2, pow, PI, Loop, If, Break, property, outputStruct, context, projectionDepth } from 'three/tsl';\n\nimport { VXGIVolume } from './VXGIVolume.js';\nimport { createConeTracer, gather, intersectVolume, sampleDirectional } from './VXGIConeTracer.js';\n\nconst _quadMesh = /*@__PURE__*/ new QuadMesh();\nconst _size = /*@__PURE__*/ new Vector2();\n\nconst TEMPORAL_SHIFT = 5.588238;\nconst TEMPORAL_CYCLE = 64;\n\nlet _rendererState;\n\nconst _neutralContext = /*@__PURE__*/ context();\n\n/**\n * Post processing node for voxel based global illumination. The scene is voxelized into a\n * {@link VXGIVolume} and indirect diffuse light and ambient occlusion are gathered per\n * pixel with approximate voxel cone tracing.\n *\n * The node is a middle path between SSGI and Light Probe Grids:\n *\n * - Compared to `SSGINode` it is free of screen-space artifacts and provides noticeably more\n * consistent lighting, since off-screen surfaces and thin occluders contribute.\n * However, it is less dynamic: objects should stay static, because geometry changes require\n * a re-voxelization (`needsUpdate = true`) which is too expensive for per-frame animation.\n * - Compared to `LightProbeGrid` it supports dynamic lighting without a new baking process and\n * produces a better overall lighting quality with less light bleeding. However, it is more\n * expensive and therefore less suitable for performance restricted use cases.\n *\n * The quality/performance of the effect mainly depend on the voxel resolution, the number of cones\n * traced per pixel as well as the apeture of the cones.\n *\n * Lights and their shadow maps are picked up automatically. Only direct lights are injected.\n *\n * References:\n * - {@link https://research.nvidia.com/publication/2011-09_interactive-indirect-illumination-using-voxel-cone-tracing}:\n * Crassin et al., Interactive Indirect Illumination Using Voxel Cone Tracing, Pacific Graphics 2011.\n *\n * Note: This node can only be used with `WebGPURenderer` and a WebGPU backend.\n *\n * @augments Node\n * @three_import import { vxgi } from 'three/addons/lighting/vxgi/VXGINode.js';\n */\nclass VXGINode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'VXGINode';\n\n\t}\n\n\t/**\n\t * Constructs a new voxel GI node.\n\t *\n\t * @param {TextureNode} depthNode - A texture node that represents the scene's depth.\n\t * @param {?TextureNode} normalNode - A texture node that represents the scene's view space normals.\n\t * @param {Scene} scene - The scene to voxelize.\n\t * @param {Camera} camera - The camera the scene is rendered with.\n\t * @param {number} [resolution=128] - Number of voxels along the longest axis of the volume. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer.\n\t */\n\tconstructor( depthNode, normalNode, scene, camera, resolution = 128 ) {\n\n\t\tsuper( 'vec4' );\n\n\t\t/**\n\t\t * A node that represents the scene's depth.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.depthNode = depthNode;\n\n\t\t/**\n\t\t * A node that represents the scene's normals. If `null`, normals are reconstructed from depth.\n\t\t *\n\t\t * @type {?TextureNode}\n\t\t */\n\t\tthis.normalNode = normalNode;\n\n\t\t/**\n\t\t * The scene to voxelize.\n\t\t *\n\t\t * @type {Scene}\n\t\t */\n\t\tthis.scene = scene;\n\n\t\t/**\n\t\t * The camera the scene is rendered with.\n\t\t *\n\t\t * @type {Camera}\n\t\t */\n\t\tthis.camera = camera;\n\n\t\t/**\n\t\t * The voxel volume. Use it to configure bounds, layers and bounces.\n\t\t *\n\t\t * @type {VXGIVolume}\n\t\t */\n\t\tthis.volume = new VXGIVolume( resolution );\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders\n\t\t * its effect once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t/**\n\t\t * Number of cones traced per pixel. Should be in the range `[2, 8]`.\n\t\t *\n\t\t * Mainly defines the quality and precision of the Voxel Cone Tracing. A value of\n\t\t * `2` - `4` is the recommended setting. Use `2` for performance restricted use cases.\n\t\t *\n\t\t * @type {UniformNode<uint>}\n\t\t * @default 3\n\t\t */\n\t\tthis.coneCount = uniform( 3, 'uint' );\n\n\t\t/**\n\t\t * Aperture of the diffuse cones in degrees. Wider cones are faster (fewer steps) but leak\n\t\t * and over-occlude more, narrow cones are more precise but noisier and take more steps.\n\t\t * Choose it together with {@link VXGINode#coneCount}. Should be in the range `[10, 90]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 40\n\t\t */\n\t\tthis.coneAngle = uniform( 40 );\n\n\t\t/**\n\t\t * Intensity of the indirect diffuse irradiance.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.giIntensity = uniform( 1 );\n\n\t\t/**\n\t\t * Power function applied to AO to make it appear darker/lighter.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.aoIntensity = uniform( 1 );\n\n\t\t/**\n\t\t * The darkest value the ambient occlusion can reach. Lifts creases and contact regions out\n\t\t * of pure black, which voxel-traced occlusion tends to overestimate at the resolution of\n\t\t * a voxel. `0` keeps the full occlusion range.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0\n\t\t */\n\t\tthis.aoMinVisibility = uniform( 0 );\n\n\t\t/**\n\t\t * Occlusion is weighted by `1 / ( 1 + distance / aoDistance )` for AO, so occluders at this\n\t\t * world-space distance count half. `0` disables the falloff.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.aoDistance = uniform( 1 );\n\n\t\t/**\n\t\t * Offset of the cone origins along the surface normal in voxels. The surface's own voxel\n\t\t * can extend up to half a voxel above the surface and the trilinear footprint of a sample\n\t\t * spans another half voxel, so 1.5 voxels avoid self-occlusion in every case.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1.5\n\t\t */\n\t\tthis.normalOffset = uniform( 1.5 );\n\n\t\t/**\n\t\t * Debug visualization of the volume: `0` = off, `1` = radiance voxels, `2` = per-axis opacity voxels.\n\t\t * The visualization replaces the GI output.\n\t\t *\n\t\t * @type {UniformNode<int>}\n\t\t * @default 0\n\t\t */\n\t\tthis.debug = uniform( 0, 'int' );\n\n\t\t/**\n\t\t * The mip level shown by the debug visualization.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0\n\t\t */\n\t\tthis.debugLevel = uniform( 0 );\n\n\t\t/**\n\t\t * Whether to use temporal filtering or not. Setting this property to `true` requires the\n\t\t * usage of `TRAANode`. Cone directions are then rotated per frame to converge the noise.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.useTemporalFiltering = true;\n\n\t\t// private uniforms\n\n\t\tthis._resolution = uniform( new Vector2() );\n\t\tthis._frame = uniform( 0 );\n\t\tthis._cameraProjectionMatrix = uniform( camera.projectionMatrix );\n\t\tthis._cameraProjectionMatrixInverse = uniform( camera.projectionMatrixInverse );\n\t\tthis._cameraWorldMatrix = uniform( camera.matrixWorld );\n\t\tthis._cameraPosition = uniform( new Vector3() ).onRenderUpdate( ( _, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );\n\t\tthis._cameraNear = reference( 'near', 'float', camera );\n\t\tthis._cameraFar = reference( 'far', 'float', camera );\n\n\t\t/**\n\t\t * The render target the effect is rendered into. The first texture holds the AO,\n\t\t * the second one the GI.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTarget = new RenderTarget( 1, 1, { depthBuffer: false, count: 2 } );\n\n\t\tconst aoTexture = this._renderTarget.textures[ 0 ];\n\t\taoTexture.name = 'VXGI.AO';\n\t\taoTexture.type = UnsignedByteType;\n\t\taoTexture.format = RedFormat;\n\n\t\tconst giTexture = this._renderTarget.textures[ 1 ];\n\t\tgiTexture.name = 'VXGI.GI';\n\t\tgiTexture.type = HalfFloatType;\n\t\tgiTexture.format = RGBAFormat;\n\n\t\tthis._material = new NodeMaterial();\n\t\tthis._material.name = 'VXGI';\n\n\t\t// the shared context of the last build and the directional setting the material was built with\n\n\t\tthis._sharedContext = null;\n\t\tthis._directional = null;\n\n\t\tthis._aoNode = passTexture( this, aoTexture );\n\t\tthis._giNode = passTexture( this, giTexture );\n\n\t}\n\n\t/**\n\t * Number of cached indirect bounces. See {@link VXGIVolume#bounces}.\n\t *\n\t * @type {number}\n\t */\n\tget bounces() {\n\n\t\treturn this.volume.bounces;\n\n\t}\n\n\tset bounces( value ) {\n\n\t\tthis.volume.bounces = value;\n\t\tthis.volume.lightingNeedsUpdate = true;\n\n\t}\n\n\t/**\n\t * Whether the coarser radiance levels are filtered directionally to reduce light bleeding\n\t * through thin walls and floors. Off by default since it costs memory and performance.\n\t * See {@link VXGIVolume#directionalRadiance}.\n\t *\n\t * @type {boolean}\n\t */\n\tget directionalRadiance() {\n\n\t\treturn this.volume.directionalRadiance;\n\n\t}\n\n\tset directionalRadiance( value ) {\n\n\t\tthis.volume.directionalRadiance = value;\n\n\t}\n\n\t/**\n\t * Set to `true` to re-voxelize the scene in the next frame.\n\t *\n\t * @type {boolean}\n\t */\n\tget needsUpdate() {\n\n\t\treturn this.volume.needsUpdate;\n\n\t}\n\n\tset needsUpdate( value ) {\n\n\t\tthis.volume.needsUpdate = value;\n\n\t}\n\n\t/**\n\t * Set to `true` to re-inject lighting in the next frame.\n\t *\n\t * @type {boolean}\n\t */\n\tget lightingNeedsUpdate() {\n\n\t\treturn this.volume.lightingNeedsUpdate;\n\n\t}\n\n\tset lightingNeedsUpdate( value ) {\n\n\t\tthis.volume.lightingNeedsUpdate = value;\n\n\t}\n\n\t/**\n\t * Returns the AO result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the AO result of the effect.\n\t */\n\tgetAONode() {\n\n\t\treturn this._aoNode;\n\n\t}\n\n\t/**\n\t * Returns the GI result of the effect as a texture node. The texture holds the indirect\n\t * diffuse irradiance, ready to be added to the lighting via `builtinGIContext()`.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the GI result of the effect.\n\t */\n\tgetGINode() {\n\n\t\treturn this._giNode;\n\n\t}\n\n\t/**\n\t * Sets the size of the effect.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetSize( width, height ) {\n\n\t\tthis._resolution.value.set( width, height );\n\t\tthis._renderTarget.setSize( width, height );\n\n\t}\n\n\t/**\n\t * This method is used to render the effect once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore( frame ) {\n\n\t\tconst { renderer } = frame;\n\n\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t// this node is usually updated while a scene pass renders whose context injects the\n\t\t// AO/GI of this node into the materials; the nested renders below must not inherit it\n\n\t\tconst currentContextNode = renderer.contextNode;\n\t\trenderer.contextNode = _neutralContext;\n\n\t\t//\n\n\t\tconst size = renderer.getDrawingBufferSize( _size );\n\t\tthis.setSize( size.width, size.height );\n\n\t\t// voxelization and light injection\n\n\t\tthis.volume.update( renderer, this.scene );\n\n\t\t// the sampling code depends on the volume's directional setting\n\n\t\tif ( this._sharedContext !== null && this._directional !== this.volume.directionalRadiance ) {\n\n\t\t\tthis._setupMaterial();\n\n\t\t}\n\n\t\t// update temporal uniforms\n\n\t\tif ( this.useTemporalFiltering === true ) {\n\n\t\t\tthis._frame.value = frame.frameId % TEMPORAL_CYCLE;\n\n\t\t} else {\n\n\t\t\tthis._frame.value = 0;\n\n\t\t}\n\n\t\t//\n\n\t\t_quadMesh.material = this._material;\n\t\t_quadMesh.name = 'VXGI';\n\n\t\t// clear (white for the AO attachment)\n\n\t\trenderer.setClearColor( 0xffffff, 1 );\n\n\t\trenderer.setRenderTarget( this._renderTarget );\n\t\t_quadMesh.render( renderer );\n\n\t\t// restore\n\n\t\trenderer.contextNode = currentContextNode;\n\n\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {PassTextureNode}\n\t */\n\tsetup( builder ) {\n\n\t\tthis._sharedContext = builder.getSharedContext();\n\t\tthis._setupMaterial();\n\n\t\treturn this._aoNode;\n\n\t}\n\n\t/**\n\t * Builds the TSL code of the effect into the internal pass material.\n\t *\n\t * @private\n\t */\n\t_setupMaterial() {\n\n\t\tconst volume = this.volume;\n\t\tconst directional = this._directional = volume.directionalRadiance;\n\t\tconst uvNode = uv();\n\n\t\tconst sampleDepth = ( uv ) => projectionDepth( this.depthNode.sample( uv ).r, this._cameraNear, this._cameraFar );\n\n\t\tconst sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.sample( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );\n\n\t\tconst voxelSize = volume.voxelSizeNode;\n\t\tconst projectionMatrixInverse = this._cameraProjectionMatrixInverse;\n\n\t\tconst trace = createConeTracer( volume, {\n\t\t\tradianceNode: volume.radianceNode,\n\t\t\tdirectionalNode: directional === true ? volume.directionalNode : null\n\t\t} );\n\n\t\tconst aoField = property( 'float' );\n\t\tconst giField = property( 'vec4' );\n\n\t\tconst outputNode = outputStruct( aoField, giField );\n\n\t\tconst gi = Fn( () => {\n\n\t\t\tconst depth = sampleDepth( uvNode ).toConst();\n\n\t\t\tdepth.greaterThanEqual( 1.0 ).discard();\n\n\t\t\tconst viewPosition = getViewPosition( uvNode, depth, projectionMatrixInverse ).toConst();\n\t\t\tconst worldPosition = this._cameraWorldMatrix.mul( vec4( viewPosition, 1 ) ).xyz.toConst();\n\t\t\tconst viewNormal = sampleNormal( uvNode ).toConst();\n\t\t\tconst worldNormal = normalize( this._cameraWorldMatrix.mul( vec4( viewNormal, 0 ) ).xyz ).toConst();\n\n\t\t\t// interleaved gradient noise for both values: its spatial structure converges well under temporal filtering\n\n\t\t\tconst temporalShift = this._frame.mul( TEMPORAL_SHIFT ).toConst();\n\t\t\tconst rotationNoise = interleavedGradientNoise( screenCoordinate.add( temporalShift ) ).toConst();\n\t\t\tconst elevationNoise = interleavedGradientNoise( screenCoordinate.add( temporalShift ).add( vec2( 5.588238, 3.14159 ) ) ).toConst();\n\n\t\t\tconst CONE_COUNT = this.coneCount.toConst();\n\t\t\tconst tanHalfAngle = this.coneAngle.mul( 0.5 ).radians().tan().toConst();\n\t\t\tconst traceDistance = volume.traceDistanceNode;\n\t\t\tconst aoDistance = this.aoDistance;\n\t\t\tconst origin = worldPosition.add( worldNormal.mul( voxelSize.mul( this.normalOffset ) ) ).toConst();\n\n\t\t\tconst { color: radiance, ao: occlusion } = gather( trace, origin, worldNormal, CONE_COUNT, tanHalfAngle, traceDistance, rotationNoise, elevationNoise, aoDistance );\n\n\t\t\t// the mean radiance over the cosine-weighted hemisphere times PI is the irradiance\n\n\t\t\tconst color = radiance.mul( this.giIntensity.mul( PI ) ).toVar();\n\n\t\t\tconst ao = mix( this.aoMinVisibility, float( 1 ), pow( occlusion.oneMinus().clamp(), this.aoIntensity ) ).toVar();\n\n\t\t\t// debug visualization: march the voxels from the camera\n\n\t\t\tIf( this.debug.greaterThan( 0 ), () => {\n\n\t\t\t\tconst cameraPosition = this._cameraPosition;\n\t\t\t\tconst direction = normalize( worldPosition.sub( cameraPosition ) ).toConst();\n\t\t\t\tconst surfaceDistance = worldPosition.sub( cameraPosition ).length().toConst();\n\t\t\t\tconst level = this.debugLevel.toConst();\n\t\t\t\tconst texel = voxelSize.mul( exp2( level ) ).toConst();\n\t\t\t\tconst levelSize = volume.volumeSizeNode.div( texel ).toConst();\n\t\t\t\tconst boundsMin = volume.boundsMinNode;\n\n\t\t\t\tconst { tEnter, tExit } = intersectVolume( volume, cameraPosition, direction );\n\t\t\t\tconst tMax = tExit.min( surfaceDistance ).toConst();\n\t\t\t\tconst t = tEnter.toVar();\n\n\t\t\t\tcolor.assign( 0 );\n\t\t\t\tao.assign( 1 );\n\n\t\t\t\tLoop( { start: 0, end: 512, type: 'int', condition: '<', name: 's' }, () => {\n\n\t\t\t\t\tIf( t.greaterThanEqual( tMax ), () => {\n\n\t\t\t\t\t\tBreak();\n\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst uvw = cameraPosition.add( direction.mul( t ) ).sub( boundsMin ).div( volume.volumeSizeNode );\n\t\t\t\t\tconst snapped = floor( uvw.mul( levelSize ) ).add( 0.5 ).div( levelSize ).toConst();\n\n\t\t\t\t\tIf( this.debug.equal( 1 ), () => {\n\n\t\t\t\t\t\tlet radiance;\n\n\t\t\t\t\t\tif ( directional === false ) {\n\n\t\t\t\t\t\t\tradiance = volume.radianceNode.sample( snapped ).level( level ).toConst();\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tradiance = vec4( 0 ).toVar();\n\n\t\t\t\t\t\t\tIf( level.lessThan( 1 ), () => {\n\n\t\t\t\t\t\t\t\tradiance.assign( volume.radianceNode.sample( snapped ).level( float( 0 ) ) );\n\n\t\t\t\t\t\t\t} ).Else( () => {\n\n\t\t\t\t\t\t\t\tradiance.assign( sampleDirectional( volume, volume.directionalNode, snapped, level.sub( 1 ), direction ) );\n\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tIf( radiance.a.greaterThan( 0.01 ), () => {\n\n\t\t\t\t\t\t\tcolor.assign( radiance.rgb.div( radiance.a ) );\n\t\t\t\t\t\t\tBreak();\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} ).Else( () => {\n\n\t\t\t\t\t\tconst opacity = volume.opacityNode.sample( snapped ).level( level ).toConst();\n\n\t\t\t\t\t\tIf( opacity.w.greaterThan( 0.01 ), () => {\n\n\t\t\t\t\t\t\tcolor.assign( opacity.xyz );\n\t\t\t\t\t\t\tBreak();\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} );\n\n\t\t\t\t\tt.addAssign( texel.mul( 0.25 ) );\n\n\t\t\t\t} );\n\n\t\t\t} );\n\n\t\t\taoField.assign( ao );\n\t\t\tgiField.assign( vec4( color, 1 ) );\n\n\t\t\treturn vec4( 0 );\n\n\t\t} );\n\n\t\tthis._material.contextNode = context( this._sharedContext );\n\t\tthis._material.colorNode = gi();\n\t\tthis._material.outputNode = outputNode;\n\t\tthis._material.needsUpdate = true;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis._renderTarget.dispose();\n\t\tthis._material.dispose();\n\t\tthis.volume.dispose();\n\n\t}\n\n}\n\nexport default VXGINode;\n\n/**\n * TSL function for creating a voxel GI effect.\n *\n * @tsl\n * @function\n * @param {TextureNode} depthNode - A texture node that represents the scene's depth.\n * @param {?TextureNode} normalNode - A texture node that represents the scene's view space normals.\n * @param {Scene} scene - The scene to voxelize.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @param {number} [resolution=128] - Number of voxels along the longest axis of the volume. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer.\n * @returns {VXGINode}\n */\nexport const vxgi = ( depthNode, normalNode, scene, camera, resolution ) => new VXGINode( depthNode, normalNode, scene, camera, resolution );\n","import { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { Camera, Scene } from 'three';\nimport { PerspectiveCamera } from 'three';\nimport type { Node, PassNode, UniformNode } from 'three/webgpu';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\nimport {\n builtinGIContext,\n pass,\n mrt,\n packNormalToRGB,\n normalView,\n sample,\n screenUV,\n uniform,\n unpackRGBToNormal,\n vec3,\n vec4,\n} from 'three/tsl';\nimport type VXGINode from 'three/examples/jsm/lighting/vxgi/VXGINode.js';\nimport { vxgi } from 'three/examples/jsm/lighting/vxgi/VXGINode.js';\nimport { LAYER } from '../../webgl/layer';\n\nexport interface VxgiPassParameters {\n coneCount: number;\n coneAngle: number;\n volumeStepScale: number;\n volumeMaxDistance: number;\n normalOffset: number;\n aoIntensity: number;\n giIntensity: number;\n bounces: number;\n directionalRadiance: boolean;\n useTemporalFiltering: boolean;\n vxgiResolution: number;\n}\n\nexport interface VxgiPerformanceParameters {\n coneCount: number;\n coneAngle: number;\n}\n\nexport class VxgiRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'VxgiRenderPass';\n override readonly passId = VxgiRenderPass.passId;\n private vxgiNode: VXGINode | undefined = undefined;\n private readonly vxgiDebug: UniformNode<'int', number>;\n private readonly vxgiDebugLevel: UniformNode<'float', number>;\n private readonly coneCount: UniformNode<'uint', number>;\n private readonly coneAngle: UniformNode<'float', number>;\n private readonly volumeStepScale: UniformNode<'float', number>;\n private readonly volumeMaxDistance: UniformNode<'float', number>;\n private readonly normalOffset: UniformNode<'float', number>;\n private readonly aoIntensity: UniformNode<'float', number>;\n private readonly giIntensity: UniformNode<'float', number>;\n private readonly bounces: number;\n private readonly directionalRadiance: boolean;\n private readonly useTemporalFiltering: boolean;\n private readonly vxgiResolution: number;\n\n constructor(params: VxgiPassParameters) {\n super();\n this.vxgiDebug = uniform(0, 'int');\n this.vxgiDebugLevel = uniform(0);\n this.coneCount = uniform(params.coneCount, 'uint');\n this.coneAngle = uniform(params.coneAngle);\n this.volumeStepScale = uniform(params.volumeStepScale);\n this.volumeMaxDistance = uniform(params.volumeMaxDistance);\n this.normalOffset = uniform(params.normalOffset);\n this.aoIntensity = uniform(params.aoIntensity);\n this.giIntensity = uniform(params.giIntensity);\n this.bounces = params.bounces;\n this.directionalRadiance = params.directionalRadiance;\n this.useTemporalFiltering = params.useTemporalFiltering;\n this.vxgiResolution = params.vxgiResolution;\n }\n\n public updatePerformanceParameters(params: VxgiPerformanceParameters): void {\n this.coneCount.value = params.coneCount;\n this.coneAngle.value = params.coneAngle;\n }\n\n override addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const gui = renderPassSettings.addFolder('VXGI Settings');\n gui\n .add(this.vxgiDebug, 'value', 0, 2, 1)\n .name('voxel view')\n .onChange(() => updateCallback());\n gui\n .add(this.vxgiDebugLevel, 'value', 0, 4, 1)\n .name('debug level')\n .onChange(() => updateCallback());\n gui\n .add(this.coneCount, 'value', 2, 8, 1)\n .name('cone count')\n .onChange(() => updateCallback());\n gui\n .add(this.coneAngle, 'value', 10, 90)\n .name('cone angle')\n .onChange(() => updateCallback());\n gui\n .add(this.volumeStepScale, 'value', 0.25, 2)\n .name('step scale')\n .onChange(() => updateCallback());\n gui\n .add(this.volumeMaxDistance, 'value', 0, 50)\n .name('max distance')\n .onChange(() => updateCallback());\n gui\n .add(this.normalOffset, 'value', 0, 4)\n .name('normal offset')\n .onChange(() => updateCallback());\n gui\n .add(this.aoIntensity, 'value', 0, 4)\n .name('AO intensity')\n .onChange(() => updateCallback());\n gui\n .add(this.giIntensity, 'value', 0, 4)\n .name('GI intensity')\n .onChange(() => updateCallback());\n }\n\n public revoxelize(): void {\n console.log('revoxelizing scene for vxgi...');\n if (this.vxgiNode) {\n this.vxgiNode.needsUpdate = true;\n }\n }\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n if (!(camera instanceof PerspectiveCamera)) {\n return currentNode; // no vxgi for orthographic camera\n }\n if (this.coneCount.value === 0) {\n return currentNode; // VXGINode divides by the cone count\n }\n\n const prePass = pass(scene, camera);\n prePass.name = 'VXGI Pre-Pass';\n prePass.transparent = false;\n prePass.setMRT(mrt({ output: packNormalToRGB(normalView) }));\n\n const prePassDepth = prePass.getTextureNode('depth');\n const prePassNormal = sample((uv) => {\n return unpackRGBToNormal(prePass.getTextureNode().sample(uv));\n });\n\n this.vxgiNode = vxgi(\n prePassDepth,\n prePassNormal,\n scene,\n camera,\n this.vxgiResolution,\n );\n // @ts-expect-error -- three-types messed this one up, works fine but shows an error\n this.vxgiNode.debug = this.vxgiDebug;\n this.vxgiNode.debugLevel = this.vxgiDebugLevel;\n this.vxgiNode.coneCount = this.coneCount;\n this.vxgiNode.coneAngle = this.coneAngle;\n this.vxgiNode.volume.stepScale = this.volumeStepScale;\n this.vxgiNode.volume.maxDistance = this.volumeMaxDistance;\n this.vxgiNode.normalOffset = this.normalOffset;\n this.vxgiNode.aoIntensity = this.aoIntensity;\n this.vxgiNode.giIntensity = this.giIntensity;\n this.vxgiNode.bounces = this.bounces;\n this.vxgiNode.directionalRadiance = this.directionalRadiance;\n this.vxgiNode.useTemporalFiltering = this.useTemporalFiltering;\n\n this.vxgiNode.volume.layers.disableAll();\n this.vxgiNode.volume.layers.enable(LAYER.OBJECT);\n this.vxgiNode.volume.layers.enable(LAYER.COMPONENT);\n this.vxgiNode.volume.layers.enable(LAYER.CONSTRUCTION);\n // also consider invisible walls for ao and gi\n this.vxgiNode.volume.layers.enable(LAYER.SHADOW_ONLY);\n\n const ao = this.vxgiNode.getAONode().toInspector('VXGI / AO');\n const gi = this.vxgiNode.getGINode().toInspector('VXGI / GI');\n\n basePassNode.contextNode = builtinGIContext(\n ao.sample(screenUV).r,\n gi.sample(screenUV).rgb,\n );\n\n if (debugMode === 'ao only') {\n return vec4(vec3(ao.r), 1);\n } else if (debugMode === 'gi only') {\n return vec4(gi.rgb, 1);\n }\n\n return currentNode;\n }\n}\n","import type {\n Box3,\n Camera,\n ColorRepresentation,\n Node,\n Object3D,\n Scene,\n ToneMapping,\n WebGPURenderer,\n PassNode,\n} from 'three/webgpu';\nimport {\n ACESFilmicToneMapping,\n AgXToneMapping,\n CineonToneMapping,\n LinearToneMapping,\n NeutralToneMapping,\n NoToneMapping,\n OrthographicCamera,\n PerspectiveCamera,\n ReinhardToneMapping,\n RenderPipeline,\n RenderTarget,\n} from 'three/webgpu';\nimport {\n diffuseColor,\n mrt,\n normalView,\n output,\n packNormalToRGB,\n pass,\n velocity,\n} from 'three/tsl';\nimport { PlannerRenderMode, RoomleRenderer } from '../roomle-renderer';\nimport type { OutlineCustomParameters } from '../webgl/renderer/scene-renderer';\nimport type { SceneShadingType } from '../webgl/renderer/shading-settings';\nimport { SCENE_SHADING_TYPES } from '../webgl/renderer/shading-settings';\nimport type { RoomleWebGPURenderPass } from './passes/roomle-webgpu-render-pass';\nimport { OutlineRenderPass } from './passes/outline-render-pass';\nimport { Inspector } from 'three/examples/jsm/inspector/Inspector.js';\nimport type DomHelper from '../utils/dom-helper';\nimport inject from '../di/inject';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport { SsgiRenderPass } from './passes/ssgi-render-pass';\nimport type { Enumify } from '#/common/src/utils/types';\nimport type { CAMERA_TYPE } from '../cameracontrol/camera-type';\nimport type { WebGpuGroundShadowReflectionContainer } from './web-gpu-ground-shadow-reflection-container';\nimport { TraaRenderPass } from './passes/traa-render-pass';\nimport type { WebGPUQualityParameters } from './roomle-webgpu-renderer-quality-levels';\nimport { RoomleWebGPUQualityManager } from './roomle-webgpu-quality-manager';\nimport type InitData from '../utils/init-data';\nimport { getColor } from '../utils/common-utils';\nimport { FogRenderPass } from './passes/fog-render-pass';\nimport { DebugRenderPass } from './passes/debug-render-pass';\nimport type { WebGpuToneMapping } from '../utils/shims';\nimport { WEBGPU_TONE_MAPPINGS } from '../utils/shims';\nimport type { WebGpuGiMode } from '../utils/shims';\nimport { WEBGPU_GI_MODES } from '../utils/shims';\nimport type { WebGpuSkyContainer } from './web-gpu-sky-container';\nimport type { SkyStateTracker } from './sky-state-tracker';\nimport { VxgiRenderPass } from './passes/vxgi-render-pass';\n\nexport { FREEZE_FRAMES_ON_QUALITY_CHANGE } from './roomle-webgpu-quality-manager';\n\n// freeze-frame on traa initialization to avoid black flicker\nexport const FREEZE_FRAMES_ON_TRAA_INITIALIZATION = 10;\n\nconst RENDER_PASS_ORDER = [\n SsgiRenderPass.passId,\n VxgiRenderPass.passId,\n OutlineRenderPass.passId,\n FogRenderPass.passId,\n TraaRenderPass.passId,\n];\n\nconst TONE_MAPPING_BY_CONFIG_VALUE: Record<WebGpuToneMapping, ToneMapping> = {\n [WEBGPU_TONE_MAPPINGS.NONE]: NoToneMapping,\n [WEBGPU_TONE_MAPPINGS.LINEAR]: LinearToneMapping,\n [WEBGPU_TONE_MAPPINGS.REINHARD]: ReinhardToneMapping,\n [WEBGPU_TONE_MAPPINGS.CINEON]: CineonToneMapping,\n [WEBGPU_TONE_MAPPINGS.ACES_FILMIC]: ACESFilmicToneMapping,\n [WEBGPU_TONE_MAPPINGS.AGX]: AgXToneMapping,\n [WEBGPU_TONE_MAPPINGS.NEUTRAL]: NeutralToneMapping,\n};\n\nexport type WebGPUDebugMode =\n | 'off'\n | 'outline'\n | 'direct lighting only'\n | 'ao only'\n | 'gi only'\n | 'denoised ao only'\n | 'denoised gi only'\n | 'without denoise'\n | 'no fog'\n | 'depth'\n | 'velocity';\n\ninterface OutlineColors {\n outlineVisibleEdgeColor: ColorRepresentation;\n outlineHiddenEdgeColor: ColorRepresentation;\n}\n\nexport class RoomleWebGPURenderer extends RoomleRenderer<WebGPURenderer> {\n private readonly renderPipeline: RenderPipeline;\n private passNeedsReassembly = true;\n private debugMode: WebGPUDebugMode = 'off';\n private readonly renderPasses = new Map<string, RoomleWebGPURenderPass>();\n private readonly guiParameterGroups = new Map<string, ParametersGroup>();\n private lastRenderCamera: Camera | undefined = undefined;\n private readonly qualityManager = new RoomleWebGPUQualityManager(\n this.applyQualityParameters.bind(this),\n );\n private freezeFrames = 0;\n private readonly freezeRenderTarget = new RenderTarget();\n private readonly debugRenderPass = new DebugRenderPass();\n private giMode: WebGpuGiMode;\n private voxelsNeedUpdate = false;\n\n @inject\n private declare _domHelper: DomHelper;\n\n @inject\n private declare _webGpuGroundShadowReflection: WebGpuGroundShadowReflectionContainer;\n\n @inject\n private declare _webGpuSkyContainer: WebGpuSkyContainer;\n\n @inject\n private declare _skyStateTracker: SkyStateTracker;\n\n @inject\n private declare _initData: InitData;\n\n constructor(\n creator: string,\n renderer: WebGPURenderer,\n enableGI: boolean,\n outlineColors?: OutlineColors,\n enableTraa: boolean = enableGI,\n ) {\n super(creator, renderer);\n\n this.giMode = this._initData.webGpuConfig.giMode;\n this.renderPipeline = new RenderPipeline(renderer);\n this.applyToneMappingConfig();\n this.enableDefaultRenderPasses(enableGI, outlineColors, enableTraa);\n if (this._initData.webGpuConfig.autoDetectQualityLevel) {\n this.qualityManager\n .autoDetectInitialQualityLevel()\n .then(() => this.qualityManager.applyCurrentQualityLevel(0));\n } else {\n this.qualityManager.applyCurrentQualityLevel(0);\n }\n }\n\n private enableDefaultRenderPasses(\n enableGI: boolean,\n outlineColors: OutlineColors | undefined,\n enableTraa: boolean,\n ) {\n const enableFog = this._initData.webGpuConfig.fog.enabled;\n const transparentBackground = this._initData.transparentBackground;\n\n if (enableGI) {\n // Couple GI temporal filtering to TRAA\n this.enableGiPass(enableTraa);\n }\n if (outlineColors) {\n this.enableOutline(\n outlineColors.outlineVisibleEdgeColor,\n outlineColors.outlineHiddenEdgeColor,\n );\n }\n if (!transparentBackground) {\n if (enableTraa) {\n this.enableTraaPass();\n this.freezeFrames = Math.max(\n this.freezeFrames,\n FREEZE_FRAMES_ON_TRAA_INITIALIZATION,\n );\n }\n if (enableFog) {\n this.enableFogPass();\n }\n }\n }\n\n public async addGroundShadowLightAndFloor(scene: Scene): Promise<void> {\n await this._webGpuGroundShadowReflection.addToScene(scene);\n }\n\n public async addSky(scene: Scene): Promise<void> {\n await this._webGpuSkyContainer.addToScene(scene);\n }\n\n private addRenderPass(renderPass: RoomleWebGPURenderPass): void {\n this.renderPasses.set(renderPass.passId, renderPass);\n this.passNeedsReassembly = true;\n }\n\n public override clearCache(): void {\n return; // not required for webgpu as there is no render cache\n }\n\n public override disableUiInteractionMode(): void {\n return; // for webgl this just disables the ground reflection which does not exist in webgpu mode yet\n }\n\n public override enableUiInteractionMode(): void {\n return; // for webgl this just re-enables the ground reflection which does not exist in webgpu mode yet\n }\n\n public override onReadyForRender(): void {\n const vxgiPass = this.getVxgiPassOrUndefined();\n if (vxgiPass) {\n // fix a visual issue with the wall voxelization\n this.passNeedsReassembly = true;\n }\n }\n\n public override updateBounds(geometryBounds: Box3): void {\n super.updateBounds(geometryBounds);\n this.voxelsNeedUpdate = true;\n }\n\n public override setCameraType(cameraType: Enumify<typeof CAMERA_TYPE>) {\n super.setCameraType(cameraType);\n this.passNeedsReassembly = true;\n }\n\n public override switchToConfigurator() {\n super.switchToConfigurator();\n\n this._webGpuGroundShadowReflection.setFloorVisible(true);\n this._webGpuGroundShadowReflection.setTopLightVisible(true);\n this._webGpuSkyContainer.setVisible(false);\n this._skyStateTracker.notifyEnteredConfigurator();\n\n const shouldEnableFog =\n this._initData.webGpuConfig.fog.enabled &&\n !this._initData.transparentBackground;\n if (shouldEnableFog) {\n this.enableFogPass();\n }\n this.passNeedsReassembly = true;\n }\n\n public override switchToPlanner(renderMode: PlannerRenderMode) {\n super.switchToPlanner(renderMode);\n\n const isSkyEnabled = this._skyStateTracker.isSkyEnabled;\n this._webGpuGroundShadowReflection.setFloorVisible(isSkyEnabled);\n this._webGpuGroundShadowReflection.setTopLightVisible(\n !isSkyEnabled && renderMode !== PlannerRenderMode.Mode2D,\n );\n this._webGpuSkyContainer.setVisible(isSkyEnabled);\n this._skyStateTracker.notifyEnteredPlanner();\n\n this.disableFogPass();\n this.passNeedsReassembly = true;\n }\n\n public override highlightObjects(selectedMeshes: Object3D[]): void {\n this.getOutlinePassOrUndefined()?.highlightObjects(selectedMeshes);\n }\n\n public override render(scene: Scene, camera: Camera): void {\n this.updateCameraProjectionMatrix(camera);\n\n if (this.passNeedsReassembly || this.lastRenderCamera !== camera) {\n this.renderPipeline.outputNode = this.assembleRenderPasses(scene, camera);\n this.renderPipeline.needsUpdate = true;\n this.passNeedsReassembly = false;\n this.lastRenderCamera = camera;\n }\n\n if (this.freezeFrames > 0) {\n this.freezeFrames--;\n this.renderToFreezeTarget();\n return;\n }\n\n if (this.voxelsNeedUpdate && !this.isDragInProgress) {\n this.voxelsNeedUpdate = false;\n this.getVxgiPassOrUndefined()?.revoxelize();\n }\n\n this.renderPipeline.render();\n\n this.qualityManager.manageQualitySettings(\n this._initData.webGpuConfig.autoQualityMinFps,\n this._initData.webGpuConfig.autoQualityMaxFps,\n );\n }\n\n // Keep rendering so the rebuilt pipeline compiles and warms up, but redirect\n // the output to an off-screen target so the canvas keeps showing the last\n // good frame instead of black flickering while the pipeline rebuilds.\n private renderToFreezeTarget(): void {\n const previousRenderTarget = this.renderer.getRenderTarget();\n this.renderer.setRenderTarget(this.freezeRenderTarget);\n this.renderPipeline.render();\n this.renderer.setRenderTarget(previousRenderTarget);\n }\n\n private updateCameraProjectionMatrix(camera: Camera): void {\n if (\n camera instanceof OrthographicCamera ||\n camera instanceof PerspectiveCamera\n ) {\n camera.updateProjectionMatrix();\n }\n }\n\n private assembleRenderPasses(scene: Scene, camera: Camera): Node<'vec4'> {\n const passNode = pass(scene, camera); // always include the scene pass\n let result: Node<'vec4'> = passNode;\n\n this.setupMRT(passNode);\n\n for (const passId of RENDER_PASS_ORDER) {\n const renderPass = this.renderPasses.get(passId);\n if (!renderPass) {\n continue;\n }\n result = renderPass.assemble(\n passNode,\n result,\n scene,\n camera,\n this.debugMode,\n );\n }\n\n return this.debugRenderPass.assemble(\n passNode,\n result,\n scene,\n camera,\n this.debugMode,\n );\n }\n\n private setupMRT(passNode: PassNode): void {\n if (this.getSsgiPassOrUndefined()) {\n passNode.setMRT(\n mrt({\n output: output,\n diffuseColor: diffuseColor,\n normal: packNormalToRGB(normalView),\n velocity: velocity,\n }),\n );\n } else if (this.getVxgiPassOrUndefined()) {\n passNode.setMRT(\n mrt({\n output: output,\n velocity: velocity,\n }),\n );\n }\n }\n\n public override setCustomOutlineParameters(\n customOutlineParameters: OutlineCustomParameters,\n ): void {\n const outlinePass = this.getOutlinePassOrUndefined();\n if (outlinePass) {\n outlinePass.setOutlineColors(\n customOutlineParameters.outlineVisibleEdgeColor,\n customOutlineParameters.outlineHiddenEdgeColor,\n );\n }\n }\n\n public override setGroundShadow(enabled: boolean, _scene: Scene): void {\n if (!this.isConfiguratorMode) {\n return; // only ever show the ground shadow floor in the configurator\n }\n\n this._webGpuGroundShadowReflection.setReceiveShadow(enabled);\n }\n\n private enableOutline(\n visibleEdgeColor: ColorRepresentation,\n hiddenEdgeColor: ColorRepresentation,\n ): void {\n if (this.getOutlinePassOrUndefined()) {\n return;\n }\n\n this.addRenderPass(\n new OutlineRenderPass({\n selectedObjects: [],\n visibleEdgeColor: visibleEdgeColor,\n hiddenEdgeColor: hiddenEdgeColor,\n edgeStrength: 3.0,\n edgeGlow: 0.0,\n edgeThickness: 1.0,\n }),\n );\n }\n\n private getOutlinePassOrUndefined(): OutlineRenderPass | undefined {\n const pass = this.renderPasses.get(OutlineRenderPass.passId);\n if (pass && pass instanceof OutlineRenderPass) {\n return pass;\n }\n return undefined;\n }\n\n private enableGiPass(useTemporalFiltering: boolean): void {\n if (this.giMode === WEBGPU_GI_MODES.SSGI) {\n this.enableSsgiPass(useTemporalFiltering);\n } else {\n this.enableVxgiPass(useTemporalFiltering);\n }\n }\n\n private switchGiMode(giMode: WebGpuGiMode): void {\n if (giMode === this.giMode) {\n return;\n }\n\n const useTemporalFiltering =\n this.renderPasses.get(TraaRenderPass.passId) !== undefined;\n this.renderPasses.delete(SsgiRenderPass.passId);\n this.renderPasses.delete(VxgiRenderPass.passId);\n this.giMode = giMode;\n this.enableGiPass(useTemporalFiltering);\n this.qualityManager.applyCurrentQualityLevel(0);\n }\n\n private enableSsgiPass(useTemporalFiltering: boolean) {\n if (this.renderPasses.get(SsgiRenderPass.passId)) {\n return;\n }\n\n const ssgiConfig = this._initData.webGpuConfig.ssgi;\n\n this.addRenderPass(\n new SsgiRenderPass({\n sliceCount: 2,\n stepCount: 12,\n radius: 8,\n expFactor: 2,\n thickness: 1,\n backfaceLighting: 0,\n aoIntensity: 0.6,\n giIntensity: 4,\n aoDenoiseRadius: ssgiConfig.aoDenoiseRadius,\n giDenoiseRadius: ssgiConfig.giDenoiseRadius,\n useLinearThickness: false,\n useScreenSpaceSampling: true,\n useTemporalFiltering,\n }),\n );\n }\n\n private enableVxgiPass(useTemporalFiltering: boolean) {\n if (this.getVxgiPassOrUndefined()) {\n return;\n }\n\n this.addRenderPass(\n new VxgiRenderPass({\n coneCount: 3,\n coneAngle: 40,\n volumeStepScale: 0.5,\n volumeMaxDistance: 0,\n normalOffset: 1.5,\n aoIntensity: 0.4,\n giIntensity: 1,\n bounces: 1,\n directionalRadiance: false,\n useTemporalFiltering,\n vxgiResolution: 128,\n }),\n );\n }\n\n private enableTraaPass() {\n if (this.renderPasses.get(TraaRenderPass.passId)) {\n return;\n }\n\n this.addRenderPass(new TraaRenderPass());\n }\n\n private enableFogPass() {\n if (this.renderPasses.get(FogRenderPass.passId)) {\n return;\n }\n\n const fogConfig = this._initData.webGpuConfig.fog;\n this.addRenderPass(\n new FogRenderPass({\n color: getColor(\n fogConfig.color ?? this._initData.colors.DEFAULT_BACKGROUND,\n ),\n nearBlend: fogConfig.nearBlend,\n farBlend: fogConfig.farBlend,\n }),\n );\n }\n\n private disableFogPass() {\n const fogRenderPass = this.renderPasses.get(FogRenderPass.passId);\n if (!fogRenderPass || !(fogRenderPass instanceof FogRenderPass)) {\n return;\n }\n fogRenderPass.removeSceneFog();\n this.renderPasses.delete(FogRenderPass.passId);\n }\n\n private applyQualityParameters(\n qualityParameters: WebGPUQualityParameters,\n freezeFrames: number,\n ): void {\n this.freezeFrames = Math.max(freezeFrames, this.freezeFrames);\n\n this.applyPixelRatio(qualityParameters);\n\n this.getSsgiPassOrUndefined()?.updatePerformanceParameters(\n qualityParameters.ssgiPerformanceParameters,\n );\n this.getVxgiPassOrUndefined()?.updatePerformanceParameters(\n qualityParameters.vxgiPerformanceParameters,\n );\n this.passNeedsReassembly = true;\n }\n\n private applyPixelRatio(qualityParameters: WebGPUQualityParameters) {\n const devicePixelRatio = Math.min(\n window?.devicePixelRatio ?? 1,\n qualityParameters.maxDevicePixelRatio,\n );\n const pixelRatioMultiplier = Math.min(\n this._initData.webGpuConfig.pixelRatioMultiplier,\n qualityParameters.maxPixelRatioMultiplier,\n );\n this.renderer.setPixelRatio(pixelRatioMultiplier * devicePixelRatio);\n }\n\n private getSsgiPassOrUndefined(): SsgiRenderPass | undefined {\n const pass = this.renderPasses.get(SsgiRenderPass.passId);\n if (pass && pass instanceof SsgiRenderPass) {\n return pass;\n }\n return undefined;\n }\n\n private getVxgiPassOrUndefined(): VxgiRenderPass | undefined {\n const pass = this.renderPasses.get(VxgiRenderPass.passId);\n if (pass && pass instanceof VxgiRenderPass) {\n return pass;\n }\n return undefined;\n }\n\n public override setShadingType(shadingType: SceneShadingType): void {\n if (shadingType === SCENE_SHADING_TYPES.DEFAULT) {\n return;\n }\n // if bright scene shading is actually used anywhere\n // it can be implemented but will skip for now for webgpu\n console.error('RoomleWebGPURenderer.setShadingType is not implemented yet');\n }\n\n public override showGUI(updateCallback: () => void): void {\n if (this.renderer.inspector instanceof Inspector) {\n return;\n }\n const guiStyle = document.createElement('style');\n guiStyle.innerText =\n '.profiler-toggle,\\n' +\n ' .profiler-mini-panel {\\n' +\n ' left: 15px;\\n' + // webgpu gui should be top left not top right\n ' right: auto !important;\\n' +\n ' }';\n document.head.appendChild(guiStyle);\n\n const inspector = new Inspector();\n this.renderer.inspector = inspector;\n this._domHelper.element?.appendChild(inspector.domElement);\n\n this.addDebugGUI(inspector, updateCallback);\n this.qualityManager.addGUI(inspector, updateCallback);\n\n const renderPassSettings = inspector.createParameters(\n 'Render Pass Settings',\n );\n for (const renderPass of this.renderPasses.values()) {\n renderPass.addParametersToGUI(renderPassSettings, updateCallback);\n }\n this._webGpuGroundShadowReflection.addParametersToGUI(\n renderPassSettings,\n updateCallback,\n );\n this._webGpuSkyContainer.addParametersToGUI(\n renderPassSettings,\n updateCallback,\n );\n this.addToneMappingSettings(renderPassSettings, updateCallback);\n }\n\n private addDebugGUI(inspector: Inspector, updateCallback: () => void): void {\n const debugSettings = inspector.createParameters('Debug Settings');\n const params = { debugMode: this.debugMode };\n debugSettings\n .add(params, 'debugMode', {\n Off: 'off',\n Outline: 'outline',\n Direct: 'direct lighting only',\n Ao: 'ao only',\n Gi: 'gi only',\n DenoisedAo: 'denoised ao only',\n DenoisedGi: 'denoised gi only',\n WithoutDenoise: 'without denoise',\n NoFog: 'no fog',\n Depth: 'depth',\n Velocity: 'velocity',\n } satisfies Record<string, WebGPUDebugMode>)\n .onChange((mode: WebGPUDebugMode) => {\n this.debugMode = mode;\n this.passNeedsReassembly = true;\n updateCallback();\n });\n\n if (\n this.renderPasses.get(SsgiRenderPass.passId) ||\n this.renderPasses.get(VxgiRenderPass.passId)\n ) {\n const giModeParams = { giMode: this.giMode };\n debugSettings\n .add(giModeParams, 'giMode', {\n Vxgi: WEBGPU_GI_MODES.VXGI,\n Ssgi: WEBGPU_GI_MODES.SSGI,\n } satisfies Record<string, WebGpuGiMode>)\n .onChange((giMode: WebGpuGiMode) => {\n this.switchGiMode(giMode);\n updateCallback();\n });\n }\n\n const reassembleButton = {\n reassembleRenderPasses: () => {\n this.passNeedsReassembly = true;\n console.log('Reassembling render passes...');\n updateCallback();\n },\n };\n\n debugSettings.add(reassembleButton, 'reassembleRenderPasses');\n }\n\n private applyToneMappingConfig(): void {\n const { toneMapping, toneMappingExposure } = this._initData.webGpuConfig;\n this.renderer.toneMapping = TONE_MAPPING_BY_CONFIG_VALUE[toneMapping];\n this.renderer.toneMappingExposure = toneMappingExposure;\n }\n\n private addToneMappingSettings(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const toneMappingSettings = renderPassSettings.addFolder('Tone Mapping');\n const params = {\n toneMapping: this.renderer.toneMapping,\n toneMappingExposure: this.renderer.toneMappingExposure,\n };\n\n toneMappingSettings\n .add(params, 'toneMapping', {\n None: NoToneMapping,\n Linear: LinearToneMapping,\n Reinhard: ReinhardToneMapping,\n Cineon: CineonToneMapping,\n ACESFilmic: ACESFilmicToneMapping,\n AgX: AgXToneMapping,\n Neutral: NeutralToneMapping,\n })\n .onChange((value: ToneMapping) => {\n this.renderer.toneMapping = value;\n this.passNeedsReassembly = true;\n updateCallback();\n });\n\n toneMappingSettings\n .add(params, 'toneMappingExposure', 0, 3, 0.01)\n .onChange((value: number) => {\n this.renderer.toneMappingExposure = value;\n this.passNeedsReassembly = true;\n updateCallback();\n });\n }\n\n public getOrCreateGUIParameters(name: string): ParametersGroup {\n const inspector = this.renderer.inspector;\n if (inspector instanceof Inspector) {\n return (\n this.guiParameterGroups.get(name) ??\n this.createAndCacheGUIParameters(inspector, name)\n );\n }\n throw new Error(\n 'Inspector GUI is not initialized. Call showGUI() before creating parameter groups.',\n );\n }\n\n private createAndCacheGUIParameters(\n inspector: Inspector,\n name: string,\n ): ParametersGroup {\n const parameters = inspector.createParameters(name);\n this.guiParameterGroups.set(name, parameters);\n return parameters;\n }\n}\n"],"x_google_ignoreList":[0,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,24,25,31,32,33,34],"mappings":";;;;;;;;;;AAGA,IAAMA,oBAA0B,IAAI,IAAU,EACxCC,qBAAsB,IAAI,GAAS,EACnC,qBAAkC,IAAI,EAAS,GAAK,EAAK,EACzD,qBAAkC,IAAI,EAAS,GAAK,EAAK,EAE3DC,IAoCE,KAAN,cAA0B,GAAK;CAE9B,WAAW,OAAO;AAEjB,SAAO;;CAeR,YAAa,GAAO,GAAQ,IAAS,EAAE,EAAG;AAEzC,QAAO,OAAQ;EAEf,IAAM,EACL,qBAAkB,EAAE,EACpB,mBAAgB,EAAO,EAAG,EAC1B,cAAW,EAAO,EAAG,EACrB,qBAAkB,MACf;AAmWJ,EA5VA,KAAK,QAAQ,GAOb,K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AAA;GACA,YAAA;GACA,KAAA;GACA,SAAA;GACD,CAAC,CACD,UAAU,MAAuB;AAGhC,GAFA,KAAK,SAAS,cAAc,GAC5B,KAAK,sBAAsB,IAC3B,GAAgB;IAChB,EAEJ,EACG,IAAI,GAAQ,uBAAuB,GAAG,GAAG,IAAK,CAC9C,UAAU,MAAkB;AAG3B,GAFA,KAAK,SAAS,sBAAsB,GACpC,KAAK,sBAAsB,IAC3B,GAAgB;IAChB;;CAGN,yBAAgC,GAA+B;EAC7D,IAAM,IAAY,KAAK,SAAS;AAChC,MAAI,aAAqB,GACvB,QACE,KAAK,mBAAmB,IAAI,EAAK,IACjC,KAAK,4BAA4B,GAAW,EAAK;AAGrD,QAAU,MACR,qFACD;;CAGH,4BACE,GACA,GACiB;EACjB,IAAM,IAAa,EAAU,iBAAiB,EAAK;AAEnD,SADA,KAAK,mBAAmB,IAAI,GAAM,EAAW,EACtC;;;IAtlBR,IAAA,GAAA,eAAA,OAAA,CAAA,EAAA,GAAA,WAAA,cAAA,KAAA,EAAA,MAGA,IAAA,GAAA,eAAA,OAAA,CAAA,EAAA,GAAA,WAAA,iCAAA,KAAA,EAAA,MAGA,IAAA,GAAA,eAAA,OAAA,CAAA,EAAA,GAAA,WAAA,uBAAA,KAAA,EAAA,MAGA,IAAA,GAAA,eAAA,OAAA,CAAA,EAAA,GAAA,WAAA,oBAAA,KAAA,EAAA,MAGA,IAAA,GAAA,eAAA,OAAA,CAAA,EAAA,GAAA,WAAA,aAAA,KAAA,EAAA"}
1
+ {"version":3,"file":"roomle-webgpu-renderer-D43bHxhT.mjs","names":["_quadMesh","_size","_rendererState","uv","_size","_quadMesh","_size","_rendererState","uv","uv","_quadMesh","_size","_rendererState","uv","_box","_size","_rendererState","uv"],"sources":["../../../../node_modules/three/examples/jsm/tsl/display/OutlineNode.js","../../packages/common-core/src/webgpu/passes/roomle-webgpu-render-pass.ts","../../packages/common-core/src/webgpu/passes/outline-render-pass.ts","../../../../node_modules/three/examples/jsm/inspector/RendererInspector.js","../../../../node_modules/three/examples/jsm/inspector/ui/Style.js","../../../../node_modules/three/examples/jsm/inspector/ui/Graph.js","../../../../node_modules/three/examples/jsm/inspector/Storage.js","../../../../node_modules/three/examples/jsm/inspector/ui/Profiler.js","../../../../node_modules/three/examples/jsm/inspector/ui/Tab.js","../../../../node_modules/three/examples/jsm/inspector/ui/List.js","../../../../node_modules/three/examples/jsm/inspector/ui/Item.js","../../../../node_modules/three/examples/jsm/inspector/ui/utils.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Performance.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Memory.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Console.js","../../../../node_modules/three/examples/jsm/inspector/ui/Values.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Parameters.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Settings.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Viewer.js","../../../../node_modules/three/examples/jsm/inspector/tabs/Timeline.js","../../../../node_modules/three/examples/jsm/inspector/Inspector.js","../../../../node_modules/three/examples/jsm/tsl/display/SSGINode.js","../../../../node_modules/three/examples/jsm/tsl/display/DenoiseNode.js","../../packages/common-core/src/webgpu/passes/ssgi-render-pass.ts","../../../../node_modules/three/examples/jsm/tsl/utils/TAAUtils.js","../../../../node_modules/three/examples/jsm/tsl/display/TRAANode.js","../../packages/common-core/src/webgpu/passes/traa-render-pass.ts","../../packages/common-core/src/webgpu/roomle-webgpu-renderer-quality-levels.ts","../../packages/common-core/src/webgpu/roomle-webgpu-quality-manager.ts","../../packages/common-core/src/webgpu/passes/fog-render-pass.ts","../../packages/common-core/src/webgpu/passes/debug-render-pass.ts","../../../../node_modules/three/examples/jsm/lighting/vxgi/VXGISceneCollector.js","../../../../node_modules/three/examples/jsm/lighting/vxgi/VXGIConeTracer.js","../../../../node_modules/three/examples/jsm/lighting/vxgi/VXGIVolume.js","../../../../node_modules/three/examples/jsm/lighting/vxgi/VXGINode.js","../../packages/common-core/src/webgpu/passes/vxgi-render-pass.ts","../../packages/common-core/src/webgpu/roomle-webgpu-renderer.ts"],"sourcesContent":["import { DepthTexture, FloatType, RenderTarget, Vector2, Node, QuadMesh, NodeMaterial, SpriteNodeMaterial, RendererUtils, NodeUpdateType } from 'three/webgpu';\nimport { Loop, int, exp, min, float, mul, uv, vec2, vec3, Fn, textureSize, orthographicDepthToViewZ, screenUV, nodeObject, uniform, vec4, passTexture, texture, perspectiveDepthToViewZ, positionView, reference, color } from 'three/tsl';\n\nconst _quadMesh = /*@__PURE__*/ new QuadMesh();\nconst _size = /*@__PURE__*/ new Vector2();\nconst _BLUR_DIRECTION_X = /*@__PURE__*/ new Vector2( 1.0, 0.0 );\nconst _BLUR_DIRECTION_Y = /*@__PURE__*/ new Vector2( 0.0, 1.0 );\n\nlet _rendererState;\n\n/**\n * Post processing node for rendering outlines around selected objects. The node\n * gives you great flexibility in composing the final outline look depending on\n * your requirements.\n * ```js\n * const renderPipeline = new THREE.RenderPipeline( renderer );\n *\n * const scenePass = pass( scene, camera );\n *\n * // outline parameter\n *\n * const edgeStrength = uniform( 3.0 );\n * const edgeGlow = uniform( 0.0 );\n * const edgeThickness = uniform( 1.0 );\n * const visibleEdgeColor = uniform( new THREE.Color( 0xffffff ) );\n * const hiddenEdgeColor = uniform( new THREE.Color( 0x4e3636 ) );\n *\n * outlinePass = outline( scene, camera, {\n * \tselectedObjects,\n * \tedgeGlow,\n * \tedgeThickness\n * } );\n *\n * // compose custom outline\n *\n * const { visibleEdge, hiddenEdge } = outlinePass;\n * const outlineColor = visibleEdge.mul( visibleEdgeColor ).add( hiddenEdge.mul( hiddenEdgeColor ) ).mul( edgeStrength );\n *\n * renderPipeline.outputNode = outlineColor.add( scenePass );\n * ```\n *\n * @augments Node\n * @three_import import { outline } from 'three/addons/tsl/display/OutlineNode.js';\n */\nclass OutlineNode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'OutlineNode';\n\n\t}\n\n\t/**\n\t * Constructs a new outline node.\n\t *\n\t * @param {Scene} scene - A reference to the scene.\n\t * @param {Camera} camera - The camera the scene is rendered with.\n\t * @param {Object} params - The configuration parameters.\n\t * @param {Array<Object3D>} [params.selectedObjects] - An array of selected objects.\n\t * @param {Node<float>} [params.edgeThickness=float(1)] - The thickness of the edges.\n\t * @param {Node<float>} [params.edgeGlow=float(0)] - Can be used for an animated glow/pulse effects.\n\t * @param {number} [params.downSampleRatio=2] - The downsample ratio.\n\t */\n\tconstructor( scene, camera, params = {} ) {\n\n\t\tsuper( 'vec4' );\n\n\t\tconst {\n\t\t\tselectedObjects = [],\n\t\t\tedgeThickness = float( 1 ),\n\t\t\tedgeGlow = float( 0 ),\n\t\t\tdownSampleRatio = 2\n\t\t} = params;\n\n\t\t/**\n\t\t * A reference to the scene.\n\t\t *\n\t\t * @type {Scene}\n\t\t */\n\t\tthis.scene = scene;\n\n\t\t/**\n\t\t * The camera the scene is rendered with.\n\t\t *\n\t\t * @type {Camera}\n\t\t */\n\t\tthis.camera = camera;\n\n\t\t/**\n\t\t * An array of selected objects.\n\t\t *\n\t\t * @type {Array<Object3D>}\n\t\t */\n\t\tthis.selectedObjects = selectedObjects;\n\n\t\t/**\n\t\t * The thickness of the edges.\n\t\t *\n\t\t * @type {Node<float>}\n\t\t */\n\t\tthis.edgeThicknessNode = nodeObject( edgeThickness );\n\n\t\t/**\n\t\t * Can be used for an animated glow/pulse effect.\n\t\t *\n\t\t * @type {Node<float>}\n\t\t */\n\t\tthis.edgeGlowNode = nodeObject( edgeGlow );\n\n\t\t/**\n\t\t * The downsample ratio.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 2\n\t\t */\n\t\tthis.downSampleRatio = downSampleRatio;\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders\n\t\t * its effect once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t// render targets\n\n\t\t/**\n\t\t * The render target for the depth pre-pass.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetDepthBuffer = new RenderTarget();\n\t\tthis._renderTargetDepthBuffer.depthTexture = new DepthTexture();\n\t\tthis._renderTargetDepthBuffer.depthTexture.type = FloatType;\n\n\t\t/**\n\t\t * The render target for the mask pass.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetMaskBuffer = new RenderTarget();\n\n\t\t/**\n\t\t * The render target for the mask downsample.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetMaskDownSampleBuffer = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The first render target for the edge detection.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetEdgeBuffer1 = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The second render target for the edge detection.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetEdgeBuffer2 = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The first render target for the blur pass.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetBlurBuffer1 = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The second render target for the blur pass.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetBlurBuffer2 = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t/**\n\t\t * The render target for the final composite.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTargetComposite = new RenderTarget( 1, 1, { depthBuffer: false } );\n\n\t\t// uniforms\n\n\t\t/**\n\t\t * Represents the near value of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {ReferenceNode<float>}\n\t\t */\n\t\tthis._cameraNear = reference( 'near', 'float', camera );\n\n\t\t/**\n\t\t * Represents the far value of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {ReferenceNode<float>}\n\t\t */\n\t\tthis._cameraFar = reference( 'far', 'float', camera );\n\n\t\t/**\n\t\t * Uniform that represents the blur direction of the pass.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._blurDirection = uniform( new Vector2() );\n\n\t\t/**\n\t\t * Texture node that holds the data from the depth pre-pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._depthTextureUniform = texture( this._renderTargetDepthBuffer.depthTexture );\n\n\t\t/**\n\t\t * Texture node that holds the data from the mask pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._maskTextureUniform = texture( this._renderTargetMaskBuffer.texture );\n\n\t\t/**\n\t\t * Texture node that holds the data from the mask downsample pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._maskTextureDownsSampleUniform = texture( this._renderTargetMaskDownSampleBuffer.texture );\n\n\t\t/**\n\t\t * Texture node that holds the data from the first edge detection pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._edge1TextureUniform = texture( this._renderTargetEdgeBuffer1.texture );\n\n\t\t/**\n\t\t * Texture node that holds the data from the second edge detection pass.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._edge2TextureUniform = texture( this._renderTargetEdgeBuffer2.texture );\n\n\t\t/**\n\t\t * Texture node that holds the current blurred color data.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._blurColorTextureUniform = texture( this._renderTargetEdgeBuffer1.texture );\n\n\t\t// constants\n\n\t\t/**\n\t\t * Visible edge color.\n\t\t *\n\t\t * @private\n\t\t * @type {Node<vec3>}\n\t\t */\n\t\tthis._visibleEdgeColor = vec3( 1, 0, 0 );\n\n\t\t/**\n\t\t * Hidden edge color.\n\t\t *\n\t\t * @private\n\t\t * @type {Node<vec3>}\n\t\t */\n\t\tthis._hiddenEdgeColor = vec3( 0, 1, 0 );\n\n\t\t// materials\n\n\t\t/**\n\t\t * The material for the depth pre-pass.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._depthMaterial = new NodeMaterial();\n\t\tthis._depthMaterial.colorNode = color( 0, 0, 0 );\n\t\tthis._depthMaterial.name = 'OutlineNode.depth';\n\n\t\tthis._depthSpriteMaterial = new SpriteNodeMaterial();\n\t\tthis._depthSpriteMaterial.colorNode = color( 0, 0, 0 );\n\t\tthis._depthSpriteMaterial.name = 'OutlineNode.depthSprite';\n\n\t\t/**\n\t\t * The material for preparing the mask.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._prepareMaskMaterial = new NodeMaterial();\n\t\tthis._prepareMaskMaterial.name = 'OutlineNode.prepareMask';\n\n\t\tthis._prepareMaskSpriteMaterial = new SpriteNodeMaterial();\n\t\tthis._prepareMaskSpriteMaterial.name = 'OutlineNode.prepareMaskSprite';\n\n\t\t/**\n\t\t * The copy material\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._materialCopy = new NodeMaterial();\n\t\tthis._materialCopy.name = 'OutlineNode.copy';\n\n\t\t/**\n\t\t * The edge detection material.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._edgeDetectionMaterial = new NodeMaterial();\n\t\tthis._edgeDetectionMaterial.name = 'OutlineNode.edgeDetection';\n\n\t\t/**\n\t\t * The material that is used to render in the blur pass.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._separableBlurMaterial = new NodeMaterial();\n\t\tthis._separableBlurMaterial.name = 'OutlineNode.separableBlur';\n\n\t\t/**\n\t\t * The material that is used to render in the blur pass.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._separableBlurMaterial2 = new NodeMaterial();\n\t\tthis._separableBlurMaterial2.name = 'OutlineNode.separableBlur2';\n\n\t\t/**\n\t\t * The final composite material.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._compositeMaterial = new NodeMaterial();\n\t\tthis._compositeMaterial.name = 'OutlineNode.composite';\n\n\t\t/**\n\t\t * An internal cache for depth materials.\n\t\t *\n\t\t * @private\n\t\t * @type {Map<Material, NodeMaterial>}\n\t\t */\n\t\tthis._depthMaterialCache = new Map();\n\n\t\t/**\n\t\t * An internal cache for mask materials.\n\t\t *\n\t\t * @private\n\t\t * @type {Map<Material, NodeMaterial>}\n\t\t */\n\t\tthis._prepareMaskMaterialCache = new Map();\n\n\t\t/**\n\t\t * Disposes the pass materials of a disposed material.\n\t\t *\n\t\t * @private\n\t\t * @type {Function}\n\t\t */\n\t\tthis._onMaterialDispose = ( event ) => {\n\n\t\t\tconst originalMaterial = event.target;\n\n\t\t\toriginalMaterial.removeEventListener( 'dispose', this._onMaterialDispose );\n\n\t\t\tfor ( const cache of [ this._depthMaterialCache, this._prepareMaskMaterialCache ] ) {\n\n\t\t\t\tconst passMaterial = cache.get( originalMaterial );\n\n\t\t\t\tif ( passMaterial !== undefined ) {\n\n\t\t\t\t\tpassMaterial.dispose();\n\t\t\t\t\tcache.delete( originalMaterial );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\t/**\n\t\t * A set to cache selected objects in the scene.\n\t\t *\n\t\t * @private\n\t\t * @type {Set<Object3D>}\n\t\t */\n\t\tthis._selectionCache = new Set();\n\n\t\t/**\n\t\t * The number of selected objects from the previous frame. Used to detect\n\t\t * the transition to an empty selection so the composite render target can\n\t\t * be cleared once and avoid leaving a stale outline on screen.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._lastSelectionCount = 0;\n\n\t\t/**\n\t\t * The result of the effect is represented as a separate texture node.\n\t\t *\n\t\t * @private\n\t\t * @type {PassTextureNode}\n\t\t */\n\t\tthis._textureNode = passTexture( this, this._renderTargetComposite.texture );\n\n\t}\n\n\t/**\n\t * A mask value that represents the visible edge.\n\t *\n\t * @return {Node<float>} The visible edge.\n\t */\n\tget visibleEdge() {\n\n\t\treturn this.r;\n\n\t}\n\n\t/**\n\t * A mask value that represents the hidden edge.\n\t *\n\t * @return {Node<float>} The hidden edge.\n\t */\n\tget hiddenEdge() {\n\n\t\treturn this.g;\n\n\t}\n\n\t/**\n\t * Returns the result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the result of the effect.\n\t */\n\tgetTextureNode() {\n\n\t\treturn this._textureNode;\n\n\t}\n\n\t/**\n\t * Sets the size of the effect.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetSize( width, height ) {\n\n\t\tthis._renderTargetDepthBuffer.setSize( width, height );\n\t\tthis._renderTargetMaskBuffer.setSize( width, height );\n\t\tthis._renderTargetComposite.setSize( width, height );\n\n\t\t// downsample 1\n\n\t\tlet resx = Math.round( width / this.downSampleRatio );\n\t\tlet resy = Math.round( height / this.downSampleRatio );\n\n\t\tthis._renderTargetMaskDownSampleBuffer.setSize( resx, resy );\n\t\tthis._renderTargetEdgeBuffer1.setSize( resx, resy );\n\t\tthis._renderTargetBlurBuffer1.setSize( resx, resy );\n\n\t\t// downsample 2\n\n\t\tresx = Math.round( resx / 2 );\n\t\tresy = Math.round( resy / 2 );\n\n\t\tthis._renderTargetEdgeBuffer2.setSize( resx, resy );\n\t\tthis._renderTargetBlurBuffer2.setSize( resx, resy );\n\n\t}\n\n\t/**\n\t * This method is used to render the effect once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore( frame ) {\n\n\t\tconst { renderer } = frame;\n\t\tconst { camera, scene } = this;\n\n\t\tthis._updateSelectionCache();\n\n\t\t// If no objects are selected, all subsequent passes can be skipped since\n\t\t// the outline would be empty anyway. The composite render target is cleared\n\t\t// once when transitioning to an empty selection so a previously rendered\n\t\t// outline does not linger on screen.\n\n\t\tif ( this._selectionCache.size === 0 ) {\n\n\t\t\tif ( this._lastSelectionCount > 0 ) {\n\n\t\t\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t\t\trenderer.setRenderTarget( this._renderTargetComposite );\n\t\t\t\trenderer.setClearColor( 0x000000, 0 );\n\t\t\t\trenderer.clear();\n\n\t\t\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t\t\t\tthis._lastSelectionCount = 0;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tthis._lastSelectionCount = this._selectionCache.size;\n\n\t\t_rendererState = RendererUtils.resetRendererAndSceneState( renderer, scene, _rendererState );\n\n\t\t//\n\n\t\tconst size = renderer.getDrawingBufferSize( _size );\n\t\tthis.setSize( size.width, size.height );\n\n\t\t//\n\n\t\trenderer.setClearColor( 0xffffff, 1 );\n\n\t\tconst currentSceneName = scene.name;\n\n\t\t// 1. Draw non-selected objects in the depth buffer\n\n\t\trenderer.setRenderTarget( this._renderTargetDepthBuffer );\n\t\trenderer.setRenderObjectFunction( ( object, scene, camera, geometry, material, group, lightsNode, clippingContext ) => {\n\n\t\t\tif ( this._selectionCache.has( object ) === false ) {\n\n\t\t\t\tconst baseMaterial = object.isSprite ? this._depthSpriteMaterial : this._depthMaterial;\n\t\t\t\tconst overrideMaterial = this._getPassMaterial( this._depthMaterialCache, baseMaterial, material );\n\n\t\t\t\trenderer.renderObject( object, scene, camera, geometry, overrideMaterial, group, lightsNode, clippingContext );\n\n\t\t\t}\n\n\t\t} );\n\n\t\tscene.name = 'Outline [ Non-Selected Objects Pass ]';\n\t\trenderer.render( scene, camera );\n\n\t\t// 2. Draw only the selected objects by comparing the depth buffer of non-selected objects\n\n\t\trenderer.setRenderTarget( this._renderTargetMaskBuffer );\n\t\trenderer.setRenderObjectFunction( ( object, scene, camera, geometry, material, group, lightsNode, clippingContext ) => {\n\n\t\t\tif ( this._selectionCache.has( object ) === true ) {\n\n\t\t\t\tconst baseMaterial = object.isSprite ? this._prepareMaskSpriteMaterial : this._prepareMaskMaterial;\n\t\t\t\tconst overrideMaterial = this._getPassMaterial( this._prepareMaskMaterialCache, baseMaterial, material );\n\n\t\t\t\trenderer.renderObject( object, scene, camera, geometry, overrideMaterial, group, lightsNode, clippingContext );\n\n\t\t\t}\n\n\t\t} );\n\n\t\tscene.name = 'Outline [ Selected Objects Pass ]';\n\t\trenderer.render( scene, camera );\n\n\t\t//\n\n\t\trenderer.setRenderObjectFunction( _rendererState.renderObjectFunction );\n\n\t\tthis._selectionCache.clear();\n\n\t\tscene.name = currentSceneName;\n\n\t\t// 3. Downsample to (at least) half resolution\n\n\t\t_quadMesh.material = this._materialCopy;\n\t\t_quadMesh.name = 'Outline [ Downsample ]';\n\t\trenderer.setRenderTarget( this._renderTargetMaskDownSampleBuffer );\n\t\t_quadMesh.render( renderer );\n\n\t\t// 4. Perform edge detection (half resolution)\n\n\t\t_quadMesh.material = this._edgeDetectionMaterial;\n\t\t_quadMesh.name = 'Outline [ Edge Detection ]';\n\t\trenderer.setRenderTarget( this._renderTargetEdgeBuffer1 );\n\t\t_quadMesh.render( renderer );\n\n\t\t// 5. Apply blur (half resolution)\n\n\t\tthis._blurColorTextureUniform.value = this._renderTargetEdgeBuffer1.texture;\n\t\tthis._blurDirection.value.copy( _BLUR_DIRECTION_X );\n\n\t\t_quadMesh.material = this._separableBlurMaterial;\n\t\t_quadMesh.name = 'Outline [ Blur Half Resolution ]';\n\t\trenderer.setRenderTarget( this._renderTargetBlurBuffer1 );\n\t\t_quadMesh.render( renderer );\n\n\t\tthis._blurColorTextureUniform.value = this._renderTargetBlurBuffer1.texture;\n\t\tthis._blurDirection.value.copy( _BLUR_DIRECTION_Y );\n\n\t\trenderer.setRenderTarget( this._renderTargetEdgeBuffer1 );\n\t\t_quadMesh.render( renderer );\n\n\t\t// 6. Apply blur (quarter resolution)\n\n\t\tthis._blurColorTextureUniform.value = this._renderTargetEdgeBuffer1.texture;\n\t\tthis._blurDirection.value.copy( _BLUR_DIRECTION_X );\n\n\t\t_quadMesh.material = this._separableBlurMaterial2;\n\t\t_quadMesh.name = 'Outline [ Blur Quarter Resolution ]';\n\t\trenderer.setRenderTarget( this._renderTargetBlurBuffer2 );\n\t\t_quadMesh.render( renderer );\n\n\t\tthis._blurColorTextureUniform.value = this._renderTargetBlurBuffer2.texture;\n\t\tthis._blurDirection.value.copy( _BLUR_DIRECTION_Y );\n\n\t\trenderer.setRenderTarget( this._renderTargetEdgeBuffer2 );\n\t\t_quadMesh.render( renderer );\n\n\t\t// 7. Composite\n\n\t\t_quadMesh.material = this._compositeMaterial;\n\t\t_quadMesh.name = 'Outline [ Blur Quarter Resolution ]';\n\t\trenderer.setRenderTarget( this._renderTargetComposite );\n\t\t_quadMesh.render( renderer );\n\n\t\t// restore\n\n\t\tRendererUtils.restoreRendererAndSceneState( renderer, scene, _rendererState );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {PassTextureNode}\n\t */\n\tsetup() {\n\n\t\t// prepare mask material\n\n\t\tconst prepareMask = () => {\n\n\t\t\tconst depth = this._depthTextureUniform.sample( screenUV );\n\n\t\t\tlet viewZNode;\n\n\t\t\tif ( this.camera.isPerspectiveCamera ) {\n\n\t\t\t\tviewZNode = perspectiveDepthToViewZ( depth, this._cameraNear, this._cameraFar );\n\n\t\t\t} else {\n\n\t\t\t\tviewZNode = orthographicDepthToViewZ( depth, this._cameraNear, this._cameraFar );\n\n\t\t\t}\n\n\t\t\tconst depthTest = positionView.z.lessThanEqual( viewZNode ).select( 1, 0 );\n\t\t\treturn vec3( 0.0, depthTest, 1.0 );\n\n\t\t};\n\n\t\tthis._prepareMaskMaterial.colorNode = prepareMask();\n\t\tthis._prepareMaskMaterial.needsUpdate = true;\n\n\t\tthis._prepareMaskSpriteMaterial.colorNode = prepareMask();\n\t\tthis._prepareMaskSpriteMaterial.needsUpdate = true;\n\n\t\t// copy material\n\n\t\tthis._materialCopy.fragmentNode = this._maskTextureUniform;\n\t\tthis._materialCopy.needsUpdate = true;\n\n\t\t// edge detection material\n\n\t\tconst edgeDetection = Fn( () => {\n\n\t\t\tconst resolution = textureSize( this._maskTextureDownsSampleUniform );\n\t\t\tconst invSize = vec2( 1 ).div( resolution ).toVar();\n\t\t\tconst uvOffset = vec4( 1.0, 0.0, 0.0, 1.0 ).mul( vec4( invSize, invSize ) );\n\n\t\t\tconst uvNode = uv();\n\t\t\tconst c1 = this._maskTextureDownsSampleUniform.sample( uvNode.add( uvOffset.xy ) ).toVar();\n\t\t\tconst c2 = this._maskTextureDownsSampleUniform.sample( uvNode.sub( uvOffset.xy ) ).toVar();\n\t\t\tconst c3 = this._maskTextureDownsSampleUniform.sample( uvNode.add( uvOffset.yw ) ).toVar();\n\t\t\tconst c4 = this._maskTextureDownsSampleUniform.sample( uvNode.sub( uvOffset.yw ) ).toVar();\n\n\t\t\tconst diff1 = mul( c1.r.sub( c2.r ), 0.5 );\n\t\t\tconst diff2 = mul( c3.r.sub( c4.r ), 0.5 );\n\t\t\tconst d = vec2( diff1, diff2 ).length();\n\t\t\tconst a1 = min( c1.g, c2.g );\n\t\t\tconst a2 = min( c3.g, c4.g );\n\t\t\tconst visibilityFactor = min( a1, a2 );\n\t\t\tconst edgeColor = visibilityFactor.oneMinus().greaterThan( 0.001 ).select( this._visibleEdgeColor, this._hiddenEdgeColor );\n\t\t\treturn vec4( edgeColor, 1 ).mul( d );\n\n\t\t} );\n\n\t\tthis._edgeDetectionMaterial.fragmentNode = edgeDetection();\n\t\tthis._edgeDetectionMaterial.needsUpdate = true;\n\n\t\t// separable blur material\n\n\t\tconst MAX_RADIUS = 4;\n\n\t\tconst gaussianPdf = Fn( ( [ x, sigma ] ) => {\n\n\t\t\treturn float( 0.39894 ).mul( exp( float( - 0.5 ).mul( x ).mul( x ).div( sigma.mul( sigma ) ) ).div( sigma ) );\n\n\t\t} );\n\n\t\tconst separableBlur = Fn( ( [ kernelRadius ] ) => {\n\n\t\t\tconst resolution = textureSize( this._maskTextureDownsSampleUniform );\n\t\t\tconst invSize = vec2( 1 ).div( resolution ).toVar();\n\t\t\tconst uvNode = uv();\n\n\t\t\tconst sigma = kernelRadius.div( 2 ).toVar();\n\t\t\tconst weightSum = gaussianPdf( 0, sigma ).toVar();\n\t\t\tconst diffuseSum = this._blurColorTextureUniform.sample( uvNode ).mul( weightSum ).toVar();\n\t\t\tconst delta = this._blurDirection.mul( invSize ).mul( kernelRadius ).div( MAX_RADIUS ).toVar();\n\n\t\t\tconst uvOffset = delta.toVar();\n\n\t\t\tLoop( { start: int( 1 ), end: int( MAX_RADIUS ), type: 'int', condition: '<=' }, ( { i } ) => {\n\n\t\t\t\tconst x = kernelRadius.mul( float( i ) ).div( MAX_RADIUS );\n\t\t\t\tconst w = gaussianPdf( x, sigma );\n\t\t\t\tconst sample1 = this._blurColorTextureUniform.sample( uvNode.add( uvOffset ) );\n\t\t\t\tconst sample2 = this._blurColorTextureUniform.sample( uvNode.sub( uvOffset ) );\n\n\t\t\t\tdiffuseSum.addAssign( sample1.add( sample2 ).mul( w ) );\n\t\t\t\tweightSum.addAssign( w.mul( 2 ) );\n\t\t\t\tuvOffset.addAssign( delta );\n\n\t\t\t} );\n\n\t\t\treturn diffuseSum.div( weightSum );\n\n\t\t} );\n\n\t\tthis._separableBlurMaterial.fragmentNode = separableBlur( this.edgeThicknessNode );\n\t\tthis._separableBlurMaterial.needsUpdate = true;\n\n\t\tthis._separableBlurMaterial2.fragmentNode = separableBlur( MAX_RADIUS );\n\t\tthis._separableBlurMaterial2.needsUpdate = true;\n\n\t\t// composite material\n\n\t\tconst composite = Fn( () => {\n\n\t\t\tconst edgeValue1 = this._edge1TextureUniform;\n\t\t\tconst edgeValue2 = this._edge2TextureUniform;\n\t\t\tconst maskColor = this._maskTextureUniform;\n\n\t\t\tconst edgeValue = edgeValue1.add( edgeValue2.mul( this.edgeGlowNode ) );\n\n\t\t\treturn maskColor.r.mul( edgeValue );\n\n\t\t} );\n\n\t\tthis._compositeMaterial.fragmentNode = composite();\n\t\tthis._compositeMaterial.needsUpdate = true;\n\n\t\treturn this._textureNode;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis.selectedObjects.length = 0;\n\n\t\tthis._renderTargetDepthBuffer.dispose();\n\t\tthis._renderTargetMaskBuffer.dispose();\n\t\tthis._renderTargetMaskDownSampleBuffer.dispose();\n\t\tthis._renderTargetEdgeBuffer1.dispose();\n\t\tthis._renderTargetEdgeBuffer2.dispose();\n\t\tthis._renderTargetBlurBuffer1.dispose();\n\t\tthis._renderTargetBlurBuffer2.dispose();\n\t\tthis._renderTargetComposite.dispose();\n\n\t\tthis._depthMaterial.dispose();\n\t\tthis._depthSpriteMaterial.dispose();\n\t\tthis._prepareMaskMaterial.dispose();\n\t\tthis._prepareMaskSpriteMaterial.dispose();\n\t\tthis._materialCopy.dispose();\n\t\tthis._edgeDetectionMaterial.dispose();\n\t\tthis._separableBlurMaterial.dispose();\n\t\tthis._separableBlurMaterial2.dispose();\n\t\tthis._compositeMaterial.dispose();\n\n\t\tfor ( const cache of [ this._depthMaterialCache, this._prepareMaskMaterialCache ] ) {\n\n\t\t\tfor ( const [ originalMaterial, passMaterial ] of cache ) {\n\n\t\t\t\toriginalMaterial.removeEventListener( 'dispose', this._onMaterialDispose );\n\n\t\t\t\tpassMaterial.dispose();\n\n\t\t\t}\n\n\t\t\tcache.clear();\n\n\t\t}\n\n\t}\n\n\t/**\n\t * Updates the selection cache based on the selected objects.\n\t *\n\t * @private\n\t */\n\t_updateSelectionCache() {\n\n\t\tfor ( let i = 0; i < this.selectedObjects.length; i ++ ) {\n\n\t\t\tconst selectedObject = this.selectedObjects[ i ];\n\t\t\tselectedObject.traverse( ( object ) => {\n\n\t\t\t\tif ( object.isMesh || object.isSprite ) this._selectionCache.add( object );\n\n\t\t\t} );\n\n\t\t}\n\n\t}\n\n\t/**\n\t * For the given material, this method returns the corresponding pass material.\n\t *\n\t * @private\n\t * @param {Map<Material, NodeMaterial>} cache - The material cache of the pass.\n\t * @param {NodeMaterial} baseMaterial - The pass material to derive from.\n\t * @param {Material} originalMaterial - The object's material.\n\t * @return {NodeMaterial} The pass material.\n\t */\n\t_getPassMaterial( cache, baseMaterial, originalMaterial ) {\n\n\t\tif ( ! originalMaterial.positionNode ) return baseMaterial; // early out if there are no node modifications\n\n\t\tlet force = false;\n\t\tlet passMaterial = cache.get( originalMaterial );\n\n\t\t// create\n\n\t\tif ( passMaterial === undefined ) {\n\n\t\t\tpassMaterial = baseMaterial.clone();\n\n\t\t\tcache.set( originalMaterial, passMaterial );\n\n\t\t\toriginalMaterial.addEventListener( 'dispose', this._onMaterialDispose );\n\n\t\t\tforce = true;\n\n\t\t}\n\n\t\t// update\n\n\t\tif ( passMaterial.version !== originalMaterial.version || force === true ) {\n\n\t\t\tpassMaterial.positionNode = originalMaterial.positionNode || null;\n\t\t\tpassMaterial.version = originalMaterial.version;\n\n\t\t}\n\n\t\treturn passMaterial;\n\n\t}\n\n}\n\nexport default OutlineNode;\n\n/**\n * TSL function for creating an outline effect around selected objects.\n *\n * @tsl\n * @function\n * @param {Scene} scene - A reference to the scene.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @param {Object} params - The configuration parameters.\n * @param {Array<Object3D>} [params.selectedObjects] - An array of selected objects.\n * @param {Node<float>} [params.edgeThickness=float(1)] - The thickness of the edges.\n * @param {Node<float>} [params.edgeGlow=float(0)] - Can be used for animated glow/pulse effects.\n * @param {number} [params.downSampleRatio=2] - The downsample ratio.\n * @returns {OutlineNode}\n */\nexport const outline = ( scene, camera, params ) => new OutlineNode( scene, camera, params );\n","import type { Node, PassNode } from 'three/webgpu';\nimport type { Camera, Scene } from 'three';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\nexport abstract class RoomleWebGPURenderPass {\n abstract readonly passId: string;\n\n /**\n * Combines this effect with the passed basePassNode\n */\n abstract assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'>;\n\n /**\n * mutates the gui by adding the relevant pass settings to it\n */\n abstract addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void;\n}\n","import type { Camera, ColorRepresentation, Object3D, Scene } from 'three';\nimport { SRGBColorSpace } from 'three';\nimport type { Node, UniformNode, PassNode } from 'three/webgpu';\nimport { Color } from 'three';\nimport { uniform, vec4 } from 'three/tsl';\nimport { outline } from 'three/addons/tsl/display/OutlineNode.js';\nimport { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\nexport interface OutlinePassParameters {\n selectedObjects: Object3D[];\n visibleEdgeColor: ColorRepresentation;\n hiddenEdgeColor: ColorRepresentation;\n edgeStrength: number;\n edgeGlow: number;\n edgeThickness: number;\n}\n\nexport class OutlineRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'OutlineRenderPass';\n override readonly passId = OutlineRenderPass.passId;\n private readonly selectedObjects: Object3D[];\n private readonly edgeStrength: UniformNode<'float', number>;\n private readonly edgeGlow: UniformNode<'float', number>;\n private readonly edgeThickness: UniformNode<'float', number>;\n private readonly visibleEdgeColor: UniformNode<'color', Color>;\n private readonly hiddenEdgeColor: UniformNode<'color', Color>;\n\n constructor(params: OutlinePassParameters) {\n super();\n this.selectedObjects = params.selectedObjects;\n this.edgeStrength = uniform(params.edgeStrength);\n this.edgeGlow = uniform(params.edgeGlow);\n this.edgeThickness = uniform(params.edgeThickness);\n this.visibleEdgeColor = uniform(new Color(params.visibleEdgeColor));\n this.hiddenEdgeColor = uniform(new Color(params.hiddenEdgeColor));\n }\n\n public highlightObjects(selectedMeshes: Object3D[]): void {\n this.selectedObjects.splice(\n 0,\n this.selectedObjects.length,\n ...selectedMeshes,\n );\n }\n\n public setOutlineColors(\n visibleEdgeColor: ColorRepresentation,\n hiddenEdgeColor: ColorRepresentation,\n ): void {\n this.visibleEdgeColor.value = new Color(visibleEdgeColor);\n this.hiddenEdgeColor.value = new Color(hiddenEdgeColor);\n }\n\n override assemble(\n _basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n const outlinePass = outline(scene, camera, {\n selectedObjects: this.selectedObjects,\n edgeThickness: this.edgeThickness,\n edgeGlow: this.edgeGlow,\n });\n\n const { visibleEdge, hiddenEdge } = outlinePass;\n\n const finalOutline = vec4(\n visibleEdge\n .mul(this.visibleEdgeColor)\n .add(hiddenEdge.mul(this.hiddenEdgeColor))\n .mul(this.edgeStrength),\n 0,\n ).toInspector('Outline / Composite');\n\n if (debugMode === 'outline') {\n return vec4(0, 0, 0, 0).add(finalOutline);\n }\n\n return currentNode.add(finalOutline);\n }\n\n override addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const gui = renderPassSettings.addFolder('Outline Settings');\n gui\n .add(this.edgeStrength, 'value', 0.01, 10)\n .name('edgeStrength')\n .onChange(() => updateCallback());\n gui\n .add(this.edgeGlow, 'value', 0.0, 1)\n .name('edgeGlow')\n .onChange(() => updateCallback());\n gui\n .add(this.edgeThickness, 'value', 1, 4)\n .name('edgeThickness')\n .onChange(() => updateCallback());\n gui\n .addColor(\n { color: this.visibleEdgeColor.value.getHex(SRGBColorSpace) },\n 'color',\n )\n .name('visibleEdgeColor')\n .onChange((value) => {\n this.visibleEdgeColor.value.set(value);\n updateCallback();\n });\n gui\n .addColor(\n { color: this.hiddenEdgeColor.value.getHex(SRGBColorSpace) },\n 'color',\n )\n .name('hiddenEdgeColor')\n .onChange((value) => {\n this.hiddenEdgeColor.value.set(value);\n updateCallback();\n });\n }\n}\n","\nimport { InspectorBase, TimestampQuery, warnOnce, RendererUtils, MeshBasicNodeMaterial, AdditiveBlending, NoToneMapping, LinearSRGBColorSpace } from 'three/webgpu';\nimport { vec3 } from 'three/tsl';\n\nclass ObjectStats {\n\n\tconstructor( uid, name ) {\n\n\t\tthis.uid = uid;\n\t\tthis.cid = uid.match( /^(.*):f(\\d+)$/ )[ 1 ]; // call id\n\t\tthis.name = name;\n\t\tthis.timestamp = 0;\n\t\tthis.cpu = 0;\n\t\tthis.gpu = 0;\n\t\tthis.fps = 0;\n\n\t\tthis.children = [];\n\t\tthis.parent = null;\n\n\t}\n\n}\n\nclass RenderStats extends ObjectStats {\n\n\tconstructor( uid, scene, camera, renderTarget ) {\n\n\t\tlet name = scene.name;\n\n\t\tif ( name === '' ) {\n\n\t\t\tif ( scene.isScene ) {\n\n\t\t\t\tname = 'Scene';\n\n\t\t\t} else if ( scene.isQuadMesh ) {\n\n\t\t\t\tname = 'QuadMesh';\n\n\t\t\t}\n\n\t\t}\n\n\t\tsuper( uid, name );\n\n\t\tthis.scene = scene;\n\t\tthis.camera = camera;\n\t\tthis.renderTarget = renderTarget;\n\n\t\tthis.isRenderStats = true;\n\n\t}\n\n}\n\nclass ComputeStats extends ObjectStats {\n\n\tconstructor( uid, computeNode ) {\n\n\t\tconst name = computeNode.name || ( computeNode.isComputeNode ? 'Compute' : 'Compute Group' );\n\n\t\tsuper( uid, name );\n\n\t\tthis.computeNode = computeNode;\n\n\t\tthis.isComputeStats = true;\n\n\t}\n\n}\n\n// returns true if the frame of the animation loop rendered or computed\n\nfunction isRenderedFrame( frame ) {\n\n\treturn frame.renders.length > 0 || frame.computes.length > 0;\n\n}\n\nexport class RendererInspector extends InspectorBase {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.currentFrame = null;\n\t\tthis.currentContext = null;\n\t\tthis.currentRender = null;\n\t\tthis.currentCompute = null;\n\t\tthis.currentNodes = null;\n\t\tthis.lastFrame = null;\n\n\t\tthis.frames = [];\n\t\tthis.framesLib = {};\n\t\tthis.maxFrames = 512;\n\n\t\tthis._lastFinishTime = 0;\n\t\tthis._lastRenderedFinishTime = 0;\n\t\tthis._resolveTimestampPromise = null;\n\t\tthis._rAFId = null;\n\n\t\tthis.overdraw = false;\n\t\tthis._overdrawMaterial = null;\n\t\tthis._renderingOverdraw = false;\n\n\t\tthis.isRendererInspector = true;\n\n\t}\n\n\tgetParent() {\n\n\t\treturn this.currentContext || this.getFrame();\n\n\t}\n\n\tbegin() {\n\n\t\tsuper.begin();\n\n\t\tthis.currentFrame = this._createFrame();\n\t\tthis.currentContext = this.currentFrame;\n\t\tthis.currentRender = null;\n\t\tthis.currentCompute = null;\n\t\tthis.currentNodes = [];\n\n\t}\n\n\tfinish() {\n\n\t\tsuper.finish();\n\n\t\tconst now = performance.now();\n\n\t\tconst frame = this.currentFrame;\n\t\tframe.finishTime = now;\n\n\t\t// frames of the animation loop which didn't render or compute, like frames skipped by the application\n\t\t// while the GPU is busy, are not frames of the application: the time is measured since the last frame\n\t\t// which rendered\n\n\t\tif ( isRenderedFrame( frame ) ) {\n\n\t\t\tframe.deltaTime = now - ( this._lastRenderedFinishTime > 0 ? this._lastRenderedFinishTime : now );\n\n\t\t\tthis._lastRenderedFinishTime = now;\n\n\t\t} else {\n\n\t\t\tframe.deltaTime = now - ( this._lastFinishTime > 0 ? this._lastFinishTime : now );\n\n\t\t}\n\n\t\tthis.addFrame( frame );\n\n\t\tthis.fps = this._getFPS();\n\n\t\tthis.lastFrame = frame;\n\n\t\tthis.currentFrame = null;\n\t\tthis.currentContext = null;\n\t\tthis.currentRender = null;\n\t\tthis.currentCompute = null;\n\t\tthis.currentNodes = null;\n\n\t\tthis._lastFinishTime = now;\n\n\t}\n\n\t_renderOverdraw() {\n\n\t\tconst primaryPass = this.getPrimaryPass();\n\n\t\tif ( primaryPass === null ) return;\n\n\t\tconst renderer = this.getRenderer();\n\n\t\tif ( this._overdrawMaterial === null ) {\n\n\t\t\t// additive constant, so each pixel sums the depth-passing fragments it shaded\n\n\t\t\tthis._overdrawMaterial = new MeshBasicNodeMaterial( {\n\t\t\t\tcolorNode: vec3( 0.25 ),\n\t\t\t\tblending: AdditiveBlending,\n\t\t\t\tdepthTest: true,\n\t\t\t\tdepthWrite: true\n\t\t\t} );\n\n\t\t}\n\n\t\tconst { scene, camera } = primaryPass;\n\n\t\t// raw render against black with no tone mapping, so the count stays linear\n\n\t\tconst state = RendererUtils.resetRendererAndSceneState( renderer, scene );\n\n\t\trenderer.toneMapping = NoToneMapping;\n\t\trenderer.outputColorSpace = LinearSRGBColorSpace;\n\n\t\tscene.overrideMaterial = this._overdrawMaterial;\n\n\t\tthis._renderingOverdraw = true;\n\n\t\trenderer.render( scene, camera );\n\n\t\tthis._renderingOverdraw = false;\n\n\t\tRendererUtils.restoreRendererAndSceneState( renderer, scene, state );\n\n\t}\n\n\t_getFPS() {\n\n\t\t// only the frames which rendered or computed are counted, within the last second\n\n\t\tlet frameSum = 0;\n\t\tlet timeSum = 0;\n\n\t\tfor ( let i = this.frames.length - 1; i >= 0; i -- ) {\n\n\t\t\tconst frame = this.frames[ i ];\n\n\t\t\tif ( isRenderedFrame( frame ) === false ) continue;\n\n\t\t\tframeSum ++;\n\t\t\ttimeSum += frame.deltaTime;\n\n\t\t\tif ( timeSum >= 1000 ) break;\n\n\t\t}\n\n\t\treturn timeSum > 0 ? ( frameSum * 1000 ) / timeSum : 0;\n\n\t}\n\n\t_createFrame() {\n\n\t\treturn {\n\t\t\tframeId: this.nodeFrame.frameId,\n\t\t\tresolvedCompute: false,\n\t\t\tresolvedRender: false,\n\t\t\tdeltaTime: 0,\n\t\t\tstartTime: performance.now(),\n\t\t\tfinishTime: 0,\n\t\t\tmiscellaneous: 0,\n\t\t\tchildren: [],\n\t\t\trenders: [],\n\t\t\tcomputes: []\n\t\t};\n\n\t}\n\n\tgetPrimaryPass() {\n\n\t\tconst frame = this.getFrame();\n\n\t\t// first scene render of the frame; nested shadow / RTT passes come after\n\n\t\tlet primary = null;\n\n\t\tfor ( const render of frame.renders ) {\n\n\t\t\tif ( render.scene.isScene === true ) {\n\n\t\t\t\tprimary = render;\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn primary;\n\n\t}\n\n\tgetFrame() {\n\n\t\treturn this.currentFrame || this.lastFrame;\n\n\t}\n\n\tgetFrameById( frameId ) {\n\n\t\treturn this.framesLib[ frameId ] || null;\n\n\t}\n\n\tupdateTabs() { }\n\n\tresolveFrame( /*frame*/ ) { }\n\n\tasync resolveTimestamp() {\n\n\t\tif ( this._resolveTimestampPromise !== null ) {\n\n\t\t\treturn this._resolveTimestampPromise;\n\n\t\t}\n\n\t\tthis._resolveTimestampPromise = new Promise( ( resolve ) => {\n\n\t\t\tthis._rAFId = requestAnimationFrame( async () => {\n\n\t\t\t\tthis._rAFId = null;\n\n\t\t\t\tconst renderer = this.getRenderer();\n\n\t\t\t\tif ( renderer === null ) {\n\n\t\t\t\t\tthis._resolveTimestampPromise = null;\n\t\t\t\t\tresolve();\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( renderer.backend.hasTimestamp ) {\n\n\t\t\t\t\tawait renderer.resolveTimestampsAsync( TimestampQuery.COMPUTE );\n\t\t\t\t\tawait renderer.resolveTimestampsAsync( TimestampQuery.RENDER );\n\n\t\t\t\t\tif ( renderer !== this.getRenderer() ) {\n\n\t\t\t\t\t\tthis._resolveTimestampPromise = null;\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst computeFrames = renderer.backend.getTimestampFrames( TimestampQuery.COMPUTE );\n\t\t\t\t\tconst renderFrames = renderer.backend.getTimestampFrames( TimestampQuery.RENDER );\n\n\t\t\t\t\tconst frameIds = [ ...new Set( [ ...computeFrames, ...renderFrames ] ) ];\n\n\t\t\t\t\tfor ( const frameId of frameIds ) {\n\n\t\t\t\t\t\tconst frame = this.getFrameById( frameId );\n\n\t\t\t\t\t\tif ( frame !== null ) {\n\n\t\t\t\t\t\t\t// resolve compute timestamps\n\n\t\t\t\t\t\t\tif ( frame.resolvedCompute === false ) {\n\n\t\t\t\t\t\t\t\tif ( frame.computes.length > 0 ) {\n\n\t\t\t\t\t\t\t\t\tif ( computeFrames.includes( frameId ) ) {\n\n\t\t\t\t\t\t\t\t\t\tfor ( const stats of frame.computes ) {\n\n\t\t\t\t\t\t\t\t\t\t\tif ( renderer.backend.hasTimestampQuery( stats.uid ) ) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpu = renderer.backend.getTimestamp( stats.uid );\n\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpu = 0;\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpuNotAvailable = true;\n\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tframe.resolvedCompute = true;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\tframe.resolvedCompute = true;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// resolve render timestamps\n\n\t\t\t\t\t\t\tif ( frame.resolvedRender === false ) {\n\n\t\t\t\t\t\t\t\tif ( frame.renders.length > 0 ) {\n\n\t\t\t\t\t\t\t\t\tif ( renderFrames.includes( frameId ) ) {\n\n\t\t\t\t\t\t\t\t\t\tfor ( const stats of frame.renders ) {\n\n\t\t\t\t\t\t\t\t\t\t\tif ( renderer.backend.hasTimestampQuery( stats.uid ) ) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpu = renderer.backend.getTimestamp( stats.uid );\n\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpu = 0;\n\t\t\t\t\t\t\t\t\t\t\t\tstats.gpuNotAvailable = true;\n\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tframe.resolvedRender = true;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\tframe.resolvedRender = true;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( frame.resolvedCompute === true && frame.resolvedRender === true ) {\n\n\t\t\t\t\t\t\t\tthis.resolveFrame( frame );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tfor ( const frame of this.frames ) {\n\n\t\t\t\t\t\tif ( frame.resolvedCompute === true && frame.resolvedRender === true ) {\n\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst previousFrame = this.getFrameById( frame.frameId - 1 );\n\n\t\t\t\t\t\tif ( previousFrame === null ) continue;\n\n\t\t\t\t\t\tif ( frame.resolvedCompute === false ) {\n\n\t\t\t\t\t\t\tfor ( const stats of frame.computes ) {\n\n\t\t\t\t\t\t\t\tstats.gpu = 0;\n\t\t\t\t\t\t\t\tstats.gpuNotAvailable = true;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tframe.resolvedCompute = true;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( frame.resolvedRender === false ) {\n\n\t\t\t\t\t\t\tfor ( const stats of frame.renders ) {\n\n\t\t\t\t\t\t\t\tstats.gpu = 0;\n\t\t\t\t\t\t\t\tstats.gpuNotAvailable = true;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tframe.resolvedRender = true;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( frame.resolvedCompute === true && frame.resolvedRender === true ) {\n\n\t\t\t\t\t\t\tthis.resolveFrame( frame );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis._resolveTimestampPromise = null;\n\n\t\t\t\tresolve();\n\n\t\t\t} );\n\n\t\t} );\n\n\t\treturn this._resolveTimestampPromise;\n\n\t}\n\n\tget isAvailable() {\n\n\t\tconst renderer = this.getRenderer();\n\n\t\treturn renderer !== null;\n\n\t}\n\n\taddFrame( frame ) {\n\n\t\t// Limit to max frames.\n\n\t\tif ( this.frames.length >= this.maxFrames ) {\n\n\t\t\tconst removedFrame = this.frames.shift();\n\t\t\tdelete this.framesLib[ removedFrame.frameId ];\n\n\t\t}\n\n\t\tthis.frames.push( frame );\n\t\tthis.framesLib[ frame.frameId ] = frame;\n\n\t\tif ( this.isAvailable ) {\n\n\t\t\tthis.updateTabs();\n\t\t\tthis.resolveTimestamp();\n\n\t\t}\n\n\t}\n\n\tinspect( node ) {\n\n\t\tif ( this.enabled === false ) return;\n\n\t\tconst currentNodes = this.currentNodes;\n\n\t\tif ( currentNodes !== null ) {\n\n\t\t\tcurrentNodes.push( node );\n\n\t\t} else {\n\n\t\t\twarnOnce( 'RendererInspector: Unable to inspect node outside of frame scope. Use \"renderer.setAnimationLoop()\".' );\n\n\t\t}\n\n\t}\n\n\tbeginCompute( uid, computeNode ) {\n\n\t\tconst frame = this.getFrame();\n\n\t\tif ( ! frame ) return;\n\n\t\tconst currentCompute = new ComputeStats( uid, computeNode );\n\t\tcurrentCompute.timestamp = performance.now();\n\t\tcurrentCompute.parent = this.getParent();\n\n\t\tframe.computes.push( currentCompute );\n\t\tcurrentCompute.parent.children.push( currentCompute );\n\n\t\tthis.currentCompute = currentCompute;\n\t\tthis.currentContext = currentCompute;\n\n\t}\n\n\tfinishCompute() {\n\n\t\tconst frame = this.getFrame();\n\n\t\tif ( ! frame ) return;\n\n\t\tconst currentCompute = this.currentCompute;\n\t\tcurrentCompute.cpu = performance.now() - currentCompute.timestamp;\n\n\t\tthis.currentContext = currentCompute.parent;\n\t\tthis.currentCompute = currentCompute.parent && currentCompute.parent.isComputeStats ? currentCompute.parent : null;\n\n\t}\n\n\tbeginRender( uid, scene, camera, renderTarget ) {\n\n\t\tconst frame = this.getFrame();\n\n\t\tif ( ! frame ) return;\n\n\t\tconst currentRender = new RenderStats( uid, scene, camera, renderTarget );\n\t\tcurrentRender.timestamp = performance.now();\n\t\tcurrentRender.parent = this.getParent();\n\n\t\tframe.renders.push( currentRender );\n\t\tcurrentRender.parent.children.push( currentRender );\n\n\t\tthis.currentRender = currentRender;\n\t\tthis.currentContext = currentRender;\n\n\t}\n\n\tfinishRender() {\n\n\t\tconst frame = this.getFrame();\n\n\t\tif ( ! frame ) return;\n\n\t\tconst currentRender = this.currentRender;\n\t\tcurrentRender.cpu = performance.now() - currentRender.timestamp;\n\n\t\tthis.currentContext = currentRender.parent;\n\t\tthis.currentRender = currentRender.parent && currentRender.parent.isRenderStats ? currentRender.parent : null;\n\n\t\t// draw over each top-level render to the canvas, the frame finishes only at the start of the next one\n\n\t\tif ( this.overdraw === true && this._renderingOverdraw === false && currentRender.parent === frame && this.getRenderer().getRenderTarget() === null ) {\n\n\t\t\tthis._renderOverdraw();\n\n\t\t}\n\n\t}\n\n\tdispose() {\n\n\t\tif ( this._rAFId !== null ) {\n\n\t\t\tcancelAnimationFrame( this._rAFId );\n\t\t\tthis._rAFId = null;\n\n\t\t}\n\n\t\tthis._resolveTimestampPromise = null;\n\n\t\tif ( this._overdrawMaterial !== null ) {\n\n\t\t\tthis._overdrawMaterial.dispose();\n\t\t\tthis._overdrawMaterial = null;\n\n\t\t}\n\n\t\tsuper.dispose();\n\n\t}\n\n}\n","export class Style {\n\n\tstatic init( container, nonce = null ) {\n\n\t\tconst css = /* css */`\n@scope (.three-inspector) {\n\n\t:scope {\n\t\t--profiler-background: #1e1e24f5;\n\t\t--profiler-header-background: #2a2a33aa;\n\t\t--profiler-header: #2a2a33;\n\t\t--profiler-border: #4a4a5a;\n\t\t--text-primary: #e0e0e0;\n\t\t--text-secondary: #9a9aab;\n\t\t--color-accent: #00aaff;\n\t\t--color-green: #4caf50;\n\t\t--color-yellow: #ffc107;\n\t\t--color-red: #f44336;\n\t\t--color-fps: rgb(63, 81, 181);\n\t\t--color-call: rgba(255, 185, 34, 1);\n\t\t--font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\t\t--font-mono: 'Courier New', Courier, monospace;\n\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tpointer-events: none;\n\t\tz-index: 1000;\n\t\toverflow: hidden;\n\t\tcolor-scheme: dark;\n\t}\n\n\t:scope * {\n\t\tpointer-events: auto;\n\t}\n\n\t.profiler-panel, .profiler-toggle, .detached-tab-panel,\n\t.profiler-panel *, .profiler-toggle *, .detached-tab-panel * {\n\t\ttext-transform: initial;\n\t\tline-height: normal;\n\t\tbox-sizing: border-box;\n\t\t-webkit-font-smoothing: antialiased;\n\t\t-moz-osx-font-smoothing: grayscale;\n\t\t-webkit-tap-highlight-color: transparent;\n\t}\n\n\t.profiler-toggle {\n\t\tposition: absolute;\n\t\ttop: 15px;\n\t\tright: 15px;\n\t\tbackground-color: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid #4a4a5a54;\n\t\tborder-radius: 12px 6px 6px 12px;\n\t\tcolor: var(--text-primary);\n\t\tcursor: pointer;\n\t\tz-index: 1002;\n\t\ttransition: all 0.2s ease-in-out;\n\t\t/*font-size: 14px;*/\n\t\tfont-size: 15px;\n\t\tbackdrop-filter: blur(8px);\n\t\tbox-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);\n\t\tdisplay: flex;\n\t\talign-items: stretch;\n\t\tpadding: 0;\n\t\toverflow: hidden;\n\t\tfont-family: var(--font-family);\n\t}\n\n\t.profiler-toggle-graph {\n\t\tposition: absolute;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tz-index: 0;\n\t\tpointer-events: none;\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tborder-radius: inherit;\n\t\topacity: 0.5;\n\t}\n\n\t.profiler-toggle.toggle-left {\n\t\tright: auto;\n\t\tleft: 15px;\n\t\tborder-radius: 6px 12px 12px 6px;\n\t\tflex-direction: row-reverse;\n\t}\n\n\t.profiler-toggle.toggle-left .builtin-tabs-container {\n\t\tborder-right: none;\n\t\tborder-left: 1px solid #262636;\n\t}\n\n\t.profiler-toggle:hover {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.profiler-toggle.panel-open .toggle-icon {\n\t\tbackground-color: rgba(0, 170, 255, 0.2);\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.toggle-icon {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\twidth: 40px;\n\t\tfont-size: 20px;\n\t\ttransition: background-color 0.2s;\n\t}\n\n\t.console-badge-container {\n\t\tposition: absolute;\n\t\ttop: 2px;\n\t\tright: 2px;\n\t\tdisplay: flex;\n\t\tgap: 2px;\n\t\tpointer-events: none;\n\t}\n\n\t.console-badge,\n\t.tab-badge {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tmin-width: 14px;\n\t\theight: 14px;\n\t\tpadding: 0 4px;\n\t\tborder-radius: 7px;\n\t\tfont-size: 9px;\n\t\tfont-weight: bold;\n\t\tcolor: #ffffff;\n\t\tline-height: 1;\n\t\tbox-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);\n\t\tborder: 1px solid rgba(0, 0, 0, 0.2);\n\t}\n\n\t.tab-badge-container {\n\t\tposition: absolute;\n\t\ttop: 1px;\n\t\tright: 3px;\n\t\tdisplay: flex;\n\t\tgap: 2px;\n\t\tpointer-events: none;\n\t}\n\n\t.console-badge.error,\n\t.tab-badge.error {\n\t\tbackground-color: var(--color-red);\n\t}\n\n\t.console-badge.warn,\n\t.tab-badge.warn {\n\t\tbackground-color: var(--color-yellow);\n\t\tcolor: #111111;\n\t}\n\n\t.profiler-toggle:hover .toggle-icon {\n\t\tbackground-color: rgba(255, 255, 255, 0.05);\n\t}\n\n\t.profiler-toggle.panel-open:hover .toggle-icon {\n\t\tbackground-color: rgba(0, 170, 255, 0.3);\n\t}\n\n\t.toggle-separator {\n\t\twidth: 1px;\n\t\tbackground-color: var(--profiler-border);\n\t}\n\n\t.toggle-text {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tdisplay: flex;\n\t\talign-items: baseline;\n\t\tpadding: 8px 14px;\n\t\tmin-width: 80px;\n\t\tjustify-content: right;\n\t}\n\n\t.toggle-text .fps-label {\n\t\tfont-size: 0.7em;\n\t\tmargin-left: 10px;\n\t\tcolor: #999;\n\t}\n\n\t.builtin-tabs-container {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tdisplay: flex;\n\t\talign-items: stretch;\n\t\tgap: 0;\n\t\tborder-right: 1px solid #262636;\n\t\torder: -1;\n\t}\n\n\t.builtin-tab-btn {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tcolor: var(--text-secondary);\n\t\tcursor: pointer;\n\t\tpadding: 8px 14px;\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 13px;\n\t\tfont-weight: 600;\n\t\ttransition: all 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tmin-width: 32px;\n\t\tposition: relative;\n\t}\n\n\t.builtin-tab-btn svg {\n\t\twidth: 20px;\n\t\theight: 20px;\n\t\tstroke: currentColor;\n\t}\n\n\t.builtin-tab-btn:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.08);\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.builtin-tab-btn:active {\n\t\tbackground-color: rgba(255, 255, 255, 0.12);\n\t}\n\n\t.builtin-tab-btn.active {\n\t\tbackground-color: rgba(0, 170, 255, 0.2);\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.builtin-tab-btn.active:hover {\n\t\tbackground-color: rgba(0, 170, 255, 0.3);\n\t}\n\n\t.profiler-mini-panel {\n\t\tposition: absolute;\n\t\ttop: 60px;\n\t\tright: 15px;\n\t\tbackground-color: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid #4a4a5a54;\n\t\tborder-radius: 8px;\n\t\tcolor: var(--text-primary);\n\t\tz-index: 9999;\n\t\tbackdrop-filter: blur(8px);\n\t\tbox-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 11px;\n\t\twidth: 350px;\n\t\tmax-width: calc(100vw - 30px);\n\t\tmin-width: 170px;\n\t\tmax-height: calc(100vh - 100px);\n\t\toverflow-y: auto;\n\t\toverflow-x: hidden;\n\t\tdisplay: none;\n\t\topacity: 0;\n\t\ttransform: translateY(-10px) scale(0.98);\n\t\ttransition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), \n\t\t\t\t\ttransform 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.profiler-mini-panel.toggle-left {\n\t\tright: auto;\n\t\tleft: 15px;\n\t}\n\n\t.profiler-mini-panel.visible {\n\t\tdisplay: block;\n\t\topacity: 1;\n\t\ttransform: translateY(0) scale(1);\n\t}\n\n\t.profiler-toggle.toggle-bottom {\n\t\ttop: auto;\n\t\tbottom: 15px;\n\t}\n\n\t.profiler-mini-panel.toggle-bottom {\n\t\ttop: auto;\n\t\tbottom: 60px;\n\t}\n\n\t.profiler-mini-panel::-webkit-scrollbar {\n\t\twidth: 6px;\n\t}\n\n\t.profiler-mini-panel::-webkit-scrollbar-track {\n\t\tbackground: transparent;\n\t}\n\n\t.profiler-mini-panel::-webkit-scrollbar-thumb {\n\t\tbackground: rgba(255, 255, 255, 0.15);\n\t\tborder-radius: 3px;\n\t\ttransition: background 0.2s;\n\t}\n\n\t.profiler-mini-panel::-webkit-scrollbar-thumb:hover {\n\t\tbackground: rgba(255, 255, 255, 0.25);\n\t}\n\n\t.mini-panel-content {\n\t\tpadding: 0;\n\t\tfont-size: 11px;\n\t\tline-height: 1.5;\n\t\tfont-family: var(--font-mono);\n\t\tletter-spacing: 0.3px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.mini-panel-content .profiler-content {\n\t\tdisplay: block !important;\n\t\tbackground: transparent;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper {\n\t\tmax-height: calc(100vh - 120px);\n\t\toverflow-y: auto;\n\t\toverflow-x: hidden;\n\t\twidth: 100%;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar {\n\t\twidth: 4px;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-track {\n\t\tbackground: transparent;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-thumb {\n\t\tbackground: rgba(255, 255, 255, 0.1);\n\t\tborder-radius: 2px;\n\t}\n\n\t.mini-panel-content .list-scroll-wrapper::-webkit-scrollbar-thumb:hover {\n\t\tbackground: rgba(255, 255, 255, 0.2);\n\t}\n\n\t.mini-panel-content .parameters {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tbox-shadow: none;\n\t\tpadding: 4px;\n\t}\n\n\t@media screen and (max-width: 340px) {\n\n\t\t.mini-panel-content .parameters {\n\t\t\tmin-width: 0 !important;\n\t\t}\n\n\t}\n\n\t.mini-panel-content .list-container.parameters {\n\t\tpadding: 2px 6px 0px 6px !important;\n\t}\n\n\t.mini-panel-content .list-header {\n\t\tdisplay: none;\n\t\tpadding: 2px 4px;\n\t\tfont-size: 11px;\n\t\tfont-weight: 600;\n\t\ttext-transform: uppercase;\n\t\tletter-spacing: 0.5px;\n\t}\n\n\t.mini-panel-content .list-item {\n\t\tborder-bottom: 1px solid rgba(74, 74, 90, 0.2);\n\t\ttransition: background-color 0.15s;\n\t}\n\n\t.mini-panel-content .list-item:last-child {\n\t\tborder-bottom: none;\n\t}\n\n\t.mini-panel-content .list-item:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.04);\n\t}\n\n\t.mini-panel-content .list-item.actionable:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.06);\n\t\tcursor: pointer;\n\t}\n\n\t.info-icon {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tborder-radius: 50%;\n\t\tbackground-color: rgba(255, 255, 255, 0.1);\n\t\tcolor: var(--text-secondary);\n\t\tfont-size: 10px;\n\t\tfont-style: italic;\n\t\tmargin-left: 6px;\n\t\tcursor: help;\n\t\tposition: relative;\n\t\tvertical-align: middle;\n\t\ttop: -1px;\n\t}\n\n\t.info-icon.active {\n\t\tbackground-color: var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t@media (hover: hover) {\n\t\t.info-icon:hover {\n\t\t\tbackground-color: var(--color-accent);\n\t\t\tcolor: white;\n\t\t}\n\t}\n\n\t.info-tooltip {\n\t\tposition: fixed;\n\t\ttransform: translate(-50%, -100%);\n\t\tbackground-color: rgba(30, 30, 36, 0.95);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tborder-radius: 6px;\n\t\tpadding: 10px 14px;\n\t\tcolor: var(--text-primary);\n\t\tfont-size: 12px;\n\t\twidth: max-content;\n\t\tmax-width: 250px;\n\t\tbox-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);\n\t\topacity: 0;\n\t\tvisibility: hidden;\n\t\ttransition: opacity 0.2s, visibility 0.2s;\n\t\tz-index: 999999;\n\t\tfont-style: normal;\n\t\tfont-family: var(--font-family);\n\t\ttext-align: left;\n\t\twhite-space: normal;\n\t}\n\n\t.info-tooltip h3 {\n\t\tmargin: 0 0 6px 0;\n\t\tfont-size: 13px;\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.info-tooltip strong {\n\t\tfont-weight: 600;\n\t\tcolor: white;\n\t}\n\n\t/* Style adjustments for lil-gui look */\n\t.mini-panel-content .item-row {\n\t\tpadding: 3px 8px;\n\t\tmin-height: 24px;\n\t}\n\n\t.mini-panel-content .list-item-row {\n\t\tpadding: 1px 4px;\n\t\tgap: 8px;\n\t\tmin-height: 21px;\n\t\talign-items: center;\n\t}\n\n\t.mini-panel-content input[type=\"checkbox\"] {\n\t\twidth: 12px;\n\t\theight: 12px;\n\t}\n\n\t.mini-panel-content input[type=\"range\"] {\n\t\theight: 18px;\n\t}\n\n\t.mini-panel-content .value-number input,\n\t.mini-panel-content .value-slider input {\n\t\tbackground-color: rgba(0, 0, 0, 0.3);\n\t\tborder: 1px solid rgba(74, 74, 90, 0.5);\n\t\tfont-size: 10px;\n\t}\n\n\t.mini-panel-content .value-number input:focus,\n\t.mini-panel-content .value-slider input:focus {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.mini-panel-content .value-slider {\n\t\tgap: 6px;\n\t}\n\n\t/* Compact nested items */\n\t.mini-panel-content .list-item .list-item {\n\t\tmargin-left: 8px;\n\t}\n\n\t.mini-panel-content .list-item .list-item .item-row,\n\t.mini-panel-content .list-item .list-item .list-item-row {\n\t\tpadding: 2px 6px;\n\t\tmin-height: 22px;\n\t}\n\n\t/* Compact collapsible headers */\n\t.mini-panel-content .collapsible .item-row,\n\t.mini-panel-content .list-item-row.collapsible {\n\t\tpadding: 2px 8px;\n\t\tfont-weight: 600;\n\t\tmin-height: 16px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tline-height: 1;\n\t}\n\n\t.mini-panel-content .collapsible-icon {\n\t\tfont-size: 10px;\n\t\twidth: 14px;\n\t\theight: 14px;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"range\"] {\n\t\theight: 12px;\n\t\tmargin-top: 1px;\n\t\tpadding-top: 5px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t\toutline: none;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"range\"]::-webkit-slider-thumb {\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tmargin-top: -5px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"range\"]::-moz-range-thumb {\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tuser-select: none;\n\t\t-moz-user-select: none;\n\t}\n\n\t.mini-panel-content .list-children-container {\n\t\tpadding-left: 0;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"number\"] {\n\t\tflex-basis: 60px !important;\n\t}\n\n\t.mini-panel-content .param-control {\n\t\talign-items: center;\n\t}\n\n\t.mini-panel-content .param-control select {\n\t\tfont-size: 11px;\n\t}\n\n\t.mini-panel-content .list-item-wrapper {\n\t\tmargin-top: 0;\n\t\tmargin-bottom: 0;\n\t}\n\n\t.profiler-panel {\n\t\tposition: absolute;\n\t\tz-index: 1001 !important;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\tright: 0;\n\t\theight: 350px;\n\t\tbackground-color: var(--profiler-background);\n\t\tbackdrop-filter: blur(8px);\n\t\tborder-top: 2px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tz-index: 1000;\n\t\t/*box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.5);*/\n\t\ttransform: translateY(100%);\n\t\ttransition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), height 0.3s ease-out, width 0.3s ease-out;\n\t\tfont-family: var(--font-mono);\n\t}\n\n\t.profiler-panel.resizing,\n\t.profiler-panel.dragging {\n\t\ttransition: none;\n\t}\n\n\t.profiler-panel.visible {\n\t\ttransform: translateY(0);\n\t}\n\n\t.profiler-panel.maximized {\n\t\theight: 100%;\n\t\tz-index: 10000 !important;\n\t}\n\n\t/* Position-specific styles */\n\t.profiler-panel.position-top {\n\t\tbottom: auto;\n\t\ttop: 0;\n\t\tborder-top: none;\n\t\tborder-bottom: 2px solid var(--profiler-border);\n\t\ttransform: translateY(-100%);\n\t}\n\n\t.profiler-panel.position-top.visible {\n\t\ttransform: translateY(0);\n\t}\n\n\t.profiler-panel.position-bottom {\n\t\t/* Default position - already defined above */\n\t}\n\n\t.profiler-panel.position-left {\n\t\ttop: 0;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\tright: auto;\n\t\twidth: 350px;\n\t\theight: 100%;\n\t\tborder-top: none;\n\t\tborder-right: 2px solid var(--profiler-border);\n\t\ttransform: translateX(-100%);\n\t}\n\n\t.profiler-panel.position-left.visible {\n\t\ttransform: translateX(0);\n\t}\n\n\t.profiler-panel.position-right {\n\t\ttop: 0;\n\t\tbottom: 0;\n\t\tleft: auto;\n\t\tright: 0;\n\t\twidth: 350px;\n\t\theight: 100%;\n\t\tborder-top: none;\n\t\tborder-left: 2px solid var(--profiler-border);\n\t\ttransform: translateX(100%);\n\t}\n\n\t.profiler-panel.position-right.visible {\n\t\ttransform: translateX(0);\n\t}\n\n\t.profiler-panel.position-floating {\n\t\tborder: 2px solid var(--profiler-border);\n\t\tborder-radius: 8px;\n\t\tbox-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);\n\t\ttransform: none !important;\n\t\toverflow: hidden;\n\t}\n\n\t.profiler-panel.position-floating.visible {\n\t\ttransform: none !important;\n\t}\n\n\t.profiler-panel.position-floating .profiler-header {\n\t\tborder-radius: 6px 6px 0 0;\n\t}\n\n\t.profiler-panel.position-floating .panel-resizer {\n\t\tbottom: 0;\n\t\tright: 0;\n\t\ttop: auto;\n\t\tleft: auto;\n\t\twidth: 16px;\n\t\theight: 16px;\n\t\tcursor: nwse-resize;\n\t\tborder-radius: 0 0 6px 0;\n\t}\n\n\t.profiler-panel.position-floating .panel-resizer::after {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tright: 2px;\n\t\tbottom: 2px;\n\t\twidth: 10px;\n\t\theight: 10px;\n\t\tbackground: linear-gradient(135deg, transparent 0%, transparent 45%, var(--profiler-border) 45%, var(--profiler-border) 55%, transparent 55%);\n\t}\n\n\n\t.panel-resizer {\n\t\tposition: absolute;\n\t\ttop: -2px;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 5px;\n\t\tcursor: ns-resize;\n\t\tz-index: 1001;\n\t\ttouch-action: none;\n\t}\n\n\t.profiler-panel.position-top .panel-resizer {\n\t\ttop: auto;\n\t\tbottom: -2px;\n\t}\n\n\t.profiler-panel.position-left .panel-resizer {\n\t\ttop: 0;\n\t\tleft: auto;\n\t\tright: -2px;\n\t\twidth: 5px;\n\t\theight: 100%;\n\t\tcursor: ew-resize;\n\t}\n\n\t.profiler-panel.position-right .panel-resizer {\n\t\ttop: 0;\n\t\tleft: -2px;\n\t\tright: auto;\n\t\twidth: 5px;\n\t\theight: 100%;\n\t\tcursor: ew-resize;\n\t}\n\n\t.profiler-header {\n\t\tdisplay: flex;\n\t\tbackground-color: var(--profiler-header-background);\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t\tflex-shrink: 0;\n\t\tjustify-content: space-between;\n\t\talign-items: stretch;\n\n\t\toverflow-x: auto;\n\t\toverflow-y: hidden;\n\t\twidth: calc(100% - 120px);\n\t\theight: 32px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.profiler-panel.has-horizontal-scroll .profiler-header {\n\t\theight: 38px;\n\t}\n\n\t/* Adjust header width based on panel position */\n\t.profiler-panel.position-right .profiler-header,\n\t.profiler-panel.position-left .profiler-header {\n\t\twidth: calc(100% - 120px);\n\t}\n\n\t.profiler-panel.position-bottom .profiler-header,\n\t.profiler-panel.position-top .profiler-header {\n\t\twidth: calc(100% - 120px);\n\t}\n\n\t/* Adjust header width when position toggle button is hidden (mobile) */\n\t.profiler-panel.hide-position-toggle .profiler-header {\n\t\twidth: calc(100% - 80px);\n\t}\n\n\t/* Adjust header width when maximized (floating position toggle button is hidden) */\n\t.profiler-panel.maximized .profiler-header {\n\t\twidth: calc(100% - 80px);\n\t}\n\n\t/* ===== RULES FOR WHEN THERE ARE NO TABS ===== */\n\n\t/* Horizontal mode (bottom/top) without tabs */\n\t.profiler-panel.position-bottom.no-tabs:not(.maximized),\n\t.profiler-panel.position-top.no-tabs:not(.maximized) {\n\t\theight: 32px !important;\n\t\tmin-height: 32px !important;\n\t}\n\n\t.profiler-panel.position-bottom.no-tabs .profiler-header,\n\t.profiler-panel.position-top.no-tabs .profiler-header {\n\t\twidth: 100%;\n\t\theight: 32px;\n\t\tborder-bottom: none;\n\t}\n\n\t.profiler-panel.position-bottom.no-tabs .profiler-content-wrapper,\n\t.profiler-panel.position-top.no-tabs .profiler-content-wrapper {\n\t\tdisplay: none;\n\t}\n\n\t.profiler-panel.position-bottom.no-tabs .panel-resizer,\n\t.profiler-panel.position-top.no-tabs .panel-resizer {\n\t\tdisplay: none;\n\t}\n\n\t/* Vertical mode (right/left) without tabs */\n\t.profiler-panel.position-right.no-tabs:not(.maximized),\n\t.profiler-panel.position-left.no-tabs:not(.maximized) {\n\t\twidth: 40px !important;\n\t\tmin-width: 40px !important;\n\t}\n\n\t/* Vertical layout for header when no tabs */\n\t.profiler-panel.position-right.no-tabs .profiler-header,\n\t.profiler-panel.position-left.no-tabs .profiler-header {\n\t\twidth: 100%;\n\t\tflex-direction: column;\n\t\theight: 100%;\n\t\tborder-bottom: none;\n\t}\n\n\t/* Vertical layout for controls when no tabs */\n\t.profiler-panel.position-right.no-tabs .profiler-controls,\n\t.profiler-panel.position-left.no-tabs .profiler-controls {\n\t\tposition: static;\n\t\tflex-direction: column-reverse;\n\t\tjustify-content: flex-end;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tborder-bottom: none;\n\t\tborder-left: none;\n\t\tbackground: transparent;\n\t}\n\n\t.profiler-panel.position-right.no-tabs .profiler-controls button,\n\t.profiler-panel.position-left.no-tabs .profiler-controls button {\n\t\twidth: 100%;\n\t\theight: 40px;\n\t\tborder-left: none;\n\t\tborder-top: none;\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t}\n\n\t.profiler-panel.position-right.no-tabs .profiler-content-wrapper,\n\t.profiler-panel.position-left.no-tabs .profiler-content-wrapper {\n\t\tdisplay: none;\n\t}\n\n\t.profiler-panel.position-right.no-tabs .profiler-tabs,\n\t.profiler-panel.position-left.no-tabs .profiler-tabs {\n\t\tdisplay: none;\n\t\tpadding-left: 2px;\n\t}\n\n\t.profiler-panel.position-right.no-tabs .panel-resizer,\n\t.profiler-panel.position-left.no-tabs .panel-resizer {\n\t\tdisplay: none;\n\t}\n\n\t/* Hide position toggle on mobile without tabs */\n\t.profiler-panel.hide-position-toggle.position-right.no-tabs:not(.maximized),\n\t.profiler-panel.hide-position-toggle.position-left.no-tabs:not(.maximized) {\n\t\twidth: 40px !important;\n\t\tmin-width: 40px !important;\n\t}\n\n\t/* Hide drag indicator on mobile devices */\n\t.profiler-panel.is-mobile .tab-btn.active::before {\n\t\tdisplay: none;\n\t}\n\n\t.profiler-header::-webkit-scrollbar,\n\t.profiler-tabs::-webkit-scrollbar,\n\t.profiler-content::-webkit-scrollbar,\n\t.detached-tab-content::-webkit-scrollbar,\n\t.console-log::-webkit-scrollbar,\n\t.timelineTrack::-webkit-scrollbar,\n\t.list-scroll-wrapper::-webkit-scrollbar {\n\t\twidth: 4px;\n\t\theight: 4px;\n\t}\n\n\t.profiler-header::-webkit-scrollbar-track,\n\t.profiler-tabs::-webkit-scrollbar-track,\n\t.profiler-content::-webkit-scrollbar-track,\n\t.detached-tab-content::-webkit-scrollbar-track,\n\t.console-log::-webkit-scrollbar-track,\n\t.timelineTrack::-webkit-scrollbar-track,\n\t.list-scroll-wrapper::-webkit-scrollbar-track {\n\t\tbackground: transparent;\n\t}\n\n\t.profiler-header::-webkit-scrollbar-thumb,\n\t.profiler-tabs::-webkit-scrollbar-thumb,\n\t.profiler-content::-webkit-scrollbar-thumb,\n\t.detached-tab-content::-webkit-scrollbar-thumb,\n\t.console-log::-webkit-scrollbar-thumb,\n\t.timelineTrack::-webkit-scrollbar-thumb,\n\t.list-scroll-wrapper::-webkit-scrollbar-thumb {\n\t\tbackground-color: rgba(255, 255, 255, 0.15);\n\t\tborder-radius: 2px;\n\t}\n\n\t.profiler-header::-webkit-scrollbar-thumb:hover,\n\t.profiler-tabs::-webkit-scrollbar-thumb:hover,\n\t.profiler-content::-webkit-scrollbar-thumb:hover,\n\t.detached-tab-content::-webkit-scrollbar-thumb:hover,\n\t.console-log::-webkit-scrollbar-thumb:hover,\n\t.timelineTrack::-webkit-scrollbar-thumb:hover,\n\t.list-scroll-wrapper::-webkit-scrollbar-thumb:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.3);\n\t}\n\n\t.profiler-header::-webkit-scrollbar-corner,\n\t.profiler-tabs::-webkit-scrollbar-corner,\n\t.profiler-content::-webkit-scrollbar-corner,\n\t.detached-tab-content::-webkit-scrollbar-corner,\n\t.console-log::-webkit-scrollbar-corner,\n\t.timelineTrack::-webkit-scrollbar-corner,\n\t.list-scroll-wrapper::-webkit-scrollbar-corner {\n\t\tbackground: transparent;\n\t}\n\n\t.profiler-header,\n\t.profiler-tabs,\n\t.profiler-content,\n\t.detached-tab-content,\n\t.console-log,\n\t.timelineTrack,\n\t.list-scroll-wrapper {\n\t\tscrollbar-width: thin;\n\t\tscrollbar-color: rgba(255, 255, 255, 0.15) transparent;\n\t}\n\n\t.profiler-panel.dragging .profiler-header {\n\t\tcursor: grabbing !important;\n\t}\n\n\t.profiler-panel.dragging {\n\t\topacity: 0.8;\n\t}\n\n\t.profiler-tabs {\n\t\tdisplay: flex;\n\t\tcursor: grab;\n\t\tposition: relative;\n\t\tmargin-left: 2px;\n\t}\n\n\t.profiler-tabs:active {\n\t\tcursor: grabbing;\n\t}\n\n\n\t.profiler-controls {\n\t\tdisplay: flex;\n\t\tposition: absolute;\n\t\tright: 0;\n\t\ttop: 0;\n\t\theight: 32px;\n\t\tbackground: var(--profiler-header-background);\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t}\n\n\t.profiler-panel.has-horizontal-scroll .profiler-controls {\n\t\theight: 38px;\n\t}\n\n\t.tab-btn {\n\t\tposition: relative;\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\t/*border-right: 1px solid var(--profiler-border);*/\n\t\tcolor: var(--text-secondary);\n\t\tpadding: 0 15px 2px 15px;\n\t\theight: 100%;\n\t\tbox-sizing: border-box;\n\t\tcursor: default;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tfont-family: var(--font-family);\n\t\tfont-weight: 600;\n\t\tfont-size: 13px;\n\t\tuser-select: none;\n\t\ttransition: opacity 0.2s, transform 0.2s;\n\t\ttouch-action: pan-x;\n\t\twhite-space: nowrap;\n\t}\n\n\t.tab-btn.active {\n\t\tborder-bottom: 2px solid var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t.tab-btn.active::before {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tleft: 2px;\n\t\ttop: 50%;\n\t\ttransform: translateY(-50%);\n\t\twidth: 8px;\n\t\theight: 14px;\n\t\tbackground-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='8' height='14' viewBox='0 0 8 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='2' cy='3' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='2' cy='7' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='2' cy='11' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='6' cy='3' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='6' cy='7' r='1' fill='%234a4a5a'/%3E%3Ccircle cx='6' cy='11' r='1' fill='%234a4a5a'/%3E%3C/svg%3E\");\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: center;\n\t\topacity: 0.6;\n\t}\n\n\t.tab-btn.no-detach.active::before {\n\t\tdisplay: none;\n\t}\n\n\t.floating-btn,\n\t.maximize-btn,\n\t.hide-panel-btn {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tborder-left: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-secondary);\n\t\twidth: 40px;\n\t\theight: 100%;\n\t\tcursor: pointer;\n\t\ttransition: all 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tflex-shrink: 0;\n\t}\n\n\t/* Disable transitions in vertical mode to avoid broken animations */\n\t.profiler-panel.position-right .floating-btn,\n\t.profiler-panel.position-right .maximize-btn,\n\t.profiler-panel.position-right .hide-panel-btn,\n\t.profiler-panel.position-left .floating-btn,\n\t.profiler-panel.position-left .maximize-btn,\n\t.profiler-panel.position-left .hide-panel-btn {\n\t\ttransition: background-color 0.2s, color 0.2s;\n\t}\n\n\t.floating-btn:hover,\n\t.maximize-btn:hover,\n\t.hide-panel-btn:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.1);\n\t\tcolor: var(--text-primary);\n\t}\n\n\t/* Hide maximize button when there are no tabs */\n\t.profiler-panel.position-right.no-tabs .maximize-btn,\n\t.profiler-panel.position-left.no-tabs .maximize-btn,\n\t.profiler-panel.position-bottom.no-tabs .maximize-btn,\n\t.profiler-panel.position-top.no-tabs .maximize-btn {\n\t\tdisplay: none !important;\n\t}\n\n\t/* Hide floating button when maximized */\n\t.profiler-panel.maximized .floating-btn {\n\t\tdisplay: none !important;\n\t}\n\n\t.profiler-content-wrapper {\n\t\tflex-grow: 1;\n\t\toverflow: hidden;\n\t\tposition: relative;\n\t}\n\n\t.profiler-content {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow-y: auto;\n\t\tfont-size: 13px;\n\t\tvisibility: hidden;\n\t\topacity: 0;\n\t\ttransition: opacity 0.2s, visibility 0.2s;\n\t\tbox-sizing: border-box;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.profiler-content.active {\n\t\tvisibility: visible;\n\t\topacity: 1;\n\t}\n\n\t.profiler-content {\n\t\toverflow: auto; /* make sure scrollbars can appear */\n\t}\n\n\n\t.list-item-row {\n\t\tdisplay: grid;\n\t\tgrid-template-columns: var(--list-grid-template, none);\n\t\talign-items: center;\n\t\tpadding: 4px 8px;\n\t\tborder-radius: 3px;\n\t\ttransition: background-color 0.2s;\n\t\tgap: 10px;\n\t\tborder-bottom: none;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.parameters .list-item-row {\n\t\tmin-height: 23px;\n\t}\n\n\t.mini-panel-content .parameters .list-item-row {\n\t\tmin-height: 21px;\n\t}\n\n\t.list-item-wrapper {\n\t\tmargin-top: 2px;\n\t\tmargin-bottom: 2px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.list-item-wrapper:has(> .list-item-row .graph-container) {\n\t\tmargin-left: -1.5em;\n\t}\n\n\t.list-item-wrapper:first-child {\n\t\t/*margin-top: 0;*/\n\t}\n\n\t.list-item-wrapper:not(.header-wrapper):nth-child(odd) > .list-item-row {\n\t\tbackground-color: rgba(0,0,0,0.1);\n\t}\n\n\t.list-item-wrapper.header-wrapper>.list-item-row {\n\t\tcolor: var(--color-accent);\n\t\tbackground-color: rgba(0, 170, 255, 0.1);\n\t}\n\n\t.list-item-wrapper.header-wrapper>.list-item-row>.list-item-cell:first-child {\n\t\tfont-weight: 600;\n\t}\n\n\t.list-item-row.collapsible,\n\t.list-item-row.actionable {\n\t\tcursor: pointer;\n\t}\n\n\t.list-item-row.collapsible {\n\t\tbackground-color: rgba(0, 170, 255, 0.15) !important;\n\t\tmin-height: 23px;\n\t}\n\n\t.list-item-row.collapsible.alert,\n\t.list-item-row.alert {\n\t\tbackground-color: rgba(244, 67, 54, 0.1) !important;\n\t}\n\n\t@media (hover: hover) {\n\n\t\t.list-item-row:hover:not(.collapsible):not(.no-hover),\n\t\t.list-item-row:hover:not(.no-hover),\n\t\t.list-item-row.actionable:hover,\n\t\t.list-item-row.collapsible.actionable:hover {\n\t\t\tbackground-color: rgba(255, 255, 255, 0.05) !important;\n\t\t}\n\n\t\t.list-item-row.collapsible:hover {\n\t\t\tbackground-color: rgba(0, 170, 255, 0.25) !important;\n\t\t}\n\n\t}\n\n\t.list-item-cell {\n\t\twhite-space: pre;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.list-item-cell:not(:first-child) {\n\t\tjustify-content: flex-end;\n\t\tfont-weight: 600;\n\t}\n\n\t.list-header {\n\t\tdisplay: grid;\n\t\tgrid-template-columns: var(--list-grid-template, none);\n\t\talign-items: center;\n\t\tpadding: 4px 8px;\n\t\tfont-weight: 600;\n\t\tcolor: var(--text-secondary);\n\t\tpadding-bottom: 6px;\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t\tmargin-bottom: 5px;\n\t\tgap: 10px;\n\t\tuser-select: none;\n\t\t-webkit-user-select: none;\n\t}\n\n\t.list-item-wrapper.section-start {\n\t\tmargin-top: 5px;\n\t\tmargin-bottom: 5px;\n\t}\n\n\t.list-header .list-header-cell:not(:first-child) {\n\t\ttext-align: right;\n\t}\n\n\t.list-children-container {\n\t\tpadding-left: 1.5em;\n\t\toverflow: hidden;\n\t\ttransition: max-height 0.1s ease-out;\n\t\tmargin-top: 2px;\n\t}\n\n\t.list-children-container.closed {\n\t\tmax-height: 0;\n\t\tdisplay: none !important;\n\t}\n\n\t.item-toggler {\n\t\tdisplay: inline-block;\n\t\tmargin-right: 0.8em;\n\t\ttext-align: left;\n\t}\n\n\t.list-item-row.open .item-toggler::before {\n\t\tcontent: '-';\n\t}\n\n\t.list-item-row:not(.open) .item-toggler::before {\n\t\tcontent: '+';\n\t}\n\n\t.list-item-cell .value.good {\n\t\tcolor: var(--color-green);\n\t}\n\n\t.list-item-cell .value.warn {\n\t\tcolor: var(--color-yellow);\n\t}\n\n\t.list-item-cell .value.bad {\n\t\tcolor: var(--color-red);\n\t}\n\n\t.list-scroll-wrapper {\n\t\twidth: max-content;\n\t\tmin-width: 100%;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tmin-height: 100%;\n\t}\n\n\t.list-container.parameters .list-item-row:not(.collapsible) {\n\t}\n\n\t.graph-container {\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t\tpadding: 8px 0;\n\t\tposition: relative;\n\t}\n\n\t.graph-svg, .graph-canvas {\n\t\twidth: 0;\n\t\tmin-width: 100%;\n\t\theight: 80px;\n\t\tbackground-color: var(--profiler-header);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tborder-radius: 4px;\n\t\tdisplay: block;\n\t}\n\n\t.graph-path {\n\t\tstroke-width: 2;\n\t\tfill-opacity: 0.4;\n\t}\n\n\t.console-buttons-group {\n\t\tdisplay: flex;\n\t\tgap: 20px;\n\t}\n\n\t.console-filter-input {\n\t\tbackground-color: var(--profiler-background);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px 10px 2px 10px;\n\t\tfont-family: var(--font-mono);\n\t\tflex-grow: 1;\n\t\tmax-width: 300px;\n\t\tborder-radius: 15px;\n\t}\n\n\t.console-filter-input:focus {\n\t\toutline: none;\n\t\tborder-color: var(--text-secondary);\n\t}\n\n\t.console-copy-button {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tcolor: var(--text-secondary);\n\t\tcursor: pointer;\n\t\tpadding: 4px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tborder-radius: 4px;\n\t\ttransition: color 0.2s, background-color 0.2s;\n\t}\n\n\t.console-copy-button:hover {\n\t\tcolor: var(--text-primary);\n\t\tbackground-color: var(--profiler-hover);\n\t}\n\n\t.console-copy-button.copied {\n\t\tcolor: var(--color-green);\n\t}\n\n\t.console-log {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tgap: 4px;\n\t\tpadding: 10px;\n\t\toverflow-y: auto;\n\t\tflex-grow: 1;\n\t\tuser-select: text;\n\t\t-webkit-user-select: text;\n\t}\n\n\t.log-message {\n\t\tdisplay: flex;\n\t\talign-items: flex-start;\n\t\tgap: 6px;\n\t\tpadding: 3px 5px;\n\t\tborder-radius: 3px;\n\t\tline-height: 1.5 !important;\n\t}\n\n\t.log-count-badge {\n\t\tdisplay: inline-block;\n\t\ttext-align: center;\n\t\tmin-width: 14px;\n\t\theight: 14px;\n\t\tborder-radius: 7px;\n\t\tpadding: 0 3px;\n\t\tfont-size: 9px;\n\t\tfont-weight: bold;\n\t\tline-height: 14px;\n\t\tbox-sizing: border-box;\n\t\tmargin-top: 0;\n\t\tflex-shrink: 0;\n\t}\n\n\t.log-icon {\n\t\tdisplay: inline-block;\n\t\ttext-align: center;\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tfont-size: 11px;\n\t\tline-height: 14px;\n\t\tmargin-top: 0;\n\t\tflex-shrink: 0;\n\t}\n\n\t.log-body {\n\t\tflex-grow: 1;\n\t\twhite-space: pre-wrap;\n\t\tword-break: break-all;\n\t}\n\n\t.log-message.info .log-count-badge {\n\t\tbackground-color: rgba(255, 255, 255, 0.12);\n\t\tborder: 1px solid rgba(255, 255, 255, 0.2);\n\t\tcolor: var(--text-secondary);\n\t}\n\n\t.log-message.warn .log-count-badge {\n\t\tbackground-color: rgba(255, 193, 7, 0.18);\n\t\tborder: 1px solid rgba(255, 193, 7, 0.35);\n\t\tcolor: var(--color-yellow);\n\t}\n\n\t.log-message.error .log-count-badge {\n\t\tbackground-color: rgba(244, 67, 54, 0.18);\n\t\tborder: 1px solid rgba(244, 67, 54, 0.35);\n\t\tcolor: #ff8a80;\n\t}\n\n\t.log-message.hidden {\n\t\tdisplay: none;\n\t}\n\n\t.log-message.info {\n\t\tcolor: var(--text-primary);\n\t}\n\n\t.log-message.warn {\n\t\tcolor: var(--color-yellow);\n\t}\n\n\t.log-message.error {\n\t\tcolor: #f9dedc;\n\t\tbackground-color: rgba(244, 67, 54, 0.1);\n\t}\n\n\t.log-prefix {\n\t\tcolor: var(--text-secondary);\n\t\tmargin-right: 8px;\n\t}\n\n\t.log-code {\n\t\tbackground-color: rgba(255, 255, 255, 0.1);\n\t\tborder-radius: 3px;\n\t\tpadding: 1px 4px;\n\t}\n\n\t.thumbnail-container {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t}\n\n\t.thumbnail-svg {\n\t\twidth: 40px;\n\t\theight: 22.5px;\n\t\tflex-shrink: 0;\n\t\tmargin-right: 8px;\n\t}\n\n\t.param-control {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: flex-end;\n\t\tgap: 10px;\n\t\twidth: 100%;\n\t}\n\n\t.param-control input,\n\t.param-control select,\n\t.param-control button {\n\t\tbackground-color: var(--profiler-background);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px 6px;\n\t\tpadding-bottom: 2px;\n\t\tfont-family: var(--font-mono);\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t\tcolor-scheme: dark;\n\t}\n\n\t.param-control input:focus {\n\t\toutline: none;\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.param-control select {\n\t\tpadding-top: 3px;\n\t\tpadding-bottom: 1px;\n\t}\n\n\t.param-control input[type=\"number\"] {\n\t\tcursor: ns-resize;\n\t}\n\n\t.param-control input[type=\"color\"] {\n\t\tpadding: 2px;\n\t}\n\n\t.param-control button {\n\t\tcursor: pointer;\n\t\ttransition: background-color 0.2s;\n\t}\n\n\t.param-control button:hover {\n\t\tbackground-color: var(--profiler-header);\n\t}\n\n\t.param-control-vector {\n\t\tdisplay: flex;\n\t\tgap: 5px;\n\t}\n\n\t.custom-checkbox {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tcursor: pointer;\n\t\tgap: 8px;\n\t\twill-change: transform;\n\t\tfont-size: 12px;\n\t}\n\n\t.custom-checkbox input {\n\t\tdisplay: none;\n\t}\n\n\t.custom-checkbox .checkmark {\n\t\twidth: 14px;\n\t\theight: 14px;\n\t\tborder: 1px solid var(--color-accent);\n\t\tborder-radius: 3px;\n\t\tdisplay: inline-flex;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\t\ttransition: background-color 0.2s, border-color 0.2s;\n\t}\n\n\t.custom-checkbox .checkbox-text {\n\t\tfont-size: 12px;\n\t\tmargin-top: 1px;\n\t\tcolor: inherit;\n\t}\n\n\t.custom-checkbox .checkmark::after {\n\t\tcontent: '';\n\t\twidth: 6px;\n\t\theight: 6px;\n\t\tbackground-color: var(--color-accent);\n\t\tborder-radius: 1px;\n\t\tdisplay: block;\n\t\ttransform: scale(0);\n\t\ttransition: transform 0.2s;\n\t}\n\n\t.list-container .custom-checkbox .checkmark {\n\t\twidth: 13px;\n\t\theight: 13px;\n\t}\n\n\t.list-container .custom-checkbox .checkmark::after {\n\t\twidth: 7px;\n\t\theight: 7px;\n\t}\n\n\t.custom-checkbox input:checked+.checkmark {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.custom-checkbox input:checked+.checkmark::after {\n\t\ttransform: scale(1);\n\t}\n\n\t.param-control input[type=\"range\"] {\n\t\t-webkit-appearance: none;\n\t\tappearance: none;\n\t\twidth: 100%;\n\t\theight: 16px;\n\t\tbackground: var(--profiler-header);\n\t\tborder-radius: 5px;\n\t\tborder: 1px solid var(--profiler-border);\n\t\toutline: none;\n\t\tpadding: 0px;\n\t\tpadding-top: 8px;\n\t}\n\n\t.param-control input[type=\"range\"]::-webkit-slider-thumb {\n\t\t-webkit-appearance: none;\n\t\tappearance: none;\n\t\twidth: 18px;\n\t\theight: 18px;\n\t\tbackground: var(--profiler-background);\n\t\tborder: 1px solid var(--color-accent);\n\t\tborder-radius: 3px;\n\t\tcursor: pointer;\n\t\tmargin-top: -8px;\n\t}\n\n\t.param-control input[type=\"range\"]::-moz-range-thumb {\n\t\twidth: 18px;\n\t\theight: 18px;\n\t\tbackground: var(--profiler-background);\n\t\tborder: 2px solid var(--color-accent);\n\t\tborder-radius: 3px;\n\t\tcursor: pointer;\n\t}\n\n\t.param-control input[type=\"range\"]::-moz-range-track {\n\t\twidth: 100%;\n\t\theight: 16px;\n\t\tbackground: var(--profiler-header);\n\t\tborder-radius: 5px;\n\t\tborder: 1px solid var(--profiler-border);\n\t}\n\n\t/* Override .param-control styles for mini-panel-content */\n\t.mini-panel-content input,\n\t.mini-panel-content select,\n\t.mini-panel-content button {\n\t\tpadding: 2px 4px;\n\t\theight: 21px;\n\t\tline-height: 1.4;\n\t\tpadding-top: 4px;\n\t}\n\n\t.mini-panel-content .param-control input,\n\t.mini-panel-content .param-control select,\n\t.mini-panel-content .param-control button {\n\t\tbackground-color: #1e1e24c2;\n\t\tline-height: 1.0;\n\t}\n\n\t.mini-panel-content .param-control select {\n\t\tpadding: 2px 2px;\n\t\tpadding-top: 3px;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"number\"]::-webkit-outer-spin-button,\n\t.mini-panel-content .param-control input[type=\"number\"]::-webkit-inner-spin-button {\n\t\t-webkit-appearance: none;\n\t\tmargin: 0;\n\t}\n\n\t.mini-panel-content .param-control input[type=\"number\"] {\n\t\t-moz-appearance: textfield;\n\t}\n\n\t.mini-panel-content .list-item-cell span {\n\t\tposition: relative;\n\t\ttop: 1px;\n\t\tmargin-left: 2px;\n\t}\n\n\t.list-container.parameters .list-item-cell:first-child .value {\n\t\toverflow: hidden;\n\t\ttext-overflow: ellipsis;\n\t\twhite-space: nowrap;\n\t}\n\n\t.list-container.parameters .list-item-cell:first-child .value:has(> .info-icon) {\n\t\tposition: relative;\n\t\tpadding-right: 20px;\n\t}\n\n\t.list-container.parameters .list-item-cell:first-child .value > .info-icon {\n\t\tposition: absolute;\n\t\ttop: calc(50% - 8px);\n\t\tright: 0;\n\t}\n\n\t.mini-panel-content .custom-checkbox .checkmark {\n\t\twidth: 11px;\n\t\theight: 11px;\n\t\tmargin-bottom: 2px;\n\t\twill-change: transform;\n\t}\n\n\t.mini-panel-content .list-container.parameters .list-item-row:not(.collapsible) {\n\t\tmargin-bottom: 2px;\n\t}\n\n\t.mini-panel-content .list-container.parameters .list-item-wrapper:has(> .list-children-container.closed) + .list-item-wrapper {\n\t\tmargin-top: 2px;\n\t}\n\n\t.mini-panel-content .list-container.parameters .list-children-container > .list-item-wrapper:first-child:has(> .list-item-row:not(.collapsible)) {\n\t\tmargin-top: 2px;\n\t}\n\n\t.mini-panel-content .list-container.parameters .list-children-container > .list-item-wrapper:last-child:has(> .list-item-row:not(.collapsible)) {\n\t\tmargin-bottom: 4px;\n\t}\n\n\t@media screen and (max-width: 450px) and (orientation: portrait) {\n\n\t\t.console-filter-input {\n\t\t\tmax-width: 100px;\n\t\t}\n\n\t}\n\n\t/* Touch device optimizations */\n\t@media (hover: none) and (pointer: coarse) {\n\n\t\t.panel-resizer {\n\t\t\ttop: -10px !important;\n\t\t\theight: 20px !important;\n\t\t}\n\n\t\t.profiler-panel.position-top .panel-resizer {\n\t\t\ttop: auto !important;\n\t\t\tbottom: -10px !important;\n\t\t\theight: 20px !important;\n\t\t}\n\n\t\t.profiler-panel.position-left .panel-resizer {\n\t\t\tright: -10px !important;\n\t\t\twidth: 20px !important;\n\t\t\theight: 100% !important;\n\t\t}\n\n\t\t.profiler-panel.position-right .panel-resizer {\n\t\t\tleft: -10px !important;\n\t\t\twidth: 20px !important;\n\t\t\theight: 100% !important;\n\t\t}\n\n\t\t.detached-tab-resizer-top,\n\t\t.detached-tab-resizer-bottom {\n\t\t\theight: 10px !important;\n\t\t}\n\n\t\t.detached-tab-resizer-left,\n\t\t.detached-tab-resizer-right {\n\t\t\twidth: 10px !important;\n\t\t}\n\n\t}\n\n\t.drag-preview-indicator {\n\t\tposition: absolute;\n\t\tbackground-color: rgba(0, 170, 255, 0.2);\n\t\tborder: 2px dashed var(--color-accent);\n\t\tz-index: 999;\n\t\tpointer-events: none;\n\t\ttransition: all 0.2s ease-out;\n\t}\n\n\t/* Detached Tab Windows */\n\t.detached-tab-panel {\n\t\tposition: absolute;\n\t\twidth: 500px;\n\t\theight: 400px;\n\t\tbackground: var(--profiler-background);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tborder-radius: 8px;\n\t\tbox-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);\n\t\tz-index: 1002;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tbackdrop-filter: blur(10px);\n\t\toverflow: hidden;\n\t\topacity: 1;\n\t\tvisibility: visible;\n\t\ttransition: opacity 0.2s, visibility 0.2s;\n\t\tfont-family: var(--font-mono);\n\t\tfont-size: 13px;\n\t}\n\n\n\t.detached-tab-header {\n\t\tbackground: var(--profiler-header-background);\n\t\tpadding: 0 3px 0 10px;\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 13px;\n\t\tcolor: var(--text-primary);\n\t\tfont-weight: 600;\n\t\tdisplay: flex;\n\t\tjustify-content: space-between;\n\t\talign-items: center;\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t\tcursor: grab;\n\t\tuser-select: none;\n\t\theight: 32px;\n\t\tflex-shrink: 0;\n\t\t-webkit-font-smoothing: antialiased;\n\t\t-moz-osx-font-smoothing: grayscale;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-header:active {\n\t\tcursor: grabbing;\n\t}\n\n\t.detached-header-controls {\n\t\tdisplay: flex;\n\t\tgap: 5px;\n\t}\n\n\t.detached-reattach-btn {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tcolor: var(--text-secondary);\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 18px;\n\t\tline-height: 1;\n\t\tcursor: pointer;\n\t\tpadding: 4px 8px;\n\t\tborder-radius: 4px;\n\t\ttransition: all 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\t-webkit-font-smoothing: antialiased;\n\t\t-moz-osx-font-smoothing: grayscale;\n\t}\n\n\t.detached-reattach-btn:hover {\n\t\tbackground: rgba(0, 170, 255, 0.2);\n\t\tcolor: var(--color-accent);\n\t}\n\n\t.detached-tab-content {\n\t\tflex: 1;\n\t\toverflow: hidden;\n\t\tposition: relative;\n\t\tbackground: var(--profiler-background);\n\t}\n\n\n\t.detached-tab-content .profiler-content {\n\t\tdisplay: flex !important;\n\t\tflex-direction: column !important;\n\t\theight: 100%;\n\t\tvisibility: visible !important;\n\t\topacity: 1 !important;\n\t\tposition: relative !important;\n\t}\n\n\t.detached-tab-content .profiler-content > * {\n\t\tfont-family: var(--font-mono);\n\t\tcolor: var(--text-primary);\n\t}\n\n\t.detached-tab-resizer {\n\t\tposition: absolute;\n\t\tbottom: 0;\n\t\tright: 0;\n\t\twidth: 20px;\n\t\theight: 20px;\n\t\tcursor: nwse-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-resizer::after {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tbottom: 2px;\n\t\tright: 2px;\n\t\twidth: 12px;\n\t\theight: 12px;\n\t\tborder-right: 2px solid var(--profiler-border);\n\t\tborder-bottom: 2px solid var(--profiler-border);\n\t\tborder-bottom-right-radius: 6px;\n\t\topacity: 0.5;\n\t}\n\n\t.detached-tab-resizer:hover::after {\n\t\topacity: 1;\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t/* Edge resizers */\n\t.detached-tab-resizer-top {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\tright: 0;\n\t\theight: 5px;\n\t\tcursor: ns-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-resizer-right {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tright: 0;\n\t\tbottom: 0;\n\t\twidth: 5px;\n\t\tcursor: ew-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-resizer-bottom {\n\t\tposition: absolute;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\tright: 0;\n\t\theight: 5px;\n\t\tcursor: ns-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t.detached-tab-resizer-left {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\tbottom: 0;\n\t\twidth: 5px;\n\t\tcursor: ew-resize;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t}\n\n\t/* Input number spin buttons - hide arrows */\n\t/* Chrome, Safari, Edge, Opera */\n\t.profiler-panel input[type=\"number\"]::-webkit-outer-spin-button,\n\t.profiler-panel input[type=\"number\"]::-webkit-inner-spin-button,\n\t.detached-tab-content input[type=\"number\"]::-webkit-outer-spin-button,\n\t.detached-tab-content input[type=\"number\"]::-webkit-inner-spin-button {\n\t\t-webkit-appearance: none;\n\t\tmargin: 0;\n\t}\n\n\t/* Firefox */\n\t.profiler-panel input[type=\"number\"],\n\t.detached-tab-content input[type=\"number\"] {\n\t\t-moz-appearance: textfield;\n\t}\n\n\t.panel-action-btn {\n\t\tbackground: transparent;\n\t\tcolor: var(--text-primary);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tborder-radius: 4px;\n\t\tpadding: 6px 12px;\n\t\tcursor: pointer;\n\t\tfont-family: var(--font-family);\n\t\tfont-size: 12px;\n\t\ttransition: background-color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t}\n\n\t.panel-action-btn:hover {\n\t\tbackground-color: rgba(255, 255, 255, 0.05);\n\t}\n\n\t.node-canvas-wrapper {\n\t\ttouch-action: none;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-detach-btn {\n\t\tposition: absolute;\n\t\ttop: 5px;\n\t\tright: 5px;\n\t\tbackground: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px;\n\t\tcursor: pointer;\n\t\topacity: 1;\n\t\ttransition: background-color 0.2s, border-color 0.2s, color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tz-index: 10;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-detach-btn:hover {\n\t\tbackground-color: var(--color-accent);\n\t\tborder-color: var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-fullscreen-btn {\n\t\tposition: absolute;\n\t\tbottom: 5px;\n\t\tright: 5px;\n\t\tbackground: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px;\n\t\tcursor: pointer;\n\t\topacity: 1;\n\t\ttransition: background-color 0.2s, border-color 0.2s, color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tz-index: 10;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-fullscreen-btn:hover {\n\t\tbackground-color: var(--color-accent);\n\t\tborder-color: var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t.profiler-panel.maximized .node-canvas-fullscreen-btn {\n\t\tdisplay: none;\n\t}\n\n\t.toolbar {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: space-between;\n\t\theight: 32px;\n\t\tpadding: 4px 6px;\n\t\tborder-bottom: 1px solid var(--profiler-border);\n\t\tbackground: var(--profiler-header-background);\n\t\tflex-shrink: 0;\n\t\tbox-sizing: border-box;\n\t\tgap: 16px;\n\t}\n\n\t.toolbar span {\n\t\tcolor: var(--text-secondary);\n\t\tfont-size: 12px;\n\t\tfont-weight: 600;\n\t}\n\n\t.toolbar .custom-checkbox .checkmark {\n\t\twidth: 12px;\n\t\theight: 12px;\n\t\tborder-radius: 4px;\n\t}\n\n\t.viewer-content .toolbar {\n\t\tjustify-content: flex-end;\n\t}\n\n\t.viewer-back-btn {\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tcolor: var(--text-secondary);\n\t\tcursor: pointer;\n\t\tfont-size: 16px;\n\t\tline-height: 1;\n\t\tpadding: 4px 8px;\n\t\tborder-radius: 4px;\n\t\tmargin-right: auto;\n\t\ttransition: color 0.2s, background-color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t}\n\n\t.viewer-back-btn:hover {\n\t\tcolor: var(--text-primary);\n\t\tbackground-color: rgba(255, 255, 255, 0.05);\n\t}\n\n\tselect {\n\t\tcolor-scheme: dark;\n\t}\n\n\tselect option,\n\toption {\n\t\tbackground-color: #1e1e24;\n\t\tcolor: var(--text-primary);\n\t}\n\n\t.select {\n\t\tbackground: var(--profiler-background);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px 16px 2px 6px;\n\t\tfont-family: var(--font-mono);\n\t\tfont-size: 12px;\n\t\toutline: none;\n\t\tcursor: pointer;\n\t\tcolor-scheme: dark;\n\t\tappearance: none;\n\t\t-webkit-appearance: none;\n\t\t-moz-appearance: none;\n\t\tbackground-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e0e0e0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\");\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: right 5px center;\n\t\tbackground-size: 10px;\n\t}\n\n\t.select:focus {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.full-viewer-container {\n\t\tdisplay: none;\n\t\tflex-grow: 1;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden;\n\t\tposition: relative;\n\t\ttouch-action: none;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-split-btn {\n\t\tposition: absolute;\n\t\ttop: 5px;\n\t\tleft: 5px;\n\t\tbackground: rgba(30, 30, 36, 0.85);\n\t\tborder: 1px solid var(--profiler-border);\n\t\tcolor: var(--text-primary);\n\t\tborder-radius: 4px;\n\t\tpadding: 4px;\n\t\tcursor: pointer;\n\t\topacity: 1;\n\t\ttransition: background-color 0.2s, border-color 0.2s, color 0.2s;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tz-index: 10;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-split-btn:hover {\n\t\tbackground-color: var(--color-accent);\n\t\tborder-color: var(--color-accent);\n\t\tcolor: white;\n\t}\n\n\t.node-canvas-wrapper .node-canvas-split-btn.active,\n\t.node-canvas-wrapper .node-canvas-fullscreen-btn.active {\n\t\tbackground-color: var(--color-accent) !important;\n\t\tborder-color: var(--color-accent) !important;\n\t\tcolor: white !important;\n\t}\n\n\t.split-screen-overlay {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tpointer-events: none !important;\n\t\tz-index: 999;\n\t\ttouch-action: none;\n\t\toverflow: hidden;\n\t}\n\n\t.split-screen-line {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tbottom: 0;\n\t\twidth: 1px;\n\t\tleft: 50%;\n\t\tbackground-color: transparent;\n\t\t/*background-color: rgba(255, 255, 255, 0.25);\n\t\tbox-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);*/\n\t\tcursor: ew-resize;\n\t\tpointer-events: auto !important;\n\t\tz-index: 10;\n\t\ttouch-action: none;\n\t\ttransition: background-color 0.15s ease-out;\n\t}\n\n\t.split-screen-line:hover,\n\t.split-screen-line:active,\n\t.split-screen-line.active {\n\t\tbackground-color: var(--color-accent);\n\t}\n\n\t.split-screen-line::before {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tbottom: 0;\n\t\tleft: -12px;\n\t\twidth: 25px;\n\t\tbackground: transparent;\n\t\tcursor: ew-resize;\n\t}\n\n\t/* Grid Mode styles for List component */\n\t.list-scroll-wrapper:has(> .list-container.grid-mode) {\n\t\twidth: 100% !important;\n\t}\n\n\t.list-container.grid-mode {\n\t\tmin-width: 0 !important;\n\t\twidth: 100% !important;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.list-container.grid-mode .list-header {\n\t\tdisplay: none !important;\n\t}\n\n\t.list-container.grid-mode .list-children-container {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\tgap: 15px;\n\t\tpadding-left: 0 !important;\n\t\tmargin-top: 10px;\n\t\tmargin-bottom: 15px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.list-container.grid-mode .list-children-container > .list-item-wrapper {\n\t\tdisplay: inline-block;\n\t\twidth: 160px;\n\t\tmargin: 0;\n\t}\n\n\t.list-container.grid-mode .list-children-container > .list-item-wrapper > .list-item-row {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\talign-items: center;\n\t\tjustify-content: flex-start;\n\t\t/*background-color: var(--profiler-header);\n\t\tborder: 1px solid var(--profiler-border);*/\n\t\tborder-radius: 6px;\n\t\tpadding: 8px;\n\t\tgap: 8px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t\tgrid-template-columns: none !important;\n\t}\n\n\t.list-container.grid-mode .list-children-container > .list-item-wrapper > .list-item-row > .list-item-cell:first-child {\n\t\twidth: 140px;\n\t\theight: 140px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tpadding: 0;\n\t}\n\n\t.list-container.grid-mode .list-children-container > .list-item-wrapper > .list-item-row > .list-item-cell:not(:first-child) {\n\t\twidth: 100%;\n\t\ttext-align: center !important;\n\t\tfont-size: 11px;\n\t\tfont-weight: 500;\n\t\tcolor: var(--text-primary);\n\t\twhite-space: normal;\n\t\tword-break: break-all;\n\t\tjustify-content: center !important;\n\t}\n\n\t/* Timeline Info & Details */\n\t.timeline-detail-block {\n\t\tfont-size: 11px;\n\t\tmargin-left: 8px;\n\t\tcolor: var(--text-secondary);\n\t\topacity: 1;\n\t}\n\n\t.timeline-detail-key,\n\t.timeline-detail-sep,\n\t.timeline-call-count {\n\t\topacity: 0.5;\n\t}\n\n\t.timeline-detail-value {\n\t\tcolor: var(--text-secondary);\n\t\topacity: 1;\n\t}\n\n\t.timeline-info-group {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tmargin-left: 12px;\n\t\tflex-shrink: 0;\n\t}\n\n\t.timeline-info-dot {\n\t\twidth: 6px;\n\t\theight: 6px;\n\t\tborder-radius: 50%;\n\t\tmargin-right: 6px;\n\t\tflex-shrink: 0;\n\t}\n\n\t.timeline-info-dot.fps {\n\t\tbackground-color: var(--color-fps);\n\t}\n\n\t.timeline-info-dot.call {\n\t\tbackground-color: var(--color-call);\n\t}\n\n\t.timeline-info-dot.red {\n\t\tbackground-color: var(--color-red);\n\t}\n\n}\n`;\n\n\t\tconst styleElement = document.createElement( 'style' );\n\n\t\tif ( nonce ) {\n\n\t\t\tstyleElement.nonce = nonce;\n\n\t\t}\n\n\t\tstyleElement.textContent = css;\n\n\t\tcontainer.appendChild( styleElement );\n\n\t}\n\n}\n","export class Graph {\n\n\tconstructor( maxPoints = 512 ) {\n\n\t\tthis.maxPoints = maxPoints;\n\t\tthis.lines = {};\n\t\tthis.limit = 0;\n\t\tthis.limitIndex = 0;\n\n\t\tthis.domElement = document.createElement( 'canvas' );\n\t\tthis.domElement.setAttribute( 'class', 'graph-canvas' );\n\n\t\tthis.ctx = this.domElement.getContext( '2d' );\n\n\t\tthis.width = 0;\n\t\tthis.height = 0;\n\t\tthis.devicePixelRatio = window.devicePixelRatio || 1;\n\n\t}\n\n\tresize( width, height ) {\n\n\t\tthis.width = width;\n\t\tthis.height = height;\n\n\t\tthis.devicePixelRatio = window.devicePixelRatio || 1;\n\t\tthis.domElement.width = width * this.devicePixelRatio;\n\t\tthis.domElement.height = height * this.devicePixelRatio;\n\n\t\tthis.draw();\n\n\t}\n\n\taddLine( id, color ) {\n\n\t\tthis.lines[ id ] = {\n\t\t\tcolor: color,\n\t\t\tresolved: null,\n\t\t\tpoints: []\n\t\t};\n\n\t}\n\n\taddPoint( lineId, value ) {\n\n\t\tconst line = this.lines[ lineId ];\n\t\tif ( ! line ) return;\n\n\t\tline.points.push( value );\n\t\tif ( line.points.length > this.maxPoints ) {\n\n\t\t\tline.points.shift();\n\n\t\t}\n\n\t\tif ( value > this.limit ) {\n\n\t\t\tthis.limit = value;\n\t\t\tthis.limitIndex = 0;\n\n\t\t}\n\n\t}\n\n\tresetLimit() {\n\n\t\tthis.limit = 0;\n\t\tthis.limitIndex = 0;\n\n\t}\n\n\tupdate() {\n\n\t\tconst width = this.domElement.clientWidth;\n\t\tconst height = this.domElement.clientHeight;\n\n\t\tif ( width === 0 || height === 0 ) return;\n\n\t\tif ( width !== this.width || height !== this.height ) {\n\n\t\t\tthis.resize( width, height );\n\n\t\t} else {\n\n\t\t\tthis.draw();\n\n\t\t}\n\n\t\tif ( this.limitIndex ++ > this.maxPoints ) {\n\n\t\t\tthis.resetLimit();\n\n\t\t}\n\n\t}\n\n\tdraw() {\n\n\t\tconst ctx = this.ctx;\n\t\tconst dpr = this.devicePixelRatio;\n\t\tconst width = this.width;\n\t\tconst height = this.height;\n\n\t\tctx.clearRect( 0, 0, width * dpr, height * dpr );\n\n\t\tif ( width === 0 || height === 0 ) return;\n\n\t\tctx.save();\n\t\tctx.scale( dpr, dpr );\n\n\t\tconst pointStep = width / ( this.maxPoints - 1 );\n\n\t\tfor ( const id in this.lines ) {\n\n\t\t\tconst line = this.lines[ id ];\n\t\t\tif ( line.points.length === 0 ) continue;\n\n\t\t\tif ( ! line.resolved ) {\n\n\t\t\t\tline.resolved = this._resolveColor( line.color );\n\n\t\t\t}\n\n\t\t\tconst resolved = line.resolved;\n\t\t\tconst drawColor = resolved ? resolved.color : '#ffffff';\n\t\t\tconst offset = width - ( ( line.points.length - 1 ) * pointStep );\n\n\t\t\t// 1. Draw fill (with opacity)\n\t\t\tlet fillStyle = drawColor;\n\n\t\t\tif ( height > 0 ) {\n\n\t\t\t\tconst gradient = ctx.createLinearGradient( 0, 0, 0, height );\n\t\t\t\tgradient.addColorStop( 0, drawColor );\n\t\t\t\tgradient.addColorStop( 1, ( resolved && resolved.transparent ) || 'rgba(0,0,0,0)' );\n\t\t\t\tfillStyle = gradient;\n\n\t\t\t}\n\n\t\t\tctx.fillStyle = fillStyle;\n\t\t\tctx.globalAlpha = 0.4;\n\t\t\tctx.beginPath();\n\t\t\tctx.moveTo( offset, height );\n\t\t\tfor ( let i = 0; i < line.points.length; i ++ ) {\n\n\t\t\t\tconst x = offset + i * pointStep;\n\t\t\t\tconst y = this.limit === 0 ? height : height - ( line.points[ i ] / this.limit ) * height;\n\t\t\t\tctx.lineTo( x, y );\n\n\t\t\t}\n\n\t\t\tctx.lineTo( offset + ( line.points.length - 1 ) * pointStep, height );\n\t\t\tctx.closePath();\n\t\t\tctx.fill();\n\n\t\t\t// 2. Draw stroke (full opacity)\n\t\t\tctx.strokeStyle = drawColor;\n\t\t\tctx.lineWidth = 2;\n\t\t\tctx.globalAlpha = 1.0;\n\t\t\tctx.beginPath();\n\t\t\tfor ( let i = 0; i < line.points.length; i ++ ) {\n\n\t\t\t\tconst x = offset + i * pointStep;\n\t\t\t\tconst y = this.limit === 0 ? height : height - ( line.points[ i ] / this.limit ) * height;\n\t\t\t\tif ( i === 0 ) {\n\n\t\t\t\t\tctx.moveTo( x, y );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tctx.lineTo( x, y );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tctx.stroke();\n\n\t\t}\n\n\t\tctx.restore();\n\n\t}\n\n\t_resolveColor( color ) {\n\n\t\tlet resolved = color;\n\n\t\tif ( color.startsWith( 'var(' ) ) {\n\n\t\t\tconst varName = color.slice( 4, - 1 ).trim();\n\t\t\tresolved = getComputedStyle( this.domElement ).getPropertyValue( varName ).trim();\n\n\t\t\tif ( ! resolved ) {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tlet transparentColor = 'rgba(0,0,0,0)';\n\n\t\tif ( resolved.startsWith( '#' ) ) {\n\n\t\t\tconst hex = resolved.substring( 0, 7 );\n\t\t\ttransparentColor = hex + '00';\n\n\t\t} else if ( resolved.startsWith( 'rgb' ) ) {\n\n\t\t\tconst match = resolved.match( /^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*[\\d.]+)?\\)$/ );\n\n\t\t\tif ( match ) {\n\n\t\t\t\ttransparentColor = `rgba(${match[ 1 ]}, ${match[ 2 ]}, ${match[ 3 ]}, 0)`;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn {\n\t\t\tcolor: resolved,\n\t\t\ttransparent: transparentColor\n\t\t};\n\n\t}\n\n\tdispose() {\n\n\t}\n\n}\n","import { REVISION } from 'three/webgpu';\n\nconst STORAGE_KEY = 'threejs-inspector';\n\nfunction getItem( id ) {\n\n\tif ( typeof localStorage === 'undefined' ) return {};\n\n\tconst data = JSON.parse( localStorage.getItem( STORAGE_KEY ) || '{}' );\n\n\tif ( data.version !== REVISION ||\n\t\t data.settings && ( data.settings.storage === 'url' && data.settings.url !== location.href ) ) {\n\n\t\tlocalStorage.removeItem( STORAGE_KEY );\n\n\t\treturn {};\n\n\t}\n\n\treturn data[ id ] || {};\n\n}\n\nfunction setItem( id, state ) {\n\n\tif ( typeof localStorage === 'undefined' ) return;\n\n\tconst data = JSON.parse( localStorage.getItem( STORAGE_KEY ) || '{}' );\n\n\tif ( state === null ) {\n\n\t\tdelete data[ id ];\n\n\t} else {\n\n\t\tdata[ id ] = state;\n\n\t}\n\n\tdata.settings = data.settings || {};\n\tdata.settings.url = data.settings.url || location.href;\n\tdata.settings.storage = data.settings.storage || 'url';\n\tdata.version = REVISION;\n\n\tlocalStorage.setItem( STORAGE_KEY, JSON.stringify( data ) );\n\n}\n\nexport { getItem, setItem };\n","import { EventDispatcher } from 'three';\nimport { Style } from './Style.js';\nimport { Graph } from './Graph.js';\nimport { getItem, setItem } from '../Storage.js';\n\nexport class Profiler extends EventDispatcher {\n\n\tconstructor( inspector, options = {} ) {\n\n\t\tsuper();\n\n\t\tthis.inspector = inspector;\n\t\tthis.nonce = options.nonce ?? inspector?.nonce ?? null;\n\t\tthis.tabs = {};\n\t\tthis.activeTabId = null;\n\t\tthis.isResizing = false;\n\t\tthis.lastHeightBottom = 350; // Height for bottom position\n\t\tthis.lastWidthRight = 450; // Width for right position\n\t\tthis.position = 'bottom'; // 'bottom' or 'right'\n\t\tthis.detachedWindows = []; // Array to store detached tab windows\n\t\tthis.maxZIndex = 1002; // Track the highest z-index for detached windows (starts at base z-index from CSS)\n\t\tthis.nextTabOriginalIndex = 0; // Track the original order of tabs as they are added\n\n\t\tthis.horizontalAlign = 'right'; // 'left' or 'right'\n\t\tthis.verticalAlign = 'top'; // 'top' or 'bottom'\n\n\t\tthis.setupShell();\n\t\tthis.setupResizing();\n\n\t\tStyle.init( this.domElement, this.nonce );\n\n\t\tthis.updateWidgetPosition();\n\n\t\t// Setup window resize listener and update mobile status\n\t\tthis.setupWindowResizeListener();\n\n\t\t// Setup orientation change listener for mobile devices\n\t\tthis.setupOrientationListener();\n\n\t\tthis.checkHeaderScroll();\n\n\t\tthis.panel.addEventListener( 'transitionend', ( e ) => {\n\n\t\t\tif ( e.target === this.panel && ( e.propertyName === 'width' || e.propertyName === 'height' || e.propertyName === 'transform' ) ) {\n\n\t\t\t\tthis.checkHeaderScroll();\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tgetSize() {\n\n\t\tif ( this.panel.classList.contains( 'visible' ) === false || this.panel.classList.contains( 'no-tabs' ) ) {\n\n\t\t\treturn { width: 0, height: 0 };\n\n\t\t}\n\n\t\tif ( this.position === 'right' ) {\n\n\t\t\treturn { width: this.panel.offsetWidth, height: 0 };\n\n\t\t} else {\n\n\t\t\treturn { width: 0, height: this.panel.offsetHeight };\n\n\t\t}\n\n\t}\n\n\tget isMobile() {\n\n\t\treturn this.detectMobile();\n\n\t}\n\n\tget isSmallScreen() {\n\n\t\treturn window.innerWidth <= 768;\n\n\t}\n\n\tdetectMobile() {\n\n\t\t// Check for mobile devices\n\t\tconst userAgent = navigator.userAgent || navigator.vendor || window.opera;\n\t\tconst isMobileUA = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test( userAgent );\n\t\tconst isTouchDevice = ( 'ontouchstart' in window ) || ( navigator.maxTouchPoints > 0 );\n\n\t\treturn isMobileUA || ( isTouchDevice && this.isSmallScreen );\n\n\t}\n\n\tsetupOrientationListener() {\n\n\t\tconst handleOrientationChange = () => {\n\n\t\t\tif ( ! this.isMobile ) return;\n\n\t\t\t// Check if device is in landscape or portrait mode\n\t\t\tconst isLandscape = window.innerWidth > window.innerHeight;\n\n\t\t\t// In landscape mode, use right position (vertical panel)\n\t\t\t// In portrait mode, use bottom position (horizontal panel)\n\t\t\tconst targetPosition = isLandscape ? 'right' : 'bottom';\n\n\t\t\tif ( this.position !== targetPosition ) {\n\n\t\t\t\tthis.setPosition( targetPosition );\n\n\t\t\t}\n\n\t\t};\n\n\t\t// Initial check\n\t\thandleOrientationChange();\n\n\t\t// Listen for orientation changes\n\t\twindow.addEventListener( 'orientationchange', handleOrientationChange );\n\t\twindow.addEventListener( 'resize', handleOrientationChange );\n\n\t}\n\n\tsetupWindowResizeListener() {\n\n\t\tconst constrainDetachedWindows = () => {\n\n\t\t\tthis.detachedWindows.forEach( detachedWindow => {\n\n\t\t\t\tthis.constrainWindowToBounds( detachedWindow.panel );\n\n\t\t\t} );\n\n\t\t};\n\n\t\tconst constrainMainPanel = () => {\n\n\t\t\t// Skip if panel is maximized (it should always fill the screen)\n\t\t\tif ( this.panel.classList.contains( 'maximized' ) ) return;\n\n\t\t\tconst windowWidth = window.innerWidth;\n\t\t\tconst windowHeight = window.innerHeight;\n\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tconst currentHeight = this.panel.offsetHeight;\n\t\t\t\tconst maxHeight = windowHeight - 50; // Leave 50px margin\n\n\t\t\t\tif ( currentHeight > maxHeight ) {\n\n\t\t\t\t\tthis.panel.style.height = `${ maxHeight }px`;\n\t\t\t\t\tthis.lastHeightBottom = maxHeight;\n\n\t\t\t\t}\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\tconst currentWidth = this.panel.offsetWidth;\n\t\t\t\tconst maxWidth = windowWidth - 50; // Leave 50px margin\n\n\t\t\t\tif ( currentWidth > maxWidth ) {\n\n\t\t\t\t\tthis.panel.style.width = `${ maxWidth }px`;\n\t\t\t\t\tthis.lastWidthRight = maxWidth;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\t// Listen for window resize events\n\t\twindow.addEventListener( 'resize', () => {\n\n\t\t\tif ( this.isSmallScreen ) {\n\n\t\t\t\tthis.floatingBtn.style.display = 'none';\n\t\t\t\tthis.panel.classList.add( 'hide-position-toggle' );\n\n\t\t\t} else {\n\n\t\t\t\tthis.floatingBtn.style.display = '';\n\t\t\t\tthis.panel.classList.remove( 'hide-position-toggle' );\n\n\t\t\t}\n\n\t\t\tif ( this.isMobile ) {\n\n\t\t\t\tthis.panel.classList.add( 'is-mobile' );\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.classList.remove( 'is-mobile' );\n\n\t\t\t}\n\n\t\t\tconstrainDetachedWindows();\n\t\t\tconstrainMainPanel();\n\t\t\tthis.checkHeaderScroll();\n\t\t\tthis.notifyLayoutChange();\n\n\t\t} );\n\n\t}\n\n\tconstrainWindowToBounds( windowPanel ) {\n\n\t\tconst windowWidth = window.innerWidth;\n\t\tconst windowHeight = window.innerHeight;\n\n\t\tconst panelWidth = windowPanel.offsetWidth;\n\t\tconst panelHeight = windowPanel.offsetHeight;\n\n\t\tlet left = parseFloat( windowPanel.style.left ) || windowPanel.offsetLeft || 0;\n\t\tlet top = parseFloat( windowPanel.style.top ) || windowPanel.offsetTop || 0;\n\n\t\t// Allow window to extend half its width/height outside the screen\n\t\tconst halfWidth = panelWidth / 2;\n\t\tconst halfHeight = panelHeight / 2;\n\n\t\t// Constrain horizontal position (allow half width to extend beyond right edge)\n\t\tif ( left + panelWidth > windowWidth + halfWidth ) {\n\n\t\t\tleft = windowWidth + halfWidth - panelWidth;\n\n\t\t}\n\n\t\t// Constrain horizontal position (allow half width to extend beyond left edge)\n\t\tif ( left < - halfWidth ) {\n\n\t\t\tleft = - halfWidth;\n\n\t\t}\n\n\t\t// Constrain vertical position (allow half height to extend beyond bottom edge)\n\t\tif ( top + panelHeight > windowHeight + halfHeight ) {\n\n\t\t\ttop = windowHeight + halfHeight - panelHeight;\n\n\t\t}\n\n\t\t// Constrain vertical position (allow half height to extend beyond top edge)\n\t\tif ( top < - halfHeight ) {\n\n\t\t\ttop = - halfHeight;\n\n\t\t}\n\n\t\t// Apply constrained position\n\t\twindowPanel.style.left = `${ left }px`;\n\t\twindowPanel.style.top = `${ top }px`;\n\n\t}\n\n\tsetupShell() {\n\n\t\tthis.domElement = document.createElement( 'div' );\n\n\t\tthis.domElement.classList.add( 'three-inspector' );\n\n\t\tthis.domElement.addEventListener( 'keydown', ( e ) => e.stopPropagation() );\n\t\tthis.domElement.addEventListener( 'keyup', ( e ) => e.stopPropagation() );\n\n\t\tthis.toggleButton = document.createElement( 'button' );\n\t\tthis.toggleButton.classList.add( 'profiler-toggle' );\n\t\tthis.toggleButton.innerHTML = `\n<span class=\"builtin-tabs-container\"></span>\n<span class=\"toggle-text\">\n\t<span class=\"fps-counter\">-</span>\n\t<span class=\"fps-label\">FPS</span>\n</span>\n<span class=\"toggle-icon\">\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"icon icon-tabler icons-tabler-outline icon-tabler-device-ipad-horizontal-search\"><path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M11.5 20h-6.5a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v5.5\" /><path d=\"M9 17h2\" /><path d=\"M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0\" /><path d=\"M20.2 20.2l1.8 1.8\" /></svg>\n\t<span class=\"console-badge-container\">\n\t\t<span class=\"console-badge error\">0</span>\n\t\t<span class=\"console-badge warn\">0</span>\n\t</span>\n</span>\n`;\n\t\tthis.toggleButton.onclick = () => this.togglePanel();\n\n\t\tconst errorBadge = this.toggleButton.querySelector( '.console-badge.error' );\n\t\terrorBadge.style.display = 'none';\n\n\t\tconst warnBadge = this.toggleButton.querySelector( '.console-badge.warn' );\n\t\twarnBadge.style.display = 'none';\n\n\t\tthis.builtinTabsContainer = this.toggleButton.querySelector( '.builtin-tabs-container' );\n\n\t\t// Create mini-panel for builtin tabs (shown when panel is hidden)\n\t\tthis.miniPanel = document.createElement( 'div' );\n\t\tthis.miniPanel.classList.add( 'profiler-mini-panel' );\n\t\tthis.miniPanel.className = 'profiler-mini-panel';\n\n\t\tthis.panel = document.createElement( 'div' );\n\t\tthis.panel.classList.add( 'profiler-panel' );\n\n\t\tconst header = document.createElement( 'div' );\n\t\theader.className = 'profiler-header';\n\n\t\t// Enable horizontal scrolling with vertical mouse wheel\n\t\theader.addEventListener( 'wheel', ( e ) => {\n\n\t\t\tif ( e.deltaY !== 0 ) {\n\n\t\t\t\te.preventDefault();\n\t\t\t\theader.scrollLeft += e.deltaY * .25;\n\n\t\t\t}\n\n\t\t}, { passive: false } );\n\n\t\tthis.tabsContainer = document.createElement( 'div' );\n\t\tthis.tabsContainer.className = 'profiler-tabs';\n\n\t\tconst controls = document.createElement( 'div' );\n\t\tcontrols.className = 'profiler-controls';\n\n\t\tthis.floatingBtn = document.createElement( 'button' );\n\t\tthis.floatingBtn.classList.add( 'floating-btn' );\n\t\tthis.floatingBtn.title = 'Switch to Right Side';\n\t\tthis.floatingBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><line x1=\"15\" y1=\"3\" x2=\"15\" y2=\"21\"></line></svg>';\n\t\tthis.floatingBtn.onclick = () => this.togglePosition();\n\n\t\t// Hide position toggle button on small screens\n\t\tif ( this.isSmallScreen ) {\n\n\t\t\tthis.floatingBtn.style.display = 'none';\n\t\t\tthis.panel.classList.add( 'hide-position-toggle' );\n\n\t\t}\n\n\t\tif ( this.isMobile ) {\n\n\t\t\tthis.panel.classList.add( 'is-mobile' );\n\n\t\t}\n\n\t\tthis.maximizeBtn = document.createElement( 'button' );\n\t\tthis.maximizeBtn.classList.add( 'maximize-btn' );\n\t\tthis.maximizeBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"/></svg>';\n\t\tthis.maximizeBtn.onclick = () => this.toggleMaximize();\n\n\t\tconst hideBtn = document.createElement( 'button' );\n\t\thideBtn.classList.add( 'hide-panel-btn' );\n\t\thideBtn.textContent = '-';\n\t\thideBtn.onclick = () => this.togglePanel();\n\n\t\tcontrols.append( this.floatingBtn, this.maximizeBtn, hideBtn );\n\t\theader.append( this.tabsContainer, controls );\n\n\t\tthis.contentWrapper = document.createElement( 'div' );\n\t\tthis.contentWrapper.className = 'profiler-content-wrapper';\n\n\t\tconst resizer = document.createElement( 'div' );\n\t\tresizer.className = 'panel-resizer';\n\n\t\tthis.panel.append( resizer, header, this.contentWrapper );\n\n\t\tthis.domElement.append( this.toggleButton, this.miniPanel, this.panel );\n\n\t\t// Set initial position class\n\t\tthis.panel.classList.add( `position-${this.position}` );\n\n\t\tif ( this.position === 'right' ) {\n\n\t\t\tthis.toggleButton.classList.add( 'position-right' );\n\t\t\tthis.miniPanel.classList.add( 'position-right' );\n\n\t\t}\n\n\t\t// Create a background performance graph for the toggle button\n\t\tthis.toggleGraph = new Graph( 80 );\n\t\tthis.toggleGraph.addLine( 'fps', '#4c4c6bff' );\n\t\tthis.toggleGraph.domElement.className = 'profiler-toggle-graph';\n\t\tthis.toggleButton.appendChild( this.toggleGraph.domElement );\n\n\t}\n\n\tsetupResizing() {\n\n\t\tconst resizer = this.panel.querySelector( '.panel-resizer' );\n\n\t\tconst onStart = ( e ) => {\n\n\t\t\tthis.isResizing = true;\n\t\t\tthis.panel.classList.add( 'resizing' );\n\t\t\tresizer.setPointerCapture( e.pointerId );\n\t\t\tconst startX = e.clientX;\n\t\t\tconst startY = e.clientY;\n\t\t\tconst startHeight = this.panel.offsetHeight;\n\t\t\tconst startWidth = this.panel.offsetWidth;\n\n\t\t\tconst onMove = ( moveEvent ) => {\n\n\t\t\t\tif ( ! this.isResizing ) return;\n\t\t\t\tmoveEvent.preventDefault();\n\t\t\t\tconst currentX = moveEvent.clientX;\n\t\t\t\tconst currentY = moveEvent.clientY;\n\n\t\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\t\t// Vertical resize for bottom position\n\t\t\t\t\tconst newHeight = startHeight - ( currentY - startY );\n\n\t\t\t\t\tif ( newHeight > 100 && newHeight < window.innerHeight - 50 ) {\n\n\t\t\t\t\t\tthis.panel.style.height = `${ newHeight }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\t\t// Horizontal resize for right position\n\t\t\t\t\tconst newWidth = startWidth - ( currentX - startX );\n\n\t\t\t\t\tif ( newWidth > 200 && newWidth < window.innerWidth - 50 ) {\n\n\t\t\t\t\t\tthis.panel.style.width = `${ newWidth }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis.dispatchEvent( { type: 'resize' } );\n\t\t\t\tthis.checkHeaderScroll();\n\n\t\t\t};\n\n\t\t\tconst onEnd = () => {\n\n\t\t\t\tthis.isResizing = false;\n\t\t\t\tthis.panel.classList.remove( 'resizing' );\n\t\t\t\tresizer.removeEventListener( 'pointermove', onMove );\n\t\t\t\tresizer.removeEventListener( 'pointerup', onEnd );\n\t\t\t\tresizer.removeEventListener( 'pointercancel', onEnd );\n\t\t\t\tif ( ! this.panel.classList.contains( 'maximized' ) ) {\n\n\t\t\t\t\t// Save dimensions based on current position\n\t\t\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\t\t\tthis.lastHeightBottom = this.panel.offsetHeight;\n\n\t\t\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\t\t\tthis.lastWidthRight = this.panel.offsetWidth;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Save layout after resize\n\t\t\t\t\tthis.saveLayout();\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t\tresizer.addEventListener( 'pointermove', onMove );\n\t\t\tresizer.addEventListener( 'pointerup', onEnd );\n\t\t\tresizer.addEventListener( 'pointercancel', onEnd );\n\n\t\t};\n\n\t\tresizer.addEventListener( 'pointerdown', onStart );\n\n\t}\n\n\ttoggleMaximize() {\n\n\t\tif ( this.panel.classList.contains( 'maximized' ) ) {\n\n\t\t\tthis.panel.classList.remove( 'maximized' );\n\t\t\tthis.domElement.classList.remove( 'maximized' );\n\n\t\t\t// Restore size based on current position\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tthis.panel.style.height = `${ this.lastHeightBottom }px`;\n\t\t\t\tthis.panel.style.width = '100%';\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\tthis.panel.style.height = '100%';\n\t\t\t\tthis.panel.style.width = `${ this.lastWidthRight }px`;\n\n\t\t\t}\n\n\t\t\tthis.maximizeBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"/></svg>';\n\n\t\t} else {\n\n\t\t\t// Save current size before maximizing\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tthis.lastHeightBottom = this.panel.offsetHeight;\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\tthis.lastWidthRight = this.panel.offsetWidth;\n\n\t\t\t}\n\n\t\t\tthis.panel.classList.add( 'maximized' );\n\t\t\tthis.domElement.classList.add( 'maximized' );\n\n\t\t\t// Maximize based on current position\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tthis.panel.style.height = '100%';\n\t\t\t\tthis.panel.style.width = '100%';\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\tthis.panel.style.height = '100%';\n\t\t\t\tthis.panel.style.width = '100%';\n\n\t\t\t}\n\n\t\t\tthis.maximizeBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"8\" y=\"8\" width=\"12\" height=\"12\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg>';\n\n\t\t}\n\n\t\tthis.updateWidgetPosition();\n\n\t\tthis.dispatchEvent( { type: 'resize' } );\n\n\t}\n\n\thide() {\n\n\t\tthis.miniPanel.classList.remove( 'visible' );\n\n\t\tthis.miniPanel.querySelectorAll( '.mini-panel-content' ).forEach( content => {\n\n\t\t\tcontent.style.display = 'none';\n\n\t\t} );\n\n\t\tthis.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ).forEach( btn => {\n\n\t\t\tbtn.classList.remove( 'active' );\n\n\t\t} );\n\n\t}\n\n\tshow( tab ) {\n\n\t\tthis.hide();\n\n\t\ttab.builtinButton.classList.add( 'active' );\n\n\t\tif ( ! tab.miniContent.firstChild ) {\n\n\t\t\twhile ( tab.content.firstChild ) {\n\n\t\t\t\ttab.miniContent.appendChild( tab.content.firstChild );\n\n\t\t\t}\n\n\t\t}\n\n\t\ttab.miniContent.style.display = 'block';\n\t\tthis.miniPanel.classList.add( 'visible' );\n\n\t}\n\n\taddTab( tab ) {\n\n\t\tthis.tabs[ tab.id ] = tab;\n\n\t\t// Assign a permanent original index to this tab\n\t\ttab.originalIndex = this.nextTabOriginalIndex ++;\n\n\t\t// Add visual indicator for tabs that cannot be detached\n\t\tif ( tab.allowDetach === false ) {\n\n\t\t\ttab.button.classList.add( 'no-detach' );\n\n\t\t}\n\n\t\t// Set visibility change callback\n\t\ttab.onVisibilityChange = () => this.updatePanelSize();\n\n\t\tthis.setupTabDragAndDrop( tab );\n\n\t\tif ( ! tab.builtin ) {\n\n\t\t\tthis.tabsContainer.appendChild( tab.button );\n\n\t\t}\n\n\t\tthis.contentWrapper.appendChild( tab.content );\n\n\t\t// Apply the current visibility state to the DOM elements\n\t\tif ( ! tab.isVisible ) {\n\n\t\t\ttab.button.style.display = 'none';\n\t\t\ttab.content.style.display = 'none';\n\n\t\t}\n\n\t\t// If tab is builtin, add it to the profiler-toggle button\n\t\tif ( tab.builtin ) {\n\n\t\t\tthis.addBuiltinTab( tab );\n\n\t\t}\n\n\t\t// Set profiler reference\n\t\ttab.profiler = this;\n\n\t\t// Update panel size when tabs change\n\t\tthis.updatePanelSize();\n\n\t\t// If newly added tab matches activeTabId from saved layout, activate it\n\t\tif ( this.activeTabId && tab.id === this.activeTabId ) {\n\n\t\t\tthis.setActiveTab( tab.id );\n\n\t\t}\n\n\t}\n\n\taddBuiltinTab( tab ) {\n\n\t\t// Create a button for the builtin tab in the profiler-toggle\n\t\tconst builtinButton = document.createElement( 'button' );\n\t\tbuiltinButton.className = 'builtin-tab-btn';\n\n\t\t// Use icon if provided, otherwise use first letter\n\t\tif ( tab.icon ) {\n\n\t\t\tbuiltinButton.innerHTML = tab.icon;\n\n\t\t} else {\n\n\t\t\tbuiltinButton.textContent = tab.button.textContent.charAt( 0 ).toUpperCase();\n\n\t\t}\n\n\t\tbuiltinButton.title = tab.button.textContent;\n\n\t\t// Create mini-panel content container for this tab\n\t\tconst miniContent = document.createElement( 'div' );\n\t\tminiContent.className = 'mini-panel-content';\n\t\tminiContent.style.display = 'none';\n\n\t\t// Store references in the tab object\n\t\ttab.builtinButton = builtinButton;\n\t\ttab.miniContent = miniContent;\n\n\t\tthis.miniPanel.appendChild( miniContent );\n\n\t\tbuiltinButton.onclick = ( e ) => {\n\n\t\t\te.stopPropagation(); // Prevent toggle panel from triggering\n\n\t\t\t// Toggle mini-panel for this tab\n\t\t\tconst isCurrentlyActive = miniContent.style.display !== 'none' && miniContent.children.length > 0;\n\n\t\t\tif ( isCurrentlyActive ) {\n\n\t\t\t\tthis.hide();\n\n\t\t\t} else {\n\n\t\t\t\tthis.show( tab );\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.builtinTabsContainer.appendChild( builtinButton );\n\n\t\t// Store references\n\t\ttab.builtinButton = builtinButton;\n\t\ttab.miniContent = miniContent;\n\n\t\t// If the tab was hidden before being added, hide the builtin button\n\t\tif ( ! tab.isVisible ) {\n\n\t\t\tbuiltinButton.style.display = 'none';\n\t\t\tminiContent.style.display = 'none';\n\n\t\t\t// Hide the builtin-tabs-container if all builtin buttons are hidden\n\t\t\tconst hasVisibleBuiltinButtons = Array.from( this.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ) )\n\t\t\t\t.some( btn => btn.style.display !== 'none' );\n\n\t\t\tif ( ! hasVisibleBuiltinButtons ) {\n\n\t\t\t\tthis.builtinTabsContainer.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tremoveTab( tab ) {\n\n\t\tif ( ! tab || this.tabs[ tab.id ] === undefined ) return;\n\n\t\tdelete this.tabs[ tab.id ];\n\n\t\tif ( tab.isDetached && tab.detachedWindow ) {\n\n\t\t\tif ( tab.detachedWindow.panel && tab.detachedWindow.panel.parentNode ) {\n\n\t\t\t\ttab.detachedWindow.panel.parentNode.removeChild( tab.detachedWindow.panel );\n\n\t\t\t}\n\n\t\t\tconst index = this.detachedWindows.indexOf( tab.detachedWindow );\n\n\t\t\tif ( index !== - 1 ) {\n\n\t\t\t\tthis.detachedWindows.splice( index, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( ! tab.builtin ) {\n\n\t\t\tif ( tab.button && tab.button.parentNode ) {\n\n\t\t\t\ttab.button.parentNode.removeChild( tab.button );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( tab.builtinButton && tab.builtinButton.parentNode ) {\n\n\t\t\t\ttab.builtinButton.parentNode.removeChild( tab.builtinButton );\n\n\t\t\t}\n\n\t\t\tif ( tab.miniContent && tab.miniContent.parentNode ) {\n\n\t\t\t\ttab.miniContent.parentNode.removeChild( tab.miniContent );\n\n\t\t\t}\n\n\t\t\t// Clean up builtin container if empty\n\t\t\tconst hasVisibleBuiltinButtons = Array.from( this.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ) )\n\t\t\t\t.some( btn => btn.style.display !== 'none' );\n\n\t\t\tif ( ! hasVisibleBuiltinButtons ) {\n\n\t\t\t\tthis.builtinTabsContainer.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( tab.content && tab.content.parentNode ) {\n\n\t\t\ttab.content.parentNode.removeChild( tab.content );\n\n\t\t}\n\n\t\tif ( this.activeTabId === tab.id ) {\n\n\t\t\tthis.activeTabId = null;\n\n\t\t\t// Try to activate another tab\n\t\t\tconst remainingTabs = Object.values( this.tabs ).filter( t => ! t.isDetached && t.isVisible );\n\n\t\t\tif ( remainingTabs.length > 0 ) {\n\n\t\t\t\tthis.setActiveTab( remainingTabs[ 0 ].id );\n\n\t\t\t} else {\n\n\t\t\t\tthis.updatePanelSize();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.updatePanelSize();\n\n\t\t}\n\n\t\ttab.onVisibilityChange = null;\n\t\ttab.profiler = null;\n\n\t}\n\n\tupdatePanelSize() {\n\n\t\t// Check if there are any visible tabs in the panel\n\t\tconst hasVisibleTabs = Object.values( this.tabs ).some( tab => ! tab.isDetached && tab.isVisible );\n\n\t\t// Add or remove CSS class to indicate no tabs state\n\t\tif ( ! hasVisibleTabs ) {\n\n\t\t\tthis.panel.classList.add( 'no-tabs' );\n\n\t\t\t// If maximized and no tabs, restore to normal size\n\t\t\tif ( this.panel.classList.contains( 'maximized' ) ) {\n\n\t\t\t\tthis.panel.classList.remove( 'maximized' );\n\t\t\t\tthis.domElement.classList.remove( 'maximized' );\n\t\t\t\tthis.maximizeBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"/></svg>';\n\n\t\t\t}\n\n\t\t\t// No tabs visible - set to minimum size\n\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\tthis.panel.style.height = '32px';\n\n\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\t// 45px = width of one button column\n\t\t\t\tthis.panel.style.width = '45px';\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.panel.classList.remove( 'no-tabs' );\n\n\t\t\tif ( Object.keys( this.tabs ).length > 0 ) {\n\n\t\t\t\t// Has tabs - restore to saved size only if we had set it to minimum before\n\t\t\t\tif ( this.position === 'bottom' ) {\n\n\t\t\t\t\tconst currentHeight = parseInt( this.panel.style.height );\n\t\t\t\t\tif ( currentHeight === 32 || currentHeight === 38 ) {\n\n\t\t\t\t\t\tthis.panel.style.height = `${ this.lastHeightBottom }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( this.position === 'right' ) {\n\n\t\t\t\t\tconst currentWidth = parseInt( this.panel.style.width );\n\t\t\t\t\tif ( currentWidth === 45 ) {\n\n\t\t\t\t\t\tthis.panel.style.width = `${ this.lastWidthRight }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.dispatchEvent( { type: 'resize' } );\n\t\tthis.checkHeaderScroll();\n\n\t}\n\n\tcheckHeaderScroll() {\n\n\t\tconst header = this.panel.querySelector( '.profiler-header' );\n\n\t\tif ( header ) {\n\n\t\t\tconst hasScroll = header.scrollWidth > header.clientWidth + 1;\n\n\t\t\tif ( hasScroll ) {\n\n\t\t\t\tthis.panel.classList.add( 'has-horizontal-scroll' );\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.classList.remove( 'has-horizontal-scroll' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tsetupTabDragAndDrop( tab ) {\n\n\t\t// Always handle basic click\n\t\ttab.button.addEventListener( 'click', () => {\n\n\t\t\tif ( ! isDragging ) {\n\n\t\t\t\tthis.setActiveTab( tab.id );\n\n\t\t\t}\n\n\t\t} );\n\n\t\t// Disable drag and drop if tab doesn't allow detach\n\t\tif ( tab.allowDetach === false ) {\n\n\t\t\ttab.button.style.cursor = 'default';\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet isDragging = false;\n\t\tlet startX, startY;\n\t\tlet hasMoved = false;\n\t\tlet previewWindow = null;\n\t\tconst dragThreshold = 10; // pixels to move before starting drag\n\n\t\tconst onDragStart = ( e ) => {\n\n\t\t\tstartX = e.clientX;\n\t\t\tstartY = e.clientY;\n\t\t\tisDragging = false;\n\t\t\thasMoved = false;\n\t\t\ttab.button.setPointerCapture( e.pointerId );\n\n\t\t};\n\n\t\tconst onDragMove = ( e ) => {\n\n\t\t\tconst currentX = e.clientX;\n\t\t\tconst currentY = e.clientY;\n\n\t\t\tconst deltaX = Math.abs( currentX - startX );\n\t\t\tconst deltaY = Math.abs( currentY - startY );\n\n\t\t\tif ( ! isDragging && ( deltaX > dragThreshold || deltaY > dragThreshold ) ) {\n\n\t\t\t\tisDragging = true;\n\t\t\t\ttab.button.style.cursor = 'grabbing';\n\t\t\t\ttab.button.style.opacity = '0.5';\n\t\t\t\ttab.button.style.transform = 'scale(1.05)';\n\n\t\t\t\tpreviewWindow = this.createPreviewWindow( tab, currentX, currentY );\n\t\t\t\tpreviewWindow.style.opacity = '0.8';\n\n\t\t\t}\n\n\t\t\tif ( isDragging && previewWindow ) {\n\n\t\t\t\thasMoved = true;\n\t\t\t\te.preventDefault();\n\n\t\t\t\tpreviewWindow.style.left = `${ currentX - 200 }px`;\n\t\t\t\tpreviewWindow.style.top = `${ currentY - 20 }px`;\n\n\t\t\t}\n\n\t\t};\n\n\t\tconst onDragEnd = () => {\n\n\t\t\tif ( isDragging && hasMoved && previewWindow ) {\n\n\t\t\t\tconst finalX = parseInt( previewWindow.style.left ) + 200;\n\t\t\t\tconst finalY = parseInt( previewWindow.style.top ) + 20;\n\n\t\t\t\tif ( previewWindow.parentNode ) {\n\n\t\t\t\t\tpreviewWindow.parentNode.removeChild( previewWindow );\n\n\t\t\t\t}\n\n\t\t\t\tthis.detachTab( tab, finalX, finalY );\n\n\t\t\t} else if ( ! hasMoved ) {\n\n\t\t\t\tthis.setActiveTab( tab.id );\n\n\t\t\t\tif ( previewWindow && previewWindow.parentNode ) {\n\n\t\t\t\t\tpreviewWindow.parentNode.removeChild( previewWindow );\n\n\t\t\t\t}\n\n\t\t\t} else if ( previewWindow ) {\n\n\t\t\t\tif ( previewWindow.parentNode ) {\n\n\t\t\t\t\tpreviewWindow.parentNode.removeChild( previewWindow );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ttab.button.style.opacity = '';\n\t\t\ttab.button.style.transform = '';\n\t\t\ttab.button.style.cursor = '';\n\t\t\tisDragging = false;\n\t\t\thasMoved = false;\n\t\t\tpreviewWindow = null;\n\n\t\t\ttab.button.removeEventListener( 'pointermove', onDragMove );\n\t\t\ttab.button.removeEventListener( 'pointerup', onDragEnd );\n\t\t\ttab.button.removeEventListener( 'pointercancel', onDragEnd );\n\n\t\t};\n\n\t\ttab.button.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\tif ( this.isMobile && e.pointerType !== 'mouse' ) return;\n\n\t\t\tonDragStart( e );\n\t\t\ttab.button.addEventListener( 'pointermove', onDragMove );\n\t\t\ttab.button.addEventListener( 'pointerup', onDragEnd );\n\t\t\ttab.button.addEventListener( 'pointercancel', onDragEnd );\n\n\t\t} );\n\n\t\t// Set cursor to grab for tabs that can be detached\n\t\ttab.button.style.cursor = 'grab';\n\n\t}\n\n\tcreatePreviewWindow( tab, x, y ) {\n\n\t\tconst windowPanel = document.createElement( 'div' );\n\t\twindowPanel.className = 'detached-tab-panel';\n\t\twindowPanel.style.left = `${ x - 200 }px`;\n\t\twindowPanel.style.top = `${ y - 20 }px`;\n\t\twindowPanel.style.pointerEvents = 'none'; // Preview only\n\n\t\t// Set z-index for preview window to be on top\n\t\tthis.maxZIndex ++;\n\t\twindowPanel.style.setProperty( 'z-index', this.maxZIndex, 'important' );\n\n\t\tconst windowHeader = document.createElement( 'div' );\n\t\twindowHeader.className = 'detached-tab-header';\n\n\t\tconst title = document.createElement( 'span' );\n\t\ttitle.textContent = tab.button.textContent.replace( '⇱', '' ).trim();\n\t\twindowHeader.appendChild( title );\n\n\t\tconst headerControls = document.createElement( 'div' );\n\t\theaderControls.className = 'detached-header-controls';\n\n\t\tconst reattachBtn = document.createElement( 'button' );\n\t\treattachBtn.className = 'detached-reattach-btn';\n\t\treattachBtn.innerHTML = '↩';\n\t\theaderControls.appendChild( reattachBtn );\n\t\twindowHeader.appendChild( headerControls );\n\n\t\tconst windowContent = document.createElement( 'div' );\n\t\twindowContent.className = 'detached-tab-content';\n\n\t\tconst resizer = document.createElement( 'div' );\n\t\tresizer.className = 'detached-tab-resizer';\n\n\t\twindowPanel.appendChild( resizer );\n\t\twindowPanel.appendChild( windowHeader );\n\t\twindowPanel.appendChild( windowContent );\n\n\t\tthis.domElement.appendChild( windowPanel );\n\n\t\treturn windowPanel;\n\n\t}\n\n\tdetachTab( tab, x, y ) {\n\n\t\tif ( tab.isDetached ) return;\n\n\t\t// Check if tab allows detachment\n\t\tif ( tab.allowDetach === false ) return;\n\n\t\tconst allButtons = Array.from( this.tabsContainer.children );\n\n\t\tconst tabIdsInOrder = allButtons.map( btn => {\n\n\t\t\treturn Object.keys( this.tabs ).find( id => this.tabs[ id ].button === btn );\n\n\t\t} ).filter( id => id !== undefined );\n\n\t\tconst currentIndex = tabIdsInOrder.indexOf( tab.id );\n\n\t\tlet newActiveTab = null;\n\n\t\tif ( this.activeTabId === tab.id ) {\n\n\t\t\ttab.setActive( false );\n\n\t\t\tconst remainingTabs = tabIdsInOrder.filter( id =>\n\t\t\t\tid !== tab.id &&\n\t\t\t\t! this.tabs[ id ].isDetached &&\n\t\t\t\tthis.tabs[ id ].isVisible\n\t\t\t);\n\n\t\t\tif ( remainingTabs.length > 0 ) {\n\n\t\t\t\tfor ( let i = currentIndex - 1; i >= 0; i -- ) {\n\n\t\t\t\t\tif ( remainingTabs.includes( tabIdsInOrder[ i ] ) ) {\n\n\t\t\t\t\t\tnewActiveTab = tabIdsInOrder[ i ];\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! newActiveTab ) {\n\n\t\t\t\t\tfor ( let i = currentIndex + 1; i < tabIdsInOrder.length; i ++ ) {\n\n\t\t\t\t\t\tif ( remainingTabs.includes( tabIdsInOrder[ i ] ) ) {\n\n\t\t\t\t\t\t\tnewActiveTab = tabIdsInOrder[ i ];\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! newActiveTab ) {\n\n\t\t\t\t\tnewActiveTab = remainingTabs[ 0 ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( tab.button.parentNode ) {\n\n\t\t\ttab.button.parentNode.removeChild( tab.button );\n\n\t\t}\n\n\t\tif ( tab.content.parentNode ) {\n\n\t\t\ttab.content.parentNode.removeChild( tab.content );\n\n\t\t}\n\n\t\tconst detachedWindow = this.createDetachedWindow( tab, x, y );\n\t\tthis.detachedWindows.push( detachedWindow );\n\n\t\ttab.isDetached = true;\n\t\ttab.detachedWindow = detachedWindow;\n\n\t\tif ( newActiveTab ) {\n\n\t\t\tthis.setActiveTab( newActiveTab );\n\n\t\t} else if ( this.activeTabId === tab.id ) {\n\n\t\t\tthis.activeTabId = null;\n\n\t\t}\n\n\t\t// Update panel size after detaching\n\t\tthis.updatePanelSize();\n\n\t\tthis.saveLayout();\n\n\t}\n\n\tcreateDetachedWindow( tab, x, y ) {\n\n\t\t// Constrain initial position to window bounds\n\t\tconst windowWidth = window.innerWidth;\n\t\tconst windowHeight = window.innerHeight;\n\t\tconst estimatedWidth = 400; // Default detached window width\n\t\tconst estimatedHeight = 300; // Default detached window height\n\n\t\tlet constrainedX = x - 200;\n\t\tlet constrainedY = y - 20;\n\n\t\tif ( constrainedX + estimatedWidth > windowWidth ) {\n\n\t\t\tconstrainedX = windowWidth - estimatedWidth;\n\n\t\t}\n\n\t\tif ( constrainedX < 0 ) {\n\n\t\t\tconstrainedX = 0;\n\n\t\t}\n\n\t\tif ( constrainedY + estimatedHeight > windowHeight ) {\n\n\t\t\tconstrainedY = windowHeight - estimatedHeight;\n\n\t\t}\n\n\t\tif ( constrainedY < 0 ) {\n\n\t\t\tconstrainedY = 0;\n\n\t\t}\n\n\t\tconst windowPanel = document.createElement( 'div' );\n\t\twindowPanel.className = 'detached-tab-panel';\n\t\twindowPanel.style.left = `${ constrainedX }px`;\n\t\twindowPanel.style.top = `${ constrainedY }px`;\n\n\n\n\t\t// Hide detached window if tab is not visible\n\t\tif ( ! tab.isVisible ) {\n\n\t\t\twindowPanel.style.display = 'none';\n\n\t\t}\n\n\t\tconst windowHeader = document.createElement( 'div' );\n\t\twindowHeader.className = 'detached-tab-header';\n\n\t\tconst title = document.createElement( 'span' );\n\t\ttitle.textContent = tab.button.textContent.replace( '⇱', '' ).trim();\n\t\twindowHeader.appendChild( title );\n\n\t\tconst headerControls = document.createElement( 'div' );\n\t\theaderControls.className = 'detached-header-controls';\n\n\t\tconst reattachBtn = document.createElement( 'button' );\n\t\treattachBtn.className = 'detached-reattach-btn';\n\t\treattachBtn.innerHTML = '↩';\n\t\treattachBtn.title = 'Reattach to main panel';\n\t\treattachBtn.onclick = () => this.reattachTab( tab );\n\n\t\theaderControls.appendChild( reattachBtn );\n\t\twindowHeader.appendChild( headerControls );\n\n\t\tconst windowContent = document.createElement( 'div' );\n\t\twindowContent.className = 'detached-tab-content';\n\t\twindowContent.appendChild( tab.content );\n\n\t\t// Make sure content is visible\n\t\ttab.content.style.display = 'block';\n\t\ttab.content.classList.add( 'active' );\n\n\t\t// Create resize handles for all edges\n\t\tconst resizerTop = document.createElement( 'div' );\n\t\tresizerTop.className = 'detached-tab-resizer-top';\n\n\t\tconst resizerRight = document.createElement( 'div' );\n\t\tresizerRight.className = 'detached-tab-resizer-right';\n\n\t\tconst resizerBottom = document.createElement( 'div' );\n\t\tresizerBottom.className = 'detached-tab-resizer-bottom';\n\n\t\tconst resizerLeft = document.createElement( 'div' );\n\t\tresizerLeft.className = 'detached-tab-resizer-left';\n\n\t\tconst resizerCorner = document.createElement( 'div' );\n\t\tresizerCorner.className = 'detached-tab-resizer';\n\n\t\twindowPanel.appendChild( resizerTop );\n\t\twindowPanel.appendChild( resizerRight );\n\t\twindowPanel.appendChild( resizerBottom );\n\t\twindowPanel.appendChild( resizerLeft );\n\t\twindowPanel.appendChild( resizerCorner );\n\t\twindowPanel.appendChild( windowHeader );\n\t\twindowPanel.appendChild( windowContent );\n\n\t\tthis.domElement.appendChild( windowPanel );\n\n\t\t// Setup window dragging\n\t\tthis.setupDetachedWindowDrag( windowPanel, windowHeader, tab );\n\n\t\t// Setup window resizing\n\t\tthis.setupDetachedWindowResize( windowPanel, resizerTop, resizerRight, resizerBottom, resizerLeft, resizerCorner );\n\n\t\t// Use the same z-index that was set on the preview window\n\t\twindowPanel.style.setProperty( 'z-index', this.maxZIndex, 'important' );\n\n\t\treturn { panel: windowPanel, tab: tab };\n\n\t}\n\n\tbringWindowToFront( windowPanel ) {\n\n\t\t// Increment the max z-index and apply it to the clicked window\n\t\tthis.maxZIndex ++;\n\t\twindowPanel.style.setProperty( 'z-index', this.maxZIndex, 'important' );\n\n\t}\n\n\tsetupDetachedWindowDrag( windowPanel, header, tab ) {\n\n\t\tlet isDragging = false;\n\t\tlet startX, startY, startLeft, startTop;\n\n\t\t// Bring window to front when clicking anywhere on it\n\t\twindowPanel.addEventListener( 'pointerdown', () => {\n\n\t\t\tthis.bringWindowToFront( windowPanel );\n\n\t\t} );\n\n\t\tconst onDragStart = ( e ) => {\n\n\t\t\tif ( e.target.classList.contains( 'detached-reattach-btn' ) ) {\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\t// Bring window to front when starting to drag\n\t\t\tthis.bringWindowToFront( windowPanel );\n\n\t\t\tisDragging = true;\n\t\t\theader.style.cursor = 'grabbing';\n\t\t\theader.setPointerCapture( e.pointerId );\n\n\t\t\tstartX = e.clientX;\n\t\t\tstartY = e.clientY;\n\n\t\t\tconst rect = windowPanel.getBoundingClientRect();\n\t\t\tstartLeft = rect.left;\n\t\t\tstartTop = rect.top;\n\n\t\t};\n\n\t\tconst onDragMove = ( e ) => {\n\n\t\t\tif ( ! isDragging ) return;\n\n\t\t\te.preventDefault();\n\n\t\t\tconst currentX = e.clientX;\n\t\t\tconst currentY = e.clientY;\n\n\t\t\tconst deltaX = currentX - startX;\n\t\t\tconst deltaY = currentY - startY;\n\n\t\t\tlet newLeft = startLeft + deltaX;\n\t\t\tlet newTop = startTop + deltaY;\n\n\t\t\t// Constrain to window bounds (allow half width/height to extend outside)\n\t\t\tconst windowWidth = window.innerWidth;\n\t\t\tconst windowHeight = window.innerHeight;\n\t\t\tconst panelWidth = windowPanel.offsetWidth;\n\t\t\tconst panelHeight = windowPanel.offsetHeight;\n\t\t\tconst halfWidth = panelWidth / 2;\n\t\t\tconst halfHeight = panelHeight / 2;\n\n\t\t\t// Allow window to extend half its width beyond right edge\n\t\t\tif ( newLeft + panelWidth > windowWidth + halfWidth ) {\n\n\t\t\t\tnewLeft = windowWidth + halfWidth - panelWidth;\n\n\t\t\t}\n\n\t\t\t// Allow window to extend half its width beyond left edge\n\t\t\tif ( newLeft < - halfWidth ) {\n\n\t\t\t\tnewLeft = - halfWidth;\n\n\t\t\t}\n\n\t\t\t// Allow window to extend half its height beyond bottom edge\n\t\t\tif ( newTop + panelHeight > windowHeight + halfHeight ) {\n\n\t\t\t\tnewTop = windowHeight + halfHeight - panelHeight;\n\n\t\t\t}\n\n\t\t\t// Allow window to extend half its height beyond top edge\n\t\t\tif ( newTop < - halfHeight ) {\n\n\t\t\t\tnewTop = - halfHeight;\n\n\t\t\t}\n\n\t\t\twindowPanel.style.left = `${ newLeft }px`;\n\t\t\twindowPanel.style.top = `${ newTop }px`;\n\n\t\t\t// Check if cursor is over the inspector panel\n\t\t\tconst panelRect = this.panel.getBoundingClientRect();\n\t\t\tconst isOverPanel = currentX >= panelRect.left && currentX <= panelRect.right &&\n\t\t\t\t\t\t\t\tcurrentY >= panelRect.top && currentY <= panelRect.bottom;\n\n\t\t\tif ( isOverPanel ) {\n\n\t\t\t\twindowPanel.style.opacity = '0.5';\n\t\t\t\tthis.panel.style.outline = '2px solid var(--accent-color)';\n\n\t\t\t} else {\n\n\t\t\t\twindowPanel.style.opacity = '';\n\t\t\t\tthis.panel.style.outline = '';\n\n\t\t\t}\n\n\t\t};\n\n\t\tconst onDragEnd = ( e ) => {\n\n\t\t\tif ( ! isDragging ) return;\n\n\t\t\tisDragging = false;\n\t\t\theader.style.cursor = '';\n\t\t\twindowPanel.style.opacity = '';\n\t\t\tthis.panel.style.outline = '';\n\n\t\t\t// Check if dropped over the inspector panel\n\t\t\tconst currentX = e.clientX;\n\t\t\tconst currentY = e.clientY;\n\n\t\t\tif ( currentX !== undefined && currentY !== undefined ) {\n\n\t\t\t\tconst panelRect = this.panel.getBoundingClientRect();\n\t\t\t\tconst isOverPanel = currentX >= panelRect.left && currentX <= panelRect.right &&\n\t\t\t\t\t\t\t\t\tcurrentY >= panelRect.top && currentY <= panelRect.bottom;\n\n\t\t\t\tif ( isOverPanel && tab ) {\n\n\t\t\t\t\t// Reattach the tab\n\t\t\t\t\tthis.reattachTab( tab );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// Save layout after moving detached window\n\t\t\t\t\tthis.saveLayout();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\theader.removeEventListener( 'pointermove', onDragMove );\n\t\t\theader.removeEventListener( 'pointerup', onDragEnd );\n\t\t\theader.removeEventListener( 'pointercancel', onDragEnd );\n\n\t\t};\n\n\t\theader.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\tonDragStart( e );\n\t\t\theader.addEventListener( 'pointermove', onDragMove );\n\t\t\theader.addEventListener( 'pointerup', onDragEnd );\n\t\t\theader.addEventListener( 'pointercancel', onDragEnd );\n\n\t\t} );\n\n\t\theader.style.cursor = 'grab';\n\n\t}\n\n\tsetupDetachedWindowResize( windowPanel, resizerTop, resizerRight, resizerBottom, resizerLeft, resizerCorner ) {\n\n\t\tconst minWidth = 250;\n\t\tconst minHeight = 150;\n\n\t\tconst setupResizer = ( resizer, direction ) => {\n\n\t\t\tlet isResizing = false;\n\t\t\tlet startX, startY, startWidth, startHeight, startLeft, startTop;\n\n\t\t\tconst onResizeStart = ( e ) => {\n\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tisResizing = true;\n\n\t\t\t\t// Bring window to front when resizing\n\t\t\t\tthis.bringWindowToFront( windowPanel );\n\n\t\t\t\tresizer.setPointerCapture( e.pointerId );\n\n\t\t\t\tstartX = e.clientX;\n\t\t\t\tstartY = e.clientY;\n\t\t\t\tstartWidth = windowPanel.offsetWidth;\n\t\t\t\tstartHeight = windowPanel.offsetHeight;\n\t\t\t\tstartLeft = windowPanel.offsetLeft;\n\t\t\t\tstartTop = windowPanel.offsetTop;\n\n\t\t\t};\n\n\t\t\tconst onResizeMove = ( e ) => {\n\n\t\t\t\tif ( ! isResizing ) return;\n\n\t\t\t\te.preventDefault();\n\n\t\t\t\tconst currentX = e.clientX;\n\t\t\t\tconst currentY = e.clientY;\n\n\t\t\t\tconst deltaX = currentX - startX;\n\t\t\t\tconst deltaY = currentY - startY;\n\n\t\t\t\tconst windowWidth = window.innerWidth;\n\t\t\t\tconst windowHeight = window.innerHeight;\n\n\t\t\t\tif ( direction === 'right' || direction === 'corner' ) {\n\n\t\t\t\t\tconst newWidth = startWidth + deltaX;\n\t\t\t\t\tconst maxWidth = windowWidth - startLeft;\n\n\t\t\t\t\tif ( newWidth >= minWidth && newWidth <= maxWidth ) {\n\n\t\t\t\t\t\twindowPanel.style.width = `${ newWidth }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( direction === 'bottom' || direction === 'corner' ) {\n\n\t\t\t\t\tconst newHeight = startHeight + deltaY;\n\t\t\t\t\tconst maxHeight = windowHeight - startTop;\n\n\t\t\t\t\tif ( newHeight >= minHeight && newHeight <= maxHeight ) {\n\n\t\t\t\t\t\twindowPanel.style.height = `${ newHeight }px`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( direction === 'left' ) {\n\n\t\t\t\t\tconst newWidth = startWidth - deltaX;\n\t\t\t\t\tconst maxLeft = startLeft + startWidth - minWidth;\n\n\t\t\t\t\tif ( newWidth >= minWidth ) {\n\n\t\t\t\t\t\tconst newLeft = startLeft + deltaX;\n\n\t\t\t\t\t\tif ( newLeft >= 0 && newLeft <= maxLeft ) {\n\n\t\t\t\t\t\t\twindowPanel.style.width = `${ newWidth }px`;\n\t\t\t\t\t\t\twindowPanel.style.left = `${ newLeft }px`;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( direction === 'top' ) {\n\n\t\t\t\t\tconst newHeight = startHeight - deltaY;\n\t\t\t\t\tconst maxTop = startTop + startHeight - minHeight;\n\n\t\t\t\t\tif ( newHeight >= minHeight ) {\n\n\t\t\t\t\t\tconst newTop = startTop + deltaY;\n\n\t\t\t\t\t\tif ( newTop >= 0 && newTop <= maxTop ) {\n\n\t\t\t\t\t\t\twindowPanel.style.height = `${ newHeight }px`;\n\t\t\t\t\t\t\twindowPanel.style.top = `${ newTop }px`;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis.dispatchEvent( { type: 'resize' } );\n\n\t\t\t};\n\n\t\t\tconst onResizeEnd = () => {\n\n\t\t\t\tisResizing = false;\n\n\t\t\t\tresizer.removeEventListener( 'pointermove', onResizeMove );\n\t\t\t\tresizer.removeEventListener( 'pointerup', onResizeEnd );\n\t\t\t\tresizer.removeEventListener( 'pointercancel', onResizeEnd );\n\n\t\t\t\t// Save layout after resizing detached window\n\t\t\t\tthis.saveLayout();\n\n\t\t\t};\n\n\t\t\tresizer.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\t\tonResizeStart( e );\n\t\t\t\tresizer.addEventListener( 'pointermove', onResizeMove );\n\t\t\t\tresizer.addEventListener( 'pointerup', onResizeEnd );\n\t\t\t\tresizer.addEventListener( 'pointercancel', onResizeEnd );\n\n\t\t\t} );\n\n\t\t};\n\n\t\t// Setup all resizers\n\t\tsetupResizer( resizerTop, 'top' );\n\t\tsetupResizer( resizerRight, 'right' );\n\t\tsetupResizer( resizerBottom, 'bottom' );\n\t\tsetupResizer( resizerLeft, 'left' );\n\t\tsetupResizer( resizerCorner, 'corner' );\n\n\t}\n\n\treattachTab( tab ) {\n\n\t\tif ( ! tab.isDetached ) return;\n\n\t\tif ( tab.detachedWindow ) {\n\n\t\t\tconst index = this.detachedWindows.indexOf( tab.detachedWindow );\n\n\t\t\tif ( index > - 1 ) {\n\n\t\t\t\tthis.detachedWindows.splice( index, 1 );\n\n\t\t\t}\n\n\t\t\tif ( tab.detachedWindow.panel.parentNode ) {\n\n\t\t\t\ttab.detachedWindow.panel.parentNode.removeChild( tab.detachedWindow.panel );\n\n\t\t\t}\n\n\t\t\ttab.detachedWindow = null;\n\n\t\t}\n\n\t\ttab.isDetached = false;\n\n\t\t// Get all tabs and sort by their original index to determine the correct order\n\t\tconst allTabs = Object.values( this.tabs );\n\t\tconst allTabsSorted = allTabs\n\t\t\t.filter( t => t.originalIndex !== undefined && t.isVisible )\n\t\t\t.sort( ( a, b ) => a.originalIndex - b.originalIndex );\n\n\t\t// Get currently attached tab buttons\n\t\tconst currentButtons = Array.from( this.tabsContainer.children );\n\n\t\t// Find the correct position for this tab\n\t\tlet insertIndex = 0;\n\t\tfor ( const t of allTabsSorted ) {\n\n\t\t\tif ( t.id === tab.id ) {\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\t// Count only non-detached, non-builtin tabs that come before this one\n\t\t\tif ( ! t.isDetached && ! t.builtin ) {\n\n\t\t\t\tinsertIndex ++;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Insert the button at the correct position\n\t\tif ( insertIndex >= currentButtons.length || currentButtons.length === 0 ) {\n\n\t\t\t// If insert index is beyond current buttons, or no buttons exist, append at the end\n\t\t\tthis.tabsContainer.appendChild( tab.button );\n\n\t\t} else {\n\n\t\t\t// Insert before the button at the insert index\n\t\t\tthis.tabsContainer.insertBefore( tab.button, currentButtons[ insertIndex ] );\n\n\t\t}\n\n\t\tthis.contentWrapper.appendChild( tab.content );\n\n\t\tthis.setActiveTab( tab.id );\n\n\t\t// Update panel size after reattaching\n\t\tthis.updatePanelSize();\n\n\t\tthis.saveLayout();\n\n\t}\n\n\tsetActiveTab( id ) {\n\n\t\tif ( this.activeTabId && this.tabs[ this.activeTabId ] && ! this.tabs[ this.activeTabId ].isDetached ) {\n\n\t\t\tthis.tabs[ this.activeTabId ].setActive( false );\n\n\t\t}\n\n\t\tthis.activeTabId = id;\n\n\t\tif ( this.tabs[ id ] ) {\n\n\t\t\tconst tab = this.tabs[ id ];\n\n\t\t\tif ( ! tab.isVisible ) {\n\n\t\t\t\ttab.show();\n\n\t\t\t}\n\n\t\t\ttab.setActive( true );\n\n\t\t}\n\n\t\tthis.saveLayout();\n\t\tthis.checkHeaderScroll();\n\n\t}\n\n\ttogglePanel() {\n\n\t\tthis.panel.classList.toggle( 'visible' );\n\t\tthis.toggleButton.classList.toggle( 'panel-open' );\n\t\tthis.miniPanel.classList.toggle( 'panel-open' );\n\n\t\tconst isVisible = this.panel.classList.contains( 'visible' );\n\n\t\tif ( isVisible && this.activeTabId && this.tabs[ this.activeTabId ] ) {\n\n\t\t\tthis.tabs[ this.activeTabId ].setActive( true );\n\n\t\t}\n\n\t\tthis.updateWidgetPosition();\n\n\t\tthis.dispatchEvent( { type: 'resize' } );\n\n\t\tthis.saveLayout();\n\n\t}\n\n\ttogglePosition() {\n\n\t\tconst newPosition = this.position === 'bottom' ? 'right' : 'bottom';\n\t\tthis.setPosition( newPosition );\n\n\t}\n\n\tsetPosition( targetPosition ) {\n\n\t\tif ( this.position === targetPosition ) return;\n\n\t\tthis.panel.style.transition = 'none';\n\n\t\t// Check if panel is currently maximized\n\t\tconst isMaximized = this.panel.classList.contains( 'maximized' );\n\n\t\tif ( targetPosition === 'right' ) {\n\n\t\t\tthis.position = 'right';\n\t\t\tthis.floatingBtn.classList.add( 'active' );\n\t\t\tthis.floatingBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><path d=\"M3 15h18\"></path></svg>';\n\t\t\tthis.floatingBtn.title = 'Switch to Bottom';\n\n\t\t\t// Apply right position styles\n\t\t\tthis.panel.classList.remove( 'position-bottom' );\n\t\t\tthis.panel.classList.add( 'position-right' );\n\t\t\tthis.panel.style.bottom = '';\n\t\t\tthis.panel.style.top = '0';\n\t\t\tthis.panel.style.right = '0';\n\t\t\tthis.panel.style.left = '';\n\n\t\t\t// Apply size based on maximized state\n\t\t\tif ( isMaximized ) {\n\n\t\t\t\tthis.panel.style.width = '100%';\n\t\t\t\tthis.panel.style.height = '100%';\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.style.width = `${ this.lastWidthRight }px`;\n\t\t\t\tthis.panel.style.height = '100%';\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.position = 'bottom';\n\t\t\tthis.floatingBtn.classList.remove( 'active' );\n\t\t\tthis.floatingBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><line x1=\"15\" y1=\"3\" x2=\"15\" y2=\"21\"></line></svg>';\n\t\t\tthis.floatingBtn.title = 'Switch to Right Side';\n\n\t\t\t// Apply bottom position styles\n\t\t\tthis.panel.classList.remove( 'position-right' );\n\t\t\tthis.panel.classList.add( 'position-bottom' );\n\t\t\tthis.panel.style.top = '';\n\t\t\tthis.panel.style.right = '';\n\t\t\tthis.panel.style.bottom = '0';\n\t\t\tthis.panel.style.left = '0';\n\n\t\t\t// Apply size based on maximized state\n\t\t\tif ( isMaximized ) {\n\n\t\t\t\tthis.panel.style.width = '100%';\n\t\t\t\tthis.panel.style.height = '100%';\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.style.width = '100%';\n\t\t\t\tthis.panel.style.height = `${ this.lastHeightBottom }px`;\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.updateWidgetPosition();\n\n\t\t// Re-enable transition after a brief delay\n\t\tsetTimeout( () => {\n\n\t\t\tthis.panel.style.transition = '';\n\n\t\t}, 50 );\n\n\t\t// Update panel size based on visible tabs\n\t\tthis.updatePanelSize();\n\n\t\t// Save layout after position change\n\t\tthis.saveLayout();\n\n\t}\n\n\tsaveLayout() {\n\n\t\tif ( this.isLoadingLayout ) return;\n\n\t\tconst layout = {\n\t\t\tposition: this.position,\n\t\t\tlastHeightBottom: this.lastHeightBottom,\n\t\t\tlastWidthRight: this.lastWidthRight,\n\t\t\tactiveTabId: this.activeTabId,\n\t\t\tdetachedTabs: [],\n\t\t\tisVisible: this.panel.classList.contains( 'visible' )\n\t\t};\n\n\t\t// Save detached windows state\n\t\tthis.detachedWindows.forEach( detachedWindow => {\n\n\t\t\tconst tab = detachedWindow.tab;\n\t\t\tconst panel = detachedWindow.panel;\n\n\t\t\t// Get position values, ensuring they're valid numbers\n\t\t\tconst left = parseFloat( panel.style.left ) || panel.offsetLeft || 0;\n\t\t\tconst top = parseFloat( panel.style.top ) || panel.offsetTop || 0;\n\t\t\tconst width = panel.offsetWidth;\n\t\t\tconst height = panel.offsetHeight;\n\n\t\t\tlayout.detachedTabs.push( {\n\t\t\t\ttabId: tab.id,\n\t\t\t\toriginalIndex: tab.originalIndex !== undefined ? tab.originalIndex : 0,\n\t\t\t\tleft: left,\n\t\t\t\ttop: top,\n\t\t\t\twidth: width,\n\t\t\t\theight: height\n\t\t\t} );\n\n\t\t} );\n\n\t\ttry {\n\n\t\t\tsetItem( 'layout', layout );\n\n\t\t} catch ( e ) {\n\n\t\t\tconsole.warn( 'Failed to save profiler layout:', e );\n\n\t\t}\n\n\t}\n\n\tloadLayout() {\n\n\t\tthis.isLoadingLayout = true;\n\n\t\ttry {\n\n\t\t\tconst layout = getItem( 'layout' );\n\n\t\t\tif ( Object.keys( layout ).length === 0 ) return;\n\n\t\t\t// Constrain detached tabs positions to current screen bounds\n\t\t\tif ( layout.detachedTabs && layout.detachedTabs.length > 0 ) {\n\n\t\t\t\tconst windowWidth = window.innerWidth;\n\t\t\t\tconst windowHeight = window.innerHeight;\n\n\t\t\t\tlayout.detachedTabs = layout.detachedTabs.map( detachedTabData => {\n\n\t\t\t\t\tlet { left, top, width, height } = detachedTabData;\n\n\t\t\t\t\t// Ensure width and height are within bounds\n\t\t\t\t\tif ( width > windowWidth ) {\n\n\t\t\t\t\t\twidth = windowWidth - 100; // Leave some margin\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( height > windowHeight ) {\n\n\t\t\t\t\t\theight = windowHeight - 100; // Leave some margin\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Allow window to extend half its width/height outside the screen\n\t\t\t\t\tconst halfWidth = width / 2;\n\t\t\t\t\tconst halfHeight = height / 2;\n\n\t\t\t\t\t// Constrain horizontal position (allow half width to extend beyond right edge)\n\t\t\t\t\tif ( left + width > windowWidth + halfWidth ) {\n\n\t\t\t\t\t\tleft = windowWidth + halfWidth - width;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Constrain horizontal position (allow half width to extend beyond left edge)\n\t\t\t\t\tif ( left < - halfWidth ) {\n\n\t\t\t\t\t\tleft = - halfWidth;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Constrain vertical position (allow half height to extend beyond bottom edge)\n\t\t\t\t\tif ( top + height > windowHeight + halfHeight ) {\n\n\t\t\t\t\t\ttop = windowHeight + halfHeight - height;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Constrain vertical position (allow half height to extend beyond top edge)\n\t\t\t\t\tif ( top < - halfHeight ) {\n\n\t\t\t\t\t\ttop = - halfHeight;\n\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...detachedTabData,\n\t\t\t\t\t\tleft,\n\t\t\t\t\t\ttop,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\theight\n\t\t\t\t\t};\n\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t\t// Restore position and dimensions\n\t\t\tif ( layout.position ) {\n\n\t\t\t\tthis.position = layout.position;\n\n\t\t\t}\n\n\t\t\tif ( layout.lastHeightBottom ) {\n\n\t\t\t\tthis.lastHeightBottom = layout.lastHeightBottom;\n\n\t\t\t}\n\n\t\t\tif ( layout.lastWidthRight ) {\n\n\t\t\t\tthis.lastWidthRight = layout.lastWidthRight;\n\n\t\t\t}\n\n\t\t\t// Constrain saved dimensions to current screen bounds\n\t\t\tconst windowWidth = window.innerWidth;\n\t\t\tconst windowHeight = window.innerHeight;\n\n\t\t\tif ( this.lastHeightBottom > windowHeight - 50 ) {\n\n\t\t\t\tthis.lastHeightBottom = windowHeight - 50;\n\n\t\t\t}\n\n\t\t\tif ( this.lastWidthRight > windowWidth - 50 ) {\n\n\t\t\t\tthis.lastWidthRight = windowWidth - 50;\n\n\t\t\t}\n\n\t\t\t// Apply the saved position after shell is set up\n\t\t\tif ( this.position === 'right' ) {\n\n\t\t\t\tthis.floatingBtn.classList.add( 'active' );\n\t\t\t\tthis.floatingBtn.innerHTML = '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><path d=\"M3 15h18\"></path></svg>';\n\t\t\t\tthis.floatingBtn.title = 'Switch to Bottom';\n\n\t\t\t\tthis.panel.classList.remove( 'position-bottom' );\n\t\t\t\tthis.panel.classList.add( 'position-right' );\n\t\t\t\tthis.toggleButton.classList.add( 'position-right' );\n\t\t\t\tthis.miniPanel.classList.add( 'position-right' );\n\t\t\t\tthis.panel.style.bottom = '';\n\t\t\t\tthis.panel.style.top = '0';\n\t\t\t\tthis.panel.style.right = '0';\n\t\t\t\tthis.panel.style.left = '';\n\t\t\t\tthis.panel.style.width = `${ this.lastWidthRight }px`;\n\t\t\t\tthis.panel.style.height = '100%';\n\n\t\t\t} else {\n\n\t\t\t\tthis.panel.style.height = `${ this.lastHeightBottom }px`;\n\n\t\t\t}\n\n\t\t\tif ( layout.isVisible ) {\n\n\t\t\t\tthis.panel.classList.add( 'visible' );\n\t\t\t\tthis.toggleButton.classList.add( 'panel-open' );\n\n\t\t\t}\n\n\t\t\tif ( layout.activeTabId ) {\n\n\t\t\t\tthis.setActiveTab( layout.activeTabId );\n\n\t\t\t}\n\n\t\t\tif ( layout.detachedTabs && layout.detachedTabs.length > 0 ) {\n\n\t\t\t\tthis.pendingDetachedTabs = layout.detachedTabs;\n\t\t\t\tthis.restoreDetachedTabs();\n\n\t\t\t}\n\n\t\t\t// Update panel size after loading layout\n\t\t\tthis.updatePanelSize();\n\n\t\t\t// Update widget position (toggle and mini panel alignment)\n\t\t\tthis.updateWidgetPosition();\n\n\t\t\t// Ensure initial open state applies to mini panel as well\n\t\t\tif ( this.panel.classList.contains( 'visible' ) ) {\n\n\t\t\t\tthis.miniPanel.classList.add( 'panel-open' );\n\n\t\t\t}\n\n\t\t} catch ( e ) {\n\n\t\t\tconsole.warn( 'Failed to load profiler layout:', e );\n\n\t\t} finally {\n\n\t\t\tthis.isLoadingLayout = false;\n\n\t\t}\n\n\t}\n\n\trestoreDetachedTabs() {\n\n\t\tif ( ! this.pendingDetachedTabs || this.pendingDetachedTabs.length === 0 ) return;\n\n\t\tthis.pendingDetachedTabs.forEach( detachedTabData => {\n\n\t\t\tconst tab = this.tabs[ detachedTabData.tabId ];\n\n\t\t\tif ( ! tab || tab.isDetached ) return;\n\n\t\t\t// Restore originalIndex if saved\n\t\t\tif ( detachedTabData.originalIndex !== undefined ) {\n\n\t\t\t\ttab.originalIndex = detachedTabData.originalIndex;\n\n\t\t\t}\n\n\t\t\tif ( tab.button.parentNode ) {\n\n\t\t\t\ttab.button.parentNode.removeChild( tab.button );\n\n\t\t\t}\n\n\t\t\tif ( tab.content.parentNode ) {\n\n\t\t\t\ttab.content.parentNode.removeChild( tab.content );\n\n\t\t\t}\n\n\t\t\tconst detachedWindow = this.createDetachedWindow( tab, 0, 0 );\n\n\t\t\tdetachedWindow.panel.style.left = `${ detachedTabData.left }px`;\n\t\t\tdetachedWindow.panel.style.top = `${ detachedTabData.top }px`;\n\t\t\tdetachedWindow.panel.style.width = `${ detachedTabData.width }px`;\n\t\t\tdetachedWindow.panel.style.height = `${ detachedTabData.height }px`;\n\n\t\t\t// Constrain window to bounds after restoring position and size\n\t\t\tthis.constrainWindowToBounds( detachedWindow.panel );\n\n\t\t\tthis.detachedWindows.push( detachedWindow );\n\n\t\t\ttab.isDetached = true;\n\t\t\ttab.detachedWindow = detachedWindow;\n\n\t\t} );\n\n\t\tthis.pendingDetachedTabs = null;\n\n\t\t// Update maxZIndex to be higher than all existing windows\n\t\tthis.detachedWindows.forEach( detachedWindow => {\n\n\t\t\tconst currentZIndex = parseInt( getComputedStyle( detachedWindow.panel ).zIndex ) || 0;\n\t\t\tif ( currentZIndex > this.maxZIndex ) {\n\n\t\t\t\tthis.maxZIndex = currentZIndex;\n\n\t\t\t}\n\n\t\t} );\n\n\t\tconst needsNewActiveTab = ! this.activeTabId ||\n\t\t\t! this.tabs[ this.activeTabId ] ||\n\t\t\tthis.tabs[ this.activeTabId ].isDetached ||\n\t\t\t! this.tabs[ this.activeTabId ].isVisible;\n\n\t\tif ( needsNewActiveTab ) {\n\n\t\t\tconst tabIds = Object.keys( this.tabs );\n\t\t\tconst availableTabs = tabIds.filter( id =>\n\t\t\t\t! this.tabs[ id ].isDetached &&\n\t\t\t\tthis.tabs[ id ].isVisible\n\t\t\t);\n\n\t\t\tif ( availableTabs.length > 0 ) {\n\n\t\t\t\tconst buttons = Array.from( this.tabsContainer.children );\n\t\t\t\tconst orderedTabIds = buttons.map( btn => {\n\n\t\t\t\t\treturn Object.keys( this.tabs ).find( id => this.tabs[ id ].button === btn );\n\n\t\t\t\t} ).filter( id =>\n\t\t\t\t\tid !== undefined &&\n\t\t\t\t\t! this.tabs[ id ].isDetached &&\n\t\t\t\t\tthis.tabs[ id ].isVisible\n\t\t\t\t);\n\n\t\t\t\tthis.setActiveTab( orderedTabIds[ 0 ] || availableTabs[ 0 ] );\n\n\t\t\t} else {\n\n\t\t\t\tthis.activeTabId = null;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Update panel size after restoring detached tabs\n\t\tthis.updatePanelSize();\n\n\t}\n\n\tsetHorizontalAlign( value ) {\n\n\t\tthis.horizontalAlign = value;\n\t\tthis.updateWidgetPosition();\n\n\t\treturn this;\n\n\t}\n\n\tsetVerticalAlign( value ) {\n\n\t\tthis.verticalAlign = value;\n\t\tthis.updateWidgetPosition();\n\n\t\treturn this;\n\n\t}\n\n\tupdateWidgetPosition() {\n\n\t\tconst isVisible = this.panel.classList.contains( 'visible' );\n\t\tconst isMaximized = this.panel.classList.contains( 'maximized' );\n\t\tconst isRight = this.position === 'right';\n\n\t\tlet horizontal = this.horizontalAlign; // 'left' or 'right'\n\t\tlet vertical = this.verticalAlign; // 'top' or 'bottom'\n\n\t\tif ( isVisible ) {\n\n\t\t\tif ( isRight ) {\n\n\t\t\t\t// If panel is open on the right:\n\t\t\t\t// Toggle should be on the opposite side of 'right' if default is 'right' to avoid overlapping the panel.\n\t\t\t\tif ( this.horizontalAlign === 'right' ) {\n\n\t\t\t\t\thorizontal = 'left';\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// If panel is open at the bottom:\n\t\t\t\tif ( ! isMaximized ) {\n\n\t\t\t\t\t// If default is bottom, we must move to top to avoid overlapping the panel at the bottom.\n\t\t\t\t\tif ( this.verticalAlign === 'bottom' ) {\n\n\t\t\t\t\t\tvertical = 'top';\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// If maximized, move to the opposite vertical position to avoid overlap with header/tabs.\n\t\t\t\t\tvertical = this.verticalAlign === 'top' ? 'bottom' : 'top';\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Apply horizontal class\n\t\tif ( horizontal === 'left' ) {\n\n\t\t\tthis.toggleButton.classList.add( 'toggle-left' );\n\t\t\tthis.miniPanel.classList.add( 'toggle-left' );\n\n\t\t} else {\n\n\t\t\tthis.toggleButton.classList.remove( 'toggle-left' );\n\t\t\tthis.miniPanel.classList.remove( 'toggle-left' );\n\n\t\t}\n\n\t\t// Apply vertical class\n\t\tif ( vertical === 'bottom' ) {\n\n\t\t\tthis.toggleButton.classList.add( 'toggle-bottom' );\n\t\t\tthis.miniPanel.classList.add( 'toggle-bottom' );\n\n\t\t} else {\n\n\t\t\tthis.toggleButton.classList.remove( 'toggle-bottom' );\n\t\t\tthis.miniPanel.classList.remove( 'toggle-bottom' );\n\n\t\t}\n\n\t\tthis.notifyLayoutChange();\n\n\t}\n\n\tisVertical() {\n\n\t\treturn this.position === 'left' || this.position === 'right' ||\n\t\t\t( this.panel && ( this.panel.classList.contains( 'position-left' ) || this.panel.classList.contains( 'position-right' ) ) );\n\n\t}\n\n\tnotifyLayoutChange() {\n\n\t\tconst isVert = this.isVertical();\n\n\t\tthis.dispatchEvent( { type: 'orientationchange', position: this.position, isVertical: isVert } );\n\t\tthis.dispatchEvent( { type: 'layoutchange', position: this.position, isVertical: isVert } );\n\n\t}\n\n\tdispose() {\n\n\t\tfor ( const tab of Object.values( this.tabs ) ) {\n\n\t\t\ttab.dispose();\n\n\t\t}\n\n\t\tthis.domElement.remove();\n\n\t\tfor ( const detachedWindow of this.detachedWindows ) {\n\n\t\t\tdetachedWindow.panel.remove();\n\n\t\t}\n\n\t\tthis.toggleGraph.dispose();\n\n\t}\n\n}\n","import { EventDispatcher } from 'three';\n\n/**\n * Tab class\n * @param {string} title - The title of the tab\n * @param {Object} options - Options for the tab\n * @param {boolean} [options.allowDetach=true] - Whether the tab can be detached into a separate window\n * @param {boolean} [options.builtin=false] - Whether the tab should appear in the profiler-toggle button\n * @param {string} [options.icon] - SVG icon HTML for the builtin button\n *\n * @example\n * // Create a tab that can be detached (default behavior)\n * const tab1 = new Tab('My Tab');\n *\n * // Create a tab that cannot be detached\n * const tab2 = new Tab('Fixed Tab', { allowDetach: false });\n *\n * // Create a builtin tab that appears in the profiler-toggle\n * const tab3 = new Tab('Builtin Tab', { builtin: true });\n *\n * // Create a builtin tab with custom icon\n * const tab4 = new Tab('Settings', { builtin: true, icon: '<svg>...</svg>' });\n *\n * // Control builtin tab visibility\n * tab3.showBuiltin(); // Show the builtin button and mini-content\n * tab3.hideBuiltin(); // Hide the builtin button and mini-content\n */\nexport class Tab extends EventDispatcher {\n\n\tconstructor( title, options = {} ) {\n\n\t\tsuper();\n\n\t\tthis.id = title.toLowerCase().replace( /\\s+/g, '-' );\n\t\tthis.button = document.createElement( 'button' );\n\t\tthis.button.className = 'tab-btn';\n\t\tthis.button.textContent = title;\n\n\t\tthis.content = document.createElement( 'div' );\n\t\tthis.content.className = 'profiler-content';\n\t\tthis.content.classList.add( `${this.id}-content` );\n\n\t\tthis._isActive = false;\n\t\tthis.isVisible = true;\n\t\tthis.isDetached = false;\n\t\tthis.detachedWindow = null;\n\t\tthis.allowDetach = options.allowDetach !== undefined ? options.allowDetach : true;\n\t\tthis.builtin = options.builtin !== undefined ? options.builtin : false;\n\t\tthis.icon = options.icon || null;\n\t\tthis.builtinButton = null; // Reference to the builtin button in profiler-toggle\n\t\tthis.miniContent = null; // Reference to the mini-panel content container\n\t\tthis.profiler = null; // Reference to the profiler instance\n\t\tthis.onVisibilityChange = null; // Callback for visibility changes\n\n\t}\n\n\tget inspector() {\n\n\t\treturn this.profiler.inspector;\n\n\t}\n\n\tget isActive() {\n\n\t\tif ( this.isDetached && this.isVisible ) return true;\n\n\t\tconst isProfilerVisible = this.profiler && this.profiler.panel.classList.contains( 'visible' );\n\n\t\tif ( ! isProfilerVisible ) return false;\n\n\t\treturn this._isActive;\n\n\t}\n\n\tset isActive( value ) {\n\n\t\tthis._isActive = value;\n\n\t}\n\n\tinit( /*inspector*/ ) { }\n\n\tupdate( /*inspector*/ ) { }\n\n\tsetActive( isActive ) {\n\n\t\tthis.button.classList.toggle( 'active', isActive );\n\t\tthis.content.classList.toggle( 'active', isActive );\n\n\t\tthis.isActive = isActive;\n\n\t}\n\n\tshow() {\n\n\t\tthis.content.style.display = '';\n\t\tthis.button.style.display = '';\n\n\t\tthis.isVisible = true;\n\n\t\t// Show detached window if tab is detached\n\t\tif ( this.isDetached && this.detachedWindow ) {\n\n\t\t\tthis.detachedWindow.panel.style.display = '';\n\n\t\t}\n\n\t\t// Notify profiler of visibility change\n\t\tif ( this.onVisibilityChange ) {\n\n\t\t\tthis.onVisibilityChange();\n\n\t\t}\n\n\t\tthis.showBuiltin();\n\n\t}\n\n\thide() {\n\n\t\tthis.content.style.display = 'none';\n\t\tthis.button.style.display = 'none';\n\n\t\tthis.isVisible = false;\n\n\t\t// Hide detached window if tab is detached\n\t\tif ( this.isDetached && this.detachedWindow ) {\n\n\t\t\tthis.detachedWindow.panel.style.display = 'none';\n\n\t\t}\n\n\t\t// Notify profiler of visibility change\n\t\tif ( this.onVisibilityChange ) {\n\n\t\t\tthis.onVisibilityChange();\n\n\t\t}\n\n\t\tthis.hideBuiltin();\n\n\t}\n\n\tshowBuiltin() {\n\n\t\tif ( ! this.builtin ) return;\n\n\t\t// Show the builtin-tabs-container\n\t\tif ( this.profiler && this.profiler.builtinTabsContainer ) {\n\n\t\t\tthis.profiler.builtinTabsContainer.style.display = '';\n\n\t\t}\n\n\t\t// Show the button\n\t\tif ( this.builtinButton ) {\n\n\t\t\tthis.builtinButton.style.display = '';\n\n\t\t}\n\n\t\t// Show and activate the mini-panel with content\n\t\tif ( this.miniContent && this.profiler ) {\n\n\t\t\t// Hide all other mini-panel contents\n\t\t\tthis.profiler.miniPanel.querySelectorAll( '.mini-panel-content' ).forEach( content => {\n\n\t\t\t\tcontent.style.display = 'none';\n\n\t\t\t} );\n\n\t\t\t// Remove active state from all builtin buttons\n\t\t\tthis.profiler.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ).forEach( btn => {\n\n\t\t\t\tbtn.classList.remove( 'active' );\n\n\t\t\t} );\n\n\t\t\t// Activate this tab's button\n\t\t\tif ( this.builtinButton ) {\n\n\t\t\t\tthis.builtinButton.classList.add( 'active' );\n\n\t\t\t}\n\n\t\t\t// Move content to mini-panel if not already there\n\t\t\tif ( ! this.miniContent.firstChild ) {\n\n\t\t\t\twhile ( this.content.firstChild ) {\n\n\t\t\t\t\tthis.miniContent.appendChild( this.content.firstChild );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// Show the mini-panel and content\n\t\t\tthis.miniContent.style.display = 'block';\n\t\t\tthis.profiler.miniPanel.classList.add( 'visible' );\n\n\t\t}\n\n\t}\n\n\thideBuiltin() {\n\n\t\tif ( ! this.builtin ) return;\n\n\t\t// Hide the button\n\t\tif ( this.builtinButton ) {\n\n\t\t\tthis.builtinButton.style.display = 'none';\n\n\t\t}\n\n\t\t// Hide the mini-panel content\n\t\tif ( this.miniContent ) {\n\n\t\t\tthis.miniContent.style.display = 'none';\n\n\t\t\t// Move content back to main panel\n\t\t\tif ( this.miniContent.firstChild ) {\n\n\t\t\t\twhile ( this.miniContent.firstChild ) {\n\n\t\t\t\t\tthis.content.appendChild( this.miniContent.firstChild );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Deactivate button\n\t\tif ( this.builtinButton ) {\n\n\t\t\tthis.builtinButton.classList.remove( 'active' );\n\n\t\t}\n\n\t\t// Hide mini-panel if no content is visible\n\t\tif ( this.profiler ) {\n\n\t\t\tconst hasVisibleContent = Array.from( this.profiler.miniPanel.querySelectorAll( '.mini-panel-content' ) )\n\t\t\t\t.some( content => content.style.display !== 'none' );\n\n\t\t\tif ( ! hasVisibleContent ) {\n\n\t\t\t\tthis.profiler.miniPanel.classList.remove( 'visible' );\n\n\t\t\t}\n\n\t\t\t// Hide the builtin-tabs-container if all builtin buttons are hidden\n\t\t\tconst hasVisibleBuiltinButtons = Array.from( this.profiler.builtinTabsContainer.querySelectorAll( '.builtin-tab-btn' ) )\n\t\t\t\t.some( btn => btn.style.display !== 'none' );\n\n\t\t\tif ( ! hasVisibleBuiltinButtons ) {\n\n\t\t\t\tthis.profiler.builtinTabsContainer.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tdispose() { }\n\n}\n","\nexport class List {\n\n\tconstructor( ...headers ) {\n\n\t\tthis.headers = headers;\n\t\tthis.children = [];\n\t\tthis.domElement = document.createElement( 'div' );\n\t\tthis.domElement.className = 'list-container';\n\t\tthis.domElement.style.padding = '5px 10px 10px 10px';\n\t\tthis.id = `list-${Math.random().toString( 36 ).slice( 2, 11 )}`;\n\t\tthis.domElement.dataset.listId = this.id;\n\n\t\tconst headerRow = document.createElement( 'div' );\n\t\theaderRow.className = 'list-header';\n\t\tthis.headers.forEach( headerText => {\n\n\t\t\tconst headerCell = document.createElement( 'div' );\n\t\t\theaderCell.className = 'list-header-cell';\n\t\t\theaderCell.textContent = headerText;\n\t\t\theaderRow.appendChild( headerCell );\n\n\t\t} );\n\t\tthis.domElement.appendChild( headerRow );\n\n\t}\n\n\tsetGridStyle( gridTemplate ) {\n\n\t\tthis.domElement.style.setProperty( '--list-grid-template', gridTemplate );\n\n\t}\n\n\tsetViewMode( mode ) {\n\n\t\tif ( mode === 'grid' ) {\n\n\t\t\tthis.domElement.classList.add( 'grid-mode' );\n\n\t\t} else {\n\n\t\t\tthis.domElement.classList.remove( 'grid-mode' );\n\n\t\t}\n\n\t}\n\n\tadd( item ) {\n\n\t\tif ( item.parent !== null ) {\n\n\t\t\titem.parent.remove( item );\n\n\t\t}\n\n\t\titem.domElement.classList.add( 'header-wrapper', 'section-start' );\n\t\titem.parent = this;\n\n\t\tthis.children.push( item );\n\t\tthis.domElement.appendChild( item.domElement );\n\n\t}\n\n\tremove( item ) {\n\n\t\tconst index = this.children.indexOf( item );\n\n\t\tif ( index !== - 1 ) {\n\n\t\t\tthis.children.splice( index, 1 );\n\t\t\tthis.domElement.removeChild( item.domElement );\n\n\t\t\titem.parent = null;\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n}\n","export class Item {\n\n\tconstructor( ...data ) {\n\n\t\tthis.children = [];\n\t\tthis.isOpen = true;\n\t\tthis.isCollapsible = false;\n\t\tthis.childrenContainer = null;\n\t\tthis.parent = null;\n\t\tthis.domElement = document.createElement( 'div' );\n\t\tthis.domElement.className = 'list-item-wrapper';\n\t\tthis.itemRow = document.createElement( 'div' );\n\t\tthis.itemRow.className = 'list-item-row';\n\n\t\tthis.userData = {};\n\n\t\tthis.data = [];\n\t\tdata.forEach( ( cellData, index ) => {\n\n\t\t\tconst cell = document.createElement( 'div' );\n\t\t\tcell.className = 'list-item-cell';\n\t\t\tthis.itemRow.appendChild( cell );\n\n\t\t\tthis.setValue( index, cellData );\n\n\t\t} );\n\n\t\tthis.domElement.appendChild( this.itemRow );\n\n\t\t// Bindings\n\n\t\tthis.onItemClick = this.onItemClick.bind( this );\n\n\t}\n\n\tonItemClick( e ) {\n\n\t\tif ( e.target.closest( 'button, a, input, label' ) ) return;\n\n\t\tthis.toggle();\n\n\t}\n\n\tadd( item, index = this.children.length ) {\n\n\t\tif ( item.parent !== null ) {\n\n\t\t\titem.parent.remove( item );\n\n\t\t}\n\n\t\titem.parent = this;\n\n\t\tthis.children.splice( index, 0, item );\n\n\t\tthis.itemRow.classList.add( 'collapsible' );\n\n\t\tif ( ! this.childrenContainer ) {\n\n\t\t\tthis.childrenContainer = document.createElement( 'div' );\n\t\t\tthis.childrenContainer.className = 'list-children-container';\n\t\t\tthis.childrenContainer.classList.toggle( 'closed', ! this.isOpen );\n\t\t\tthis.domElement.appendChild( this.childrenContainer );\n\t\t\tthis.itemRow.addEventListener( 'click', this.onItemClick );\n\n\t\t}\n\n\t\tthis.childrenContainer.insertBefore(\n\t\t\titem.domElement,\n\t\t\tthis.childrenContainer.children[ index ] || null\n\t\t);\n\n\t\tthis.updateToggler();\n\t\treturn this;\n\n\t}\n\n\tremove( item ) {\n\n\t\tconst index = this.children.indexOf( item );\n\n\t\tif ( index !== - 1 ) {\n\n\t\t\tthis.children.splice( index, 1 );\n\t\t\tthis.childrenContainer.removeChild( item.domElement );\n\n\t\t\titem.parent = null;\n\n\t\t\tif ( this.children.length === 0 ) {\n\n\t\t\t\tthis.itemRow.classList.remove( 'collapsible' );\n\t\t\t\tthis.itemRow.removeEventListener( 'click', this.onItemClick );\n\n\t\t\t\tthis.childrenContainer.remove();\n\t\t\t\tthis.childrenContainer = null;\n\n\t\t\t}\n\n\t\t\tthis.updateToggler();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tupdateToggler() {\n\n\t\tconst firstCell = this.itemRow.querySelector( '.list-item-cell:first-child' );\n\t\tlet toggler = this.itemRow.querySelector( '.item-toggler' );\n\n\t\tif ( this.children.length > 0 || this.isCollapsible ) {\n\n\t\t\tif ( ! toggler ) {\n\n\t\t\t\ttoggler = document.createElement( 'span' );\n\t\t\t\ttoggler.className = 'item-toggler';\n\t\t\t\tfirstCell.prepend( toggler );\n\n\t\t\t}\n\n\t\t\tif ( this.isOpen ) {\n\n\t\t\t\tthis.itemRow.classList.add( 'open' );\n\n\t\t\t}\n\n\t\t} else if ( toggler ) {\n\n\t\t\ttoggler.remove();\n\n\t\t}\n\n\t}\n\n\tsetCollapsible( collapsible ) {\n\n\t\tthis.isCollapsible = collapsible;\n\n\t\tif ( collapsible ) {\n\n\t\t\tthis.itemRow.classList.add( 'collapsible' );\n\n\t\t\tif ( ! this.childrenContainer ) {\n\n\t\t\t\tthis.childrenContainer = document.createElement( 'div' );\n\t\t\t\tthis.childrenContainer.className = 'list-children-container';\n\t\t\t\tthis.childrenContainer.classList.toggle( 'closed', ! this.isOpen );\n\t\t\t\tthis.domElement.appendChild( this.childrenContainer );\n\t\t\t\tthis.itemRow.addEventListener( 'click', this.onItemClick );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.itemRow.classList.remove( 'collapsible' );\n\n\t\t}\n\n\t\tthis.updateToggler();\n\n\t\treturn this;\n\n\t}\n\n\ttoggle() {\n\n\t\tthis.isOpen = ! this.isOpen;\n\t\tthis.itemRow.classList.toggle( 'open', this.isOpen );\n\n\t\tif ( this.childrenContainer ) {\n\n\t\t\tthis.childrenContainer.classList.toggle( 'closed', ! this.isOpen );\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tclose() {\n\n\t\tif ( this.isOpen ) {\n\n\t\t\tthis.toggle();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tshow() {\n\n\t\tthis.domElement.style.display = '';\n\n\t\treturn this;\n\n\t}\n\n\thide() {\n\n\t\tthis.domElement.style.display = 'none';\n\n\t\treturn this;\n\n\t}\n\n\tsetValue( index, value ) {\n\n\t\tthis.data[ index ] = value;\n\n\t\tconst cell = this.itemRow.children[ index ];\n\n\t\tif ( cell ) {\n\n\t\t\tconst toggler = cell.querySelector( '.item-toggler' );\n\n\t\t\tcell.innerHTML = '';\n\n\t\t\tif ( toggler ) {\n\n\t\t\t\tcell.appendChild( toggler );\n\n\t\t\t}\n\n\t\t\tif ( value instanceof HTMLElement ) {\n\n\t\t\t\tcell.appendChild( value );\n\n\t\t\t} else {\n\n\t\t\t\tcell.append( String( value ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tgetValue( index ) {\n\n\t\treturn this.data[ index ];\n\n\t}\n\n}\n","export function createValueSpan() {\n\n\tconst span = document.createElement( 'span' );\n\tspan.className = 'value';\n\n\treturn span;\n\n}\n\nexport function setText( element, text ) {\n\n\tif ( element && element.textContent !== text ) {\n\n\t\telement.textContent = text;\n\n\t}\n\n}\n\nexport function getText( element ) {\n\n\treturn element ? element.textContent : null;\n\n}\n\nexport function splitPath( fullPath ) {\n\n\tconst lastSlash = fullPath.lastIndexOf( '/' );\n\n\tif ( lastSlash === - 1 ) {\n\n\t\treturn {\n\t\t\tpath: '',\n\t\t\tname: fullPath.trim()\n\t\t};\n\n\t}\n\n\tconst path = fullPath.substring( 0, lastSlash ).trim();\n\tconst name = fullPath.substring( lastSlash + 1 ).trim();\n\n\treturn { path, name };\n\n}\n\nexport function splitCamelCase( str ) {\n\n\treturn str.replace( /([a-z0-9])([A-Z])/g, '$1 $2' ).trim();\n\n}\n\nexport function formatBytes( bytes, decimals = 2 ) {\n\n\tif ( bytes === 0 ) return '0 Bytes';\n\n\tconst k = 1024;\n\tconst dm = decimals < 0 ? 0 : decimals;\n\tconst sizes = [ 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ];\n\tconst i = Math.floor( Math.log( bytes ) / Math.log( k ) );\n\n\treturn parseFloat( ( bytes / Math.pow( k, i ) ).toFixed( dm ) ) + ' ' + sizes[ i ];\n\n}\n\nexport function info( parentNode, text ) {\n\n\tlet infoIcon = parentNode.querySelector( '.info-icon' );\n\n\tif ( ! infoIcon ) {\n\n\t\tinfoIcon = document.createElement( 'span' );\n\t\tinfoIcon.className = 'info-icon';\n\t\tinfoIcon.textContent = 'i';\n\t\tparentNode.appendChild( infoIcon );\n\n\t} else {\n\n\t\tconst newInfoIcon = infoIcon.cloneNode( true );\n\t\tinfoIcon.replaceWith( newInfoIcon );\n\t\tinfoIcon = newInfoIcon;\n\n\t}\n\n\tconst showTooltip = () => {\n\n\t\tconst container = infoIcon.closest( '.three-inspector' ) || document.body;\n\t\tlet tooltip = container.querySelector( '.three-inspector-info-tooltip' );\n\n\t\tif ( ! tooltip ) {\n\n\t\t\ttooltip = document.createElement( 'div' );\n\t\t\ttooltip.className = 'info-tooltip three-inspector-info-tooltip';\n\t\t\tcontainer.appendChild( tooltip );\n\n\t\t}\n\n\t\tconst html = text.trim().replace( /### (.*?)(?:\\r?\\n|$)/g, '<h3>$1</h3>' )\n\t\t\t\t\t .replace( /\\*\\*(.*?)\\*\\*/g, '<strong>$1</strong>' )\n\t\t\t\t\t .replace( /\\n/g, '<br/>' );\n\n\t\ttooltip.innerHTML = html;\n\n\t\tconst rect = infoIcon.getBoundingClientRect();\n\t\tconst tooltipWidth = tooltip.getBoundingClientRect().width;\n\n\t\t// keep the centered tooltip within the viewport so it isn't clipped near an edge\n\n\t\tconst margin = 8;\n\t\tconst half = tooltipWidth / 2;\n\t\tconst center = Math.max( margin + half, Math.min( window.innerWidth - margin - half, rect.left + rect.width / 2 ) );\n\n\t\ttooltip.style.left = center + 'px';\n\t\ttooltip.style.top = ( rect.top - 8 ) + 'px';\n\n\t\ttooltip.style.opacity = '1';\n\t\ttooltip.style.visibility = 'visible';\n\n\t};\n\n\tconst hideTooltip = () => {\n\n\t\tconst container = infoIcon.closest( '.three-inspector' ) || document.body;\n\t\tconst tooltip = container.querySelector( '.three-inspector-info-tooltip' );\n\t\tif ( tooltip ) {\n\n\t\t\ttooltip.style.opacity = '0';\n\t\t\ttooltip.style.visibility = 'hidden';\n\n\t\t}\n\n\t};\n\n\tlet isClickedOpen = false;\n\n\tconst onDocumentPointerDown = ( e ) => {\n\n\t\tif ( ! infoIcon.contains( e.target ) ) {\n\n\t\t\tisClickedOpen = false;\n\t\t\tinfoIcon.classList.remove( 'active' );\n\t\t\thideTooltip();\n\t\t\tdocument.removeEventListener( 'pointerdown', onDocumentPointerDown );\n\n\t\t}\n\n\t};\n\n\tinfoIcon.addEventListener( 'pointerenter', () => {\n\n\t\tshowTooltip();\n\n\t} );\n\n\tinfoIcon.addEventListener( 'pointerleave', () => {\n\n\t\tif ( ! isClickedOpen ) {\n\n\t\t\thideTooltip();\n\n\t\t}\n\n\t} );\n\n\tinfoIcon.addEventListener( 'click', ( e ) => {\n\n\t\te.stopPropagation();\n\n\t\tisClickedOpen = ! isClickedOpen;\n\n\t\tif ( isClickedOpen ) {\n\n\t\t\tinfoIcon.classList.add( 'active' );\n\t\t\tshowTooltip();\n\t\t\tdocument.addEventListener( 'pointerdown', onDocumentPointerDown );\n\n\t\t} else {\n\n\t\t\tinfoIcon.classList.remove( 'active' );\n\t\t\thideTooltip();\n\t\t\tdocument.removeEventListener( 'pointerdown', onDocumentPointerDown );\n\n\t\t}\n\n\t} );\n\n\treturn infoIcon;\n\n}\n\n","import { Tab } from '../ui/Tab.js';\nimport { List } from '../ui/List.js';\nimport { Graph } from '../ui/Graph.js';\nimport { Item } from '../ui/Item.js';\nimport { createValueSpan, setText } from '../ui/utils.js';\n\nclass Performance extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Performance', options );\n\n\t\tconst perfList = new List( 'Name', 'CPU', 'GPU', 'Total' );\n\t\tperfList.setGridStyle( 'minmax(200px, 2fr) 80px 80px 80px' );\n\t\tperfList.domElement.style.minWidth = '600px';\n\n\t\tconst scrollWrapper = document.createElement( 'div' );\n\t\tscrollWrapper.className = 'list-scroll-wrapper';\n\t\tscrollWrapper.appendChild( perfList.domElement );\n\t\tthis.content.appendChild( scrollWrapper );\n\n\t\t//\n\n\t\tconst graphContainer = document.createElement( 'div' );\n\t\tgraphContainer.className = 'graph-container';\n\n\t\tconst graph = new Graph();\n\t\tgraph.addLine( 'fps', 'var( --color-fps )' );\n\t\tgraph.addLine( 'cpu', 'var( --color-yellow )' );\n\t\tgraph.addLine( 'gpu', 'var( --color-green )' );\n\t\tgraphContainer.append( graph.domElement );\n\n\t\t//\n\n\t\t/*\n\t\tconst label = document.createElement( 'label' );\n\t\tlabel.className = 'custom-checkbox';\n\n\t\tconst checkbox = document.createElement( 'input' );\n\t\tcheckbox.type = 'checkbox';\n\n\t\tconst checkmark = document.createElement( 'span' );\n\t\tcheckmark.className = 'checkmark';\n\n\t\tlabel.appendChild( checkbox );\n\t\tlabel.appendChild( checkmark );\n\t\t*/\n\n\t\tthis.graphFpsCounter = createValueSpan();\n\t\tconst graphStats = new Item( 'Graph Stats', createValueSpan(), createValueSpan(), this.graphFpsCounter );\n\t\tperfList.add( graphStats );\n\n\t\tconst graphItem = new Item( graphContainer );\n\t\tgraphItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';\n\t\tgraphStats.add( graphItem );\n\n\t\t//\n\n\t\tconst frameStats = new Item( 'Frame Stats', createValueSpan(), createValueSpan(), createValueSpan() );\n\t\tperfList.add( frameStats );\n\n\t\tconst miscellaneous = new Item( 'Miscellaneous & Idle', createValueSpan(), createValueSpan(), createValueSpan() );\n\t\tmiscellaneous.domElement.firstChild.style.backgroundColor = '#00ff0b1a';\n\t\tmiscellaneous.domElement.firstChild.classList.add( 'no-hover' );\n\t\tframeStats.add( miscellaneous );\n\n\t\t//\n\n\t\tthis.notInUse = new Map();\n\t\tthis.frameStats = frameStats;\n\t\tthis.graphStats = graphStats;\n\t\tthis.graph = graph;\n\t\tthis.miscellaneous = miscellaneous;\n\n\t\t//\n\n\t\tthis.currentRender = null;\n\t\tthis.currentItem = null;\n\t\tthis.frameItems = new Map();\n\n\t}\n\n\tresolveStats( inspector, stats, budget = Infinity ) {\n\n\t\tconst data = inspector.getStatsData( stats.cid );\n\n\t\tlet item = data.item;\n\n\t\tif ( item === undefined ) {\n\n\t\t\titem = new Item( createValueSpan(), createValueSpan(), createValueSpan(), createValueSpan() );\n\n\t\t\tif ( stats.name ) {\n\n\t\t\t\tif ( stats.isComputeStats === true ) {\n\n\t\t\t\t\tstats.name = `${ stats.name } [ Compute ]`;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tstats.name = `Unnamed ${ stats.cid }`;\n\n\t\t\t}\n\n\t\t\titem.userData.name = stats.name;\n\n\t\t\tthis.currentItem.add( item );\n\t\t\tdata.item = item;\n\n\t\t} else {\n\n\t\t\titem.userData.name = stats.name;\n\n\t\t\tif ( this.notInUse.has( stats.cid ) ) {\n\n\t\t\t\titem.domElement.firstElementChild.classList.remove( 'alert' );\n\n\t\t\t\tthis.notInUse.delete( stats.cid );\n\n\t\t\t}\n\n\t\t\tconst statsIndex = stats.parent.children.indexOf( stats );\n\n\t\t\tif ( item.parent === null || item.parent.children.indexOf( item ) !== statsIndex ) {\n\n\t\t\t\tthis.currentItem.add( item, statsIndex );\n\n\t\t\t}\n\n\t\t}\n\n\t\tlet name = item.userData.name;\n\n\t\tif ( stats.isComputeStats ) {\n\n\t\t\tname += ' [ Compute ]';\n\n\t\t}\n\n\t\t// A row never shows more GPU time than its parent, see updateText()\n\n\t\tconst displayGpu = stats.gpuNotAvailable === true ? 0 : Math.min( data.gpu, budget );\n\t\tconst displayTotal = data.cpu + displayGpu;\n\n\t\tsetText( item.data[ 0 ], name );\n\t\tsetText( item.data[ 1 ], data.cpu.toFixed( 2 ) );\n\t\tsetText( item.data[ 2 ], stats.gpuNotAvailable === true ? '-' : displayGpu.toFixed( 2 ) );\n\t\tsetText( item.data[ 3 ], displayTotal.toFixed( 2 ) );\n\n\t\t//\n\n\t\tconst previousItem = this.currentItem;\n\n\t\tthis.currentItem = item;\n\n\t\tconst childBudget = stats.gpuNotAvailable === true ? budget : displayGpu;\n\n\t\tfor ( const child of stats.children ) {\n\n\t\t\tthis.resolveStats( inspector, child, childBudget );\n\n\t\t}\n\n\t\tthis.currentItem = previousItem;\n\n\t\tthis.frameItems.set( stats.cid, item );\n\n\t}\n\n\tupdateGraph( inspector, frame ) {\n\n\t\tconst fps = inspector.fps;\n\n\t\tthis.graph.addPoint( 'fps', fps );\n\n\t\tif ( frame ) {\n\n\t\t\tconst cpuValue = Math.min( ( ( frame.cpu || 0 ) * fps ) / 1000, 1.0 ) * fps;\n\t\t\tconst gpuValue = Math.min( ( ( frame.gpu || 0 ) * fps ) / 1000, 1.0 ) * fps;\n\n\t\t\tthis.graph.addPoint( 'cpu', cpuValue );\n\t\t\tthis.graph.addPoint( 'gpu', gpuValue );\n\n\t\t}\n\n\t\tthis.graph.update();\n\n\t}\n\n\taddNotInUse( cid, item ) {\n\n\t\titem.domElement.firstElementChild.classList.add( 'alert' );\n\n\t\tthis.notInUse.set( cid, {\n\t\t\titem,\n\t\t\ttime: performance.now()\n\t\t} );\n\n\t\tthis.updateNotInUse( cid );\n\n\t}\n\n\tupdateNotInUse( cid ) {\n\n\t\tconst { item, time } = this.notInUse.get( cid );\n\n\t\tconst current = performance.now();\n\t\tconst duration = 5;\n\t\tconst remaining = duration - Math.floor( ( current - time ) / 1000 );\n\n\t\tif ( remaining >= 0 ) {\n\n\t\t\tconst counter = '*'.repeat( Math.max( 0, remaining ) );\n\t\t\tconst element = item.domElement.querySelector( '.list-item-cell .value' );\n\n\t\t\tsetText( element, item.userData.name + ' (not in use) ' + counter );\n\n\t\t} else {\n\n\t\t\titem.domElement.firstElementChild.classList.remove( 'alert' );\n\t\t\titem.parent.remove( item );\n\n\t\t\tthis.notInUse.delete( cid );\n\n\t\t}\n\n\t}\n\n\tupdateText( inspector, frame ) {\n\n\t\tconst oldFrameItems = new Map( this.frameItems );\n\n\t\tthis.frameItems.clear();\n\n\t\t// GPU timestamps can sum to more than the frame time when the GPU overlaps passes, so cap the display at\n\t\t// the frame time, and cap each row at its parent's value\n\n\t\tconst hasTimestamp = inspector.getRenderer().backend.hasTimestamp;\n\t\tconst gpuBudget = hasTimestamp ? Math.min( frame.gpu, frame.deltaTime ) : 0;\n\t\tconst totalDisplay = frame.cpu + gpuBudget;\n\n\t\tthis.currentItem = this.frameStats;\n\n\t\tfor ( const child of frame.children ) {\n\n\t\t\tthis.resolveStats( inspector, child, gpuBudget );\n\n\t\t}\n\n\t\t// remove unused frame items\n\n\t\tfor ( const [ cid, item ] of oldFrameItems ) {\n\n\t\t\tif ( ! this.frameItems.has( cid ) ) {\n\n\t\t\t\tthis.addNotInUse( cid, item );\n\n\t\t\t\toldFrameItems.delete( cid );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// update not in use items\n\n\t\tfor ( const cid of this.notInUse.keys() ) {\n\n\t\t\tthis.updateNotInUse( cid );\n\n\t\t}\n\n\t\t//\n\n\t\tsetText( this.graphFpsCounter, inspector.fps.toFixed() + ' FPS' );\n\n\t\t//\n\n\t\tsetText( this.frameStats.data[ 1 ], frame.cpu.toFixed( 2 ) );\n\t\tsetText( this.frameStats.data[ 2 ], hasTimestamp ? gpuBudget.toFixed( 2 ) : '-' );\n\t\tsetText( this.frameStats.data[ 3 ], totalDisplay.toFixed( 2 ) );\n\n\t\t//\n\n\t\tsetText( this.miscellaneous.data[ 1 ], frame.miscellaneous.toFixed( 2 ) );\n\t\tsetText( this.miscellaneous.data[ 2 ], '-' );\n\t\tsetText( this.miscellaneous.data[ 3 ], frame.miscellaneous.toFixed( 2 ) );\n\n\t\t//\n\n\t\tthis.currentItem = null;\n\n\t}\n\n}\n\nexport { Performance };\n","import { Tab } from '../ui/Tab.js';\nimport { List } from '../ui/List.js';\nimport { Graph } from '../ui/Graph.js';\nimport { Item } from '../ui/Item.js';\nimport { createValueSpan, setText, formatBytes } from '../ui/utils.js';\n\nclass Memory extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Memory', options );\n\n\t\tconst memoryList = new List( 'Name', 'Count', 'Size' );\n\t\tmemoryList.setGridStyle( 'minmax(200px, 2fr) 60px 100px' );\n\t\tmemoryList.domElement.style.minWidth = '300px';\n\n\t\tconst scrollWrapper = document.createElement( 'div' );\n\t\tscrollWrapper.className = 'list-scroll-wrapper';\n\t\tscrollWrapper.appendChild( memoryList.domElement );\n\t\tthis.content.appendChild( scrollWrapper );\n\n\t\t// graph\n\n\t\tconst graphContainer = document.createElement( 'div' );\n\t\tgraphContainer.className = 'graph-container';\n\n\t\tconst graph = new Graph();\n\t\tgraph.addLine( 'total', 'var( --color-yellow )' );\n\t\tgraphContainer.append( graph.domElement );\n\n\t\t// stats\n\n\t\tconst graphStats = new Item( 'Graph Stats', '', '' );\n\t\tmemoryList.add( graphStats );\n\n\t\tconst graphItem = new Item( graphContainer );\n\t\tgraphItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';\n\t\tgraphStats.add( graphItem );\n\n\t\t// info\n\n\t\tthis.memoryStats = new Item( 'Renderer Info', '', createValueSpan() );\n\t\tthis.memoryStats.domElement.firstChild.classList.add( 'no-hover' );\n\t\tmemoryList.add( this.memoryStats );\n\n\t\tthis.attributes = new Item( 'Attributes', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.attributes );\n\n\t\tthis.geometries = new Item( 'Geometries', createValueSpan(), 'N/A' );\n\t\tthis.memoryStats.add( this.geometries );\n\n\t\tthis.indexAttributes = new Item( 'Index Attributes', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.indexAttributes );\n\n\t\tthis.indirectStorageAttributes = new Item( 'Indirect Storage Attributes', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.indirectStorageAttributes );\n\n\t\tthis.programs = new Item( 'Programs', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.programs );\n\n\t\tthis.readbackBuffers = new Item( 'Readback Buffers', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.readbackBuffers );\n\n\t\tthis.renderTargets = new Item( 'Render Targets', createValueSpan(), 'N/A' );\n\t\tthis.memoryStats.add( this.renderTargets );\n\n\t\tthis.storageAttributes = new Item( 'Storage Attributes', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.storageAttributes );\n\n\t\tthis.textures = new Item( 'Textures', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.textures );\n\n\t\tthis.uniformBuffers = new Item( 'Uniform Buffers', createValueSpan(), createValueSpan() );\n\t\tthis.memoryStats.add( this.uniformBuffers );\n\n\t\tthis.graph = graph;\n\n\t}\n\n\tupdateGraph( inspector ) {\n\n\t\tconst renderer = inspector.getRenderer();\n\n\t\tconst memory = renderer.info.memory;\n\n\t\tthis.graph.addPoint( 'total', memory.total );\n\n\t\tif ( this.graph.limit === 0 ) this.graph.limit = 1;\n\n\t\tthis.graph.update();\n\n\t}\n\n\tupdateText( inspector ) {\n\n\t\tconst renderer = inspector.getRenderer();\n\n\t\tconst memory = renderer.info.memory;\n\n\t\tsetText( this.memoryStats.data[ 2 ], formatBytes( memory.total ) );\n\n\t\tsetText( this.attributes.data[ 1 ], memory.attributes.toString() );\n\t\tsetText( this.attributes.data[ 2 ], formatBytes( memory.attributesSize ) );\n\n\t\tsetText( this.geometries.data[ 1 ], memory.geometries.toString() );\n\n\t\tsetText( this.indexAttributes.data[ 1 ], memory.indexAttributes.toString() );\n\t\tsetText( this.indexAttributes.data[ 2 ], formatBytes( memory.indexAttributesSize ) );\n\n\t\tsetText( this.indirectStorageAttributes.data[ 1 ], memory.indirectStorageAttributes.toString() );\n\t\tsetText( this.indirectStorageAttributes.data[ 2 ], formatBytes( memory.indirectStorageAttributesSize ) );\n\n\t\tsetText( this.programs.data[ 1 ], memory.programs.toString() );\n\t\tsetText( this.programs.data[ 2 ], formatBytes( memory.programsSize ) );\n\n\t\tsetText( this.readbackBuffers.data[ 1 ], memory.readbackBuffers.toString() );\n\t\tsetText( this.readbackBuffers.data[ 2 ], formatBytes( memory.readbackBuffersSize ) );\n\n\t\tsetText( this.renderTargets.data[ 1 ], memory.renderTargets.toString() );\n\n\t\tsetText( this.storageAttributes.data[ 1 ], memory.storageAttributes.toString() );\n\t\tsetText( this.storageAttributes.data[ 2 ], formatBytes( memory.storageAttributesSize ) );\n\n\t\tsetText( this.textures.data[ 1 ], memory.textures.toString() );\n\t\tsetText( this.textures.data[ 2 ], formatBytes( memory.texturesSize ) );\n\n\t\tsetText( this.uniformBuffers.data[ 1 ], memory.uniformBuffers.toString() );\n\t\tsetText( this.uniformBuffers.data[ 2 ], formatBytes( memory.uniformBuffersSize ) );\n\n\t}\n\n}\n\nexport { Memory };\n","import { Tab } from '../ui/Tab.js';\n\nclass Console extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Console', options );\n\n\t\tthis.filters = { info: true, warn: true, error: true };\n\t\tthis.filterText = '';\n\n\t\tthis.unreadErrors = 0;\n\t\tthis.unreadWarns = 0;\n\n\t\tthis.tabBadgeContainer = document.createElement( 'span' );\n\t\tthis.tabBadgeContainer.className = 'tab-badge-container';\n\n\t\tthis.tabErrorBadge = document.createElement( 'span' );\n\t\tthis.tabErrorBadge.className = 'tab-badge error';\n\t\tthis.tabErrorBadge.style.display = 'none';\n\n\t\tthis.tabWarnBadge = document.createElement( 'span' );\n\t\tthis.tabWarnBadge.className = 'tab-badge warn';\n\t\tthis.tabWarnBadge.style.display = 'none';\n\n\t\tthis.tabBadgeContainer.appendChild( this.tabErrorBadge );\n\t\tthis.tabBadgeContainer.appendChild( this.tabWarnBadge );\n\t\tthis.button.appendChild( this.tabBadgeContainer );\n\n\t\tthis.buildHeader();\n\n\t\tthis.logContainer = document.createElement( 'div' );\n\t\tthis.logContainer.classList.add( 'console-log' );\n\t\tthis.content.appendChild( this.logContainer );\n\n\t\tthis.lastMessage = null;\n\n\t}\n\n\tbuildHeader() {\n\n\t\tconst header = document.createElement( 'div' );\n\t\theader.className = 'toolbar';\n\n\t\tconst filterInput = document.createElement( 'input' );\n\t\tfilterInput.type = 'text';\n\t\tfilterInput.className = 'console-filter-input';\n\t\tfilterInput.placeholder = 'Filter...';\n\t\tfilterInput.addEventListener( 'input', ( e ) => {\n\n\t\t\tthis.filterText = e.target.value.toLowerCase();\n\t\t\tthis.applyFilters();\n\n\t\t} );\n\n\t\tconst copyButton = document.createElement( 'button' );\n\t\tcopyButton.className = 'console-copy-button';\n\t\tcopyButton.title = 'Copy all';\n\t\tcopyButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"></rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"></path></svg>';\n\t\tcopyButton.addEventListener( 'click', () => this.copyAll( copyButton ) );\n\n\t\tconst buttonsGroup = document.createElement( 'div' );\n\t\tbuttonsGroup.className = 'console-buttons-group';\n\n\t\tObject.keys( this.filters ).forEach( type => {\n\n\t\t\tconst label = document.createElement( 'label' );\n\t\t\tlabel.className = 'custom-checkbox';\n\t\t\tlabel.style.color = `var(--${type === 'info' ? 'text-primary' : 'color-' + ( type === 'warn' ? 'yellow' : 'red' )})`;\n\n\t\t\tconst checkbox = document.createElement( 'input' );\n\t\t\tcheckbox.type = 'checkbox';\n\t\t\tcheckbox.checked = this.filters[ type ];\n\t\t\tcheckbox.dataset.type = type;\n\n\t\t\tconst checkmark = document.createElement( 'span' );\n\t\t\tcheckmark.className = 'checkmark';\n\n\t\t\tconst labelText = document.createElement( 'span' );\n\t\t\tlabelText.className = 'checkbox-text';\n\t\t\tlabelText.textContent = type.charAt( 0 ).toUpperCase() + type.slice( 1 );\n\n\t\t\tlabel.appendChild( checkbox );\n\t\t\tlabel.appendChild( checkmark );\n\t\t\tlabel.appendChild( labelText );\n\t\t\tbuttonsGroup.appendChild( label );\n\n\t\t} );\n\n\t\tbuttonsGroup.addEventListener( 'change', ( e ) => {\n\n\t\t\tconst type = e.target.dataset.type;\n\t\t\tif ( type in this.filters ) {\n\n\t\t\t\tthis.filters[ type ] = e.target.checked;\n\t\t\t\tthis.applyFilters();\n\n\t\t\t}\n\n\t\t} );\n\n\t\tbuttonsGroup.appendChild( copyButton );\n\n\t\theader.appendChild( filterInput );\n\t\theader.appendChild( buttonsGroup );\n\t\tthis.content.appendChild( header );\n\n\t}\n\n\tapplyFilters() {\n\n\t\tconst messages = this.logContainer.querySelectorAll( '.log-message' );\n\t\tmessages.forEach( msg => {\n\n\t\t\tconst type = msg.dataset.type;\n\t\t\tconst text = msg.dataset.rawText.toLowerCase();\n\n\t\t\tconst showByType = this.filters[ type ];\n\t\t\tconst showByText = text.includes( this.filterText );\n\n\t\t\tmsg.classList.toggle( 'hidden', ! ( showByType && showByText ) );\n\n\t\t} );\n\n\t}\n\n\tcopyAll( button ) {\n\n\t\tconst win = this.logContainer.ownerDocument.defaultView;\n\t\tconst selection = win.getSelection();\n\t\tconst selectedText = selection.toString();\n\t\tconst textInConsole = selectedText && this.logContainer.contains( selection.anchorNode );\n\n\t\tlet text;\n\t\tif ( textInConsole ) {\n\n\t\t\ttext = selectedText;\n\n\t\t} else {\n\n\t\t\tconst messages = this.logContainer.querySelectorAll( '.log-message:not(.hidden)' );\n\t\t\ttext = Array.from( messages ).map( msg => msg.dataset.rawText ).join( '\\n' );\n\n\t\t}\n\n\t\tnavigator.clipboard.writeText( text );\n\n\t\tbutton.classList.add( 'copied' );\n\t\tsetTimeout( () => button.classList.remove( 'copied' ), 350 );\n\n\t}\n\n\t_getIcon( type, subType ) {\n\n\t\tlet icon;\n\n\t\tif ( subType === 'tip' ) {\n\n\t\t\ticon = '💭';\n\n\t\t} else if ( subType === 'tsl' ) {\n\n\t\t\ticon = '✨';\n\n\t\t} else if ( subType === 'webgpurenderer' ) {\n\n\t\t\ticon = '🎨';\n\n\t\t} else if ( type === 'warn' ) {\n\n\t\t\ticon = '⚠️';\n\n\t\t} else if ( type === 'error' ) {\n\n\t\t\ticon = '🔴';\n\n\t\t} else if ( type === 'info' ) {\n\n\t\t\ticon = 'ℹ️';\n\n\t\t}\n\n\t\treturn icon;\n\n\t}\n\n\t_formatMessage( type, text ) {\n\n\t\tconst fragment = document.createDocumentFragment();\n\t\tconst prefixMatch = text.match( /^([\\w\\.]+:\\s)/ );\n\t\tlet content = text;\n\n\t\tif ( prefixMatch ) {\n\n\t\t\tconst fullPrefix = prefixMatch[ 0 ];\n\t\t\tconst parts = fullPrefix.slice( 0, - 2 ).split( '.' );\n\t\t\tconst shortPrefix = ( parts.length > 1 ? parts[ parts.length - 1 ] : parts[ 0 ] ) + ':';\n\n\t\t\tconst prefixSpan = document.createElement( 'span' );\n\t\t\tprefixSpan.className = 'log-prefix';\n\t\t\tprefixSpan.textContent = shortPrefix;\n\t\t\tfragment.appendChild( prefixSpan );\n\t\t\tcontent = text.substring( fullPrefix.length );\n\n\t\t}\n\n\t\tconst parts = content.split( /(\".*?\"|'.*?'|`.*?`)/g ).map( p => p.trim() ).filter( Boolean );\n\n\t\tparts.forEach( ( part, index ) => {\n\n\t\t\tif ( /^(\"|'|`)/.test( part ) ) {\n\n\t\t\t\tconst codeSpan = document.createElement( 'span' );\n\t\t\t\tcodeSpan.className = 'log-code';\n\t\t\t\tcodeSpan.textContent = part.slice( 1, - 1 );\n\t\t\t\tfragment.appendChild( codeSpan );\n\n\t\t\t} else {\n\n\t\t\t\tif ( index > 0 ) part = ' ' + part; // add space before parts except the first\n\t\t\t\tif ( index < parts.length - 1 ) part += ' '; // add space between parts\n\n\t\t\t\tfragment.appendChild( document.createTextNode( part ) );\n\n\t\t\t}\n\n\t\t} );\n\n\t\treturn fragment;\n\n\t}\n\n\tsetActive( isActive ) {\n\n\t\tsuper.setActive( isActive );\n\n\t\tif ( isActive ) {\n\n\t\t\tthis.clearUnread();\n\n\t\t}\n\n\t}\n\n\tclearUnread() {\n\n\t\tthis.unreadErrors = 0;\n\t\tthis.unreadWarns = 0;\n\t\tthis.updateBadges();\n\n\t}\n\n\tupdateBadges() {\n\n\t\tif ( ! this.profiler ) return;\n\n\t\tconst errorBadge = this.profiler.toggleButton.querySelector( '.console-badge.error' );\n\t\tconst warnBadge = this.profiler.toggleButton.querySelector( '.console-badge.warn' );\n\n\t\tif ( errorBadge ) {\n\n\t\t\tif ( this.unreadErrors > 0 ) {\n\n\t\t\t\terrorBadge.textContent = this.unreadErrors > 99 ? '+99' : this.unreadErrors;\n\t\t\t\terrorBadge.style.display = '';\n\n\t\t\t} else {\n\n\t\t\t\terrorBadge.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( warnBadge ) {\n\n\t\t\tif ( this.unreadWarns > 0 ) {\n\n\t\t\t\twarnBadge.textContent = this.unreadWarns > 99 ? '+99' : this.unreadWarns;\n\t\t\t\twarnBadge.style.display = '';\n\n\t\t\t} else {\n\n\t\t\t\twarnBadge.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.tabErrorBadge ) {\n\n\t\t\tif ( this.unreadErrors > 0 ) {\n\n\t\t\t\tthis.tabErrorBadge.textContent = this.unreadErrors > 99 ? '+99' : this.unreadErrors;\n\t\t\t\tthis.tabErrorBadge.style.display = '';\n\n\t\t\t} else {\n\n\t\t\t\tthis.tabErrorBadge.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.tabWarnBadge ) {\n\n\t\t\tif ( this.unreadWarns > 0 ) {\n\n\t\t\t\tthis.tabWarnBadge.textContent = this.unreadWarns > 99 ? '+99' : this.unreadWarns;\n\t\t\t\tthis.tabWarnBadge.style.display = '';\n\n\t\t\t} else {\n\n\t\t\t\tthis.tabWarnBadge.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\taddMessage( type, text ) {\n\n\t\tif ( this.lastMessage && this.lastMessage.type === type && this.lastMessage.text === text ) {\n\n\t\t\tthis.lastMessage.count ++;\n\t\t\tthis.lastMessage.countBadge.textContent = this.lastMessage.count;\n\t\t\tthis.lastMessage.countBadge.style.display = '';\n\n\t\t} else {\n\n\t\t\tconst msg = document.createElement( 'div' );\n\t\t\tmsg.className = `log-message ${type}`;\n\t\t\tmsg.dataset.type = type;\n\t\t\tmsg.dataset.rawText = text;\n\n\t\t\tconst countBadge = document.createElement( 'span' );\n\t\t\tcountBadge.className = 'log-count-badge';\n\t\t\tcountBadge.style.display = 'none';\n\t\t\tmsg.appendChild( countBadge );\n\n\t\t\tlet icon = null;\n\t\t\tconst prefixMatch = text.match( /^([\\w\\.]+:\\s)/ );\n\t\t\tif ( prefixMatch ) {\n\n\t\t\t\tconst fullPrefix = prefixMatch[ 0 ];\n\t\t\t\tconst parts = fullPrefix.slice( 0, - 2 ).split( '.' );\n\t\t\t\tconst shortPrefix = ( parts.length > 1 ? parts[ parts.length - 1 ] : parts[ 0 ] ) + ':';\n\t\t\t\ticon = this._getIcon( type, shortPrefix.split( ':' )[ 0 ].toLowerCase() );\n\n\t\t\t}\n\n\t\t\tif ( icon ) {\n\n\t\t\t\tconst iconSpan = document.createElement( 'span' );\n\t\t\t\ticonSpan.className = 'log-icon';\n\t\t\t\ticonSpan.textContent = icon;\n\t\t\t\tmsg.appendChild( iconSpan );\n\n\t\t\t}\n\n\t\t\tconst body = document.createElement( 'span' );\n\t\t\tbody.className = 'log-body';\n\t\t\tbody.appendChild( this._formatMessage( type, text ) );\n\t\t\tmsg.appendChild( body );\n\n\t\t\tconst showByType = this.filters[ type ];\n\t\t\tconst showByText = text.toLowerCase().includes( this.filterText );\n\t\t\tmsg.classList.toggle( 'hidden', ! ( showByType && showByText ) );\n\n\t\t\tthis.logContainer.appendChild( msg );\n\n\t\t\tif ( this.logContainer.children.length > 200 ) {\n\n\t\t\t\tconst firstChild = this.logContainer.firstChild;\n\t\t\t\tthis.logContainer.removeChild( firstChild );\n\t\t\t\tif ( this.lastMessage && this.lastMessage.element === firstChild ) {\n\n\t\t\t\t\tthis.lastMessage = null;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.lastMessage = {\n\t\t\t\ttype,\n\t\t\t\ttext,\n\t\t\t\tcount: 1,\n\t\t\t\telement: msg,\n\t\t\t\tcountBadge\n\t\t\t};\n\n\t\t}\n\n\t\tthis.logContainer.scrollTop = this.logContainer.scrollHeight;\n\n\t\t// Update unread counts if the console is not active/visible\n\t\tconst isUnread = ! this.isActive;\n\n\t\tif ( isUnread ) {\n\n\t\t\tif ( type === 'error' ) {\n\n\t\t\t\tthis.unreadErrors ++;\n\t\t\t\tthis.updateBadges();\n\n\t\t\t} else if ( type === 'warn' ) {\n\n\t\t\t\tthis.unreadWarns ++;\n\t\t\t\tthis.updateBadges();\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\nexport { Console };\n","import { EventDispatcher } from 'three';\n\nclass Value extends EventDispatcher {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.domElement = document.createElement( 'div' );\n\t\tthis.domElement.className = 'param-control';\n\n\t\tthis._onChangeFunction = null;\n\t\tthis._changeTimeout = null;\n\t\tthis._debounceTime = 0;\n\n\t\tthis.addEventListener( 'change', ( e ) => {\n\n\t\t\t// defer to avoid issues when changing multiple values in the same call stack\n\n\t\t\tclearTimeout( this._changeTimeout );\n\n\t\t\tthis._changeTimeout = setTimeout( () => {\n\n\t\t\t\tif ( this._onChangeFunction ) this._onChangeFunction( e.value );\n\n\t\t\t}, this._debounceTime );\n\n\t\t} );\n\n\t}\n\n\tsetValue( /*val*/ ) {\n\n\t\tthis.dispatchChange();\n\n\t\treturn this;\n\n\t}\n\n\tgetValue() {\n\n\t\treturn null;\n\n\t}\n\n\tdispatchChange() {\n\n\t\tthis.dispatchEvent( { type: 'change', value: this.getValue() } );\n\n\t}\n\n\tonChange( callback ) {\n\n\t\tthis._onChangeFunction = callback;\n\n\t\treturn this;\n\n\t}\n\n\tdebounce( time ) {\n\n\t\tthis._debounceTime = time;\n\n\t\treturn this;\n\n\t}\n\n\tshow() {\n\n\t\tthis.dispatchEvent( { type: 'show' } );\n\n\t\treturn this;\n\n\t}\n\n\thide() {\n\n\t\tthis.dispatchEvent( { type: 'hide' } );\n\n\t\treturn this;\n\n\t}\n\n}\n\nclass ValueNumber extends Value {\n\n\tconstructor( { value = 0, step = 0.1, min = - Infinity, max = Infinity } ) {\n\n\t\tsuper();\n\n\t\tthis.input = document.createElement( 'input' );\n\t\tthis.input.type = 'number';\n\t\tthis.input.value = value;\n\t\tthis.input.step = step;\n\t\tthis.input.min = min;\n\t\tthis.input.max = max;\n\t\tthis.input.addEventListener( 'change', this._onChangeValue.bind( this ) );\n\t\tthis.domElement.appendChild( this.input );\n\t\tthis.addDragHandler();\n\n\t}\n\n\t_onChangeValue() {\n\n\t\tconst value = parseFloat( this.input.value );\n\t\tconst min = parseFloat( this.input.min );\n\t\tconst max = parseFloat( this.input.max );\n\n\t\tif ( value > max ) {\n\n\t\t\tthis.input.value = max;\n\n\t\t} else if ( value < min ) {\n\n\t\t\tthis.input.value = min;\n\n\t\t} else if ( isNaN( value ) ) {\n\n\t\t\tthis.input.value = min;\n\n\t\t}\n\n\t\tthis.dispatchChange();\n\n\t}\n\n\taddDragHandler() {\n\n\t\tconst threshold = 2;\n\n\t\tlet isPressed = false;\n\t\tlet isDragging = false;\n\t\tlet startX, startY, startValue;\n\n\t\tthis.input.style.touchAction = 'none';\n\n\t\tthis.input.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\tisPressed = true;\n\t\t\tstartX = e.clientX;\n\t\t\tstartY = e.clientY;\n\t\t\tstartValue = parseFloat( this.input.value );\n\n\t\t} );\n\n\t\tdocument.addEventListener( 'pointermove', ( e ) => {\n\n\t\t\tif ( isPressed ) {\n\n\t\t\t\t// start dragging only after a vertical movement, a horizontal one selects text\n\n\t\t\t\tif ( Math.abs( e.clientY - startY ) > threshold ) {\n\n\t\t\t\t\tisPressed = false;\n\t\t\t\t\tisDragging = true;\n\t\t\t\t\tstartY = e.clientY;\n\t\t\t\t\tthis.input.blur();\n\t\t\t\t\tdocument.body.style.cursor = 'ns-resize';\n\n\t\t\t\t} else if ( Math.abs( e.clientX - startX ) > threshold ) {\n\n\t\t\t\t\tisPressed = false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( isDragging ) {\n\n\t\t\t\tconst deltaY = startY - e.clientY;\n\t\t\t\tconst step = parseFloat( this.input.step ) || 1;\n\t\t\t\tconst min = parseFloat( this.input.min );\n\t\t\t\tconst max = parseFloat( this.input.max );\n\n\t\t\t\tlet stepSize = step;\n\n\t\t\t\tif ( ! isNaN( max ) && isFinite( min ) ) {\n\n\t\t\t\t\tstepSize = ( max - min ) / 100;\n\n\t\t\t\t}\n\n\t\t\t\tconst change = deltaY * stepSize;\n\n\t\t\t\tlet newValue = startValue + change;\n\t\t\t\tnewValue = Math.max( min, Math.min( newValue, max ) );\n\n\t\t\t\tconst precision = ( String( step ).split( '.' )[ 1 ] || [] ).length;\n\t\t\t\tthis.input.value = newValue.toFixed( precision );\n\n\t\t\t\tthis.input.dispatchEvent( new Event( 'input' ) );\n\n\t\t\t\tthis.dispatchChange();\n\n\t\t\t}\n\n\t\t} );\n\n\t\tdocument.addEventListener( 'pointerup', () => {\n\n\t\t\tisPressed = false;\n\n\t\t\tif ( isDragging ) {\n\n\t\t\t\tisDragging = false;\n\t\t\t\tdocument.body.style.cursor = 'default';\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tthis.input.value = val;\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\treturn parseFloat( this.input.value );\n\n\t}\n\n}\n\nclass ValueCheckbox extends Value {\n\n\tconstructor( { value = false } ) {\n\n\t\tsuper();\n\n\t\tconst label = document.createElement( 'label' );\n\t\tlabel.className = 'custom-checkbox';\n\n\t\tconst checkbox = document.createElement( 'input' );\n\t\tcheckbox.type = 'checkbox';\n\t\tcheckbox.checked = value;\n\t\tthis.checkbox = checkbox;\n\n\t\tconst checkmark = document.createElement( 'span' );\n\t\tcheckmark.className = 'checkmark';\n\n\t\tlabel.appendChild( checkbox );\n\t\tlabel.appendChild( checkmark );\n\t\tthis.domElement.appendChild( label );\n\n\t\tcheckbox.addEventListener( 'change', () => {\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tthis.checkbox.checked = val;\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\treturn this.checkbox.checked;\n\n\t}\n\n}\n\nclass ValueSlider extends Value {\n\n\tconstructor( { value = 0, min = 0, max = 1, step = 0.01 } ) {\n\n\t\tsuper();\n\n\t\tthis.slider = document.createElement( 'input' );\n\t\tthis.slider.type = 'range';\n\t\tthis.slider.min = min;\n\t\tthis.slider.max = max;\n\t\tthis.slider.step = step;\n\n\t\tconst numberValue = new ValueNumber( { value, min, max, step } );\n\t\tthis.numberInput = numberValue.input;\n\t\tthis.numberInput.style.flexBasis = '80px';\n\t\tthis.numberInput.style.flexShrink = '0';\n\n\t\tthis.slider.value = value;\n\n\t\tthis.domElement.append( this.slider, this.numberInput );\n\n\t\tthis.slider.addEventListener( 'input', () => {\n\n\t\t\tthis.numberInput.value = this.slider.value;\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t\tnumberValue.addEventListener( 'change', () => {\n\n\t\t\tthis.slider.value = parseFloat( this.numberInput.value );\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tthis.slider.value = val;\n\t\tthis.numberInput.value = val;\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\treturn parseFloat( this.slider.value );\n\n\t}\n\n\tstep( value ) {\n\n\t\tthis.slider.step = value;\n\t\tthis.numberInput.step = value;\n\t\tthis.slider.value = parseFloat( this.numberInput.value );\n\n\t\treturn this;\n\n\t}\n\n}\n\nclass ValueSelect extends Value {\n\n\tconstructor( { options = [], value = '' } ) {\n\n\t\tsuper();\n\n\t\tconst select = document.createElement( 'select' );\n\n\t\tconst createOption = ( name, optionValue ) => {\n\n\t\t\tconst optionEl = document.createElement( 'option' );\n\t\t\toptionEl.value = name;\n\t\t\toptionEl.textContent = name;\n\n\t\t\tif ( optionValue == value ) optionEl.selected = true;\n\n\t\t\tselect.appendChild( optionEl );\n\n\t\t\treturn optionEl;\n\n\t\t};\n\n\t\tif ( Array.isArray( options ) ) {\n\n\t\t\toptions.forEach( opt => createOption( opt, opt ) );\n\n\t\t} else {\n\n\t\t\tObject.entries( options ).forEach( ( [ key, value ] ) => createOption( key, value ) );\n\n\t\t}\n\n\t\tthis.domElement.appendChild( select );\n\n\t\t//\n\n\t\tselect.addEventListener( 'change', () => {\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t\tthis.options = options;\n\t\tthis.select = select;\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tif ( Array.isArray( this.options ) ) {\n\n\t\t\tthis.select.value = val;\n\n\t\t} else {\n\n\t\t\tconst entry = Object.entries( this.options ).find( ( [ , v ] ) => v === val );\n\n\t\t\tif ( entry ) {\n\n\t\t\t\tthis.select.value = entry[ 0 ];\n\n\t\t\t} else {\n\n\t\t\t\tthis.select.value = val;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\tconst options = this.options;\n\n\t\tif ( Array.isArray( options ) ) {\n\n\t\t\treturn options[ this.select.selectedIndex ];\n\n\t\t} else {\n\n\t\t\treturn options[ this.select.value ];\n\n\t\t}\n\n\t}\n\n}\n\nclass ValueColor extends Value {\n\n\tconstructor( { value = '#ffffff' } ) {\n\n\t\tsuper();\n\n\t\tconst colorInput = document.createElement( 'input' );\n\t\tcolorInput.type = 'color';\n\t\tcolorInput.value = this._getColorHex( value );\n\t\tthis.colorInput = colorInput;\n\n\t\tthis._value = value;\n\n\t\tcolorInput.addEventListener( 'input', () => {\n\n\t\t\tconst colorValue = colorInput.value;\n\n\t\t\tif ( this._value.isColor ) {\n\n\t\t\t\tthis._value.setHex( parseInt( colorValue.slice( 1 ), 16 ) );\n\n\t\t\t} else {\n\n\t\t\t\tthis._value = colorValue;\n\n\t\t\t}\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t\tthis.domElement.appendChild( colorInput );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tconst colorHex = this._getColorHex( val );\n\n\t\tthis.colorInput.value = colorHex;\n\n\t\tif ( this._value && this._value.isColor ) {\n\n\t\t\tthis._value.setHex( parseInt( colorHex.slice( 1 ), 16 ) );\n\n\t\t} else {\n\n\t\t\tthis._value = val;\n\n\t\t}\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\t_getColorHex( color ) {\n\n\t\tif ( color && color.isColor ) {\n\n\t\t\tcolor = color.getHex();\n\n\t\t}\n\n\t\tif ( typeof color === 'number' ) {\n\n\t\t\tcolor = '#' + color.toString( 16 ).padStart( 6, '0' );\n\n\t\t} else if ( typeof color === 'string' && color[ 0 ] !== '#' ) {\n\n\t\t\tcolor = '#' + color;\n\n\t\t}\n\n\t\treturn color;\n\n\t}\n\n\tgetValue() {\n\n\t\tlet value = this._value;\n\n\t\tif ( typeof value === 'string' ) {\n\n\t\t\tvalue = parseInt( value.slice( 1 ), 16 );\n\n\t\t}\n\n\t\treturn value;\n\n\t}\n\n}\n\nclass ValueButton extends Value {\n\n\tconstructor( { text = 'Button', value = () => {} } ) {\n\n\t\tsuper();\n\n\t\tconst button = document.createElement( 'button' );\n\t\tbutton.textContent = text;\n\t\tbutton.onclick = value;\n\t\tthis.domElement.appendChild( button );\n\n\t}\n\n}\n\nclass ValueString extends Value {\n\n\tconstructor( { value = '' } ) {\n\n\t\tsuper();\n\n\t\tconst input = document.createElement( 'input' );\n\t\tinput.type = 'text';\n\t\tinput.value = value;\n\t\tthis.input = input;\n\n\t\tinput.addEventListener( 'input', () => {\n\n\t\t\tthis.dispatchChange();\n\n\t\t} );\n\n\t\tthis.domElement.appendChild( input );\n\n\t}\n\n\tsetValue( val ) {\n\n\t\tthis.input.value = val;\n\n\t\treturn super.setValue( val );\n\n\t}\n\n\tgetValue() {\n\n\t\treturn this.input.value;\n\n\t}\n\n}\n\nexport { Value, ValueNumber, ValueString, ValueCheckbox, ValueSlider, ValueSelect, ValueColor, ValueButton };\n","import { Tab } from '../ui/Tab.js';\nimport { List } from '../ui/List.js';\nimport { Item } from '../ui/Item.js';\nimport { createValueSpan, info } from '../ui/utils.js';\nimport { ValueString, ValueNumber, ValueSlider, ValueSelect, ValueCheckbox, ValueColor, ValueButton } from '../ui/Values.js';\n\nclass ParametersGroup {\n\n\tconstructor( parameters, name ) {\n\n\t\tthis.parameters = parameters;\n\n\t\tthis.paramList = new Item( name );\n\t\tthis.paramList.setCollapsible( true );\n\n\t\tthis.objects = [];\n\n\t}\n\n\tclose() {\n\n\t\tthis.paramList.close();\n\n\t\treturn this;\n\n\t}\n\n\tname( name ) {\n\n\t\tthis.paramList.setValue( 0, name );\n\n\t\treturn this;\n\n\t}\n\n\tshow() {\n\n\t\tthis.paramList.show();\n\n\t\treturn this;\n\n\t}\n\n\thide() {\n\n\t\tthis.paramList.hide();\n\n\t\treturn this;\n\n\t}\n\n\tadd( object, property, ...params ) {\n\n\t\tconst value = object[ property ];\n\t\tconst type = typeof value;\n\n\t\tlet item = null;\n\n\t\tif ( typeof params[ 0 ] === 'object' ) {\n\n\t\t\titem = this.addSelect( object, property, params[ 0 ] );\n\n\t\t} else if ( type === 'number' ) {\n\n\t\t\tif ( params.length >= 2 ) {\n\n\t\t\t\titem = this.addSlider( object, property, ...params );\n\n\t\t\t} else {\n\n\t\t\t\titem = this.addNumber( object, property, ...params );\n\n\t\t\t}\n\n\t\t} else if ( type === 'boolean' ) {\n\n\t\t\titem = this.addBoolean( object, property );\n\n\t\t} else if ( type === 'string' ) {\n\n\t\t\titem = this.addString( object, property );\n\n\t\t} else if ( type === 'function' ) {\n\n\t\t\titem = this.addButton( object, property, ...params );\n\n\t\t}\n\n\t\treturn item;\n\n\t}\n\n\t_addInfo( editor, itemNode ) {\n\n\t\teditor.info = ( text ) => {\n\n\t\t\tinfo( itemNode, text );\n\t\t\treturn editor;\n\n\t\t};\n\n\t}\n\n\t_addParameter( object, property, editor, subItem ) {\n\n\t\tsubItem.data[ 0 ].title = property;\n\n\t\teditor.name = ( name ) => {\n\n\t\t\tsubItem.data[ 0 ].title = name;\n\n\t\t\tif ( subItem.data[ 0 ].childNodes.length > 0 && subItem.data[ 0 ].firstChild.nodeType === 3 /* Node.TEXT_NODE */ ) {\n\n\t\t\t\tsubItem.data[ 0 ].firstChild.textContent = name;\n\n\t\t\t} else {\n\n\t\t\t\tsubItem.data[ 0 ].insertBefore( document.createTextNode( name ), subItem.data[ 0 ].firstChild );\n\n\t\t\t}\n\n\t\t\treturn editor;\n\n\t\t};\n\n\t\tthis._addInfo( editor, subItem.data[ 0 ] );\n\n\t\teditor.listen = () => {\n\n\t\t\tconst update = () => {\n\n\t\t\t\tconst value = editor.getValue();\n\t\t\t\tconst propertyValue = object[ property ];\n\n\t\t\t\tif ( value !== propertyValue ) {\n\n\t\t\t\t\teditor.setValue( propertyValue );\n\n\t\t\t\t}\n\n\t\t\t\trequestAnimationFrame( update );\n\n\t\t\t};\n\n\t\t\trequestAnimationFrame( update );\n\n\t\t\treturn editor;\n\n\t\t};\n\n\n\t\tthis._registerParameter( object, property, editor, subItem );\n\n\t}\n\n\t_registerParameter( object, property, editor, subItem ) {\n\n\t\tthis.objects.push( { object: object, key: property, editor: editor, subItem: subItem } );\n\n\t\teditor.addEventListener( 'show', () => subItem.show() );\n\t\teditor.addEventListener( 'hide', () => subItem.hide() );\n\n\t}\n\n\taddString( object, property ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueString( { value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddFolder( name ) {\n\n\t\tconst group = new ParametersGroup( this.parameters, name );\n\n\t\tthis.paramList.add( group.paramList );\n\n\t\treturn group;\n\n\t}\n\n\taddBoolean( object, property ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueCheckbox( { value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\t// extends logic to toggle checkbox when clicking on the row\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\n\t\titemRow.classList.add( 'actionable' );\n\t\titemRow.addEventListener( 'click', ( e ) => {\n\n\t\t\tif ( e.target.closest( 'label' ) ) return;\n\n\t\t\tconst checkbox = itemRow.querySelector( 'input[type=\"checkbox\"]' );\n\n\t\t\tif ( checkbox ) {\n\n\t\t\t\tcheckbox.checked = ! checkbox.checked;\n\t\t\t\tcheckbox.dispatchEvent( new Event( 'change' ) );\n\n\t\t\t}\n\n\t\t} );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddSelect( object, property, options ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueSelect( { options, value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddColor( object, property ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueColor( { value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddSlider( object, property, min = 0, max = 1, step = 0.01 ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueSlider( { value, min, max, step } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddNumber( object, property, ...params ) {\n\n\t\tconst value = object[ property ];\n\t\tconst [ min, max ] = params;\n\n\t\tconst editor = new ValueNumber( { value, min, max } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst description = createValueSpan();\n\t\tdescription.textContent = property;\n\n\t\tconst subItem = new Item( description, editor.domElement );\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\tthis._addParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n\taddButton( object, property ) {\n\n\t\tconst value = object[ property ];\n\n\t\tconst editor = new ValueButton( { text: property, value } );\n\t\teditor.addEventListener( 'change', ( { value } ) => {\n\n\t\t\tobject[ property ] = value;\n\n\t\t} );\n\n\t\tconst subItem = new Item( editor.domElement );\n\t\tsubItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';\n\t\tthis.paramList.add( subItem );\n\n\t\tconst itemRow = subItem.domElement.firstChild;\n\t\titemRow.classList.add( 'actionable' );\n\n\t\t// extend object property\n\n\t\teditor.name = ( name ) => {\n\n\t\t\tconst buttonNode = editor.domElement.childNodes[ 0 ];\n\n\t\t\tif ( buttonNode.childNodes.length > 0 && buttonNode.firstChild.nodeType === 3 /* Node.TEXT_NODE */ ) {\n\n\t\t\t\tbuttonNode.firstChild.textContent = name;\n\n\t\t\t} else {\n\n\t\t\t\tbuttonNode.insertBefore( document.createTextNode( name ), buttonNode.firstChild );\n\n\t\t\t}\n\n\t\t\treturn editor;\n\n\t\t};\n\n\t\tthis._addInfo( editor, editor.domElement.childNodes[ 0 ] );\n\n\t\tthis._registerParameter( object, property, editor, subItem );\n\n\t\treturn editor;\n\n\t}\n\n}\n\nclass Parameters extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( options.name || 'Parameters', options );\n\n\t\tconst paramList = new List( 'Property', 'Value' );\n\t\tparamList.domElement.classList.add( 'parameters' );\n\t\tparamList.setGridStyle( 'minmax(0, .5fr) minmax(0, 1fr)' );\n\t\tparamList.domElement.style.minWidth = '300px';\n\n\t\tconst scrollWrapper = document.createElement( 'div' );\n\t\tscrollWrapper.className = 'list-scroll-wrapper';\n\t\tscrollWrapper.appendChild( paramList.domElement );\n\t\tthis.content.appendChild( scrollWrapper );\n\n\t\tthis.paramList = paramList;\n\n\t\tthis.groups = [];\n\n\t}\n\n\tcreateGroup( name ) {\n\n\t\tconst group = new ParametersGroup( this, name );\n\n\t\tthis.paramList.add( group.paramList );\n\t\tthis.groups.push( group );\n\n\t\treturn group;\n\n\t}\n\n}\n\nexport { Parameters };\n","import { Parameters } from './Parameters.js';\nimport { WebGPURenderer, WebGLBackend, Node } from 'three/webgpu';\nimport { getItem, setItem } from '../Storage.js';\n\nconst _extensions = [\n\t{\n\t\tname: 'Color Grading',\n\t\turl: '../extensions/color-grading/ColorGrading.js'\n\t},\n\t{\n\t\tname: 'TSL Graph',\n\t\turl: '../extensions/tsl-graph/TSLGraphEditor.js'\n\t}\n];\n\nconst _init = WebGPURenderer.prototype.init;\n\nfunction forceWebGL( enable ) {\n\n\tif ( enable ) {\n\n\t\tWebGPURenderer.prototype.init = async function () {\n\n\t\t\tif ( this.backend.isWebGLBackend !== true ) {\n\n\t\t\t\tconst parameters = this.backend.parameters;\n\n\t\t\t\tthis.backend = new WebGLBackend( parameters );\n\n\t\t\t}\n\n\t\t\treturn _init.call( this );\n\n\t\t};\n\n\t} else {\n\n\t\tWebGPURenderer.prototype.init = _init;\n\n\t}\n\n}\n\nlet _state = null;\n\nfunction _loadState() {\n\n\tif ( _state !== null ) return _state;\n\n\tconst settings = getItem( 'settings' );\n\n\t_state = {\n\t\tforceWebGL: settings.forceWebGL !== undefined ? settings.forceWebGL : false,\n\t\tcaptureStackTrace: settings.captureStackTrace !== undefined ? settings.captureStackTrace : false,\n\t\tactiveExtensions: settings.activeExtensions !== undefined ? settings.activeExtensions : {},\n\t\tstorage: settings.storage !== undefined ? settings.storage : 'url'\n\t};\n\n\tif ( _state.forceWebGL ) {\n\n\t\tforceWebGL( true );\n\n\t}\n\n\tif ( _state.captureStackTrace ) {\n\n\t\tNode.captureStackTrace = true;\n\n\t}\n\n\treturn _state;\n\n}\n\nfunction _saveState() {\n\n\tsetItem( 'settings', {\n\t\tforceWebGL: _state.forceWebGL,\n\t\tcaptureStackTrace: _state.captureStackTrace,\n\t\tactiveExtensions: _state.activeExtensions,\n\t\tstorage: _state.storage\n\t} );\n\n}\n\n_loadState();\n\n//\n\nclass Settings extends Parameters {\n\n\tconstructor() {\n\n\t\tsuper( { name: 'Settings' } );\n\n\t\tthis.extensions = {};\n\n\t\tconst currentState = _loadState();\n\n\t\t// UI\n\n\t\tconst rendererGroup = this.createGroup( 'Renderer' );\n\n\t\trendererGroup.add( currentState, 'forceWebGL' ).name( 'Force WebGL' ).onChange( ( enable ) => {\n\n\t\t\tforceWebGL( enable );\n\t\t\t_saveState();\n\n\t\t\tlocation.reload();\n\n\t\t} );\n\n\t\trendererGroup.add( currentState, 'captureStackTrace' ).name( 'Capture Stack Trace' ).onChange( ( enable ) => {\n\n\t\t\tNode.captureStackTrace = enable;\n\t\t\t_saveState();\n\n\t\t\tlocation.reload();\n\n\t\t} );\n\n\t\t// Render Modes\n\n\t\tconst modesGroup = this.createGroup( 'Render Modes' );\n\n\t\tmodesGroup.add( { overdraw: false }, 'overdraw' ).name( 'Overdraw' ).onChange( ( enable ) => {\n\n\t\t\tthis.inspector.overdraw = enable;\n\n\t\t} ).info( 'Shows how many times each pixel is shaded.' );\n\n\t}\n\n\tinit() {\n\n\t\tconst extensionsGroup = this.createGroup( 'Extensions' );\n\n\t\tconst storageGroup = this.createGroup( 'Storage' );\n\n\t\tconst currentState = _loadState();\n\n\t\tstorageGroup.add( currentState, 'storage', { 'URL Session': 'url', 'Keep across Origin': 'origin' } )\n\t\t\t.name( 'Save Settings' )\n\t\t\t.onChange( () => {\n\n\t\t\t\t_saveState();\n\n\t\t\t} ).info( `\nDefines how the **Inspector** preferences and states are stored in the browser.\n\n**URL Session**\nSaves state based on the exact URL. It will reset the settings whenever the URL changes.\n\n**Keep across Origin**\nShares the same state across any page within the current origin.` );\n\n\t\tstorageGroup.add( {\n\t\t\tclear: () => {\n\n\t\t\t\tlocalStorage.removeItem( 'threejs-inspector' );\n\n\t\t\t\tlocation.reload();\n\n\t\t\t}\n\t\t}, 'clear' ).name( 'Clear Settings' );\n\n\t\tthis._getExtensions().then( extensions => {\n\n\t\t\tfor ( const extension of extensions ) {\n\n\t\t\t\textension.active = false;\n\t\t\t\textension.loaded = false;\n\t\t\t\textension.tab = null;\n\n\t\t\t\tthis.extensions[ extension.name ] = extension;\n\n\t\t\t\textension.ui = extensionsGroup.add( { [ extension.name ]: false }, extension.name ).onChange( async ( value ) => {\n\n\t\t\t\t\tthis.setActiveExtension( extension.name, value );\n\n\t\t\t\t\t// User preference\n\n\t\t\t\t\tif ( value ) {\n\n\t\t\t\t\t\t_state.activeExtensions[ extension.name ] = {\n\t\t\t\t\t\t\tname: extension.name,\n\t\t\t\t\t\t\turl: extension.url\n\t\t\t\t\t\t};\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tdelete _state.activeExtensions[ extension.name ];\n\n\n\t\t\t\t\t}\n\n\t\t\t\t\t//\n\n\t\t\t\t\tthis._updateExtensionUI( extension );\n\n\t\t\t\t\t_saveState();\n\n\t\t\t\t} );\n\n\t\t\t\t// Set user-defined state\n\n\t\t\t\tif ( _state.activeExtensions[ extension.name ] !== undefined ) {\n\n\t\t\t\t\textension.ui.setValue( true );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tasync setActiveExtension( name, value ) {\n\n\t\tconst extension = this.extensions[ name ];\n\t\tconst inspector = this.inspector;\n\n\t\tif ( extension ) {\n\n\t\t\tif ( value ) {\n\n\t\t\t\tawait this._loadExtension( inspector, extension );\n\n\t\t\t} else {\n\n\t\t\t\tawait this._unloadExtension( inspector, extension );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t_updateExtensionUI( extension ) {\n\n\t\tconst forceActive = extension.active && _state.activeExtensions[ extension.name ] === undefined;\n\n\t\tif ( forceActive ) {\n\n\t\t\textension.ui.checkbox.checked = true;\n\t\t\textension.ui.domElement.style.setProperty( '--accent-color', 'var(--color-green)' );\n\n\t\t} else {\n\n\t\t\textension.ui.domElement.style.removeProperty( '--accent-color' );\n\n\t\t}\n\n\t}\n\n\tasync _unloadExtension( inspector, extension ) {\n\n\t\tif ( extension.active === false ) return;\n\n\t\t//\n\n\t\tinspector.removeTab( extension.tab );\n\n\t\textension.active = false;\n\t\textension.loaded = false;\n\t\textension.tab = null;\n\n\t\tthis._updateExtensionUI( extension );\n\n\t\tthis.dispatchEvent( { type: 'extensionremoved', name: extension.name } );\n\n\t}\n\n\tasync _loadExtension( inspector, extension ) {\n\n\t\tif ( extension.active === true ) return;\n\n\t\t//\n\n\t\textension.active = true;\n\n\t\tconst extUrl = new URL( extension.url, import.meta.url ).href;\n\n\t\tconst module = await import( extUrl );\n\n\t\tconst keys = Object.keys( module );\n\t\tconst ExtensionClass = module[ keys[ 0 ] ];\n\t\tconst extensionTab = new ExtensionClass();\n\n\t\tinspector.addTab( extensionTab );\n\n\t\textension.loaded = true;\n\t\textension.tab = extensionTab;\n\n\t\tthis._updateExtensionUI( extension );\n\n\t\tthis.dispatchEvent( { type: 'extensionadded', name: extension.name, tab: extensionTab } );\n\n\t}\n\n\tasync _getExtensions() {\n\n\t\treturn _extensions;\n\n\t}\n\n}\n\nexport { Settings };\n","import { Tab } from '../ui/Tab.js';\nimport { List } from '../ui/List.js';\nimport { Item } from '../ui/Item.js';\nimport { splitPath, splitCamelCase } from '../ui/utils.js';\nimport { getItem, setItem } from '../Storage.js';\n\nimport { RendererUtils, NoToneMapping, LinearSRGBColorSpace, QuadMesh, NodeMaterial, CanvasTarget, Vector2, Color } from 'three/webgpu';\nimport { renderOutput, rtt, vec2, vec3, vec4, Fn, screenUV, step, OnMaterialUpdate, uniform, float } from 'three/tsl';\n\nconst _size = /*@__PURE__*/ new Vector2();\n\nconst splitIcon = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"12\" y1=\"1\" x2=\"12\" y2=\"23\"></line><polyline points=\"5 8 1 12 5 16\"></polyline><polyline points=\"19 8 23 12 19 16\"></polyline></svg>';\nconst fullscreenIcon = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3\"/></svg>';\nconst backIcon = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg>';\n\nconst aspectRatioUV = /*@__PURE__*/ Fn( ( [ uv, textureNode, canvasAspect ] ) => {\n\n\tconst textureAspect = uniform( 0 );\n\n\tOnMaterialUpdate( () => {\n\n\t\tconst { width, height } = textureNode.value;\n\n\t\ttextureAspect.value = width / height;\n\n\t} );\n\n\tconst ratio = canvasAspect.div( textureAspect );\n\n\tconst centered = uv.sub( 0.5 );\n\n\t// If canvasAspect > textureAspect:\n\tconst uvWide = vec2( centered.x.mul( ratio ), centered.y ).add( 0.5 );\n\n\t// If canvasAspect <= textureAspect:\n\tconst uvTall = vec2( centered.x, centered.y.div( ratio ) ).add( 0.5 );\n\n\tconst finalUV = canvasAspect.greaterThan( textureAspect ).select( uvWide, uvTall );\n\n\tconst inBounds = step( 0.0, finalUV.x ).mul( step( finalUV.x, 1.0 ) ).mul( step( 0.0, finalUV.y ) ).mul( step( finalUV.y, 1.0 ) );\n\n\treturn vec3( finalUV, inBounds );\n\n} );\n\nclass Viewer extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Viewer', options );\n\n\t\tthis.content.style.overflow = 'hidden';\n\t\tthis.maximizedByFullscreenButton = false;\n\n\t\t// Toolbar\n\t\tconst toolbar = document.createElement( 'div' );\n\t\ttoolbar.className = 'toolbar';\n\n\t\tconst backBtn = document.createElement( 'button' );\n\t\tbackBtn.className = 'viewer-back-btn';\n\t\tbackBtn.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line><polyline points=\"12 19 5 12 12 5\"></polyline></svg>';\n\t\tbackBtn.title = 'Back';\n\t\tbackBtn.style.display = 'none';\n\t\ttoolbar.appendChild( backBtn );\n\n\t\tconst label = document.createElement( 'span' );\n\t\tlabel.textContent = 'View:';\n\t\ttoolbar.appendChild( label );\n\n\t\tconst select = document.createElement( 'select' );\n\t\tselect.className = 'select';\n\t\tselect.style.width = '200px';\n\n\t\tconst defaultOption = document.createElement( 'option' );\n\t\tdefaultOption.value = 'list';\n\t\tdefaultOption.textContent = 'List';\n\t\tselect.appendChild( defaultOption );\n\n\t\ttoolbar.appendChild( select );\n\n\t\tconst nodeList = new List( 'Viewer', 'Name' );\n\t\tnodeList.setGridStyle( '150px minmax(200px, 2fr)' );\n\t\tnodeList.domElement.style.minWidth = '400px';\n\t\tthis.nodeList = nodeList;\n\n\t\tthis.content.appendChild( toolbar );\n\n\t\tconst scrollWrapper = document.createElement( 'div' );\n\t\tscrollWrapper.className = 'list-scroll-wrapper';\n\t\tscrollWrapper.style.flexGrow = '1';\n\t\tscrollWrapper.style.overflowY = 'auto';\n\t\tscrollWrapper.style.minHeight = '0';\n\t\tscrollWrapper.appendChild( nodeList.domElement );\n\t\tthis.content.appendChild( scrollWrapper );\n\n\t\t// Container for full screen view\n\t\tconst fullViewerContainer = document.createElement( 'div' );\n\t\tfullViewerContainer.className = 'full-viewer-container';\n\t\tfullViewerContainer.style.touchAction = 'none';\n\t\tthis.content.appendChild( fullViewerContainer );\n\n\t\tconst nodes = new Item( 'User Defined' );\n\t\tnodes.setCollapsible( true );\n\t\tnodeList.add( nodes );\n\n\t\t//\n\n\t\tthis.itemLibrary = new Map();\n\t\tthis.folderLibrary = new Map();\n\t\tthis.canvasNodes = new Map();\n\t\tthis.currentDataList = [];\n\t\tthis.nodes = nodes;\n\t\tthis.scrollWrapper = scrollWrapper;\n\t\tthis.fullViewerContainer = fullViewerContainer;\n\t\tthis.select = select;\n\t\tthis.backBtn = backBtn;\n\t\tthis.activeFullNodeId = null;\n\t\tthis.pendingRestoreView = true;\n\n\t\tthis.splitActive = false;\n\t\tthis.splitCanvasData = null;\n\t\tthis.splitOverlay = null;\n\t\tthis.splitLine = null;\n\t\tthis.splitQuad = null;\n\t\tthis.splitMaterial = null;\n\t\tthis.splitUniforms = null;\n\t\tthis.splitCanvas = null;\n\t\tthis.splitCanvasTarget = null;\n\n\t\tbackBtn.addEventListener( 'click', () => {\n\n\t\t\tif ( this.splitActive ) {\n\n\t\t\t\tthis.stopSplitMode();\n\n\t\t\t}\n\n\t\t\tselect.value = 'list';\n\t\t\tthis.showListView();\n\n\t\t\tif ( this.maximizedByFullscreenButton ) {\n\n\t\t\t\tif ( this.profiler && this.profiler.panel.classList.contains( 'maximized' ) ) {\n\n\t\t\t\t\tthis.profiler.toggleMaximize();\n\n\t\t\t\t}\n\n\t\t\t\tthis.maximizedByFullscreenButton = false;\n\n\t\t\t}\n\n\t\t\tthis.saveLastView();\n\n\t\t} );\n\n\t\tselect.addEventListener( 'change', () => {\n\n\t\t\tconst val = select.value;\n\n\t\t\tif ( val === 'list' ) {\n\n\t\t\t\tthis.showListView();\n\n\t\t\t} else {\n\n\t\t\t\tthis.showNodeView( val );\n\n\t\t\t}\n\n\t\t\tthis.saveLastView();\n\n\t\t} );\n\n\t\t// Event forwarding setup for OrbitControls\n\t\tthis.isDraggingThumbnail = false;\n\t\tthis.activeSourceCanvas = null;\n\t\tthis.activePointerIds = new Set();\n\n\t\tconst handleGlobalPointer = ( e ) => {\n\n\t\t\tif ( ! this.isDraggingThumbnail || ! this.activeSourceCanvas ) return;\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\tif ( e.isForwarded ) return;\n\n\t\t\t// Block native event from reaching other document-level listeners (OrbitControls)\n\t\t\te.stopImmediatePropagation();\n\t\t\te.preventDefault();\n\n\t\t\t// Project and dispatch forwarded event\n\t\t\tthis.forwardEvent( e, this.activeSourceCanvas, renderer.domElement );\n\n\t\t\tif ( e.type === 'pointerup' || e.type === 'pointercancel' ) {\n\n\t\t\t\tthis.activePointerIds.delete( e.pointerId );\n\n\t\t\t\tif ( this.activePointerIds.size === 0 ) {\n\n\t\t\t\t\tthis.isDraggingThumbnail = false;\n\t\t\t\t\tthis.activeSourceCanvas = null;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\twindow.addEventListener( 'pointermove', handleGlobalPointer, true );\n\t\twindow.addEventListener( 'pointerup', handleGlobalPointer, true );\n\t\twindow.addEventListener( 'pointercancel', handleGlobalPointer, true );\n\n\t}\n\n\tgetFolder( name ) {\n\n\t\tlet folder = this.folderLibrary.get( name );\n\n\t\tif ( folder === undefined ) {\n\n\t\t\tfolder = new Item( name );\n\t\t\tfolder.setCollapsible( true );\n\n\t\t\tthis.folderLibrary.set( name, folder );\n\t\t\tthis.nodeList.add( folder );\n\n\t\t}\n\n\t\treturn folder;\n\n\t}\n\n\thide() {\n\n\t\tsuper.hide();\n\t\tthis.maximizedByFullscreenButton = false;\n\t\tthis.isDraggingThumbnail = false;\n\t\tthis.activeSourceCanvas = null;\n\t\tthis.activePointerIds.clear();\n\n\t\tif ( this.splitActive ) {\n\n\t\t\tthis.stopSplitMode();\n\n\t\t}\n\n\t}\n\n\taddNodeItem( canvasData ) {\n\n\t\tlet item = this.itemLibrary.get( canvasData.id );\n\n\t\tif ( item === undefined ) {\n\n\t\t\tconst name = canvasData.name;\n\t\t\tconst domElement = canvasData.canvasTarget.domElement;\n\n\t\t\t// Create wrapper\n\t\t\tconst wrapper = document.createElement( 'div' );\n\t\t\twrapper.className = 'node-canvas-wrapper';\n\t\t\twrapper.style.position = 'relative';\n\t\t\twrapper.style.display = 'inline-block';\n\t\t\twrapper.style.width = '140px';\n\t\t\twrapper.style.height = '140px';\n\t\t\twrapper.style.touchAction = 'none';\n\n\t\t\t// View full screen button\n\t\t\tconst viewBtn = document.createElement( 'button' );\n\t\t\tviewBtn.className = 'node-canvas-detach-btn';\n\t\t\tviewBtn.title = 'View full size';\n\t\t\tviewBtn.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"7\" y1=\"17\" x2=\"17\" y2=\"7\"></line><polyline points=\"7 7 17 7 17 17\"></polyline></svg>';\n\n\t\t\tviewBtn.onclick = ( e ) => {\n\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tif ( this.splitActive ) {\n\n\t\t\t\t\tthis.stopSplitMode();\n\n\t\t\t\t}\n\n\t\t\t\tthis.select.value = canvasData.id;\n\t\t\t\tthis.showNodeView( canvasData.id );\n\t\t\t\tthis.saveLastView();\n\n\t\t\t};\n\n\t\t\t// Fullscreen and maximize button\n\t\t\tconst fullscreenBtn = document.createElement( 'button' );\n\t\t\tfullscreenBtn.className = 'node-canvas-fullscreen-btn';\n\t\t\tfullscreenBtn.title = 'Fullscreen view';\n\t\t\tfullscreenBtn.innerHTML = fullscreenIcon;\n\n\t\t\tfullscreenBtn.onclick = ( e ) => {\n\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tif ( this.splitActive && this.splitCanvasData === canvasData && this.splitFullscreen ) {\n\n\t\t\t\t\tthis.stopSplitMode();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis.splitFullscreen = true;\n\t\t\t\t\tthis.startSplitMode( canvasData );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t\t// Split screen button\n\t\t\tconst splitBtn = document.createElement( 'button' );\n\t\t\tsplitBtn.className = 'node-canvas-split-btn';\n\t\t\tsplitBtn.title = 'Interactive split screen';\n\t\t\tsplitBtn.innerHTML = splitIcon;\n\n\t\t\tsplitBtn.onclick = ( e ) => {\n\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tif ( this.splitActive && this.splitCanvasData === canvasData && ! this.splitFullscreen ) {\n\n\t\t\t\t\tthis.stopSplitMode();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis.splitFullscreen = false;\n\t\t\t\t\tthis.startSplitMode( canvasData );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t\twrapper.appendChild( domElement );\n\t\t\twrapper.appendChild( viewBtn );\n\t\t\twrapper.appendChild( fullscreenBtn );\n\t\t\twrapper.appendChild( splitBtn );\n\n\t\t\tthis.setupEventForwarding( domElement );\n\n\t\t\t// Store elements in canvasData for access\n\t\t\tcanvasData.domElement = domElement;\n\t\t\tcanvasData.wrapperElement = wrapper;\n\t\t\tcanvasData.splitBtn = splitBtn;\n\t\t\tcanvasData.fullscreenBtn = fullscreenBtn;\n\n\t\t\titem = new Item( wrapper, name );\n\t\t\titem.itemRow.children[ 1 ].style[ 'justify-content' ] = 'flex-start';\n\t\t\tthis.itemLibrary.set( canvasData.id, item );\n\n\t\t}\n\n\t\treturn item;\n\n\t}\n\n\tsetupEventForwarding( sourceCanvas ) {\n\n\t\tsourceCanvas.style.touchAction = 'none';\n\n\t\tconst onPointerDown = ( e ) => {\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\tif ( ! renderer || ! renderer.domElement ) return;\n\n\t\t\tconst targetCanvas = renderer.domElement;\n\n\t\t\tthis.isDraggingThumbnail = true;\n\t\t\tthis.activeSourceCanvas = sourceCanvas;\n\t\t\tthis.activePointerIds.add( e.pointerId );\n\n\t\t\t// Project and dispatch pointerdown\n\t\t\tthis.forwardEvent( e, sourceCanvas, targetCanvas );\n\n\t\t};\n\n\t\tsourceCanvas.addEventListener( 'pointerdown', onPointerDown );\n\n\t\t// Wheel event support for zooming\n\t\tconst onWheel = ( e ) => {\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\tif ( ! renderer || ! renderer.domElement ) return;\n\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\n\t\t\tthis.forwardEvent( e, sourceCanvas, renderer.domElement );\n\n\t\t};\n\n\t\tsourceCanvas.addEventListener( 'wheel', onWheel, { passive: false } );\n\n\t\t// Click, dblclick, contextmenu\n\t\tconst onMouseShortcut = ( e ) => {\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\tif ( ! renderer || ! renderer.domElement ) return;\n\n\t\t\te.stopPropagation();\n\n\t\t\tif ( e.type === 'contextmenu' ) {\n\n\t\t\t\te.preventDefault();\n\n\t\t\t}\n\n\t\t\tthis.forwardEvent( e, sourceCanvas, renderer.domElement );\n\n\t\t};\n\n\t\tsourceCanvas.addEventListener( 'click', onMouseShortcut );\n\t\tsourceCanvas.addEventListener( 'dblclick', onMouseShortcut );\n\t\tsourceCanvas.addEventListener( 'contextmenu', onMouseShortcut );\n\n\t}\n\n\tforwardEvent( event, sourceCanvas, targetCanvas ) {\n\n\t\tconst sourceRect = sourceCanvas.getBoundingClientRect();\n\t\tconst targetRect = targetCanvas.getBoundingClientRect();\n\n\t\tconst localX = ( event.clientX - sourceRect.left ) / sourceRect.width;\n\t\tconst localY = ( event.clientY - sourceRect.top ) / sourceRect.height;\n\n\t\tconst targetClientX = targetRect.left + localX * targetRect.width;\n\t\tconst targetClientY = targetRect.top + localY * targetRect.height;\n\t\tconst targetPageX = targetClientX + window.scrollX;\n\t\tconst targetPageY = targetClientY + window.scrollY;\n\n\t\tlet newEvent;\n\n\t\tconst eventInit = {\n\t\t\tbubbles: true,\n\t\t\tcancelable: true,\n\t\t\tview: window,\n\t\t\tclientX: targetClientX,\n\t\t\tclientY: targetClientY,\n\t\t\tscreenX: targetClientX + window.screenX,\n\t\t\tscreenY: targetClientY + window.screenY,\n\t\t\tpageX: targetPageX,\n\t\t\tpageY: targetPageY,\n\t\t\tctrlKey: event.ctrlKey,\n\t\t\tshiftKey: event.shiftKey,\n\t\t\taltKey: event.altKey,\n\t\t\tmetaKey: event.metaKey,\n\t\t\tbuttons: event.buttons,\n\t\t\tbutton: event.button\n\t\t};\n\n\t\tif ( event instanceof WheelEvent ) {\n\n\t\t\tnewEvent = new WheelEvent( event.type, {\n\t\t\t\t...eventInit,\n\t\t\t\tdeltaX: event.deltaX,\n\t\t\t\tdeltaY: event.deltaY,\n\t\t\t\tdeltaZ: event.deltaZ,\n\t\t\t\tdeltaMode: event.deltaMode\n\t\t\t} );\n\n\t\t} else if ( window.PointerEvent && event instanceof PointerEvent ) {\n\n\t\t\tnewEvent = new PointerEvent( event.type, {\n\t\t\t\t...eventInit,\n\t\t\t\tpointerId: event.pointerId,\n\t\t\t\twidth: event.width,\n\t\t\t\theight: event.height,\n\t\t\t\tpressure: event.pressure,\n\t\t\t\ttiltX: event.tiltX,\n\t\t\t\ttiltY: event.tiltY,\n\t\t\t\tpointerType: event.pointerType,\n\t\t\t\tisPrimary: event.isPrimary\n\t\t\t} );\n\n\t\t} else {\n\n\t\t\tnewEvent = new MouseEvent( event.type, eventInit );\n\n\t\t}\n\n\t\tnewEvent.isForwarded = true;\n\t\ttargetCanvas.dispatchEvent( newEvent );\n\n\t}\n\n\tinit( inspector ) {\n\n\t\tsuper.init( inspector );\n\n\t\tconst updateLayoutFromPosition = () => {\n\n\t\t\tconst position = inspector.profiler.position;\n\t\t\tconst isHorizontal = position === 'top' || position === 'bottom';\n\t\t\tthis.setViewMode( isHorizontal ? 'grid' : 'list' );\n\n\t\t};\n\n\t\tinspector.profiler.addEventListener( 'resize', updateLayoutFromPosition );\n\n\t\t// Run initially once\n\t\tupdateLayoutFromPosition();\n\n\t}\n\n\tsetViewMode( mode ) {\n\n\t\tif ( this.nodeList ) {\n\n\t\t\tif ( mode === 'grid' ) {\n\n\t\t\t\tthis.nodeList.domElement.style.minWidth = '0';\n\n\t\t\t} else {\n\n\t\t\t\tthis.nodeList.domElement.style.minWidth = '400px';\n\n\t\t\t}\n\n\t\t\tthis.nodeList.setViewMode( mode );\n\n\t\t}\n\n\t}\n\n\tshowListView() {\n\n\t\tif ( this.activeFullNodeId ) {\n\n\t\t\tconst canvasData = Array.from( this.canvasNodes.values() ).find( data => String( data.id ) === String( this.activeFullNodeId ) );\n\n\t\t\tif ( canvasData ) {\n\n\t\t\t\t// Move canvas back to wrapper\n\t\t\t\tcanvasData.wrapperElement.appendChild( canvasData.domElement );\n\n\t\t\t\t// Reset size\n\t\t\t\tcanvasData.domElement.style.width = '';\n\t\t\t\tcanvasData.domElement.style.height = '';\n\t\t\t\tcanvasData.canvasTarget.setSize( 140, 140 );\n\n\t\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\t\trenderer.backend.delete( canvasData.canvasTarget );\n\n\t\t\t}\n\n\t\t\tthis.activeFullNodeId = null;\n\n\t\t}\n\n\t\tthis.scrollWrapper.style.display = '';\n\t\tthis.fullViewerContainer.style.display = 'none';\n\t\tthis.backBtn.style.display = 'none';\n\n\t}\n\n\tshowNodeView( nodeId ) {\n\n\t\t// First restore previous full screen node if any\n\t\tif ( this.activeFullNodeId && String( this.activeFullNodeId ) !== String( nodeId ) ) {\n\n\t\t\tthis.showListView();\n\n\t\t}\n\n\t\tconst canvasData = Array.from( this.canvasNodes.values() ).find( data => String( data.id ) === String( nodeId ) );\n\n\t\tif ( canvasData ) {\n\n\t\t\tthis.addNodeItem( canvasData );\n\n\t\t\tthis.activeFullNodeId = nodeId;\n\t\t\tthis.backBtn.style.display = 'flex';\n\n\t\t\t// Hide list, show full screen container\n\t\t\tthis.scrollWrapper.style.display = 'none';\n\t\t\tthis.fullViewerContainer.style.display = 'flex';\n\n\t\t\t// Move canvas to the full viewer container\n\t\t\tthis.fullViewerContainer.appendChild( canvasData.domElement );\n\t\t\tcanvasData.domElement.style.width = '100%';\n\t\t\tcanvasData.domElement.style.height = '100%';\n\n\t\t\t// Resize canvas to fit full viewer container\n\t\t\tconst rect = this.fullViewerContainer.getBoundingClientRect();\n\t\t\tconst contentWidth = rect.width || this.content.clientWidth;\n\t\t\tconst contentHeight = rect.height || ( this.content.clientHeight - 38 ); // minus toolbar\n\t\t\tcanvasData.canvasTarget.setSize( contentWidth, contentHeight );\n\n\t\t\tconst renderer = this.inspector.getRenderer();\n\n\t\t\trenderer.backend.delete( canvasData.canvasTarget );\n\n\t\t}\n\n\t}\n\n\tget isActive() {\n\n\t\tif ( this.splitActive ) return true;\n\n\t\treturn super.isActive;\n\n\t}\n\n\tset isActive( value ) {\n\n\t\tsuper.isActive = value;\n\n\t}\n\n\tstartSplitMode( canvasData ) {\n\n\t\tif ( this.profiler && this.profiler.panel.classList.contains( 'visible' ) ) {\n\n\t\t\tthis.profiler.togglePanel();\n\n\t\t}\n\n\t\tthis.splitActive = true;\n\t\tthis.splitCanvasData = canvasData;\n\t\tthis.splitX = 0.5;\n\n\t\tconst renderer = this.inspector.getRenderer();\n\t\tconst mainCanvas = renderer.domElement;\n\t\tconst rect = mainCanvas.getBoundingClientRect();\n\t\tconst targetParent = document.fullscreenElement || this.profiler.domElement;\n\t\tconst parentRect = targetParent.getBoundingClientRect();\n\t\tconst localLeft = rect.left - parentRect.left;\n\t\tconst localTop = rect.top - parentRect.top;\n\n\t\t// Position target canvas on top of main canvas\n\t\tif ( ! this.splitCanvas ) {\n\n\t\t\tthis.splitCanvas = document.createElement( 'canvas' );\n\t\t\tthis.splitCanvas.style.position = 'absolute';\n\t\t\tthis.splitCanvas.style.pointerEvents = 'none';\n\t\t\tthis.splitCanvas.style.zIndex = '998';\n\n\t\t\tthis.splitCanvasTarget = new CanvasTarget( this.splitCanvas );\n\t\t\tthis.splitCanvasTarget.setPixelRatio( window.devicePixelRatio );\n\n\t\t}\n\n\t\tthis.splitCanvas.style.left = `${ localLeft }px`;\n\t\tthis.splitCanvas.style.top = `${ localTop }px`;\n\t\tthis.splitCanvas.style.width = `${ rect.width }px`;\n\t\tthis.splitCanvas.style.height = `${ rect.height }px`;\n\n\t\tthis.splitCanvasTarget.setSize( rect.width, rect.height );\n\t\trenderer.backend.delete( this.splitCanvasTarget );\n\n\t\ttargetParent.appendChild( this.splitCanvas );\n\n\t\t// Overlay divider line (only in split/non-fullscreen mode)\n\t\tif ( ! this.splitFullscreen ) {\n\n\t\t\tif ( ! this.splitOverlay ) {\n\n\t\t\t\tconst overlay = document.createElement( 'div' );\n\t\t\t\toverlay.className = 'split-screen-overlay three-inspector';\n\n\t\t\t\tconst line = document.createElement( 'div' );\n\t\t\t\tline.className = 'split-screen-line';\n\n\t\t\t\toverlay.appendChild( line );\n\n\t\t\t\tlet isDragging = false;\n\n\t\t\t\tconst onPointerDown = ( e ) => {\n\n\t\t\t\t\tisDragging = true;\n\t\t\t\t\tline.classList.add( 'active' );\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t};\n\n\t\t\t\tconst onPointerMove = ( e ) => {\n\n\t\t\t\t\tif ( ! isDragging ) return;\n\n\t\t\t\t\tconst r = mainCanvas.getBoundingClientRect();\n\t\t\t\t\tconst localX = e.clientX - r.left;\n\t\t\t\t\tconst pct = Math.max( 0, Math.min( 1, localX / r.width ) );\n\t\t\t\t\tthis.splitX = pct;\n\t\t\t\t\tline.style.left = `${ pct * 100 }%`;\n\n\t\t\t\t\tif ( this.splitUniforms && this.splitUniforms.splitX ) {\n\n\t\t\t\t\t\tthis.splitUniforms.splitX.value = pct;\n\n\t\t\t\t\t}\n\n\t\t\t\t};\n\n\t\t\t\tconst onPointerUp = () => {\n\n\t\t\t\t\tisDragging = false;\n\t\t\t\t\tline.classList.remove( 'active' );\n\n\t\t\t\t};\n\n\t\t\t\tline.addEventListener( 'pointerdown', onPointerDown );\n\t\t\t\twindow.addEventListener( 'pointermove', onPointerMove );\n\t\t\t\twindow.addEventListener( 'pointerup', onPointerUp );\n\n\t\t\t\tthis.splitOverlay = overlay;\n\t\t\t\tthis.splitLine = line;\n\n\t\t\t}\n\n\t\t\tthis.splitOverlay.style.left = `${ localLeft }px`;\n\t\t\tthis.splitOverlay.style.top = `${ localTop }px`;\n\t\t\tthis.splitOverlay.style.width = `${ rect.width }px`;\n\t\t\tthis.splitOverlay.style.height = `${ rect.height }px`;\n\t\t\tthis.splitLine.style.left = '50%';\n\n\t\t\ttargetParent.appendChild( this.splitOverlay );\n\n\t\t} else {\n\n\t\t\t// If we transitioned from split to fullscreen, remove the overlay slider\n\t\t\tif ( this.splitOverlay && this.splitOverlay.parentElement ) {\n\n\t\t\t\tthis.splitOverlay.parentElement.removeChild( this.splitOverlay );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( ! this.splitUniforms ) {\n\n\t\t\tthis.splitUniforms = {\n\t\t\t\tsplitX: uniform( 0.5 ),\n\t\t\t\tviewportWidth: uniform( rect.width )\n\t\t\t};\n\n\t\t}\n\n\t\tthis.splitUniforms.splitX.value = 0.5;\n\t\tthis.splitUniforms.viewportWidth.value = rect.width;\n\n\t\t// Recreate or setup material for split screen comparison\n\t\tconst target = canvasData.inspectNode.context( { getUV: () => screenUV } );\n\t\tconst targetColor = renderOutput( vec4( vec3( target ), 1 ), NoToneMapping, renderer.outputColorSpace );\n\n\t\tlet finalColor;\n\n\t\tif ( this.splitFullscreen ) {\n\n\t\t\tfinalColor = targetColor;\n\n\t\t} else {\n\n\t\t\tfinalColor = Fn( () => {\n\n\t\t\t\tscreenUV.x.lessThan( this.splitUniforms.splitX ).discard();\n\n\t\t\t\treturn targetColor;\n\n\t\t\t} )();\n\n\t\t}\n\n\t\tif ( this.splitMaterial ) {\n\n\t\t\tthis.splitMaterial.dispose();\n\n\t\t}\n\n\t\tthis.splitMaterial = new NodeMaterial();\n\t\tthis.splitMaterial.outputNode = finalColor;\n\t\tthis.splitMaterial.depthTest = false;\n\t\tthis.splitMaterial.depthWrite = false;\n\n\t\tif ( this.splitQuad ) {\n\n\t\t\tthis.splitQuad.material = this.splitMaterial;\n\n\t\t} else {\n\n\t\t\tthis.splitQuad = new QuadMesh( this.splitMaterial );\n\n\t\t}\n\n\t\tthis.updateSplitButtonsState();\n\n\t}\n\n\tstopSplitMode() {\n\n\t\tthis.splitActive = false;\n\t\tthis.splitCanvasData = null;\n\t\tthis.splitFullscreen = false;\n\n\t\tif ( this.splitOverlay && this.splitOverlay.parentElement ) {\n\n\t\t\tthis.splitOverlay.parentElement.removeChild( this.splitOverlay );\n\n\t\t}\n\n\t\tif ( this.splitCanvas && this.splitCanvas.parentElement ) {\n\n\t\t\tthis.splitCanvas.parentElement.removeChild( this.splitCanvas );\n\n\t\t}\n\n\t\tthis.updateSplitButtonsState();\n\n\t}\n\n\tupdateSplitButtonsState() {\n\n\t\tif ( this.splitActive ) {\n\n\t\t\tthis.backBtn.style.display = '';\n\n\t\t} else {\n\n\t\t\tif ( this.select.value === 'list' ) {\n\n\t\t\t\tthis.backBtn.style.display = 'none';\n\n\t\t\t} else {\n\n\t\t\t\tthis.backBtn.style.display = '';\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( const canvasData of this.canvasNodes.values() ) {\n\n\t\t\tif ( ! canvasData.splitBtn || ! canvasData.fullscreenBtn ) continue;\n\n\t\t\tconst isSelected = this.splitActive && this.splitCanvasData === canvasData;\n\n\t\t\tif ( isSelected ) {\n\n\t\t\t\tif ( this.splitFullscreen ) {\n\n\t\t\t\t\tcanvasData.fullscreenBtn.classList.add( 'active' );\n\t\t\t\t\tcanvasData.fullscreenBtn.innerHTML = backIcon;\n\t\t\t\t\tcanvasData.fullscreenBtn.title = 'Exit Fullscreen';\n\n\t\t\t\t\tcanvasData.splitBtn.classList.remove( 'active' );\n\t\t\t\t\tcanvasData.splitBtn.innerHTML = splitIcon;\n\t\t\t\t\tcanvasData.splitBtn.title = 'Interactive split screen';\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcanvasData.splitBtn.classList.add( 'active' );\n\t\t\t\t\tcanvasData.splitBtn.innerHTML = backIcon;\n\t\t\t\t\tcanvasData.splitBtn.title = 'Exit Split Screen';\n\n\t\t\t\t\tcanvasData.fullscreenBtn.classList.remove( 'active' );\n\t\t\t\t\tcanvasData.fullscreenBtn.innerHTML = fullscreenIcon;\n\t\t\t\t\tcanvasData.fullscreenBtn.title = 'Fullscreen view';\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tcanvasData.splitBtn.classList.remove( 'active' );\n\t\t\t\tcanvasData.splitBtn.innerHTML = splitIcon;\n\t\t\t\tcanvasData.splitBtn.title = 'Interactive split screen';\n\n\t\t\t\tcanvasData.fullscreenBtn.classList.remove( 'active' );\n\t\t\t\tcanvasData.fullscreenBtn.innerHTML = fullscreenIcon;\n\t\t\t\tcanvasData.fullscreenBtn.title = 'Fullscreen view';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tgetCanvasDataByNode( renderer, node ) {\n\n\t\tlet canvasData = this.canvasNodes.get( node );\n\n\t\tif ( canvasData === undefined ) {\n\n\t\t\tconst canvas = document.createElement( 'canvas' );\n\n\t\t\tconst canvasTarget = new CanvasTarget( canvas );\n\t\t\tcanvasTarget.setPixelRatio( window.devicePixelRatio );\n\t\t\tcanvasTarget.setSize( 140, 140 );\n\n\t\t\tconst id = node.id;\n\n\t\t\tconst { path, name } = splitPath( splitCamelCase( node.getName() || '(unnamed)' ) );\n\n\t\t\tconst canvasAspect = uniform( 1 );\n\t\t\tconst mask = float( 1 );\n\n\t\t\tlet inspectNode = node.callback !== null ? node.callback( node.node ) : node.node;\n\t\t\tlet rttNode = null;\n\n\t\t\tif ( inspectNode.isTextureNode !== true && inspectNode.isPassNode !== true ) {\n\n\t\t\t\t// render other nodes in the resolution of the renderer, e.g. screen-space nodes\n\n\t\t\t\trttNode = rtt( inspectNode );\n\t\t\t\trttNode.uvNode = null; // use the aspect ratio corrected uv of the viewer\n\n\t\t\t\tinspectNode = rttNode;\n\n\t\t\t}\n\n\t\t\tconst target = inspectNode.context( { getUV: ( textureNode ) => {\n\n\t\t\t\tconst uvData = aspectRatioUV( screenUV, textureNode, canvasAspect );\n\t\t\t\tconst correctedUV = uvData.xy;\n\t\t\t\tmask.assign( uvData.z );\n\n\t\t\t\treturn correctedUV;\n\n\t\t\t} } );\n\n\t\t\tlet output = vec4( vec3( target ), 1 ).mul( mask );\n\t\t\toutput = renderOutput( output, NoToneMapping, renderer.outputColorSpace );\n\n\t\t\tconst material = new NodeMaterial();\n\t\t\tmaterial.outputNode = output;\n\n\t\t\tconst quad = new QuadMesh( material );\n\t\t\tquad.name = 'Viewer - ' + name;\n\n\t\t\tcanvasData = {\n\t\t\t\tid,\n\t\t\t\tname,\n\t\t\t\tpath,\n\t\t\t\tnode,\n\t\t\t\tinspectNode,\n\t\t\t\trttNode,\n\t\t\t\tquad,\n\t\t\t\tcanvasTarget,\n\t\t\t\tmaterial,\n\t\t\t\tcanvasAspect\n\t\t\t};\n\n\t\t\tthis.canvasNodes.set( node, canvasData );\n\n\t\t}\n\n\t\treturn canvasData;\n\n\t}\n\n\tupdate( inspector ) {\n\n\t\tconst renderer = inspector.getRenderer();\n\n\t\tif ( this.splitActive ) {\n\n\t\t\tconst mainCanvas = renderer.domElement;\n\t\t\tconst rect = mainCanvas.getBoundingClientRect();\n\n\t\t\tif ( rect.width <= 0 || rect.height <= 0 ) {\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tconst targetParent = document.fullscreenElement || this.profiler.domElement;\n\t\t\tconst parentRect = targetParent.getBoundingClientRect();\n\t\t\tconst localLeft = rect.left - parentRect.left;\n\t\t\tconst localTop = rect.top - parentRect.top;\n\n\t\t\tif ( this.splitCanvas.parentElement !== targetParent ) {\n\n\t\t\t\ttargetParent.appendChild( this.splitCanvas );\n\n\t\t\t}\n\n\t\t\tif ( this.splitOverlay && ! this.splitFullscreen && this.splitOverlay.parentElement !== targetParent ) {\n\n\t\t\t\ttargetParent.appendChild( this.splitOverlay );\n\n\t\t\t}\n\n\t\t\tthis.splitCanvas.style.left = `${ localLeft }px`;\n\t\t\tthis.splitCanvas.style.top = `${ localTop }px`;\n\t\t\tthis.splitCanvas.style.width = `${ rect.width }px`;\n\t\t\tthis.splitCanvas.style.height = `${ rect.height }px`;\n\n\t\t\tif ( this.splitOverlay && ! this.splitFullscreen ) {\n\n\t\t\t\tthis.splitOverlay.style.left = `${ localLeft }px`;\n\t\t\t\tthis.splitOverlay.style.top = `${ localTop }px`;\n\t\t\t\tthis.splitOverlay.style.width = `${ rect.width }px`;\n\t\t\t\tthis.splitOverlay.style.height = `${ rect.height }px`;\n\n\t\t\t}\n\n\t\t\tif ( this.splitCanvasTarget.width !== rect.width || this.splitCanvasTarget.height !== rect.height ) {\n\n\t\t\t\tthis.splitCanvasTarget.setSize( rect.width, rect.height );\n\n\t\t\t\tif ( this.splitUniforms && this.splitUniforms.viewportWidth ) {\n\n\t\t\t\t\tthis.splitUniforms.viewportWidth.value = rect.width;\n\n\t\t\t\t}\n\n\t\t\t\trenderer.backend.delete( this.splitCanvasTarget );\n\n\t\t\t}\n\n\t\t\t// Render the split quad to the splitCanvasTarget\n\t\t\tconst previousCanvasTarget = renderer.getCanvasTarget();\n\t\t\tconst previousClearColor = renderer.getClearColor( new Color() );\n\t\t\tconst previousClearAlpha = renderer.getClearAlpha();\n\n\t\t\tconst state = RendererUtils.resetRendererState( renderer );\n\n\t\t\trenderer.toneMapping = NoToneMapping;\n\t\t\trenderer.outputColorSpace = LinearSRGBColorSpace;\n\n\t\t\trenderer.setCanvasTarget( this.splitCanvasTarget );\n\t\t\trenderer.setClearColor( 0x000000, 0 );\n\n\t\t\tthis.splitQuad.render( renderer );\n\n\t\t\trenderer.setCanvasTarget( previousCanvasTarget );\n\t\t\trenderer.setClearColor( previousClearColor, previousClearAlpha );\n\n\t\t\tRendererUtils.restoreRendererState( renderer, state );\n\n\t\t}\n\n\t\tconst nodes = inspector.getNodes();\n\n\t\tif ( nodes.length > 0 ) {\n\n\t\t\tif ( ! renderer.backend.isWebGPUBackend ) {\n\n\t\t\t\t// Viewer is only available with WebGPU.\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( ! this.isVisible ) {\n\n\t\t\t\tthis.show();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( ! this.isActive ) return;\n\n\t\tconst canvasDataList = nodes.map( node => this.getCanvasDataByNode( renderer, node ) );\n\n\t\t// Check if the list of nodes has changed\n\t\tlet nodesChanged = canvasDataList.length !== this.currentDataList.length;\n\n\t\tif ( ! nodesChanged ) {\n\n\t\t\tfor ( let i = 0; i < canvasDataList.length; i ++ ) {\n\n\t\t\t\tif ( canvasDataList[ i ].id !== this.currentDataList[ i ].id ) {\n\n\t\t\t\t\tnodesChanged = true;\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( nodesChanged ) {\n\n\t\t\tconst currentSelectedValue = this.select.value;\n\n\t\t\t// Clear options except the first one ('list')\n\t\t\twhile ( this.select.options.length > 1 ) {\n\n\t\t\t\tthis.select.remove( 1 );\n\n\t\t\t}\n\n\t\t\t// Add options for each node in canvasDataList\n\t\t\tfor ( const canvasData of canvasDataList ) {\n\n\t\t\t\tconst option = document.createElement( 'option' );\n\t\t\t\toption.value = canvasData.id;\n\t\t\t\toption.textContent = canvasData.path ? `${ canvasData.path } / ${ canvasData.name }` : canvasData.name;\n\t\t\t\tthis.select.appendChild( option );\n\n\t\t\t}\n\n\t\t\t// Try to restore from saved view first on initial load\n\t\t\tlet restored = false;\n\n\t\t\tif ( this.pendingRestoreView ) {\n\n\t\t\t\tconst savedView = getItem( 'viewerLastView' );\n\n\t\t\t\tif ( savedView !== 'list' ) {\n\n\t\t\t\t\tfor ( let i = 0; i < this.select.options.length; i ++ ) {\n\n\t\t\t\t\t\tif ( this.select.options[ i ].textContent === savedView ) {\n\n\t\t\t\t\t\t\tthis.select.selectedIndex = i;\n\t\t\t\t\t\t\tconst nodeId = this.select.options[ i ].value;\n\t\t\t\t\t\t\tthis.showNodeView( nodeId );\n\t\t\t\t\t\t\trestored = true;\n\t\t\t\t\t\t\tthis.pendingRestoreView = false;\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis.pendingRestoreView = false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( ! restored ) {\n\n\t\t\t\t// Restore selection if still valid\n\t\t\t\tlet hasSelectedValue = false;\n\n\t\t\t\tfor ( let i = 0; i < this.select.options.length; i ++ ) {\n\n\t\t\t\t\tif ( this.select.options[ i ].value === currentSelectedValue ) {\n\n\t\t\t\t\t\tthis.select.selectedIndex = i;\n\t\t\t\t\t\thasSelectedValue = true;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! hasSelectedValue ) {\n\n\t\t\t\t\tthis.select.value = 'list';\n\t\t\t\t\tthis.showListView();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Real-time resize of active full-screen node canvas target\n\t\tif ( this.activeFullNodeId ) {\n\n\t\t\tconst canvasData = canvasDataList.find( data => String( data.id ) === String( this.activeFullNodeId ) );\n\n\t\t\tif ( canvasData ) {\n\n\t\t\t\tconst rect = this.fullViewerContainer.getBoundingClientRect();\n\t\t\t\tconst contentWidth = rect.width || this.content.clientWidth;\n\t\t\t\tconst contentHeight = rect.height || ( this.content.clientHeight - 38 );\n\n\t\t\t\tif ( canvasData.canvasTarget.domElement.width !== contentWidth || canvasData.canvasTarget.domElement.height !== contentHeight ) {\n\n\t\t\t\t\tcanvasData.canvasTarget.setSize( contentWidth, contentHeight );\n\n\t\t\t\t\trenderer.backend.delete( canvasData.canvasTarget );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tconst previousDataList = [ ...this.currentDataList ];\n\n\t\t// remove old\n\n\t\tfor ( const canvasData of previousDataList ) {\n\n\t\t\tif ( this.itemLibrary.has( canvasData.id ) && canvasDataList.indexOf( canvasData ) === - 1 ) {\n\n\t\t\t\tconst item = this.itemLibrary.get( canvasData.id );\n\t\t\t\tconst parent = item.parent;\n\n\t\t\t\tparent.remove( item );\n\n\t\t\t\tif ( this.folderLibrary.has( parent.data[ 0 ] ) && parent.children.length === 0 ) {\n\n\t\t\t\t\tparent.parent.remove( parent );\n\n\t\t\t\t\tthis.folderLibrary.delete( parent.data[ 0 ] );\n\n\t\t\t\t}\n\n\t\t\t\tthis.itemLibrary.delete( canvasData.id );\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tconst indexes = {};\n\n\t\tfor ( const canvasData of canvasDataList ) {\n\n\t\t\tconst item = this.addNodeItem( canvasData );\n\t\t\tconst previousCanvasTarget = renderer.getCanvasTarget();\n\n\t\t\tconst path = canvasData.path;\n\n\t\t\tif ( path ) {\n\n\t\t\t\tconst folder = this.getFolder( path );\n\n\t\t\t\tif ( indexes[ path ] === undefined ) {\n\n\t\t\t\t\tindexes[ path ] = 0;\n\n\t\t\t\t}\n\n\t\t\t\tif ( folder.parent === null || item.parent !== folder || folder.children.indexOf( item ) !== indexes[ path ] ) {\n\n\t\t\t\t\tfolder.add( item );\n\n\t\t\t\t}\n\n\t\t\t\tindexes[ path ] ++;\n\n\t\t\t} else {\n\n\t\t\t\tif ( ! item.parent ) {\n\n\t\t\t\t\tthis.nodes.add( item );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst rttNodes = [];\n\n\t\t\tconst mainSize = previousCanvasTarget.getDrawingBufferSize( _size );\n\n\t\t\tcanvasData.inspectNode.traverse( ( child ) => {\n\n\t\t\t\tif ( child.isRTTNode && child.autoResize === true ) {\n\n\t\t\t\t\tconst oldWidth = child.width;\n\t\t\t\t\tconst oldHeight = child.height;\n\n\t\t\t\t\tchild.width = mainSize.width;\n\t\t\t\t\tchild.height = mainSize.height;\n\n\t\t\t\t\tchild.setSize( mainSize.width, mainSize.height );\n\n\t\t\t\t\trttNodes.push( {\n\t\t\t\t\t\tnode: child,\n\t\t\t\t\t\toldWidth,\n\t\t\t\t\t\toldHeight\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t\tconst state = RendererUtils.resetRendererState( renderer );\n\n\t\t\trenderer.toneMapping = NoToneMapping;\n\t\t\trenderer.outputColorSpace = LinearSRGBColorSpace;\n\n\t\t\trenderer.setCanvasTarget( canvasData.canvasTarget );\n\n\t\t\tif ( canvasData.canvasAspect ) {\n\n\t\t\t\tcanvasData.canvasAspect.value = canvasData.canvasTarget.domElement.width / canvasData.canvasTarget.domElement.height;\n\n\t\t\t}\n\n\t\t\tcanvasData.quad.render( renderer );\n\n\t\t\trenderer.setCanvasTarget( previousCanvasTarget );\n\n\t\t\tRendererUtils.restoreRendererState( renderer, state );\n\n\t\t\tfor ( const rtt of rttNodes ) {\n\n\t\t\t\trtt.node.width = rtt.oldWidth;\n\t\t\t\trtt.node.height = rtt.oldHeight;\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.currentDataList = canvasDataList;\n\n\t}\n\n\tsetActive( isActive ) {\n\n\t\tsuper.setActive( isActive );\n\n\t}\n\n\tsaveLastView() {\n\n\t\tconst selectedValue = this.select.value;\n\n\t\tif ( selectedValue === 'list' ) {\n\n\t\t\tsetItem( 'viewerLastView', 'list' );\n\n\t\t} else {\n\n\t\t\tconst selectedOption = this.select.options[ this.select.selectedIndex ];\n\n\t\t\tif ( selectedOption ) {\n\n\t\t\t\tsetItem( 'viewerLastView', selectedOption.textContent );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tdispose() {\n\n\t\tif ( this.splitActive ) {\n\n\t\t\tthis.stopSplitMode();\n\n\t\t}\n\n\t\tif ( this.splitCanvas ) {\n\n\t\t\tif ( this.splitCanvas.parentElement ) {\n\n\t\t\t\tthis.splitCanvas.parentElement.removeChild( this.splitCanvas );\n\n\t\t\t}\n\n\t\t\tthis.splitCanvas = null;\n\n\t\t}\n\n\t\tif ( this.splitCanvasTarget ) {\n\n\t\t\tthis.splitCanvasTarget.dispose();\n\t\t\tthis.splitCanvasTarget = null;\n\n\t\t}\n\n\t\tif ( this.splitMaterial ) {\n\n\t\t\tthis.splitMaterial.dispose();\n\t\t\tthis.splitMaterial = null;\n\n\t\t}\n\n\t\tfor ( const canvasData of this.canvasNodes.values() ) {\n\n\t\t\tcanvasData.canvasTarget.dispose();\n\t\t\tcanvasData.material.dispose();\n\n\t\t\tif ( canvasData.rttNode !== null ) canvasData.rttNode.dispose();\n\n\t\t}\n\n\t\tthis.canvasNodes.clear();\n\n\t\tsuper.dispose();\n\n\t}\n\n}\n\nexport { Viewer };\n","import { Tab } from '../ui/Tab.js';\nimport { Graph } from '../ui/Graph.js';\nimport { getItem, setItem } from '../Storage.js';\nimport { info } from '../ui/utils.js';\nimport {\n\tByteType,\n\tFloatType,\n\tHalfFloatType,\n\tIntType,\n\tShortType,\n\tUnsignedByteType,\n\tUnsignedInt101111Type,\n\tUnsignedInt248Type,\n\tUnsignedInt5999Type,\n\tUnsignedIntType,\n\tUnsignedShort4444Type,\n\tUnsignedShort5551Type,\n\tUnsignedShortType,\n\tAlphaFormat,\n\tRGBFormat,\n\tRGBAFormat,\n\tDepthFormat,\n\tDepthStencilFormat,\n\tRedFormat,\n\tRedIntegerFormat,\n\tRGFormat,\n\tRGIntegerFormat,\n\tRGBIntegerFormat,\n\tRGBAIntegerFormat\n} from 'three';\n\nconst LIMIT = 500;\nconst TRIANGLES_GRAPH_LIMIT = 60;\n\nclass Timeline extends Tab {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper( 'Timeline', options );\n\n\t\tthis.content.style.overflow = 'hidden';\n\t\tthis.isRecording = false;\n\t\tthis.frames = []; // Array of { id: number, calls: [] }\n\n\t\tthis.baseTriangles = 0;\n\t\tthis.currentFrame = null;\n\t\tthis.isHierarchicalView = true;\n\t\tthis.activeBlocks = new Map();\n\t\tthis.domPool = [];\n\t\tthis.originalBackend = null;\n\t\tthis.originalMethods = new Map();\n\t\tthis.renderer = null;\n\n\t\tthis.graph = new Graph( LIMIT ); // Accommodate standard graph points\n\t\t// Make lines in timeline graph\n\t\tthis.graph.addLine( 'fps', 'var( --color-fps )' );\n\t\tthis.graph.addLine( 'calls', 'var( --color-call )' );\n\t\tthis.graph.addLine( 'triangles', 'var( --color-red )' );\n\n\t\tthis.buildHeader();\n\t\tthis.buildUI();\n\n\t\t// Bind window resize to update graph bounds\n\t\twindow.addEventListener( 'resize', () => {\n\n\t\t\tif ( this.isActive && ! this.isRecording && this.frames.length > 0 ) {\n\n\t\t\t\tthis.renderSlider();\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tinit( inspector ) {\n\n\t\tsuper.init( inspector );\n\n\t\tthis.profiler.addEventListener( 'resize', () => {\n\n\t\t\tif ( this.isActive && ! this.isRecording && this.frames.length > 0 ) {\n\n\t\t\t\tthis.renderSlider();\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tsetActive( isActive ) {\n\n\t\tsuper.setActive( isActive );\n\n\t\tif ( isActive && ! this.isRecording && this.frames.length > 0 ) {\n\n\t\t\tthis.renderSlider();\n\n\t\t}\n\n\t}\n\n\tbuildHeader() {\n\n\t\tconst header = document.createElement( 'div' );\n\t\theader.className = 'toolbar';\n\n\t\tthis.recordButton = document.createElement( 'button' );\n\t\tthis.recordButton.className = 'console-copy-button'; // Reusing style\n\t\tthis.recordButton.title = 'Record';\n\t\tthis.recordButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"></circle><circle cx=\"12\" cy=\"12\" r=\"4\" fill=\"currentColor\"></circle></svg>';\n\t\tthis.recordButton.style.padding = '0 10px';\n\t\tthis.recordButton.style.lineHeight = '24px'; // Match other buttons height\n\t\tthis.recordButton.style.display = 'flex';\n\t\tthis.recordButton.style.alignItems = 'center';\n\t\tthis.recordButton.addEventListener( 'click', () => this.toggleRecording() );\n\n\t\tconst clearButton = document.createElement( 'button' );\n\t\tclearButton.className = 'console-copy-button';\n\t\tclearButton.title = 'Clear';\n\t\tclearButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"3 6 5 6 21 6\"></polyline><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\"></path><line x1=\"10\" y1=\"11\" x2=\"10\" y2=\"17\"></line><line x1=\"14\" y1=\"11\" x2=\"14\" y2=\"17\"></line></svg>';\n\t\tclearButton.style.padding = '0 10px';\n\t\tclearButton.style.lineHeight = '24px';\n\t\tclearButton.style.display = 'flex';\n\t\tclearButton.style.alignItems = 'center';\n\t\tclearButton.addEventListener( 'click', () => this.clear() );\n\n\t\tthis.viewModeSelect = document.createElement( 'select' );\n\t\tthis.viewModeSelect.className = 'select';\n\t\tthis.viewModeSelect.style.width = '120px';\n\t\tthis.viewModeSelect.style.marginRight = '10px';\n\n\t\tconst hierarchyOption = document.createElement( 'option' );\n\t\thierarchyOption.value = 'hierarchy';\n\t\thierarchyOption.textContent = 'Hierarchy';\n\t\tthis.viewModeSelect.appendChild( hierarchyOption );\n\n\t\tconst countsOption = document.createElement( 'option' );\n\t\tcountsOption.value = 'counts';\n\t\tcountsOption.textContent = 'Count';\n\t\tthis.viewModeSelect.appendChild( countsOption );\n\n\t\tthis.viewModeSelect.value = this.isHierarchicalView ? 'hierarchy' : 'counts';\n\n\t\tthis.viewModeSelect.addEventListener( 'change', () => {\n\n\t\t\tthis.isHierarchicalView = this.viewModeSelect.value === 'hierarchy';\n\n\t\t\tif ( this.selectedFrameIndex !== undefined && this.selectedFrameIndex !== - 1 ) {\n\n\t\t\t\tthis.selectFrame( this.selectedFrameIndex );\n\n\t\t\t}\n\n\t\t} );\n\n\t\tthis.recordRefreshButton = document.createElement( 'button' );\n\t\tthis.recordRefreshButton.className = 'console-copy-button'; // Reusing style\n\t\tthis.recordRefreshButton.title = 'Refresh & Record';\n\t\tthis.recordRefreshButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\"></path><path d=\"M21 3v5h-5\"></path><circle cx=\"12\" cy=\"12\" r=\"3\" fill=\"currentColor\"></circle></svg>';\n\t\tthis.recordRefreshButton.style.padding = '0 10px';\n\t\tthis.recordRefreshButton.style.lineHeight = '24px';\n\t\tthis.recordRefreshButton.style.display = 'flex';\n\t\tthis.recordRefreshButton.style.alignItems = 'center';\n\t\tthis.recordRefreshButton.addEventListener( 'click', () => {\n\n\t\t\tconst timelineSettings = getItem( 'timeline' );\n\t\t\ttimelineSettings.recording = true;\n\t\t\tsetItem( 'timeline', timelineSettings );\n\n\t\t\twindow.location.reload();\n\n\t\t} );\n\n\t\tthis.exportButton = document.createElement( 'button' );\n\t\tthis.exportButton.className = 'console-copy-button';\n\t\tthis.exportButton.title = 'Export';\n\t\tthis.exportButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"></path><polyline points=\"7 10 12 15 17 10\"></polyline><line x1=\"12\" y1=\"15\" x2=\"12\" y2=\"3\"></line></svg>';\n\t\tthis.exportButton.style.padding = '0 10px';\n\t\tthis.exportButton.style.lineHeight = '24px';\n\t\tthis.exportButton.style.display = 'flex';\n\t\tthis.exportButton.style.alignItems = 'center';\n\t\tthis.exportButton.addEventListener( 'click', () => this.exportData() );\n\n\t\tconst buttonsGroup = document.createElement( 'div' );\n\t\tbuttonsGroup.className = 'console-buttons-group';\n\t\tbuttonsGroup.appendChild( this.recordButton );\n\t\tbuttonsGroup.appendChild( this.recordRefreshButton );\n\t\tbuttonsGroup.appendChild( this.exportButton );\n\t\tbuttonsGroup.appendChild( clearButton );\n\n\t\tconst titleElement = document.createElement( 'div' );\n\t\ttitleElement.style.display = 'flex';\n\t\ttitleElement.style.alignItems = 'center';\n\t\ttitleElement.style.color = 'var(--text-primary)';\n\t\ttitleElement.style.alignSelf = 'center';\n\n\t\tthis.frameInfo = document.createElement( 'span' );\n\t\tthis.frameInfo.style.display = 'inline-flex';\n\t\tthis.frameInfo.style.alignItems = 'center';\n\t\tthis.frameInfo.style.marginLeft = '5px';\n\t\tthis.frameInfo.style.fontFamily = 'monospace';\n\t\tthis.frameInfo.style.color = 'var(--text-secondary)';\n\t\tthis.frameInfo.style.fontSize = '12px';\n\n\t\ttitleElement.appendChild( this.viewModeSelect );\n\t\ttitleElement.appendChild( this.frameInfo );\n\n\t\theader.appendChild( titleElement );\n\t\theader.appendChild( buttonsGroup );\n\t\tthis.content.appendChild( header );\n\n\t}\n\n\tbuildUI() {\n\n\t\tconst container = document.createElement( 'div' );\n\t\tcontainer.style.display = 'flex';\n\t\tcontainer.style.flexDirection = 'column';\n\t\tcontainer.style.flex = '1';\n\t\tcontainer.style.minHeight = '0';\n\t\tcontainer.style.marginTop = '10px';\n\t\tcontainer.style.width = '100%';\n\n\t\t// Top Player/Graph Slider using Graph.js SVG\n\t\tconst graphContainer = document.createElement( 'div' );\n\t\tgraphContainer.style.height = '60px';\n\t\tgraphContainer.style.minHeight = '60px';\n\t\tgraphContainer.style.borderBottom = '1px solid var(--border-color)';\n\t\tgraphContainer.style.backgroundColor = 'var(--background-color)';\n\n\t\tthis.graphSlider = document.createElement( 'div' );\n\t\tthis.graphSlider.style.height = '100%';\n\t\tthis.graphSlider.style.margin = '0 10px';\n\t\tthis.graphSlider.style.position = 'relative';\n\t\tthis.graphSlider.style.cursor = 'crosshair';\n\t\tthis.graphSlider.style.touchAction = 'none';\n\n\t\tgraphContainer.appendChild( this.graphSlider );\n\n\t\t// Setup SVG from Graph\n\t\tthis.graph.domElement.style.width = '0';\n\t\tthis.graph.domElement.style.minWidth = '100%';\n\t\tthis.graph.domElement.style.height = '100%';\n\t\tthis.graphSlider.appendChild( this.graph.domElement );\n\n\t\t// Hover indicator\n\t\tthis.hoverIndicator = document.createElement( 'div' );\n\t\tthis.hoverIndicator.style.position = 'absolute';\n\t\tthis.hoverIndicator.style.top = '0';\n\t\tthis.hoverIndicator.style.bottom = '0';\n\t\tthis.hoverIndicator.style.width = '1px';\n\t\tthis.hoverIndicator.style.backgroundColor = 'rgba(255, 255, 255, 0.3)';\n\t\tthis.hoverIndicator.style.pointerEvents = 'none';\n\t\tthis.hoverIndicator.style.display = 'none';\n\t\tthis.hoverIndicator.style.zIndex = '9';\n\t\tthis.hoverIndicator.style.transform = 'translateX(-50%)';\n\t\tthis.graphSlider.appendChild( this.hoverIndicator );\n\n\t\t// Playhead indicator (vertical line)\n\t\tthis.playhead = document.createElement( 'div' );\n\t\tthis.playhead.style.position = 'absolute';\n\t\tthis.playhead.style.top = '0';\n\t\tthis.playhead.style.bottom = '0';\n\t\tthis.playhead.style.width = '2px';\n\t\tthis.playhead.style.backgroundColor = 'var(--color-red)';\n\t\tthis.playhead.style.boxShadow = '0 0 4px rgba(255,0,0,0.5)';\n\t\tthis.playhead.style.pointerEvents = 'none';\n\t\tthis.playhead.style.display = 'none';\n\t\tthis.playhead.style.zIndex = '10';\n\t\tthis.playhead.style.transform = 'translateX(-50%)';\n\t\tthis.graphSlider.appendChild( this.playhead );\n\n\t\t// Playhead handle (triangle/pointer)\n\t\tconst playheadHandle = document.createElement( 'div' );\n\t\tplayheadHandle.style.position = 'absolute';\n\t\tplayheadHandle.style.top = '0';\n\t\tplayheadHandle.style.left = '50%';\n\t\tplayheadHandle.style.transform = 'translate(-50%, 0)';\n\t\tplayheadHandle.style.width = '0';\n\t\tplayheadHandle.style.height = '0';\n\t\tplayheadHandle.style.borderLeft = '6px solid transparent';\n\t\tplayheadHandle.style.borderRight = '6px solid transparent';\n\t\tplayheadHandle.style.borderTop = '8px solid var(--color-red)';\n\t\tthis.playhead.appendChild( playheadHandle );\n\n\t\t// Make it focusable to accept keyboard events\n\t\tthis.graphSlider.tabIndex = 0;\n\t\tthis.graphSlider.style.outline = 'none';\n\n\t\t// Pointer interactivity on the graph\n\t\tlet isDragging = false;\n\n\t\tconst updatePlayheadFromEvent = ( e ) => {\n\n\t\t\tif ( this.isRecording || this.frames.length === 0 ) return;\n\n\t\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\t\tlet x = e.clientX - rect.left;\n\n\t\t\t// Clamp\n\t\t\tx = Math.max( 0, Math.min( x, rect.width ) );\n\n\t\t\tthis.fixedScreenX = x;\n\n\t\t\t// The graph stretches its points across the width\n\t\t\t// Find closest frame index based on exact point coordinates\n\t\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\t\t\tif ( pointCount === 0 ) return;\n\n\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\n\t\t\tlet localFrameIndex = Math.round( ( x - offset ) / pointStep );\n\t\t\tlocalFrameIndex = Math.max( 0, Math.min( localFrameIndex, pointCount - 1 ) );\n\n\t\t\tif ( localFrameIndex >= pointCount - 2 ) {\n\n\t\t\t\tthis.isTrackingLatest = true;\n\n\t\t\t} else {\n\n\t\t\t\tthis.isTrackingLatest = false;\n\n\t\t\t}\n\n\t\t\tlet frameIndex = localFrameIndex;\n\n\t\t\tif ( this.frames.length > pointCount ) {\n\n\t\t\t\tframeIndex += this.frames.length - pointCount;\n\n\t\t\t}\n\n\t\t\tthis.playhead.style.display = 'block';\n\t\t\tthis.selectFrame( frameIndex );\n\n\t\t};\n\n\t\tthis.graphSlider.addEventListener( 'pointerdown', ( e ) => {\n\n\t\t\tif ( this.isRecording ) return;\n\n\t\t\tisDragging = true;\n\t\t\tthis.isManualScrubbing = true;\n\t\t\tthis.graphSlider.focus();\n\t\t\tupdatePlayheadFromEvent( e );\n\n\t\t} );\n\n\t\tthis.graphSlider.addEventListener( 'pointerenter', () => {\n\n\t\t\tif ( this.frames.length > 0 && ! this.isRecording ) {\n\n\t\t\t\tthis.hoverIndicator.style.display = 'block';\n\n\t\t\t}\n\n\t\t} );\n\n\t\tthis.graphSlider.addEventListener( 'pointerleave', () => {\n\n\t\t\tthis.hoverIndicator.style.display = 'none';\n\n\t\t} );\n\n\t\tthis.graphSlider.addEventListener( 'pointermove', ( e ) => {\n\n\t\t\tif ( this.frames.length === 0 || this.isRecording ) return;\n\n\t\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\t\tlet x = e.clientX - rect.left;\n\t\t\tx = Math.max( 0, Math.min( x, rect.width ) );\n\n\t\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\t\t\tif ( pointCount > 0 ) {\n\n\t\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\t\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\n\t\t\t\tlet localFrameIndex = Math.round( ( x - offset ) / pointStep );\n\t\t\t\tlocalFrameIndex = Math.max( 0, Math.min( localFrameIndex, pointCount - 1 ) );\n\n\t\t\t\tlet snappedX = offset + localFrameIndex * pointStep;\n\t\t\t\tsnappedX = Math.max( 1, Math.min( snappedX, rect.width - 1 ) );\n\t\t\t\tthis.hoverIndicator.style.left = snappedX + 'px';\n\n\t\t\t} else {\n\n\t\t\t\tconst clampedX = Math.max( 1, Math.min( x, rect.width - 1 ) );\n\t\t\t\tthis.hoverIndicator.style.left = clampedX + 'px';\n\n\t\t\t}\n\n\t\t} );\n\n\t\tthis.graphSlider.addEventListener( 'keydown', ( e ) => {\n\n\t\t\tif ( this.frames.length === 0 || this.isRecording ) return;\n\n\t\t\tlet newIndex = this.selectedFrameIndex;\n\n\t\t\tif ( e.key === 'ArrowLeft' ) {\n\n\t\t\t\tnewIndex = Math.max( 0, this.selectedFrameIndex - 1 );\n\t\t\t\te.preventDefault();\n\n\t\t\t} else if ( e.key === 'ArrowRight' ) {\n\n\t\t\t\tnewIndex = Math.min( this.frames.length - 1, this.selectedFrameIndex + 1 );\n\t\t\t\te.preventDefault();\n\n\t\t\t}\n\n\t\t\tif ( newIndex !== this.selectedFrameIndex ) {\n\n\t\t\t\tthis.selectFrame( newIndex );\n\n\t\t\t\t// Update playhead tracking state\n\t\t\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\t\t\t\tif ( pointCount > 0 ) {\n\n\t\t\t\t\tlet localIndex = newIndex;\n\t\t\t\t\tif ( this.frames.length > pointCount ) {\n\n\t\t\t\t\t\tlocalIndex = newIndex - ( this.frames.length - pointCount );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( localIndex >= pointCount - 2 ) {\n\n\t\t\t\t\t\tthis.isTrackingLatest = true;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tthis.isTrackingLatest = false;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\t\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\t\t\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\t\t\t\t\tthis.fixedScreenX = offset + localIndex * pointStep;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\twindow.addEventListener( 'pointermove', ( e ) => {\n\n\t\t\tif ( isDragging ) {\n\n\t\t\t\tupdatePlayheadFromEvent( e );\n\n\t\t\t\t// Also move hover indicator to match playback\n\t\t\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\t\t\tlet x = e.clientX - rect.left;\n\t\t\t\tx = Math.max( 0, Math.min( x, rect.width ) );\n\n\t\t\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\t\t\t\tif ( pointCount > 0 ) {\n\n\t\t\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\t\t\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\n\t\t\t\t\tlet localFrameIndex = Math.round( ( x - offset ) / pointStep );\n\t\t\t\t\tlocalFrameIndex = Math.max( 0, Math.min( localFrameIndex, pointCount - 1 ) );\n\n\t\t\t\t\tlet snappedX = offset + localFrameIndex * pointStep;\n\t\t\t\t\tsnappedX = Math.max( 1, Math.min( snappedX, rect.width - 1 ) );\n\t\t\t\t\tthis.hoverIndicator.style.left = snappedX + 'px';\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst clampedX = Math.max( 1, Math.min( x, rect.width - 1 ) );\n\t\t\t\t\tthis.hoverIndicator.style.left = clampedX + 'px';\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\twindow.addEventListener( 'pointerup', () => {\n\n\t\t\tisDragging = false;\n\t\t\tthis.isManualScrubbing = false;\n\n\t\t} );\n\n\t\tcontainer.appendChild( graphContainer );\n\n\t\t// Bottom Main Area (Timeline Sequence)\n\t\tconst mainArea = document.createElement( 'div' );\n\t\tmainArea.style.flex = '1';\n\t\tmainArea.style.display = 'flex';\n\t\tmainArea.style.flexDirection = 'column';\n\t\tmainArea.style.overflow = 'hidden';\n\n\t\t// Timeline Track\n\t\tthis.timelineTrack = document.createElement( 'div' );\n\t\tthis.timelineTrack.style.flex = '1';\n\t\tthis.timelineTrack.style.overflowY = 'auto';\n\t\tthis.timelineTrack.style.margin = '10px';\n\t\tthis.timelineTrack.style.marginTop = '8px';\n\t\tthis.timelineTrack.style.backgroundColor = 'var(--background-color)';\n\t\tthis.timelineTrack.style.position = 'relative';\n\t\tmainArea.appendChild( this.timelineTrack );\n\n\t\tthis.timelineContent = document.createElement( 'div' );\n\t\tthis.timelineContent.style.position = 'relative';\n\t\tthis.timelineContent.style.width = '100%';\n\t\tthis.timelineTrack.appendChild( this.timelineContent );\n\n\t\tthis.timelineTrack.addEventListener( 'scroll', () => {\n\n\t\t\tif ( ! this.isRecording && this.frames.length > 0 ) {\n\n\t\t\t\tthis.updateVisibleBlocks();\n\n\t\t\t}\n\n\t\t} );\n\n\t\tcontainer.appendChild( mainArea );\n\t\tthis.content.appendChild( container );\n\n\t}\n\n\tsetRenderer( renderer ) {\n\n\t\tthis.renderer = renderer;\n\n\t\tconst timelineSettings = getItem( 'timeline' );\n\n\t\tif ( timelineSettings.recording ) {\n\n\t\t\ttimelineSettings.recording = false;\n\t\t\tsetItem( 'timeline', timelineSettings );\n\n\t\t\tthis.toggleRecording();\n\n\t\t}\n\n\t}\n\n\ttoggleRecording() {\n\n\t\tif ( ! this.renderer ) {\n\n\t\t\tconsole.warn( 'Timeline: No renderer defined.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tthis.isRecording = ! this.isRecording;\n\n\t\tif ( this.isRecording ) {\n\n\t\t\tthis.recordButton.title = 'Stop';\n\t\t\tthis.recordButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect></svg>';\n\t\t\tthis.recordButton.style.color = 'var(--color-red)';\n\t\t\tthis.startRecording();\n\n\t\t} else {\n\n\t\t\tthis.recordButton.title = 'Record';\n\t\t\tthis.recordButton.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"></circle><circle cx=\"12\" cy=\"12\" r=\"4\" fill=\"currentColor\"></circle></svg>';\n\t\t\tthis.recordButton.style.color = '';\n\t\t\tthis.stopRecording();\n\t\t\tthis.renderSlider();\n\n\t\t}\n\n\t}\n\n\tstartRecording() {\n\n\t\tthis.frames = [];\n\t\tthis.currentFrame = null;\n\t\tthis.selectedFrameIndex = - 1;\n\t\tthis.fixedScreenX = 0;\n\t\tthis.isTrackingLatest = true;\n\t\tthis.isManualScrubbing = false;\n\t\tthis.clear();\n\t\tthis.frameInfo.textContent = 'Recording...';\n\n\t\tconst backend = this.renderer.backend;\n\t\tconst methods = Object.getOwnPropertyNames( Object.getPrototypeOf( backend ) ).filter( prop => prop !== 'constructor' );\n\n\t\tfor ( const prop of methods ) {\n\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor( Object.getPrototypeOf( backend ), prop );\n\n\t\t\tif ( descriptor && ( descriptor.get || descriptor.set ) ) continue;\n\n\t\t\tconst originalFunc = backend[ prop ];\n\n\t\t\tif ( typeof originalFunc === 'function' && typeof prop === 'string' ) {\n\n\t\t\t\tthis.originalMethods.set( prop, originalFunc );\n\n\t\t\t\tbackend[ prop ] = ( ...args ) => {\n\n\t\t\t\t\tif ( prop.toLowerCase().includes( 'timestamp' ) || prop.startsWith( 'get' ) || prop.startsWith( 'set' ) || prop.startsWith( 'has' ) || prop.startsWith( '_' ) || prop.startsWith( 'needs' ) ) {\n\n\t\t\t\t\t\treturn originalFunc.apply( backend, args );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check for frame change\n\t\t\t\t\tconst frameNumber = this.renderer.info.frame;\n\n\t\t\t\t\tif ( ! this.currentFrame || this.currentFrame.id !== frameNumber ) {\n\n\t\t\t\t\t\tif ( this.currentFrame ) {\n\n\t\t\t\t\t\t\tthis.resolveIndirectTriangles( this.currentFrame );\n\n\t\t\t\t\t\t\tthis.currentFrame.fps = this.renderer.inspector ? this.renderer.inspector.fps : 0;\n\n\t\t\t\t\t\t\tif ( ! isFinite( this.currentFrame.fps ) ) {\n\n\t\t\t\t\t\t\t\tthis.currentFrame.fps = 0;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst t = this.currentFrame.triangles || 0;\n\n\t\t\t\t\t\t\tif ( t > this.baseTriangles ) {\n\n\t\t\t\t\t\t\t\tconst oldBase = this.baseTriangles;\n\t\t\t\t\t\t\t\tthis.baseTriangles = t;\n\n\t\t\t\t\t\t\t\tif ( oldBase > 0 ) {\n\n\t\t\t\t\t\t\t\t\tconst ratio = oldBase / this.baseTriangles;\n\t\t\t\t\t\t\t\t\tconst points = this.graph.lines[ 'triangles' ].points;\n\n\t\t\t\t\t\t\t\t\tfor ( let i = 0; i < points.length; i ++ ) {\n\n\t\t\t\t\t\t\t\t\t\tpoints[ i ] *= ratio;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst normalizedTriangles = this.baseTriangles > 0 ? ( t / this.baseTriangles ) * TRIANGLES_GRAPH_LIMIT : 0;\n\n\t\t\t\t\t\t\tthis.graph.addPoint( 'calls', this.currentFrame.calls.length );\n\t\t\t\t\t\t\tthis.graph.addPoint( 'fps', this.currentFrame.fps );\n\t\t\t\t\t\t\tthis.graph.addPoint( 'triangles', normalizedTriangles );\n\t\t\t\t\t\t\tthis.graph.update();\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.currentFrame = { id: frameNumber, calls: [], fps: 0, triangles: 0, indirectDraws: [] };\n\t\t\t\t\t\tthis.frames.push( this.currentFrame );\n\n\t\t\t\t\t\tif ( this.frames.length > LIMIT ) {\n\n\t\t\t\t\t\t\tthis.frames.shift();\n\n\t\t\t\t\t\t}\n\n\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst call = { method: prop, target: args[ 0 ] };\n\t\t\t\t\tconst details = this.getCallDetail( prop, args );\n\n\t\t\t\t\tif ( details ) {\n\n\t\t\t\t\t\tcall.details = details;\n\n\t\t\t\t\t\tif ( details.triangles !== undefined ) {\n\n\t\t\t\t\t\t\tthis.currentFrame.triangles += details.triangles;\n\n\t\t\t\t\t\t} else if ( details.indirect === true ) {\n\n\t\t\t\t\t\t\tconst renderObject = args[ 0 ];\n\n\t\t\t\t\t\t\tthis.currentFrame.indirectDraws.push( {\n\t\t\t\t\t\t\t\tdetails,\n\t\t\t\t\t\t\t\tattribute: renderObject.getIndirect(),\n\t\t\t\t\t\t\t\toffset: renderObject.getIndirectOffset()\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.currentFrame.calls.push( call );\n\n\t\t\t\t\treturn originalFunc.apply( backend, args );\n\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tstopRecording() {\n\n\t\tif ( this.originalMethods.size > 0 ) {\n\n\t\t\tconst backend = this.renderer.backend;\n\n\t\t\tfor ( const [ prop, originalFunc ] of this.originalMethods.entries() ) {\n\n\t\t\t\tbackend[ prop ] = originalFunc;\n\n\t\t\t}\n\n\t\t\tthis.originalMethods.clear();\n\n\t\t\tif ( this.currentFrame ) {\n\n\t\t\t\tthis.resolveIndirectTriangles( this.currentFrame );\n\n\t\t\t\tthis.currentFrame.fps = this.renderer.inspector ? this.renderer.inspector.fps : 0;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tresolveIndirectTriangles( frame ) {\n\n\t\tconst draws = frame.indirectDraws;\n\n\t\tif ( ! draws || draws.length === 0 ) return;\n\n\t\tframe.indirectDraws = null;\n\n\t\t// the draw arguments live on the GPU: [ vertexCount | indexCount, instanceCount, ... ]. the buffer is read\n\t\t// once per frame, after the frame was submitted and before the next one changes it\n\n\t\tconst readbacks = new Map();\n\n\t\tfor ( const draw of draws ) {\n\n\t\t\tif ( readbacks.has( draw.attribute ) === false ) {\n\n\t\t\t\treadbacks.set( draw.attribute, this.renderer.getArrayBufferAsync( draw.attribute ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\tPromise.all( draws.map( ( draw ) => readbacks.get( draw.attribute ) ) ).then( ( buffers ) => {\n\n\t\t\tfor ( let i = 0; i < draws.length; i ++ ) {\n\n\t\t\t\tconst draw = draws[ i ];\n\t\t\t\tconst data = new Uint32Array( buffers[ i ] );\n\t\t\t\tconst offsets = Array.isArray( draw.offset ) ? draw.offset : [ draw.offset ];\n\n\t\t\t\tlet triangles = 0;\n\n\t\t\t\tfor ( const offset of offsets ) {\n\n\t\t\t\t\tconst index = offset / 4;\n\n\t\t\t\t\ttriangles += Math.floor( data[ index ] / 3 ) * data[ index + 1 ];\n\n\t\t\t\t}\n\n\t\t\t\tdraw.details.triangles = triangles;\n\t\t\t\tframe.triangles += triangles;\n\n\t\t\t}\n\n\t\t\tif ( this.isRecording === false && this.frames.includes( frame ) ) this.renderSlider();\n\n\t\t} );\n\n\t}\n\n\tclear() {\n\n\t\tthis.frames = [];\n\t\tthis.clearActiveBlocks();\n\t\tthis.timelineContent.innerHTML = '';\n\t\tthis.timelineContent.style.height = '0px';\n\t\tthis.playhead.style.display = 'none';\n\t\tthis.frameInfo.textContent = '';\n\t\tthis.baseTriangles = 0;\n\t\tthis.graph.lines[ 'calls' ].points = [];\n\t\tthis.graph.lines[ 'fps' ].points = [];\n\t\tthis.graph.lines[ 'triangles' ].points = [];\n\t\tthis.graph.resetLimit();\n\t\tthis.graph.update();\n\n\t}\n\n\texportData() {\n\n\t\tif ( this.frames.length === 0 ) return;\n\n\t\tconst data = JSON.stringify( this.frames, null, '\\t' );\n\t\tconst blob = new Blob( [ data ], { type: 'application/json' } );\n\t\tconst url = URL.createObjectURL( blob );\n\t\tconst a = document.createElement( 'a' );\n\t\ta.href = url;\n\t\ta.download = 'threejs-timeline.json';\n\t\ta.click();\n\t\tURL.revokeObjectURL( url );\n\n\t}\n\n\tgetRenderTargetDetails( renderTarget ) {\n\n\t\tconst textures = renderTarget.textures;\n\t\tconst attachments = [];\n\n\t\tconst getBPC = ( texture ) => {\n\n\t\t\tswitch ( texture.type ) {\n\n\t\t\t\tcase ByteType:\n\t\t\t\tcase UnsignedByteType:\n\t\t\t\t\treturn '8';\n\t\t\t\tcase ShortType:\n\t\t\t\tcase UnsignedShortType:\n\t\t\t\tcase HalfFloatType:\n\t\t\t\tcase UnsignedShort4444Type:\n\t\t\t\tcase UnsignedShort5551Type:\n\t\t\t\t\treturn '16';\n\t\t\t\tcase IntType:\n\t\t\t\tcase UnsignedIntType:\n\t\t\t\tcase FloatType:\n\t\t\t\tcase UnsignedInt248Type:\n\t\t\t\tcase UnsignedInt5999Type:\n\t\t\t\tcase UnsignedInt101111Type:\n\t\t\t\t\treturn '32';\n\t\t\t\tdefault:\n\t\t\t\t\treturn '?';\n\n\t\t\t}\n\n\t\t};\n\n\t\tconst getFormat = ( texture ) => {\n\n\t\t\tswitch ( texture.format ) {\n\n\t\t\t\tcase AlphaFormat:\n\t\t\t\t\treturn 'a';\n\t\t\t\tcase RedFormat:\n\t\t\t\tcase RedIntegerFormat:\n\t\t\t\t\treturn 'r';\n\t\t\t\tcase RGFormat:\n\t\t\t\tcase RGIntegerFormat:\n\t\t\t\t\treturn 'rg';\n\t\t\t\tcase RGBFormat:\n\t\t\t\tcase RGBIntegerFormat:\n\t\t\t\t\treturn 'rgb';\n\t\t\t\tcase DepthFormat:\n\t\t\t\t\treturn 'depth';\n\t\t\t\tcase DepthStencilFormat:\n\t\t\t\t\treturn 'depth-stencil';\n\t\t\t\tcase RGBAFormat:\n\t\t\t\tcase RGBAIntegerFormat:\n\t\t\t\tdefault:\n\t\t\t\t\treturn 'rgba';\n\n\t\t\t}\n\n\t\t};\n\n\t\tfor ( let i = 0; i < textures.length; i ++ ) {\n\n\t\t\tconst texture = textures[ i ];\n\n\t\t\tconst bpc = getBPC( texture );\n\t\t\tconst format = getFormat( texture );\n\n\t\t\tlet description = `[${ i }]`;\n\n\t\t\tif ( texture.name && ! ( texture.isDepthTexture && texture.name === 'depth' ) ) {\n\n\t\t\t\tdescription += ` ${ texture.name }`;\n\n\t\t\t}\n\n\t\t\tdescription += ` ${ format } ${ bpc } bpc`;\n\n\t\t\tattachments.push( description );\n\n\t\t}\n\n\t\tconst details = {\n\t\t\ttarget: renderTarget.name || 'RenderTarget',\n\t\t\t[ `attachments(${ textures.length })` ]: '\\n' + attachments.join( '\\n' )\n\t\t};\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\tdetails.depth = `${ getBPC( renderTarget.depthTexture ) } bpc`;\n\n\t\t}\n\n\t\treturn details;\n\n\t}\n\n\tgetCallDetail( method, args ) {\n\n\t\tswitch ( method ) {\n\n\t\t\tcase 'draw': {\n\n\t\t\t\tconst renderObject = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tobject: renderObject.object.name || renderObject.object.type,\n\t\t\t\t\tmaterial: renderObject.material.name || renderObject.material.type,\n\t\t\t\t\tgeometry: renderObject.geometry.name || renderObject.geometry.type\n\t\t\t\t};\n\n\t\t\t\tif ( renderObject.getDrawParameters ) {\n\n\t\t\t\t\tconst drawParams = renderObject.getDrawParameters();\n\n\t\t\t\t\tif ( drawParams ) {\n\n\t\t\t\t\t\tif ( renderObject.object.isMesh || renderObject.object.isSprite ) {\n\n\t\t\t\t\t\t\t// the WebGL backend doesn't support indirect draws, it draws with the parameters of the geometry\n\n\t\t\t\t\t\t\tif ( this.renderer.backend.isWebGPUBackend === true && renderObject.getIndirect() !== null ) {\n\n\t\t\t\t\t\t\t\tdetails.indirect = true;\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tdetails.triangles = drawParams.vertexCount / 3;\n\n\t\t\t\t\t\t\t\tif ( renderObject.object.count > 1 ) {\n\n\t\t\t\t\t\t\t\t\tdetails.instance = renderObject.object.count;\n\n\t\t\t\t\t\t\t\t\tdetails[ 'triangles per instance' ] = details.triangles;\n\t\t\t\t\t\t\t\t\tdetails.triangles *= details.instance;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'beginRender': {\n\n\t\t\t\tconst renderContext = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tscene: this.renderer.inspector.currentRender.name || 'unknown',\n\t\t\t\t\tcamera: renderContext.camera.name || renderContext.camera.type\n\t\t\t\t};\n\n\t\t\t\tif ( renderContext.renderTarget && ! renderContext.renderTarget.isPostProcessingRenderTarget ) {\n\n\t\t\t\t\tObject.assign( details, this.getRenderTargetDetails( renderContext.renderTarget ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdetails.target = 'CanvasTarget';\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'beginCompute': {\n\n\t\t\t\tconst details = {\n\t\t\t\t\tcompute: this.renderer.inspector.currentCompute.name || 'unknown'\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'compute': {\n\n\t\t\t\tconst computeNode = args[ 1 ];\n\t\t\t\tconst bindings = args[ 2 ];\n\t\t\t\tconst dispatchSize = args[ 4 ] || computeNode.dispatchSize || computeNode.count;\n\n\t\t\t\tconst node = computeNode.name || computeNode.type || 'unknown';\n\n\t\t\t\t// bindings\n\n\t\t\t\tlet bindingsCount = 0;\n\n\t\t\t\tif ( bindings ) {\n\n\t\t\t\t\tbindingsCount = bindings.length;\n\n\t\t\t\t}\n\n\t\t\t\t// dispatch\n\n\t\t\t\tlet dispatch;\n\n\t\t\t\tif ( dispatchSize.isIndirectStorageBufferAttribute ) {\n\n\t\t\t\t\tdispatch = 'indirect';\n\n\t\t\t\t} else if ( Array.isArray( dispatchSize ) ) {\n\n\t\t\t\t\tdispatch = dispatchSize.join( ', ' );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdispatch = dispatchSize;\n\n\t\t\t\t}\n\n\t\t\t\t// details\n\n\t\t\t\treturn {\n\t\t\t\t\tnode,\n\t\t\t\t\tbindings: bindingsCount,\n\t\t\t\t\tdispatch\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tcase 'updateBinding': {\n\n\t\t\t\tconst binding = args[ 0 ];\n\n\t\t\t\treturn { group: binding.name || 'unknown' };\n\n\t\t\t}\n\n\t\t\tcase 'clear': {\n\n\t\t\t\tconst renderContext = args[ 3 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tcolor: args[ 0 ],\n\t\t\t\t\tdepth: args[ 1 ],\n\t\t\t\t\tstencil: args[ 2 ]\n\t\t\t\t};\n\n\t\t\t\tif ( renderContext.renderTarget && ! renderContext.renderTarget.isPostProcessingRenderTarget ) {\n\n\t\t\t\t\tconst renderTargetDetails = this.getRenderTargetDetails( renderContext.renderTarget );\n\n\t\t\t\t\tif ( renderTargetDetails.depth ) {\n\n\t\t\t\t\t\trenderTargetDetails[ 'depth texture' ] = renderTargetDetails.depth;\n\n\t\t\t\t\t\tdelete renderTargetDetails.depth;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tObject.assign( details, renderTargetDetails );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdetails.target = 'CanvasTarget';\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'updateViewport': {\n\n\t\t\t\tconst renderContext = args[ 0 ];\n\t\t\t\tconst { x, y, width, height } = renderContext.viewportValue;\n\n\t\t\t\treturn { x, y, width, height };\n\n\t\t\t}\n\n\t\t\tcase 'updateScissor': {\n\n\t\t\t\tconst renderContext = args[ 0 ];\n\t\t\t\tconst { x, y, width, height } = renderContext.scissorValue;\n\n\t\t\t\treturn { x, y, width, height };\n\n\t\t\t}\n\n\t\t\tcase 'createProgram':\n\t\t\tcase 'destroyProgram': {\n\n\t\t\t\tconst program = args[ 0 ];\n\t\t\t\treturn { stage: program.stage, name: program.name || 'unknown' };\n\n\t\t\t}\n\n\t\t\tcase 'createRenderPipeline': {\n\n\t\t\t\tconst renderObject = args[ 0 ];\n\t\t\t\tconst details = {\n\t\t\t\t\tobject: renderObject.object ? ( renderObject.object.name || renderObject.object.type || 'unknown' ) : 'unknown',\n\t\t\t\t\tmaterial: renderObject.material ? ( renderObject.material.name || renderObject.material.type || 'unknown' ) : 'unknown'\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'createComputePipeline':\n\t\t\tcase 'destroyComputePipeline': {\n\n\t\t\t\tconst pipeline = args[ 0 ];\n\t\t\t\treturn { name: pipeline.name || 'unknown' };\n\n\t\t\t}\n\n\t\t\tcase 'createBindings':\n\t\t\tcase 'updateBindings': {\n\n\t\t\t\tconst bindGroup = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tgroup: bindGroup.name || 'unknown',\n\t\t\t\t\tcount: bindGroup.bindings.length\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'createUniformBuffer':\n\t\t\tcase 'destroyUniformBuffer': {\n\n\t\t\t\tconst binding = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tgroup: binding.groupNode.name || 'unknown',\n\t\t\t\t\tsize: binding.byteLength + ' bytes'\n\t\t\t\t};\n\n\t\t\t\tif ( binding.name !== details.group ) {\n\n\t\t\t\t\tdetails.name = binding.name;\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'createNodeBuilder': {\n\n\t\t\t\tconst object = args[ 0 ];\n\t\t\t\tconst details = { object: object.name || object.type || 'unknown' };\n\n\t\t\t\tif ( object.material ) {\n\n\t\t\t\t\tdetails.material = object.material.name || object.material.type || 'unknown';\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'createAttribute':\n\t\t\tcase 'createIndexAttribute':\n\t\t\tcase 'createStorageAttribute':\n\t\t\tcase 'destroyAttribute':\n\t\t\tcase 'destroyIndexAttribute':\n\t\t\tcase 'destroyStorageAttribute': {\n\n\t\t\t\tconst attribute = args[ 0 ];\n\t\t\t\tconst details = {};\n\n\t\t\t\tif ( attribute.name ) details.name = attribute.name;\n\t\t\t\tif ( attribute.count !== undefined ) details.count = attribute.count;\n\t\t\t\tif ( attribute.itemSize !== undefined ) details.itemSize = attribute.itemSize;\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'copyFramebufferToTexture': {\n\n\t\t\t\tconst target = args[ 0 ];\n\t\t\t\tconst rectangle = args[ 2 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\ttarget: this.getTextureName( target ),\n\t\t\t\t\twidth: rectangle.z,\n\t\t\t\t\theight: rectangle.w\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'copyTextureToTexture': {\n\n\t\t\t\tconst srcTexture = args[ 0 ];\n\t\t\t\tconst dstTexture = args[ 1 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tsource: this.getTextureName( srcTexture ),\n\t\t\t\t\tdestination: this.getTextureName( dstTexture )\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'updateSampler': {\n\n\t\t\t\tconst texture = args[ 0 ];\n\n\t\t\t\tconst details = {\n\t\t\t\t\tmagFilter: this.getTextureFilterName( texture.magFilter ),\n\t\t\t\t\tminFilter: this.getTextureFilterName( texture.minFilter ),\n\t\t\t\t\twrapS: this.getTextureWrapName( texture.wrapS ),\n\t\t\t\t\twrapT: this.getTextureWrapName( texture.wrapT ),\n\t\t\t\t\tanisotropy: texture.anisotropy\n\t\t\t\t};\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t\tcase 'updateTexture':\n\t\t\tcase 'generateMipmaps':\n\t\t\tcase 'createTexture':\n\t\t\tcase 'destroyTexture': {\n\n\t\t\t\tconst texture = args[ 0 ];\n\t\t\t\tconst name = this.getTextureName( texture );\n\t\t\t\tconst details = { texture: name };\n\n\t\t\t\tif ( texture.image ) {\n\n\t\t\t\t\tif ( texture.image.width !== undefined ) details.width = texture.image.width;\n\t\t\t\t\tif ( texture.image.height !== undefined ) details.height = texture.image.height;\n\n\t\t\t\t}\n\n\t\t\t\treturn details;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn null;\n\n\t}\n\n\tgetTextureName( texture ) {\n\n\t\tif ( texture.name ) return texture.name;\n\n\t\tconst types = [\n\t\t\t'isFramebufferTexture', 'isDepthTexture', 'isDataArrayTexture',\n\t\t\t'isData3DTexture', 'isDataTexture', 'isCompressedArrayTexture',\n\t\t\t'isCompressedTexture', 'isCubeTexture', 'isVideoTexture',\n\t\t\t'isCanvasTexture', 'isTexture'\n\t\t];\n\n\t\tfor ( const type of types ) {\n\n\t\t\tif ( texture[ type ] ) return type.replace( 'is', '' );\n\n\t\t}\n\n\t\treturn 'Texture';\n\n\t}\n\n\tgetTextureFilterName( filter ) {\n\n\t\tconst filters = {\n\t\t\t1003: 'Nearest',\n\t\t\t1004: 'NearestMipmapNearest',\n\t\t\t1005: 'NearestMipmapLinear',\n\t\t\t1006: 'Linear',\n\t\t\t1007: 'LinearMipmapNearest',\n\t\t\t1008: 'LinearMipmapLinear'\n\t\t};\n\n\t\treturn filters[ filter ] || filter;\n\n\t}\n\n\tgetTextureWrapName( wrap ) {\n\n\t\tconst wrappings = {\n\t\t\t1000: 'Repeat',\n\t\t\t1001: 'ClampToEdge',\n\t\t\t1002: 'MirroredRepeat'\n\t\t};\n\n\t\treturn wrappings[ wrap ] || wrap;\n\n\t}\n\n\tformatDetails( details ) {\n\n\t\tconst parts = [];\n\n\t\tfor ( const key in details ) {\n\n\t\t\tif ( details[ key ] !== undefined ) {\n\n\t\t\t\tparts.push( `<span class=\"timeline-detail-key\">${key}:</span> <span class=\"timeline-detail-value\">${details[ key ]}</span>` );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( parts.length === 0 ) return '';\n\n\t\treturn `<span class=\"timeline-detail-block\">{ ${parts.join( '<span class=\"timeline-detail-sep\">, </span>' )} }</span>`;\n\n\t}\n\n\trenderSlider() {\n\n\t\tif ( this.frames.length === 0 ) {\n\n\t\t\tthis.playhead.style.display = 'none';\n\t\t\tthis.frameInfo.textContent = '';\n\t\t\treturn;\n\n\t\t}\n\n\t\t// Reset graph safely to fit recorded frames exactly up to maxPoints\n\t\tthis.graph.lines[ 'calls' ].points = [];\n\t\tthis.graph.lines[ 'fps' ].points = [];\n\t\tthis.graph.lines[ 'triangles' ].points = [];\n\t\tthis.graph.resetLimit();\n\n\t\t// If recorded frames exceed SVG Graph maxPoints, we sample/slice it\n\t\t// (Graph.js inherently handles shifting for real-time,\n\t\t// but statically we want to visualize as much up to max bounds)\n\t\tlet framesToRender = this.frames;\n\t\tif ( framesToRender.length > this.graph.maxPoints ) {\n\n\t\t\tframesToRender = framesToRender.slice( - this.graph.maxPoints );\n\t\t\tthis.frames = framesToRender; // Adjust our internal array to match what's visible\n\n\t\t}\n\n\t\tlet maxTriangles = 0;\n\n\t\tfor ( let i = 0; i < framesToRender.length; i ++ ) {\n\n\t\t\tconst t = framesToRender[ i ].triangles || 0;\n\t\t\tif ( t > maxTriangles ) {\n\n\t\t\t\tmaxTriangles = t;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let i = 0; i < framesToRender.length; i ++ ) {\n\n\t\t\tconst t = framesToRender[ i ].triangles || 0;\n\t\t\tconst normalizedTriangles = maxTriangles > 0 ? ( t / maxTriangles ) * TRIANGLES_GRAPH_LIMIT : 0;\n\n\t\t\t// Adding calls length to the Graph SVG to visualize workload geometry\n\t\t\tthis.graph.addPoint( 'calls', framesToRender[ i ].calls.length );\n\t\t\tthis.graph.addPoint( 'fps', framesToRender[ i ].fps || 0 );\n\t\t\tthis.graph.addPoint( 'triangles', normalizedTriangles );\n\n\t\t}\n\n\t\tthis.graph.update();\n\n\t\tthis.playhead.style.display = 'block';\n\n\t\t// Select the previously selected frame, or the last one if tracking, or 0\n\t\tlet targetFrame = 0;\n\t\tif ( this.selectedFrameIndex !== - 1 && this.selectedFrameIndex < this.frames.length ) {\n\n\t\t\ttargetFrame = this.selectedFrameIndex;\n\n\t\t} else if ( this.frames.length > 0 ) {\n\n\t\t\ttargetFrame = this.frames.length - 1;\n\n\t\t}\n\n\t\tthis.selectFrame( targetFrame );\n\n\t}\n\n\tselectFrame( index ) {\n\n\t\tif ( this.isRecording ) return;\n\n\t\tif ( index < 0 || index >= this.frames.length ) return;\n\n\t\tthis.selectedFrameIndex = index;\n\n\t\tconst frame = this.frames[ index ];\n\t\tthis.renderTimelineTrack( frame );\n\n\t\t// Update UI texts\n\t\tconst panelWidth = this.content.offsetWidth;\n\n\t\tconst isCompact = panelWidth < 800;\n\t\tconst frameLabel = isCompact ? '' : 'Frame: ';\n\t\tconst fpsSuffix = isCompact ? '' : ' FPS';\n\t\tconst callsSuffix = isCompact ? '' : ' calls';\n\t\tconst trianglesSuffix = isCompact ? '' : ' triangles';\n\n\t\tconst group = ( type, text ) => `<span class=\"timeline-info-group\"><span class=\"timeline-info-dot ${type}\"></span>${text}</span>`;\n\t\tconst maxTriangles = Math.max( this.baseTriangles, frame.triangles || 0 );\n\t\tconst trianglesText = isCompact ? ( frame.triangles || 0 ) : ( frame.triangles || 0 ) + ' / ' + maxTriangles + trianglesSuffix;\n\t\tthis.frameInfo.innerHTML = frameLabel + frame.id + group( 'fps', ( frame.fps || 0 ).toFixed( 1 ) + fpsSuffix ) + group( 'call', frame.calls.length + callsSuffix ) + group( 'red', trianglesText );\n\n\t\t// Update playhead position\n\t\tconst rect = this.graphSlider.getBoundingClientRect();\n\t\tconst pointCount = this.graph.lines[ 'calls' ].points.length;\n\n\t\tif ( pointCount > 0 ) {\n\n\t\t\t// Calculate point width step\n\t\t\tconst pointStep = rect.width / ( this.graph.maxPoints - 1 );\n\n\t\t\tlet localIndex = index;\n\n\t\t\tif ( this.frames.length > pointCount ) {\n\n\t\t\t\tlocalIndex = index - ( this.frames.length - pointCount );\n\n\t\t\t}\n\n\t\t\t// x offset calculation from SVG update logic\n\t\t\t// The graph translates (slides) back if points length < maxPoints\n\t\t\t// which means point 0 is at offset\n\t\t\tconst offset = rect.width - ( ( pointCount - 1 ) * pointStep );\n\t\t\tlet xPos = offset + ( localIndex * pointStep );\n\t\t\txPos = Math.max( 1, Math.min( xPos, rect.width - 1 ) );\n\n\t\t\tthis.playhead.style.left = xPos + 'px';\n\t\t\tthis.playhead.style.display = 'block';\n\n\t\t}\n\n\t}\n\n\tcreateBlock() {\n\n\t\tconst block = document.createElement( 'div' );\n\t\tblock.style.display = 'flex';\n\t\tblock.style.alignItems = 'center';\n\t\tblock.style.padding = '4px 8px';\n\t\tblock.style.backgroundColor = 'rgba(255, 255, 255, 0.03)';\n\t\tblock.style.fontFamily = 'monospace';\n\t\tblock.style.fontSize = '12px';\n\t\tblock.style.color = 'var(--text-primary)';\n\t\tblock.style.overflow = 'hidden';\n\t\tblock.style.position = 'absolute';\n\t\tblock.style.left = '0';\n\t\tblock.style.right = '0';\n\t\tblock.style.height = '24px';\n\t\tblock.style.boxSizing = 'border-box';\n\n\t\tblock.arrow = document.createElement( 'span' );\n\t\tblock.arrow.style.fontSize = '10px';\n\t\tblock.arrow.style.marginRight = '8px';\n\t\tblock.arrow.style.cursor = 'pointer';\n\t\tblock.arrow.style.width = '35px';\n\t\tblock.arrow.style.textAlign = 'center';\n\t\tblock.arrow.style.flexShrink = '0';\n\t\tblock.arrow.style.whiteSpace = 'nowrap';\n\t\tblock.appendChild( block.arrow );\n\n\t\tblock.titleSpan = document.createElement( 'span' );\n\t\tblock.titleSpan.style.flex = '1';\n\t\tblock.titleSpan.style.minWidth = '0';\n\t\tblock.titleSpan.style.overflow = 'hidden';\n\t\tblock.titleSpan.style.textOverflow = 'ellipsis';\n\t\tblock.titleSpan.style.whiteSpace = 'nowrap';\n\t\tblock.appendChild( block.titleSpan );\n\n\t\tblock.addEventListener( 'click', ( e ) => {\n\n\t\t\tif ( ! block._groupId ) return;\n\n\t\t\te.stopPropagation();\n\n\t\t\tif ( this.collapsedGroups.has( block._groupId ) ) {\n\n\t\t\t\tthis.collapsedGroups.delete( block._groupId );\n\n\t\t\t} else {\n\n\t\t\t\tthis.collapsedGroups.add( block._groupId );\n\n\t\t\t}\n\n\t\t\tthis.renderTimelineTrack( this.frames[ this.selectedFrameIndex ] );\n\n\t\t} );\n\n\t\treturn block;\n\n\t}\n\n\tclearActiveBlocks() {\n\n\t\tif ( this.activeBlocks ) {\n\n\t\t\tfor ( const block of this.activeBlocks.values() ) {\n\n\t\t\t\tblock.remove();\n\t\t\t\tthis.domPool.push( block );\n\n\t\t\t}\n\n\t\t\tthis.activeBlocks.clear();\n\n\t\t}\n\n\t}\n\n\tupdateVisibleBlocks() {\n\n\t\tif ( ! this.flatList || this.flatList.length === 0 ) {\n\n\t\t\tthis.clearActiveBlocks();\n\t\t\treturn;\n\n\t\t}\n\n\t\tconst ROW_HEIGHT = 26;\n\t\tconst BUFFER_ROWS = 5;\n\n\t\tconst scrollTop = this.timelineTrack.scrollTop;\n\t\tconst viewportHeight = this.timelineTrack.clientHeight;\n\n\t\tlet startIndex = Math.floor( scrollTop / ROW_HEIGHT ) - BUFFER_ROWS;\n\t\tlet endIndex = Math.ceil( ( scrollTop + viewportHeight ) / ROW_HEIGHT ) + BUFFER_ROWS;\n\n\t\tstartIndex = Math.max( 0, startIndex );\n\t\tendIndex = Math.min( this.flatList.length - 1, endIndex );\n\n\t\tconst nextActiveBlocks = new Map();\n\n\t\tfor ( const [ index, block ] of this.activeBlocks.entries() ) {\n\n\t\t\tif ( index < startIndex || index > endIndex ) {\n\n\t\t\t\tblock.remove();\n\t\t\t\tthis.domPool.push( block );\n\n\t\t\t} else {\n\n\t\t\t\tnextActiveBlocks.set( index, block );\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.activeBlocks = nextActiveBlocks;\n\n\t\tfor ( let i = startIndex; i <= endIndex; i ++ ) {\n\n\t\t\tlet block = this.activeBlocks.get( i );\n\n\t\t\tif ( ! block ) {\n\n\t\t\t\tblock = this.domPool.pop() || this.createBlock();\n\t\t\t\tthis.timelineContent.appendChild( block );\n\t\t\t\tthis.activeBlocks.set( i, block );\n\n\t\t\t}\n\n\t\t\tconst item = this.flatList[ i ];\n\t\t\tconst call = item.call;\n\n\t\t\tblock.style.top = ( i * ROW_HEIGHT ) + 'px';\n\t\t\tblock.style.marginLeft = ( item.indent * 24 ) + 'px';\n\t\t\tblock.style.borderLeft = '4px solid ' + this.getColorForMethod( call.method );\n\t\t\tblock._groupId = item.groupId;\n\n\t\t\tconst directInfoIcon = block.querySelector( ':scope > .info-icon' );\n\t\t\tif ( directInfoIcon ) {\n\n\t\t\t\tdirectInfoIcon.remove();\n\n\t\t\t}\n\n\t\t\tblock.titleSpan.textContent = '';\n\n\t\t\tconst methodSpan = document.createElement( 'span' );\n\t\t\tmethodSpan.textContent = call.method;\n\t\t\tblock.titleSpan.appendChild( methodSpan );\n\n\t\t\tif ( call.details ) {\n\n\t\t\t\tlet tooltipText = `### ${call.method}\\n`;\n\t\t\t\tfor ( const key in call.details ) {\n\n\t\t\t\t\tif ( call.details[ key ] !== undefined ) {\n\n\t\t\t\t\t\ttooltipText += `**${key}**: ${call.details[ key ]}\\n`;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tconst infoIcon = info( block.titleSpan, tooltipText );\n\t\t\t\tinfoIcon.style.flexShrink = '0';\n\t\t\t\tinfoIcon.style.marginLeft = '6px';\n\t\t\t\tinfoIcon.style.display = 'inline-flex';\n\t\t\t\tinfoIcon.style.verticalAlign = 'middle';\n\n\t\t\t}\n\n\t\t\tconst detailsAndCountSpan = document.createElement( 'span' );\n\t\t\tlet detailsAndCountHTML = ( call.formatedDetails ? call.formatedDetails : '' );\n\t\t\tif ( call.count > 1 ) {\n\n\t\t\t\tdetailsAndCountHTML += ` <span class=\"timeline-call-count\">( ${call.count} )</span>`;\n\n\t\t\t}\n\n\t\t\tif ( detailsAndCountHTML ) {\n\n\t\t\t\tdetailsAndCountSpan.innerHTML = detailsAndCountHTML;\n\t\t\t\tblock.titleSpan.appendChild( detailsAndCountSpan );\n\n\t\t\t}\n\n\t\t\tif ( item.groupId ) {\n\n\t\t\t\tblock.style.cursor = 'pointer';\n\t\t\t\tblock.arrow.style.display = 'inline-block';\n\t\t\t\tblock.arrow.textContent = item.isCollapsed ? '[ + ]' : '[ - ]';\n\n\t\t\t} else {\n\n\t\t\t\tblock.style.cursor = 'default';\n\t\t\t\tblock.arrow.style.display = 'none';\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\trenderTimelineTrack( frame ) {\n\n\t\tif ( this.isRecording ) return;\n\n\t\tthis.flatList = [];\n\n\t\tif ( ! frame || frame.calls.length === 0 ) {\n\n\t\t\tthis.clearActiveBlocks();\n\t\t\tthis.timelineContent.innerHTML = '';\n\t\t\tthis.timelineContent.style.height = '0px';\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( ! this.collapsedGroups ) {\n\n\t\t\tthis.collapsedGroups = new Set();\n\n\t\t}\n\n\t\tif ( this.isHierarchicalView ) {\n\n\t\t\tconst groupedCalls = [];\n\t\t\tlet currentGroup = null;\n\n\t\t\tfor ( let i = 0; i < frame.calls.length; i ++ ) {\n\n\t\t\t\tconst call = frame.calls[ i ];\n\t\t\t\tconst isStructural = call.method.startsWith( 'begin' ) || call.method.startsWith( 'finish' );\n\t\t\t\tconst formatedDetails = call.details ? this.formatDetails( call.details ) : '';\n\n\t\t\t\tif ( currentGroup && currentGroup.method === call.method && currentGroup.formatedDetails === formatedDetails && ! isStructural ) {\n\n\t\t\t\t\tcurrentGroup.count ++;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcurrentGroup = { method: call.method, count: 1, formatedDetails, target: call.target, details: call.details };\n\t\t\t\t\tgroupedCalls.push( currentGroup );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tlet currentIndent = 0;\n\t\t\tconst elementStack = [ { isCollapsed: false, id: '', beginCount: 0 } ];\n\t\t\tconst instanceCounts = new WeakMap();\n\n\t\t\tfor ( let i = 0; i < groupedCalls.length; i ++ ) {\n\n\t\t\t\tconst call = groupedCalls[ i ];\n\t\t\t\tlet instanceIndex = 0;\n\n\t\t\t\tif ( call.target && typeof call.target === 'object' ) {\n\n\t\t\t\t\tinstanceIndex = instanceCounts.get( call.target ) || 0;\n\t\t\t\t\tinstanceCounts.set( call.target, instanceIndex + 1 );\n\n\t\t\t\t}\n\n\t\t\t\tconst currentParent = elementStack[ elementStack.length - 1 ];\n\n\t\t\t\tlet groupId = null;\n\t\t\t\tlet isCollapsed = false;\n\n\t\t\t\tif ( call.method.startsWith( 'begin' ) ) {\n\n\t\t\t\t\tconst beginIndex = currentParent.beginCount ++;\n\t\t\t\t\tgroupId = currentParent.id + '/' + call.method + '-' + beginIndex;\n\t\t\t\t\tisCollapsed = this.collapsedGroups.has( groupId );\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! currentParent.isCollapsed ) {\n\n\t\t\t\t\tthis.flatList.push( {\n\t\t\t\t\t\tcall,\n\t\t\t\t\t\tindent: currentIndent,\n\t\t\t\t\t\tgroupId,\n\t\t\t\t\t\tisCollapsed,\n\t\t\t\t\t\tinstanceIndex\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t\tif ( call.method.startsWith( 'begin' ) ) {\n\n\t\t\t\t\tcurrentIndent ++;\n\t\t\t\t\telementStack.push( { isCollapsed: currentParent.isCollapsed || isCollapsed, id: groupId, beginCount: 0 } );\n\n\t\t\t\t} else if ( call.method.startsWith( 'finish' ) ) {\n\n\t\t\t\t\tcurrentIndent = Math.max( 0, currentIndent - 1 );\n\t\t\t\t\telementStack.pop();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst callCounts = {};\n\n\t\t\tfor ( let i = 0; i < frame.calls.length; i ++ ) {\n\n\t\t\t\tconst method = frame.calls[ i ].method;\n\n\t\t\t\tif ( method.startsWith( 'finish' ) ) continue;\n\n\t\t\t\tcallCounts[ method ] = ( callCounts[ method ] || 0 ) + 1;\n\n\t\t\t}\n\n\t\t\tconst sortedCalls = Object.keys( callCounts ).map( method => ( { method, count: callCounts[ method ] } ) );\n\t\t\tsortedCalls.sort( ( a, b ) => b.count - a.count );\n\n\t\t\tfor ( let i = 0; i < sortedCalls.length; i ++ ) {\n\n\t\t\t\tconst call = sortedCalls[ i ];\n\n\t\t\t\tthis.flatList.push( {\n\t\t\t\t\tcall,\n\t\t\t\t\tindent: 0,\n\t\t\t\t\tgroupId: null,\n\t\t\t\t\tisCollapsed: false,\n\t\t\t\t\tinstanceIndex: 0\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst ROW_HEIGHT = 26;\n\t\tthis.timelineContent.style.height = ( this.flatList.length * ROW_HEIGHT ) + 'px';\n\t\tthis.updateVisibleBlocks();\n\n\t}\n\n\tgetColorForMethod( method ) {\n\n\t\tif ( method.startsWith( 'begin' ) ) return 'var(--color-green)';\n\t\tif ( method.startsWith( 'finish' ) || method.startsWith( 'destroy' ) ) return 'var(--color-red)';\n\t\tif ( method.startsWith( 'draw' ) || method.startsWith( 'compute' ) || method.startsWith( 'create' ) || method.startsWith( 'generate' ) ) return 'var(--color-yellow)';\n\t\treturn 'var(--text-secondary)';\n\n\t}\n\n}\n\nexport { Timeline };\n","\nimport { RendererInspector } from './RendererInspector.js';\nimport { Profiler } from './ui/Profiler.js';\nimport { Performance } from './tabs/Performance.js';\nimport { Memory } from './tabs/Memory.js';\nimport { Console } from './tabs/Console.js';\nimport { Parameters } from './tabs/Parameters.js';\nimport { Settings } from './tabs/Settings.js';\nimport { Viewer } from './tabs/Viewer.js';\nimport { Timeline } from './tabs/Timeline.js';\nimport { setText } from './ui/utils.js';\nimport { getItem, setItem } from './Storage.js';\n\nimport { setConsoleFunction, getConsoleFunction, REVISION } from 'three/webgpu';\n\nclass Inspector extends RendererInspector {\n\n\tconstructor( options = {} ) {\n\n\t\tsuper();\n\n\t\tconst {\n\t\t\tnonce = null\n\t\t} = options;\n\n\t\tthis.nonce = nonce;\n\n\t\t// init profiler\n\n\t\tconst profiler = new Profiler( this, options );\n\t\tprofiler.addEventListener( 'resize', ( e ) => this.dispatchEvent( e ) );\n\t\tprofiler.addEventListener( 'orientationchange', ( e ) => this.dispatchEvent( e ) );\n\t\tprofiler.addEventListener( 'layoutchange', ( e ) => this.dispatchEvent( e ) );\n\n\t\tconst parameters = new Parameters( {\n\t\t\tbuiltin: true,\n\t\t\ticon: '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0\" /><path d=\"M4 6l8 0\" /><path d=\"M16 6l4 0\" /><path d=\"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0\" /><path d=\"M4 12l2 0\" /><path d=\"M10 12l10 0\" /><path d=\"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0\" /><path d=\"M4 18l11 0\" /><path d=\"M19 18l1 0\" /></svg>'\n\t\t} );\n\t\tparameters.hide();\n\t\tprofiler.addTab( parameters );\n\n\t\tconst viewer = new Viewer();\n\t\tviewer.hide();\n\t\tprofiler.addTab( viewer );\n\n\t\tconst performance = new Performance();\n\t\tprofiler.addTab( performance );\n\n\t\tconst memory = new Memory();\n\t\tprofiler.addTab( memory );\n\n\t\tconst timeline = new Timeline();\n\t\tprofiler.addTab( timeline );\n\n\t\tconst consoleTab = new Console();\n\t\tprofiler.addTab( consoleTab );\n\n\t\tconst settings = new Settings();\n\t\tprofiler.addTab( settings );\n\n\t\tprofiler.loadLayout();\n\n\t\tif ( ! profiler.activeTabId ) {\n\n\t\t\tprofiler.setActiveTab( performance.id );\n\n\t\t}\n\n\t\tthis.statsData = new Map();\n\t\tthis.profiler = profiler;\n\t\tthis.performance = performance;\n\t\tthis.memory = memory;\n\t\tthis.console = consoleTab;\n\t\tthis.parameters = parameters;\n\t\tthis.viewer = viewer;\n\t\tthis.timeline = timeline;\n\t\tthis.settings = settings;\n\t\tthis.once = {};\n\t\tthis.extensionsData = new WeakMap();\n\t\tthis.previousConsoleFunction = null;\n\t\tthis._domObserver = null;\n\n\t\tthis.displayCycle = {\n\t\t\ttext: {\n\t\t\t\tneedsUpdate: false,\n\t\t\t\tduration: .25,\n\t\t\t\ttime: 0\n\t\t\t},\n\t\t\tgraph: {\n\t\t\t\tneedsUpdate: false,\n\t\t\t\tduration: .02,\n\t\t\t\ttime: 0\n\t\t\t},\n\t\t\ttoggleGraph: {\n\t\t\t\tneedsUpdate: false,\n\t\t\t\tduration: .02,\n\t\t\t\ttime: 0\n\t\t\t}\n\t\t};\n\n\t}\n\n\tget domElement() {\n\n\t\treturn this.profiler.domElement;\n\n\t}\n\n\tisVertical() {\n\n\t\treturn this.profiler ? this.profiler.isVertical() : false;\n\n\t}\n\n\tonExtension( name, callback ) {\n\n\t\tconst extensionAdded = ( e ) => {\n\n\t\t\tif ( e.name === name ) {\n\n\t\t\t\tcallback( e.tab );\n\n\t\t\t\tthis.settings.removeEventListener( 'extensionadded', extensionAdded );\n\n\t\t\t}\n\n\t\t};\n\n\t\tif ( this.settings.extensions[ name ] && this.settings.extensions[ name ].loaded ) {\n\n\t\t\tcallback( this.settings.extensions[ name ] );\n\n\t\t} else {\n\n\t\t\tthis.settings.addEventListener( 'extensionadded', extensionAdded );\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\thide() {\n\n\t\tthis.profiler.hide();\n\n\t}\n\n\tshow() {\n\n\t\tthis.profiler.show();\n\n\t}\n\n\tsetVisible( value ) {\n\n\t\tthis.domElement.style.display = value ? '' : 'none';\n\n\t\treturn this;\n\n\t}\n\n\tgetVisible() {\n\n\t\treturn this.domElement.style.display !== 'none';\n\n\t}\n\n\tgetSize() {\n\n\t\treturn this.profiler.getSize();\n\n\t}\n\n\tsetActiveTab( tab ) {\n\n\t\tthis.profiler.setActiveTab( tab.id );\n\n\t\treturn this;\n\n\t}\n\n\tsetHorizontalAlign( value ) {\n\n\t\tthis.profiler.setHorizontalAlign( value );\n\n\t\treturn this;\n\n\t}\n\n\tsetVerticalAlign( value ) {\n\n\t\tthis.profiler.setVerticalAlign( value );\n\n\t\treturn this;\n\n\t}\n\n\taddTab( tab ) {\n\n\t\tthis.profiler.addTab( tab );\n\n\t\treturn this;\n\n\t}\n\n\tremoveTab( tab ) {\n\n\t\ttab.dispose();\n\n\t\tthis.profiler.removeTab( tab );\n\n\t\treturn this;\n\n\t}\n\n\tsetActiveExtension( name, value ) {\n\n\t\tthis.settings.setActiveExtension( name, value );\n\n\t\treturn this;\n\n\t}\n\n\tresolveConsoleOnce( type, message ) {\n\n\t\tconst key = type + message;\n\n\t\tif ( this.once[ key ] !== true ) {\n\n\t\t\tthis.resolveConsole( type, message );\n\t\t\tthis.once[ key ] = true;\n\n\t\t}\n\n\t}\n\n\tresolveConsole( type, message, stackTrace = null ) {\n\n\t\tswitch ( type ) {\n\n\t\t\tcase 'log':\n\n\t\t\t\tthis.console.addMessage( 'info', message );\n\n\t\t\t\tconsole.log( message );\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'warn':\n\n\t\t\t\tthis.console.addMessage( 'warn', message );\n\n\t\t\t\tif ( stackTrace && stackTrace.isStackTrace ) {\n\n\t\t\t\t\tconsole.warn( stackTrace.getError( message ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( message );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'error':\n\n\t\t\t\tthis.console.addMessage( 'error', message );\n\n\t\t\t\tif ( stackTrace && stackTrace.isStackTrace ) {\n\n\t\t\t\t\tconsole.error( stackTrace.getError( message ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.error( message );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tsetRenderer( renderer ) {\n\n\t\tsuper.setRenderer( renderer );\n\n\t\tif ( renderer !== null ) {\n\n\t\t\tconst previousConsoleFunction = getConsoleFunction();\n\n\t\t\tthis.previousConsoleFunction = previousConsoleFunction;\n\n\t\t\tsetConsoleFunction( ( type, message, ...params ) => {\n\n\t\t\t\tif ( previousConsoleFunction ) {\n\n\t\t\t\t\tpreviousConsoleFunction( type, message, ...params );\n\n\t\t\t\t}\n\n\t\t\t\tthis.resolveConsole( type, message, ...params );\n\n\t\t\t} );\n\n\t\t\tif ( this.isAvailable ) {\n\n\t\t\t\tconst init = async () => {\n\n\t\t\t\t\tif ( renderer.hasInitialized() === false ) await renderer.init();\n\n\t\t\t\t\trenderer.backend.trackTimestamp = true;\n\n\t\t\t\t\tif ( renderer.hasFeature( 'timestamp-query' ) !== true ) {\n\n\t\t\t\t\t\tthis.console.addMessage( 'error', 'THREE.Inspector: GPU Timestamp Queries not available.' );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tlet sign = `THREE.WebGPURenderer: ${ REVISION } [ \"`;\n\n\t\t\t\t\tif ( renderer.backend.isWebGPUBackend ) {\n\n\t\t\t\t\t\tsign += 'WebGPU';\n\n\t\t\t\t\t} else if ( renderer.backend.isWebGLBackend ) {\n\n\t\t\t\t\t\tsign += 'WebGL2';\n\n\t\t\t\t\t}\n\n\t\t\t\t\tsign += '\" ]';\n\n\t\t\t\t\tthis.console.addMessage( 'info', sign );\n\n\t\t\t\t\t//\n\n\t\t\t\t\tconst domElement = this.domElement;\n\n\t\t\t\t\tif ( domElement.parentElement === null ) {\n\n\t\t\t\t\t\tif ( renderer.domElement.parentElement !== null ) {\n\n\t\t\t\t\t\t\trenderer.domElement.parentElement.appendChild( domElement );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tif ( this._domObserver !== null ) {\n\n\t\t\t\t\t\t\t\tthis._domObserver.disconnect();\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthis._domObserver = new MutationObserver( () => {\n\n\t\t\t\t\t\t\t\tif ( renderer.domElement && renderer.domElement.parentElement !== null ) {\n\n\t\t\t\t\t\t\t\t\trenderer.domElement.parentElement.appendChild( domElement );\n\n\t\t\t\t\t\t\t\t\tif ( this._domObserver !== null ) {\n\n\t\t\t\t\t\t\t\t\t\tthis._domObserver.disconnect();\n\t\t\t\t\t\t\t\t\t\tthis._domObserver = null;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tthis._domObserver.observe( document.body || document.documentElement, { childList: true, subtree: true } );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t};\n\n\t\t\t\tinit();\n\n\t\t\t\tthis.timeline.setRenderer( renderer );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( this.previousConsoleFunction ) {\n\n\t\t\t\tsetConsoleFunction( this.previousConsoleFunction );\n\t\t\t\tthis.previousConsoleFunction = undefined;\n\n\t\t\t}\n\n\t\t\tif ( this._domObserver !== null ) {\n\n\t\t\t\tthis._domObserver.disconnect();\n\t\t\t\tthis._domObserver = null;\n\n\t\t\t}\n\n\t\t\tthis.profiler.dispose();\n\n\t\t\tthis.statsData.clear();\n\n\t\t\tsuper.dispose();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tcreateParameters( name ) {\n\n\t\tif ( this.parameters.isVisible === false ) {\n\n\t\t\tthis.parameters.show();\n\n\t\t}\n\n\t\treturn this.parameters.createGroup( name );\n\n\t}\n\n\tgetStatsData( cid ) {\n\n\t\tlet data = this.statsData.get( cid );\n\n\t\tif ( data === undefined ) {\n\n\t\t\tdata = {};\n\n\t\t\tthis.statsData.set( cid, data );\n\n\t\t}\n\n\t\treturn data;\n\n\t}\n\n\tresolveStats( stats ) {\n\n\t\tconst data = this.getStatsData( stats.cid );\n\n\t\tif ( data.initialized !== true ) {\n\n\t\t\tdata.cpu = stats.cpu;\n\t\t\tdata.gpu = stats.gpu;\n\t\t\tdata.stats = [];\n\n\t\t\tdata.initialized = true;\n\n\t\t}\n\n\t\t// store stats\n\n\t\tif ( data.stats.length > this.maxFrames ) {\n\n\t\t\tdata.stats.shift();\n\n\t\t}\n\n\t\tdata.stats.push( stats );\n\n\t\t// compute averages\n\n\t\tdata.cpu = this.getAverageDeltaTime( data, 'cpu' );\n\t\tdata.gpu = this.getAverageDeltaTime( data, 'gpu' );\n\n\t\t// children: the CPU time of a render or compute call includes the calls nested in it, the GPU time of each\n\t\t// pass is measured separately\n\n\t\tfor ( const child of stats.children ) {\n\n\t\t\tthis.resolveStats( child );\n\n\t\t\tconst childData = this.getStatsData( child.cid );\n\n\t\t\tdata.gpu += childData.gpu;\n\n\t\t}\n\n\t\tdata.total = data.cpu + data.gpu;\n\n\t}\n\n\tgetNodes() {\n\n\t\treturn this.currentNodes;\n\n\t}\n\n\tgetAverageDeltaTime( statsData, property, frames = this.fps ) {\n\n\t\tconst statsArray = statsData.stats;\n\n\t\tlet sum = 0;\n\t\tlet count = 0;\n\n\t\tfor ( let i = statsArray.length - 1; i >= 0 && count < frames; i -- ) {\n\n\t\t\tconst stats = statsArray[ i ];\n\t\t\tconst value = stats[ property ];\n\n\t\t\tif ( value > 0 ) {\n\n\t\t\t\t// ignore invalid values\n\n\t\t\t\tsum += value;\n\t\t\t\tcount ++;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn count > 0 ? sum / count : 0;\n\n\t}\n\n\tupdateTabs() {\n\n\t\t// tabs\n\n\t\tconst tabs = Object.values( this.profiler.tabs );\n\n\t\tfor ( const tab of tabs ) {\n\n\t\t\tlet tabData = this.extensionsData.get( tab );\n\n\t\t\tif ( tabData === undefined ) {\n\n\t\t\t\ttab.init( this );\n\n\t\t\t\ttabData = {};\n\n\t\t\t\tthis.extensionsData.set( tab, tabData );\n\n\t\t\t}\n\n\t\t\ttab.update( this );\n\n\t\t}\n\n\t}\n\n\tresolveFrame( frame ) {\n\n\t\tconst previousFrame = this.getFrameById( frame.frameId - 1 );\n\n\t\tif ( ! previousFrame ) return;\n\n\t\tframe.cpu = 0;\n\t\tframe.gpu = 0;\n\t\tframe.total = 0;\n\n\t\tfor ( const stats of frame.children ) {\n\n\t\t\tthis.resolveStats( stats );\n\n\t\t\tconst data = this.getStatsData( stats.cid );\n\n\t\t\tframe.cpu += data.cpu;\n\t\t\tframe.gpu += data.gpu;\n\t\t\tframe.total += data.total;\n\n\t\t}\n\n\t\t// the time since the last frame which rendered, see RendererInspector.finish()\n\n\t\tframe.miscellaneous = frame.deltaTime - frame.total;\n\n\t\tif ( frame.miscellaneous < 0 ) {\n\n\t\t\t// Frame desync, probably due to async GPU timing.\n\n\t\t\tframe.miscellaneous = 0;\n\n\t\t}\n\n\t\t//\n\n\t\tthis.updateCycle( this.displayCycle.text );\n\t\tthis.updateCycle( this.displayCycle.graph );\n\t\tthis.updateCycle( this.displayCycle.toggleGraph );\n\n\t\tif ( this.displayCycle.text.needsUpdate ) {\n\n\t\t\tsetText( this.profiler.toggleButton.querySelector( '.fps-counter' ), this.fps.toFixed() );\n\n\t\t\tthis.performance.updateText( this, frame );\n\t\t\tthis.memory.updateText( this );\n\n\t\t}\n\n\t\tif ( this.displayCycle.toggleGraph.needsUpdate ) {\n\n\t\t\tif ( this.profiler.toggleGraph ) {\n\n\t\t\t\tthis.profiler.toggleGraph.addPoint( 'fps', this.fps );\n\t\t\t\tthis.profiler.toggleGraph.update();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.displayCycle.graph.needsUpdate ) {\n\n\t\t\tthis.performance.updateGraph( this, frame );\n\t\t\tthis.memory.updateGraph( this );\n\n\t\t}\n\n\t\tthis.displayCycle.text.needsUpdate = false;\n\t\tthis.displayCycle.graph.needsUpdate = false;\n\t\tthis.displayCycle.toggleGraph.needsUpdate = false;\n\n\t}\n\n\tupdateCycle( cycle ) {\n\n\t\tcycle.time += this.nodeFrame.deltaTime;\n\n\t\tif ( cycle.time >= cycle.duration ) {\n\n\t\t\tcycle.needsUpdate = true;\n\t\t\tcycle.time = 0;\n\n\t\t}\n\n\t}\n\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis.setRenderer( null );\n\n\t}\n\n}\n\nexport { Inspector, getItem, setItem };\n","import { RenderTarget, Vector2, Node, QuadMesh, NodeMaterial, RendererUtils, MathUtils, RGBFormat, RedFormat, UnsignedInt101111Type, UnsignedByteType } from 'three/webgpu';\nimport { clamp, normalize, reference, Fn, NodeUpdateType, uniform, vec4, passTexture, uv, getViewPosition, screenCoordinate, float, sub, fract, dot, vec2, rand, vec3, Loop, mul, PI, cos, sin, uint, cross, acos, sign, pow, luminance, If, max, abs, Break, sqrt, HALF_PI, div, ceil, shiftRight, convertToTexture, bool, getNormalFromDepth, countOneBits, interleavedGradientNoise, property, outputStruct, context, isBackgroundDepth, min, projectionDepth } from 'three/tsl';\n\nconst _quadMesh = /*@__PURE__*/ new QuadMesh();\nconst _size = /*@__PURE__*/ new Vector2();\n\n// From Activision GTAO paper: https://www.activision.com/cdn/research/s2016_pbs_activision_occlusion.pptx\nconst _temporalRotations = [ 60, 300, 180, 240, 120, 0 ];\nconst _spatialOffsets = [ 0, 0.5, 0.25, 0.75 ];\n\nlet _rendererState;\n\n/**\n * Post processing node for applying Screen Space Global Illumination (SSGI) to a scene.\n *\n * References:\n * - {@link https://github.com/cdrinmatane/SSRT3}.\n * - {@link https://cdrinmatane.github.io/posts/ssaovb-code/}.\n * - {@link https://cdrinmatane.github.io/cgspotlight-slides/ssilvb_slides.pdf}.\n *\n * The quality and performance of the effect mainly depend on `sliceCount` and `stepCount`.\n * The total number of samples taken per pixel is `sliceCount` * `stepCount` * `2`. Here are some\n * recommended presets depending on whether temporal filtering is used or not.\n *\n * With temporal filtering (recommended):\n *\n * - Low: `sliceCount` of `1`, `stepCount` of `12`.\n * - Medium: `sliceCount` of `2`, `stepCount` of `8`.\n * - High: `sliceCount` of `3`, `stepCount` of `16`.\n *\n * Use for a higher slice count if you notice temporal instabilities like flickering. Reduce the sample\n * count then to mitigate the performance lost.\n *\n * Without temporal filtering:\n *\n * - Low: `sliceCount` of `2`, `stepCount` of `6`.\n * - Medium: `sliceCount` of `3`, `stepCount` of `8`.\n * - High: `sliceCount` of `4`, `stepCount` of `12`.\n *\n * @augments Node\n * @three_import import { ssgi } from 'three/addons/tsl/display/SSGINode.js';\n */\nclass SSGINode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'SSGINode';\n\n\t}\n\n\t/**\n\t * Constructs a new SSGI node.\n\t *\n\t * @param {TextureNode} beautyNode - A texture node that represents the beauty or scene pass.\n\t * @param {TextureNode} depthNode - A texture node that represents the scene's depth.\n\t * @param {TextureNode} normalNode - A texture node that represents the scene's normals.\n\t * @param {PerspectiveCamera} camera - The camera the scene is rendered with.\n\t */\n\tconstructor( beautyNode, depthNode, normalNode, camera ) {\n\n\t\tsuper( 'vec4' );\n\n\t\t/**\n\t\t * A texture node that represents the beauty or scene pass.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.beautyNode = beautyNode;\n\n\t\t/**\n\t\t * A node that represents the scene's depth.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.depthNode = depthNode;\n\n\t\t/**\n\t\t * A node that represents the scene's normals. If no normals are passed to the\n\t\t * constructor (because MRT is not available), normals can be automatically\n\t\t * reconstructed from depth values in the shader.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.normalNode = normalNode;\n\n\t\t/**\n\t\t * The resolution scale. Values towards `0.5` noticeably increase noise, so it's\n\t\t * recommended to lower the renderer's pixel ratio first. Use this property only\n\t\t * for fine-tuning performance.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 1\n\t\t */\n\t\tthis.resolutionScale = 1;\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders\n\t\t * its effect once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t/**\n\t\t * Number of per-pixel hemisphere slices. This has a big performance cost and should be kept as low as possible.\n\t\t * Should be in the range `[1, 4]`.\n\t\t *\n\t\t * @type {UniformNode<uint>}\n\t\t * @default 1\n\t\t */\n\t\tthis.sliceCount = uniform( 1, 'uint' );\n\n\t\t/**\n\t\t * Number of samples taken along one side of a given hemisphere slice. This has a big performance cost and should\n\t\t * be kept as low as possible. Should be in the range `[1, 32]`.\n\t\t *\n\t\t * @type {UniformNode<uint>}\n\t\t * @default 12\n\t\t */\n\t\tthis.stepCount = uniform( 12, 'uint' );\n\n\t\t/**\n\t\t * Power function applied to AO to make it appear darker/lighter. Should be in the range `[0, 4]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.aoIntensity = uniform( 1, 'float' );\n\n\t\t/**\n\t\t * Intensity of the indirect diffuse light. Should be in the range `[0, 100]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 10\n\t\t */\n\t\tthis.giIntensity = uniform( 10, 'float' );\n\n\t\t/**\n\t\t * Effective sampling radius in world space. AO and GI can only have influence within that radius.\n\t\t * Should be in the range `[1, 25]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 12\n\t\t */\n\t\tthis.radius = uniform( 12, 'float' );\n\n\t\t/**\n\t\t * Makes the sample distance in screen space instead of world-space (helps having more detail up close).\n\t\t *\n\t\t * @type {UniformNode<bool>}\n\t\t * @default true\n\t\t */\n\t\tthis.useScreenSpaceSampling = uniform( true, 'bool' );\n\n\t\t/**\n\t\t * Controls samples distribution. It's an exponent applied at each step get increasing step size over the distance.\n\t\t * Should be in the range `[1, 3]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 2\n\t\t */\n\t\tthis.expFactor = uniform( 2, 'float' );\n\n\t\t/**\n\t\t * Constant thickness value of objects on the screen in world units. Allows light to pass behind surfaces past that thickness value.\n\t\t * Should be in the range `[0.01, 10]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.thickness = uniform( 1, 'float' );\n\n\t\t/**\n\t\t * Whether to increase thickness linearly over distance or not (avoid losing detail over the distance).\n\t\t *\n\t\t * @type {UniformNode<bool>}\n\t\t * @default false\n\t\t */\n\t\tthis.useLinearThickness = uniform( false, 'bool' );\n\n\t\t/**\n\t\t * How much light backface surfaces emit.\n\t\t * Should be in the range `[0, 1]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0\n\t\t */\n\t\tthis.backfaceLighting = uniform( 0, 'float' );\n\n\t\t/**\n\t\t * Whether to use temporal filtering or not. Setting this property to\n\t\t * `true` requires the usage of `TRAANode`. This will help to reduce noise\n\t\t * although it introduces typical TAA artifacts like ghosting and temporal\n\t\t * instabilities.\n\t\t *\n\t\t * If setting this property to `false`, a manual denoise via `DenoiseNode`\n\t\t * is required.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.useTemporalFiltering = true;\n\n\t\t// private uniforms\n\n\t\t/**\n\t\t * The resolution of the effect.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._resolution = uniform( new Vector2() );\n\n\t\t/**\n\t\t * Used to compute the effective step radius when viewSpaceSampling is `false`.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._halfProjScale = uniform( 1 );\n\n\t\t/**\n\t\t * Temporal direction that influences the rotation angle for each slice.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis._temporalDirection = uniform( 0 );\n\n\t\t/**\n\t\t * Temporal offset added to the initial ray step.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis._temporalOffset = uniform( 0 );\n\n\t\t/**\n\t\t * Resolution scale uniform.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis._resolutionScale = uniform( 0 );\n\n\t\t/**\n\t\t * Represents the projection matrix of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraProjectionMatrix = uniform( camera.projectionMatrix );\n\n\t\t/**\n\t\t * Represents the inverse projection matrix of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraProjectionMatrixInverse = uniform( camera.projectionMatrixInverse );\n\n\t\t/**\n\t\t * Represents the near value of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {ReferenceNode<float>}\n\t\t */\n\t\tthis._cameraNear = reference( 'near', 'float', camera );\n\n\t\t/**\n\t\t * Represents the far value of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {ReferenceNode<float>}\n\t\t */\n\t\tthis._cameraFar = reference( 'far', 'float', camera );\n\n\t\t/**\n\t\t * A reference to the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {PerspectiveCamera}\n\t\t */\n\t\tthis._camera = camera;\n\n\t\t/**\n\t\t * The render target the effect is rendered into. The first texture holds the GI,\n\t\t * the second one the AO.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._ssgiRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, count: 2 } );\n\n\t\tconst aoTexture = this._ssgiRenderTarget.textures[ 0 ];\n\t\taoTexture.name = 'SSGI.AO';\n\t\taoTexture.type = UnsignedByteType;\n\t\taoTexture.format = RedFormat;\n\n\t\tconst giTexture = this._ssgiRenderTarget.textures[ 1 ];\n\t\tgiTexture.name = 'SSGI.GI';\n\t\tgiTexture.type = UnsignedInt101111Type;\n\t\tgiTexture.format = RGBFormat;\n\n\t\t/**\n\t\t * The material that is used to render the effect.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._material = new NodeMaterial();\n\t\tthis._material.name = 'SSGI';\n\n\t\t/**\n\t\t * The AO result of the effect is represented as a separate texture node.\n\t\t *\n\t\t * @private\n\t\t * @type {PassTextureNode}\n\t\t */\n\t\tthis._aoNode = passTexture( this, this._ssgiRenderTarget.textures[ 0 ] );\n\n\t\t/**\n\t\t * The GI result of the effect is represented as a separate texture node.\n\t\t *\n\t\t * @private\n\t\t * @type {PassTextureNode}\n\t\t */\n\t\tthis._giNode = passTexture( this, this._ssgiRenderTarget.textures[ 1 ] );\n\n\t}\n\n\t/**\n\t * Returns the AO result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the AO result of the effect.\n\t */\n\tgetAONode() {\n\n\t\treturn this._aoNode;\n\n\t}\n\n\t/**\n\t * Returns the GI result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the GI result of the effect.\n\t */\n\tgetGINode() {\n\n\t\treturn this._giNode;\n\n\t}\n\n\t/**\n\t * Sets the size of the effect.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetSize( width, height ) {\n\n\t\twidth = Math.round( this.resolutionScale * width );\n\t\theight = Math.round( this.resolutionScale * height );\n\n\t\tthis._resolutionScale.value = this.resolutionScale;\n\t\tthis._resolution.value.set( width, height );\n\t\tthis._ssgiRenderTarget.setSize( width, height );\n\n\t\tthis._halfProjScale.value = height / ( Math.tan( this._camera.fov * MathUtils.DEG2RAD * 0.5 ) * 2 ) * 0.5;\n\n\t}\n\n\t/**\n\t * This method is used to render the effect once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore( frame ) {\n\n\t\tconst { renderer } = frame;\n\n\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t//\n\n\t\tconst size = renderer.getDrawingBufferSize( _size );\n\t\tthis.setSize( size.width, size.height );\n\n\t\t// update temporal uniforms\n\n\t\tif ( this.useTemporalFiltering === true ) {\n\n\t\t\tconst frameId = frame.frameId;\n\n\t\t\tthis._temporalDirection.value = _temporalRotations[ frameId % 6 ] / 360;\n\t\t\tthis._temporalOffset.value = _spatialOffsets[ frameId % 4 ];\n\n\t\t} else {\n\n\t\t\tthis._temporalDirection.value = 1;\n\t\t\tthis._temporalOffset.value = 1;\n\n\t\t}\n\n\t\t//\n\n\t\t_quadMesh.material = this._material;\n\t\t_quadMesh.name = 'SSGI';\n\n\t\t// clear (white for the AO attachement)\n\n\t\trenderer.setClearColor( 0xffffff, 1 );\n\n\t\t// gi\n\n\t\trenderer.setRenderTarget( this._ssgiRenderTarget );\n\t\t_quadMesh.render( renderer );\n\n\t\t// restore\n\n\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {PassTextureNode}\n\t */\n\tsetup( builder ) {\n\n\t\tconst renderer = builder.renderer;\n\n\t\tif ( renderer.backend.isWebGPUBackend === true && renderer.hasFeature( 'rg11b10ufloat-renderable' ) === false ) {\n\n\t\t\tconsole.error( 'THREE.SSGINode: The device does not support the \"rg11b10ufloat-renderable\" feature which is required for SSGI.' );\n\n\t\t}\n\n\t\tconst uvNode = uv();\n\t\tconst MAX_RAY = uint( 32 );\n\t\tconst globalOccludedBitfield = uint( 0 );\n\n\t\tconst sampleDepth = ( uv ) => projectionDepth( this.depthNode.sample( uv ).r, this._cameraNear, this._cameraFar );\n\n\t\tconst sampleCenterDepth = ( uv ) => {\n\n\t\t\t// Sidestep the nearest-rounding during depth access for the unjittered center pixel to avoid banding\n\n\t\t\tconst g = this.depthNode.gather().sample( uv );\n\t\t\tconst depth = builder.renderer.reversedDepthBuffer === true ? max( max( g.x, g.y ), max( g.z, g.w ) ) : min( min( g.x, g.y ), min( g.z, g.w ) );\n\n\t\t\treturn projectionDepth( depth, this._cameraNear, this._cameraFar );\n\n\t\t};\n\n\t\tconst sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.sample( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );\n\t\tconst sampleBeauty = ( uv ) => this.beautyNode.sample( uv );\n\n\t\t// From Activision GTAO paper: https://www.activision.com/cdn/research/s2016_pbs_activision_occlusion.pptx\n\n\t\tconst spatialOffsets = Fn( ( [ position ] ) => {\n\n\t\t\treturn float( 0.25 ).mul( sub( position.y, position.x ).bitAnd( 3 ) );\n\n\t\t}, { position: 'vec2', return: 'float' } );\n\n\t\tconst GTAOFastAcos = Fn( ( [ value ] ) => {\n\n\t\t\tconst outVal = abs( value ).mul( float( - 0.156583 ) ).add( HALF_PI );\n\t\t\toutVal.mulAssign( sqrt( abs( value ).oneMinus() ) );\n\n\t\t\tconst x = value.x.greaterThanEqual( 0 ).select( outVal.x, PI.sub( outVal.x ) );\n\t\t\tconst y = value.y.greaterThanEqual( 0 ).select( outVal.y, PI.sub( outVal.y ) );\n\n\t\t\treturn vec2( x, y );\n\n\t\t}, { value: 'vec2', return: 'vec2' } );\n\n\t\tconst horizonSampling = Fn( ( [ directionIsRight, stepRadius, radiusVS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ] ) => {\n\n\t\t\tconst STEP_COUNT = this.stepCount.toConst();\n\t\t\tconst EXP_FACTOR = this.expFactor.toConst();\n\t\t\tconst THICKNESS = this.thickness.toConst();\n\t\t\tconst BACKFACE_LIGHTING = this.backfaceLighting.toConst();\n\n\t\t\tconst uvDirection = directionIsRight.select( vec2( 1, - 1 ), vec2( - 1, 1 ) ); // Port note: Because of different uv conventions, uv-y has a different sign\n\t\t\tconst samplingDirection = directionIsRight.select( 1, - 1 );\n\n\t\t\tconst color = vec3( 0 );\n\n\t\t\tLoop( { start: uint( 0 ), end: STEP_COUNT, type: 'uint', condition: '<' }, ( { i } ) => {\n\n\t\t\t\tconst offset = pow( abs( mul( stepRadius, float( i ).add( initialRayStep ) ).div( radiusVS ) ), EXP_FACTOR ).mul( radiusVS ).toConst();\n\t\t\t\tconst uvOffset = slideDirTexelSize.mul( max( offset, float( i ).add( 1 ) ) ).toConst();\n\t\t\t\tconst sampleUV = uvNode.add( uvOffset.mul( uvDirection ) ).toConst();\n\n\t\t\t\tIf( sampleUV.x.lessThanEqual( 0 ).or( sampleUV.y.lessThanEqual( 0 ) ).or( sampleUV.x.greaterThanEqual( 1 ) ).or( sampleUV.y.greaterThanEqual( 1 ) ), () => {\n\n\t\t\t\t\tBreak();\n\n\t\t\t\t} );\n\n\t\t\t\tconst sampleViewPosition = getViewPosition( sampleUV, sampleDepth( sampleUV ), this._cameraProjectionMatrixInverse ).toConst();\n\t\t\t\tconst pixelToSample = sampleViewPosition.sub( viewPosition ).normalize().toConst();\n\t\t\t\tconst linearThicknessMultiplier = this.useLinearThickness.select( sampleViewPosition.z.negate().div( this._cameraFar ).clamp().mul( 100 ), float( 1 ) );\n\t\t\t\tconst pixelToSampleBackface = normalize( sampleViewPosition.sub( linearThicknessMultiplier.mul( viewDir ).mul( THICKNESS ) ).sub( viewPosition ) );\n\n\t\t\t\tlet frontBackHorizon = vec2( dot( pixelToSample, viewDir ), dot( pixelToSampleBackface, viewDir ) );\n\t\t\t\tfrontBackHorizon = GTAOFastAcos( clamp( frontBackHorizon, - 1, 1 ) );\n\t\t\t\tfrontBackHorizon = clamp( div( mul( samplingDirection, frontBackHorizon.negate() ).sub( n.sub( HALF_PI ) ), PI ) ); // Port note: subtract half pi instead of adding it\n\t\t\t\tfrontBackHorizon = directionIsRight.select( frontBackHorizon.yx, frontBackHorizon.xy ); // Front/Back get inverted depending on angle\n\n\t\t\t\t// inline ComputeOccludedBitfield() for easier debugging\n\n\t\t\t\tconst minHorizon = frontBackHorizon.x.toConst();\n\t\t\t\tconst maxHorizon = frontBackHorizon.y.toConst();\n\n\t\t\t\tconst startHorizonInt = uint( frontBackHorizon.mul( float( MAX_RAY ) ) ).toConst();\n\t\t\t\tconst angleHorizonInt = uint( ceil( maxHorizon.sub( minHorizon ).mul( float( MAX_RAY ) ) ) ).toConst();\n\t\t\t\tconst angleHorizonBitfield = angleHorizonInt.greaterThan( uint( 0 ) ).select( uint( shiftRight( uint( 0xFFFFFFFF ), uint( 32 ).sub( MAX_RAY ).add( MAX_RAY.sub( angleHorizonInt ) ) ) ), uint( 0 ) ).toConst();\n\t\t\t\tlet currentOccludedBitfield = angleHorizonBitfield.shiftLeft( startHorizonInt );\n\t\t\t\tcurrentOccludedBitfield = currentOccludedBitfield.bitAnd( globalOccludedBitfield.bitNot() );\n\n\t\t\t\tglobalOccludedBitfield.assign( globalOccludedBitfield.bitOr( currentOccludedBitfield ) );\n\t\t\t\tconst numOccludedZones = countOneBits( currentOccludedBitfield );\n\n\t\t\t\t//\n\n\t\t\t\tIf( numOccludedZones.greaterThan( 0 ), () => { // If a ray hit the sample, that sample is visible from shading point\n\n\t\t\t\t\tconst lightColor = sampleBeauty( sampleUV );\n\n\t\t\t\t\tIf( luminance( lightColor ).greaterThan( 0.001 ), () => { // Continue if there is light at that location (intensity > 0)\n\n\t\t\t\t\t\tconst lightDirectionVS = normalize( pixelToSample );\n\t\t\t\t\t\tconst normalDotLightDirection = clamp( dot( viewNormal, lightDirectionVS ) );\n\n\t\t\t\t\t\tIf( normalDotLightDirection.greaterThan( 0.001 ), () => { // Continue if light is facing surface normal\n\n\t\t\t\t\t\t\tconst lightNormalVS = sampleNormal( sampleUV );\n\n\t\t\t\t\t\t\t// Intensity of outgoing light in the direction of the shading point\n\n\t\t\t\t\t\t\tlet lightNormalDotLightDirection = dot( lightNormalVS, lightDirectionVS.negate() );\n\n\t\t\t\t\t\t\tconst d = sign( lightNormalDotLightDirection ).lessThan( 0 ).select( abs( lightNormalDotLightDirection ).mul( BACKFACE_LIGHTING ), abs( lightNormalDotLightDirection ) );\n\t\t\t\t\t\t\tlightNormalDotLightDirection = BACKFACE_LIGHTING.greaterThan( 0 ).and( dot( lightNormalVS, viewDir ).greaterThan( 0 ) ).select( d, clamp( lightNormalDotLightDirection ) );\n\n\t\t\t\t\t\t\tcolor.rgb.addAssign( float( numOccludedZones ).div( float( MAX_RAY ) ).mul( lightColor ).mul( normalDotLightDirection ).mul( lightNormalDotLightDirection ) );\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} );\n\n\t\t\t\t} );\n\n\t\t\t} );\n\n\t\t\treturn color;\n\n\t\t} );\n\n\t\tconst aoField = property( 'float' );\n\t\tconst giField = property( 'vec3' );\n\n\t\tconst outputNode = outputStruct( aoField, giField );\n\n\t\tconst gi = Fn( () => {\n\n\t\t\tconst depth = this._resolutionScale.lessThan( 1 ).select( sampleCenterDepth( uvNode ), sampleDepth( uvNode ) ).toConst();\n\n\t\t\tisBackgroundDepth( depth ).discard();\n\n\t\t\tconst viewPosition = getViewPosition( uvNode, depth, this._cameraProjectionMatrixInverse ).toVar();\n\t\t\tconst viewNormal = sampleNormal( uvNode ).toVar();\n\t\t\tconst viewDir = normalize( viewPosition.xyz.negate() ).toVar();\n\n\t\t\t//\n\n\t\t\tconst noiseOffset = spatialOffsets( screenCoordinate );\n\t\t\tconst noiseDirection = interleavedGradientNoise( screenCoordinate );\n\t\t\tconst noiseJitterIdx = this._temporalDirection.mul( 0.02 ); // Port: Add noiseJitterIdx here for slightly better noise convergence with TRAA (see #31890 for more details)\n\t\t\tconst initialRayStep = fract( noiseOffset.add( this._temporalOffset ) ).add( rand( uvNode.add( noiseJitterIdx ).mul( 2 ).sub( 1 ) ) );\n\n\t\t\tconst ao = float( 0 );\n\t\t\tconst color = vec3( 0 );\n\n\t\t\tconst ROTATION_COUNT = this.sliceCount.toConst();\n\t\t\tconst STEP_COUNT = this.stepCount.toConst();\n\t\t\tconst AO_INTENSITY = this.aoIntensity.toConst();\n\t\t\tconst GI_INTENSITY = this.giIntensity.toConst();\n\t\t\tconst RADIUS = this.radius.toConst();\n\n\t\t\tconst stepRadius = float( 0 ).toVar();\n\n\t\t\tIf( this.useScreenSpaceSampling, () => {\n\n\t\t\t\tstepRadius.assign( RADIUS.mul( this._resolution.x.div( 2 ) ).div( float( 16 ) ) ); // SSRT3 has a bug where stepRadius is divided by STEP_COUNT twice; fix here\n\n\t\t\t} ).Else( () => {\n\n\t\t\t\tstepRadius.assign( max( RADIUS.mul( this._halfProjScale ).div( viewPosition.z.negate() ), float( STEP_COUNT ) ) ); // Port note: viewZ is negative so a negate is required\n\n\t\t\t} );\n\n\t\t\tstepRadius.divAssign( float( STEP_COUNT ).add( 1 ) );\n\t\t\tconst radiusVS = max( 1, float( STEP_COUNT.sub( 1 ) ) ).mul( stepRadius ).toConst();\n\n\t\t\t//\n\n\t\t\tLoop( { start: uint( 0 ), end: ROTATION_COUNT, type: 'uint', condition: '<' }, ( { i } ) => {\n\n\t\t\t\tconst rotationAngle = mul( float( i ).add( noiseDirection ).add( this._temporalDirection ), PI.div( float( ROTATION_COUNT ) ) ).toConst();\n\t\t\t\tconst sliceDir = vec3( vec2( cos( rotationAngle ), sin( rotationAngle ) ), 0 ).toConst();\n\t\t\t\tconst slideDirTexelSize = sliceDir.xy.mul( float( 1 ).div( this._resolution ) ).toConst();\n\n\t\t\t\tconst planeNormal = normalize( cross( sliceDir, viewDir ) ).toConst();\n\t\t\t\tconst tangent = cross( viewDir, planeNormal ).toConst();\n\t\t\t\tconst projectedNormal = viewNormal.sub( planeNormal.mul( dot( viewNormal, planeNormal ) ) ).toConst();\n\t\t\t\tconst projectedNormalNormalized = normalize( projectedNormal ).toConst();\n\n\t\t\t\tconst cos_n = clamp( dot( projectedNormalNormalized, viewDir ), - 1, 1 ).toConst();\n\t\t\t\tconst n = sign( dot( projectedNormal, tangent ) ).negate().mul( acos( cos_n ) ).toConst();\n\n\t\t\t\tglobalOccludedBitfield.assign( 0 );\n\n\t\t\t\tcolor.addAssign( horizonSampling( bool( true ), stepRadius, radiusVS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ) );\n\t\t\t\tcolor.addAssign( horizonSampling( bool( false ), stepRadius, radiusVS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ) );\n\n\t\t\t\tao.addAssign( float( countOneBits( globalOccludedBitfield ) ).div( float( MAX_RAY ) ) );\n\n\t\t\t} );\n\n\t\t\tao.divAssign( float( ROTATION_COUNT ) );\n\t\t\tao.assign( pow( ao.clamp().oneMinus(), AO_INTENSITY ).clamp() );\n\n\t\t\tcolor.divAssign( float( ROTATION_COUNT ) );\n\t\t\tcolor.mulAssign( GI_INTENSITY );\n\n\t\t\t// scale color based on luminance\n\n\t\t\tconst maxLuminance = float( 7 ).toConst(); // 7 represent a HDR luminance value\n\t\t\tconst currentLuminance = luminance( color );\n\n\t\t\tconst scale = currentLuminance.greaterThan( maxLuminance ).select( maxLuminance.div( currentLuminance ), float( 1 ) );\n\t\t\tcolor.mulAssign( scale );\n\n\t\t\taoField.assign( ao );\n\t\t\tgiField.assign( color );\n\n\t\t\treturn vec4( 0 );\n\n\t\t} );\n\n\t\tthis._material.contextNode = context( builder.getSharedContext() );\n\t\tthis._material.colorNode = gi();\n\t\tthis._material.outputNode = outputNode;\n\t\tthis._material.needsUpdate = true;\n\n\t\t//\n\n\t\treturn this._aoNode;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis._ssgiRenderTarget.dispose();\n\n\t\tthis._material.dispose();\n\n\t}\n\n}\n\nexport default SSGINode;\n\n/**\n * TSL function for creating a SSGI effect.\n *\n * @tsl\n * @function\n * @param {TextureNode} beautyNode - The texture node that represents the input of the effect.\n * @param {TextureNode} depthNode - A texture node that represents the scene's depth.\n * @param {TextureNode} normalNode - A texture node that represents the scene's normals.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @returns {SSGINode}\n */\nexport const ssgi = ( beautyNode, depthNode, normalNode, camera ) => new SSGINode( convertToTexture( beautyNode ), depthNode, normalNode, camera );\n","import { DataTexture, RepeatWrapping, Vector2, Vector3, Node } from 'three/webgpu';\nimport { texture, getNormalFromDepth, getViewPosition, convertToTexture, nodeObject, Fn, float, NodeUpdateType, uv, uniform, Loop, luminance, vec2, vec3, vec4, uniformArray, int, dot, max, pow, abs, If, textureSize, sin, cos, mat2, PI, property, isBackgroundDepth } from 'three/tsl';\nimport { SimplexNoise } from '../../math/SimplexNoise.js';\n\n/**\n * Post processing node for denoising data like raw screen-space ambient occlusion output.\n * Denoise can noticeably improve the quality of ambient occlusion but also add quite some\n * overhead to the post processing setup. It's best to make its usage optional (e.g. via\n * graphic settings).\n *\n * Reference: {@link https://openaccess.thecvf.com/content/WACV2021/papers/Khademi_Self-Supervised_Poisson-Gaussian_Denoising_WACV_2021_paper.pdf}.\n *\n * @augments Node\n * @three_import import { denoise } from 'three/addons/tsl/display/DenoiseNode.js';\n */\nclass DenoiseNode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'DenoiseNode';\n\n\t}\n\n\t/**\n\t * Constructs a new denoise node.\n\t *\n\t * @param {TextureNode} textureNode - The texture node that represents the input of the effect (e.g. AO).\n\t * @param {Node<float>} depthNode - A node that represents the scene's depth.\n\t * @param {?Node<vec3>} normalNode - A node that represents the scene's normals.\n\t * @param {Camera} camera - The camera the scene is rendered with.\n\t */\n\tconstructor( textureNode, depthNode, normalNode, camera ) {\n\n\t\tsuper( 'vec4' );\n\n\t\t/**\n\t\t * The texture node that represents the input of the effect (e.g. AO).\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.textureNode = textureNode;\n\n\t\t/**\n\t\t * A node that represents the scene's depth.\n\t\t *\n\t\t * @type {Node<float>}\n\t\t */\n\t\tthis.depthNode = depthNode;\n\n\t\t/**\n\t\t * A node that represents the scene's normals. If no normals are passed to the\n\t\t * constructor (because MRT is not available), normals can be automatically\n\t\t * reconstructed from depth values in the shader.\n\t\t *\n\t\t * @type {?Node<vec3>}\n\t\t */\n\t\tthis.normalNode = normalNode;\n\n\t\t/**\n\t\t * The internal noise texture.\n\t\t *\n\t\t * @private\n\t\t * @type {DataTexture}\n\t\t */\n\t\tthis._noiseTexture = generateDefaultNoise();\n\n\t\t/**\n\t\t * The node represents the internal noise texture.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.noiseNode = texture( this._noiseTexture );\n\n\t\t/**\n\t\t * The luma Phi value.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.lumaPhi = uniform( 5 );\n\n\t\t/**\n\t\t * The depth Phi value.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.depthPhi = uniform( 5 );\n\n\t\t/**\n\t\t * The normal Phi value.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.normalPhi = uniform( 5 );\n\n\t\t/**\n\t\t * The radius.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.radius = uniform( 5 );\n\n\t\t/**\n\t\t * The index.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.index = uniform( 0 );\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node updates\n\t\t * its internal uniforms once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t/**\n\t\t * The resolution of the effect.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._resolution = uniform( new Vector2() );\n\n\t\t/**\n\t\t * An array of sample vectors.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformArrayNode<vec3>}\n\t\t */\n\t\tthis._sampleVectors = uniformArray( generateDenoiseSamples( 16, 2, 1 ) );\n\n\t\t/**\n\t\t * Represents the inverse projection matrix of the scene's camera.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraProjectionMatrixInverse = uniform( camera.projectionMatrixInverse );\n\n\t}\n\n\t/**\n\t * This method is used to update internal uniforms once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore() {\n\n\t\tconst map = this.textureNode.value;\n\n\t\tthis._resolution.value.set( map.image.width, map.image.height );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {ShaderCallNodeInternal}\n\t */\n\tsetup( /* builder */ ) {\n\n\t\tconst uvNode = uv();\n\n\t\tconst sampleTexture = ( uv ) => this.textureNode.sample( uv );\n\t\tconst sampleDepth = ( uv ) => this.depthNode.sample( uv ).x;\n\t\tconst sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.sample( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );\n\t\tconst sampleNoise = ( uv ) => this.noiseNode.sample( uv );\n\n\t\tconst denoiseSample = Fn( ( [ center, viewNormal, viewPosition, sampleUv ] ) => {\n\n\t\t\tconst texel = sampleTexture( sampleUv ).toVar();\n\t\t\tconst depth = sampleDepth( sampleUv ).toVar();\n\t\t\tconst normal = sampleNormal( sampleUv ).toVar();\n\t\t\tconst neighborColor = texel.rgb;\n\t\t\tconst viewPos = getViewPosition( sampleUv, depth, this._cameraProjectionMatrixInverse ).toVar();\n\n\t\t\tconst normalDiff = dot( viewNormal, normal ).toVar();\n\t\t\tconst normalSimilarity = pow( max( normalDiff, 0 ), this.normalPhi ).toVar();\n\t\t\tconst lumaDiff = abs( luminance( neighborColor ).sub( luminance( center ) ) ).toVar();\n\t\t\tconst lumaSimilarity = max( float( 1.0 ).sub( lumaDiff.div( this.lumaPhi ) ), 0 ).toVar();\n\t\t\tconst depthDiff = abs( dot( viewPosition.sub( viewPos ), viewNormal ) ).toVar();\n\t\t\tconst depthSimilarity = max( float( 1.0 ).sub( depthDiff.div( this.depthPhi ) ), 0 );\n\t\t\tconst w = lumaSimilarity.mul( depthSimilarity ).mul( normalSimilarity );\n\n\t\t\treturn vec4( neighborColor.mul( w ), w );\n\n\t\t} );\n\n\t\tconst denoise = Fn( ( [ uvNode ] ) => {\n\n\t\t\tconst depth = sampleDepth( uvNode ).toVar();\n\t\t\tconst viewNormal = sampleNormal( uvNode ).toVar();\n\n\t\t\tconst texel = sampleTexture( uvNode ).toVar();\n\t\t\tconst result = property( 'vec4' );\n\n\t\t\tIf( isBackgroundDepth( depth ).or( dot( viewNormal, viewNormal ).equal( 0.0 ) ), () => {\n\n\t\t\t\tresult.assign( texel );\n\n\t\t\t} ).Else( () => {\n\n\t\t\t\tconst center = vec3( texel.rgb );\n\n\t\t\t\tconst viewPosition = getViewPosition( uvNode, depth, this._cameraProjectionMatrixInverse ).toConst();\n\n\t\t\t\tconst noiseResolution = textureSize( this.noiseNode, 0 );\n\t\t\t\tlet noiseUv = vec2( uvNode.x, uvNode.y.oneMinus() );\n\t\t\t\tnoiseUv = noiseUv.mul( this._resolution.div( noiseResolution ) );\n\t\t\t\tconst noiseTexel = sampleNoise( noiseUv ).toVar();\n\n\t\t\t\tconst x = sin( noiseTexel.element( this.index.mod( 4 ).mul( 2 ).mul( PI ) ) );\n\t\t\t\tconst y = cos( noiseTexel.element( this.index.mod( 4 ).mul( 2 ).mul( PI ) ) );\n\n\t\t\t\tconst noiseVec = vec2( x, y );\n\t\t\t\tconst rotationMatrix = mat2( noiseVec.x, noiseVec.y.negate(), noiseVec.x, noiseVec.y );\n\n\t\t\t\tconst totalWeight = float( 1.0 ).toVar();\n\t\t\t\tconst denoised = vec3( texel.rgb ).toVar();\n\n\t\t\t\tLoop( { start: int( 0 ), end: int( 16 ), type: 'int', condition: '<' }, ( { i } ) => {\n\n\t\t\t\t\tconst sampleDir = this._sampleVectors.element( i );\n\t\t\t\t\tconst offset = rotationMatrix.mul( sampleDir.xy.mul( float( 1.0 ).add( sampleDir.z.mul( this.radius.sub( 1 ) ) ) ) ).div( this._resolution );\n\t\t\t\t\tconst sampleUv = uvNode.add( offset );\n\n\t\t\t\t\tconst sampleResult = denoiseSample( center, viewNormal, viewPosition, sampleUv );\n\n\t\t\t\t\tdenoised.addAssign( sampleResult.xyz );\n\t\t\t\t\ttotalWeight.addAssign( sampleResult.w );\n\n\t\t\t\t} );\n\n\t\t\t\tIf( totalWeight.greaterThan( float( 0 ) ), () => {\n\n\t\t\t\t\tdenoised.divAssign( totalWeight );\n\n\t\t\t\t} );\n\n\t\t\t\tresult.assign( vec4( denoised, texel.a ) );\n\n\t\t\t} );\n\n\t\t\treturn result;\n\n\t\t}/*, { uv: 'vec2', return: 'vec4' }*/ );\n\n\t\tconst output = Fn( () => {\n\n\t\t\treturn denoise( uvNode );\n\n\t\t} );\n\n\t\tconst outputNode = output();\n\n\t\treturn outputNode;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis._noiseTexture.dispose();\n\n\t}\n\n}\n\nexport default DenoiseNode;\n\n/**\n * Generates denoise samples based on the given parameters.\n *\n * @private\n * @param {number} numSamples - The number of samples.\n * @param {number} numRings - The number of rings.\n * @param {number} radiusExponent - The radius exponent.\n * @return {Array<Vector3>} The denoise samples.\n */\nfunction generateDenoiseSamples( numSamples, numRings, radiusExponent ) {\n\n\tconst samples = [];\n\n\tfor ( let i = 0; i < numSamples; i ++ ) {\n\n\t\tconst angle = 2 * Math.PI * numRings * i / numSamples;\n\t\tconst radius = Math.pow( i / ( numSamples - 1 ), radiusExponent );\n\t\tsamples.push( new Vector3( Math.cos( angle ), Math.sin( angle ), radius ) );\n\n\t}\n\n\treturn samples;\n\n}\n\n/**\n * Generates a default noise texture for the given size.\n *\n * @private\n * @param {number} [size=64] - The texture size.\n * @return {DataTexture} The generated noise texture.\n */\nfunction generateDefaultNoise( size = 64 ) {\n\n\tconst simplex = new SimplexNoise();\n\n\tconst arraySize = size * size * 4;\n\tconst data = new Uint8Array( arraySize );\n\n\tfor ( let i = 0; i < size; i ++ ) {\n\n\t\tfor ( let j = 0; j < size; j ++ ) {\n\n\t\t\tconst x = i;\n\t\t\tconst y = j;\n\n\t\t\tdata[ ( i * size + j ) * 4 ] = ( simplex.noise( x, y ) * 0.5 + 0.5 ) * 255;\n\t\t\tdata[ ( i * size + j ) * 4 + 1 ] = ( simplex.noise( x + size, y ) * 0.5 + 0.5 ) * 255;\n\t\t\tdata[ ( i * size + j ) * 4 + 2 ] = ( simplex.noise( x, y + size ) * 0.5 + 0.5 ) * 255;\n\t\t\tdata[ ( i * size + j ) * 4 + 3 ] = ( simplex.noise( x + size, y + size ) * 0.5 + 0.5 ) * 255;\n\n\t\t}\n\n\t}\n\n\tconst noiseTexture = new DataTexture( data, size, size );\n\tnoiseTexture.wrapS = RepeatWrapping;\n\tnoiseTexture.wrapT = RepeatWrapping;\n\tnoiseTexture.needsUpdate = true;\n\n\treturn noiseTexture;\n\n}\n\n/**\n * TSL function for creating a denoise effect.\n *\n * @tsl\n * @function\n * @param {Node} node - The node that represents the input of the effect (e.g. AO).\n * @param {Node<float>} depthNode - A node that represents the scene's depth.\n * @param {?Node<vec3>} normalNode - A node that represents the scene's normals.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @returns {DenoiseNode}\n */\nexport const denoise = ( node, depthNode, normalNode, camera ) => new DenoiseNode( convertToTexture( node ), nodeObject( depthNode ), nodeObject( normalNode ), camera );\n","import { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { Camera, Scene } from 'three';\nimport { PerspectiveCamera } from 'three';\nimport type { Node, UniformNode } from 'three/webgpu';\nimport type { PassNode } from 'three/webgpu';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\nimport { add, unpackRGBToNormal, sample, vec3, vec4, uniform } from 'three/tsl';\nimport { ssgi } from 'three/addons/tsl/display/SSGINode.js';\nimport { denoise } from 'three/addons/tsl/display/DenoiseNode.js';\n\nexport interface SsgiPassParameters {\n sliceCount: number;\n stepCount: number;\n radius: number;\n expFactor: number;\n thickness: number;\n backfaceLighting: number;\n aoIntensity: number;\n giIntensity: number;\n aoDenoiseRadius: number;\n giDenoiseRadius: number;\n useLinearThickness: boolean;\n useScreenSpaceSampling: boolean;\n useTemporalFiltering: boolean;\n}\n\nexport interface SsgiPerformanceParameters {\n sliceCount: number;\n stepCount: number;\n}\n\nexport class SsgiRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'SsgiRenderPass';\n override readonly passId = SsgiRenderPass.passId;\n private readonly sliceCount: UniformNode<'uint', number>;\n private readonly stepCount: UniformNode<'uint', number>;\n private readonly radius: UniformNode<'float', number>;\n private readonly expFactor: UniformNode<'float', number>;\n private readonly thickness: UniformNode<'float', number>;\n private readonly backfaceLighting: UniformNode<'float', number>;\n private readonly aoIntensity: UniformNode<'float', number>;\n private readonly giIntensity: UniformNode<'float', number>;\n private readonly useLinearThickness: UniformNode<'bool', boolean>;\n private readonly useScreenSpaceSampling: UniformNode<'bool', boolean>;\n private readonly giDenoiseRadius: UniformNode<'float', number>;\n private readonly aoDenoiseRadius: UniformNode<'float', number>;\n private readonly useTemporalFiltering: boolean;\n\n constructor(params: SsgiPassParameters) {\n super();\n this.sliceCount = uniform(params.sliceCount, 'uint');\n this.stepCount = uniform(params.stepCount, 'uint');\n this.radius = uniform(params.radius);\n this.expFactor = uniform(params.expFactor);\n this.thickness = uniform(params.thickness);\n this.backfaceLighting = uniform(params.backfaceLighting);\n this.aoIntensity = uniform(params.aoIntensity);\n this.giIntensity = uniform(params.giIntensity);\n this.useLinearThickness = uniform(params.useLinearThickness);\n this.useScreenSpaceSampling = uniform(params.useScreenSpaceSampling);\n this.giDenoiseRadius = uniform(params.giDenoiseRadius);\n this.aoDenoiseRadius = uniform(params.aoDenoiseRadius);\n this.useTemporalFiltering = params.useTemporalFiltering;\n }\n\n public updatePerformanceParameters(params: SsgiPerformanceParameters): void {\n this.sliceCount.value = params.sliceCount;\n this.stepCount.value = params.stepCount;\n }\n\n override addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const gui = renderPassSettings.addFolder('SSGI Settings');\n gui\n .add(this.sliceCount, 'value', 1, 4, 1)\n .name('slice count')\n .onChange(() => updateCallback());\n gui\n .add(this.stepCount, 'value', 1, 32, 1)\n .name('step count')\n .onChange(() => updateCallback());\n gui\n .add(this.radius, 'value', 1, 25)\n .name('radius')\n .onChange(() => updateCallback());\n gui\n .add(this.expFactor, 'value', 1, 3)\n .name('exp factor')\n .onChange(() => updateCallback());\n gui\n .add(this.thickness, 'value', 0.01, 10)\n .name('thickness')\n .onChange(() => updateCallback());\n gui\n .add(this.backfaceLighting, 'value', 0, 1)\n .name('backface lighting')\n .onChange(() => updateCallback());\n gui\n .add(this.aoIntensity, 'value', 0, 4)\n .name('AO intensity')\n .onChange(() => updateCallback());\n gui\n .add(this.giIntensity, 'value', 0, 100)\n .name('GI intensity')\n .onChange(() => updateCallback());\n gui\n .add(this.useLinearThickness, 'value')\n .name('use linear thickness')\n .onChange(() => updateCallback());\n gui\n .add(this.useScreenSpaceSampling, 'value')\n .name('use screen-space sampling')\n .onChange(() => updateCallback());\n gui\n .add(this.aoDenoiseRadius, 'value', 0, 20)\n .name('AO denoise radius')\n .onChange(() => updateCallback());\n gui\n .add(this.giDenoiseRadius, 'value', 0, 20)\n .name('GI denoise radius')\n .onChange(() => updateCallback());\n }\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n _scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n if (!(camera instanceof PerspectiveCamera)) {\n return currentNode; // no ssgi for orthographic camera\n }\n if (this.sliceCount.value === 0 || this.stepCount.value === 0) {\n return currentNode; // SSGINode does division by these values\n }\n\n const scenePassColor = basePassNode.getTextureNode('output');\n const scenePassDiffuse = basePassNode.getTextureNode('diffuseColor');\n const scenePassDepth = basePassNode.getTextureNode('depth');\n const scenePassNormal = basePassNode.getTextureNode('normal');\n\n const sceneNormal = sample((uv) => {\n return unpackRGBToNormal(scenePassNormal.sample(uv));\n });\n\n const giPass = ssgi(scenePassColor, scenePassDepth, sceneNormal, camera);\n giPass.sliceCount = this.sliceCount;\n giPass.stepCount = this.stepCount;\n giPass.radius = this.radius;\n giPass.expFactor = this.expFactor;\n giPass.thickness = this.thickness;\n giPass.backfaceLighting = this.backfaceLighting;\n giPass.aoIntensity = this.aoIntensity;\n giPass.giIntensity = this.giIntensity;\n giPass.useLinearThickness = this.useLinearThickness;\n giPass.useScreenSpaceSampling = this.useScreenSpaceSampling;\n giPass.useTemporalFiltering = this.useTemporalFiltering;\n\n let gi = giPass.getGINode().toInspector('SSGI / GI');\n let ao = giPass.getAONode().toInspector('SSGI / AO');\n const denoisedGI = denoise(\n gi,\n scenePassDepth,\n sceneNormal,\n camera,\n ).toInspector('SSGI / GI Denoised');\n denoisedGI.radius = this.giDenoiseRadius;\n const denoisedAO = denoise(\n ao,\n scenePassDepth,\n sceneNormal,\n camera,\n ).toInspector('SSGI / AO Denoised');\n denoisedAO.radius = this.aoDenoiseRadius;\n\n const compositePass = vec4(\n add(\n // @ts-ignore -- three-types messed this one up, works fine but shows an error\n scenePassColor.rgb.mul(denoisedAO.r),\n // @ts-ignore -- three-types messed this one up, works fine but shows an error\n scenePassDiffuse.rgb.mul(denoisedGI.rgb),\n ),\n scenePassColor.a,\n );\n compositePass.name = 'Ssgi Composite';\n\n if (debugMode === 'ao only') {\n return vec4(vec3(ao.r), 1);\n } else if (debugMode === 'gi only') {\n return vec4(gi.rgb, 1);\n } else if (debugMode === 'denoised ao only') {\n // @ts-ignore -- three-types messed this one up, works fine but shows an error\n return vec4(vec3(denoisedAO.r), 1);\n } else if (debugMode === 'denoised gi only') {\n // @ts-ignore -- three-types messed this one up, works fine but shows an error\n return vec4(denoisedGI.rgb, 1);\n } else if (debugMode === 'without denoise') {\n return vec4(\n add(scenePassColor.rgb.mul(ao.r), scenePassDiffuse.rgb.mul(gi.rgb)),\n scenePassColor.a,\n );\n }\n\n return compositePass;\n }\n}\n","import { add, float, Fn, If, luminance, max, struct, vec2, vec4, getViewPosition, logarithmicDepthToViewZ, viewZToOrthographicDepth, viewZToPerspectiveDepth } from 'three/tsl';\n\n/**\n * Optimized version of AABB clipping.\n *\n * Reference: {@link https://github.com/playdeadgames/temporal}\n *\n * @tsl\n * @private\n * @function\n * @param {Node<vec4>} currentColor - The current color.\n * @param {Node<vec4>} historyColor - The history color.\n * @param {Node<vec4>} minColor - The minimum color of the AABB.\n * @param {Node<vec4>} maxColor - The maximum color of the AABB.\n * @return {Node<vec4>} The clipped history color.\n */\nexport const clipAABB = Fn( ( [ currentColor, historyColor, minColor, maxColor ] ) => {\n\n\tconst pClip = maxColor.rgb.add( minColor.rgb ).mul( 0.5 ).toConst();\n\tconst eClip = maxColor.rgb.sub( minColor.rgb ).mul( 0.5 ).add( 1e-7 ).toConst();\n\tconst vClip = historyColor.sub( vec4( pClip, currentColor.a ) ).toConst();\n\tconst vUnit = vClip.xyz.div( eClip ).toConst();\n\tconst absUnit = vUnit.abs().toConst();\n\tconst maxUnit = max( absUnit.x, absUnit.y, absUnit.z ).toConst();\n\treturn maxUnit.greaterThan( 1 ).select(\n\t\tvec4( pClip, currentColor.a ).add( vClip.div( maxUnit ) ),\n\t\thistoryColor\n\t);\n\n}, {\n\tcurrentColor: 'vec4',\n\thistoryColor: 'vec4',\n\tminColor: 'vec4',\n\tmaxColor: 'vec4',\n\treturn: 'vec4'\n} );\n\n/**\n * Blends the current and history color with a flicker reduction based on luminance weighing.\n *\n * @tsl\n * @private\n * @function\n * @param {Node<vec4>} currentColor - The current color.\n * @param {Node<vec4>} historyColor - The history color.\n * @param {Node<float>} currentWeight - The weight of the current color.\n * @return {Node<vec4>} The blended color.\n */\nexport const flickerReduction = Fn( ( [ currentColor, historyColor, currentWeight ] ) => {\n\n\tconst compressedCurrent = currentColor.mul( float( 1 ).div( ( max( currentColor.r, currentColor.g, currentColor.b ).add( 1 ) ) ) ).toConst();\n\tconst compressedHistory = historyColor.mul( float( 1 ).div( ( max( historyColor.r, historyColor.g, historyColor.b ).add( 1 ) ) ) ).toConst();\n\n\tconst luminanceCurrent = luminance( compressedCurrent.rgb ).toConst();\n\tconst luminanceHistory = luminance( compressedHistory.rgb ).toConst();\n\n\tconst weightCurrent = currentWeight.div( luminanceCurrent.add( 1 ) ).toConst();\n\tconst weightHistory = currentWeight.oneMinus().div( luminanceHistory.add( 1 ) ).toConst();\n\n\treturn add( currentColor.mul( weightCurrent ), historyColor.mul( weightHistory ) ).div( max( weightCurrent.add( weightHistory ), 0.00001 ) );\n\n} );\n\n/**\n * Samples the 3×3 neighborhood of the given texel position in the depth buffer and returns\n * the closest depth, its texel position and the farthest depth. Reversed and logarithmic depth\n * values are converted to perspective depth.\n *\n * @tsl\n * @private\n * @function\n * @param {TextureNode} depthNode - The depth buffer.\n * @param {Node<vec2>} positionTexel - The texel position.\n * @param {Node<vec2>} cameraNearFar - The camera's near and far.\n * @return {Node<struct>} A struct with the members `closestDepth`, `closestPositionTexel` and `farthestDepth`.\n */\nexport const sampleCurrentDepth = Fn( ( [ depthNode, positionTexel, cameraNearFar ], builder ) => {\n\n\tconst closestDepth = float( 2 ).toVar();\n\tconst closestPositionTexel = vec2( 0 ).toVar();\n\tconst farthestDepth = float( - 1 ).toVar();\n\n\tfor ( let x = - 1; x <= 1; ++ x ) {\n\n\t\tfor ( let y = - 1; y <= 1; ++ y ) {\n\n\t\t\tconst neighbor = positionTexel.add( vec2( x, y ) ).toVar();\n\t\t\tlet depth = depthNode.load( neighbor ).r;\n\t\t\tif ( builder.renderer.reversedDepthBuffer ) depth = depth.oneMinus();\n\t\t\tif ( builder.renderer.logarithmicDepthBuffer ) depth = logarithmicToPerspectiveDepth( depth, cameraNearFar );\n\t\t\tdepth = depth.toVar();\n\n\t\t\tIf( depth.lessThan( closestDepth ), () => {\n\n\t\t\t\tclosestDepth.assign( depth );\n\t\t\t\tclosestPositionTexel.assign( neighbor );\n\n\t\t\t} );\n\n\t\t\tIf( depth.greaterThan( farthestDepth ), () => {\n\n\t\t\t\tfarthestDepth.assign( depth );\n\n\t\t\t} );\n\n\t\t}\n\n\t}\n\n\treturn currentDepthStruct( closestDepth, closestPositionTexel, farthestDepth );\n\n} );\n\n/**\n * Samples the previous depth buffer and reprojects the depth into the current view.\n *\n * @tsl\n * @private\n * @function\n * @param {TextureNode} previousDepthNode - The previous depth buffer.\n * @param {Node<vec2>} uv - The uv coordinates.\n * @param {Node<mat4>} previousCameraProjectionMatrixInverse - The previous camera projection matrix inverse.\n * @param {Node<mat4>} previousCameraWorldMatrix - The previous camera world matrix.\n * @param {Node<mat4>} cameraWorldMatrixInverse - The current camera world matrix inverse.\n * @param {Node<vec2>} cameraNearFar - The camera's near and far.\n * @param {Camera} camera - The camera.\n * @return {Node<float>} The reprojected depth.\n */\nexport const samplePreviousDepth = Fn( ( [ previousDepthNode, uv, previousCameraProjectionMatrixInverse, previousCameraWorldMatrix, cameraWorldMatrixInverse, cameraNearFar, camera ], builder ) => {\n\n\tlet depth = previousDepthNode.sample( uv ).r;\n\tif ( builder.renderer.logarithmicDepthBuffer ) depth = logarithmicToPerspectiveDepth( depth, cameraNearFar );\n\tconst positionView = getViewPosition( uv, depth, previousCameraProjectionMatrixInverse );\n\tconst positionWorld = previousCameraWorldMatrix.mul( vec4( positionView, 1 ) ).xyz;\n\tconst viewZ = cameraWorldMatrixInverse.mul( vec4( positionWorld, 1 ) ).z;\n\treturn camera.isOrthographicCamera\n\t\t? viewZToOrthographicDepth( viewZ, cameraNearFar.x, cameraNearFar.y )\n\t\t: viewZToPerspectiveDepth( viewZ, cameraNearFar.x, cameraNearFar.y );\n\n} );\n\n/**\n * Computes a sequence of Halton(2, 3) jitter offsets in the range [0, 1].\n *\n * @private\n * @function\n * @param {number} length - The number of offsets.\n * @return {Array<Array<number>>} The jitter offsets.\n */\nexport function computeHaltonOffsets( length ) {\n\n\treturn Array.from( { length }, ( _, index ) => [ halton( index + 1, 2 ), halton( index + 1, 3 ) ] );\n\n}\n\nconst currentDepthStruct = struct( {\n\tclosestDepth: 'float',\n\tclosestPositionTexel: 'vec2',\n\tfarthestDepth: 'float'\n} );\n\nconst logarithmicToPerspectiveDepth = ( depth, cameraNearFar ) => {\n\n\tconst { x: near, y: far } = cameraNearFar;\n\tconst viewZ = logarithmicDepthToViewZ( depth, near, far );\n\treturn viewZToPerspectiveDepth( viewZ, near, far );\n\n};\n\nfunction halton( index, base ) {\n\n\tlet fraction = 1;\n\tlet result = 0;\n\twhile ( index > 0 ) {\n\n\t\tfraction /= base;\n\t\tresult += fraction * ( index % base );\n\t\tindex = Math.floor( index / base );\n\n\t}\n\n\treturn result;\n\n}\n","import { HalfFloatType, Vector2, RenderTarget, RendererUtils, QuadMesh, NodeMaterial, Node, NodeUpdateType, Matrix4, DepthTexture } from 'three/webgpu';\nimport { float, Fn, max, texture, uniform, uv, vec2, convertToTexture, passTexture, velocity, ivec2, mix, context, OnBeforeRenderPipeline, OnAfterRenderPipeline } from 'three/tsl';\nimport { clipAABB, computeHaltonOffsets, flickerReduction, sampleCurrentDepth, samplePreviousDepth } from '../utils/TAAUtils.js';\n\nconst _quadMesh = /*@__PURE__*/ new QuadMesh();\nconst _size = /*@__PURE__*/ new Vector2();\n\nlet _rendererState;\n\n\n/**\n * A special node that applies TRAA (Temporal Reprojection Anti-Aliasing).\n *\n * References:\n * - {@link https://alextardif.com/TAA.html}\n * - {@link https://www.elopezr.com/temporal-aa-and-the-quest-for-the-holy-trail/}\n *\n * Note: MSAA must be disabled when TRAA is in use.\n *\n * @augments Node\n * @three_import import { traa } from 'three/addons/tsl/display/TRAANode.js';\n */\nclass TRAANode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'TRAANode';\n\n\t}\n\n\t/**\n\t * Constructs a new TRAA node.\n\t *\n\t * @param {TextureNode} beautyNode - The texture node that represents the input of the effect.\n\t * @param {TextureNode} depthNode - A node that represents the scene's depth.\n\t * @param {TextureNode} velocityNode - A node that represents the scene's velocity.\n\t * @param {Camera} camera - The camera the scene is rendered with.\n\t */\n\tconstructor( beautyNode, depthNode, velocityNode, camera ) {\n\n\t\tsuper( 'vec4' );\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isTRAANode = true;\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders\n\t\t * its effect once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t/**\n\t\t * The texture node that represents the input of the effect.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.beautyNode = beautyNode;\n\n\t\t/**\n\t\t * A node that represents the scene's velocity.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.depthNode = depthNode;\n\n\t\t/**\n\t\t * A node that represents the scene's velocity.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.velocityNode = velocityNode;\n\n\t\t/**\n\t\t * The camera the scene is rendered with.\n\t\t *\n\t\t * @type {Camera}\n\t\t */\n\t\tthis.camera = camera;\n\n\t\t/**\n\t\t * When the difference between the current and previous depth goes above this threshold,\n\t\t * the history is considered invalid.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0.0005\n\t\t */\n\t\tthis.depthThreshold = 0.0005;\n\n\t\t/**\n\t\t * The depth difference within the 3×3 neighborhood to consider a pixel as an edge.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0.001\n\t\t */\n\t\tthis.edgeDepthDiff = 0.001;\n\n\t\t/**\n\t\t * The history becomes invalid as the pixel length of the velocity approaches this value.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 128\n\t\t */\n\t\tthis.maxVelocityLength = 128;\n\n\t\t/**\n\t\t * Whether to decrease the weight on the current frame when the velocity is more subpixel.\n\t\t * This reduces blurriness under motion, but can introduce a square pattern artifact.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.useSubpixelCorrection = true;\n\n\t\t/**\n\t\t * The jitter index selects the current camera offset value.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._jitterIndex = 0;\n\n\t\t/**\n\t\t * A uniform node holding the inverse resolution value.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._invSize = uniform( new Vector2() );\n\n\t\t/**\n\t\t * The render target that represents the history of frame data.\n\t\t *\n\t\t * @private\n\t\t * @type {?RenderTarget}\n\t\t */\n\t\tthis._historyRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType, depthTexture: new DepthTexture() } );\n\t\tthis._historyRenderTarget.texture.name = 'TRAANode.history';\n\n\t\t/**\n\t\t * The render target for the resolve.\n\t\t *\n\t\t * @private\n\t\t * @type {?RenderTarget}\n\t\t */\n\t\tthis._resolveRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );\n\t\tthis._resolveRenderTarget.texture.name = 'TRAANode.resolve';\n\n\t\t/**\n\t\t * Material used for the resolve step.\n\t\t *\n\t\t * @private\n\t\t * @type {NodeMaterial}\n\t\t */\n\t\tthis._resolveMaterial = new NodeMaterial();\n\t\tthis._resolveMaterial.name = 'TRAA.resolve';\n\n\t\t/**\n\t\t * The result of the effect is represented as a separate texture node.\n\t\t *\n\t\t * @private\n\t\t * @type {PassTextureNode}\n\t\t */\n\t\tthis._textureNode = passTexture( this, this._resolveRenderTarget.texture );\n\n\t\t/**\n\t\t * Used to save the original/unjittered projection matrix.\n\t\t *\n\t\t * @private\n\t\t * @type {Matrix4}\n\t\t */\n\t\tthis._originalProjectionMatrix = new Matrix4();\n\n\t\t/**\n\t\t * A uniform node holding the camera's near and far.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<vec2>}\n\t\t */\n\t\tthis._cameraNearFar = uniform( new Vector2() );\n\n\t\t/**\n\t\t * A uniform node holding the camera world matrix.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraWorldMatrix = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A uniform node holding the camera world matrix inverse.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraWorldMatrixInverse = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A uniform node holding the camera projection matrix inverse.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._cameraProjectionMatrixInverse = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A uniform node holding the previous frame's view matrix.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._previousCameraWorldMatrix = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A uniform node holding the previous frame's projection matrix inverse.\n\t\t *\n\t\t * @private\n\t\t * @type {UniformNode<mat4>}\n\t\t */\n\t\tthis._previousCameraProjectionMatrixInverse = uniform( new Matrix4() );\n\n\t\t/**\n\t\t * A texture node for the previous depth buffer.\n\t\t *\n\t\t * @private\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis._previousDepthNode = texture( this._historyRenderTarget.depthTexture );\n\n\t\t/**\n\t\t * The node used to render the scene's velocity.\n\t\t *\n\t\t * @private\n\t\t * @type {?VelocityNode}\n\t\t */\n\t\tthis._velocityNode = null;\n\n\t}\n\n\t/**\n\t * Returns the result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the result of the effect.\n\t */\n\tgetTextureNode() {\n\n\t\treturn this._textureNode;\n\n\t}\n\n\t/**\n\t * Sets the size of the effect.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetSize( width, height ) {\n\n\t\tthis._historyRenderTarget.setSize( width, height );\n\t\tthis._resolveRenderTarget.setSize( width, height );\n\n\t\tthis._invSize.value.set( 1 / width, 1 / height );\n\n\t}\n\n\t/**\n\t * Defines the TRAA's current jitter as a view offset\n\t * to the scene's camera.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetViewOffset( width, height ) {\n\n\t\t// save original/unjittered projection matrix for velocity pass\n\n\t\tthis.camera.updateProjectionMatrix();\n\t\tthis._originalProjectionMatrix.copy( this.camera.projectionMatrix );\n\n\t\tthis._velocityNode.setProjectionMatrix( this._originalProjectionMatrix );\n\n\t\t//\n\n\t\tconst viewOffset = {\n\n\t\t\tfullWidth: width,\n\t\t\tfullHeight: height,\n\t\t\toffsetX: 0,\n\t\t\toffsetY: 0,\n\t\t\twidth: width,\n\t\t\theight: height\n\n\t\t};\n\n\t\tconst jitterOffset = _haltonOffsets[ this._jitterIndex ];\n\n\t\tthis.camera.setViewOffset(\n\n\t\t\tviewOffset.fullWidth, viewOffset.fullHeight,\n\n\t\t\tviewOffset.offsetX + jitterOffset[ 0 ] - 0.5, viewOffset.offsetY + jitterOffset[ 1 ] - 0.5,\n\n\t\t\tviewOffset.width, viewOffset.height\n\n\t\t);\n\n\t}\n\n\t/**\n\t * Clears the view offset from the scene's camera.\n\t */\n\tclearViewOffset() {\n\n\t\tthis.camera.clearViewOffset();\n\n\t\tthis._velocityNode.setProjectionMatrix( null );\n\n\t\t// update jitter index\n\n\t\tthis._jitterIndex ++;\n\t\tthis._jitterIndex = this._jitterIndex % _haltonOffsets.length;\n\n\t}\n\n\t/**\n\t * This method is used to render the effect once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore( frame ) {\n\n\t\tconst { renderer } = frame;\n\n\t\t// store previous frame matrices before updating current ones\n\n\t\tthis._previousCameraWorldMatrix.value.copy( this._cameraWorldMatrix.value );\n\t\tthis._previousCameraProjectionMatrixInverse.value.copy( this._cameraProjectionMatrixInverse.value );\n\n\t\t// update camera matrices uniforms\n\n\t\tthis._cameraNearFar.value.set( this.camera.near, this.camera.far );\n\t\tthis._cameraWorldMatrix.value.copy( this.camera.matrixWorld );\n\t\tthis._cameraWorldMatrixInverse.value.copy( this.camera.matrixWorldInverse );\n\t\tthis._cameraProjectionMatrixInverse.value.copy( this.camera.projectionMatrixInverse );\n\n\t\t// keep the TRAA in sync with the dimensions of the beauty node\n\n\t\tconst beautyRenderTarget = ( this.beautyNode.isRTTNode ) ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget;\n\n\t\tconst width = beautyRenderTarget.texture.width;\n\t\tconst height = beautyRenderTarget.texture.height;\n\n\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t//\n\n\t\tconst needsRestart = this._historyRenderTarget.width !== width || this._historyRenderTarget.height !== height;\n\t\tthis.setSize( width, height );\n\n\t\t// every time when the dimensions change we need fresh history data\n\n\t\tif ( needsRestart === true ) {\n\n\t\t\t// make sure to reset the history with the contents of the beauty buffer otherwise subsequent frames after the\n\t\t\t// resize will fade from a darker color to the correct one because the history was cleared with black.\n\n\t\t\trenderer.copyTextureToTexture( beautyRenderTarget.texture, this._historyRenderTarget.texture );\n\n\t\t}\n\n\t\t// resolve\n\n\t\trenderer.setRenderTarget( this._resolveRenderTarget );\n\t\t_quadMesh.material = this._resolveMaterial;\n\t\t_quadMesh.name = 'TRAA';\n\t\t_quadMesh.render( renderer );\n\t\trenderer.setRenderTarget( null );\n\n\t\t// update history\n\n\t\trenderer.copyTextureToTexture( this._resolveRenderTarget.texture, this._historyRenderTarget.texture );\n\n\t\t// Copy current depth to previous depth buffer\n\n\t\tconst size = renderer.getDrawingBufferSize( _size );\n\n\t\t// only allow the depth copy if the dimensions of the history render target match with the drawing\n\t\t// render buffer and thus the depth texture of the scene. For some reasons, there are timing issues\n\t\t// with WebGPU resulting in different size of the drawing buffer and the beauty render target when\n\t\t// resizing the browser window. This does not happen with the WebGL backend\n\n\t\tif ( this._historyRenderTarget.height === size.height && this._historyRenderTarget.width === size.width ) {\n\n\t\t\tconst currentDepth = this.depthNode.value;\n\t\t\trenderer.copyTextureToTexture( currentDepth, this._historyRenderTarget.depthTexture );\n\n\t\t}\n\n\t\t// restore\n\n\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's render targets and TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {PassTextureNode}\n\t */\n\tsetup( builder ) {\n\n\t\tthis.depthNode.build( builder );\n\t\tthis.velocityNode.build( builder );\n\t\tthis.beautyNode.build( builder );\n\n\t\tif ( builder.renderPipeline && ! builder.context.renderPipelineState.viewOffsetOwner ) {\n\n\t\t\tbuilder.context.renderPipelineState.viewOffsetOwner = this;\n\n\t\t\tOnBeforeRenderPipeline( () => {\n\n\t\t\t\tconst size = builder.renderer.getDrawingBufferSize( _size );\n\t\t\t\tthis.setViewOffset( size.width, size.height );\n\n\t\t\t} );\n\n\t\t\tOnAfterRenderPipeline( () => {\n\n\t\t\t\tthis.clearViewOffset();\n\n\t\t\t} );\n\n\t\t}\n\n\t\tthis._historyRenderTarget.depthTexture.format = this.depthNode.value.format;\n\t\tthis._historyRenderTarget.depthTexture.type = this.depthNode.value.type;\n\n\t\tif ( builder.context.velocity !== undefined ) {\n\n\t\t\tthis._velocityNode = builder.context.velocity;\n\n\t\t} else {\n\n\t\t\tthis._velocityNode = velocity;\n\n\t\t}\n\n\t\t// Performs variance clipping.\n\t\t// See: https://developer.download.nvidia.com/gameworks/events/GDC2016/msalvi_temporal_supersampling.pdf\n\t\tconst varianceClipping = Fn( ( [ positionTexel, currentColor, historyColor, gamma ] ) => {\n\n\t\t\tconst offsets = [\n\t\t\t\t[ - 1, - 1 ],\n\t\t\t\t[ - 1, 1 ],\n\t\t\t\t[ 1, - 1 ],\n\t\t\t\t[ 1, 1 ],\n\t\t\t\t[ 1, 0 ],\n\t\t\t\t[ 0, - 1 ],\n\t\t\t\t[ 0, 1 ],\n\t\t\t\t[ - 1, 0 ]\n\t\t\t];\n\n\t\t\tconst moment1 = currentColor.toVar();\n\t\t\tconst moment2 = currentColor.pow2().toVar();\n\n\t\t\tfor ( const [ x, y ] of offsets ) {\n\n\t\t\t\t// Use max() to prevent NaN values from propagating.\n\t\t\t\tconst neighbor = this.beautyNode.offset( ivec2( x, y ) ).load( positionTexel ).max( 0 );\n\t\t\t\tmoment1.addAssign( neighbor );\n\t\t\t\tmoment2.addAssign( neighbor.pow2() );\n\n\t\t\t}\n\n\t\t\tconst N = float( offsets.length + 1 );\n\t\t\tconst mean = moment1.div( N );\n\t\t\tconst variance = moment2.div( N ).sub( mean.pow2() ).max( 0 ).sqrt().mul( gamma );\n\t\t\tconst minColor = mean.sub( variance );\n\t\t\tconst maxColor = mean.add( variance );\n\n\t\t\treturn clipAABB( mean.clamp( minColor, maxColor ), historyColor, minColor, maxColor );\n\n\t\t} );\n\n\t\t// Returns the amount of subpixel (expressed within [0, 1]) in the velocity.\n\t\tconst subpixelCorrection = Fn( ( [ velocityUV, textureSize ] ) => {\n\n\t\t\tconst velocityTexel = velocityUV.mul( textureSize );\n\t\t\tconst phase = velocityTexel.fract().abs();\n\t\t\tconst weight = max( phase, phase.oneMinus() );\n\t\t\treturn weight.x.mul( weight.y ).oneMinus().div( 0.75 );\n\n\t\t}, { velocityUV: 'vec2', textureSize: 'ivec2', return: 'float' } );\n\n\t\tconst historyNode = texture( this._historyRenderTarget.texture );\n\n\t\tconst resolve = Fn( () => {\n\n\t\t\tconst uvNode = uv();\n\t\t\tconst textureSize = this.beautyNode.size(); // Assumes all the buffers share the same size.\n\t\t\tconst positionTexel = uvNode.mul( textureSize );\n\n\t\t\t// sample the closest and farthest depths in the current buffer\n\n\t\t\tconst currentDepth = sampleCurrentDepth( this.depthNode, positionTexel, this._cameraNearFar );\n\t\t\tconst closestDepth = currentDepth.get( 'closestDepth' );\n\t\t\tconst closestPositionTexel = currentDepth.get( 'closestPositionTexel' );\n\t\t\tconst farthestDepth = currentDepth.get( 'farthestDepth' );\n\n\t\t\t// convert the NDC offset to UV offset\n\n\t\t\tconst offsetUV = this.velocityNode.load( closestPositionTexel ).xy.mul( vec2( 0.5, - 0.5 ) );\n\n\t\t\t// sample the previous depth\n\n\t\t\tconst historyUV = uvNode.sub( offsetUV );\n\t\t\tconst previousDepth = samplePreviousDepth( this._previousDepthNode, historyUV, this._previousCameraProjectionMatrixInverse, this._previousCameraWorldMatrix, this._cameraWorldMatrixInverse, this._cameraNearFar, this.camera );\n\n\t\t\t// history is considered valid when the UV is in range and there's no disocclusion except on edges\n\n\t\t\tconst isValidUV = historyUV.greaterThanEqual( 0 ).all().and( historyUV.lessThanEqual( 1 ).all() );\n\t\t\tconst isEdge = farthestDepth.sub( closestDepth ).greaterThan( this.edgeDepthDiff );\n\t\t\tconst isDisocclusion = closestDepth.sub( previousDepth ).greaterThan( this.depthThreshold );\n\t\t\tconst hasValidHistory = isValidUV.and( isEdge.or( isDisocclusion.not() ) );\n\n\t\t\t// sample the current and previous colors\n\n\t\t\tconst currentColor = this.beautyNode.sample( uvNode );\n\t\t\tconst historyColor = historyNode.sample( historyUV );\n\n\t\t\t// increase the weight towards the current frame under motion\n\n\t\t\tconst motionFactor = uvNode.sub( historyUV ).mul( textureSize ).length().div( this.maxVelocityLength ).saturate();\n\t\t\tconst currentWeight = float( 0.05 ).toVar(); // A minimum weight\n\n\t\t\tif ( this.useSubpixelCorrection ) {\n\n\t\t\t\t// Increase the minimum weight towards the current frame when the velocity is more subpixel.\n\t\t\t\tcurrentWeight.addAssign( subpixelCorrection( offsetUV, textureSize ).mul( 0.25 ) );\n\n\t\t\t}\n\n\t\t\tcurrentWeight.assign( hasValidHistory.select( currentWeight.add( motionFactor ).saturate(), 1 ) );\n\n\t\t\t// Perform neighborhood clipping/clamping. We use variance clipping here.\n\n\t\t\tconst varianceGamma = mix( 0.5, 1, motionFactor.oneMinus().pow2() ); // Reasonable gamma range is [0.75, 2]\n\t\t\tconst clippedHistoryColor = varianceClipping( positionTexel, currentColor, historyColor, varianceGamma );\n\n\t\t\t// flicker reduction based on luminance weighing\n\n\t\t\tconst output = flickerReduction( currentColor, clippedHistoryColor, currentWeight );\n\n\t\t\treturn output;\n\n\t\t} );\n\n\t\t// materials\n\n\t\tthis._resolveMaterial.contextNode = context( builder.getSharedContext() );\n\t\tthis._resolveMaterial.colorNode = resolve();\n\n\t\treturn this._textureNode;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis._historyRenderTarget.dispose();\n\t\tthis._resolveRenderTarget.dispose();\n\n\t\tthis._resolveMaterial.dispose();\n\n\t}\n\n}\n\nexport default TRAANode;\n\nconst _haltonOffsets = /*@__PURE__*/ computeHaltonOffsets( 32 );\n\n/**\n * TSL function for creating a TRAA node for Temporal Reprojection Anti-Aliasing.\n *\n * @tsl\n * @function\n * @param {TextureNode} beautyNode - The texture node that represents the input of the effect.\n * @param {TextureNode} depthNode - A node that represents the scene's depth.\n * @param {TextureNode} velocityNode - A node that represents the scene's velocity.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @returns {TRAANode}\n */\nexport const traa = ( beautyNode, depthNode, velocityNode, camera ) => new TRAANode( convertToTexture( beautyNode ), depthNode, velocityNode, camera );\n","import type { Camera, Scene } from 'three';\nimport { PerspectiveCamera } from 'three';\nimport type { Node, PassNode } from 'three/webgpu';\nimport { traa } from 'three/addons/tsl/display/TRAANode.js';\nimport { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\nexport class TraaRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'TraaRenderPass';\n override readonly passId = TraaRenderPass.passId;\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n _scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n if (!(camera instanceof PerspectiveCamera)) {\n return currentNode; // no ssgi/traa for orthographic camera\n }\n const scenePassDepth = basePassNode.getTextureNode('depth');\n const scenePassVelocity = basePassNode.getTextureNode('velocity');\n\n const traaPass = traa(\n currentNode,\n scenePassDepth,\n scenePassVelocity,\n camera,\n );\n\n if (debugMode === 'velocity') {\n return traaPass.velocityNode;\n }\n\n return traaPass;\n }\n\n override addParametersToGUI(\n _renderPassSettings: ParametersGroup,\n _updateCallback: () => void,\n ): void {\n return;\n }\n}\n","import type { SsgiPerformanceParameters } from './passes/ssgi-render-pass';\nimport type { VxgiPerformanceParameters } from './passes/vxgi-render-pass';\n\nexport interface WebGPUQualityParameters {\n maxDevicePixelRatio: number;\n maxPixelRatioMultiplier: number;\n ssgiPerformanceParameters: SsgiPerformanceParameters;\n vxgiPerformanceParameters: VxgiPerformanceParameters;\n}\n\nexport const WEBGPU_QUALITY_LEVELS = {\n HIGHEST: 'highest',\n HIGHER: 'higher',\n HIGH: 'high',\n MEDIUM: 'medium',\n LOW: 'low',\n LOWEST: 'lowest',\n} as const;\n\nexport type WebGPUQualityLevel =\n (typeof WEBGPU_QUALITY_LEVELS)[keyof typeof WEBGPU_QUALITY_LEVELS];\n\nexport type WebGPUQualityMap = Map<WebGPUQualityLevel, WebGPUQualityParameters>;\n\nexport const WEBGPU_QUALITY_LEVEL_ORDER: WebGPUQualityLevel[] = [\n WEBGPU_QUALITY_LEVELS.HIGHEST,\n WEBGPU_QUALITY_LEVELS.HIGHER,\n WEBGPU_QUALITY_LEVELS.HIGH,\n WEBGPU_QUALITY_LEVELS.MEDIUM,\n WEBGPU_QUALITY_LEVELS.LOW,\n WEBGPU_QUALITY_LEVELS.LOWEST,\n];\n\nexport const WEBGPU_MAX_QUALITY_LEVEL = WEBGPU_QUALITY_LEVEL_ORDER[0];\nexport const WEBGPU_MIN_QUALITY_LEVEL =\n WEBGPU_QUALITY_LEVEL_ORDER[WEBGPU_QUALITY_LEVEL_ORDER.length - 1];\n\nexport const DEFAULT_WEBGPU_QUALITY_LEVEL: WebGPUQualityLevel =\n WEBGPU_QUALITY_LEVELS.HIGHEST;\n\nexport const defaultWebGPUQualityLevelMap: WebGPUQualityMap = new Map([\n [\n WEBGPU_QUALITY_LEVELS.HIGHEST,\n {\n maxDevicePixelRatio: 1.5,\n maxPixelRatioMultiplier: 2,\n ssgiPerformanceParameters: { sliceCount: 3, stepCount: 16 },\n vxgiPerformanceParameters: { coneCount: 4, coneAngle: 40 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.HIGHER,\n {\n maxDevicePixelRatio: 1.5,\n maxPixelRatioMultiplier: 2,\n ssgiPerformanceParameters: { sliceCount: 2, stepCount: 8 },\n vxgiPerformanceParameters: { coneCount: 3, coneAngle: 40 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.HIGH,\n {\n maxDevicePixelRatio: 1.5,\n maxPixelRatioMultiplier: 2,\n ssgiPerformanceParameters: { sliceCount: 1, stepCount: 12 },\n vxgiPerformanceParameters: { coneCount: 3, coneAngle: 50 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.MEDIUM,\n {\n maxDevicePixelRatio: 1.25,\n maxPixelRatioMultiplier: 1.5,\n ssgiPerformanceParameters: { sliceCount: 1, stepCount: 12 },\n vxgiPerformanceParameters: { coneCount: 2, coneAngle: 60 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.LOW,\n {\n maxDevicePixelRatio: 1,\n maxPixelRatioMultiplier: 1,\n ssgiPerformanceParameters: { sliceCount: 1, stepCount: 8 },\n vxgiPerformanceParameters: { coneCount: 2, coneAngle: 70 },\n },\n ],\n [\n WEBGPU_QUALITY_LEVELS.LOWEST,\n {\n maxDevicePixelRatio: 1,\n maxPixelRatioMultiplier: 1,\n ssgiPerformanceParameters: { sliceCount: 0, stepCount: 0 },\n vxgiPerformanceParameters: { coneCount: 0, coneAngle: 70 },\n },\n ],\n]);\n\nconst benchmarkFpsRangeMap = [\n { min: 70, max: Infinity, value: WEBGPU_QUALITY_LEVELS.HIGHEST },\n { min: 55, max: 69, value: WEBGPU_QUALITY_LEVELS.HIGHER },\n { min: 40, max: 54, value: WEBGPU_QUALITY_LEVELS.HIGH },\n { min: 30, max: 39, value: WEBGPU_QUALITY_LEVELS.MEDIUM },\n { min: 20, max: 29, value: WEBGPU_QUALITY_LEVELS.LOW },\n { min: 0, max: 19, value: WEBGPU_QUALITY_LEVELS.LOWEST },\n];\n\nexport const benchmarkFpsToQualityLevel = (fps: number): WebGPUQualityLevel => {\n const match = benchmarkFpsRangeMap.find(\n (range) => fps >= range.min && fps <= range.max,\n );\n return match!.value;\n};\n","import type { Inspector } from 'three/examples/jsm/inspector/Inspector.js';\nimport FpsCounter from '../utils/fps-counter';\nimport type {\n WebGPUQualityLevel,\n WebGPUQualityMap,\n WebGPUQualityParameters,\n} from './roomle-webgpu-renderer-quality-levels';\nimport {\n benchmarkFpsToQualityLevel,\n DEFAULT_WEBGPU_QUALITY_LEVEL,\n defaultWebGPUQualityLevelMap,\n WEBGPU_MAX_QUALITY_LEVEL,\n WEBGPU_MIN_QUALITY_LEVEL,\n WEBGPU_QUALITY_LEVEL_ORDER,\n} from './roomle-webgpu-renderer-quality-levels';\n\n// freeze-frame on quality change to avoid black flicker\nexport const FREEZE_FRAMES_ON_QUALITY_CHANGE = 6;\n\n// how long the fps has to stay beyond a threshold before the quality level is adjusted\nexport const QUALITY_CHANGE_DEBOUNCE_MS = 800;\n\ntype QualityChangeDirection = 'increment' | 'decrement';\n\ntype ApplyQualityParametersCallback = (\n qualityParameters: WebGPUQualityParameters,\n freezeFrames: number,\n) => void;\n\nexport class RoomleWebGPUQualityManager {\n private qualityLevel: WebGPUQualityLevel = DEFAULT_WEBGPU_QUALITY_LEVEL;\n private qualityMap: WebGPUQualityMap = defaultWebGPUQualityLevelMap;\n private fpsCounter = new FpsCounter();\n private qualityChangePendingSince: number | undefined;\n private qualityChangePendingDirection: QualityChangeDirection | undefined;\n private readonly applyQualityParametersCallback: ApplyQualityParametersCallback;\n\n constructor(applyQualityParametersCallback: ApplyQualityParametersCallback) {\n this.applyQualityParametersCallback = applyQualityParametersCallback;\n }\n\n public getQualityLevel(): WebGPUQualityLevel {\n return this.qualityLevel;\n }\n\n public manageQualitySettings(minFps: number, maxFps: number): void {\n this.fpsCounter.update();\n const fps = this.fpsCounter.getFps();\n const shouldDecrementQualityLevel =\n fps > 0 && fps < minFps && this.qualityLevel !== WEBGPU_MIN_QUALITY_LEVEL;\n const shouldIncrementQualityLevel =\n fps > maxFps && this.qualityLevel !== WEBGPU_MAX_QUALITY_LEVEL;\n\n const qualityChangeDirection = shouldDecrementQualityLevel\n ? 'decrement'\n : shouldIncrementQualityLevel\n ? 'increment'\n : undefined;\n\n if (qualityChangeDirection === undefined) {\n this.qualityChangePendingSince = undefined;\n this.qualityChangePendingDirection = undefined;\n return;\n }\n\n const now = (performance || Date).now();\n if (\n this.qualityChangePendingDirection !== qualityChangeDirection ||\n this.qualityChangePendingSince === undefined\n ) {\n this.qualityChangePendingDirection = qualityChangeDirection;\n this.qualityChangePendingSince = now;\n return;\n }\n\n if (now - this.qualityChangePendingSince < QUALITY_CHANGE_DEBOUNCE_MS) {\n return;\n }\n\n if (qualityChangeDirection === 'decrement') {\n this.decrementQualityLevel();\n } else {\n this.incrementQualityLevel();\n }\n\n console.log(`fps at ${fps}, setting quality level to ${this.qualityLevel}`);\n this.qualityChangePendingSince = undefined;\n this.qualityChangePendingDirection = undefined;\n this.fpsCounter.reset();\n }\n\n public incrementQualityLevel(): void {\n const currentIndex = WEBGPU_QUALITY_LEVEL_ORDER.indexOf(this.qualityLevel);\n this.setQualityLevelByOrderIndex(currentIndex - 1);\n }\n\n public decrementQualityLevel(): void {\n const currentIndex = WEBGPU_QUALITY_LEVEL_ORDER.indexOf(this.qualityLevel);\n this.setQualityLevelByOrderIndex(currentIndex + 1);\n }\n\n public setQualityLevel(qualityLevel: WebGPUQualityLevel): void {\n if (this.qualityLevel === qualityLevel) {\n return;\n }\n this.qualityLevel = qualityLevel;\n this.applyCurrentQualityLevel();\n }\n\n public addGUI(inspector: Inspector, updateCallback: () => void): void {\n const qualitySettings = inspector.createParameters('Quality Settings');\n const qualityLevels = Object.fromEntries(\n WEBGPU_QUALITY_LEVEL_ORDER.map((level) => [level, level]),\n ) as Record<string, WebGPUQualityLevel>;\n const params = {\n qualityLevel: this.qualityLevel,\n };\n\n qualitySettings\n .add(params, 'qualityLevel', qualityLevels)\n .onChange((qualityLevel: WebGPUQualityLevel) => {\n this.setQualityLevel(qualityLevel);\n updateCallback();\n });\n }\n\n private setQualityLevelByOrderIndex(index: number): void {\n const clampedIndex = Math.min(\n Math.max(index, 0),\n WEBGPU_QUALITY_LEVEL_ORDER.length - 1,\n );\n this.setQualityLevel(WEBGPU_QUALITY_LEVEL_ORDER[clampedIndex]);\n }\n\n public applyCurrentQualityLevel(\n freezeFrames = FREEZE_FRAMES_ON_QUALITY_CHANGE,\n ): void {\n const qualityParameters = this.qualityMap.get(this.qualityLevel);\n if (!qualityParameters) {\n return;\n }\n this.applyQualityParametersCallback(qualityParameters, freezeFrames);\n }\n\n public async autoDetectInitialQualityLevel(): Promise<void> {\n const { getGPUTier } = await import('@pmndrs/detect-gpu');\n const gpuBenchmark = await getGPUTier({\n benchmarksURL: './benchmarks',\n });\n if (!gpuBenchmark || !gpuBenchmark.fps) {\n console.info(\n 'Could not autodetect performance - no benchmark for graphics hardware. Defaulting to HIGHEST',\n );\n this.qualityLevel = DEFAULT_WEBGPU_QUALITY_LEVEL;\n return;\n }\n this.qualityLevel = benchmarkFpsToQualityLevel(gpuBenchmark.fps);\n console.info(\n `The initial quality setting has been set to ${this.qualityLevel} based on a benchmark performance of ${gpuBenchmark.fps}fps of the graphics hardware.`,\n );\n }\n}\n","import type { Camera, ColorRepresentation, Material, Scene } from 'three';\nimport {\n Color,\n DoubleSide,\n MeshBasicMaterial,\n PerspectiveCamera,\n SRGBColorSpace,\n} from 'three';\nimport type { Node, PassNode, UniformNode, TextureNode } from 'three/webgpu';\nimport {\n fog,\n mix,\n screenUV,\n vec4,\n uniform,\n max,\n min,\n positionWorld,\n depthPass,\n} from 'three/tsl';\nimport { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\nexport interface FogPassParameters {\n color: ColorRepresentation;\n nearBlend: number;\n farBlend: number;\n}\n\nexport class FogRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'FogRenderPass';\n override readonly passId = FogRenderPass.passId;\n private readonly fogColor: UniformNode<'color', Color>;\n private readonly fogNearBlend: UniformNode<'float', number>;\n private readonly fogFarBlend: UniformNode<'float', number>;\n private sceneWithFog: Scene | undefined = undefined;\n\n // separate depth only pass for transparent objects\n // which do not write to the normal depth buffer\n private transparentObjectsDepthPass: PassNode | undefined = undefined;\n private readonly depthOverrideMaterial: Material;\n\n constructor(params: FogPassParameters) {\n super();\n this.fogColor = uniform(new Color(params.color));\n this.fogNearBlend = uniform(params.nearBlend);\n this.fogFarBlend = uniform(params.farBlend);\n this.depthOverrideMaterial = new MeshBasicMaterial({ side: DoubleSide });\n }\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n // no fog for orthographic camera\n if (\n !(camera instanceof PerspectiveCamera) ||\n debugMode === 'no fog' ||\n debugMode === 'depth'\n ) {\n this.removeSceneFog();\n return currentNode;\n }\n\n const scenePassDepth = basePassNode.getTextureNode('depth');\n const transparentObjectsDepth = this.getTransparentObjectsDepthPassTexture(\n scene,\n camera,\n );\n // nearest of opaque scene depth and transparent (ghost) depth\n const depth = min(scenePassDepth.r, transparentObjectsDepth.r);\n\n const cameraProjectionMatrixInverse = uniform(\n camera.projectionMatrixInverse,\n );\n const cameraWorldMatrix = uniform(camera.matrixWorld);\n const cameraFar = uniform(camera.far).onRenderUpdate(() => camera.far);\n const fogFar = min(max(20, cameraFar), 50).sub(this.fogFarBlend);\n const fogNear = fogFar.sub(this.fogNearBlend);\n\n // map to clip space [-1, 1]^2\n const clipX = screenUV.x.mul(2.0).sub(1.0);\n const clipY = screenUV.y.mul(2.0).sub(1.0);\n const ndc = vec4(clipX, clipY, depth, 1.0);\n\n const viewSpacePosition = cameraProjectionMatrixInverse.mul(ndc);\n const viewSpacePositionNormalizedXYZ = viewSpacePosition.xyz.div(\n viewSpacePosition.w,\n );\n\n const worldPosition = cameraWorldMatrix.mul(\n vec4(viewSpacePositionNormalizedXYZ, 1.0),\n ).xyz;\n const xzDistanceToOrigin = worldPosition.xz.length();\n\n const fogFactor = fogFar\n .sub(xzDistanceToOrigin)\n .div(fogFar.sub(fogNear))\n .clamp(0.0, 1.0)\n .toInspector('Fog / Factor');\n\n this.addSceneFog(scene, fogNear, fogFar);\n\n return mix(vec4(this.fogColor, 1), currentNode, fogFactor).toInspector(\n 'Fog / Composite',\n );\n }\n\n // add basically the same fog again but in the scene fogNode\n // to make it also show in e.g. transmissive materials\n private addSceneFog(\n scene: Scene,\n fogNear: Node<'float'>,\n fogFar: Node<'float'>,\n ) {\n const distance = positionWorld.xz.length();\n\n const fogFactor = fogFar\n .sub(distance)\n .div(fogFar.sub(fogNear))\n .clamp(0.0, 1.0)\n .oneMinus();\n\n scene.fogNode = fog(this.fogColor, fogFactor);\n this.sceneWithFog = scene;\n }\n\n private getTransparentObjectsDepthPassTexture(\n scene: Scene,\n camera: Camera,\n ): TextureNode {\n this.transparentObjectsDepthPass?.dispose();\n this.transparentObjectsDepthPass = depthPass(scene, camera);\n // only draw non-opaque objects, but force them to write only depth\n this.transparentObjectsDepthPass.opaque = false;\n this.transparentObjectsDepthPass.overrideMaterial =\n this.depthOverrideMaterial;\n return this.transparentObjectsDepthPass.getTextureNode('depth');\n }\n\n public removeSceneFog() {\n if (this.sceneWithFog) {\n this.sceneWithFog.fogNode = null;\n this.sceneWithFog = undefined;\n }\n this.transparentObjectsDepthPass?.dispose();\n this.transparentObjectsDepthPass = undefined;\n }\n\n override addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const gui = renderPassSettings.addFolder('Fog Settings');\n gui\n .add(this.fogNearBlend, 'value', 0, 30, 0.1)\n .name('near blend')\n .onChange(() => updateCallback());\n gui\n .add(this.fogFarBlend, 'value', 0, 30, 0.1)\n .name('far blend')\n .onChange(() => updateCallback());\n gui\n .addColor({ color: this.fogColor.value.getHex(SRGBColorSpace) }, 'color')\n .name('color')\n .onChange((value) => {\n this.fogColor.value.set(value);\n updateCallback();\n });\n }\n}\n","import type { Camera, Scene } from 'three';\nimport type { Node, PassNode } from 'three/webgpu';\nimport { context, vec3, vec4 } from 'three/tsl';\nimport { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\n\n// should be applied last and unconditionally\nexport class DebugRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'DebugRenderPass';\n override readonly passId = DebugRenderPass.passId;\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n _scene: Scene,\n _camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n if (debugMode === 'depth') {\n const scenePassDepth = basePassNode.getTextureNode('depth');\n return vec4(vec3(scenePassDepth.r), 1.0);\n } else if (debugMode === 'direct lighting only') {\n basePassNode.contextNode = context();\n return basePassNode;\n }\n\n return currentNode;\n }\n\n override addParametersToGUI(\n _renderPassSettings: ParametersGroup,\n _updateCallback: () => void,\n ): void {\n // debug GUI is added in RoomleWebGPURenderer#addDebugGUI since it concerns all passes\n return;\n }\n}\n","import { Box3, Color, MathUtils, Matrix4, Vector2, Vector3, BackSide, DoubleSide, FrontSide, SRGBColorSpace } from 'three/webgpu';\n\nconst _matrix = /*@__PURE__*/ new Matrix4();\nconst _box = /*@__PURE__*/ new Box3();\nconst _va = /*@__PURE__*/ new Vector3();\nconst _vb = /*@__PURE__*/ new Vector3();\nconst _vc = /*@__PURE__*/ new Vector3();\nconst _uva = /*@__PURE__*/ new Vector2();\nconst _uvb = /*@__PURE__*/ new Vector2();\nconst _uvc = /*@__PURE__*/ new Vector2();\nconst _uv = /*@__PURE__*/ new Vector2();\nconst _color = /*@__PURE__*/ new Color();\nconst _albedo = /*@__PURE__*/ new Color();\nconst _emissive = /*@__PURE__*/ new Color();\nconst _columns = /*@__PURE__*/ new Map();\n\nconst IMAGE_SAMPLE_SIZE = 64;\nconst POSITION_QUANTIZATION = 131072;\n\n/**\n * Number of floats per triangle record: three positions (vec4 each, w unused),\n * albedo (rgb + side flag) and emissive (rgb + unused).\n */\nexport const TRIANGLE_STRIDE = 20;\n\nconst _srgbLUT = new Float32Array( 256 );\n\nfor ( let i = 0; i < 256; i ++ ) {\n\n\tconst c = i / 255;\n\t_srgbLUT[ i ] = ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n}\n\nclass GrowableFloat32Array {\n\n\tconstructor( initialSize ) {\n\n\t\tthis.array = new Float32Array( initialSize );\n\t\tthis.length = 0;\n\n\t}\n\n\tensure( count ) {\n\n\t\tif ( this.length + count > this.array.length ) {\n\n\t\t\tlet size = this.array.length * 2;\n\t\t\twhile ( size < this.length + count ) size *= 2;\n\n\t\t\tconst array = new Float32Array( size );\n\t\t\tarray.set( this.array );\n\t\t\tthis.array = array;\n\n\t\t}\n\n\t}\n\n\tpush4( x, y, z, w ) {\n\n\t\tconst a = this.array, i = this.length;\n\t\ta[ i ] = x; a[ i + 1 ] = y; a[ i + 2 ] = z; a[ i + 3 ] = w;\n\t\tthis.length += 4;\n\n\t}\n\n\tresult() {\n\n\t\treturn this.array.slice( 0, this.length );\n\n\t}\n\n}\n\n/**\n * Downscales a texture image into a small pixel buffer so triangle colors can be\n * looked up on the CPU. Returns `null` for images that cannot be read.\n *\n * @private\n * @param {Texture} texture - The texture.\n * @param {Map<string, ?Object>} cache - Cache keyed by texture uuid.\n * @return {?{data: Uint8ClampedArray, width: number, height: number, srgb: boolean}} The image sampler.\n */\nfunction getImageSampler( texture, cache ) {\n\n\tif ( cache.has( texture.uuid ) ) return cache.get( texture.uuid );\n\n\tlet sampler = null;\n\tconst image = texture.image;\n\n\tif ( image && texture.isCompressedTexture !== true ) {\n\n\t\tconst srgb = texture.colorSpace === SRGBColorSpace;\n\n\t\tif ( image.data !== undefined && image.width !== undefined ) {\n\n\t\t\t// DataTexture (RGBA 8-bit only)\n\n\t\t\tif ( image.data.length === image.width * image.height * 4 && image.data.BYTES_PER_ELEMENT === 1 ) {\n\n\t\t\t\tsampler = { data: image.data, width: image.width, height: image.height, srgb };\n\n\t\t\t}\n\n\t\t} else if ( image.width > 0 && image.height > 0 ) {\n\n\t\t\ttry {\n\n\t\t\t\tconst size = IMAGE_SAMPLE_SIZE;\n\t\t\t\tconst canvas = ( typeof OffscreenCanvas !== 'undefined' ) ? new OffscreenCanvas( size, size ) : document.createElement( 'canvas' );\n\t\t\t\tcanvas.width = size;\n\t\t\t\tcanvas.height = size;\n\n\t\t\t\tconst context = canvas.getContext( '2d', { willReadFrequently: true } );\n\t\t\t\tcontext.imageSmoothingEnabled = true;\n\t\t\t\tcontext.imageSmoothingQuality = 'high';\n\t\t\t\tcontext.drawImage( image, 0, 0, size, size );\n\n\t\t\t\tsampler = { data: context.getImageData( 0, 0, size, size ).data, width: size, height: size, srgb };\n\n\t\t\t} catch ( e ) {\n\n\t\t\t\tsampler = null;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tcache.set( texture.uuid, sampler );\n\n\treturn sampler;\n\n}\n\n/**\n * Samples the given texture at the given uv coordinates. The result is written\n * into `target` (linear rgb) and the alpha is returned.\n *\n * @private\n */\nfunction sampleTexture( texture, sampler, uv, target ) {\n\n\t_uv.copy( uv );\n\ttexture.transformUv( _uv );\n\n\tconst x = Math.min( sampler.width - 1, Math.max( 0, Math.floor( _uv.x * sampler.width ) ) );\n\tconst y = Math.min( sampler.height - 1, Math.max( 0, Math.floor( _uv.y * sampler.height ) ) );\n\tconst i = ( y * sampler.width + x ) * 4;\n\tconst data = sampler.data;\n\n\tif ( sampler.srgb ) {\n\n\t\ttarget.setRGB( _srgbLUT[ data[ i ] ], _srgbLUT[ data[ i + 1 ] ], _srgbLUT[ data[ i + 2 ] ] );\n\n\t} else {\n\n\t\ttarget.setRGB( data[ i ] / 255, data[ i + 1 ] / 255, data[ i + 2 ] / 255 );\n\n\t}\n\n\treturn data[ i + 3 ] / 255;\n\n}\n\nfunction getMaterialInfo( material, cache, imageCache ) {\n\n\tif ( cache.has( material ) ) return cache.get( material );\n\n\tconst unlit = material.isMeshBasicMaterial === true || material.isMeshBasicNodeMaterial === true;\n\n\tconst info = {\n\t\tunlit,\n\t\tside: material.side === BackSide ? 1 : ( material.side === DoubleSide ? 2 : 0 ),\n\t\topacity: material.transparent === true ? material.opacity : 1,\n\t\talphaTest: material.alphaTest || 0,\n\t\tcolor: material.color ? material.color : null,\n\t\temissive: ( ! unlit && material.emissive ) ? material.emissive : null,\n\t\temissiveIntensity: material.emissiveIntensity !== undefined ? material.emissiveIntensity : 1,\n\t\tmap: null,\n\t\tmapSampler: null,\n\t\temissiveMap: null,\n\t\temissiveMapSampler: null\n\t};\n\n\tif ( material.map && material.map.isTexture ) {\n\n\t\tinfo.mapSampler = getImageSampler( material.map, imageCache );\n\t\tif ( info.mapSampler !== null ) info.map = material.map;\n\n\t}\n\n\tif ( ! unlit && material.emissiveMap && material.emissiveMap.isTexture ) {\n\n\t\tinfo.emissiveMapSampler = getImageSampler( material.emissiveMap, imageCache );\n\t\tif ( info.emissiveMapSampler !== null ) info.emissiveMap = material.emissiveMap;\n\n\t}\n\n\t// the uv transform is normally updated by the renderer\n\n\tif ( info.map !== null && info.map.matrixAutoUpdate === true ) info.map.updateMatrix();\n\tif ( info.emissiveMap !== null && info.emissiveMap.matrixAutoUpdate === true ) info.emissiveMap.updateMatrix();\n\n\tcache.set( material, info );\n\n\treturn info;\n\n}\n\n/**\n * Returns `true` if the object should contribute geometry to the voxel volume.\n *\n * @private\n */\nfunction isVoxelizable( object, layers, exclude ) {\n\n\treturn object.isMesh === true && object.isSkyMesh !== true && object.isBatchedMesh !== true &&\n\t\tlayers.test( object.layers ) === true && exclude.has( object ) === false && object.geometry !== undefined;\n\n}\n\n/**\n * Computes the world-space bounding box of all voxelizable meshes.\n *\n * @param {Scene} scene - The scene.\n * @param {Layers} layers - Only objects that pass the layer test are considered.\n * @param {Set<Object3D>} exclude - Objects to skip.\n * @param {Box3} target - The target box.\n * @return {Box3} The bounding box.\n */\nexport function computeSceneBounds( scene, layers, exclude, target ) {\n\n\ttarget.makeEmpty();\n\n\tscene.traverseVisible( ( object ) => {\n\n\t\tif ( isVoxelizable( object, layers, exclude ) ) {\n\n\t\t\ttarget.expandByObject( object, true );\n\n\t\t}\n\n\t} );\n\n\treturn target;\n\n}\n\n/**\n * Collects the triangles of all meshes in the scene as flat, world-space records suitable\n * for GPU voxelization. Per-triangle albedo and emissive colors are resolved on the CPU\n * (material color multiplied with a texture lookup at the triangle's centroid). Large\n * triangles are subdivided so every record covers a bounded number of voxels.\n *\n * @param {Scene} scene - The scene.\n * @param {Object} options - Options.\n * @param {Box3} options.bounds - Triangles outside these bounds are skipped.\n * @param {Layers} options.layers - Objects must pass this layer test.\n * @param {Set<Object3D>} options.exclude - Objects to skip.\n * @param {number} options.subVoxelSize - Size of a sub-voxel in world units.\n * @param {number} options.maxEdge - Maximum triangle edge length in sub-voxels before subdivision.\n * @param {number} options.minOpacity - Triangles with lower opacity are skipped.\n * @return {{data: Float32Array, count: number}} The triangle records and triangle count.\n */\nexport function collectSceneTriangles( scene, options ) {\n\n\tconst { bounds, layers, exclude, subVoxelSize, maxEdge, minOpacity } = options;\n\n\tconst materialCache = new Map();\n\tconst imageCache = new Map();\n\tconst buffer = new GrowableFloat32Array( 1024 * TRIANGLE_STRIDE );\n\n\tconst maxEdgeSq = ( maxEdge * subVoxelSize ) * ( maxEdge * subVoxelSize );\n\n\t// triangle emission with subdivision of large triangles\n\n\tconst stack = [];\n\n\tfunction emit( a, b, c, albedo, emissive, side ) {\n\n\t\tstack.push( a.x, a.y, a.z, b.x, b.y, b.z, c.x, c.y, c.z );\n\n\t\twhile ( stack.length > 0 ) {\n\n\t\t\tconst cz = stack.pop(), cy = stack.pop(), cx = stack.pop();\n\t\t\tconst bz = stack.pop(), by = stack.pop(), bx = stack.pop();\n\t\t\tconst az = stack.pop(), ay = stack.pop(), ax = stack.pop();\n\n\t\t\tconst abSq = ( bx - ax ) ** 2 + ( by - ay ) ** 2 + ( bz - az ) ** 2;\n\t\t\tconst bcSq = ( cx - bx ) ** 2 + ( cy - by ) ** 2 + ( cz - bz ) ** 2;\n\t\t\tconst caSq = ( ax - cx ) ** 2 + ( ay - cy ) ** 2 + ( az - cz ) ** 2;\n\t\t\tconst longest = Math.max( abSq, bcSq, caSq );\n\n\t\t\tif ( longest > maxEdgeSq ) {\n\n\t\t\t\t// split along the longest edge\n\n\t\t\t\tif ( longest === abSq ) {\n\n\t\t\t\t\tconst mx = ( ax + bx ) * 0.5, my = ( ay + by ) * 0.5, mz = ( az + bz ) * 0.5;\n\t\t\t\t\tstack.push( ax, ay, az, mx, my, mz, cx, cy, cz );\n\t\t\t\t\tstack.push( mx, my, mz, bx, by, bz, cx, cy, cz );\n\n\t\t\t\t} else if ( longest === bcSq ) {\n\n\t\t\t\t\tconst mx = ( bx + cx ) * 0.5, my = ( by + cy ) * 0.5, mz = ( bz + cz ) * 0.5;\n\t\t\t\t\tstack.push( ax, ay, az, bx, by, bz, mx, my, mz );\n\t\t\t\t\tstack.push( ax, ay, az, mx, my, mz, cx, cy, cz );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst mx = ( cx + ax ) * 0.5, my = ( cy + ay ) * 0.5, mz = ( cz + az ) * 0.5;\n\t\t\t\t\tstack.push( ax, ay, az, bx, by, bz, mx, my, mz );\n\t\t\t\t\tstack.push( mx, my, mz, bx, by, bz, cx, cy, cz );\n\n\t\t\t\t}\n\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tbuffer.ensure( TRIANGLE_STRIDE );\n\t\t\tbuffer.push4( ax, ay, az, 0 );\n\t\t\tbuffer.push4( bx, by, bz, 0 );\n\t\t\tbuffer.push4( cx, cy, cz, 0 );\n\t\t\tbuffer.push4( albedo.r, albedo.g, albedo.b, side );\n\t\t\tbuffer.push4( emissive.r, emissive.g, emissive.b, 0 );\n\n\t\t}\n\n\t}\n\n\tfunction processMesh( mesh, matrixWorld ) {\n\n\t\tconst geometry = mesh.geometry;\n\t\tconst positionAttribute = geometry.getAttribute( 'position' );\n\n\t\tif ( positionAttribute === undefined ) return;\n\n\t\tconst index = geometry.index;\n\t\tconst materials = Array.isArray( mesh.material ) ? mesh.material : [ mesh.material ];\n\t\tconst vertexCount = index !== null ? index.count : positionAttribute.count;\n\n\t\tlet groups = geometry.groups;\n\n\t\tif ( Array.isArray( mesh.material ) === false || groups.length === 0 ) {\n\n\t\t\tgroups = [ { start: 0, count: vertexCount, materialIndex: 0 } ];\n\n\t\t}\n\n\t\tconst drawRange = geometry.drawRange;\n\t\tconst rangeStart = drawRange.start;\n\t\tconst rangeEnd = Math.min( vertexCount, drawRange.start + drawRange.count );\n\n\t\tfor ( const group of groups ) {\n\n\t\t\tconst material = materials[ group.materialIndex ];\n\n\t\t\tif ( material === undefined || material === null || material.visible === false ) continue;\n\n\t\t\tconst info = getMaterialInfo( material, materialCache, imageCache );\n\n\t\t\tif ( info.opacity < minOpacity ) continue;\n\n\t\t\tconst uvAttribute = info.map !== null ? geometry.getAttribute( info.map.channel > 0 ? 'uv' + info.map.channel : 'uv' ) : null;\n\t\t\tconst emissiveUVAttribute = info.emissiveMap !== null ? geometry.getAttribute( info.emissiveMap.channel > 0 ? 'uv' + info.emissiveMap.channel : 'uv' ) : null;\n\n\t\t\tconst start = Math.max( group.start, rangeStart );\n\t\t\tconst end = Math.min( group.start + group.count, rangeEnd );\n\n\t\t\tfor ( let i = start; i + 2 < end; i += 3 ) {\n\n\t\t\t\tconst ia = index !== null ? index.getX( i ) : i;\n\t\t\t\tconst ib = index !== null ? index.getX( i + 1 ) : i + 1;\n\t\t\t\tconst ic = index !== null ? index.getX( i + 2 ) : i + 2;\n\n\t\t\t\t_va.fromBufferAttribute( positionAttribute, ia ).applyMatrix4( matrixWorld );\n\t\t\t\t_vb.fromBufferAttribute( positionAttribute, ib ).applyMatrix4( matrixWorld );\n\t\t\t\t_vc.fromBufferAttribute( positionAttribute, ic ).applyMatrix4( matrixWorld );\n\n\t\t\t\t// skip triangles outside the volume\n\n\t\t\t\t_box.makeEmpty().expandByPoint( _va ).expandByPoint( _vb ).expandByPoint( _vc );\n\n\t\t\t\tif ( bounds.intersectsBox( _box ) === false ) continue;\n\n\t\t\t\t// skip degenerate triangles\n\n\t\t\t\tif ( _box.min.distanceToSquared( _box.max ) < 1e-14 ) continue;\n\n\t\t\t\t// resolve colors\n\n\t\t\t\tlet alpha = info.opacity;\n\n\t\t\t\tif ( info.color !== null ) _albedo.copy( info.color ); else _albedo.setRGB( 1, 1, 1 );\n\n\t\t\t\tif ( uvAttribute !== undefined && uvAttribute !== null ) {\n\n\t\t\t\t\t_uva.fromBufferAttribute( uvAttribute, ia );\n\t\t\t\t\t_uvb.fromBufferAttribute( uvAttribute, ib );\n\t\t\t\t\t_uvc.fromBufferAttribute( uvAttribute, ic );\n\t\t\t\t\t_uva.add( _uvb ).add( _uvc ).multiplyScalar( 1 / 3 );\n\n\t\t\t\t\talpha *= sampleTexture( info.map, info.mapSampler, _uva, _color );\n\t\t\t\t\t_albedo.multiply( _color );\n\n\t\t\t\t}\n\n\t\t\t\tif ( info.alphaTest > 0 && alpha < info.alphaTest ) continue;\n\t\t\t\tif ( alpha < minOpacity ) continue;\n\n\t\t\t\tif ( info.unlit ) {\n\n\t\t\t\t\t_emissive.copy( _albedo );\n\t\t\t\t\t_albedo.setRGB( 0, 0, 0 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tif ( info.emissive !== null ) {\n\n\t\t\t\t\t\t_emissive.copy( info.emissive ).multiplyScalar( info.emissiveIntensity );\n\n\t\t\t\t\t\tif ( emissiveUVAttribute !== undefined && emissiveUVAttribute !== null ) {\n\n\t\t\t\t\t\t\t_uva.fromBufferAttribute( emissiveUVAttribute, ia );\n\t\t\t\t\t\t\t_uvb.fromBufferAttribute( emissiveUVAttribute, ib );\n\t\t\t\t\t\t\t_uvc.fromBufferAttribute( emissiveUVAttribute, ic );\n\t\t\t\t\t\t\t_uva.add( _uvb ).add( _uvc ).multiplyScalar( 1 / 3 );\n\n\t\t\t\t\t\t\tsampleTexture( info.emissiveMap, info.emissiveMapSampler, _uva, _color );\n\t\t\t\t\t\t\t_emissive.multiply( _color );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t_emissive.setRGB( 0, 0, 0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\temit( _va, _vb, _vc, _albedo, _emissive, info.side );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tscene.traverseVisible( ( object ) => {\n\n\t\tif ( isVoxelizable( object, layers, exclude ) === false ) return;\n\n\t\tif ( object.isInstancedMesh === true ) {\n\n\t\t\tfor ( let i = 0; i < object.count; i ++ ) {\n\n\t\t\t\tobject.getMatrixAt( i, _matrix );\n\t\t\t\t_matrix.premultiply( object.matrixWorld );\n\t\t\t\tprocessMesh( object, _matrix );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tprocessMesh( object, object.matrixWorld );\n\n\t\t}\n\n\t} );\n\n\tconst data = buffer.result();\n\n\treturn { data, count: data.length / TRIANGLE_STRIDE };\n\n}\n\n/**\n * Marks the sub-voxels inside closed meshes, so cones starting within an object are blocked. Only meshes\n * with visible, opaque and single-sided materials whose geometry is closed and faces outwards are filled.\n *\n * @param {Scene} scene - The scene.\n * @param {Object} options - Options.\n * @param {Vector3} options.boundsMin - The minimum corner of the voxel grid.\n * @param {number} options.voxelSize - The size of a voxel in world units.\n * @param {Vector3} options.gridSize - The number of voxels per axis.\n * @param {Layers} options.layers - Objects must pass this layer test.\n * @param {Set<Object3D>} options.exclude - Objects to skip.\n * @param {Uint8Array} target - One byte per voxel that receives the 2x2x2 sub-voxel bits of the interiors.\n */\nexport function computeSolidVoxels( scene, options, target ) {\n\n\tconst { boundsMin, voxelSize, gridSize, layers, exclude } = options;\n\n\tconst closedGeometries = new Map();\n\n\tscene.traverseVisible( ( object ) => {\n\n\t\tif ( isVoxelizable( object, layers, exclude ) === false || hasSolidMaterials( object ) === false ) return;\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( closedGeometries.has( geometry ) === false ) closedGeometries.set( geometry, isClosed( geometry ) && facesOutwards( geometry ) );\n\n\t\tif ( closedGeometries.get( geometry ) === false ) return;\n\n\t\tif ( object.isInstancedMesh === true ) {\n\n\t\t\tfor ( let i = 0; i < object.count; i ++ ) {\n\n\t\t\t\tobject.getMatrixAt( i, _matrix );\n\t\t\t\t_matrix.premultiply( object.matrixWorld );\n\t\t\t\tfillInterior( geometry, _matrix, boundsMin, voxelSize, gridSize, target );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tfillInterior( geometry, object.matrixWorld, boundsMin, voxelSize, gridSize, target );\n\n\t\t}\n\n\t} );\n\n}\n\n/**\n * Returns `true` if all materials of the mesh render an opaque, single-sided surface.\n *\n * @private\n */\nfunction hasSolidMaterials( mesh ) {\n\n\tconst materials = Array.isArray( mesh.material ) ? mesh.material : [ mesh.material ];\n\n\tfor ( const material of materials ) {\n\n\t\tif ( material.visible === false || material.side !== FrontSide || material.transparent === true || material.alphaTest > 0 ) return false;\n\n\t}\n\n\treturn true;\n\n}\n\n/**\n * Returns `true` if every edge of the geometry is shared by an even number of triangles. Vertices with\n * the same position (e.g. at uv seams) are treated as one vertex.\n *\n * @private\n */\nfunction isClosed( geometry ) {\n\n\tconst position = geometry.getAttribute( 'position' );\n\n\tif ( position === undefined ) return false;\n\n\tconst index = geometry.index;\n\tconst indices = index !== null ? index.array : null;\n\tconst count = index !== null ? index.count : position.count;\n\n\t_box.setFromBufferAttribute( position );\n\n\tconst min = _box.min;\n\tconst size = _box.getSize( _vb );\n\tconst scaleX = POSITION_QUANTIZATION / Math.max( size.x, 1e-9 );\n\tconst scaleY = POSITION_QUANTIZATION / Math.max( size.y, 1e-9 );\n\tconst scaleZ = POSITION_QUANTIZATION / Math.max( size.z, 1e-9 );\n\n\tconst vertexMask = MathUtils.ceilPowerOfTwo( Math.max( position.count, 1 ) * 2 ) - 1;\n\tconst vertexKeys = new Int32Array( ( vertexMask + 1 ) * 3 );\n\tconst vertexSlots = new Int32Array( vertexMask + 1 ).fill( - 1 );\n\tconst vertexIds = new Int32Array( position.count );\n\tlet vertexCount = 0;\n\n\tfor ( let i = 0; i < position.count; i ++ ) {\n\n\t\tconst x = Math.round( ( position.getX( i ) - min.x ) * scaleX );\n\t\tconst y = Math.round( ( position.getY( i ) - min.y ) * scaleY );\n\t\tconst z = Math.round( ( position.getZ( i ) - min.z ) * scaleZ );\n\n\t\tlet slot = ( Math.imul( x, 73856093 ) ^ Math.imul( y, 19349663 ) ^ Math.imul( z, 83492791 ) ) & vertexMask;\n\n\t\twhile ( vertexSlots[ slot ] !== - 1 && ( vertexKeys[ slot * 3 ] !== x || vertexKeys[ slot * 3 + 1 ] !== y || vertexKeys[ slot * 3 + 2 ] !== z ) ) slot = ( slot + 1 ) & vertexMask;\n\n\t\tif ( vertexSlots[ slot ] === - 1 ) {\n\n\t\t\tvertexSlots[ slot ] = vertexCount ++;\n\t\t\tvertexKeys[ slot * 3 ] = x;\n\t\t\tvertexKeys[ slot * 3 + 1 ] = y;\n\t\t\tvertexKeys[ slot * 3 + 2 ] = z;\n\n\t\t}\n\n\t\tvertexIds[ i ] = vertexSlots[ slot ];\n\n\t}\n\n\tconst edgeMask = MathUtils.ceilPowerOfTwo( Math.max( count, 1 ) * 2 ) - 1;\n\tconst edgeKeys = new Int32Array( ( edgeMask + 1 ) * 2 ).fill( - 1 );\n\tconst edgeParity = new Uint8Array( edgeMask + 1 );\n\tlet openEdges = 0;\n\n\tconst toggleEdge = ( a, b ) => {\n\n\t\tif ( a > b ) {\n\n\t\t\tconst t = a; a = b; b = t;\n\n\t\t}\n\n\t\tlet slot = ( Math.imul( a, 73856093 ) ^ Math.imul( b, 19349663 ) ) & edgeMask;\n\n\t\twhile ( edgeKeys[ slot * 2 ] !== - 1 && ( edgeKeys[ slot * 2 ] !== a || edgeKeys[ slot * 2 + 1 ] !== b ) ) slot = ( slot + 1 ) & edgeMask;\n\n\t\tedgeKeys[ slot * 2 ] = a;\n\t\tedgeKeys[ slot * 2 + 1 ] = b;\n\t\tedgeParity[ slot ] ^= 1;\n\t\topenEdges += edgeParity[ slot ] === 1 ? 1 : - 1;\n\n\t};\n\n\tfor ( let i = 0; i + 2 < count; i += 3 ) {\n\n\t\tconst a = vertexIds[ indices !== null ? indices[ i ] : i ];\n\t\tconst b = vertexIds[ indices !== null ? indices[ i + 1 ] : i + 1 ];\n\t\tconst c = vertexIds[ indices !== null ? indices[ i + 2 ] : i + 2 ];\n\n\t\tif ( a === b || b === c || c === a ) continue;\n\n\t\ttoggleEdge( a, b );\n\t\ttoggleEdge( b, c );\n\t\ttoggleEdge( c, a );\n\n\t}\n\n\treturn openEdges === 0;\n\n}\n\n/**\n * Returns `true` if the triangles of the given closed geometry face outwards (positive signed volume).\n *\n * @private\n */\nfunction facesOutwards( geometry ) {\n\n\tconst position = geometry.getAttribute( 'position' );\n\tconst index = geometry.index;\n\tconst indices = index !== null ? index.array : null;\n\tconst count = index !== null ? index.count : position.count;\n\n\t_box.min.fromBufferAttribute( position, 0 );\n\n\tlet volume = 0;\n\n\tfor ( let i = 0; i + 2 < count; i += 3 ) {\n\n\t\t_va.fromBufferAttribute( position, indices !== null ? indices[ i ] : i ).sub( _box.min );\n\t\t_vb.fromBufferAttribute( position, indices !== null ? indices[ i + 1 ] : i + 1 ).sub( _box.min );\n\t\t_vc.fromBufferAttribute( position, indices !== null ? indices[ i + 2 ] : i + 2 ).sub( _box.min );\n\n\t\tvolume += _va.dot( _vb.cross( _vc ) );\n\n\t}\n\n\treturn volume > 0;\n\n}\n\n/**\n * Marks the sub-voxels between pairs of surface crossings along each sub-voxel column in x.\n *\n * @private\n */\nfunction fillInterior( geometry, matrix, boundsMin, voxelSize, gridSize, target ) {\n\n\tconst position = geometry.getAttribute( 'position' );\n\tconst index = geometry.index;\n\tconst count = index !== null ? index.count : position.count;\n\n\tconst invSubVoxel = 2 / voxelSize;\n\tconst columnsY = gridSize.y * 2, columnsZ = gridSize.z * 2, length = gridSize.x * 2;\n\n\t_columns.clear();\n\n\tfor ( let i = 0; i + 2 < count; i += 3 ) {\n\n\t\tconst a = _va.fromBufferAttribute( position, index !== null ? index.getX( i ) : i ).applyMatrix4( matrix ).sub( boundsMin ).multiplyScalar( invSubVoxel );\n\t\tlet b = _vb.fromBufferAttribute( position, index !== null ? index.getX( i + 1 ) : i + 1 ).applyMatrix4( matrix ).sub( boundsMin ).multiplyScalar( invSubVoxel );\n\t\tlet c = _vc.fromBufferAttribute( position, index !== null ? index.getX( i + 2 ) : i + 2 ).applyMatrix4( matrix ).sub( boundsMin ).multiplyScalar( invSubVoxel );\n\n\t\tconst area = edgeFunction( a, b, c.y, c.z );\n\n\t\tif ( area === 0 ) continue;\n\n\t\tif ( area < 0 ) {\n\n\t\t\tconst t = b; b = c; c = t;\n\n\t\t}\n\n\t\tconst j0 = Math.max( Math.ceil( Math.min( a.y, b.y, c.y ) - 0.5 ), 0 );\n\t\tconst j1 = Math.min( Math.floor( Math.max( a.y, b.y, c.y ) - 0.5 ), columnsY - 1 );\n\t\tconst k0 = Math.max( Math.ceil( Math.min( a.z, b.z, c.z ) - 0.5 ), 0 );\n\t\tconst k1 = Math.min( Math.floor( Math.max( a.z, b.z, c.z ) - 0.5 ), columnsZ - 1 );\n\n\t\tfor ( let k = k0; k <= k1; k ++ ) {\n\n\t\t\tfor ( let j = j0; j <= j1; j ++ ) {\n\n\t\t\t\tconst y = j + 0.5, z = k + 0.5;\n\n\t\t\t\tconst wa = edgeFunction( b, c, y, z );\n\t\t\t\tconst wb = edgeFunction( c, a, y, z );\n\t\t\t\tconst wc = edgeFunction( a, b, y, z );\n\n\t\t\t\tif ( isInside( wa, b, c ) && isInside( wb, c, a ) && isInside( wc, a, b ) ) {\n\n\t\t\t\t\tconst column = j + k * columnsY;\n\t\t\t\t\tlet crossings = _columns.get( column );\n\n\t\t\t\t\tif ( crossings === undefined ) {\n\n\t\t\t\t\t\tcrossings = [];\n\t\t\t\t\t\t_columns.set( column, crossings );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcrossings.push( ( wa * a.x + wb * b.x + wc * c.x ) / ( wa + wb + wc ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfor ( const [ column, crossings ] of _columns ) {\n\n\t\tif ( crossings.length % 2 !== 0 ) continue;\n\n\t\tcrossings.sort( ( p, q ) => p - q );\n\n\t\tconst j = column % columnsY, k = ( column - j ) / columnsY;\n\t\tconst offset = gridSize.x * ( ( j >> 1 ) + gridSize.y * ( k >> 1 ) );\n\t\tconst bitsYZ = ( ( j & 1 ) << 1 ) | ( ( k & 1 ) << 2 );\n\n\t\tfor ( let n = 0; n < crossings.length; n += 2 ) {\n\n\t\t\tconst i0 = Math.max( Math.ceil( crossings[ n ] - 0.5 ), 0 );\n\t\t\tconst i1 = Math.min( Math.ceil( crossings[ n + 1 ] - 0.5 ), length );\n\n\t\t\tfor ( let i = i0; i < i1; i ++ ) target[ offset + ( i >> 1 ) ] |= 1 << ( ( i & 1 ) | bitsYZ );\n\n\t\t}\n\n\t}\n\n}\n\n/**\n * Edge function of the edge from `a` to `b` at the given point in the yz plane. As in the watertight\n * ray/triangle test, the vertices are taken relative to the point, so a shared edge evaluates exactly\n * opposite for both of its triangles.\n *\n * @private\n */\nfunction edgeFunction( a, b, y, z ) {\n\n\treturn ( a.y - y ) * ( b.z - z ) - ( a.z - z ) * ( b.y - y );\n\n}\n\n/**\n * Inside test for an edge function value. Points on an edge belong to one triangle only (top-left rule).\n *\n * @private\n */\nfunction isInside( w, a, b ) {\n\n\tif ( w !== 0 ) return w > 0;\n\n\tconst dz = b.z - a.z;\n\n\treturn dz < 0 || ( dz === 0 && b.y > a.y );\n\n}\n","import { float, vec3, vec4, If, Loop, Break, max, min, abs, dot, cross, normalize, clamp, log2, exp2, fract, sqrt, cos, sin, select, EPSILON, PI } from 'three/tsl';\n\n/**\n * Emits the intersection of a ray with the bounds of the given volume.\n *\n * @param {VXGIVolume} volume - The volume.\n * @param {Node<vec3>} origin - The ray origin.\n * @param {Node<vec3>} direction - The normalized ray direction.\n * @return {{tEnter: Node<float>, tExit: Node<float>}} The entry and exit distances. The ray misses the volume if `tExit <= tEnter`.\n */\nexport function intersectVolume( volume, origin, direction ) {\n\n\tconst boundsMin = volume.boundsMinNode;\n\tconst boundsMax = boundsMin.add( volume.volumeSizeNode ).toConst();\n\n\tconst safeDirection = vec3(\n\t\tselect( abs( direction.x ).lessThan( EPSILON ), EPSILON, direction.x ),\n\t\tselect( abs( direction.y ).lessThan( EPSILON ), EPSILON, direction.y ),\n\t\tselect( abs( direction.z ).lessThan( EPSILON ), EPSILON, direction.z )\n\t).toConst();\n\n\tconst invDirection = float( 1 ).div( safeDirection ).toConst();\n\tconst t0 = boundsMin.sub( origin ).mul( invDirection ).toConst();\n\tconst t1 = boundsMax.sub( origin ).mul( invDirection ).toConst();\n\tconst tNear = min( t0, t1 ).toConst();\n\tconst tFar = max( t0, t1 ).toConst();\n\n\tconst tEnter = max( max( tNear.x, tNear.y ), max( tNear.z, 0 ) ).toConst();\n\tconst tExit = min( min( tFar.x, tFar.y ), tFar.z ).toConst();\n\n\treturn { tEnter, tExit };\n\n}\n\n/**\n * Emits a directional radiance lookup: for each axis the direction block facing the ray is\n * sampled from the directional texture and the three samples are blended with the squared\n * direction components. The block is selected arithmetically, so the lookup does not branch.\n *\n * @param {VXGIVolume} volume - The volume.\n * @param {Texture3DNode} directionalNode - The directional radiance texture node.\n * @param {Node<vec3>} uvw - The texture coordinates within the volume.\n * @param {Node<float>} level - The mip level of the directional texture.\n * @param {Node<vec3>} direction - The normalized ray direction.\n * @return {Node<vec4>} The premultiplied radiance and its weight.\n */\nexport function sampleDirectional( volume, directionalNode, uvw, level, direction ) {\n\n\tconst weights = direction.mul( direction ).toConst();\n\n\t// keep the lookup inside its block: clamp x by half a texel of the coarser blended level\n\n\tconst halfTexel = exp2( level.ceil() ).mul( 0.5 ).div( volume.directionalWidthNode ).toConst();\n\tconst u = uvw.x.clamp( halfTexel, halfTexel.oneMinus() ).toConst();\n\n\tconst result = vec4( 0 ).toVar();\n\n\tfor ( let axis = 0; axis < 3; axis ++ ) {\n\n\t\tconst component = [ 'x', 'y', 'z' ][ axis ];\n\t\tconst block = float( axis * 2 ).add( select( direction[ component ].lessThan( 0 ), 1, 0 ) );\n\t\tconst blockUVW = vec3( block.add( u ).div( 6 ), uvw.y, uvw.z );\n\n\t\tresult.addAssign( directionalNode.sample( blockUVW ).level( level ).mul( weights[ component ] ) );\n\n\t}\n\n\treturn result;\n\n}\n\n/**\n * Creates a cone tracing function for a {@link VXGIVolume}. The returned function emits\n * TSL code that marches a cone through the volume's opacity/radiance mip chain and returns the\n * gathered radiance, the accumulated occlusion and a distance-weighted occlusion for AO.\n *\n * Implements the approximate voxel cone tracing of Crassin et al. 2011: the cone is sampled at\n * the mip level matching its current diameter with quadrilinear interpolation, samples are\n * composited front-to-back with the emission-absorption model, the opacity of a sample is\n * corrected for the step size and the anisotropic opacity (and, if given, the directional\n * radiance) is interpolated from the three directional values closest to the cone direction.\n * Cones leaving the volume gather nothing.\n *\n * @param {VXGIVolume} volume - The volume to trace.\n * @param {Object} [options={}] - Options.\n * @param {?TextureNode} [options.radianceNode=null] - The radiance texture node to gather from. If `null`, only occlusion is computed.\n * @param {?Texture3DNode} [options.directionalNode=null] - The directional radiance texture node of the coarser levels, see {@link VXGIVolume#directionalRadiance}. If `null`, the coarser levels are gathered from the radiance node's mips.\n * @param {number} [options.maxSteps=128] - Upper bound of steps per cone.\n * @return {Function} A function `( origin, direction, tanHalfAngle, maxDistance, aoDistance = null ) => { color, alpha, ao }`. AO is only computed if `aoDistance` is given.\n */\nexport function createConeTracer( volume, options = {} ) {\n\n\tconst { radianceNode = null, directionalNode = null, maxSteps = 128 } = options;\n\n\tconst opacityNode = volume.opacityNode;\n\tconst boundsMin = volume.boundsMinNode;\n\tconst volumeSize = volume.volumeSizeNode;\n\tconst voxelSize = volume.voxelSizeNode;\n\tconst maxLevel = volume.maxLevelNode;\n\tconst stepScale = volume.stepScale;\n\n\treturn ( origin, direction, tanHalfAngle, maxDistance, aoDistance = null ) => {\n\n\t\tconst color = vec3( 0 ).toVar();\n\t\tconst alpha = float( 0 ).toVar();\n\t\tconst ao = float( 0 ).toVar();\n\n\t\tconst { tEnter, tExit } = intersectVolume( volume, origin, direction );\n\n\t\t// cones start one voxel away from their origin so the voxels the origin lies in are not sampled\n\n\t\tconst t = max( tEnter, voxelSize ).toVar();\n\t\tconst limit = min( tExit, maxDistance ).toConst();\n\n\t\t// interpolation weights of the three directional opacity values (sum to one)\n\n\t\tconst directionWeights = direction.mul( direction ).toConst();\n\n\t\t// AO falloff 1 / ( 1 + r / aoDistance )\n\n\t\tconst aoFalloff = aoDistance !== null ? select( aoDistance.greaterThan( 0 ), float( 1 ).div( max( aoDistance, EPSILON ) ), float( 0 ) ).toConst() : null;\n\n\t\tIf( tExit.greaterThan( t ), () => {\n\n\t\t\tLoop( { start: 0, end: maxSteps, type: 'int', condition: '<', name: 's' }, () => {\n\n\t\t\t\tIf( t.greaterThanEqual( limit ).or( alpha.greaterThanEqual( 0.98 ) ), () => {\n\n\t\t\t\t\tBreak();\n\n\t\t\t\t} );\n\n\t\t\t\tconst diameter = max( t.mul( 2 ).mul( tanHalfAngle ), voxelSize ).toConst();\n\t\t\t\tconst lod = clamp( log2( diameter.div( voxelSize ) ), 0, maxLevel ).toConst();\n\t\t\t\tconst position = origin.add( direction.mul( t ) ).toConst();\n\t\t\t\tconst uvw = position.sub( boundsMin ).div( volumeSize ).toConst();\n\n\t\t\t\tconst opacity = opacityNode.sample( uvw ).level( lod ).toConst();\n\n\t\t\t\t// directional opacity, corrected for a step that is a fraction of the texel size\n\n\t\t\t\tconst a = clamp( dot( opacity.xyz, directionWeights ), 0, 1 ).oneMinus().pow( stepScale ).oneMinus().toConst();\n\t\t\t\tconst weight = a.mul( alpha.oneMinus() ).toConst();\n\n\t\t\t\tif ( radianceNode !== null ) {\n\n\t\t\t\t\tlet radiance;\n\n\t\t\t\t\tif ( directionalNode === null ) {\n\n\t\t\t\t\t\tradiance = radianceNode.sample( uvw ).level( lod ).toConst();\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// the finest level is isotropic, coarser levels are stored directionally at half\n\t\t\t\t\t\t// resolution; their weight only counts the surfaces facing the ray\n\n\t\t\t\t\t\tradiance = vec4( 0 ).toVar();\n\n\t\t\t\t\t\tIf( lod.lessThan( 1 ), () => {\n\n\t\t\t\t\t\t\tradiance.assign( radianceNode.sample( uvw ).level( float( 0 ) ) );\n\n\t\t\t\t\t\t} ).Else( () => {\n\n\t\t\t\t\t\t\tradiance.assign( sampleDirectional( volume, directionalNode, uvw, lod.sub( 1 ), direction ) );\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcolor.addAssign( radiance.rgb.div( max( radiance.a, 1e-4 ) ).mul( weight ) );\n\n\t\t\t\t}\n\n\t\t\t\talpha.addAssign( weight );\n\n\t\t\t\tif ( aoFalloff !== null ) {\n\n\t\t\t\t\tao.addAssign( a.mul( ao.oneMinus() ).div( t.mul( aoFalloff ).add( 1 ) ) );\n\n\t\t\t\t}\n\n\t\t\t\tt.addAssign( voxelSize.mul( exp2( lod ) ).mul( stepScale ) );\n\n\t\t\t} );\n\n\t\t} );\n\n\t\treturn { color, alpha, ao };\n\n\t};\n\n}\n\n/**\n * Emits a diffuse gather: Traces stratified cosine-weighted cones around the normal and averages them.\n *\n * @param {Function} trace - The cone tracing function, see {@link createConeTracer}.\n * @param {Node<vec3>} origin - The origin of the cones.\n * @param {Node<vec3>} normal - The normalized surface normal.\n * @param {Node<uint>|number} coneCount - The number of cones.\n * @param {Node<float>} tanHalfAngle - The tangent of half the cone angle.\n * @param {Node<float>} maxDistance - The maximum trace distance.\n * @param {Node<float>|number} rotation - Rotation of the cones around the normal in `[0, 1)`.\n * @param {Node<float>|number} elevation - Offset of the cones within their elevation strata in `[0, 1)`.\n * @param {?Node<float>} [aoDistance=null] - The AO falloff distance. AO is only computed if given.\n * @return {{color: Node<vec3>, ao: Node<float>}} The mean radiance and the mean AO of the cones.\n */\nexport function gather( trace, origin, normal, coneCount, tanHalfAngle, maxDistance, rotation, elevation, aoDistance = null ) {\n\n\t// tangent frame\n\n\tconst up = select( abs( normal.y ).lessThan( 0.99 ), vec3( 0, 1, 0 ), vec3( 1, 0, 0 ) );\n\tconst tangent = normalize( cross( normal, up ) ).toConst();\n\tconst bitangent = cross( normal, tangent ).toConst();\n\n\tconst color = vec3( 0 ).toVar();\n\tconst ao = float( 0 ).toVar();\n\n\tLoop( { start: 0, end: coneCount, type: 'uint', condition: '<', name: 'c' }, ( { c } ) => {\n\n\t\t// stratified cosine-weighted directions\n\n\t\tconst u1 = float( c ).add( elevation ).div( float( coneCount ) ).toConst();\n\t\tconst u2 = fract( float( c ).mul( 0.618034 ).add( rotation ) ).toConst();\n\t\tconst sinTheta = sqrt( u1 ).toConst();\n\t\tconst cosTheta = sqrt( u1.oneMinus() ).toConst();\n\t\tconst phi = u2.mul( PI.mul( 2 ) ).toConst();\n\n\t\tconst direction = normalize( tangent.mul( cos( phi ).mul( sinTheta ) ).add( bitangent.mul( sin( phi ).mul( sinTheta ) ) ).add( normal.mul( cosTheta ) ) ).toConst();\n\n\t\tconst cone = trace( origin, direction, tanHalfAngle, maxDistance, aoDistance );\n\n\t\tcolor.addAssign( cone.color );\n\n\t\tif ( aoDistance !== null ) ao.addAssign( cone.ao );\n\n\t} );\n\n\treturn { color: color.div( float( coneCount ) ), ao: ao.div( float( coneCount ) ) };\n\n}\n","import { Box3, Vector3, Vector4, Matrix4, Layers, Storage3DTexture, StorageBufferAttribute, StorageTexture3DNode, RendererUtils, HalfFloatType, UnsignedByteType, RGBAFormat, LinearFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping, MathUtils } from 'three/webgpu';\nimport { Fn, If, Loop, uniform, uniformArray, storage, instanceIndex, textureStore, texture3D, texture, cubeTexture, float, int, uint, vec2, vec3, vec4, ivec3, uvec3, max, min, abs, dot, cross, normalize, floor, sign, select, countOneBits, atomicOr, smoothstep, hash, length, PI, getDistanceAttenuation, viewZToPerspectiveDepth, viewZToReversedPerspectiveDepth } from 'three/tsl';\n\nimport { collectSceneTriangles, computeSceneBounds, computeSolidVoxels, TRIANGLE_STRIDE } from './VXGISceneCollector.js';\nimport { createConeTracer, gather } from './VXGIConeTracer.js';\n\nconst _box = /*@__PURE__*/ new Box3();\nconst _size = /*@__PURE__*/ new Vector3();\nconst _position = /*@__PURE__*/ new Vector3();\nconst _target = /*@__PURE__*/ new Vector3();\n\nconst MAX_EDGE_SUBVOXELS = 16;\nconst BOUNCE_CONE_COUNT = 8;\n\n// the six directions a ray can travel, as (axis, sign) pairs\n\nconst DIRECTIONS = [[ 0, 1 ], [ 0, - 1 ], [ 1, 1 ], [ 1, - 1 ], [ 2, 1 ], [ 2, - 1 ]];\n\nlet _rendererState;\n\n/**\n * Storage texture node bound to a single mip level. Texture nodes normally share one binding\n * per texture; this node keys the binding by access and mip level so a kernel can read one\n * level while writing another.\n *\n * @private\n */\nclass MipStorageTexture3DNode extends StorageTexture3DNode {\n\n\tconstructor( value, access, mipLevel ) {\n\n\t\tsuper( value, null, null );\n\n\t\tthis.setAccess( access );\n\t\tthis.setMipLevel( mipLevel );\n\n\t}\n\n\tgetUniformHash() {\n\n\t\treturn `${ this.value.uuid }:${ this.access }:${ this.mipLevel }`;\n\n\t}\n\n}\n\n/**\n * Holds the voxel representation of a scene for {@link VXGINode}: an anisotropic opacity\n * mip chain, a direct radiance volume and a radiance volume with cached bounces.\n *\n * The representation is a dense variant of the pre-filtered voxel hierarchy of Crassin et al. 2011\n * (a dense mip chain instead of a sparse octree, which keeps cone samples to two texture fetches):\n * opacity stores visibility per major axis and is filtered directionally (volumetric integration\n * along the axis, averaging across it), radiance is stored opacity-premultiplied and indirect bounces\n * are cached in the volume via cone tracing. Only direct lights are injected.\n * Voxelization uses conservative rasterization along the dominant triangle axis in a compute shader.\n * The interiors of closed meshes are filled, so cones starting inside an object (e.g. near contact\n * points) are blocked.\n *\n * Direct light is injected per voxel instead of splatting photons from a light-view map as in the\n * paper: the shadow maps rendered by the renderer are the light-view maps, and every occupied voxel\n * pulls its visibility from them (2D maps for directional and spot lights, cube maps for point\n * lights) and evaluates its irradiance analytically. This reuses the existing shadow passes, makes\n * the injected shadows match the direct lighting exactly and needs neither atomics nor a\n * normalization by photon density. Lights without a shadow map fall back to a visibility cone\n * traced through the volume. The trade-off is a cost proportional to the number of occupied voxels\n * times lights rather than to the light-view resolution, and that only outgoing diffuse radiance\n * is stored (no incoming direction distribution for glossy cones).\n *\n * References:\n * - {@link https://research.nvidia.com/publication/2011-09_interactive-indirect-illumination-using-voxel-cone-tracing}:\n * Crassin et al., Interactive Indirect Illumination Using Voxel Cone Tracing, Pacific Graphics 2011.\n * - {@link https://developer.nvidia.com/content/basics-gpu-voxelization}: Basics of GPU voxelization.\n * - {@link https://doi.org/10.1145/1882261.1866201}: Schwarz and Seidel, Fast Parallel Surface and Solid\n * Voxelization on GPUs, ACM Transactions on Graphics 2010.\n *\n * Note: This class can only be used with `WebGPURenderer` and a WebGPU backend.\n *\n * @three_import import { VXGIVolume } from 'three/addons/lighting/vxgi/VXGIVolume.js';\n */\nclass VXGIVolume {\n\n\t/**\n\t * Constructs a new volume.\n\t *\n\t * @param {number} [resolution=128] - Number of voxels along the longest axis of the bounds. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer.\n\t */\n\tconstructor( resolution = 128 ) {\n\n\t\t/**\n\t\t * Number of voxels along the longest axis of the bounds. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 128\n\t\t */\n\t\tthis.resolution = resolution;\n\n\t\t/**\n\t\t * The requested world-space bounds of the volume. If empty (the default), the bounds are\n\t\t * computed from the scene at voxelization. See {@link VXGIVolume#worldBounds} for the\n\t\t * effective bounds.\n\t\t *\n\t\t * @type {Box3}\n\t\t */\n\t\tthis.bounds = new Box3();\n\n\t\t/**\n\t\t * The effective world-space bounds of the voxel grid, updated at voxelization.\n\t\t *\n\t\t * @type {Box3}\n\t\t * @readonly\n\t\t */\n\t\tthis.worldBounds = new Box3();\n\n\t\t/**\n\t\t * Only meshes that pass this layer test are voxelized.\n\t\t *\n\t\t * @type {Layers}\n\t\t */\n\t\tthis.layers = new Layers();\n\n\t\t/**\n\t\t * Number of cached indirect bounces stored in the volume. Should be in the range `[0, 2]`.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 1\n\t\t */\n\t\tthis.bounces = 1;\n\n\t\t/**\n\t\t * Triangles with a lower opacity are not voxelized.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0.1\n\t\t */\n\t\tthis.minOpacity = 0.1;\n\n\t\t/**\n\t\t * Whether the coarser radiance levels are filtered directionally: along each axis the finer\n\t\t * voxels are composited front to back using their surface normals, so a cone only gathers\n\t\t * the surfaces facing it. This reduces light bleeding through thin walls and floors (e.g. a\n\t\t * sunlit floor brightening the ceiling of the room below) at the cost of additional memory\n\t\t * and a more expensive radiance lookup. Changing it triggers a re-voxelization.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.directionalRadiance = false;\n\n\t\t/**\n\t\t * Maximum number of lights injected into the volume.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 8\n\t\t */\n\t\tthis.maxLights = 8;\n\n\t\t/**\n\t\t * Set to `true` to re-voxelize the scene in the next update.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsUpdate = true;\n\n\t\t/**\n\t\t * Set to `true` to re-inject lighting in the next update. Changes of the lights and of the\n\t\t * injection parameters are detected automatically, so this is rarely needed.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.lightingNeedsUpdate = true;\n\n\t\t/**\n\t\t * Maximum cone length in world units. `0` means unbounded.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0\n\t\t */\n\t\tthis.maxDistance = uniform( 0 );\n\n\t\t/**\n\t\t * Step size relative to the texel size of the sampled mip level.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0.5\n\t\t */\n\t\tthis.stepScale = uniform( 0.5 );\n\n\t\t/**\n\t\t * Aperture in degrees of the visibility cones traced towards lights that do not provide a\n\t\t * shadow map. Wider cones are cheaper but soften the injected shadows.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 10\n\t\t */\n\t\tthis.shadowConeAngle = uniform( 10 );\n\n\t\t/**\n\t\t * Aperture of the cones used for the cached bounces in degrees.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 60\n\t\t */\n\t\tthis.bounceConeAngle = uniform( 60 );\n\n\t\t/**\n\t\t * The minimum corner of the volume.\n\t\t *\n\t\t * @type {UniformNode<vec3>}\n\t\t */\n\t\tthis.boundsMinNode = uniform( new Vector3() );\n\n\t\t/**\n\t\t * The size of the volume.\n\t\t *\n\t\t * @type {UniformNode<vec3>}\n\t\t */\n\t\tthis.volumeSizeNode = uniform( new Vector3( 1, 1, 1 ) );\n\n\t\t/**\n\t\t * The size of a voxel.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.voxelSizeNode = uniform( 1 );\n\n\t\t/**\n\t\t * The highest valid mip level of the voxel textures.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.maxLevelNode = uniform( 0 );\n\n\t\t/**\n\t\t * The per-axis opacity of the scene (`xyz`) and the occupancy (`w`) as a mip chain.\n\t\t *\n\t\t * @type {Storage3DTexture}\n\t\t */\n\t\tthis.opacityTexture = this._createTexture( 'VXGI.Opacity', UnsignedByteType, true, 1, 1, 1 );\n\n\t\t/**\n\t\t * The radiance of the scene including cached bounces, premultiplied by occupancy, as a mip chain.\n\t\t * With {@link VXGIVolume#directionalRadiance} only the finest level is used and the coarser\n\t\t * levels live in {@link VXGIVolume#directionalTexture}.\n\t\t *\n\t\t * @type {Storage3DTexture}\n\t\t */\n\t\tthis.radianceTexture = this._createTexture( 'VXGI.Radiance', HalfFloatType, true, 1, 1, 1 );\n\n\t\t/**\n\t\t * Texture node of {@link VXGIVolume#opacityTexture}. Stays valid across re-allocations of the volume.\n\t\t *\n\t\t * @type {Texture3DNode}\n\t\t */\n\t\tthis.opacityNode = texture3D( this.opacityTexture );\n\n\t\t/**\n\t\t * Texture node of {@link VXGIVolume#radianceTexture}. Stays valid across re-allocations of the volume.\n\t\t *\n\t\t * @type {Texture3DNode}\n\t\t */\n\t\tthis.radianceNode = texture3D( this.radianceTexture );\n\n\t\t/**\n\t\t * The coarser radiance levels filtered directionally for the six directions a ray can travel\n\t\t * (+x, -x, +y, -y, +z, -z), only allocated with {@link VXGIVolume#directionalRadiance}. Each\n\t\t * texel holds the radiance of the surfaces facing the direction premultiplied by their weight\n\t\t * (`rgb`) and the weight (`a`); occlusion comes from the opacity mip chain. The six directions\n\t\t * are stored side by side along x in one half-resolution mip chain; level `n` of the volume is\n\t\t * its level `n - 1`.\n\t\t *\n\t\t * @type {Storage3DTexture}\n\t\t */\n\t\tthis.directionalTexture = this._createTexture( 'VXGI.Directional', HalfFloatType, true, 6, 1, 1 );\n\n\t\t/**\n\t\t * Texture node of {@link VXGIVolume#directionalTexture}. Stays valid across re-allocations of the volume.\n\t\t *\n\t\t * @type {Texture3DNode}\n\t\t */\n\t\tthis.directionalNode = texture3D( this.directionalTexture );\n\n\t\t/**\n\t\t * The width of one direction block of the directional texture in texels (at its level 0).\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t */\n\t\tthis.directionalWidthNode = uniform( 1 );\n\n\t\t// private\n\n\t\tthis._traceDistance = this.maxDistance.greaterThan( 0 ).select( this.maxDistance, float( 1e10 ) );\n\t\tthis._allocated = false;\n\n\t\tthis._gridSize = new Vector3();\n\t\tthis._levels = 1;\n\t\tthis._voxelCount = 0;\n\t\tthis._gridSizeNode = [ uniform( 1, 'uint' ), uniform( 1, 'uint' ), uniform( 1, 'uint' ) ];\n\t\tthis._voxelCountNode = uniform( 0, 'uint' );\n\n\t\tthis._pingPongTexture = null;\n\t\tthis._directTexture = null;\n\t\tthis._pingPongDirectionalTexture = null;\n\t\tthis._normalTexture = null;\n\t\tthis._directional = false;\n\n\t\tthis._occupancyAttribute = null;\n\t\tthis._triangleIdAttribute = null;\n\t\tthis._solidAttribute = null;\n\t\tthis._triangleAttribute = null;\n\t\tthis._trianglesNode = null;\n\t\tthis._triangleCount = 0;\n\t\tthis._triangleCountNode = uniform( 0, 'uint' );\n\n\t\tthis._kernels = null;\n\n\t\tthis._lightsArray = [];\n\t\tfor ( let i = 0; i < this.maxLights * 4; i ++ ) this._lightsArray.push( new Vector4() );\n\t\tthis._lightsNode = uniformArray( this._lightsArray, 'vec4' );\n\t\tthis._lightCountNode = uniform( 0, 'uint' );\n\t\tthis._lightKey = '';\n\n\t\t// per light slot: type, shadow map (2D depth or cube depth) and its matrix / bias / near / far\n\n\t\tthis._lightTypes = [];\n\t\tthis._lightShadows = [];\n\t\tthis._shadowMatrices = [];\n\t\tthis._shadowParams = [];\n\n\t\tfor ( let i = 0; i < this.maxLights; i ++ ) {\n\n\t\t\tthis._shadowMatrices.push( uniform( new Matrix4() ) );\n\t\t\tthis._shadowParams.push( uniform( new Vector4() ) );\n\n\t\t}\n\n\t\tthis._lightsKey = '';\n\n\n\t\tthis._exclude = new Set();\n\n\t}\n\n\t/**\n\t * The effective maximum cone length as a node.\n\t *\n\t * @type {Node<float>}\n\t */\n\tget traceDistanceNode() {\n\n\t\treturn this._traceDistance;\n\n\t}\n\n\t/**\n\t * Updates the volume if required. Voxelizes the scene when `needsUpdate` is set and re-injects\n\t * lighting when `lightingNeedsUpdate` is set or a light has changed.\n\t *\n\t * @param {Renderer} renderer - The renderer.\n\t * @param {Scene} scene - The scene.\n\t */\n\tupdate( renderer, scene ) {\n\n\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t// the volume might be updated before the scene was rendered for the first time\n\n\t\tif ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();\n\n\t\tif ( this.needsUpdate === true || this._allocated === false || this._directional !== this.directionalRadiance ) {\n\n\t\t\tthis._voxelize( renderer, scene );\n\n\t\t\tthis.needsUpdate = false;\n\t\t\tthis.lightingNeedsUpdate = true;\n\n\t\t}\n\n\t\tconst lightKey = this._collectLights( renderer, scene );\n\n\t\tif ( this.lightingNeedsUpdate === true || lightKey !== this._lightKey ) {\n\n\t\t\tthis._lightKey = lightKey;\n\t\t\tthis._updateLighting( renderer );\n\n\t\t\tthis.lightingNeedsUpdate = false;\n\n\t\t}\n\n\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t}\n\n\t/**\n\t * Frees internal resources.\n\t */\n\tdispose() {\n\n\t\tthis._disposeGrid();\n\n\t}\n\n\t// geometry\n\n\t_voxelize( renderer, scene ) {\n\n\t\tthis._exclude.clear();\n\n\t\tconst bounds = this.bounds.isEmpty() ? computeSceneBounds( scene, this.layers, this._exclude, _box ) : _box.copy( this.bounds );\n\n\t\tif ( bounds.isEmpty() ) bounds.min.set( - 1, - 1, - 1 ), bounds.max.set( 1, 1, 1 );\n\n\t\t// grid setup: the longest axis gets `resolution` voxels, all dimensions are padded by\n\t\t// one voxel and rounded up so every mip level has integer dimensions\n\n\t\tbounds.getSize( _size );\n\n\t\tconst resolution = Math.max( 8, this.resolution );\n\t\tconst voxelSize = Math.max( _size.x, _size.y, _size.z ) / resolution;\n\t\tlet levels = MathUtils.clamp( Math.floor( Math.log2( resolution ) ) - 2, 1, 8 );\n\t\tconst multiple = 2 ** ( levels - 1 );\n\n\t\tconst gridSize = _size.clone();\n\t\tgridSize.x = Math.ceil( ( Math.ceil( _size.x / voxelSize ) + 2 ) / multiple ) * multiple;\n\t\tgridSize.y = Math.ceil( ( Math.ceil( _size.y / voxelSize ) + 2 ) / multiple ) * multiple;\n\t\tgridSize.z = Math.ceil( ( Math.ceil( _size.z / voxelSize ) + 2 ) / multiple ) * multiple;\n\n\t\tlevels = Math.min( levels, Math.floor( Math.log2( Math.max( gridSize.x, gridSize.y ) ) ) + 1 );\n\n\t\tthis.boundsMinNode.value.copy( bounds.min ).subScalar( voxelSize );\n\t\tthis.volumeSizeNode.value.copy( gridSize ).multiplyScalar( voxelSize );\n\t\tthis.worldBounds.min.copy( this.boundsMinNode.value );\n\t\tthis.worldBounds.max.copy( this.boundsMinNode.value ).add( this.volumeSizeNode.value );\n\t\tthis.voxelSizeNode.value = voxelSize;\n\t\tthis.maxLevelNode.value = levels - 1;\n\n\t\tif ( this._allocated === false || gridSize.equals( this._gridSize ) === false || levels !== this._levels || this._directional !== this.directionalRadiance ) {\n\n\t\t\tthis._allocateGrid( gridSize, levels );\n\n\t\t}\n\n\t\t// collect triangles\n\n\t\t_box.min.copy( this.boundsMinNode.value );\n\t\t_box.max.copy( this.boundsMinNode.value ).add( this.volumeSizeNode.value );\n\n\t\tconst { data, count } = collectSceneTriangles( scene, {\n\t\t\tbounds: _box,\n\t\t\tlayers: this.layers,\n\t\t\texclude: this._exclude,\n\t\t\tsubVoxelSize: voxelSize * 0.5,\n\t\t\tmaxEdge: MAX_EDGE_SUBVOXELS,\n\t\t\tminOpacity: this.minOpacity\n\t\t} );\n\n\t\tthis._triangleCount = count;\n\t\tthis._triangleCountNode.value = count;\n\n\t\tif ( this._triangleAttribute !== null ) this._triangleAttribute.dispose();\n\n\t\tthis._triangleAttribute = new StorageBufferAttribute( count > 0 ? data : new Float32Array( TRIANGLE_STRIDE ), 4 );\n\t\tthis._trianglesNode = storage( this._triangleAttribute, 'vec4', this._triangleAttribute.count ).toReadOnly();\n\n\t\tconst solid = this._solidAttribute.array;\n\n\t\tsolid.fill( 0 );\n\t\tcomputeSolidVoxels( scene, { boundsMin: this.boundsMinNode.value, voxelSize, gridSize, layers: this.layers, exclude: this._exclude }, new Uint8Array( solid.buffer ) );\n\t\tthis._solidAttribute.needsUpdate = true;\n\n\t\t// kernels depend on the triangle buffer and grid\n\n\t\tthis._disposeKernels();\n\t\tconst kernels = this._getKernels();\n\n\t\trenderer.compute( kernels.clear );\n\n\t\tif ( count > 0 ) renderer.compute( kernels.voxelize );\n\n\t\trenderer.compute( kernels.resolve );\n\n\t\tfor ( const kernel of kernels.opacityMips ) renderer.compute( kernel );\n\n\t}\n\n\t_allocateGrid( gridSize, levels ) {\n\n\t\tthis._disposeGrid();\n\n\t\tconst { x, y, z } = gridSize;\n\n\t\tthis._gridSize.copy( gridSize );\n\t\tthis._levels = levels;\n\t\tthis._voxelCount = x * y * z;\n\t\tthis._gridSizeNode[ 0 ].value = x;\n\t\tthis._gridSizeNode[ 1 ].value = y;\n\t\tthis._gridSizeNode[ 2 ].value = z;\n\t\tthis._voxelCountNode.value = this._voxelCount;\n\n\t\tconst directional = this._directional = this.directionalRadiance;\n\n\t\tthis.opacityTexture = this._createTexture( 'VXGI.Opacity', UnsignedByteType, true, x, y, z );\n\t\tthis.radianceTexture = this._createTexture( 'VXGI.Radiance', HalfFloatType, directional === false, x, y, z );\n\t\tthis._pingPongTexture = this._createTexture( 'VXGI.RadiancePingPong', HalfFloatType, directional === false, x, y, z );\n\t\tthis._directTexture = this._createTexture( 'VXGI.Direct', HalfFloatType, false, x, y, z );\n\n\t\t// the directional levels start at level 1, i.e. at half resolution, six direction blocks along x\n\n\t\tif ( directional === true ) {\n\n\t\t\tconst hx = Math.ceil( x / 2 ), hy = Math.ceil( y / 2 ), hz = Math.ceil( z / 2 );\n\n\t\t\tthis.directionalTexture = this._createTexture( 'VXGI.Directional', HalfFloatType, true, 6 * hx, hy, hz );\n\t\t\tthis._pingPongDirectionalTexture = this._createTexture( 'VXGI.DirectionalPingPong', HalfFloatType, true, 6 * hx, hy, hz );\n\t\t\tthis._normalTexture = this._createTexture( 'VXGI.Normal', UnsignedByteType, false, x, y, z );\n\t\t\tthis.directionalWidthNode.value = hx;\n\n\t\t} else {\n\n\t\t\tthis.directionalTexture = this._createTexture( 'VXGI.Directional', HalfFloatType, true, 6, 1, 1 );\n\t\t\tthis.directionalWidthNode.value = 1;\n\n\t\t}\n\n\t\tthis.opacityNode.value = this.opacityTexture;\n\t\tthis.radianceNode.value = this.radianceTexture;\n\t\tthis.directionalNode.value = this.directionalTexture;\n\n\t\tthis._allocated = true;\n\n\t\tthis._occupancyAttribute = new StorageBufferAttribute( this._voxelCount, 1, Uint32Array );\n\t\tthis._triangleIdAttribute = new StorageBufferAttribute( this._voxelCount, 1, Uint32Array );\n\t\tthis._solidAttribute = new StorageBufferAttribute( Math.ceil( this._voxelCount / 4 ), 1, Uint32Array );\n\n\t}\n\n\t_createTexture( name, type, mipmaps, x, y, z ) {\n\n\t\tconst texture = new Storage3DTexture( x, y, z );\n\t\ttexture.name = name;\n\t\ttexture.type = type;\n\t\ttexture.format = RGBAFormat;\n\t\ttexture.generateMipmaps = mipmaps;\n\t\ttexture.mipmapsAutoUpdate = false;\n\t\ttexture.minFilter = mipmaps ? LinearMipmapLinearFilter : LinearFilter;\n\t\ttexture.magFilter = LinearFilter;\n\t\ttexture.wrapS = texture.wrapT = texture.wrapR = ClampToEdgeWrapping;\n\n\t\treturn texture;\n\n\t}\n\n\t_disposeGrid() {\n\n\t\tthis._disposeKernels();\n\n\t\tthis.opacityTexture.dispose();\n\t\tthis.radianceTexture.dispose();\n\t\tthis.directionalTexture.dispose();\n\n\t\tif ( this._pingPongTexture !== null ) {\n\n\t\t\tthis._pingPongTexture.dispose();\n\t\t\tthis._directTexture.dispose();\n\n\t\t\tthis._pingPongTexture = null;\n\t\t\tthis._directTexture = null;\n\n\t\t}\n\n\t\tif ( this._normalTexture !== null ) {\n\n\t\t\tthis._normalTexture.dispose();\n\t\t\tthis._pingPongDirectionalTexture.dispose();\n\n\t\t\tthis._normalTexture = null;\n\t\t\tthis._pingPongDirectionalTexture = null;\n\n\t\t}\n\n\t\tif ( this._occupancyAttribute !== null ) {\n\n\t\t\tthis._occupancyAttribute.dispose();\n\t\t\tthis._triangleIdAttribute.dispose();\n\t\t\tthis._solidAttribute.dispose();\n\n\t\t\tthis._occupancyAttribute = null;\n\t\t\tthis._triangleIdAttribute = null;\n\t\t\tthis._solidAttribute = null;\n\n\t\t}\n\n\t\tif ( this._triangleAttribute !== null ) {\n\n\t\t\tthis._triangleAttribute.dispose();\n\n\t\t\tthis._triangleAttribute = null;\n\t\t\tthis._trianglesNode = null;\n\n\t\t}\n\n\t\tthis._allocated = false;\n\n\t}\n\n\t// lighting\n\n\t_collectLights( renderer, scene ) {\n\n\t\tconst lights = this._lightsArray;\n\t\tlet count = 0;\n\t\tlet key = renderer.shadowMap.enabled ? 'S' : 'N';\n\n\t\tthis._lightTypes.length = 0;\n\t\tthis._lightShadows.length = 0;\n\n\t\tscene.traverseVisible( ( object ) => {\n\n\t\t\tif ( object.isLight !== true || count >= this.maxLights ) return;\n\n\t\t\tlet type;\n\n\t\t\tif ( object.isDirectionalLight === true ) type = 0;\n\t\t\telse if ( object.isSpotLight === true ) type = 2;\n\t\t\telse if ( object.isPointLight === true ) type = 1;\n\t\t\telse return;\n\n\t\t\tconst l0 = lights[ count * 4 ], l1 = lights[ count * 4 + 1 ], l2 = lights[ count * 4 + 2 ], l3 = lights[ count * 4 + 3 ];\n\n\t\t\t_position.setFromMatrixPosition( object.matrixWorld );\n\t\t\tl0.set( _position.x, _position.y, _position.z, type );\n\n\t\t\tif ( type === 0 || type === 2 ) {\n\n\t\t\t\t_target.setFromMatrixPosition( object.target.matrixWorld );\n\n\t\t\t\tif ( type === 0 ) {\n\n\t\t\t\t\t_target.subVectors( _position, _target ).normalize(); // direction towards the light\n\n\t\t\t\t} else {\n\n\t\t\t\t\t_target.subVectors( _target, _position ).normalize(); // spot axis\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_target.set( 0, 0, 0 );\n\n\t\t\t}\n\n\t\t\tl1.set( _target.x, _target.y, _target.z, object.distance || 0 );\n\n\t\t\tconst color = object.color, intensity = object.intensity;\n\t\t\tl2.set( color.r * intensity, color.g * intensity, color.b * intensity, object.decay !== undefined ? object.decay : 2 );\n\n\t\t\t// the light's shadow map is used for the injected visibility when available\n\n\t\t\tlet shadowTexture = null;\n\n\t\t\tif ( object.castShadow === true && renderer.shadowMap.enabled === true && object.shadow.map !== null && object.shadow.map.depthTexture !== undefined ) {\n\n\t\t\t\tconst shadow = object.shadow;\n\n\t\t\t\tshadowTexture = shadow.map.depthTexture;\n\t\t\t\tthis._shadowMatrices[ count ].value.copy( shadow.matrix );\n\t\t\t\tthis._shadowParams[ count ].value.set( shadow.bias, shadow.camera.near, shadow.camera.far, 0 );\n\n\t\t\t}\n\n\t\t\tthis._lightTypes.push( type );\n\t\t\tthis._lightShadows.push( shadowTexture );\n\n\t\t\tif ( type === 2 ) {\n\n\t\t\t\tl3.set( Math.cos( object.angle ), Math.cos( object.angle * ( 1 - object.penumbra ) ), 0, 0 );\n\n\t\t\t} else {\n\n\t\t\t\tl3.set( 0, 0, 0, 0 );\n\n\t\t\t}\n\n\t\t\tkey += `|${ type },${ l0.x.toFixed( 3 ) },${ l0.y.toFixed( 3 ) },${ l0.z.toFixed( 3 ) },${ l1.x.toFixed( 4 ) },${ l1.y.toFixed( 4 ) },${ l1.z.toFixed( 4 ) },${ l1.w },${ l2.x.toFixed( 3 ) },${ l2.y.toFixed( 3 ) },${ l2.z.toFixed( 3 ) },${ l2.w },${ l3.x.toFixed( 4 ) },${ l3.y.toFixed( 4 ) },${ shadowTexture !== null ? shadowTexture.uuid : '-' }`;\n\n\t\t\tcount ++;\n\n\t\t} );\n\n\t\tthis._lightCountNode.value = count;\n\n\t\t// injection parameters that are baked into the cached radiance\n\n\t\tkey += `|${ this.bounces },${ this.bounceConeAngle.value },${ this.shadowConeAngle.value },${ this.stepScale.value },${ this.maxDistance.value }`;\n\n\t\t// the inject kernels are specialized for the set of lights and their shadow maps\n\n\t\tthis._lightsKey = this._lightTypes.map( ( type, i ) => type + ':' + ( this._lightShadows[ i ] !== null ? this._lightShadows[ i ].uuid : '-' ) ).join( '|' );\n\n\t\treturn key;\n\n\t}\n\n\t_updateLighting( renderer ) {\n\n\t\tconst kernels = this._getKernels();\n\t\tconst bounces = Math.max( 0, Math.round( this.bounces ) );\n\n\t\t// the ping-pong order is chosen so the final result always ends up in `radianceTexture`\n\n\t\tlet index = bounces % 2;\n\n\t\tif ( kernels.inject[ index ] === null || kernels.injectKey[ index ] !== this._lightsKey ) {\n\n\t\t\tif ( kernels.inject[ index ] !== null ) kernels.inject[ index ].dispose();\n\n\t\t\tkernels.inject[ index ] = this._createInjectKernel( renderer, index );\n\t\t\tkernels.injectKey[ index ] = this._lightsKey;\n\n\t\t}\n\n\t\trenderer.compute( kernels.inject[ index ] );\n\n\t\tfor ( const kernel of kernels.radianceMips[ index ] ) renderer.compute( kernel );\n\n\t\tfor ( let i = 0; i < bounces; i ++ ) {\n\n\t\t\tconst target = 1 - index;\n\n\t\t\trenderer.compute( kernels.bounce[ target ] );\n\n\t\t\tfor ( const kernel of kernels.radianceMips[ target ] ) renderer.compute( kernel );\n\n\t\t\tindex = target;\n\n\t\t}\n\n\t}\n\n\t// kernels\n\n\t_getRadianceTexture( index ) {\n\n\t\treturn index === 0 ? this.radianceTexture : this._pingPongTexture;\n\n\t}\n\n\t_getDirectionalTexture( index ) {\n\n\t\treturn index === 0 ? this.directionalTexture : this._pingPongDirectionalTexture;\n\n\t}\n\n\t_getKernels() {\n\n\t\tif ( this._kernels !== null ) return this._kernels;\n\n\t\tconst kernels = {\n\t\t\tclear: this._createClearKernel(),\n\t\t\tvoxelize: this._createVoxelizeKernel(),\n\t\t\tresolve: this._createResolveKernel(),\n\t\t\topacityMips: [],\n\t\t\tradianceMips: [[], []],\n\t\t\tinject: [ null, null ],\n\t\t\tinjectKey: [ null, null ],\n\t\t\tbounce: [ null, null ]\n\t\t};\n\n\t\tfor ( let level = 1; level < this._levels; level ++ ) {\n\n\t\t\tkernels.opacityMips.push( this._createOpacityMipKernel( level ) );\n\n\t\t\t// the coarser radiance levels are either isotropic mips or directionally filtered\n\n\t\t\tfor ( let index = 0; index < 2; index ++ ) {\n\n\t\t\t\tkernels.radianceMips[ index ].push( this._directional === true ? this._createDirectionalKernel( index, level ) : this._createRadianceMipKernel( this._getRadianceTexture( index ), level ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\tkernels.bounce[ 0 ] = this._createBounceKernel( 0 );\n\t\tkernels.bounce[ 1 ] = this._createBounceKernel( 1 );\n\n\t\tthis._kernels = kernels;\n\n\t\treturn kernels;\n\n\t}\n\n\t_disposeKernels() {\n\n\t\tif ( this._kernels === null ) return;\n\n\t\tconst { clear, voxelize, resolve, opacityMips, radianceMips, inject, bounce } = this._kernels;\n\n\t\tfor ( const kernel of [ clear, voxelize, resolve, ...opacityMips, ...radianceMips.flat(), ...inject, ...bounce ] ) {\n\n\t\t\tif ( kernel !== null ) kernel.dispose();\n\n\t\t}\n\n\t\tthis._kernels = null;\n\n\t}\n\n\t_getLevelSize( level ) {\n\n\t\treturn [ this._gridSize.x >> level, this._gridSize.y >> level, this._gridSize.z >> level ];\n\n\t}\n\n\t/**\n\t * Returns the 3D coordinates of the given linear voxel index.\n\t *\n\t * @private\n\t */\n\t_coords( index, size ) {\n\n\t\tconst [ x, y ] = size;\n\n\t\treturn uvec3( index.mod( uint( x ) ), index.div( uint( x ) ).mod( uint( y ) ), index.div( uint( x * y ) ) );\n\n\t}\n\n\t_createClearKernel() {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount );\n\t\tconst triangleIds = storage( this._triangleIdAttribute, 'uint', this._voxelCount );\n\t\tconst voxelCount = this._voxelCountNode;\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( voxelCount ), () => {\n\n\t\t\t\toccupancy.element( instanceIndex ).assign( uint( 0 ) );\n\t\t\t\ttriangleIds.element( instanceIndex ).assign( uint( 0 ) );\n\n\t\t\t} );\n\n\t\t} )().compute( this._voxelCount ).setName( 'VXGI.Clear' );\n\n\t}\n\n\t_createVoxelizeKernel() {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount ).toAtomic();\n\t\tconst triangleIds = storage( this._triangleIdAttribute, 'uint', this._voxelCount );\n\t\tconst triangles = this._trianglesNode;\n\t\tconst triangleCount = this._triangleCountNode;\n\t\tconst boundsMin = this.boundsMinNode;\n\t\tconst invSubVoxel = float( 2 ).div( this.voxelSizeNode );\n\t\tconst [ gx, gy ] = this._gridSizeNode;\n\t\tconst subSize = vec3( this._gridSize.x * 2, this._gridSize.y * 2, this._gridSize.z * 2 );\n\n\t\treturn Fn( () => {\n\n\t\t\tconst triangleIndex = instanceIndex;\n\n\t\t\tIf( triangleIndex.lessThan( triangleCount ), () => {\n\n\t\t\t\tconst base = triangleIndex.mul( 5 ).toConst();\n\n\t\t\t\t// triangle in sub-voxel space\n\n\t\t\t\tconst p0 = triangles.element( base ).xyz.sub( boundsMin ).mul( invSubVoxel ).toConst();\n\t\t\t\tconst p1 = triangles.element( base.add( 1 ) ).xyz.sub( boundsMin ).mul( invSubVoxel ).toConst();\n\t\t\t\tconst p2 = triangles.element( base.add( 2 ) ).xyz.sub( boundsMin ).mul( invSubVoxel ).toConst();\n\n\t\t\t\tconst n = cross( p1.sub( p0 ), p2.sub( p0 ) ).toConst();\n\t\t\t\tconst an = abs( n ).toConst();\n\n\t\t\t\t// project along the dominant axis: swizzle so the dominant axis becomes z\n\n\t\t\t\tconst isZ = an.z.greaterThanEqual( an.x ).and( an.z.greaterThanEqual( an.y ) ).toConst();\n\t\t\t\tconst isY = isZ.not().and( an.y.greaterThanEqual( an.x ) ).toConst();\n\n\t\t\t\tconst swizzle = ( v ) => select( isZ, v.xyz, select( isY, v.zxy, v.yzx ) );\n\n\t\t\t\tconst q0 = swizzle( p0 ).toConst();\n\t\t\t\tconst q1 = swizzle( p1 ).toConst();\n\t\t\t\tconst q2 = swizzle( p2 ).toConst();\n\t\t\t\tconst nq = swizzle( n ).toConst();\n\t\t\t\tconst sd = swizzle( subSize ).toConst();\n\n\t\t\t\tconst qmin = min( q0, min( q1, q2 ) ).toConst();\n\t\t\t\tconst qmax = max( q0, max( q1, q2 ) ).toConst();\n\n\t\t\t\tconst i0 = int( floor( qmin.x ) ).max( 0 ).toConst();\n\t\t\t\tconst i1 = int( floor( qmax.x ) ).min( int( sd.x ).sub( 1 ) ).toConst();\n\t\t\t\tconst j0 = int( floor( qmin.y ) ).max( 0 ).toConst();\n\t\t\t\tconst j1 = int( floor( qmax.y ) ).min( int( sd.y ).sub( 1 ) ).toConst();\n\n\t\t\t\t// conservative edge functions\n\n\t\t\t\tconst areaSign = sign( nq.z ).toConst();\n\n\t\t\t\tconst edge = ( a, b ) => {\n\n\t\t\t\t\tconst normal = vec2( a.y.sub( b.y ), b.x.sub( a.x ) ).mul( areaSign ).toConst();\n\t\t\t\t\tconst bias = float( 0.5 ).mul( abs( normal.x ).add( abs( normal.y ) ) ).toConst();\n\n\t\t\t\t\treturn { a, normal, bias };\n\n\t\t\t\t};\n\n\t\t\t\tconst e0 = edge( q0.xy, q1.xy );\n\t\t\t\tconst e1 = edge( q1.xy, q2.xy );\n\t\t\t\tconst e2 = edge( q2.xy, q0.xy );\n\n\t\t\t\tconst halfExtent = float( 0.5 ).mul( abs( nq.x ).add( abs( nq.y ) ) ).div( abs( nq.z ) ).toConst();\n\n\t\t\t\tLoop( { start: i0, end: i1, type: 'int', condition: '<=', name: 'i' }, { start: j0, end: j1, type: 'int', condition: '<=', name: 'j' }, ( { i, j } ) => {\n\n\t\t\t\t\tconst c = vec2( float( i ).add( 0.5 ), float( j ).add( 0.5 ) ).toConst();\n\n\t\t\t\t\tconst inside = dot( e0.normal, c.sub( e0.a ) ).add( e0.bias ).greaterThanEqual( 0 )\n\t\t\t\t\t\t.and( dot( e1.normal, c.sub( e1.a ) ).add( e1.bias ).greaterThanEqual( 0 ) )\n\t\t\t\t\t\t.and( dot( e2.normal, c.sub( e2.a ) ).add( e2.bias ).greaterThanEqual( 0 ) );\n\n\t\t\t\t\tIf( inside, () => {\n\n\t\t\t\t\t\t// depth range of the triangle plane within this column\n\n\t\t\t\t\t\tconst wc = q0.z.sub( nq.x.mul( c.x.sub( q0.x ) ).add( nq.y.mul( c.y.sub( q0.y ) ) ).div( nq.z ) ).toConst();\n\n\t\t\t\t\t\tconst k0 = int( floor( max( wc.sub( halfExtent ), qmin.z ) ) ).max( 0 ).toConst();\n\t\t\t\t\t\tconst k1 = int( floor( min( wc.add( halfExtent ), qmax.z ) ) ).min( int( sd.z ).sub( 1 ) ).toConst();\n\n\t\t\t\t\t\tLoop( { start: k0, end: k1, type: 'int', condition: '<=', name: 'k' }, ( { k } ) => {\n\n\t\t\t\t\t\t\tconst s = select( isZ, ivec3( i, j, k ), select( isY, ivec3( j, k, i ), ivec3( k, i, j ) ) ).toConst();\n\n\t\t\t\t\t\t\tconst voxel = uvec3( s.div( 2 ) ).toConst();\n\t\t\t\t\t\t\tconst bit = uint( s.x.bitAnd( 1 ) ).bitOr( uint( s.y.bitAnd( 1 ) ).shiftLeft( uint( 1 ) ) ).bitOr( uint( s.z.bitAnd( 1 ) ).shiftLeft( uint( 2 ) ) ).toConst();\n\t\t\t\t\t\t\tconst voxelIndex = voxel.x.add( gx.mul( voxel.y.add( gy.mul( voxel.z ) ) ) ).toConst();\n\n\t\t\t\t\t\t\tatomicOr( occupancy.element( voxelIndex ), uint( 1 ).shiftLeft( bit ) );\n\t\t\t\t\t\t\ttriangleIds.element( voxelIndex ).assign( triangleIndex.add( 1 ) );\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} );\n\n\t\t\t\t} );\n\n\t\t\t} );\n\n\t\t} )().compute( this._triangleCount ).setName( 'VXGI.Voxelize' );\n\n\t}\n\n\t_createResolveKernel() {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst solid = storage( this._solidAttribute, 'uint', this._solidAttribute.count ).toReadOnly();\n\t\tconst opacityTexture = this.opacityTexture;\n\t\tconst voxelCount = this._voxelCountNode;\n\t\tconst size = this._getLevelSize( 0 );\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( voxelCount ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst solidBits = solid.element( instanceIndex.shiftRight( uint( 2 ) ) ).shiftRight( instanceIndex.bitAnd( uint( 3 ) ).mul( uint( 8 ) ) ).bitAnd( uint( 0xFF ) );\n\t\t\t\tconst bits = occupancy.element( instanceIndex ).bitOr( solidBits ).toConst();\n\n\t\t\t\t// per-axis coverage from the 2x2x2 sub-voxel occupancy\n\n\t\t\t\tconst coverage = ( m0, m1, m2, m3 ) => {\n\n\t\t\t\t\treturn select( bits.bitAnd( uint( m0 ) ).notEqual( uint( 0 ) ), 0.25, 0 )\n\t\t\t\t\t\t.add( select( bits.bitAnd( uint( m1 ) ).notEqual( uint( 0 ) ), 0.25, 0 ) )\n\t\t\t\t\t\t.add( select( bits.bitAnd( uint( m2 ) ).notEqual( uint( 0 ) ), 0.25, 0 ) )\n\t\t\t\t\t\t.add( select( bits.bitAnd( uint( m3 ) ).notEqual( uint( 0 ) ), 0.25, 0 ) );\n\n\t\t\t\t};\n\n\t\t\t\tconst opacityX = coverage( 0x03, 0x0C, 0x30, 0xC0 );\n\t\t\t\tconst opacityY = coverage( 0x05, 0x0A, 0x50, 0xA0 );\n\t\t\t\tconst opacityZ = coverage( 0x11, 0x22, 0x44, 0x88 );\n\t\t\t\tconst occupied = float( countOneBits( bits ) ).div( 8 );\n\n\t\t\t\ttextureStore( opacityTexture, coords, vec4( opacityX, opacityY, opacityZ, occupied ) );\n\n\t\t\t} );\n\n\t\t} )().compute( this._voxelCount ).setName( 'VXGI.Resolve' );\n\n\t}\n\n\t_createOpacityMipKernel( level ) {\n\n\t\tconst size = this._getLevelSize( level );\n\t\tconst count = size[ 0 ] * size[ 1 ] * size[ 2 ];\n\n\t\tconst source = new MipStorageTexture3DNode( this.opacityTexture, 'readOnly', level - 1 );\n\t\tconst target = new MipStorageTexture3DNode( this.opacityTexture, 'writeOnly', level );\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( uint( count ) ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst base = ivec3( coords.mul( uint( 2 ) ) ).toConst();\n\n\t\t\t\tconst children = [];\n\n\t\t\t\tfor ( let z = 0; z < 2; z ++ ) {\n\n\t\t\t\t\tfor ( let y = 0; y < 2; y ++ ) {\n\n\t\t\t\t\t\tfor ( let x = 0; x < 2; x ++ ) {\n\n\t\t\t\t\t\t\tchildren[ x + y * 2 + z * 4 ] = source.load( base.add( ivec3( x, y, z ) ) ).toConst();\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// along each axis the two children are combined, across the axis they are averaged\n\n\t\t\t\tconst child = ( x, y, z ) => children[ x + y * 2 + z * 4 ];\n\t\t\t\tconst combine = ( a, b ) => a.oneMinus().mul( b.oneMinus() ).oneMinus();\n\n\t\t\t\tlet opacityX = float( 0 ), opacityY = float( 0 ), opacityZ = float( 0 ), occupied = float( 0 );\n\n\t\t\t\tfor ( let a = 0; a < 2; a ++ ) {\n\n\t\t\t\t\tfor ( let b = 0; b < 2; b ++ ) {\n\n\t\t\t\t\t\topacityX = opacityX.add( combine( child( 0, a, b ).x, child( 1, a, b ).x ) );\n\t\t\t\t\t\topacityY = opacityY.add( combine( child( a, 0, b ).y, child( a, 1, b ).y ) );\n\t\t\t\t\t\topacityZ = opacityZ.add( combine( child( a, b, 0 ).z, child( a, b, 1 ).z ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tfor ( let i = 0; i < 8; i ++ ) occupied = occupied.add( children[ i ].w );\n\n\t\t\t\ttextureStore( target, coords, vec4( opacityX.mul( 0.25 ), opacityY.mul( 0.25 ), opacityZ.mul( 0.25 ), occupied.mul( 0.125 ) ) );\n\n\t\t\t} );\n\n\t\t} )().compute( count ).setName( 'VXGI.OpacityMip' + level );\n\n\t}\n\n\t_createRadianceMipKernel( radianceTexture, level ) {\n\n\t\tconst size = this._getLevelSize( level );\n\t\tconst count = size[ 0 ] * size[ 1 ] * size[ 2 ];\n\n\t\tconst source = new MipStorageTexture3DNode( radianceTexture, 'readOnly', level - 1 );\n\t\tconst target = new MipStorageTexture3DNode( radianceTexture, 'writeOnly', level );\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( uint( count ) ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst base = ivec3( coords.mul( uint( 2 ) ) ).toConst();\n\n\t\t\t\tlet sum = vec4( 0 );\n\n\t\t\t\tfor ( let z = 0; z < 2; z ++ ) {\n\n\t\t\t\t\tfor ( let y = 0; y < 2; y ++ ) {\n\n\t\t\t\t\t\tfor ( let x = 0; x < 2; x ++ ) {\n\n\t\t\t\t\t\t\tsum = sum.add( source.load( base.add( ivec3( x, y, z ) ) ) );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureStore( target, coords, sum.mul( 0.125 ) );\n\n\t\t\t} );\n\n\t\t} )().compute( count ).setName( 'VXGI.RadianceMip' + level );\n\n\t}\n\n\t/**\n\t * Creates the kernel that filters the six direction blocks of the directional texture at a\n\t * level from the next finer level: along the direction's axis the two finer voxels are\n\t * composited front to back with the front voxel's opacity along that axis, across the axis\n\t * they are averaged. Level 1 is filtered from the isotropic finest level, where a voxel only\n\t * contributes to the directions its surface faces against.\n\t *\n\t * @private\n\t */\n\t_createDirectionalKernel( index, level ) {\n\n\t\tconst size = this._getLevelSize( level );\n\t\tconst count = size[ 0 ] * size[ 1 ] * size[ 2 ];\n\t\tconst texture = this._getDirectionalTexture( index );\n\t\tconst opacity = texture3D( this.opacityTexture );\n\t\tconst radiance = texture3D( this._getRadianceTexture( index ) );\n\t\tconst normals = texture3D( this._normalTexture );\n\n\t\t// level n of the volume is level n - 1 of the half resolution directional texture\n\n\t\tconst source = level === 1 ? null : new MipStorageTexture3DNode( texture, 'readOnly', level - 2 );\n\t\tconst target = new MipStorageTexture3DNode( texture, 'writeOnly', level - 1 );\n\t\tconst blockWidth = size[ 0 ];\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( uint( count ) ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst base = ivec3( coords.mul( uint( 2 ) ) ).toConst();\n\n\t\t\t\tconst offset = ( i ) => ivec3( i & 1, ( i >> 1 ) & 1, ( i >> 2 ) & 1 );\n\n\t\t\t\tconst childOpacity = [];\n\t\t\t\tconst childNormal = [];\n\t\t\t\tconst childRadiance = [];\n\n\t\t\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\t\t\tchildOpacity.push( opacity.load( base.add( offset( i ) ) ).level( level - 1 ).toConst() );\n\n\t\t\t\t\tif ( level === 1 ) {\n\n\t\t\t\t\t\tchildNormal.push( normals.load( base.add( offset( i ) ) ).xyz.mul( 2 ).sub( 1 ).toConst() );\n\t\t\t\t\t\tchildRadiance.push( radiance.load( base.add( offset( i ) ) ).toConst() );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tfor ( let direction = 0; direction < 6; direction ++ ) {\n\n\t\t\t\t\tconst [ axis, sign ] = DIRECTIONS[ direction ];\n\t\t\t\t\tconst travel = vec3( axis === 0 ? sign : 0, axis === 1 ? sign : 0, axis === 2 ? sign : 0 );\n\t\t\t\t\tconst block = ivec3( direction * blockWidth * 2, 0, 0 ); // block offset in the finer level\n\n\t\t\t\t\t// a child holds the radiance of its surfaces facing the direction premultiplied by\n\t\t\t\t\t// their weight (rgb) and the weight (a); at the finest level a voxel only counts for a\n\t\t\t\t\t// direction if its surface faces against it, so a surface parallel to the axis does\n\t\t\t\t\t// not mix in. The front child hides the back child by its opacity along the axis.\n\n\t\t\t\t\tconst child = ( i ) => level === 1\n\t\t\t\t\t\t? childRadiance[ i ].mul( smoothstep( 0, 0.3, dot( childNormal[ i ], travel.negate() ) ) )\n\t\t\t\t\t\t: source.load( base.add( block ).add( offset( i ) ) );\n\t\t\t\t\tconst axisOpacity = ( i ) => [ childOpacity[ i ].x, childOpacity[ i ].y, childOpacity[ i ].z ][ axis ];\n\n\t\t\t\t\tlet sum = vec4( 0 );\n\n\t\t\t\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\t\t\t\t// each column along the axis is composited once, starting at its front voxel\n\n\t\t\t\t\t\tif ( ( ( i >> axis ) & 1 ) !== ( sign > 0 ? 0 : 1 ) ) continue;\n\n\t\t\t\t\t\tconst front = i;\n\t\t\t\t\t\tconst back = i ^ ( 1 << axis );\n\n\t\t\t\t\t\tsum = sum.add( child( front ) ).add( child( back ).mul( axisOpacity( front ).oneMinus() ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttextureStore( target, ivec3( coords ).add( ivec3( direction * blockWidth, 0, 0 ) ), sum.mul( 0.25 ) );\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t} )().compute( count ).setName( 'VXGI.Directional' + level );\n\n\t}\n\n\t/**\n\t * Emits the code for reading the surface data of the given voxel.\n\t *\n\t * @private\n\t */\n\t_surface( coords, triangleId ) {\n\n\t\tconst triangles = this._trianglesNode;\n\n\t\tconst base = triangleId.sub( 1 ).mul( 5 ).toConst();\n\t\tconst a = triangles.element( base ).xyz.toConst();\n\t\tconst b = triangles.element( base.add( 1 ) ).xyz.toConst();\n\t\tconst c = triangles.element( base.add( 2 ) ).xyz.toConst();\n\t\tconst albedo = triangles.element( base.add( 3 ) ).toConst();\n\t\tconst emissive = triangles.element( base.add( 4 ) ).xyz.toConst();\n\n\t\tconst normal = normalize( cross( b.sub( a ), c.sub( a ) ) ).toVar();\n\t\tnormal.assign( select( albedo.w.equal( 1 ), normal.negate(), normal ) ); // back side\n\n\t\tconst position = this.boundsMinNode.add( vec3( coords ).add( 0.5 ).mul( this.voxelSizeNode ) ).toConst();\n\n\t\treturn { position, normal, albedo: albedo.xyz, side: albedo.w, emissive };\n\n\t}\n\n\t_createInjectKernel( renderer, index ) {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst triangleIds = storage( this._triangleIdAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst voxelCount = this._voxelCountNode;\n\t\tconst size = this._getLevelSize( 0 );\n\t\tconst voxelSize = this.voxelSizeNode;\n\t\tconst lights = this._lightsNode;\n\n\t\tconst directTexture = this._directTexture;\n\t\tconst normalTexture = this._normalTexture;\n\t\tconst radianceTexture = this._getRadianceTexture( index );\n\n\t\tconst lightTypes = this._lightTypes.slice();\n\t\tconst lightShadows = this._lightShadows.slice();\n\t\tconst shadowMatrices = this._shadowMatrices;\n\t\tconst shadowParams = this._shadowParams;\n\t\tconst reversedDepth = renderer.reversedDepthBuffer === true;\n\t\tconst shadowTanHalfAngle = this.shadowConeAngle.mul( 0.5 ).radians().tan();\n\n\t\tconst trace = createConeTracer( this, { maxSteps: 256 } );\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( voxelCount ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst bits = occupancy.element( instanceIndex ).toConst();\n\t\t\t\tconst result = vec4( 0 ).toVar();\n\t\t\t\tconst encodedNormal = normalTexture !== null ? vec4( 0 ).toVar() : null;\n\n\t\t\t\tIf( bits.notEqual( uint( 0 ) ), () => {\n\n\t\t\t\t\tconst surface = this._surface( coords, triangleIds.element( instanceIndex ) );\n\t\t\t\t\tconst { position, normal, albedo, side, emissive } = surface;\n\n\t\t\t\t\tif ( encodedNormal !== null ) encodedNormal.assign( vec4( normal.mul( 0.5 ).add( 0.5 ), 1 ) );\n\n\t\t\t\t\tconst irradiance = vec3( 0 ).toVar();\n\n\t\t\t\t\t// one specialized block per light; the kernel is rebuilt when the light set changes\n\n\t\t\t\t\tfor ( let i = 0; i < lightTypes.length; i ++ ) {\n\n\t\t\t\t\t\tconst type = lightTypes[ i ];\n\t\t\t\t\t\tconst shadowTexture = lightShadows[ i ];\n\n\t\t\t\t\t\tconst l0 = lights.element( i * 4 ).toConst();\n\t\t\t\t\t\tconst l1 = lights.element( i * 4 + 1 ).toConst();\n\t\t\t\t\t\tconst l2 = lights.element( i * 4 + 2 ).toConst();\n\t\t\t\t\t\tconst l3 = lights.element( i * 4 + 3 ).toConst();\n\n\t\t\t\t\t\tconst lightDirection = vec3( 0 ).toVar();\n\t\t\t\t\t\tconst lightDistance = float( 1e10 ).toVar();\n\t\t\t\t\t\tconst attenuation = float( 1 ).toVar();\n\n\t\t\t\t\t\tif ( type === 0 ) {\n\n\t\t\t\t\t\t\tlightDirection.assign( l1.xyz );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tconst lightVector = l0.xyz.sub( position ).toConst();\n\t\t\t\t\t\t\tlightDistance.assign( length( lightVector ) );\n\t\t\t\t\t\t\tlightDirection.assign( lightVector.div( lightDistance ) );\n\t\t\t\t\t\t\tattenuation.assign( getDistanceAttenuation( { lightDistance, cutoffDistance: l1.w, decayExponent: l2.w } ) );\n\n\t\t\t\t\t\t\tif ( type === 2 ) {\n\n\t\t\t\t\t\t\t\tattenuation.mulAssign( smoothstep( l3.x, l3.y, dot( l1.xyz, lightDirection.negate() ) ) );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst ndl = dot( normal, lightDirection ).toVar();\n\t\t\t\t\t\tndl.assign( select( side.equal( 2 ), abs( ndl ), max( ndl, 0 ) ) );\n\n\t\t\t\t\t\tIf( ndl.greaterThan( 0 ).and( attenuation.greaterThan( 0 ) ), () => {\n\n\t\t\t\t\t\t\tconst visibility = float( 1 ).toVar();\n\t\t\t\t\t\t\tconst shadowPosition = position.add( normal.mul( voxelSize ) ).toConst();\n\n\t\t\t\t\t\t\tif ( shadowTexture === null ) {\n\n\t\t\t\t\t\t\t\t// no shadow map: trace a visibility cone through the volume\n\n\t\t\t\t\t\t\t\tconst origin = position.add( normal.mul( voxelSize.mul( 1.5 ) ) );\n\t\t\t\t\t\t\t\tconst occlusion = trace( origin, lightDirection, shadowTanHalfAngle, lightDistance.sub( voxelSize ) );\n\t\t\t\t\t\t\t\tvisibility.assign( occlusion.alpha.oneMinus() );\n\n\t\t\t\t\t\t\t} else if ( type === 1 ) {\n\n\t\t\t\t\t\t\t\t// point light: cube shadow map addressed by the light-to-voxel vector\n\n\t\t\t\t\t\t\t\tconst params = shadowParams[ i ];\n\t\t\t\t\t\t\t\tconst bias = params.x, near = params.y, far = params.z;\n\n\t\t\t\t\t\t\t\tconst lightToVoxel = shadowPosition.sub( l0.xyz ).toConst();\n\t\t\t\t\t\t\t\tconst absVector = abs( lightToVoxel ).toConst();\n\t\t\t\t\t\t\t\tconst viewZ = max( max( absVector.x, absVector.y ), absVector.z ).toConst();\n\n\t\t\t\t\t\t\t\tIf( viewZ.greaterThanEqual( near ).and( viewZ.lessThanEqual( far ) ), () => {\n\n\t\t\t\t\t\t\t\t\tconst depth = cubeTexture( shadowTexture, normalize( lightToVoxel ) ).r; // depth cubes need an integer level, which the compute path emits by default\n\n\t\t\t\t\t\t\t\t\tif ( reversedDepth ) {\n\n\t\t\t\t\t\t\t\t\t\tconst reference = viewZToReversedPerspectiveDepth( viewZ.negate(), near, far ).sub( bias );\n\t\t\t\t\t\t\t\t\t\tvisibility.assign( select( reference.greaterThanEqual( depth ), 1, 0 ) );\n\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\tconst reference = viewZToPerspectiveDepth( viewZ.negate(), near, far ).add( bias );\n\t\t\t\t\t\t\t\t\t\tvisibility.assign( select( reference.lessThanEqual( depth ), 1, 0 ) );\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t// directional and spot lights: 2D shadow map addressed by the shadow matrix\n\n\t\t\t\t\t\t\t\tconst bias = shadowParams[ i ].x;\n\n\t\t\t\t\t\t\t\tconst clip = shadowMatrices[ i ].mul( vec4( shadowPosition, 1 ) ).toConst();\n\t\t\t\t\t\t\t\tconst coord = clip.xyz.div( clip.w ).toConst();\n\t\t\t\t\t\t\t\tconst uv = vec2( coord.x, coord.y.oneMinus() ).toConst();\n\n\t\t\t\t\t\t\t\tconst inside = uv.x.greaterThanEqual( 0 ).and( uv.x.lessThanEqual( 1 ) ).and( uv.y.greaterThanEqual( 0 ) ).and( uv.y.lessThanEqual( 1 ) ).and( coord.z.greaterThanEqual( 0 ) ).and( coord.z.lessThanEqual( 1 ) ).toConst();\n\n\t\t\t\t\t\t\t\tIf( inside, () => {\n\n\t\t\t\t\t\t\t\t\tconst depth = texture( shadowTexture, uv ).r;\n\n\t\t\t\t\t\t\t\t\tif ( reversedDepth ) {\n\n\t\t\t\t\t\t\t\t\t\tvisibility.assign( select( coord.z.sub( bias ).greaterThanEqual( depth ), 1, 0 ) );\n\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\tvisibility.assign( select( coord.z.add( bias ).lessThanEqual( depth ), 1, 0 ) );\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tirradiance.addAssign( l2.xyz.mul( attenuation.mul( ndl ).mul( visibility ) ) );\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst radiance = albedo.mul( irradiance ).div( PI ).add( emissive );\n\t\t\t\t\tconst occupied = float( countOneBits( bits ) ).div( 8 );\n\n\t\t\t\t\tresult.assign( vec4( radiance.mul( occupied ), occupied ) );\n\n\t\t\t\t} );\n\n\t\t\t\ttextureStore( directTexture, coords, result );\n\t\t\t\ttextureStore( radianceTexture, coords, result );\n\n\t\t\t\tif ( encodedNormal !== null ) textureStore( normalTexture, coords, encodedNormal );\n\n\t\t\t} );\n\n\t\t} )().compute( this._voxelCount ).setName( 'VXGI.Inject' );\n\n\t}\n\n\t_createBounceKernel( index ) {\n\n\t\tconst occupancy = storage( this._occupancyAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst triangleIds = storage( this._triangleIdAttribute, 'uint', this._voxelCount ).toReadOnly();\n\t\tconst voxelCount = this._voxelCountNode;\n\t\tconst size = this._getLevelSize( 0 );\n\t\tconst voxelSize = this.voxelSizeNode;\n\n\t\tconst directTexture = this._directTexture;\n\t\tconst sourceTexture = this._getRadianceTexture( 1 - index );\n\t\tconst targetTexture = this._getRadianceTexture( index );\n\n\t\tconst trace = createConeTracer( this, {\n\t\t\tradianceNode: texture3D( sourceTexture ),\n\t\t\tdirectionalNode: this._directional === true ? texture3D( this._getDirectionalTexture( 1 - index ) ) : null\n\t\t} );\n\t\tconst traceDistance = this._traceDistance;\n\t\tconst tanHalfAngle = this.bounceConeAngle.mul( 0.5 ).radians().tan();\n\n\t\treturn Fn( () => {\n\n\t\t\tIf( instanceIndex.lessThan( voxelCount ), () => {\n\n\t\t\t\tconst coords = this._coords( instanceIndex, size ).toConst();\n\t\t\t\tconst bits = occupancy.element( instanceIndex ).toConst();\n\t\t\t\tconst result = vec4( 0 ).toVar();\n\n\t\t\t\tIf( bits.notEqual( uint( 0 ) ), () => {\n\n\t\t\t\t\tconst { position, normal, albedo } = this._surface( coords, triangleIds.element( instanceIndex ) );\n\n\t\t\t\t\tconst direct = texture3D( directTexture, vec3( coords ).add( 0.5 ).div( vec3( size[ 0 ], size[ 1 ], size[ 2 ] ) ), float( 0 ) ).toConst();\n\n\t\t\t\t\tconst rotation = hash( instanceIndex ).toConst();\n\t\t\t\t\tconst origin = position.add( normal.mul( voxelSize.mul( 1.5 ) ) ).toConst();\n\n\t\t\t\t\tconst { color } = gather( trace, origin, normal, BOUNCE_CONE_COUNT, tanHalfAngle, traceDistance, rotation, 0.5 );\n\n\t\t\t\t\tconst bounce = albedo.mul( color );\n\n\t\t\t\t\tresult.assign( vec4( direct.rgb.add( bounce.mul( direct.a ) ), direct.a ) );\n\n\t\t\t\t} );\n\n\t\t\t\ttextureStore( targetTexture, coords, result );\n\n\t\t\t} );\n\n\t\t} )().compute( this._voxelCount ).setName( 'VXGI.Bounce' );\n\n\t}\n\n}\n\nexport { VXGIVolume };\n","import { RenderTarget, Vector2, Vector3, Node, QuadMesh, NodeMaterial, RendererUtils, HalfFloatType, RGBAFormat, RedFormat, UnsignedByteType } from 'three/webgpu';\nimport { Fn, NodeUpdateType, uniform, reference, vec2, vec4, float, uv, mix, passTexture, getViewPosition, getNormalFromDepth, screenCoordinate, interleavedGradientNoise, normalize, floor, exp2, pow, PI, Loop, If, Break, property, outputStruct, context, projectionDepth } from 'three/tsl';\n\nimport { VXGIVolume } from './VXGIVolume.js';\nimport { createConeTracer, gather, intersectVolume, sampleDirectional } from './VXGIConeTracer.js';\n\nconst _quadMesh = /*@__PURE__*/ new QuadMesh();\nconst _size = /*@__PURE__*/ new Vector2();\n\nconst TEMPORAL_SHIFT = 5.588238;\nconst TEMPORAL_CYCLE = 64;\n\nlet _rendererState;\n\nconst _neutralContext = /*@__PURE__*/ context();\n\n/**\n * Post processing node for voxel based global illumination. The scene is voxelized into a\n * {@link VXGIVolume} and indirect diffuse light and ambient occlusion are gathered per\n * pixel with approximate voxel cone tracing.\n *\n * The node is a middle path between SSGI and Light Probe Grids:\n *\n * - Compared to `SSGINode` it is free of screen-space artifacts and provides noticeably more\n * consistent lighting, since off-screen surfaces and thin occluders contribute.\n * However, it is less dynamic: objects should stay static, because geometry changes require\n * a re-voxelization (`needsUpdate = true`) which is too expensive for per-frame animation.\n * - Compared to `LightProbeGrid` it supports dynamic lighting without a new baking process and\n * produces a better overall lighting quality with less light bleeding. However, it is more\n * expensive and therefore less suitable for performance restricted use cases.\n *\n * The quality/performance of the effect mainly depend on the voxel resolution, the number of cones\n * traced per pixel as well as the apeture of the cones.\n *\n * Lights and their shadow maps are picked up automatically. Only direct lights are injected.\n *\n * References:\n * - {@link https://research.nvidia.com/publication/2011-09_interactive-indirect-illumination-using-voxel-cone-tracing}:\n * Crassin et al., Interactive Indirect Illumination Using Voxel Cone Tracing, Pacific Graphics 2011.\n *\n * Note: This node can only be used with `WebGPURenderer` and a WebGPU backend.\n *\n * @augments Node\n * @three_import import { vxgi } from 'three/addons/lighting/vxgi/VXGINode.js';\n */\nclass VXGINode extends Node {\n\n\tstatic get type() {\n\n\t\treturn 'VXGINode';\n\n\t}\n\n\t/**\n\t * Constructs a new voxel GI node.\n\t *\n\t * @param {TextureNode} depthNode - A texture node that represents the scene's depth.\n\t * @param {?TextureNode} normalNode - A texture node that represents the scene's view space normals.\n\t * @param {Scene} scene - The scene to voxelize.\n\t * @param {Camera} camera - The camera the scene is rendered with.\n\t * @param {number} [resolution=128] - Number of voxels along the longest axis of the volume. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer.\n\t */\n\tconstructor( depthNode, normalNode, scene, camera, resolution = 128 ) {\n\n\t\tsuper( 'vec4' );\n\n\t\t/**\n\t\t * A node that represents the scene's depth.\n\t\t *\n\t\t * @type {TextureNode}\n\t\t */\n\t\tthis.depthNode = depthNode;\n\n\t\t/**\n\t\t * A node that represents the scene's normals. If `null`, normals are reconstructed from depth.\n\t\t *\n\t\t * @type {?TextureNode}\n\t\t */\n\t\tthis.normalNode = normalNode;\n\n\t\t/**\n\t\t * The scene to voxelize.\n\t\t *\n\t\t * @type {Scene}\n\t\t */\n\t\tthis.scene = scene;\n\n\t\t/**\n\t\t * The camera the scene is rendered with.\n\t\t *\n\t\t * @type {Camera}\n\t\t */\n\t\tthis.camera = camera;\n\n\t\t/**\n\t\t * The voxel volume. Use it to configure bounds, layers and bounces.\n\t\t *\n\t\t * @type {VXGIVolume}\n\t\t */\n\t\tthis.volume = new VXGIVolume( resolution );\n\n\t\t/**\n\t\t * The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders\n\t\t * its effect once per frame in `updateBefore()`.\n\t\t *\n\t\t * @type {string}\n\t\t * @default 'frame'\n\t\t */\n\t\tthis.updateBeforeType = NodeUpdateType.FRAME;\n\n\t\t/**\n\t\t * Number of cones traced per pixel. Should be in the range `[2, 8]`.\n\t\t *\n\t\t * Mainly defines the quality and precision of the Voxel Cone Tracing. A value of\n\t\t * `2` - `4` is the recommended setting. Use `2` for performance restricted use cases.\n\t\t *\n\t\t * @type {UniformNode<uint>}\n\t\t * @default 3\n\t\t */\n\t\tthis.coneCount = uniform( 3, 'uint' );\n\n\t\t/**\n\t\t * Aperture of the diffuse cones in degrees. Wider cones are faster (fewer steps) but leak\n\t\t * and over-occlude more, narrow cones are more precise but noisier and take more steps.\n\t\t * Choose it together with {@link VXGINode#coneCount}. Should be in the range `[10, 90]`.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 40\n\t\t */\n\t\tthis.coneAngle = uniform( 40 );\n\n\t\t/**\n\t\t * Intensity of the indirect diffuse irradiance.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.giIntensity = uniform( 1 );\n\n\t\t/**\n\t\t * Power function applied to AO to make it appear darker/lighter.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.aoIntensity = uniform( 1 );\n\n\t\t/**\n\t\t * The darkest value the ambient occlusion can reach. Lifts creases and contact regions out\n\t\t * of pure black, which voxel-traced occlusion tends to overestimate at the resolution of\n\t\t * a voxel. `0` keeps the full occlusion range.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0\n\t\t */\n\t\tthis.aoMinVisibility = uniform( 0 );\n\n\t\t/**\n\t\t * Occlusion is weighted by `1 / ( 1 + distance / aoDistance )` for AO, so occluders at this\n\t\t * world-space distance count half. `0` disables the falloff.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1\n\t\t */\n\t\tthis.aoDistance = uniform( 1 );\n\n\t\t/**\n\t\t * Offset of the cone origins along the surface normal in voxels. The surface's own voxel\n\t\t * can extend up to half a voxel above the surface and the trilinear footprint of a sample\n\t\t * spans another half voxel, so 1.5 voxels avoid self-occlusion in every case.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 1.5\n\t\t */\n\t\tthis.normalOffset = uniform( 1.5 );\n\n\t\t/**\n\t\t * Debug visualization of the volume: `0` = off, `1` = radiance voxels, `2` = per-axis opacity voxels.\n\t\t * The visualization replaces the GI output.\n\t\t *\n\t\t * @type {UniformNode<int>}\n\t\t * @default 0\n\t\t */\n\t\tthis.debug = uniform( 0, 'int' );\n\n\t\t/**\n\t\t * The mip level shown by the debug visualization.\n\t\t *\n\t\t * @type {UniformNode<float>}\n\t\t * @default 0\n\t\t */\n\t\tthis.debugLevel = uniform( 0 );\n\n\t\t/**\n\t\t * Whether to use temporal filtering or not. Setting this property to `true` requires the\n\t\t * usage of `TRAANode`. Cone directions are then rotated per frame to converge the noise.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.useTemporalFiltering = true;\n\n\t\t// private uniforms\n\n\t\tthis._resolution = uniform( new Vector2() );\n\t\tthis._frame = uniform( 0 );\n\t\tthis._cameraProjectionMatrix = uniform( camera.projectionMatrix );\n\t\tthis._cameraProjectionMatrixInverse = uniform( camera.projectionMatrixInverse );\n\t\tthis._cameraWorldMatrix = uniform( camera.matrixWorld );\n\t\tthis._cameraPosition = uniform( new Vector3() ).onRenderUpdate( ( _, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );\n\t\tthis._cameraNear = reference( 'near', 'float', camera );\n\t\tthis._cameraFar = reference( 'far', 'float', camera );\n\n\t\t/**\n\t\t * The render target the effect is rendered into. The first texture holds the AO,\n\t\t * the second one the GI.\n\t\t *\n\t\t * @private\n\t\t * @type {RenderTarget}\n\t\t */\n\t\tthis._renderTarget = new RenderTarget( 1, 1, { depthBuffer: false, count: 2 } );\n\n\t\tconst aoTexture = this._renderTarget.textures[ 0 ];\n\t\taoTexture.name = 'VXGI.AO';\n\t\taoTexture.type = UnsignedByteType;\n\t\taoTexture.format = RedFormat;\n\n\t\tconst giTexture = this._renderTarget.textures[ 1 ];\n\t\tgiTexture.name = 'VXGI.GI';\n\t\tgiTexture.type = HalfFloatType;\n\t\tgiTexture.format = RGBAFormat;\n\n\t\tthis._material = new NodeMaterial();\n\t\tthis._material.name = 'VXGI';\n\n\t\t// the shared context of the last build and the directional setting the material was built with\n\n\t\tthis._sharedContext = null;\n\t\tthis._directional = null;\n\n\t\tthis._aoNode = passTexture( this, aoTexture );\n\t\tthis._giNode = passTexture( this, giTexture );\n\n\t}\n\n\t/**\n\t * Number of cached indirect bounces. See {@link VXGIVolume#bounces}.\n\t *\n\t * @type {number}\n\t */\n\tget bounces() {\n\n\t\treturn this.volume.bounces;\n\n\t}\n\n\tset bounces( value ) {\n\n\t\tthis.volume.bounces = value;\n\t\tthis.volume.lightingNeedsUpdate = true;\n\n\t}\n\n\t/**\n\t * Whether the coarser radiance levels are filtered directionally to reduce light bleeding\n\t * through thin walls and floors. Off by default since it costs memory and performance.\n\t * See {@link VXGIVolume#directionalRadiance}.\n\t *\n\t * @type {boolean}\n\t */\n\tget directionalRadiance() {\n\n\t\treturn this.volume.directionalRadiance;\n\n\t}\n\n\tset directionalRadiance( value ) {\n\n\t\tthis.volume.directionalRadiance = value;\n\n\t}\n\n\t/**\n\t * Set to `true` to re-voxelize the scene in the next frame.\n\t *\n\t * @type {boolean}\n\t */\n\tget needsUpdate() {\n\n\t\treturn this.volume.needsUpdate;\n\n\t}\n\n\tset needsUpdate( value ) {\n\n\t\tthis.volume.needsUpdate = value;\n\n\t}\n\n\t/**\n\t * Set to `true` to re-inject lighting in the next frame.\n\t *\n\t * @type {boolean}\n\t */\n\tget lightingNeedsUpdate() {\n\n\t\treturn this.volume.lightingNeedsUpdate;\n\n\t}\n\n\tset lightingNeedsUpdate( value ) {\n\n\t\tthis.volume.lightingNeedsUpdate = value;\n\n\t}\n\n\t/**\n\t * Returns the AO result of the effect as a texture node.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the AO result of the effect.\n\t */\n\tgetAONode() {\n\n\t\treturn this._aoNode;\n\n\t}\n\n\t/**\n\t * Returns the GI result of the effect as a texture node. The texture holds the indirect\n\t * diffuse irradiance, ready to be added to the lighting via `builtinGIContext()`.\n\t *\n\t * @return {PassTextureNode} A texture node that represents the GI result of the effect.\n\t */\n\tgetGINode() {\n\n\t\treturn this._giNode;\n\n\t}\n\n\t/**\n\t * Sets the size of the effect.\n\t *\n\t * @param {number} width - The width of the effect.\n\t * @param {number} height - The height of the effect.\n\t */\n\tsetSize( width, height ) {\n\n\t\tthis._resolution.value.set( width, height );\n\t\tthis._renderTarget.setSize( width, height );\n\n\t}\n\n\t/**\n\t * This method is used to render the effect once per frame.\n\t *\n\t * @param {NodeFrame} frame - The current node frame.\n\t */\n\tupdateBefore( frame ) {\n\n\t\tconst { renderer } = frame;\n\n\t\t_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );\n\n\t\t// this node is usually updated while a scene pass renders whose context injects the\n\t\t// AO/GI of this node into the materials; the nested renders below must not inherit it\n\n\t\tconst currentContextNode = renderer.contextNode;\n\t\trenderer.contextNode = _neutralContext;\n\n\t\t//\n\n\t\tconst size = renderer.getDrawingBufferSize( _size );\n\t\tthis.setSize( size.width, size.height );\n\n\t\t// voxelization and light injection\n\n\t\tthis.volume.update( renderer, this.scene );\n\n\t\t// the sampling code depends on the volume's directional setting\n\n\t\tif ( this._sharedContext !== null && this._directional !== this.volume.directionalRadiance ) {\n\n\t\t\tthis._setupMaterial();\n\n\t\t}\n\n\t\t// update temporal uniforms\n\n\t\tif ( this.useTemporalFiltering === true ) {\n\n\t\t\tthis._frame.value = frame.frameId % TEMPORAL_CYCLE;\n\n\t\t} else {\n\n\t\t\tthis._frame.value = 0;\n\n\t\t}\n\n\t\t//\n\n\t\t_quadMesh.material = this._material;\n\t\t_quadMesh.name = 'VXGI';\n\n\t\t// clear (white for the AO attachment)\n\n\t\trenderer.setClearColor( 0xffffff, 1 );\n\n\t\trenderer.setRenderTarget( this._renderTarget );\n\t\t_quadMesh.render( renderer );\n\n\t\t// restore\n\n\t\trenderer.contextNode = currentContextNode;\n\n\t\tRendererUtils.restoreRendererState( renderer, _rendererState );\n\n\t}\n\n\t/**\n\t * This method is used to setup the effect's TSL code.\n\t *\n\t * @param {NodeBuilder} builder - The current node builder.\n\t * @return {PassTextureNode}\n\t */\n\tsetup( builder ) {\n\n\t\tthis._sharedContext = builder.getSharedContext();\n\t\tthis._setupMaterial();\n\n\t\treturn this._aoNode;\n\n\t}\n\n\t/**\n\t * Builds the TSL code of the effect into the internal pass material.\n\t *\n\t * @private\n\t */\n\t_setupMaterial() {\n\n\t\tconst volume = this.volume;\n\t\tconst directional = this._directional = volume.directionalRadiance;\n\t\tconst uvNode = uv();\n\n\t\tconst sampleDepth = ( uv ) => projectionDepth( this.depthNode.sample( uv ).r, this._cameraNear, this._cameraFar );\n\n\t\tconst sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.sample( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );\n\n\t\tconst voxelSize = volume.voxelSizeNode;\n\t\tconst projectionMatrixInverse = this._cameraProjectionMatrixInverse;\n\n\t\tconst trace = createConeTracer( volume, {\n\t\t\tradianceNode: volume.radianceNode,\n\t\t\tdirectionalNode: directional === true ? volume.directionalNode : null\n\t\t} );\n\n\t\tconst aoField = property( 'float' );\n\t\tconst giField = property( 'vec4' );\n\n\t\tconst outputNode = outputStruct( aoField, giField );\n\n\t\tconst gi = Fn( () => {\n\n\t\t\tconst depth = sampleDepth( uvNode ).toConst();\n\n\t\t\tdepth.greaterThanEqual( 1.0 ).discard();\n\n\t\t\tconst viewPosition = getViewPosition( uvNode, depth, projectionMatrixInverse ).toConst();\n\t\t\tconst worldPosition = this._cameraWorldMatrix.mul( vec4( viewPosition, 1 ) ).xyz.toConst();\n\t\t\tconst viewNormal = sampleNormal( uvNode ).toConst();\n\t\t\tconst worldNormal = normalize( this._cameraWorldMatrix.mul( vec4( viewNormal, 0 ) ).xyz ).toConst();\n\n\t\t\t// interleaved gradient noise for both values: its spatial structure converges well under temporal filtering\n\n\t\t\tconst temporalShift = this._frame.mul( TEMPORAL_SHIFT ).toConst();\n\t\t\tconst rotationNoise = interleavedGradientNoise( screenCoordinate.add( temporalShift ) ).toConst();\n\t\t\tconst elevationNoise = interleavedGradientNoise( screenCoordinate.add( temporalShift ).add( vec2( 5.588238, 3.14159 ) ) ).toConst();\n\n\t\t\tconst CONE_COUNT = this.coneCount.toConst();\n\t\t\tconst tanHalfAngle = this.coneAngle.mul( 0.5 ).radians().tan().toConst();\n\t\t\tconst traceDistance = volume.traceDistanceNode;\n\t\t\tconst aoDistance = this.aoDistance;\n\t\t\tconst origin = worldPosition.add( worldNormal.mul( voxelSize.mul( this.normalOffset ) ) ).toConst();\n\n\t\t\tconst { color: radiance, ao: occlusion } = gather( trace, origin, worldNormal, CONE_COUNT, tanHalfAngle, traceDistance, rotationNoise, elevationNoise, aoDistance );\n\n\t\t\t// the mean radiance over the cosine-weighted hemisphere times PI is the irradiance\n\n\t\t\tconst color = radiance.mul( this.giIntensity.mul( PI ) ).toVar();\n\n\t\t\tconst ao = mix( this.aoMinVisibility, float( 1 ), pow( occlusion.oneMinus().clamp(), this.aoIntensity ) ).toVar();\n\n\t\t\t// debug visualization: march the voxels from the camera\n\n\t\t\tIf( this.debug.greaterThan( 0 ), () => {\n\n\t\t\t\tconst cameraPosition = this._cameraPosition;\n\t\t\t\tconst direction = normalize( worldPosition.sub( cameraPosition ) ).toConst();\n\t\t\t\tconst surfaceDistance = worldPosition.sub( cameraPosition ).length().toConst();\n\t\t\t\tconst level = this.debugLevel.toConst();\n\t\t\t\tconst texel = voxelSize.mul( exp2( level ) ).toConst();\n\t\t\t\tconst levelSize = volume.volumeSizeNode.div( texel ).toConst();\n\t\t\t\tconst boundsMin = volume.boundsMinNode;\n\n\t\t\t\tconst { tEnter, tExit } = intersectVolume( volume, cameraPosition, direction );\n\t\t\t\tconst tMax = tExit.min( surfaceDistance ).toConst();\n\t\t\t\tconst t = tEnter.toVar();\n\n\t\t\t\tcolor.assign( 0 );\n\t\t\t\tao.assign( 1 );\n\n\t\t\t\tLoop( { start: 0, end: 512, type: 'int', condition: '<', name: 's' }, () => {\n\n\t\t\t\t\tIf( t.greaterThanEqual( tMax ), () => {\n\n\t\t\t\t\t\tBreak();\n\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst uvw = cameraPosition.add( direction.mul( t ) ).sub( boundsMin ).div( volume.volumeSizeNode );\n\t\t\t\t\tconst snapped = floor( uvw.mul( levelSize ) ).add( 0.5 ).div( levelSize ).toConst();\n\n\t\t\t\t\tIf( this.debug.equal( 1 ), () => {\n\n\t\t\t\t\t\tlet radiance;\n\n\t\t\t\t\t\tif ( directional === false ) {\n\n\t\t\t\t\t\t\tradiance = volume.radianceNode.sample( snapped ).level( level ).toConst();\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tradiance = vec4( 0 ).toVar();\n\n\t\t\t\t\t\t\tIf( level.lessThan( 1 ), () => {\n\n\t\t\t\t\t\t\t\tradiance.assign( volume.radianceNode.sample( snapped ).level( float( 0 ) ) );\n\n\t\t\t\t\t\t\t} ).Else( () => {\n\n\t\t\t\t\t\t\t\tradiance.assign( sampleDirectional( volume, volume.directionalNode, snapped, level.sub( 1 ), direction ) );\n\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tIf( radiance.a.greaterThan( 0.01 ), () => {\n\n\t\t\t\t\t\t\tcolor.assign( radiance.rgb.div( radiance.a ) );\n\t\t\t\t\t\t\tBreak();\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} ).Else( () => {\n\n\t\t\t\t\t\tconst opacity = volume.opacityNode.sample( snapped ).level( level ).toConst();\n\n\t\t\t\t\t\tIf( opacity.w.greaterThan( 0.01 ), () => {\n\n\t\t\t\t\t\t\tcolor.assign( opacity.xyz );\n\t\t\t\t\t\t\tBreak();\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} );\n\n\t\t\t\t\tt.addAssign( texel.mul( 0.25 ) );\n\n\t\t\t\t} );\n\n\t\t\t} );\n\n\t\t\taoField.assign( ao );\n\t\t\tgiField.assign( vec4( color, 1 ) );\n\n\t\t\treturn vec4( 0 );\n\n\t\t} );\n\n\t\tthis._material.contextNode = context( this._sharedContext );\n\t\tthis._material.colorNode = gi();\n\t\tthis._material.outputNode = outputNode;\n\t\tthis._material.needsUpdate = true;\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the effect is no longer required.\n\t */\n\tdispose() {\n\n\t\tsuper.dispose();\n\n\t\tthis._renderTarget.dispose();\n\t\tthis._material.dispose();\n\t\tthis.volume.dispose();\n\n\t}\n\n}\n\nexport default VXGINode;\n\n/**\n * TSL function for creating a voxel GI effect.\n *\n * @tsl\n * @function\n * @param {TextureNode} depthNode - A texture node that represents the scene's depth.\n * @param {?TextureNode} normalNode - A texture node that represents the scene's view space normals.\n * @param {Scene} scene - The scene to voxelize.\n * @param {Camera} camera - The camera the scene is rendered with.\n * @param {number} [resolution=128] - Number of voxels along the longest axis of the volume. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer.\n * @returns {VXGINode}\n */\nexport const vxgi = ( depthNode, normalNode, scene, camera, resolution ) => new VXGINode( depthNode, normalNode, scene, camera, resolution );\n","import { RoomleWebGPURenderPass } from './roomle-webgpu-render-pass';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport type { Camera, Scene } from 'three';\nimport { PerspectiveCamera } from 'three';\nimport type { Node, PassNode, UniformNode } from 'three/webgpu';\nimport type { WebGPUDebugMode } from '../roomle-webgpu-renderer';\nimport {\n builtinGIContext,\n pass,\n mrt,\n packNormalToRGB,\n normalView,\n sample,\n screenUV,\n uniform,\n unpackRGBToNormal,\n vec3,\n vec4,\n} from 'three/tsl';\nimport type VXGINode from 'three/examples/jsm/lighting/vxgi/VXGINode.js';\nimport { vxgi } from 'three/examples/jsm/lighting/vxgi/VXGINode.js';\nimport { LAYER } from '../../webgl/layer';\n\nexport interface VxgiPassParameters {\n coneCount: number;\n coneAngle: number;\n volumeStepScale: number;\n volumeMaxDistance: number;\n normalOffset: number;\n aoIntensity: number;\n giIntensity: number;\n bounces: number;\n directionalRadiance: boolean;\n useTemporalFiltering: boolean;\n vxgiResolution: number;\n}\n\nexport interface VxgiPerformanceParameters {\n coneCount: number;\n coneAngle: number;\n}\n\nexport class VxgiRenderPass extends RoomleWebGPURenderPass {\n static readonly passId = 'VxgiRenderPass';\n override readonly passId = VxgiRenderPass.passId;\n private vxgiNode: VXGINode | undefined = undefined;\n private readonly vxgiDebug: UniformNode<'int', number>;\n private readonly vxgiDebugLevel: UniformNode<'float', number>;\n private readonly coneCount: UniformNode<'uint', number>;\n private readonly coneAngle: UniformNode<'float', number>;\n private readonly volumeStepScale: UniformNode<'float', number>;\n private readonly volumeMaxDistance: UniformNode<'float', number>;\n private readonly normalOffset: UniformNode<'float', number>;\n private readonly aoIntensity: UniformNode<'float', number>;\n private readonly giIntensity: UniformNode<'float', number>;\n private readonly bounces: number;\n private readonly directionalRadiance: boolean;\n private readonly useTemporalFiltering: boolean;\n private readonly vxgiResolution: number;\n\n constructor(params: VxgiPassParameters) {\n super();\n this.vxgiDebug = uniform(0, 'int');\n this.vxgiDebugLevel = uniform(0);\n this.coneCount = uniform(params.coneCount, 'uint');\n this.coneAngle = uniform(params.coneAngle);\n this.volumeStepScale = uniform(params.volumeStepScale);\n this.volumeMaxDistance = uniform(params.volumeMaxDistance);\n this.normalOffset = uniform(params.normalOffset);\n this.aoIntensity = uniform(params.aoIntensity);\n this.giIntensity = uniform(params.giIntensity);\n this.bounces = params.bounces;\n this.directionalRadiance = params.directionalRadiance;\n this.useTemporalFiltering = params.useTemporalFiltering;\n this.vxgiResolution = params.vxgiResolution;\n }\n\n public updatePerformanceParameters(params: VxgiPerformanceParameters): void {\n this.coneCount.value = params.coneCount;\n this.coneAngle.value = params.coneAngle;\n }\n\n override addParametersToGUI(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const gui = renderPassSettings.addFolder('VXGI Settings');\n gui\n .add(this.vxgiDebug, 'value', 0, 2, 1)\n .name('voxel view')\n .onChange(() => updateCallback());\n gui\n .add(this.vxgiDebugLevel, 'value', 0, 4, 1)\n .name('debug level')\n .onChange(() => updateCallback());\n gui\n .add(this.coneCount, 'value', 2, 8, 1)\n .name('cone count')\n .onChange(() => updateCallback());\n gui\n .add(this.coneAngle, 'value', 10, 90)\n .name('cone angle')\n .onChange(() => updateCallback());\n gui\n .add(this.volumeStepScale, 'value', 0.25, 2)\n .name('step scale')\n .onChange(() => updateCallback());\n gui\n .add(this.volumeMaxDistance, 'value', 0, 50)\n .name('max distance')\n .onChange(() => updateCallback());\n gui\n .add(this.normalOffset, 'value', 0, 4)\n .name('normal offset')\n .onChange(() => updateCallback());\n gui\n .add(this.aoIntensity, 'value', 0, 4)\n .name('AO intensity')\n .onChange(() => updateCallback());\n gui\n .add(this.giIntensity, 'value', 0, 4)\n .name('GI intensity')\n .onChange(() => updateCallback());\n }\n\n public revoxelize(): void {\n console.log('revoxelizing scene for vxgi...');\n if (this.vxgiNode) {\n this.vxgiNode.needsUpdate = true;\n }\n }\n\n override assemble(\n basePassNode: PassNode,\n currentNode: Node<'vec4'>,\n scene: Scene,\n camera: Camera,\n debugMode: WebGPUDebugMode,\n ): Node<'vec4'> {\n if (!(camera instanceof PerspectiveCamera)) {\n return currentNode; // no vxgi for orthographic camera\n }\n if (this.coneCount.value === 0) {\n return currentNode; // VXGINode divides by the cone count\n }\n\n const prePass = pass(scene, camera);\n prePass.name = 'VXGI Pre-Pass';\n prePass.transparent = false;\n prePass.setMRT(mrt({ output: packNormalToRGB(normalView) }));\n\n const prePassDepth = prePass.getTextureNode('depth');\n const prePassNormal = sample((uv) => {\n return unpackRGBToNormal(prePass.getTextureNode().sample(uv));\n });\n\n this.vxgiNode = vxgi(\n prePassDepth,\n prePassNormal,\n scene,\n camera,\n this.vxgiResolution,\n );\n // @ts-expect-error -- three-types messed this one up, works fine but shows an error\n this.vxgiNode.debug = this.vxgiDebug;\n this.vxgiNode.debugLevel = this.vxgiDebugLevel;\n this.vxgiNode.coneCount = this.coneCount;\n this.vxgiNode.coneAngle = this.coneAngle;\n this.vxgiNode.volume.stepScale = this.volumeStepScale;\n this.vxgiNode.volume.maxDistance = this.volumeMaxDistance;\n this.vxgiNode.normalOffset = this.normalOffset;\n this.vxgiNode.aoIntensity = this.aoIntensity;\n this.vxgiNode.giIntensity = this.giIntensity;\n this.vxgiNode.bounces = this.bounces;\n this.vxgiNode.directionalRadiance = this.directionalRadiance;\n this.vxgiNode.useTemporalFiltering = this.useTemporalFiltering;\n\n this.vxgiNode.volume.layers.disableAll();\n this.vxgiNode.volume.layers.enable(LAYER.OBJECT);\n this.vxgiNode.volume.layers.enable(LAYER.COMPONENT);\n this.vxgiNode.volume.layers.enable(LAYER.CONSTRUCTION);\n // also consider invisible walls for ao and gi\n this.vxgiNode.volume.layers.enable(LAYER.SHADOW_ONLY);\n\n const ao = this.vxgiNode.getAONode().toInspector('VXGI / AO');\n const gi = this.vxgiNode.getGINode().toInspector('VXGI / GI');\n\n basePassNode.contextNode = builtinGIContext(\n ao.sample(screenUV).r,\n gi.sample(screenUV).rgb,\n );\n\n if (debugMode === 'ao only') {\n return vec4(vec3(ao.r), 1);\n } else if (debugMode === 'gi only') {\n return vec4(gi.rgb, 1);\n }\n\n return currentNode;\n }\n}\n","import type {\n Box3,\n Camera,\n ColorRepresentation,\n Node,\n Object3D,\n Scene,\n ToneMapping,\n WebGPURenderer,\n PassNode,\n} from 'three/webgpu';\nimport {\n ACESFilmicToneMapping,\n AgXToneMapping,\n CineonToneMapping,\n LinearToneMapping,\n NeutralToneMapping,\n NoToneMapping,\n OrthographicCamera,\n PerspectiveCamera,\n ReinhardToneMapping,\n RenderPipeline,\n RenderTarget,\n} from 'three/webgpu';\nimport {\n diffuseColor,\n mrt,\n normalView,\n output,\n packNormalToRGB,\n pass,\n velocity,\n} from 'three/tsl';\nimport { PlannerRenderMode, RoomleRenderer } from '../roomle-renderer';\nimport type { OutlineCustomParameters } from '../webgl/renderer/scene-renderer';\nimport type { SceneShadingType } from '../webgl/renderer/shading-settings';\nimport { SCENE_SHADING_TYPES } from '../webgl/renderer/shading-settings';\nimport type { RoomleWebGPURenderPass } from './passes/roomle-webgpu-render-pass';\nimport { OutlineRenderPass } from './passes/outline-render-pass';\nimport { Inspector } from 'three/examples/jsm/inspector/Inspector.js';\nimport type DomHelper from '../utils/dom-helper';\nimport inject from '../di/inject';\nimport type { ParametersGroup } from 'three/examples/jsm/inspector/tabs/Parameters.js';\nimport { SsgiRenderPass } from './passes/ssgi-render-pass';\nimport type { Enumify } from '#/common/src/utils/types';\nimport type { CAMERA_TYPE } from '../cameracontrol/camera-type';\nimport type { WebGpuGroundShadowReflectionContainer } from './web-gpu-ground-shadow-reflection-container';\nimport { TraaRenderPass } from './passes/traa-render-pass';\nimport type { WebGPUQualityParameters } from './roomle-webgpu-renderer-quality-levels';\nimport { RoomleWebGPUQualityManager } from './roomle-webgpu-quality-manager';\nimport type InitData from '../utils/init-data';\nimport { getColor } from '../utils/common-utils';\nimport { FogRenderPass } from './passes/fog-render-pass';\nimport { DebugRenderPass } from './passes/debug-render-pass';\nimport type { WebGpuToneMapping } from '../utils/shims';\nimport { WEBGPU_TONE_MAPPINGS } from '../utils/shims';\nimport type { WebGpuGiMode } from '../utils/shims';\nimport { WEBGPU_GI_MODES } from '../utils/shims';\nimport type { WebGpuSkyContainer } from './web-gpu-sky-container';\nimport type { SkyStateTracker } from './sky-state-tracker';\nimport { VxgiRenderPass } from './passes/vxgi-render-pass';\n\nexport { FREEZE_FRAMES_ON_QUALITY_CHANGE } from './roomle-webgpu-quality-manager';\n\n// freeze-frame on traa initialization to avoid black flicker\nexport const FREEZE_FRAMES_ON_TRAA_INITIALIZATION = 10;\n\nconst RENDER_PASS_ORDER = [\n SsgiRenderPass.passId,\n VxgiRenderPass.passId,\n OutlineRenderPass.passId,\n FogRenderPass.passId,\n TraaRenderPass.passId,\n];\n\nconst TONE_MAPPING_BY_CONFIG_VALUE: Record<WebGpuToneMapping, ToneMapping> = {\n [WEBGPU_TONE_MAPPINGS.NONE]: NoToneMapping,\n [WEBGPU_TONE_MAPPINGS.LINEAR]: LinearToneMapping,\n [WEBGPU_TONE_MAPPINGS.REINHARD]: ReinhardToneMapping,\n [WEBGPU_TONE_MAPPINGS.CINEON]: CineonToneMapping,\n [WEBGPU_TONE_MAPPINGS.ACES_FILMIC]: ACESFilmicToneMapping,\n [WEBGPU_TONE_MAPPINGS.AGX]: AgXToneMapping,\n [WEBGPU_TONE_MAPPINGS.NEUTRAL]: NeutralToneMapping,\n};\n\nexport type WebGPUDebugMode =\n | 'off'\n | 'outline'\n | 'direct lighting only'\n | 'ao only'\n | 'gi only'\n | 'denoised ao only'\n | 'denoised gi only'\n | 'without denoise'\n | 'no fog'\n | 'depth'\n | 'velocity';\n\ninterface OutlineColors {\n outlineVisibleEdgeColor: ColorRepresentation;\n outlineHiddenEdgeColor: ColorRepresentation;\n}\n\nexport class RoomleWebGPURenderer extends RoomleRenderer<WebGPURenderer> {\n private readonly renderPipeline: RenderPipeline;\n private passNeedsReassembly = true;\n private debugMode: WebGPUDebugMode = 'off';\n private readonly renderPasses = new Map<string, RoomleWebGPURenderPass>();\n private readonly guiParameterGroups = new Map<string, ParametersGroup>();\n private lastRenderCamera: Camera | undefined = undefined;\n private readonly qualityManager = new RoomleWebGPUQualityManager(\n this.applyQualityParameters.bind(this),\n );\n private freezeFrames = 0;\n private readonly freezeRenderTarget = new RenderTarget();\n private readonly debugRenderPass = new DebugRenderPass();\n private giMode: WebGpuGiMode;\n private voxelsNeedUpdate = false;\n\n @inject\n private declare _domHelper: DomHelper;\n\n @inject\n private declare _webGpuGroundShadowReflection: WebGpuGroundShadowReflectionContainer;\n\n @inject\n private declare _webGpuSkyContainer: WebGpuSkyContainer;\n\n @inject\n private declare _skyStateTracker: SkyStateTracker;\n\n @inject\n private declare _initData: InitData;\n\n constructor(\n creator: string,\n renderer: WebGPURenderer,\n enableGI: boolean,\n outlineColors?: OutlineColors,\n enableTraa: boolean = enableGI,\n ) {\n super(creator, renderer);\n\n this.giMode = this._initData.webGpuConfig.giMode;\n this.renderPipeline = new RenderPipeline(renderer);\n this.applyToneMappingConfig();\n this.enableDefaultRenderPasses(enableGI, outlineColors, enableTraa);\n if (this._initData.webGpuConfig.autoDetectQualityLevel) {\n this.qualityManager\n .autoDetectInitialQualityLevel()\n .then(() => this.qualityManager.applyCurrentQualityLevel(0));\n } else {\n this.qualityManager.applyCurrentQualityLevel(0);\n }\n }\n\n private enableDefaultRenderPasses(\n enableGI: boolean,\n outlineColors: OutlineColors | undefined,\n enableTraa: boolean,\n ) {\n const enableFog = this._initData.webGpuConfig.fog.enabled;\n const transparentBackground = this._initData.transparentBackground;\n\n if (enableGI) {\n // Couple GI temporal filtering to TRAA\n this.enableGiPass(enableTraa);\n }\n if (outlineColors) {\n this.enableOutline(\n outlineColors.outlineVisibleEdgeColor,\n outlineColors.outlineHiddenEdgeColor,\n );\n }\n if (!transparentBackground) {\n if (enableTraa) {\n this.enableTraaPass();\n this.freezeFrames = Math.max(\n this.freezeFrames,\n FREEZE_FRAMES_ON_TRAA_INITIALIZATION,\n );\n }\n if (enableFog) {\n this.enableFogPass();\n }\n }\n }\n\n public async addGroundShadowLightAndFloor(scene: Scene): Promise<void> {\n await this._webGpuGroundShadowReflection.addToScene(scene);\n }\n\n public async addSky(scene: Scene): Promise<void> {\n await this._webGpuSkyContainer.addToScene(scene);\n }\n\n private addRenderPass(renderPass: RoomleWebGPURenderPass): void {\n this.renderPasses.set(renderPass.passId, renderPass);\n this.passNeedsReassembly = true;\n }\n\n public override clearCache(): void {\n return; // not required for webgpu as there is no render cache\n }\n\n public override disableUiInteractionMode(): void {\n return; // for webgl this just disables the ground reflection which does not exist in webgpu mode yet\n }\n\n public override enableUiInteractionMode(): void {\n return; // for webgl this just re-enables the ground reflection which does not exist in webgpu mode yet\n }\n\n public override onReadyForRender(): void {\n const vxgiPass = this.getVxgiPassOrUndefined();\n if (vxgiPass) {\n // fix a visual issue with the wall voxelization\n this.passNeedsReassembly = true;\n }\n }\n\n public override updateBounds(geometryBounds: Box3): void {\n super.updateBounds(geometryBounds);\n this.voxelsNeedUpdate = true;\n }\n\n public override setCameraType(cameraType: Enumify<typeof CAMERA_TYPE>) {\n super.setCameraType(cameraType);\n this.passNeedsReassembly = true;\n }\n\n public override switchToConfigurator() {\n super.switchToConfigurator();\n\n this._webGpuGroundShadowReflection.setFloorVisible(true);\n this._webGpuGroundShadowReflection.setTopLightVisible(true);\n this._webGpuSkyContainer.setVisible(false);\n this._skyStateTracker.notifyEnteredConfigurator();\n\n const shouldEnableFog =\n this._initData.webGpuConfig.fog.enabled &&\n !this._initData.transparentBackground;\n if (shouldEnableFog) {\n this.enableFogPass();\n }\n this.passNeedsReassembly = true;\n }\n\n public override switchToPlanner(renderMode: PlannerRenderMode) {\n super.switchToPlanner(renderMode);\n\n const isSkyEnabled = this._skyStateTracker.isSkyEnabled;\n this._webGpuGroundShadowReflection.setFloorVisible(isSkyEnabled);\n this._webGpuGroundShadowReflection.setTopLightVisible(\n !isSkyEnabled && renderMode !== PlannerRenderMode.Mode2D,\n );\n this._webGpuSkyContainer.setVisible(isSkyEnabled);\n this._skyStateTracker.notifyEnteredPlanner();\n\n this.disableFogPass();\n this.passNeedsReassembly = true;\n }\n\n public override highlightObjects(selectedMeshes: Object3D[]): void {\n this.getOutlinePassOrUndefined()?.highlightObjects(selectedMeshes);\n }\n\n public override render(scene: Scene, camera: Camera): void {\n this.updateCameraProjectionMatrix(camera);\n\n if (this.passNeedsReassembly || this.lastRenderCamera !== camera) {\n this.renderPipeline.outputNode = this.assembleRenderPasses(scene, camera);\n this.renderPipeline.needsUpdate = true;\n this.passNeedsReassembly = false;\n this.lastRenderCamera = camera;\n }\n\n if (this.freezeFrames > 0) {\n this.freezeFrames--;\n this.renderToFreezeTarget();\n return;\n }\n\n if (this.voxelsNeedUpdate && !this.isDragInProgress) {\n this.voxelsNeedUpdate = false;\n this.getVxgiPassOrUndefined()?.revoxelize();\n }\n\n this.renderPipeline.render();\n\n this.qualityManager.manageQualitySettings(\n this._initData.webGpuConfig.autoQualityMinFps,\n this._initData.webGpuConfig.autoQualityMaxFps,\n );\n }\n\n // Keep rendering so the rebuilt pipeline compiles and warms up, but redirect\n // the output to an off-screen target so the canvas keeps showing the last\n // good frame instead of black flickering while the pipeline rebuilds.\n private renderToFreezeTarget(): void {\n const previousRenderTarget = this.renderer.getRenderTarget();\n this.renderer.setRenderTarget(this.freezeRenderTarget);\n this.renderPipeline.render();\n this.renderer.setRenderTarget(previousRenderTarget);\n }\n\n private updateCameraProjectionMatrix(camera: Camera): void {\n if (\n camera instanceof OrthographicCamera ||\n camera instanceof PerspectiveCamera\n ) {\n camera.updateProjectionMatrix();\n }\n }\n\n private assembleRenderPasses(scene: Scene, camera: Camera): Node<'vec4'> {\n const passNode = pass(scene, camera); // always include the scene pass\n let result: Node<'vec4'> = passNode;\n\n this.setupMRT(passNode);\n\n for (const passId of RENDER_PASS_ORDER) {\n const renderPass = this.renderPasses.get(passId);\n if (!renderPass) {\n continue;\n }\n result = renderPass.assemble(\n passNode,\n result,\n scene,\n camera,\n this.debugMode,\n );\n }\n\n return this.debugRenderPass.assemble(\n passNode,\n result,\n scene,\n camera,\n this.debugMode,\n );\n }\n\n private setupMRT(passNode: PassNode): void {\n if (this.getSsgiPassOrUndefined()) {\n passNode.setMRT(\n mrt({\n output: output,\n diffuseColor: diffuseColor,\n normal: packNormalToRGB(normalView),\n velocity: velocity,\n }),\n );\n } else if (this.getVxgiPassOrUndefined()) {\n passNode.setMRT(\n mrt({\n output: output,\n velocity: velocity,\n }),\n );\n }\n }\n\n public override setCustomOutlineParameters(\n customOutlineParameters: OutlineCustomParameters,\n ): void {\n const outlinePass = this.getOutlinePassOrUndefined();\n if (outlinePass) {\n outlinePass.setOutlineColors(\n customOutlineParameters.outlineVisibleEdgeColor,\n customOutlineParameters.outlineHiddenEdgeColor,\n );\n }\n }\n\n public override setGroundShadow(enabled: boolean, _scene: Scene): void {\n if (!this.isConfiguratorMode) {\n return; // only ever show the ground shadow floor in the configurator\n }\n\n this._webGpuGroundShadowReflection.setReceiveShadow(enabled);\n }\n\n private enableOutline(\n visibleEdgeColor: ColorRepresentation,\n hiddenEdgeColor: ColorRepresentation,\n ): void {\n if (this.getOutlinePassOrUndefined()) {\n return;\n }\n\n this.addRenderPass(\n new OutlineRenderPass({\n selectedObjects: [],\n visibleEdgeColor: visibleEdgeColor,\n hiddenEdgeColor: hiddenEdgeColor,\n edgeStrength: 3.0,\n edgeGlow: 0.0,\n edgeThickness: 1.0,\n }),\n );\n }\n\n private getOutlinePassOrUndefined(): OutlineRenderPass | undefined {\n const pass = this.renderPasses.get(OutlineRenderPass.passId);\n if (pass && pass instanceof OutlineRenderPass) {\n return pass;\n }\n return undefined;\n }\n\n private enableGiPass(useTemporalFiltering: boolean): void {\n if (this.giMode === WEBGPU_GI_MODES.SSGI) {\n this.enableSsgiPass(useTemporalFiltering);\n } else {\n this.enableVxgiPass(useTemporalFiltering);\n }\n }\n\n private switchGiMode(giMode: WebGpuGiMode): void {\n if (giMode === this.giMode) {\n return;\n }\n\n const useTemporalFiltering =\n this.renderPasses.get(TraaRenderPass.passId) !== undefined;\n this.renderPasses.delete(SsgiRenderPass.passId);\n this.renderPasses.delete(VxgiRenderPass.passId);\n this.giMode = giMode;\n this.enableGiPass(useTemporalFiltering);\n this.qualityManager.applyCurrentQualityLevel(0);\n }\n\n private enableSsgiPass(useTemporalFiltering: boolean) {\n if (this.renderPasses.get(SsgiRenderPass.passId)) {\n return;\n }\n\n const ssgiConfig = this._initData.webGpuConfig.ssgi;\n\n this.addRenderPass(\n new SsgiRenderPass({\n sliceCount: 2,\n stepCount: 12,\n radius: 8,\n expFactor: 2,\n thickness: 1,\n backfaceLighting: 0,\n aoIntensity: 0.6,\n giIntensity: 4,\n aoDenoiseRadius: ssgiConfig.aoDenoiseRadius,\n giDenoiseRadius: ssgiConfig.giDenoiseRadius,\n useLinearThickness: false,\n useScreenSpaceSampling: true,\n useTemporalFiltering,\n }),\n );\n }\n\n private enableVxgiPass(useTemporalFiltering: boolean) {\n if (this.getVxgiPassOrUndefined()) {\n return;\n }\n\n this.addRenderPass(\n new VxgiRenderPass({\n coneCount: 3,\n coneAngle: 40,\n volumeStepScale: 0.5,\n volumeMaxDistance: 0,\n normalOffset: 1.5,\n aoIntensity: 0.4,\n giIntensity: 1,\n bounces: 1,\n directionalRadiance: false,\n useTemporalFiltering,\n vxgiResolution: 128,\n }),\n );\n }\n\n private enableTraaPass() {\n if (this.renderPasses.get(TraaRenderPass.passId)) {\n return;\n }\n\n this.addRenderPass(new TraaRenderPass());\n }\n\n private enableFogPass() {\n if (this.renderPasses.get(FogRenderPass.passId)) {\n return;\n }\n\n const fogConfig = this._initData.webGpuConfig.fog;\n this.addRenderPass(\n new FogRenderPass({\n color: getColor(\n fogConfig.color ?? this._initData.colors.DEFAULT_BACKGROUND,\n ),\n nearBlend: fogConfig.nearBlend,\n farBlend: fogConfig.farBlend,\n }),\n );\n }\n\n private disableFogPass() {\n const fogRenderPass = this.renderPasses.get(FogRenderPass.passId);\n if (!fogRenderPass || !(fogRenderPass instanceof FogRenderPass)) {\n return;\n }\n fogRenderPass.removeSceneFog();\n this.renderPasses.delete(FogRenderPass.passId);\n }\n\n private applyQualityParameters(\n qualityParameters: WebGPUQualityParameters,\n freezeFrames: number,\n ): void {\n this.freezeFrames = Math.max(freezeFrames, this.freezeFrames);\n\n this.applyPixelRatio(qualityParameters);\n\n this.getSsgiPassOrUndefined()?.updatePerformanceParameters(\n qualityParameters.ssgiPerformanceParameters,\n );\n this.getVxgiPassOrUndefined()?.updatePerformanceParameters(\n qualityParameters.vxgiPerformanceParameters,\n );\n this.passNeedsReassembly = true;\n }\n\n private applyPixelRatio(qualityParameters: WebGPUQualityParameters) {\n const devicePixelRatio = Math.min(\n window?.devicePixelRatio ?? 1,\n qualityParameters.maxDevicePixelRatio,\n );\n const pixelRatioMultiplier = Math.min(\n this._initData.webGpuConfig.pixelRatioMultiplier,\n qualityParameters.maxPixelRatioMultiplier,\n );\n this.renderer.setPixelRatio(pixelRatioMultiplier * devicePixelRatio);\n }\n\n private getSsgiPassOrUndefined(): SsgiRenderPass | undefined {\n const pass = this.renderPasses.get(SsgiRenderPass.passId);\n if (pass && pass instanceof SsgiRenderPass) {\n return pass;\n }\n return undefined;\n }\n\n private getVxgiPassOrUndefined(): VxgiRenderPass | undefined {\n const pass = this.renderPasses.get(VxgiRenderPass.passId);\n if (pass && pass instanceof VxgiRenderPass) {\n return pass;\n }\n return undefined;\n }\n\n public override setShadingType(shadingType: SceneShadingType): void {\n if (shadingType === SCENE_SHADING_TYPES.DEFAULT) {\n return;\n }\n // if bright scene shading is actually used anywhere\n // it can be implemented but will skip for now for webgpu\n console.error('RoomleWebGPURenderer.setShadingType is not implemented yet');\n }\n\n public override showGUI(updateCallback: () => void): void {\n if (this.renderer.inspector instanceof Inspector) {\n return;\n }\n const guiStyle = document.createElement('style');\n guiStyle.innerText =\n '.profiler-toggle,\\n' +\n ' .profiler-mini-panel {\\n' +\n ' left: 15px;\\n' + // webgpu gui should be top left not top right\n ' right: auto !important;\\n' +\n ' }';\n document.head.appendChild(guiStyle);\n\n const inspector = new Inspector();\n this.renderer.inspector = inspector;\n this._domHelper.element?.appendChild(inspector.domElement);\n\n this.addDebugGUI(inspector, updateCallback);\n this.qualityManager.addGUI(inspector, updateCallback);\n\n const renderPassSettings = inspector.createParameters(\n 'Render Pass Settings',\n );\n for (const renderPass of this.renderPasses.values()) {\n renderPass.addParametersToGUI(renderPassSettings, updateCallback);\n }\n this._webGpuGroundShadowReflection.addParametersToGUI(\n renderPassSettings,\n updateCallback,\n );\n this._webGpuSkyContainer.addParametersToGUI(\n renderPassSettings,\n updateCallback,\n );\n this.addToneMappingSettings(renderPassSettings, updateCallback);\n }\n\n private addDebugGUI(inspector: Inspector, updateCallback: () => void): void {\n const debugSettings = inspector.createParameters('Debug Settings');\n const params = { debugMode: this.debugMode };\n debugSettings\n .add(params, 'debugMode', {\n Off: 'off',\n Outline: 'outline',\n Direct: 'direct lighting only',\n Ao: 'ao only',\n Gi: 'gi only',\n DenoisedAo: 'denoised ao only',\n DenoisedGi: 'denoised gi only',\n WithoutDenoise: 'without denoise',\n NoFog: 'no fog',\n Depth: 'depth',\n Velocity: 'velocity',\n } satisfies Record<string, WebGPUDebugMode>)\n .onChange((mode: WebGPUDebugMode) => {\n this.debugMode = mode;\n this.passNeedsReassembly = true;\n updateCallback();\n });\n\n if (\n this.renderPasses.get(SsgiRenderPass.passId) ||\n this.renderPasses.get(VxgiRenderPass.passId)\n ) {\n const giModeParams = { giMode: this.giMode };\n debugSettings\n .add(giModeParams, 'giMode', {\n Vxgi: WEBGPU_GI_MODES.VXGI,\n Ssgi: WEBGPU_GI_MODES.SSGI,\n } satisfies Record<string, WebGpuGiMode>)\n .onChange((giMode: WebGpuGiMode) => {\n this.switchGiMode(giMode);\n updateCallback();\n });\n }\n\n const reassembleButton = {\n reassembleRenderPasses: () => {\n this.passNeedsReassembly = true;\n console.log('Reassembling render passes...');\n updateCallback();\n },\n };\n\n debugSettings.add(reassembleButton, 'reassembleRenderPasses');\n }\n\n private applyToneMappingConfig(): void {\n const { toneMapping, toneMappingExposure } = this._initData.webGpuConfig;\n this.renderer.toneMapping = TONE_MAPPING_BY_CONFIG_VALUE[toneMapping];\n this.renderer.toneMappingExposure = toneMappingExposure;\n }\n\n private addToneMappingSettings(\n renderPassSettings: ParametersGroup,\n updateCallback: () => void,\n ): void {\n const toneMappingSettings = renderPassSettings.addFolder('Tone Mapping');\n const params = {\n toneMapping: this.renderer.toneMapping,\n toneMappingExposure: this.renderer.toneMappingExposure,\n };\n\n toneMappingSettings\n .add(params, 'toneMapping', {\n None: NoToneMapping,\n Linear: LinearToneMapping,\n Reinhard: ReinhardToneMapping,\n Cineon: CineonToneMapping,\n ACESFilmic: ACESFilmicToneMapping,\n AgX: AgXToneMapping,\n Neutral: NeutralToneMapping,\n })\n .onChange((value: ToneMapping) => {\n this.renderer.toneMapping = value;\n this.passNeedsReassembly = true;\n updateCallback();\n });\n\n toneMappingSettings\n .add(params, 'toneMappingExposure', 0, 3, 0.01)\n .onChange((value: number) => {\n this.renderer.toneMappingExposure = value;\n this.passNeedsReassembly = true;\n updateCallback();\n });\n }\n\n public getOrCreateGUIParameters(name: string): ParametersGroup {\n const inspector = this.renderer.inspector;\n if (inspector instanceof Inspector) {\n return (\n this.guiParameterGroups.get(name) ??\n this.createAndCacheGUIParameters(inspector, name)\n );\n }\n throw new Error(\n 'Inspector GUI is not initialized. Call showGUI() before creating parameter groups.',\n );\n }\n\n private createAndCacheGUIParameters(\n inspector: Inspector,\n name: string,\n ): ParametersGroup {\n const parameters = inspector.createParameters(name);\n this.guiParameterGroups.set(name, parameters);\n return parameters;\n }\n}\n"],"x_google_ignoreList":[0,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,24,25,31,32,33,34],"mappings":";;;;;;;;;;AAGA,IAAMA,oBAA0B,IAAI,IAAU,EACxCC,qBAAsB,IAAI,GAAS,EACnC,qBAAkC,IAAI,EAAS,GAAK,EAAK,EACzD,qBAAkC,IAAI,EAAS,GAAK,EAAK,EAE3DC,IAoCE,KAAN,cAA0B,GAAK;CAE9B,WAAW,OAAO;AAEjB,SAAO;;CAeR,YAAa,GAAO,GAAQ,IAAS,EAAE,EAAG;AAEzC,QAAO,OAAQ;EAEf,IAAM,EACL,qBAAkB,EAAE,EACpB,mBAAgB,EAAO,EAAG,EAC1B,cAAW,EAAO,EAAG,EACrB,qBAAkB,MACf;AAmWJ,EA5VA,KAAK,QAAQ,GAOb,KAAK,SAAS,GAOd,KAAK,kBAAkB,GAOvB,KAAK,oBAAoB,GAAY,EAAe,EAOpD,KAAK,eAAe,GAAY,EAAU,EAQ1C,KAAK,kBAAkB,GASvB,KAAK,mBAAmB,GAAe,OAUvC,KAAK,2BAA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